source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Boundary.lean | import Mathlib.AlgebraicTopology.SimplicialSet.StdSimplex
/-!
# The boundary of the standard simplex
We introduce the boundary `∂Δ[n]` of the standard simplex `Δ[n]`.
(These notations become available by doing `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 u
open Simplicial
namespace SSet
/-- The boundary `∂Δ[n]` of the `n`-th standard simplex consists of
all `m`-simplices of `stdSimplex n` that are not surjective
(when viewed as monotone function `m → n`). -/
def boundary (n : ℕ) : (Δ[n] : SSet.{u}).Subcomplex where
obj _ := setOf (fun s ↦ ¬Function.Surjective (stdSimplex.asOrderHom s))
map _ _ hs h := hs (Function.Surjective.of_comp h)
/-- The boundary `∂Δ[n]` of the `n`-th standard simplex -/
scoped[Simplicial] notation3 "∂Δ[" n "]" => SSet.boundary n
lemma boundary_eq_iSup (n : ℕ) :
boundary.{u} n = ⨆ (i : Fin (n + 1)), stdSimplex.face {i}ᶜ := by
ext
simp [stdSimplex.face_obj, boundary, Function.Surjective]
tauto
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Subcomplex.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Basic
import Mathlib.CategoryTheory.Subpresheaf.OfSection
/-!
# Subcomplexes of a simplicial set
Given a simplicial set `X`, this file defines the type `X.Subcomplex`
of subcomplexes of `X` as an abbreviation for `Subpresheaf X`.
It also introduces a coercion from `X.Subcomplex` to `SSet`.
## Implementation note
`SSet.{u}` is defined as `Cᵒᵖ ⥤ Type u`, but it is not an abbreviation.
This is the reason why `Subpresheaf.ι` is redefined here as `Subcomplex.ι`
so that this morphism appears as a morphism in `SSet` instead of a morphism
in the category of presheaves.
-/
universe u
open CategoryTheory Simplicial Limits
namespace SSet
-- Note: this could be obtained as `inferInstanceAs (Balanced (_ ⥤ _))`
-- by importing `Mathlib.CategoryTheory.Adhesive`, but we give a
-- different proof so as to reduce imports
instance : Balanced SSet.{u} where
isIso_of_mono_of_epi f _ _ := by
rw [NatTrans.isIso_iff_isIso_app]
intro
rw [isIso_iff_bijective]
constructor
· rw [← mono_iff_injective]
infer_instance
· rw [← epi_iff_surjective]
infer_instance
variable (X Y : SSet.{u})
/-- The complete lattice of subcomplexes of a simplicial set. -/
abbrev Subcomplex := Subpresheaf X
variable {X Y}
namespace Subcomplex
/-- The underlying simplicial set of a subcomplex. -/
abbrev toSSet (A : X.Subcomplex) : SSet.{u} := A.toPresheaf
instance : CoeOut X.Subcomplex SSet.{u} where
coe := fun S ↦ S.toSSet
/-- If `A : Subcomplex X`, this is the inclusion `A ⟶ X` in the category `SSet`. -/
abbrev ι (A : Subcomplex X) : Quiver.Hom (V := SSet) A X := Subpresheaf.ι A
instance (A : X.Subcomplex) : Mono A.ι :=
inferInstanceAs (Mono (Subpresheaf.ι A))
section
variable {S₁ S₂ : X.Subcomplex} (h : S₁ ≤ S₂)
/-- Given an inequality `S₁ ≤ S₂` between subcomplexes of a simplicial set,
this is the induced morphism in the category `SSet`. -/
abbrev homOfLE : (S₁ : SSet.{u}) ⟶ (S₂ : SSet.{u}) := Subpresheaf.homOfLe h
@[reassoc]
lemma homOfLE_comp {S₃ : X.Subcomplex} (h' : S₂ ≤ S₃) :
homOfLE h ≫ homOfLE h' = homOfLE (h.trans h') := rfl
variable (S₁) in
@[simp]
lemma homOfLE_refl : homOfLE (by rfl : S₁ ≤ S₁) = 𝟙 _ := rfl
@[simp]
lemma homOfLE_app_val (Δ : SimplexCategoryᵒᵖ) (x : S₁.obj Δ) :
((homOfLE h).app Δ x).val = x.val := rfl
@[reassoc (attr := simp)]
lemma homOfLE_ι : homOfLE h ≫ S₂.ι = S₁.ι := rfl
instance mono_homOfLE : Mono (homOfLE h) := mono_of_mono_fac (homOfLE_ι h)
/-- This is the isomorphism of simplicial sets corresponding to
an equality of subcomplexes. -/
@[simps]
def eqToIso (h : S₁ = S₂) : (S₁ : SSet.{u}) ≅ S₂ where
hom := homOfLE h.le
inv := homOfLE h.symm.le
end
/-- The functor which sends `A : X.Subcomplex` to `A.toSSet`. -/
@[simps]
def toSSetFunctor : X.Subcomplex ⥤ SSet.{u} where
obj A := A
map h := homOfLE (leOfHom h)
section
variable (X)
/-- If `X : SSet`, this is the isomorphism of simplicial sets
from `⊤ : X.Subcomplex` to `X`. -/
@[simps! inv_app_coe]
def topIso : ((⊤ : X.Subcomplex) : SSet) ≅ X :=
NatIso.ofComponents (fun n ↦ (Equiv.Set.univ (X.obj n)).toIso)
@[simp]
lemma topIso_hom : (topIso X).hom = Subcomplex.ι _ := rfl
@[reassoc (attr := simp)]
lemma topIso_inv_ι : (topIso X).inv ≫ Subpresheaf.ι _ = 𝟙 _ := rfl
end
instance : Subsingleton (((⊥ : X.Subcomplex) : SSet.{u}) ⟶ Y) where
allEq _ _ := by ext _ ⟨_, h⟩; simp at h
instance : Unique (((⊥ : X.Subcomplex) : SSet.{u}) ⟶ Y) where
default :=
{ app := by rintro _ ⟨_, h⟩; simp at h
naturality _ _ _ := by ext ⟨_, h⟩; simp at h }
uniq := by subsingleton
/-- If `X` is a simplicial set, then the empty subcomplex of `X` is an initial
object in `SSet`. -/
def isInitialBot : IsInitial ((⊥ : X.Subcomplex) : SSet.{u}) :=
IsInitial.ofUnique _
/-- The subcomplex of a simplicial set that is generated by a simplex. -/
abbrev ofSimplex {n : ℕ} (x : X _⦋n⦌) : X.Subcomplex := Subpresheaf.ofSection x
lemma mem_ofSimplex_obj {n : ℕ} (x : X _⦋n⦌) :
x ∈ (ofSimplex x).obj _ :=
Subpresheaf.mem_ofSection_obj x
lemma ofSimplex_le_iff {n : ℕ} (x : X _⦋n⦌) (A : X.Subcomplex) :
ofSimplex x ≤ A ↔ x ∈ A.obj _ :=
Subpresheaf.ofSection_le_iff _ _
lemma mem_ofSimplex_obj_iff {n : ℕ} (x : X _⦋n⦌) {m : SimplexCategoryᵒᵖ} (y : X.obj m) :
y ∈ (ofSimplex x).obj m ↔ ∃ (f : m.unop ⟶ ⦋n⦌), X.map f.op x = y := by
dsimp [ofSimplex, Subpresheaf.ofSection]
aesop
section
variable (f : X ⟶ Y)
/-- The range of a morphism of simplicial sets, as a subcomplex. -/
abbrev range : Y.Subcomplex := Subpresheaf.range f
/-- The morphism `X ⟶ Subcomplex.range f` induced by `f : X ⟶ Y`. -/
abbrev toRange : X ⟶ Subcomplex.range f := Subpresheaf.toRange f
@[reassoc (attr := simp)]
lemma toRange_ι : toRange f ≫ (Subcomplex.range f).ι = f := rfl
@[simp]
lemma toRange_app_val {Δ : SimplexCategoryᵒᵖ} (x : X.obj Δ) :
((toRange f).app Δ x).val = f.app Δ x := rfl
instance : Epi (toRange f) :=
inferInstanceAs (Epi (Subpresheaf.toRange f))
instance [Mono f] : Mono (toRange f) :=
mono_of_mono_fac (toRange_ι f)
instance [Mono f] : IsIso (toRange f) :=
isIso_of_mono_of_epi _
lemma range_eq_top_iff : Subcomplex.range f = ⊤ ↔ Epi f := by
rw [NatTrans.epi_iff_epi_app, Subpresheaf.ext_iff, funext_iff]
simp only [epi_iff_surjective, Subpresheaf.range_obj, Subpresheaf.top_obj,
Set.top_eq_univ, Set.range_eq_univ]
lemma range_eq_top [Epi f] : Subcomplex.range f = ⊤ := by
rwa [range_eq_top_iff]
end
section
variable (f : X ⟶ Y) {B : Y.Subcomplex} (hf : range f ≤ B)
/-- Given a morphism of simplicial sets `f : X ⟶ Y` whose
range is `≤ B` for some `B : Y.Subcomplex`, this is the
induced morphism `X ⟶ B`. -/
def lift : X ⟶ B := Subpresheaf.lift f hf
@[reassoc (attr := simp)]
lemma lift_ι : lift f hf ≫ B.ι = f := rfl
@[simp]
lemma lift_app_coe {n : SimplexCategoryᵒᵖ} (x : X.obj n) :
((lift f hf).app _ x).1 = f.app _ x := rfl
end
section
/-- The preimage of a subcomplex by a morphism of simplicial sets. -/
@[simps]
def preimage (A : X.Subcomplex) (p : Y ⟶ X) : Y.Subcomplex where
obj n := p.app n ⁻¹' (A.obj n)
map f := (Set.preimage_mono (A.map f)).trans (by
simp only [Set.preimage_preimage, FunctorToTypes.naturality _ _ p f]
rfl)
@[simp]
lemma preimage_max (A B : X.Subcomplex) (p : Y ⟶ X) :
(A ⊔ B).preimage p = A.preimage p ⊔ B.preimage p := rfl
@[simp]
lemma preimage_min (A B : X.Subcomplex) (p : Y ⟶ X) :
(A ⊓ B).preimage p = A.preimage p ⊓ B.preimage p := rfl
@[simp]
lemma preimage_iSup {ι : Type*} (A : ι → X.Subcomplex) (p : Y ⟶ X) :
(⨆ i, A i).preimage p = ⨆ i, (A i).preimage p := by aesop
@[simp]
lemma preimage_iInf {ι : Type*} (A : ι → X.Subcomplex) (p : Y ⟶ X) :
(⨅ i, A i).preimage p = ⨅ i, (A i).preimage p := by aesop
end
section
variable (A : X.Subcomplex) (f : X ⟶ Y)
/-- The image of a subcomplex by a morphism of simplicial sets. -/
@[simps!]
def image : Y.Subcomplex := Subpresheaf.image A f
lemma image_le_iff (Z : Y.Subcomplex) :
A.image f ≤ Z ↔ A ≤ Z.preimage f := by
simp [Subpresheaf.le_def]
lemma image_top : (⊤ : X.Subcomplex).image f = range f := by aesop
@[simp]
lemma image_id : A.image (𝟙 _) = A := by aesop
lemma image_comp {Z : SSet.{u}} (g : Y ⟶ Z) :
A.image (f ≫ g) = (A.image f).image g := by aesop
lemma range_comp {Z : SSet.{u}} (g : Y ⟶ Z) :
Subcomplex.range (f ≫ g) = (Subcomplex.range f).image g := by aesop
lemma image_eq_range : A.image f = range (A.ι ≫ f) := by aesop
lemma image_iSup {ι : Type*} (S : ι → X.Subcomplex) (f : X ⟶ Y) :
image (⨆ i, S i) f = ⨆ i, (S i).image f := by
aesop
@[simp]
lemma preimage_range : (range f).preimage f = ⊤ :=
le_antisymm (by simp) (by rw [← image_le_iff, image_top])
@[simp]
lemma image_le_range : A.image f ≤ range f := by
simp [image_le_iff, preimage_range, le_top]
@[simp]
lemma image_ofSimplex {n : ℕ} (x : X _⦋n⦌) (f : X ⟶ Y) :
(ofSimplex x).image f = ofSimplex (f.app _ x) := by
apply le_antisymm
· rw [image_le_iff, ofSimplex_le_iff, preimage_obj, Set.mem_preimage]
apply mem_ofSimplex_obj
· rw [ofSimplex_le_iff]
exact ⟨x, mem_ofSimplex_obj _, rfl⟩
/-- Given a morphism of simplicial sets `f : X ⟶ Y` and a subcomplex `A` of `X`,
this is the induced morphism from `A` to `A.image f`. -/
@[simps!]
def toImage : (A : SSet) ⟶ (A.image f : SSet) :=
(A.image f).lift (A.ι ≫ f) (by rw [image_eq_range])
@[reassoc (attr := simp)]
lemma toImage_ι : A.toImage f ≫ (A.image f).ι = A.ι ≫ f := rfl
instance : Epi (A.toImage f) := by
rw [← range_eq_top_iff]
apply le_antisymm (by simp)
rintro m ⟨_, ⟨y, hy, rfl⟩⟩ _
exact ⟨⟨y, hy⟩, rfl⟩
lemma image_monotone : Monotone (fun (S : X.Subcomplex) ↦ S.image f) := by
intro S T h
rw [image_le_iff]
exact h.trans (by rw [← image_le_iff])
end
lemma preimage_eq_top_iff (B : X.Subcomplex) (f : Y ⟶ X) :
B.preimage f = ⊤ ↔ range f ≤ B := by
rw [← image_top, image_le_iff, top_le_iff]
@[simp]
lemma image_preimage_le (B : X.Subcomplex) (f : Y ⟶ X) :
(B.preimage f).image f ≤ B := by
rw [image_le_iff]
/-- Given a morphism of simplicial sets `p : Y ⟶ X` and
`A : X.Subcomplex`, this is the induced morphism
`(A.preimage p : SSet) ⟶ (A : SSet)`. -/
@[simps!]
def fromPreimage (A : X.Subcomplex) (p : Y ⟶ X) :
(A.preimage p : SSet) ⟶ (A : SSet) :=
lift (Subcomplex.ι _ ≫ p) (by simp [range_comp])
@[reassoc (attr := simp)]
lemma fromPreimage_ι (A : X.Subcomplex) (p : Y ⟶ X) :
A.fromPreimage p ≫ A.ι = (A.preimage p).ι ≫ p := rfl
end Subcomplex
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/KanComplex.lean | import Mathlib.AlgebraicTopology.ModelCategory.IsCofibrant
import Mathlib.AlgebraicTopology.SimplicialSet.CategoryWithFibrations
import Mathlib.AlgebraicTopology.SimplicialSet.Subcomplex
/-!
# Kan complexes
In this file, the abbreviation `KanComplex` is introduced for
fibrant objects in the category `SSet` which is equipped with
Kan fibrations.
In `Mathlib/AlgebraicTopology/Quasicategory/Basic.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.
-/
universe u
namespace SSet
open CategoryTheory Simplicial Limits
open modelCategoryQuillen in
/-- A simplicial set `S` is a Kan complex if it is fibrant, which means that
the projection `S ⟶ ⊤_ _` has the right lifting property with respect to horn inclusions. -/
abbrev KanComplex (S : SSet.{u}) : Prop := HomotopicalAlgebra.IsFibrant S
/-- A Kan complex `S` satisfies the following horn-filling condition:
for every nonzero `n : ℕ` and `0 ≤ i ≤ n`,
every map of simplicial sets `σ₀ : Λ[n, i] → S` can be extended to a map `σ : Δ[n] → S`. -/
lemma KanComplex.hornFilling {S : SSet.{u}} [KanComplex S]
{n : ℕ} {i : Fin (n + 2)} (σ₀ : (Λ[n + 1, i] : SSet) ⟶ S) :
∃ σ : Δ[n + 1] ⟶ S, σ₀ = Λ[n + 1, i].ι ≫ σ := by
have sq' : CommSq σ₀ Λ[n + 1, i].ι (terminal.from S) (terminal.from _) := ⟨by simp⟩
exact ⟨sq'.lift, by simp⟩
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Basic.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.CategoryTheory.Limits.Types.Colimits
import Mathlib.CategoryTheory.Yoneda
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.)
-/
universe v u
open CategoryTheory CategoryTheory.Limits CategoryTheory.Functor
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
@[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
@[simp]
lemma id_app (X : SSet) (n : SimplexCategoryᵒᵖ) :
NatTrans.app (𝟙 X) n = 𝟙 _ := rfl
@[simp, reassoc]
lemma comp_app {X Y Z : SSet} (f : X ⟶ Y) (g : Y ⟶ Z) (n : SimplexCategoryᵒᵖ) :
(f ≫ g).app n = f.app n ≫ g.app n := rfl
/-- The constant map of simplicial sets `X ⟶ Y` induced by a simplex `y : Y _[0]`. -/
@[simps]
def const {X Y : SSet.{u}} (y : Y _⦋0⦌) : X ⟶ Y where
app n _ := Y.map (n.unop.const _ 0).op y
naturality _ _ _ := by
ext
dsimp
rw [← FunctorToTypes.map_comp_apply]
rfl
@[simp]
lemma comp_const {X Y Z : SSet.{u}} (f : X ⟶ Y) (z : Z _⦋0⦌) :
f ≫ const z = const z := rfl
@[simp]
lemma const_comp {X Y Z : SSet.{u}} (y : Y _⦋0⦌) (g : Y ⟶ Z) :
const (X := X) y ≫ g = const (g.app _ y) := by
ext m x
simp [FunctorToTypes.naturality]
/-- 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}
/-- Truncated simplicial sets. -/
def Truncated (n : ℕ) :=
SimplicialObject.Truncated (Type u) n
namespace Truncated
instance largeCategory (n : ℕ) : LargeCategory (Truncated n) := by
dsimp only [Truncated]
infer_instance
instance hasLimits {n : ℕ} : HasLimits (Truncated n) := by
dsimp only [Truncated]
infer_instance
instance hasColimits {n : ℕ} : HasColimits (Truncated n) := by
dsimp only [Truncated]
infer_instance
/-- The ulift functor `SSet.Truncated.{u} ⥤ SSet.Truncated.{max u v}` on truncated
simplicial sets. -/
def uliftFunctor (k : ℕ) : SSet.Truncated.{u} k ⥤ SSet.Truncated.{max u v} k :=
(whiskeringRight _ _ _).obj CategoryTheory.uliftFunctor.{v, u}
@[ext]
lemma 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)
/-- Further truncation of truncated simplicial sets. -/
abbrev trunc (n m : ℕ) (h : m ≤ n := by omega) :
SSet.Truncated n ⥤ SSet.Truncated m :=
SimplicialObject.Truncated.trunc (Type u) n m
@[simp]
lemma id_app {n : ℕ} (X : Truncated n) (d : (SimplexCategory.Truncated n)ᵒᵖ) :
NatTrans.app (𝟙 X) d = 𝟙 _ :=
rfl
@[simp, reassoc]
lemma comp_app {n : ℕ} {X Y Z : Truncated n} (f : X ⟶ Y) (g : Y ⟶ Z)
(d : (SimplexCategory.Truncated n)ᵒᵖ) :
(f ≫ g).app d = f.app d ≫ g.app d :=
rfl
end Truncated
/-- The truncation functor on simplicial sets. -/
abbrev truncation (n : ℕ) : SSet ⥤ SSet.Truncated n := SimplicialObject.truncation n
/-- For all `m ≤ n`, `truncation m` factors through `SSet.Truncated n`. -/
def truncationCompTrunc {n m : ℕ} (h : m ≤ n) :
truncation n ⋙ Truncated.trunc n m ≅ truncation m :=
Iso.refl _
open SimplexCategory
noncomputable section
/-- The n-skeleton as a functor `SSet.Truncated n ⥤ SSet`. -/
protected abbrev Truncated.sk (n : ℕ) : SSet.Truncated n ⥤ SSet.{u} :=
SimplicialObject.Truncated.sk n
/-- The n-coskeleton as a functor `SSet.Truncated n ⥤ SSet`. -/
protected abbrev Truncated.cosk (n : ℕ) : SSet.Truncated n ⥤ SSet.{u} :=
SimplicialObject.Truncated.cosk n
/-- The n-skeleton as an endofunctor on `SSet`. -/
abbrev sk (n : ℕ) : SSet.{u} ⥤ SSet.{u} := SimplicialObject.sk n
/-- The n-coskeleton as an endofunctor on `SSet`. -/
abbrev cosk (n : ℕ) : SSet.{u} ⥤ SSet.{u} := SimplicialObject.cosk n
end
section adjunctions
/-- The adjunction between the n-skeleton and n-truncation. -/
noncomputable def skAdj (n : ℕ) : Truncated.sk n ⊣ truncation.{u} n :=
SimplicialObject.skAdj n
/-- The adjunction between n-truncation and the n-coskeleton. -/
noncomputable def coskAdj (n : ℕ) : truncation.{u} n ⊣ Truncated.cosk n :=
SimplicialObject.coskAdj n
namespace Truncated
instance cosk_reflective (n) : IsIso (coskAdj n).counit :=
SimplicialObject.Truncated.cosk_reflective n
instance sk_coreflective (n) : IsIso (skAdj n).unit :=
SimplicialObject.Truncated.sk_coreflective n
/-- Since `Truncated.inclusion` is fully faithful, so is right Kan extension along it. -/
noncomputable def cosk.fullyFaithful (n) :
(Truncated.cosk n).FullyFaithful :=
SimplicialObject.Truncated.cosk.fullyFaithful n
instance cosk.full (n) : (Truncated.cosk n).Full :=
SimplicialObject.Truncated.cosk.full n
instance cosk.faithful (n) : (Truncated.cosk n).Faithful :=
SimplicialObject.Truncated.cosk.faithful n
noncomputable instance coskAdj.reflective (n) : Reflective (Truncated.cosk n) :=
SimplicialObject.Truncated.coskAdj.reflective n
/-- Since `Truncated.inclusion` is fully faithful, so is left Kan extension along it. -/
noncomputable def sk.fullyFaithful (n) :
(Truncated.sk n).FullyFaithful := SimplicialObject.Truncated.sk.fullyFaithful n
instance sk.full (n) : (Truncated.sk n).Full := SimplicialObject.Truncated.sk.full n
instance sk.faithful (n) : (Truncated.sk n).Faithful :=
SimplicialObject.Truncated.sk.faithful n
noncomputable instance skAdj.coreflective (n) : Coreflective (Truncated.sk n) :=
SimplicialObject.Truncated.skAdj.coreflective n
end Truncated
end adjunctions
/-- The category of augmented simplicial sets, as a particular case of
augmented simplicial objects. -/
abbrev Augmented :=
SimplicialObject.Augmented (Type u)
section applications
variable {S : SSet}
lemma δ_comp_δ_apply {n} {i j : Fin (n + 2)} (H : i ≤ j) (x : S _⦋n + 2⦌) :
S.δ i (S.δ j.succ x) = S.δ j (S.δ i.castSucc x) := congr_fun (S.δ_comp_δ H) x
lemma δ_comp_δ'_apply {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j)
(x : S _⦋n + 2⦌) : S.δ i (S.δ j x) =
S.δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) (S.δ i.castSucc x) :=
congr_fun (S.δ_comp_δ' H) x
lemma δ_comp_δ''_apply {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j)
(x : S _⦋n + 2⦌) :
S.δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) (S.δ j.succ x) =
S.δ j (S.δ i x) := congr_fun (S.δ_comp_δ'' H) x
lemma δ_comp_δ_self_apply {n} {i : Fin (n + 2)} (x : S _⦋n + 2⦌) :
S.δ i (S.δ i.castSucc x) = S.δ i (S.δ i.succ x) := congr_fun S.δ_comp_δ_self x
lemma δ_comp_δ_self'_apply {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : j = Fin.castSucc i)
(x : S _⦋n + 2⦌) : S.δ i (S.δ j x) = S.δ i (S.δ i.succ x) := congr_fun (S.δ_comp_δ_self' H) x
lemma δ_comp_σ_of_le_apply {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ Fin.castSucc j)
(x : S _⦋n + 1⦌) :
S.δ (Fin.castSucc i) (S.σ j.succ x) = S.σ j (S.δ i x) := congr_fun (S.δ_comp_σ_of_le H) x
@[simp]
lemma δ_comp_σ_self_apply {n} (i : Fin (n + 1)) (x : S _⦋n⦌) : S.δ i.castSucc (S.σ i x) = x :=
congr_fun S.δ_comp_σ_self x
lemma δ_comp_σ_self'_apply {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = Fin.castSucc i)
(x : S _⦋n⦌) : S.δ j (S.σ i x) = x := congr_fun (S.δ_comp_σ_self' H) x
@[simp]
lemma δ_comp_σ_succ_apply {n} (i : Fin (n + 1)) (x : S _⦋n⦌) : S.δ i.succ (S.σ i x) = x :=
congr_fun S.δ_comp_σ_succ x
lemma δ_comp_σ_succ'_apply {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = i.succ) (x : S _⦋n⦌) :
S.δ j (S.σ i x) = x := congr_fun (S.δ_comp_σ_succ' H) x
lemma δ_comp_σ_of_gt_apply {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSucc j < i)
(x : S _⦋n + 1⦌) : S.δ i.succ (S.σ (Fin.castSucc j) x) = S.σ j (S.δ i x) :=
congr_fun (S.δ_comp_σ_of_gt H) x
lemma δ_comp_σ_of_gt'_apply {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i)
(x : S _⦋n + 1⦌) : S.δ i (S.σ j x) =
S.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le)))
(S.δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) x) :=
congr_fun (S.δ_comp_σ_of_gt' H) x
lemma σ_comp_σ_apply {n} {i j : Fin (n + 1)} (H : i ≤ j) (x : S _⦋n⦌) :
S.σ i.castSucc (S.σ j x) = S.σ j.succ (S.σ i x) := congr_fun (S.σ_comp_σ H) x
variable {T : SSet} (f : S ⟶ T)
open Opposite
lemma δ_naturality_apply {n : ℕ} (i : Fin (n + 2)) (x : S _⦋n + 1⦌) :
f.app (op ⦋n⦌) (S.δ i x) = T.δ i (f.app (op ⦋n + 1⦌) x) := by
change (S.δ i ≫ f.app (op ⦋n⦌)) x = (f.app (op ⦋n + 1⦌) ≫ T.δ i) x
exact congr_fun (SimplicialObject.δ_naturality f i) x
lemma σ_naturality_apply {n : ℕ} (i : Fin (n + 1)) (x : S _⦋n⦌) :
f.app (op ⦋n + 1⦌) (S.σ i x) = T.σ i (f.app (op ⦋n⦌) x) := by
change (S.σ i ≫ f.app (op ⦋n + 1⦌)) x = (f.app (op ⦋n⦌) ≫ T.σ i) x
exact congr_fun (SimplicialObject.σ_naturality f i) x
end applications
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Path.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Horn
/-!
# Paths in simplicial sets
A path in a simplicial set `X` of length `n` is a directed path comprised of
`n + 1` 0-simplices and `n` 1-simplices, together with identifications between
0-simplices and the sources and targets of the 1-simplices. We define this
construction first for truncated simplicial sets in `SSet.Truncated.Path`. A
path in a simplicial set `X` is then defined as a 1-truncated path in the
1-truncation of `X`.
An `n`-simplex has a maximal path, the `spine` of the simplex, which is a path
of length `n`.
-/
universe v u
open CategoryTheory Opposite Simplicial SimplexCategory
namespace SSet
namespace Truncated
open SimplexCategory.Truncated Truncated.Hom SimplicialObject.Truncated
/-- A path of length `n` in a 1-truncated simplicial set `X` is a directed path
of `n` edges. -/
@[ext]
structure Path₁ (X : SSet.Truncated.{u} 1) (n : ℕ) where
/-- A path includes the data of `n + 1` 0-simplices in `X`. -/
vertex : Fin (n + 1) → X _⦋0⦌₁
/-- A path includes the data of `n` 1-simplices in `X`. -/
arrow : Fin n → X _⦋1⦌₁
/-- The source of a 1-simplex in a path is identified with the source vertex. -/
arrow_src (i : Fin n) : X.map (tr (δ 1)).op (arrow i) = vertex i.castSucc
/-- The target of a 1-simplex in a path is identified with the target vertex. -/
arrow_tgt (i : Fin n) : X.map (tr (δ 0)).op (arrow i) = vertex i.succ
/-- A path of length `m` in an `n + 1`-truncated simplicial set `X` is given by
the data of a `Path₁` structure on the further 1-truncation of `X`. -/
def Path {n : ℕ} (X : SSet.Truncated.{u} (n + 1)) (m : ℕ) :=
trunc (n + 1) 1 |>.obj X |>.Path₁ m
namespace Path
variable {n : ℕ} {X : SSet.Truncated.{u} (n + 1)} {m : ℕ}
/-- A path includes the data of `n + 1` 0-simplices in `X`. -/
abbrev vertex (f : Path X m) (i : Fin (m + 1)) : X _⦋0⦌ₙ₊₁ :=
Path₁.vertex f i
/-- A path includes the data of `n` 1-simplices in `X`. -/
abbrev arrow (f : Path X m) (i : Fin m) : X _⦋1⦌ₙ₊₁ :=
Path₁.arrow f i
/-- The source of a 1-simplex in a path is identified with the source vertex. -/
lemma arrow_src (f : Path X m) (i : Fin m) :
X.map (tr (δ 1)).op (f.arrow i) = f.vertex i.castSucc :=
Path₁.arrow_src f i
/-- The target of a 1-simplex in a path is identified with the target vertex. -/
lemma arrow_tgt (f : Path X m) (i : Fin m) :
X.map (tr (δ 0)).op (f.arrow i) = f.vertex i.succ :=
Path₁.arrow_tgt f i
@[ext]
lemma ext {f g : Path X m} (hᵥ : f.vertex = g.vertex) (hₐ : f.arrow = g.arrow) :
f = g :=
Path₁.ext hᵥ hₐ
/-- To show two paths equal it suffices to show that they have the same edges. -/
@[ext]
lemma ext' {f g : Path X (m + 1)} (h : ∀ i, f.arrow i = g.arrow i) : f = g := by
ext j
· rcases Fin.eq_castSucc_or_eq_last j with ⟨k, hk⟩ | hl
· rw [hk, ← f.arrow_src k, ← g.arrow_src k, h]
· simp only [hl, ← Fin.succ_last]
rw [← f.arrow_tgt (Fin.last m), ← g.arrow_tgt (Fin.last m), h]
· exact h j
/-- For `j + l ≤ m`, a path of length `m` restricts to a path of length `l`, namely
the subpath spanned by the vertices `j ≤ i ≤ j + l` and edges `j ≤ i < j + l`. -/
def interval (f : Path X m) (j l : ℕ) (h : j + l ≤ m := by omega) : Path X l where
vertex i := f.vertex ⟨j + i, by omega⟩
arrow i := f.arrow ⟨j + i, by omega⟩
arrow_src i := f.arrow_src ⟨j + i, by omega⟩
arrow_tgt i := f.arrow_tgt ⟨j + i, by omega⟩
variable {X Y : SSet.Truncated.{u} (n + 1)} {m : ℕ}
/-- Maps of `n + 1`-truncated simplicial sets induce maps of paths. -/
def map (f : Path X m) (σ : X ⟶ Y) : Path Y m where
vertex i := σ.app (op ⦋0⦌ₙ₊₁) (f.vertex i)
arrow i := σ.app (op ⦋1⦌ₙ₊₁) (f.arrow i)
arrow_src i := by
simp only [← f.arrow_src i]
exact congr (σ.naturality (tr (δ 1)).op) rfl |>.symm
arrow_tgt i := by
simp only [← f.arrow_tgt i]
exact congr (σ.naturality (tr (δ 0)).op) rfl |>.symm
/- We write this lemma manually to ensure it refers to `Path.vertex`. -/
@[simp]
lemma map_vertex (f : Path X m) (σ : X ⟶ Y) (i : Fin (m + 1)) :
(f.map σ).vertex i = σ.app (op ⦋0⦌ₙ₊₁) (f.vertex i) :=
rfl
/- We write this lemma manually to ensure it refers to `Path.arrow`. -/
@[simp]
lemma map_arrow (f : Path X m) (σ : X ⟶ Y) (i : Fin m) :
(f.map σ).arrow i = σ.app (op ⦋1⦌ₙ₊₁) (f.arrow i) :=
rfl
lemma map_interval (f : Path X m) (σ : X ⟶ Y) (j l : ℕ) (h : j + l ≤ m) :
(f.map σ).interval j l h = (f.interval j l h).map σ :=
rfl
end Path
variable {n : ℕ} (X : SSet.Truncated.{u} (n + 1))
/-- The spine of an `m`-simplex in `X` is the path of edges of length `m`
formed by traversing in order through its vertices. -/
def spine (m : ℕ) (h : m ≤ n + 1 := by omega) (Δ : X _⦋m⦌ₙ₊₁) : Path X m where
vertex i := X.map (tr (SimplexCategory.const ⦋0⦌ ⦋m⦌ i)).op Δ
arrow i := X.map (tr (mkOfSucc i)).op Δ
arrow_src i := by
dsimp only [tr, trunc, SimplicialObject.Truncated.trunc, incl,
Functor.whiskeringLeft_obj_obj, id_eq, Functor.comp_map, Functor.op_map,
Quiver.Hom.unop_op]
rw [← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp, δ_one_mkOfSucc]
arrow_tgt i := by
dsimp only [tr, trunc, SimplicialObject.Truncated.trunc, incl,
Functor.whiskeringLeft_obj_obj, id_eq, Functor.comp_map, Functor.op_map,
Quiver.Hom.unop_op]
rw [← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp, δ_zero_mkOfSucc]
/-- Further truncating `X` above `m` does not change the `m`-spine. -/
lemma trunc_spine (k m : ℕ) (h : m ≤ k + 1) (hₙ : k ≤ n) :
((trunc (n + 1) (k + 1)).obj X).spine m = X.spine m :=
rfl
variable (m : ℕ) (hₘ : m ≤ n + 1)
/- We write this lemma manually to ensure it refers to `Path.vertex`. -/
@[simp]
lemma spine_vertex (Δ : X _⦋m⦌ₙ₊₁) (i : Fin (m + 1)) :
(X.spine m hₘ Δ).vertex i =
X.map (tr (SimplexCategory.const ⦋0⦌ ⦋m⦌ i)).op Δ :=
rfl
/- We write this lemma manually to ensure it refers to `Path.arrow`. -/
@[simp]
lemma spine_arrow (Δ : X _⦋m⦌ₙ₊₁) (i : Fin m) :
(X.spine m hₘ Δ).arrow i = X.map (tr (mkOfSucc i)).op Δ :=
rfl
lemma spine_map_vertex (Δ : X _⦋m⦌ₙ₊₁) (a : ℕ) (hₐ : a ≤ n + 1)
(φ : ⦋a⦌ₙ₊₁ ⟶ ⦋m⦌ₙ₊₁) (i : Fin (a + 1)) :
(X.spine a hₐ (X.map φ.op Δ)).vertex i =
(X.spine m hₘ Δ).vertex (φ.toOrderHom i) := by
dsimp only [spine_vertex]
rw [← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
SimplexCategory.const_comp]
lemma spine_map_subinterval (j l : ℕ) (h : j + l ≤ m) (Δ : X _⦋m⦌ₙ₊₁) :
X.spine l (by cutsat) (X.map (tr (subinterval j l h)).op Δ) =
(X.spine m hₘ Δ).interval j l h := by
ext i
· dsimp only [spine_vertex, Path.interval]
rw [← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
const_subinterval_eq]
· dsimp only [spine_arrow, Path.interval]
rw [← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
mkOfSucc_subinterval_eq]
end Truncated
/-- A path of length `n` in a simplicial set `X` is defined as a 1-truncated
path in the 1-truncation of `X`. -/
abbrev Path (X : SSet.{u}) (n : ℕ) := truncation 1 |>.obj X |>.Path n
namespace Path
variable {X : SSet.{u}} {n : ℕ}
/-- A path includes the data of `n + 1` 0-simplices in `X`. -/
abbrev vertex (f : Path X n) (i : Fin (n + 1)) : X _⦋0⦌ :=
Truncated.Path.vertex f i
/-- A path includes the data of `n` 1-simplices in `X`. -/
abbrev arrow (f : Path X n) (i : Fin n) : X _⦋1⦌ :=
Truncated.Path.arrow f i
lemma congr_vertex {f g : Path X n} (h : f = g) (i : Fin (n + 1)) :
f.vertex i = g.vertex i := by rw [h]
lemma congr_arrow {f g : Path X n} (h : f = g) (i : Fin n) :
f.arrow i = g.arrow i := by rw [h]
/-- The source of a 1-simplex in a path is identified with the source vertex. -/
lemma arrow_src (f : Path X n) (i : Fin n) :
X.δ 1 (f.arrow i) = f.vertex i.castSucc :=
Truncated.Path.arrow_src f i
/-- The target of a 1-simplex in a path is identified with the target vertex. -/
lemma arrow_tgt (f : Path X n) (i : Fin n) :
X.δ 0 (f.arrow i) = f.vertex i.succ :=
Truncated.Path.arrow_tgt f i
@[ext]
lemma ext {f g : Path X n} (hᵥ : f.vertex = g.vertex) (hₐ : f.arrow = g.arrow) :
f = g :=
Truncated.Path.ext hᵥ hₐ
/-- To show two paths equal it suffices to show that they have the same edges. -/
@[ext]
lemma ext' {f g : Path X (n + 1)} (h : ∀ i, f.arrow i = g.arrow i) : f = g :=
Truncated.Path.ext' h
@[ext]
lemma ext₀ {f g : Path X 0} (h : f.vertex 0 = g.vertex 0) : f = g := by
ext i
· fin_cases i; exact h
· fin_cases i
/-- For `j + l ≤ n`, a path of length `n` restricts to a path of length `l`, namely
the subpath spanned by the vertices `j ≤ i ≤ j + l` and edges `j ≤ i < j + l`. -/
def interval (f : Path X n) (j l : ℕ) (h : j + l ≤ n := by grind) : Path X l :=
Truncated.Path.interval f j l h
lemma arrow_interval (f : Path X n) (j l : ℕ) (k' : Fin l) (k : Fin n)
(h : j + l ≤ n := by omega) (hkk' : j + k' = k := by grind) :
(f.interval j l h).arrow k' = f.arrow k := by
dsimp [interval, arrow, Truncated.Path.interval, Truncated.Path.arrow]
congr
variable {X Y : SSet.{u}} {n : ℕ}
/-- Maps of simplicial sets induce maps of paths in a simplicial set. -/
def map (f : Path X n) (σ : X ⟶ Y) : Path Y n :=
Truncated.Path.map f ((truncation 1).map σ)
@[simp]
lemma map_vertex (f : Path X n) (σ : X ⟶ Y) (i : Fin (n + 1)) :
(f.map σ).vertex i = σ.app (op ⦋0⦌) (f.vertex i) :=
rfl
@[simp]
lemma map_arrow (f : Path X n) (σ : X ⟶ Y) (i : Fin n) :
(f.map σ).arrow i = σ.app (op ⦋1⦌) (f.arrow i) :=
rfl
/-- `Path.map` respects subintervals of paths. -/
lemma map_interval (f : Path X n) (σ : X ⟶ Y) (j l : ℕ) (h : j + l ≤ n) :
(f.map σ).interval j l h = (f.interval j l h).map σ :=
rfl
end Path
section spine
variable (X : SSet.{u}) (n : ℕ)
/-- The spine of an `n`-simplex in `X` is the path of edges of length `n` formed
by traversing in order through the vertices of `X _⦋n⦌ₙ₊₁`. -/
def spine : X _⦋n⦌ → Path X n :=
truncation (n + 1) |>.obj X |>.spine n
@[simp]
lemma spine_vertex (Δ : X _⦋n⦌) (i : Fin (n + 1)) :
(X.spine n Δ).vertex i = X.map (SimplexCategory.const ⦋0⦌ ⦋n⦌ i).op Δ :=
rfl
@[simp]
lemma spine_arrow (Δ : X _⦋n⦌) (i : Fin n) :
(X.spine n Δ).arrow i = X.map (mkOfSucc i).op Δ :=
rfl
lemma spine_δ₀ {m : ℕ} (x : X _⦋m + 1⦌) :
X.spine m (X.δ 0 x) = (X.spine (m + 1) x).interval 1 m := by
obtain _ | m := m
· ext
simp [spine, Path.vertex, Truncated.Path.vertex, SimplicialObject.truncation,
Truncated.spine, Path.interval, Truncated.Path.interval, Truncated.inclusion,
Truncated.Hom.tr, ← SimplexCategory.δ_zero_eq_const, ← SimplicialObject.δ_def]
· ext i
dsimp
rw [SimplicialObject.δ_def, ← FunctorToTypes.map_comp_apply, ← op_comp,
SimplexCategory.mkOfSucc_δ_gt (j := 0) (i := i) (by simp)]
symm
exact Path.arrow_interval _ _ _ _ _ _ (by rw [Fin.val_succ, add_comm])
/-- For `m ≤ n + 1`, the `m`-spine of `X` factors through the `n + 1`-truncation
of `X`. -/
lemma truncation_spine (m : ℕ) (h : m ≤ n + 1) :
((truncation (n + 1)).obj X).spine m = X.spine m :=
rfl
lemma spine_map_vertex (Δ : X _⦋n⦌) {m : ℕ}
(φ : ⦋m⦌ ⟶ ⦋n⦌) (i : Fin (m + 1)) :
(X.spine m (X.map φ.op Δ)).vertex i =
(X.spine n Δ).vertex (φ.toOrderHom i) :=
truncation (max m n + 1) |>.obj X
|>.spine_map_vertex n (by omega) Δ m (by omega) φ i
lemma spine_map_subinterval (j l : ℕ) (h : j + l ≤ n) (Δ : X _⦋n⦌) :
X.spine l (X.map (subinterval j l h).op Δ) = (X.spine n Δ).interval j l h :=
truncation (n + 1) |>.obj X |>.spine_map_subinterval n (by cutsat) j l h Δ
end spine
/-- The spine of the unique non-degenerate `n`-simplex in `Δ[n]`. -/
def stdSimplex.spineId (n : ℕ) : Path Δ[n] n :=
spine Δ[n] n (objEquiv.symm (𝟙 _))
@[simp]
lemma stdSimplex.spineId_vertex (n : ℕ) (i : Fin (n + 1)) :
(stdSimplex.spineId n).vertex i = obj₀Equiv.symm i := rfl
@[simp]
lemma stdSimplex.spineId_arrow_apply_zero (n : ℕ) (i : Fin n) :
(stdSimplex.spineId n).arrow i 0 = i.castSucc := rfl
@[simp]
lemma stdSimplex.spineId_arrow_apply_one (n : ℕ) (i : Fin n) :
(stdSimplex.spineId n).arrow i 1 = i.succ := rfl
/-- A path of a simplicial set can be lifted to a subcomplex if the vertices
and arrows belong to this subcomplex. -/
@[simps]
def Subcomplex.liftPath {X : SSet.{u}} (A : X.Subcomplex) {n : ℕ} (p : Path X n)
(hp₀ : ∀ j, p.vertex j ∈ A.obj _)
(hp₁ : ∀ j, p.arrow j ∈ A.obj _) :
Path A n where
vertex j := ⟨p.vertex j, hp₀ _⟩
arrow j := ⟨p.arrow j, hp₁ _⟩
arrow_src j := Subtype.ext <| p.arrow_src j
arrow_tgt j := Subtype.ext <| p.arrow_tgt j
@[simp]
lemma Subcomplex.map_ι_liftPath {X : SSet.{u}} (A : X.Subcomplex) {n : ℕ} (p : Path X n)
(hp₀ : ∀ j, p.vertex j ∈ A.obj _)
(hp₁ : ∀ j, p.arrow j ∈ A.obj _) :
(A.liftPath p hp₀ hp₁).map A.ι = p := rfl
/-- Any inner horn contains the spine of the unique non-degenerate `n`-simplex
in `Δ[n]`. -/
@[simps! vertex_coe arrow_coe]
def horn.spineId {n : ℕ} (i : Fin (n + 3))
(h₀ : 0 < i) (hₙ : i < Fin.last (n + 2)) :
Path (Λ[n + 2, i] : SSet.{u}) (n + 2) :=
Λ[n + 2, i].liftPath (stdSimplex.spineId (n + 2)) (by simp) (fun j ↦ by
convert (horn.primitiveEdge.{u} h₀ hₙ j).2
ext a
fin_cases a <;> rfl)
@[simp]
lemma horn.spineId_map_hornInclusion {n : ℕ} (i : Fin (n + 3))
(h₀ : 0 < i) (hₙ : i < Fin.last (n + 2)) :
Path.map (horn.spineId.{u} i h₀ hₙ) Λ[n + 2, i].ι =
stdSimplex.spineId (n + 2) := rfl
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/CompStructTruncated.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Basic
import Mathlib.AlgebraicTopology.SimplexCategory.Truncated
/-!
# Edges and "triangles" in truncated simplicial sets
Given a `2`-truncated simplicial set `X`, we introduce two types:
* Given `0`-simplices `x₀` and `x₁`, we define `Edge x₀ x₁`
which is the type of `1`-simplices with faces `x₁` and `x₀` respectively;
* Given `0`-simplices `x₀`, `x₁`, `x₂`, edges `e₀₁ : Edge x₀ x₁`, `e₁₂ : Edge x₁ x₂`,
`e₀₂ : Edge x₀ x₂`, a structure `CompStruct e₀₁ e₁₂ e₀₂` which records the
data of a `2`-simplex with faces `e₁₂`, `e₀₂` and `e₀₁` respectively. This data
will allow to obtain relations in the homotopy category of `X`.
-/
universe v u
open CategoryTheory Simplicial SimplicialObject.Truncated
SimplexCategory.Truncated
namespace SSet.Truncated
variable {X Y : Truncated.{u} 2}
/-- In a `2`-truncated simplicial set, an edge from a vertex `x₀` to `x₁` is
a `1`-simplex with prescribed `0`-dimensional faces. -/
@[ext]
structure Edge (x₀ x₁ : X _⦋0⦌₂) where
/-- A `1`-simplex -/
edge : X _⦋1⦌₂
/-- The source of the edge is `x₀`. -/
src_eq : X.map (δ₂ 1).op edge = x₀ := by cat_disch
/-- The target of the edge is `x₁`. -/
tgt_eq : X.map (δ₂ 0).op edge = x₁ := by cat_disch
namespace Edge
attribute [simp] src_eq tgt_eq
/-- The edge given by a `1`-simplex. -/
@[simps]
def mk' (s : X _⦋1⦌₂) : Edge (X.map (δ₂ 1).op s) (X.map (δ₂ 0).op s) where
edge := s
lemma exists_of_simplex (s : X _⦋1⦌₂) :
∃ (x₀ x₁ : X _⦋0⦌₂) (e : Edge x₀ x₁), e.edge = s :=
⟨_, _, mk' s, rfl⟩
/-- The constant edge on a `0`-simplex. -/
@[simps]
def id (x : X _⦋0⦌₂) : Edge x x where
edge := X.map (σ₂ 0).op x
src_eq := by simp [← FunctorToTypes.map_comp_apply, ← op_comp]
tgt_eq := by simp [← FunctorToTypes.map_comp_apply, ← op_comp]
/-- The image of an edge by a morphism of truncated simplicial sets. -/
@[simps]
def map {x₀ x₁ : X _⦋0⦌₂} (e : Edge x₀ x₁) (f : X ⟶ Y) :
Edge (f.app _ x₀) (f.app _ x₁) where
edge := f.app _ e.edge
src_eq := by simp [← FunctorToTypes.naturality]
tgt_eq := by simp [← FunctorToTypes.naturality]
@[simp]
lemma map_id (x : X _⦋0⦌₂) (f : X ⟶ Y) :
(Edge.id x).map f = Edge.id (f.app _ x) := by
ext
simp [FunctorToTypes.naturality]
/-- Let `x₀`, `x₁`, `x₂` be `0`-simplices of a `2`-truncated simplicial set `X`,
`e₀₁` an edge from `x₀` to `x₁`, `e₁₂` an edge from `x₁` to `x₂`,
`e₀₂` an edge from `x₀` to `x₂`. This is the data of a `2`-simplex whose
faces are respectively `e₀₂`, `e₁₂` and `e₀₁`. Such structures shall provide
relations in the homotopy category of arbitrary (truncated) simplicial sets
(and specialized constructions for quasicategories and Kan complexes.). -/
@[ext]
structure CompStruct {x₀ x₁ x₂ : X _⦋0⦌₂}
(e₀₁ : Edge x₀ x₁) (e₁₂ : Edge x₁ x₂) (e₀₂ : Edge x₀ x₂) where
/-- A `2`-simplex with prescribed `1`-dimensional faces -/
simplex : X _⦋2⦌₂
d₂ : X.map (δ₂ 2).op simplex = e₀₁.edge := by cat_disch
d₀ : X.map (δ₂ 0).op simplex = e₁₂.edge := by cat_disch
d₁ : X.map (δ₂ 1).op simplex = e₀₂.edge := by cat_disch
namespace CompStruct
attribute [simp] d₀ d₁ d₂
lemma exists_of_simplex (s : X _⦋2⦌₂) :
∃ (x₀ x₁ x₂ : X _⦋0⦌₂) (e₀₁ : Edge x₀ x₁) (e₁₂ : Edge x₁ x₂)
(e₀₂ : Edge x₀ x₂) (h : CompStruct e₀₁ e₁₂ e₀₂), h.simplex = s := by
refine ⟨X.map (Hom.tr (SimplexCategory.const _ _ 0)).op s,
X.map (Hom.tr (SimplexCategory.const _ _ 1)).op s,
X.map (Hom.tr (SimplexCategory.const _ _ 2)).op s,
.mk _ ?_ ?_, .mk _ ?_ ?_, .mk _ ?_ ?_, .mk s rfl rfl rfl, rfl⟩
all_goals
· rw [← FunctorToTypes.map_comp_apply, ← op_comp]
apply congr_fun; congr
decide
/-- `e : Edge x y` is a composition of `Edge.id x` with `e`. -/
def idComp {x y : X _⦋0⦌₂} (e : Edge x y) :
CompStruct (.id x) e e where
simplex := X.map (σ₂ 0).op e.edge
d₂ := by
rw [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_two_comp_σ₂_zero]
simp
d₀ := by
rw [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_zero_comp_σ₂_zero]
simp
d₁ := by
rw [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_one_comp_σ₂_zero]
simp
/-- `e : Edge x y` is a composition of `e` with `Edge.id y`. -/
def compId {x y : X _⦋0⦌₂} (e : Edge x y) :
CompStruct e (.id y) e where
simplex := X.map (σ₂ 1).op e.edge
d₂ := by
rw [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_two_comp_σ₂_one]
simp
d₀ := by
rw [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_zero_comp_σ₂_one]
simp
d₁ := by
rw [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_one_comp_σ₂_one]
simp
attribute [local simp ←] FunctorToTypes.naturality in
/-- The image of a `Edge.CompStruct` by a morphism of `2`-truncated
simplicial sets. -/
@[simps]
def map {x₀ x₁ x₂ : X _⦋0⦌₂}
{e₀₁ : Edge x₀ x₁} {e₁₂ : Edge x₁ x₂} {e₀₂ : Edge x₀ x₂}
(h : CompStruct e₀₁ e₁₂ e₀₂) (f : X ⟶ Y) :
CompStruct (e₀₁.map f) (e₁₂.map f) (e₀₂.map f) where
simplex := f.app _ h.simplex
end CompStruct
end Edge
end SSet.Truncated |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplices.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Degenerate
import Mathlib.AlgebraicTopology.SimplicialSet.Simplices
/-!
# The partially ordered type of non degenerate simplices of a simplicial set
In this file, we introduce the partially ordered type `X.N` of
non degenerate simplices of a simplicial set `X`. We obtain
an embedding `X.orderEmbeddingN : X.N ↪o X.Subcomplex` which sends
a non degenerate simplex to the subcomplex of `X` it generates.
Given an arbitrary simplex `x : X.S`, we show that there is a unique
non degenerate `x.toN : X.N` such that `x.toN.subcomplex = x.subcomplex`.
-/
universe u
open CategoryTheory Simplicial
namespace SSet
variable (X : SSet.{u})
/-- The type of non degenerate simplices of a simplicial set. -/
structure N extends X.S where mk' ::
nonDegenerate : simplex ∈ X.nonDegenerate _
namespace N
variable {X}
lemma mk'_surjective (s : X.N) :
∃ (t : X.S) (ht : t.simplex ∈ X.nonDegenerate _), s = mk' t ht :=
⟨s.toS, s.nonDegenerate, rfl⟩
/-- Constructor for the type of non degenerate simplices of a simplicial set. -/
@[simps]
def mk {n : ℕ} (x : X _⦋n⦌) (hx : x ∈ X.nonDegenerate n) : X.N where
simplex := x
nonDegenerate := hx
lemma mk_surjective (x : X.N) :
∃ (n : ℕ) (y : X.nonDegenerate n), x = N.mk _ y.prop :=
⟨x.dim, ⟨_, x.nonDegenerate⟩, rfl⟩
lemma ext_iff (x y : X.N) :
x = y ↔ x.toS = y.toS := by
grind [cases SSet.N]
instance : Preorder X.N := Preorder.lift toS
lemma le_iff {x y : X.N} : x ≤ y ↔ x.subcomplex ≤ y.subcomplex :=
Iff.rfl
lemma le_iff_exists_mono {x y : X.N} :
x ≤ y ↔ ∃ (f : ⦋x.dim⦌ ⟶ ⦋y.dim⦌) (_ : Mono f), X.map f.op y.simplex = x.simplex := by
simp only [le_iff, CategoryTheory.Subpresheaf.ofSection_le_iff,
Subcomplex.mem_ofSimplex_obj_iff]
exact ⟨fun ⟨f, hf⟩ ↦ ⟨f, X.mono_of_nonDegenerate ⟨_, x.nonDegenerate⟩ f _ hf, hf⟩, by tauto⟩
lemma dim_le_of_le {x y : X.N} (h : x ≤ y) : x.dim ≤ y.dim := by
rw [le_iff_exists_mono] at h
obtain ⟨f, hf, _⟩ := h
exact SimplexCategory.len_le_of_mono f
lemma dim_lt_of_lt {x y : X.N} (h : x < y) : x.dim < y.dim := by
obtain h' | h' := (dim_le_of_le h.le).lt_or_eq
· exact h'
· obtain ⟨f, _, hf⟩ := le_iff_exists_mono.1 h.le
obtain ⟨d, ⟨x, hx⟩, rfl⟩ := x.mk_surjective
obtain ⟨d', ⟨y, hy⟩, rfl⟩ := y.mk_surjective
obtain rfl : d = d' := h'
obtain rfl := SimplexCategory.eq_id_of_mono f
obtain rfl : y = x := by simpa using hf
simp at h
instance : PartialOrder X.N where
le_antisymm x₁ x₂ h h' := by
obtain ⟨n₁, ⟨x₁, hx₁⟩, rfl⟩ := x₁.mk_surjective
obtain ⟨n₂, ⟨x₂, hx₂⟩, rfl⟩ := x₂.mk_surjective
obtain rfl : n₁ = n₂ := le_antisymm (dim_le_of_le h) (dim_le_of_le h')
rw [le_iff_exists_mono] at h
obtain ⟨f, hf, h⟩ := h
obtain rfl := SimplexCategory.eq_id_of_mono f
aesop
lemma subcomplex_injective {x y : X.N} (h : x.subcomplex = y.subcomplex) :
x = y := by
apply le_antisymm
all_goals
· rw [le_iff, h]
lemma subcomplex_injective_iff {x y : X.N} :
x.subcomplex = y.subcomplex ↔ x = y :=
⟨subcomplex_injective, by rintro rfl; rfl⟩
lemma eq_iff {x y : X.N} :
x = y ↔ x.subcomplex = y.subcomplex :=
⟨by rintro rfl; rfl, fun h ↦ by simp [le_antisymm_iff, le_iff, h]⟩
section
variable (s : X.N) {d : ℕ} (hd : s.dim = d)
/-- When `s : X.N` is such that `s.dim = d`, this is a term
that is equal to `s`, but whose dimension if definitionally equal to `d`. -/
abbrev cast : X.N where
toS := s.toS.cast hd
nonDegenerate := by
subst hd
exact s.nonDegenerate
lemma cast_eq_self : s.cast hd = s := by
subst hd
rfl
end
end N
/-- The map which sends a non degenerate simplex of a simplicial set to
the subcomplex it generates is an order embedding. -/
@[simps]
def orderEmbeddingN : X.N ↪o X.Subcomplex where
toFun x := x.subcomplex
inj' _ _ h := by
dsimp at h
apply le_antisymm <;> rw [N.le_iff, h]
map_rel_iff' := Iff.rfl
namespace S
variable {X}
lemma existsUnique_n (x : X.S) : ∃! (y : X.N), y.subcomplex = x.subcomplex :=
existsUnique_of_exists_of_unique (by
obtain ⟨n, x, hx, rfl⟩ := x.mk_surjective
obtain ⟨m, f, _, y, rfl⟩ := X.exists_nonDegenerate x
refine ⟨N.mk _ y.prop, le_antisymm ?_ ?_⟩
· simp only [Subcomplex.ofSimplex_le_iff]
have := isSplitEpi_of_epi f
have : Function.Injective (X.map f.op) := by
rw [← mono_iff_injective]
infer_instance
refine ⟨(section_ f).op, this ?_⟩
dsimp
rw [← FunctorToTypes.map_comp_apply, ← FunctorToTypes.map_comp_apply,
← op_comp, ← op_comp, Category.assoc, IsSplitEpi.id, Category.comp_id]
· simp only [Subcomplex.ofSimplex_le_iff]
exact ⟨f.op, rfl⟩)
(fun y₁ y₂ h₁ h₂ ↦ N.subcomplex_injective (by rw [h₁, h₂]))
/-- This is the non degenerate simplex of a simplicial set which
generates the same subcomplex as a given simplex. -/
noncomputable def toN (x : X.S) : X.N := x.existsUnique_n.exists.choose
@[simp]
lemma subcomplex_toN (x : X.S) : x.toN.subcomplex = x.subcomplex :=
x.existsUnique_n.exists.choose_spec
lemma toN_eq_iff {x : X.S} {y : X.N} :
x.toN = y ↔ y.subcomplex = x.subcomplex :=
⟨by rintro rfl; simp, fun h ↦ x.existsUnique_n.unique (by simp) h⟩
end S
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Degenerate.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Subcomplex
/-!
# Degenerate simplices
Given a simplicial set `X` and `n : ℕ`, we define the sets `X.degenerate n`
and `X.nonDegenerate n` of degenerate or non-degenerate simplices of dimension `n`.
Any simplex `x : X _⦋n⦌` can be written in a unique way as `X.map f.op y`
for an epimorphism `f : ⦋n⦌ ⟶ ⦋m⦌` and a non-degenerate `m`-simplex `y`
(see lemmas `exists_nonDegenerate`, `unique_nonDegenerate_dim`,
`unique_nonDegenerate_simplex` and `unique_nonDegenerate_map`).
-/
universe u
open CategoryTheory Simplicial Limits Opposite
namespace SSet
variable (X : SSet.{u})
/-- An `n`-simplex of a simplicial set `X` is degenerate if it is in the range
of `X.map f.op` for some morphism `f : [n] ⟶ [m]` with `m < n`. -/
def degenerate (n : ℕ) : Set (X _⦋n⦌) :=
setOf (fun x ↦ ∃ (m : ℕ) (_ : m < n) (f : ⦋n⦌ ⟶ ⦋m⦌),
x ∈ Set.range (X.map f.op))
/-- The set of `n`-dimensional non-degenerate simplices in a simplicial
set `X` is the complement of `X.degenerate n`. -/
def nonDegenerate (n : ℕ) : Set (X _⦋n⦌) := (X.degenerate n)ᶜ
@[simp]
lemma degenerate_zero : X.degenerate 0 = ∅ := by
ext x
simp only [Set.mem_empty_iff_false, iff_false]
rintro ⟨m, hm, _⟩
simp at hm
@[simp]
lemma nondegenerate_zero : X.nonDegenerate 0 = Set.univ := by
simp [nonDegenerate]
variable {n : ℕ}
lemma mem_nonDegenerate_iff_notMem_degenerate (x : X _⦋n⦌) :
x ∈ X.nonDegenerate n ↔ x ∉ X.degenerate n := Iff.rfl
@[deprecated (since := "2025-05-23")]
alias mem_nonDegenerate_iff_not_mem_degenerate := mem_nonDegenerate_iff_notMem_degenerate
lemma mem_degenerate_iff_notMem_nonDegenerate (x : X _⦋n⦌) :
x ∈ X.degenerate n ↔ x ∉ X.nonDegenerate n := by
simp [nonDegenerate]
@[deprecated (since := "2025-05-23")]
alias mem_degenerate_iff_not_mem_nonDegenerate := mem_degenerate_iff_notMem_nonDegenerate
lemma σ_mem_degenerate (i : Fin (n + 1)) (x : X _⦋n⦌) :
X.σ i x ∈ X.degenerate (n + 1) :=
⟨n, by cutsat, SimplexCategory.σ i, Set.mem_range_self x⟩
lemma mem_degenerate_iff (x : X _⦋n⦌) :
x ∈ X.degenerate n ↔ ∃ (m : ℕ) (_ : m < n) (f : ⦋n⦌ ⟶ ⦋m⦌) (_ : Epi f),
x ∈ Set.range (X.map f.op) := by
constructor
· rintro ⟨m, hm, f, y, hy⟩
rw [← image.fac f, op_comp] at hy
have : _ ≤ m := SimplexCategory.len_le_of_mono (image.ι f)
exact ⟨(image f).len, by cutsat, factorThruImage f, inferInstance, by aesop⟩
· rintro ⟨m, hm, f, hf, hx⟩
exact ⟨m, hm, f, hx⟩
lemma degenerate_eq_iUnion_range_σ :
X.degenerate (n + 1) = ⋃ (i : Fin (n + 1)), Set.range (X.σ i) := by
ext x
constructor
· intro hx
rw [mem_degenerate_iff] at hx
obtain ⟨m, hm, f, hf, y, rfl⟩ := hx
obtain ⟨i, θ, rfl⟩ := SimplexCategory.eq_σ_comp_of_not_injective f (fun hf ↦ by
rw [← SimplexCategory.mono_iff_injective] at hf
have := SimplexCategory.le_of_mono f
cutsat)
aesop
· intro hx
simp only [Set.mem_iUnion, Set.mem_range] at hx
obtain ⟨i, y, rfl⟩ := hx
apply σ_mem_degenerate
lemma exists_nonDegenerate (x : X _⦋n⦌) :
∃ (m : ℕ) (f : ⦋n⦌ ⟶ ⦋m⦌) (_ : Epi f)
(y : X.nonDegenerate m), x = X.map f.op y := by
induction n with
| zero =>
exact ⟨0, 𝟙 _, inferInstance, ⟨x, by simp⟩, by simp⟩
| succ n hn =>
by_cases hx : x ∈ X.nonDegenerate (n + 1)
· exact ⟨n + 1, 𝟙 _, inferInstance, ⟨x, hx⟩, by simp⟩
· simp only [← mem_degenerate_iff_notMem_nonDegenerate,
degenerate_eq_iUnion_range_σ, Set.mem_iUnion, Set.mem_range] at hx
obtain ⟨i, y, rfl⟩ := hx
obtain ⟨m, f, hf, z, rfl⟩ := hn y
exact ⟨_, SimplexCategory.σ i ≫ f, inferInstance, z, by simp; rfl⟩
lemma isIso_of_nonDegenerate (x : X.nonDegenerate n)
{m : SimplexCategory} (f : ⦋n⦌ ⟶ m) [Epi f]
(y : X.obj (op m)) (hy : X.map f.op y = x) :
IsIso f := by
obtain ⟨x, hx⟩ := x
induction m using SimplexCategory.rec with | _ m
rw [mem_nonDegenerate_iff_notMem_degenerate] at hx
by_contra!
refine hx ⟨_, not_le.1 (fun h ↦ this ?_), f, y, hy⟩
rw [SimplexCategory.isIso_iff_of_epi]
exact le_antisymm h (SimplexCategory.len_le_of_epi f)
lemma mono_of_nonDegenerate (x : X.nonDegenerate n)
{m : SimplexCategory} (f : ⦋n⦌ ⟶ m)
(y : X.obj (op m)) (hy : X.map f.op y = x) :
Mono f := by
have := X.isIso_of_nonDegenerate x (factorThruImage f) (y := X.map (image.ι f).op y) (by
rw [← FunctorToTypes.map_comp_apply, ← op_comp, image.fac f, hy])
rw [← image.fac f]
infer_instance
namespace unique_nonDegenerate
/-!
Auxiliary definitions and lemmas for the lemmas
`unique_nonDegenerate_dim`, `unique_nonDegenerate_simplex` and
`unique_nonDegenerate_map` which assert the uniqueness of the
decomposition obtained in the lemma `exists_nonDegenerate`.
-/
section
variable {X} {x : X _⦋n⦌}
{m₁ m₂ : ℕ} {f₁ : ⦋n⦌ ⟶ ⦋m₁⦌} (hf₁ : SplitEpi f₁)
(y₁ : X.nonDegenerate m₁) (hy₁ : x = X.map f₁.op y₁)
(f₂ : ⦋n⦌ ⟶ ⦋m₂⦌) (y₂ : X _⦋m₂⦌) (hy₂ : x = X.map f₂.op y₂)
/-- The composition of a section of `f₁` and `f₂`. It is proven below that it
is the identity, see `g_eq_id`. -/
private def g := hf₁.section_ ≫ f₂
variable {f₂ y₁ y₂}
include hf₁ hy₁ hy₂
private lemma map_g_op_y₂ : X.map (g hf₁ f₂).op y₂ = y₁ := by
dsimp [g]
rw [FunctorToTypes.map_comp_apply, ← hy₂, hy₁, ← FunctorToTypes.map_comp_apply, ← op_comp,
SplitEpi.id, op_id, FunctorToTypes.map_id_apply]
private lemma isIso_factorThruImage_g :
IsIso (factorThruImage (g hf₁ f₂)) := by
have := map_g_op_y₂ hf₁ hy₁ hy₂
rw [← image.fac (g hf₁ f₂), op_comp, FunctorToTypes.map_comp_apply] at this
exact X.isIso_of_nonDegenerate y₁ (factorThruImage (g hf₁ f₂)) _ this
private lemma mono_g : Mono (g hf₁ f₂) := by
have := isIso_factorThruImage_g hf₁ hy₁ hy₂
rw [← image.fac (g hf₁ f₂)]
infer_instance
private lemma le : m₁ ≤ m₂ :=
have := isIso_factorThruImage_g hf₁ hy₁ hy₂
SimplexCategory.len_le_of_mono
(factorThruImage (g hf₁ f₂) ≫ image.ι _)
end
variable {X} in
private lemma g_eq_id {x : X _⦋n⦌} {m : ℕ} {f₁ : ⦋n⦌ ⟶ ⦋m⦌}
{y₁ : X.nonDegenerate m} (hy₁ : x = X.map f₁.op y₁)
{f₂ : ⦋n⦌ ⟶ ⦋m⦌} {y₂ : X _⦋m⦌} (hy₂ : x = X.map f₂.op y₂) (hf₁ : SplitEpi f₁) :
g hf₁ f₂ = 𝟙 _ := by
have := mono_g hf₁ hy₁ hy₂
apply SimplexCategory.eq_id_of_mono
end unique_nonDegenerate
section
open unique_nonDegenerate
/-!
The following lemmas `unique_nonDegenerate_dim`, `unique_nonDegenerate_simplex` and
`unique_nonDegenerate_map` assert the uniqueness of the decomposition
obtained in the lemma `exists_nonDegenerate`.
-/
lemma unique_nonDegenerate_dim (x : X _⦋n⦌) {m₁ m₂ : ℕ}
(f₁ : ⦋n⦌ ⟶ ⦋m₁⦌) [Epi f₁] (y₁ : X.nonDegenerate m₁) (hy₁ : x = X.map f₁.op y₁)
(f₂ : ⦋n⦌ ⟶ ⦋m₂⦌) [Epi f₂] (y₂ : X.nonDegenerate m₂) (hy₂ : x = X.map f₂.op y₂) :
m₁ = m₂ := by
obtain ⟨⟨hf₁⟩⟩ := isSplitEpi_of_epi f₁
obtain ⟨⟨hf₂⟩⟩ := isSplitEpi_of_epi f₂
exact le_antisymm (le hf₁ hy₁ hy₂) (le hf₂ hy₂ hy₁)
lemma unique_nonDegenerate_simplex (x : X _⦋n⦌) {m : ℕ}
(f₁ : ⦋n⦌ ⟶ ⦋m⦌) [Epi f₁] (y₁ : X.nonDegenerate m) (hy₁ : x = X.map f₁.op y₁)
(f₂ : ⦋n⦌ ⟶ ⦋m⦌) (y₂ : X.nonDegenerate m) (hy₂ : x = X.map f₂.op y₂) :
y₁ = y₂ := by
obtain ⟨⟨hf₁⟩⟩ := isSplitEpi_of_epi f₁
ext
simpa [g_eq_id hy₁ hy₂ hf₁] using (map_g_op_y₂ hf₁ hy₁ hy₂).symm
lemma unique_nonDegenerate_map (x : X _⦋n⦌) {m : ℕ}
(f₁ : ⦋n⦌ ⟶ ⦋m⦌) [Epi f₁] (y₁ : X.nonDegenerate m) (hy₁ : x = X.map f₁.op y₁)
(f₂ : ⦋n⦌ ⟶ ⦋m⦌) (y₂ : X.nonDegenerate m) (hy₂ : x = X.map f₂.op y₂) :
f₁ = f₂ := by
ext x : 3
suffices ∃ (hf₁ : SplitEpi f₁), hf₁.section_.toOrderHom (f₁.toOrderHom x) = x by
obtain ⟨hf₁, hf₁'⟩ := this
dsimp at hf₁'
simpa [g, hf₁'] using (SimplexCategory.congr_toOrderHom_apply (g_eq_id hy₁ hy₂ hf₁)
(f₁.toOrderHom x)).symm
obtain ⟨⟨hf⟩⟩ := isSplitEpi_of_epi f₁
let α (y : Fin (m + 1)) : Fin (n + 1) :=
if y = f₁.toOrderHom x then x else hf.section_.toOrderHom y
have hα₁ (y : Fin (m + 1)) : f₁.toOrderHom (α y) = y := by
dsimp [α]
split_ifs with hy
· rw [hy]
· apply SimplexCategory.congr_toOrderHom_apply hf.id
have hα₂ : Monotone α := by
rintro y₁ y₂ h
by_contra! h'
suffices y₂ ≤ y₁ by simp [show y₁ = y₂ by cutsat] at h'
simpa only [hα₁] using f₁.toOrderHom.monotone h'.le
exact ⟨{ section_ := SimplexCategory.Hom.mk ⟨α, hα₂⟩, id := by ext : 3; apply hα₁ },
by simp [α]⟩
end
namespace Subcomplex
variable {X} (A : X.Subcomplex)
lemma mem_degenerate_iff {n : ℕ} (x : A.obj (op ⦋n⦌)) :
x ∈ degenerate A n ↔ x.val ∈ X.degenerate n := by
rw [SSet.mem_degenerate_iff, SSet.mem_degenerate_iff]
constructor
· rintro ⟨m, hm, f, _, y, rfl⟩
exact ⟨m, hm, f, inferInstance, y.val, rfl⟩
· obtain ⟨x, hx⟩ := x
rintro ⟨m, hm, f, _, ⟨y, rfl⟩⟩
refine ⟨m, hm, f, inferInstance, ⟨y, ?_⟩, rfl⟩
have := isSplitEpi_of_epi f
simpa [Set.mem_preimage, ← op_comp, ← FunctorToTypes.map_comp_apply,
IsSplitEpi.id, op_id, FunctorToTypes.map_id_apply] using A.map (section_ f).op hx
lemma mem_nonDegenerate_iff {n : ℕ} (x : A.obj (op ⦋n⦌)) :
x ∈ nonDegenerate A n ↔ x.val ∈ X.nonDegenerate n := by
rw [mem_nonDegenerate_iff_notMem_degenerate,
mem_nonDegenerate_iff_notMem_degenerate, mem_degenerate_iff]
lemma le_iff_contains_nonDegenerate (B : X.Subcomplex) :
A ≤ B ↔ ∀ (n : ℕ) (x : X.nonDegenerate n), x.val ∈ A.obj _ → x.val ∈ B.obj _ := by
constructor
· aesop
· rintro h ⟨n⟩ x hx
induction n using SimplexCategory.rec with | _ n =>
obtain ⟨m, f, _, ⟨a, ha⟩, ha'⟩ := exists_nonDegenerate A ⟨x, hx⟩
simp only [Subpresheaf.toPresheaf_obj, Subtype.ext_iff,
Subpresheaf.toPresheaf_map_coe] at ha'
subst ha'
rw [mem_nonDegenerate_iff] at ha
exact B.map f.op (h _ ⟨_, ha⟩ a.prop)
lemma eq_top_iff_contains_nonDegenerate :
A = ⊤ ↔ ∀ (n : ℕ), X.nonDegenerate n ⊆ A.obj _ := by
simpa using le_iff_contains_nonDegenerate ⊤ A
lemma degenerate_eq_top_iff (n : ℕ) :
degenerate A n = ⊤ ↔ (X.degenerate n ⊓ A.obj _) = A.obj _ := by
constructor
· intro h
ext x
simp only [Set.inf_eq_inter, Set.mem_inter_iff, and_iff_right_iff_imp]
intro hx
simp [← A.mem_degenerate_iff ⟨x, hx⟩, h, Set.top_eq_univ, Set.mem_univ]
· intro h
simp only [Set.inf_eq_inter, Set.inter_eq_right] at h
ext x
simpa [A.mem_degenerate_iff] using h x.prop
variable (X) in
lemma iSup_ofSimplex_nonDegenerate_eq_top :
⨆ (x : Σ (p : ℕ), X.nonDegenerate p), ofSimplex x.2.val = ⊤ := by
rw [eq_top_iff_contains_nonDegenerate]
intro n x hx
simp only [Subpresheaf.iSup_obj, Set.mem_iUnion, Sigma.exists,
Subtype.exists, exists_prop]
exact ⟨n, x, hx, mem_ofSimplex_obj x⟩
end Subcomplex
section
variable {X} {Y : SSet.{u}}
lemma degenerate_app_apply {n : ℕ} {x : X _⦋n⦌} (hx : x ∈ X.degenerate n) (f : X ⟶ Y) :
f.app _ x ∈ Y.degenerate n := by
obtain ⟨m, hm, g, y, rfl⟩ := hx
exact ⟨m, hm, g, f.app _ y, by rw [FunctorToTypes.naturality]⟩
lemma degenerate_le_preimage (f : X ⟶ Y) (n : ℕ) :
X.degenerate n ⊆ (f.app _)⁻¹' (Y.degenerate n) :=
fun _ hx ↦ degenerate_app_apply hx f
lemma image_degenerate_le (f : X ⟶ Y) (n : ℕ) :
(f.app _)'' (X.degenerate n) ⊆ Y.degenerate n := by
simpa using degenerate_le_preimage f n
lemma degenerate_iff_of_isIso (f : X ⟶ Y) [IsIso f] {n : ℕ} (x : X _⦋n⦌) :
f.app _ x ∈ Y.degenerate n ↔ x ∈ X.degenerate n := by
constructor
· intro hy
simpa [← FunctorToTypes.comp] using degenerate_app_apply hy (inv f)
· exact fun hx ↦ degenerate_app_apply hx f
lemma nonDegenerate_iff_of_isIso (f : X ⟶ Y) [IsIso f] {n : ℕ} (x : X _⦋n⦌) :
f.app _ x ∈ Y.nonDegenerate n ↔ x ∈ X.nonDegenerate n := by
simp [mem_nonDegenerate_iff_notMem_degenerate,
degenerate_iff_of_isIso]
attribute [local simp] nonDegenerate_iff_of_isIso in
/-- The bijection on nondegenerate simplices induced by an isomorphism
of simplicial sets. -/
@[simps]
def nonDegenerateEquivOfIso (e : X ≅ Y) {n : ℕ} :
X.nonDegenerate n ≃ Y.nonDegenerate n where
toFun := fun ⟨x, hx⟩ ↦ ⟨e.hom.app _ x, by aesop⟩
invFun := fun ⟨y, hy⟩ ↦ ⟨e.inv.app _ y, by aesop⟩
left_inv _ := by aesop
right_inv _ := by aesop
end
variable {X} in
lemma degenerate_iff_of_mono {Y : SSet.{u}} (f : X ⟶ Y) [Mono f] (x : X _⦋n⦌) :
f.app _ x ∈ Y.degenerate n ↔ x ∈ X.degenerate n := by
rw [← degenerate_iff_of_isIso (Subcomplex.toRange f) x,
Subcomplex.mem_degenerate_iff]
simp
variable {X} in
lemma nonDegenerate_iff_of_mono {Y : SSet.{u}} (f : X ⟶ Y) [Mono f] (x : X _⦋n⦌) :
f.app _ x ∈ Y.nonDegenerate n ↔ x ∈ X.nonDegenerate n := by
simp [mem_nonDegenerate_iff_notMem_degenerate, degenerate_iff_of_mono]
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/NonDegenerateSimplicesSubcomplex.lean | import Mathlib.AlgebraicTopology.SimplicialSet.NonDegenerateSimplices
/-!
# The type of nondegenerate simplices not in a subcomplex
In this file, given a subcomplex `A` of a simplicial set `X`,
we introduce the type `A.N` of nondegenerate simplices of `X`
that are not in `A`.
-/
universe u
open CategoryTheory Simplicial
namespace SSet.Subcomplex
variable {X : SSet.{u}} (A : X.Subcomplex)
/-- The type of nondegenerate simplices which do not belong to
a given subcomplex of a simplicial set. -/
structure N extends X.N where mk' ::
notMem : simplex ∉ A.obj _
namespace N
variable {A}
lemma mk'_surjective (s : A.N) :
∃ (t : X.N) (ht : t.simplex ∉ A.obj _), s = mk' t ht :=
⟨s.toN, s.notMem, rfl⟩
/-- Constructor for the type of nondegenerate simplices which
do not belong to a given subcomplex of a simplicial set. -/
@[simps!]
def mk {n : ℕ} (x : X _⦋n⦌) (hx : x ∈ X.nonDegenerate n)
(hx' : x ∉ A.obj _) : A.N where
simplex := x
nonDegenerate := hx
notMem := hx'
lemma mk_surjective (s : A.N) :
∃ (n : ℕ) (x : X _⦋n⦌) (hx : x ∈ X.nonDegenerate n)
(hx' : x ∉ A.obj _), s = mk x hx hx' :=
⟨s.dim, s.simplex, s.nonDegenerate, s.notMem, rfl⟩
lemma ext_iff (x y : A.N) :
x = y ↔ x.toN = y.toN := by
grind [cases SSet.Subcomplex.N]
instance : PartialOrder A.N :=
PartialOrder.lift toN (fun _ _ ↦ by simp [ext_iff])
lemma le_iff {x y : A.N} : x ≤ y ↔ x.toN ≤ y.toN :=
Iff.rfl
section
variable (s : A.N) {d : ℕ} (hd : s.dim = d)
/-- When `A` is a subcomplex of a simplicial set `X`,
and `s : A.N` is such that `s.dim = d`, this is a term
that is equal to `s`, but whose dimension if definitionally equal to `d`. -/
abbrev cast : A.N where
toN := s.toN.cast hd
notMem := hd ▸ s.notMem
lemma cast_eq_self : s.cast hd = s := by
subst hd
rfl
end
end N
end SSet.Subcomplex |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/StdSimplex.lean | import Mathlib.AlgebraicTopology.SimplicialSet.NerveNondegenerate
import Mathlib.Data.Fin.VecNotation
import Mathlib.Order.Fin.SuccAboveOrderIso
/-!
# The standard simplex
We define the standard simplices `Δ[n]` as simplicial sets.
See files `SimplicialSet.Boundary` and `SimplicialSet.Horn`
for their boundaries`∂Δ[n]` and horns `Λ[n, i]`.
(The notations are available via `open Simplicial`.)
-/
universe u
open CategoryTheory Limits Simplicial Opposite
namespace SSet
/-- The functor `SimplexCategory ⥤ SSet` which sends `⦋n⦌` to the standard simplex `Δ[n]` is a
cosimplicial object in the category of simplicial sets. (This functor is essentially given by the
Yoneda embedding). -/
def stdSimplex : CosimplicialObject SSet.{u} := uliftYoneda
@[inherit_doc SSet.stdSimplex]
scoped[Simplicial] notation3 "Δ[" n "]" => SSet.stdSimplex.obj (SimplexCategory.mk n)
instance : Inhabited SSet :=
⟨Δ[0]⟩
instance {n} : Inhabited (SSet.Truncated n) :=
⟨(truncation n).obj <| Δ[0]⟩
namespace stdSimplex
open Finset Opposite SimplexCategory
@[simp]
lemma map_id (n : SimplexCategory) :
(SSet.stdSimplex.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ᵒᵖ} :
(stdSimplex.{u}.obj n).obj m ≃ (m.unop ⟶ n) :=
Equiv.ulift.{u, 0}
/-- If `x : Δ[n] _⦋d⦌` and `i : Fin (d + 1)`, we may evaluate `x i : Fin (n + 1)`. -/
instance (n i : ℕ) : FunLike (Δ[n] _⦋i⦌) (Fin (i + 1)) (Fin (n + 1)) where
coe x j := (objEquiv x).toOrderHom j
coe_injective' _ _ h := objEquiv.injective (by ext : 3; apply congr_fun h)
lemma monotone_apply {n i : ℕ} (x : Δ[n] _⦋i⦌) :
Monotone (fun (j : Fin (i + 1)) ↦ x j) :=
(objEquiv x).toOrderHom.monotone
@[ext]
lemma ext {n d : ℕ} (x y : Δ[n] _⦋d⦌) (h : ∀ (i : Fin (d + 1)), x i = y i) : x = y :=
DFunLike.ext _ _ h
@[simp]
lemma objEquiv_toOrderHom_apply {n i : ℕ}
(x : (stdSimplex.{u} ^⦋n⦌).obj (op ⦋i⦌)) (j : Fin (i + 1)) :
DFunLike.coe (F := Fin (i + 1) →o Fin (n + 1))
((DFunLike.coe (F := Δ[n].obj (op ⦋i⦌) ≃ (⦋i⦌ ⟶ ⦋n⦌))
objEquiv x)).toOrderHom j = x j :=
rfl
lemma objEquiv_symm_comp {n n' : SimplexCategory} {m : SimplexCategoryᵒᵖ}
(f : m.unop ⟶ n) (g : n ⟶ n') :
objEquiv.{u}.symm (f ≫ g) =
(stdSimplex.map g).app _ (objEquiv.{u}.symm f) := rfl
@[simp]
lemma objEquiv_symm_apply {n m : ℕ} (f : ⦋m⦌ ⟶ ⦋n⦌) (i : Fin (m + 1)) :
(objEquiv.{u}.symm f : Δ[n] _⦋m⦌) i = f.toOrderHom i := rfl
/-- 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)) :
(stdSimplex.{u}.obj n).obj m :=
objEquiv.symm (Hom.mk f)
@[simp]
lemma objMk_apply {n m : ℕ} (f : Fin (m + 1) →o Fin (n + 1)) (i : Fin (m + 1)) :
objMk.{u} (n := ⦋n⦌) (m := op ⦋m⦌) f i = f i :=
rfl
/-- 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
lemma map_apply {m₁ m₂ : SimplexCategoryᵒᵖ} (f : m₁ ⟶ m₂) {n : SimplexCategory}
(x : (stdSimplex.{u}.obj n).obj m₁) :
(stdSimplex.{u}.obj n).map f x = objEquiv.symm (f.unop ≫ objEquiv x) := by
rfl
/-- The canonical bijection `(stdSimplex.obj n ⟶ X) ≃ X.obj (op n)`. -/
def _root_.SSet.yonedaEquiv {X : SSet.{u}} {n : SimplexCategory} :
(stdSimplex.obj n ⟶ X) ≃ X.obj (op n) :=
uliftYonedaEquiv
lemma yonedaEquiv_map {n m : SimplexCategory} (f : n ⟶ m) :
yonedaEquiv.{u} (stdSimplex.map f) = objEquiv.symm f :=
yonedaEquiv.symm.injective rfl
/-- 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 `0`-simplices of `Δ[n]` identify to the elements in `Fin (n + 1)`. -/
@[simps]
def obj₀Equiv {n : ℕ} : Δ[n] _⦋0⦌ ≃ Fin (n + 1) where
toFun x := x 0
invFun i := const _ i _
left_inv x := by ext i : 1; fin_cases i; 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 [*, 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
attribute [local simp] image_subset_iff
/-- Given `S : Finset (Fin (n + 1))`, this is the corresponding face of `Δ[n]`,
as a subcomplex. -/
@[simps -isSimp obj]
def face {n : ℕ} (S : Finset (Fin (n + 1))) : (Δ[n] : SSet.{u}).Subcomplex where
obj U := setOf (fun f ↦ Finset.image (objEquiv f).toOrderHom ⊤ ≤ S)
map {U V} i := by aesop
attribute [local simp] face_obj
@[simp]
lemma mem_face_iff {n : ℕ} (S : Finset (Fin (n + 1))) {d : ℕ} (x : (Δ[n] : SSet.{u}) _⦋d⦌) :
x ∈ (face S).obj _ ↔ ∀ (i : Fin (d + 1)), x i ∈ S := by
simp
lemma face_inter_face {n : ℕ} (S₁ S₂ : Finset (Fin (n + 1))) :
face S₁ ⊓ face S₂ = face (S₁ ⊓ S₂) := by
aesop
end stdSimplex
lemma yonedaEquiv_comp {X Y : SSet.{u}} {n : SimplexCategory}
(f : stdSimplex.obj n ⟶ X) (g : X ⟶ Y) :
yonedaEquiv (f ≫ g) = g.app _ (yonedaEquiv f) := rfl
namespace Subcomplex
variable {X : SSet.{u}}
lemma range_eq_ofSimplex {n : ℕ} (f : Δ[n] ⟶ X) :
Subpresheaf.range f = ofSimplex (yonedaEquiv f) :=
Subpresheaf.range_eq_ofSection' _
lemma yonedaEquiv_coe {A : X.Subcomplex} {n : SimplexCategory}
(f : stdSimplex.obj n ⟶ A) :
(DFunLike.coe (F := ((stdSimplex.obj n ⟶ Subpresheaf.toPresheaf A) ≃ A.obj (op n)))
yonedaEquiv f).val = yonedaEquiv (f ≫ A.ι) := by
rfl
end Subcomplex
namespace stdSimplex
lemma face_eq_ofSimplex {n : ℕ} (S : Finset (Fin (n + 1))) (m : ℕ) (e : Fin (m + 1) ≃o S) :
face.{u} S =
Subcomplex.ofSimplex (X := Δ[n])
(objMk ((OrderHom.Subtype.val _).comp
e.toOrderEmbedding.toOrderHom)) := by
apply le_antisymm
· rintro ⟨k⟩ x hx
induction k using SimplexCategory.rec with | _ k
rw [mem_face_iff] at hx
let φ : Fin (k + 1) →o S :=
{ toFun i := ⟨x i, hx i⟩
monotone' := (objEquiv x).toOrderHom.monotone }
refine ⟨Quiver.Hom.op
(SimplexCategory.Hom.mk ((e.symm.toOrderEmbedding.toOrderHom.comp φ))), ?_⟩
obtain ⟨f, rfl⟩ := objEquiv.symm.surjective x
ext j : 1
simpa only [Subtype.ext_iff] using e.apply_symm_apply ⟨_, hx j⟩
· simp
/-- If `S : Finset (Fin (n + 1))` is order isomorphic to `Fin (m + 1)`,
then the face `face S` of `Δ[n]` is representable by `m`,
i.e. `face S` is isomorphic to `Δ[m]`, see `stdSimplex.isoOfRepresentableBy`. -/
def faceRepresentableBy {n : ℕ} (S : Finset (Fin (n + 1)))
(m : ℕ) (e : Fin (m + 1) ≃o S) :
(face S : SSet.{u}).RepresentableBy ⦋m⦌ where
homEquiv {j} :=
{ toFun f := ⟨objMk ((OrderHom.Subtype.val (SetLike.coe S)).comp
(e.toOrderEmbedding.toOrderHom.comp f.toOrderHom)), fun _ ↦ by aesop⟩
invFun := fun ⟨x, hx⟩ ↦ SimplexCategory.Hom.mk
{ toFun i := e.symm ⟨(objEquiv x).toOrderHom i, hx (by aesop)⟩
monotone' i₁ i₂ h := e.symm.monotone (by
simp only [Subtype.mk_le_mk]
exact OrderHom.monotone _ h) }
left_inv f := by
ext i : 3
apply e.symm_apply_apply
right_inv := fun ⟨x, hx⟩ ↦ by
induction j using SimplexCategory.rec with | _ j
dsimp
ext i : 2
exact congr_arg Subtype.val
(e.apply_symm_apply ⟨(objEquiv x).toOrderHom i, _⟩) }
homEquiv_comp f g := by aesop
/-- If a simplicial set `X` is representable by `⦋m⦌` for some `m : ℕ`, then this is the
corresponding isomorphism `Δ[m] ≅ X`. -/
def isoOfRepresentableBy {X : SSet.{u}} {m : ℕ} (h : X.RepresentableBy ⦋m⦌) :
Δ[m] ≅ X :=
NatIso.ofComponents (fun n ↦ Equiv.toIso (objEquiv.trans h.homEquiv))
(fun _ ↦ by ext; apply h.homEquiv_comp)
lemma ofSimplex_yonedaEquiv_δ {n : ℕ} (i : Fin (n + 2)) :
Subcomplex.ofSimplex (yonedaEquiv (stdSimplex.δ i)) = face.{u} {i}ᶜ :=
(face_eq_ofSimplex _ _ (Fin.succAboveOrderIso i)).symm
@[simp]
lemma range_δ {n : ℕ} (i : Fin (n + 2)) :
Subpresheaf.range (stdSimplex.δ i) = face.{u} {i}ᶜ := by
rw [Subcomplex.range_eq_ofSimplex]
exact ofSimplex_yonedaEquiv_δ i
/-- The standard simplex identifies to the nerve to the preordered type
`ULift (Fin (n + 1))`. -/
@[pp_with_univ]
def isoNerve (n : ℕ) :
(Δ[n] : SSet.{u}) ≅ nerve (ULift.{u} (Fin (n + 1))) :=
NatIso.ofComponents (fun d ↦ Equiv.toIso (objEquiv.trans
{ toFun f := (ULift.orderIso.symm.monotone.comp f.toOrderHom.monotone).functor
invFun f :=
SimplexCategory.Hom.mk
(ULift.orderIso.toOrderEmbedding.toOrderHom.comp f.toOrderHom)
left_inv _ := by aesop }))
@[simp]
lemma isoNerve_hom_app_apply {n d : ℕ}
(s : (Δ[n] _⦋d⦌)) (i : Fin (d + 1)) :
((isoNerve.{u} n).hom.app _ s).obj i = ULift.up (s i) := rfl
@[simp]
lemma isoNerve_inv_app_apply {n d : ℕ}
(F : (nerve (ULift.{u} (Fin (n + 1)))) _⦋d⦌) (i : Fin (d + 1)) :
(isoNerve.{u} n).inv.app _ F i = (F.obj i).down := rfl
lemma mem_nonDegenerate_iff_strictMono {n d : ℕ} (s : (Δ[n] : SSet.{u}) _⦋d⦌) :
s ∈ Δ[n].nonDegenerate d ↔ StrictMono s := by
rw [← nonDegenerate_iff_of_mono (isoNerve n).hom,
PartialOrder.mem_nerve_nonDegenerate_iff_strictMono]
rfl
lemma mem_nonDegenerate_iff_mono {n d : ℕ} (s : (Δ[n] : SSet.{u}) _⦋d⦌) :
s ∈ Δ[n].nonDegenerate d ↔ Mono (objEquiv s) := by
rw [mem_nonDegenerate_iff_strictMono,
SimplexCategory.mono_iff_injective]
refine ⟨fun h ↦ h.injective, fun h ↦ ?_⟩
rw [Fin.strictMono_iff_lt_succ]
intro i
obtain h' | h' := (stdSimplex.monotone_apply s i.castSucc_le_succ).lt_or_eq
· exact h'
· simpa [Fin.ext_iff] using h h'
lemma objEquiv_symm_mem_nonDegenerate_iff_mono {n d : ℕ} (f : ⦋d⦌ ⟶ ⦋n⦌) :
(objEquiv.{u} (m := (op ⦋d⦌))).symm f ∈ Δ[n].nonDegenerate d ↔ Mono f := by
simp [mem_nonDegenerate_iff_mono]
/-- Nondegenerate `d`-dimensional simplices of the standard simplex `Δ[n]`
identify to order embeddings `Fin (d + 1) ↪o Fin (n + 1)`. -/
@[simps! apply_apply symm_apply_coe]
def nonDegenerateEquiv {n d : ℕ} :
(Δ[n] : SSet.{u}).nonDegenerate d ≃ (Fin (d + 1) ↪o Fin (n + 1)) where
toFun s := OrderEmbedding.ofStrictMono _ ((mem_nonDegenerate_iff_strictMono _).1 s.2)
invFun s := ⟨objEquiv.symm (.mk s.toOrderHom), by
simpa [mem_nonDegenerate_iff_strictMono] using s.strictMono⟩
left_inv _ := by aesop
end stdSimplex
section Examples
open Simplicial
/-- The simplicial circle. -/
noncomputable def S1 : SSet :=
Limits.colimit <|
Limits.parallelPair (stdSimplex.δ 0 : Δ[0] ⟶ Δ[1]) (stdSimplex.δ 1)
end Examples
namespace Augmented
/-- 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 stdSimplex : SimplexCategory ⥤ SSet.Augmented.{u} where
obj Δ :=
{ left := SSet.stdSimplex.obj Δ
right := terminal _
hom := { app := fun _ => terminal.from _ } }
map θ :=
{ left := SSet.stdSimplex.map θ
right := terminal.from _ }
end Augmented
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Coskeletal.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Coskeletal
import Mathlib.AlgebraicTopology.SimplicialSet.StrictSegal
import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction
import Mathlib.CategoryTheory.Functor.KanExtension.Basic
/-!
# Coskeletal simplicial sets
In this file, we prove that if `X` is `StrictSegal` then `X` is 2-coskeletal,
i.e. `X ≅ (cosk 2).obj X`. In particular, nerves of categories are 2-coskeletal.
This isomorphism follows from the fact that `rightExtensionInclusion X 2` is a right Kan
extension. In fact, we show that when `X` is `StrictSegal` then
`(rightExtensionInclusion X n).IsPointwiseRightKanExtension` holds.
As an example, `SimplicialObject.IsCoskeletal (nerve C) 2` shows that nerves of categories are
2-coskeletal.
-/
universe v u
open CategoryTheory Simplicial SimplexCategory Truncated
open Opposite Category Functor Limits
namespace SSet
namespace Truncated
/-- The identity natural transformation exhibits a simplicial set as a right extension of its
restriction along `(Truncated.inclusion (n := n)).op`. -/
@[simps!]
def rightExtensionInclusion (X : SSet.{u}) (n : ℕ) :
RightExtension (Truncated.inclusion (n := n)).op
((Truncated.inclusion n).op ⋙ X) := RightExtension.mk _ (𝟙 _)
end Truncated
section
open StructuredArrow
namespace StrictSegal
variable {X : SSet.{u}} (sx : StrictSegal X)
namespace isPointwiseRightKanExtensionAt
/-- A morphism in `SimplexCategory` with domain `⦋0⦌`, `⦋1⦌`, or `⦋2⦌` defines an object in the
comma category `StructuredArrow (op ⦋n⦌) (Truncated.inclusion (n := 2)).op`. -/
abbrev strArrowMk₂ {i : ℕ} {n : ℕ} (φ : ⦋i⦌ ⟶ ⦋n⦌) (hi : i ≤ 2 := by omega) :
StructuredArrow (op ⦋n⦌) (Truncated.inclusion 2).op :=
StructuredArrow.mk (Y := op ⦋i⦌₂) φ.op
/-- Given a term in the cone over the diagram
`(proj (op ⦋n⦌) ((Truncated.inclusion 2).op ⋙ (Truncated.inclusion 2).op ⋙ X)` where `X` is
Strict Segal, one can produce an `n`-simplex in `X`. -/
@[simp]
noncomputable def lift {X : SSet.{u}} (sx : StrictSegal X) {n}
(s : Cone (proj (op ⦋n⦌) (Truncated.inclusion 2).op ⋙
(Truncated.inclusion 2).op ⋙ X)) (x : s.pt) : X _⦋n⦌ :=
sx.spineToSimplex {
vertex := fun i ↦ s.π.app (.mk (Y := op ⦋0⦌₂) (.op (SimplexCategory.const _ _ i))) x
arrow := fun i ↦ s.π.app (.mk (Y := op ⦋1⦌₂) (.op (mkOfLe _ _ (Fin.castSucc_le_succ i)))) x
arrow_src := fun i ↦ by
let φ : strArrowMk₂ (mkOfLe _ _ (Fin.castSucc_le_succ i)) ⟶
strArrowMk₂ (⦋0⦌.const _ i.castSucc) :=
StructuredArrow.homMk (δ 1).op
(Quiver.Hom.unop_inj (by ext x; fin_cases x; rfl))
exact congr_fun (s.w φ) x
arrow_tgt := fun i ↦ by
dsimp
let φ : strArrowMk₂ (mkOfLe _ _ (Fin.castSucc_le_succ i)) ⟶
strArrowMk₂ (⦋0⦌.const _ i.succ) :=
StructuredArrow.homMk (δ 0).op
(Quiver.Hom.unop_inj (by ext x; fin_cases x; rfl))
exact congr_fun (s.w φ) x }
lemma fac_aux₁ {n : ℕ}
(s : Cone (proj (op ⦋n⦌) (Truncated.inclusion 2).op ⋙ (Truncated.inclusion 2).op ⋙ X))
(x : s.pt) (i : ℕ) (hi : i < n) :
X.map (mkOfSucc ⟨i, hi⟩).op (lift sx s x) =
s.π.app (strArrowMk₂ (mkOfSucc ⟨i, hi⟩)) x := by
dsimp [lift]
rw [spineToSimplex_arrow]
rfl
lemma fac_aux₂ {n : ℕ}
(s : Cone (proj (op ⦋n⦌) (Truncated.inclusion 2).op ⋙ (Truncated.inclusion 2).op ⋙ X))
(x : s.pt) (i j : ℕ) (hij : i ≤ j) (hj : j ≤ n) :
X.map (mkOfLe ⟨i, by cutsat⟩ ⟨j, by cutsat⟩ hij).op (lift sx s x) =
s.π.app (strArrowMk₂ (mkOfLe ⟨i, by cutsat⟩ ⟨j, by cutsat⟩ hij)) x := by
obtain ⟨k, hk⟩ := Nat.le.dest hij
revert i j
induction k with
| zero =>
rintro i j hij hj hik
obtain rfl : i = j := hik
have : mkOfLe ⟨i, Nat.lt_add_one_of_le hj⟩ ⟨i, Nat.lt_add_one_of_le hj⟩ (by rfl) =
⦋1⦌.const ⦋0⦌ 0 ≫ ⦋0⦌.const ⦋n⦌ ⟨i, Nat.lt_add_one_of_le hj⟩ := Hom.ext_one_left _ _
rw [this]
let α : (strArrowMk₂ (⦋0⦌.const ⦋n⦌ ⟨i, Nat.lt_add_one_of_le hj⟩)) ⟶
(strArrowMk₂ (⦋1⦌.const ⦋0⦌ 0 ≫ ⦋0⦌.const ⦋n⦌ ⟨i, Nat.lt_add_one_of_le hj⟩)) :=
StructuredArrow.homMk ((⦋1⦌.const ⦋0⦌ 0).op) (by simp; rfl)
have nat := congr_fun (s.π.naturality α) x
dsimp only [Fin.val_zero, Nat.add_zero, id_eq, Int.reduceNeg, Int.cast_ofNat_Int,
Int.reduceAdd, Fin.eta, comp_obj, StructuredArrow.proj_obj, op_obj, const_obj_obj,
const_obj_map, types_comp_apply, types_id_apply, Functor.comp_map, StructuredArrow.proj_map,
op_map] at nat
rw [nat, op_comp, Functor.map_comp]
simp only [types_comp_apply]
refine congrArg (X.map (⦋1⦌.const ⦋0⦌ 0).op) ?_
unfold strArrowMk₂
rw [lift, StrictSegal.spineToSimplex_vertex]
congr
| succ k hk =>
intro i j hij hj hik
let α := strArrowMk₂ (mkOfLeComp (n := n) ⟨i, by cutsat⟩ ⟨i + k, by cutsat⟩
⟨j, by cutsat⟩ (by simp) (by simp only [Fin.mk_le_mk]; cutsat))
let α₀ := strArrowMk₂ (mkOfLe (n := n) ⟨i + k, by cutsat⟩ ⟨j, by cutsat⟩
(by simp only [Fin.mk_le_mk]; cutsat))
let α₁ := strArrowMk₂ (mkOfLe (n := n) ⟨i, by cutsat⟩ ⟨j, by cutsat⟩ hij)
let α₂ := strArrowMk₂ (mkOfLe (n := n) ⟨i, by cutsat⟩ ⟨i + k, by cutsat⟩ (by simp))
let β₀ : α ⟶ α₀ := StructuredArrow.homMk ((mkOfSucc 1).op) (Quiver.Hom.unop_inj
(by ext x; fin_cases x <;> rfl))
let β₁ : α ⟶ α₁ := StructuredArrow.homMk ((δ 1).op) (Quiver.Hom.unop_inj
(by ext x; fin_cases x <;> rfl))
let β₂ : α ⟶ α₂ := StructuredArrow.homMk ((mkOfSucc 0).op) (Quiver.Hom.unop_inj
(by ext x; fin_cases x <;> rfl))
have h₀ : X.map α₀.hom (lift sx s x) = s.π.app α₀ x := by
subst hik
exact fac_aux₁ _ _ _ _ hj
have h₂ : X.map α₂.hom (lift sx s x) = s.π.app α₂ x :=
hk i (i + k) (by simp) (by cutsat) rfl
change X.map α₁.hom (lift sx s x) = s.π.app α₁ x
have : X.map α.hom (lift sx s x) = s.π.app α x := by
apply sx.spineInjective
apply Path.ext'
intro t
dsimp only [spineEquiv]
rw [Equiv.coe_fn_mk, spine_arrow, spine_arrow,
← FunctorToTypes.map_comp_apply]
match t with
| 0 =>
have : α.hom ≫ (mkOfSucc 0).op = α₂.hom :=
Quiver.Hom.unop_inj (by ext x; fin_cases x <;> rfl)
rw [this, h₂, ← congr_fun (s.w β₂) x]
rfl
| 1 =>
have : α.hom ≫ (mkOfSucc 1).op = α₀.hom :=
Quiver.Hom.unop_inj (by ext x; fin_cases x <;> rfl)
rw [this, h₀, ← congr_fun (s.w β₀) x]
rfl
rw [← StructuredArrow.w β₁, FunctorToTypes.map_comp_apply, this, ← s.w β₁]
dsimp
lemma fac_aux₃ {n : ℕ}
(s : Cone (proj (op ⦋n⦌) (Truncated.inclusion 2).op ⋙ (Truncated.inclusion 2).op ⋙ X))
(x : s.pt) (φ : ⦋1⦌ ⟶ ⦋n⦌) :
X.map φ.op (lift sx s x) = s.π.app (strArrowMk₂ φ) x := by
obtain ⟨i, j, hij, rfl⟩ : ∃ i j hij, φ = mkOfLe i j hij :=
⟨φ.toOrderHom 0, φ.toOrderHom 1, φ.toOrderHom.monotone (by decide),
Hom.ext_one_left _ _ rfl rfl⟩
exact fac_aux₂ _ _ _ _ _ _ (by cutsat)
end isPointwiseRightKanExtensionAt
open Truncated
open isPointwiseRightKanExtensionAt in
/-- A strict Segal simplicial set is 2-coskeletal. -/
noncomputable def isPointwiseRightKanExtensionAt (n : ℕ) :
(rightExtensionInclusion X 2).IsPointwiseRightKanExtensionAt ⟨⦋n⦌⟩ where
lift s x := lift sx s x
fac s j := by
ext x
obtain ⟨⟨i, hi⟩, ⟨f : _ ⟶ _⟩, rfl⟩ := j.mk_surjective
obtain ⟨i, rfl⟩ : ∃ j, ⦋j⦌ = i := ⟨_, i.mk_len⟩
dsimp at hi ⊢
apply sx.spineInjective
dsimp
ext k
· dsimp only [spineEquiv, Equiv.coe_fn_mk]
rw [show op f = f.op from rfl]
rw [spine_map_vertex, spine_spineToSimplex_apply, spine_vertex]
let α : strArrowMk₂ f hi ⟶ strArrowMk₂ (⦋0⦌.const ⦋n⦌ (f.toOrderHom k)) :=
StructuredArrow.homMk ((⦋0⦌.const _ (by exact k)).op) (by simp; rfl)
exact congr_fun (s.w α).symm x
· dsimp only [spineEquiv, Equiv.coe_fn_mk, spine_arrow]
rw [← FunctorToTypes.map_comp_apply]
let α : strArrowMk₂ f ⟶ strArrowMk₂ (mkOfSucc k ≫ f) :=
StructuredArrow.homMk (mkOfSucc k).op (by simp; rfl)
exact (isPointwiseRightKanExtensionAt.fac_aux₃ _ _ _ _).trans (congr_fun (s.w α).symm x)
uniq s m hm := by
ext x
apply sx.spineInjective (X := X)
dsimp [spineEquiv]
rw [sx.spine_spineToSimplex_apply]
ext i
· exact congr_fun (hm (StructuredArrow.mk (Y := op ⦋0⦌₂) (⦋0⦌.const ⦋n⦌ i).op)) x
· exact congr_fun (hm (.mk (Y := op ⦋1⦌₂) (.op (mkOfLe _ _ (Fin.castSucc_le_succ i))))) x
/-- Since `StrictSegal.isPointwiseRightKanExtensionAt` proves that the appropriate
cones are limit cones, `rightExtensionInclusion X 2` is a pointwise right Kan extension. -/
noncomputable def isPointwiseRightKanExtension :
(rightExtensionInclusion X 2).IsPointwiseRightKanExtension :=
fun Δ => sx.isPointwiseRightKanExtensionAt Δ.unop.len
theorem isRightKanExtension (sx : StrictSegal X) :
X.IsRightKanExtension (𝟙 ((inclusion 2).op ⋙ X)) :=
RightExtension.IsPointwiseRightKanExtension.isRightKanExtension
sx.isPointwiseRightKanExtension
/-- When `X` is `StrictSegal`, `X` is 2-coskeletal. -/
theorem isCoskeletal (sx : StrictSegal X) :
SimplicialObject.IsCoskeletal X 2 where
isRightKanExtension := sx.isRightKanExtension
/-- When `X` satisfies `IsStrictSegal`, `X` is 2-coskeletal. -/
instance isCoskeletal' [IsStrictSegal X] : SimplicialObject.IsCoskeletal X 2 :=
isCoskeletal <| ofIsStrictSegal X
end StrictSegal
end
end SSet
namespace CategoryTheory
namespace Nerve
open SSet
instance (C : Type u) [Category.{v} C] :
SimplicialObject.IsCoskeletal (nerve C) 2 := inferInstance
/-- The essential data of the nerve functor is contained in the 2-truncation, which is
recorded by the composite functor `nerveFunctor₂`. -/
def nerveFunctor₂ : Cat.{v, u} ⥤ SSet.Truncated 2 := nerveFunctor ⋙ truncation 2
instance (X : Cat.{v, u}) : (nerveFunctor₂.obj X).IsStrictSegal := by
dsimp [nerveFunctor₂]
infer_instance
/-- The natural isomorphism between `nerveFunctor` and `nerveFunctor₂ ⋙ Truncated.cosk 2` whose
components `nerve C ≅ (Truncated.cosk 2).obj (nerveFunctor₂.obj C)` shows that nerves of categories
are 2-coskeletal. -/
noncomputable def cosk₂Iso : nerveFunctor.{v, u} ≅ nerveFunctor₂.{v, u} ⋙ Truncated.cosk 2 :=
NatIso.ofComponents (fun C ↦ (nerve C).isoCoskOfIsCoskeletal 2)
(fun _ ↦ (coskAdj 2).unit.naturality _)
end Nerve
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/PairingCore.lean | import Mathlib.AlgebraicTopology.SimplicialSet.AnodyneExtensions.Pairing
/-!
# Helper structure in order to construct pairings
In this file, we introduce a helper structure `Subcomplex.PairingCore`
in order to construct a pairing for a subcomplex of a simplicial set.
The main difference with `Subcomplex.Pairing` are that we provide
an index type `ι` and a function `dim : ι → ℕ` which allow to
parametrize type (II) and (I) simplices in such a way that, *definitionally*,
their dimensions are respectively `dim s` or `dim s + 1` for `s : ι`.
-/
universe v u
open CategoryTheory Simplicial
namespace SSet.Subcomplex
variable {X : SSet.{u}} (A : X.Subcomplex)
/-- An helper structure in order to construct a pairing for a subcomplex of a
simplicial set `X`. The main difference with `Pairing` is that we provide
an index type `ι` and a function `dim : ι → ℕ` which allow to
parametrize type (I) simplices as `simplex s : X _⦋dim s + 1⦌` for `s : ι`,
and type (II) simplices as a face of `simplex s` in `X _⦋dim s⦌`. -/
structure PairingCore where
/-- the index type -/
ι : Type v
/-- the dimension of each type (II) simplex -/
dim (s : ι) : ℕ
/-- the family of type (I) simplices -/
simplex (s : ι) : X _⦋dim s + 1⦌
/-- the corresponding type (II) simplex is the `1`-codimensional
face given by this index -/
index (s : ι) : Fin (dim s + 2)
nonDegenerate₁ (s : ι) : simplex s ∈ X.nonDegenerate _
nonDegenerate₂ (s : ι) : X.δ (index s) (simplex s) ∈ X.nonDegenerate _
notMem₁ (s : ι) : simplex s ∉ A.obj _
notMem₂ (s : ι) : X.δ (index s) (simplex s) ∉ A.obj _
injective_type₁' {s t : ι} (h : S.mk (simplex s) = S.mk (simplex t)) : s = t
injective_type₂' {s t : ι}
(h : S.mk (X.δ (index s) (simplex s)) = S.mk (X.δ (index t) (simplex t))) : s = t
type₁_ne_type₂' (s t : ι) : S.mk (simplex s) ≠ S.mk (X.δ (index t) (simplex t))
surjective' (x : A.N) :
∃ (s : ι), x.toS = S.mk (simplex s) ∨ x.toS = S.mk (X.δ (index s) (simplex s))
variable {A}
/-- The `PairingCore` structure induced by a pairing. The opposite construction
is `PairingCore.pairing`. -/
noncomputable def Pairing.pairingCore (P : A.Pairing) [P.IsProper] :
A.PairingCore where
ι := P.II
dim s := s.val.dim
simplex s := ((P.p s).val.cast (P.isUniquelyCodimOneFace s).dim_eq).simplex
index s := (P.isUniquelyCodimOneFace s).index rfl
nonDegenerate₁ s := ((P.p s).val.cast (P.isUniquelyCodimOneFace s).dim_eq).nonDegenerate
nonDegenerate₂ s := by
rw [(P.isUniquelyCodimOneFace s).δ_index rfl]
exact s.val.nonDegenerate
notMem₁ s := ((P.p s).val.cast (P.isUniquelyCodimOneFace s).dim_eq).notMem
notMem₂ s := by
rw [(P.isUniquelyCodimOneFace s).δ_index rfl]
exact s.val.notMem
injective_type₁' {s t} _ := by
apply P.p.injective
rwa [Subtype.ext_iff, N.ext_iff, SSet.N.ext_iff,
← (P.p s).val.cast_eq_self (P.isUniquelyCodimOneFace s).dim_eq,
← (P.p t).val.cast_eq_self (P.isUniquelyCodimOneFace t).dim_eq]
injective_type₂' {s t} h := by
rw [(P.isUniquelyCodimOneFace s).δ_index rfl,
(P.isUniquelyCodimOneFace t).δ_index rfl] at h
rwa [Subtype.ext_iff, N.ext_iff, SSet.N.ext_iff]
type₁_ne_type₂' s t h := (P.ne (P.p s) t) (by
rw [(P.isUniquelyCodimOneFace t).δ_index rfl] at h
rwa [← (P.p s).val.cast_eq_self (P.isUniquelyCodimOneFace s).dim_eq,
N.ext_iff, SSet.N.ext_iff])
surjective' x := by
obtain ⟨s, rfl | rfl⟩ := P.exists_or x
· refine ⟨s, Or.inr ?_⟩
simp [(P.isUniquelyCodimOneFace s).δ_index]
· refine ⟨s, Or.inl ?_⟩
nth_rw 1 [← (P.p s).val.cast_eq_self (P.isUniquelyCodimOneFace s).dim_eq]
rfl
namespace PairingCore
variable (h : A.PairingCore)
/-- The type (I) simplices of `h : A.PairingCore`, as a family indexed by `h.ι`. -/
@[simps!]
def type₁ (s : h.ι) : A.N :=
Subcomplex.N.mk (h.simplex s) (h.nonDegenerate₁ s) (h.notMem₁ s)
/-- The type (II) simplices of `h : A.PairingCore`, as a family indexed by `h.ι`. -/
@[simps!]
def type₂ (s : h.ι) : A.N :=
Subcomplex.N.mk (X.δ (h.index s) (h.simplex s)) (h.nonDegenerate₂ s)
(h.notMem₂ s)
lemma injective_type₁ : Function.Injective h.type₁ :=
fun _ _ hst ↦ h.injective_type₁' (by rwa [Subcomplex.N.ext_iff, SSet.N.ext_iff] at hst)
lemma injective_type₂ : Function.Injective h.type₂ :=
fun s t hst ↦ h.injective_type₂' (by rwa [Subcomplex.N.ext_iff, SSet.N.ext_iff] at hst)
lemma type₁_ne_type₂ (s t : h.ι) : h.type₁ s ≠ h.type₂ t := by
simpa only [ne_eq, N.ext_iff, SSet.N.ext_iff] using h.type₁_ne_type₂' s t
lemma surjective (x : A.N) :
∃ (s : h.ι), x = h.type₁ s ∨ x = h.type₂ s := by
obtain ⟨s, _ | _⟩ := h.surjective' x
· exact ⟨s, Or.inl (by rwa [N.ext_iff, SSet.N.ext_iff])⟩
· exact ⟨s, Or.inr (by rwa [N.ext_iff, SSet.N.ext_iff])⟩
/-- The type (I) simplices of `h : A.PairingCore`, as a subset of `A.N`. -/
def I : Set A.N := Set.range h.type₁
/-- The type (II) simplices of `h : A.PairingCore`, as a subset of `A.N`. -/
def II : Set A.N := Set.range h.type₂
/-- The bijection `h.ι ≃ h.I` when `h : A.PairingCore`. -/
@[simps! apply_coe]
noncomputable def equivI : h.ι ≃ h.I := Equiv.ofInjective _ h.injective_type₁
/-- The bijection `h.ι ≃ h.II` when `h : A.PairingCore`. -/
@[simps! apply_coe]
noncomputable def equivII : h.ι ≃ h.II := Equiv.ofInjective _ h.injective_type₂
/-- The pairing induced by `h : A.PairingCore`. -/
@[simps I II]
noncomputable def pairing : A.Pairing where
I := h.I
II := h.II
inter := by
ext s
simp only [I, II, Set.mem_inter_iff, Set.mem_range, Set.mem_empty_iff_false,
iff_false, not_and, not_exists, forall_exists_index]
rintro t rfl s
exact (h.type₁_ne_type₂ t s).symm
union := by
ext s
have := h.surjective s
simp only [I, II, Set.mem_union, Set.mem_range, Set.mem_univ, iff_true]
aesop
p := h.equivII.symm.trans h.equivI
@[simp]
lemma pairing_p_equivII (x : h.ι) :
DFunLike.coe (F := h.II ≃ h.I) h.pairing.p (h.equivII x) = h.equivI x := by
simp [pairing]
@[simp]
lemma pairing_p_symm_equivI (x : h.ι) :
DFunLike.coe (F := h.I ≃ h.II) h.pairing.p.symm (h.equivI x) = h.equivII x := by
simp [pairing]
/-- The condition that `h : A.PairingCore` is proper, i.e. for each `s : h.ι`,
the type (II) simplex `h.type₂ s` is uniquely a `1`-codimensional
face of the type (I) simplex `h.type₁ s`. -/
class IsProper : Prop where
isUniquelyCodimOneFace (s : h.ι) :
S.IsUniquelyCodimOneFace (h.type₂ s).toS (h.type₁ s).toS
lemma isUniquelyCodimOneFace [h.IsProper] (s : h.ι) :
S.IsUniquelyCodimOneFace (h.type₂ s).toS (h.type₁ s).toS :=
IsProper.isUniquelyCodimOneFace _
instance [h.IsProper] : h.pairing.IsProper where
isUniquelyCodimOneFace x := by
obtain ⟨s, rfl⟩ := h.equivII.surjective x
simpa using h.isUniquelyCodimOneFace s
@[simp]
lemma isUniquelyCodimOneFace_index [h.IsProper] (s : h.ι) :
(h.isUniquelyCodimOneFace s).index rfl = h.index s := by
symm
simp [← (h.isUniquelyCodimOneFace s).δ_eq_iff]
lemma isUniquelyCodimOneFace_index_coe
[h.IsProper] (s : h.ι) {d : ℕ} (hd : h.dim s = d) :
((h.isUniquelyCodimOneFace s).index hd).val = (h.index s).val := by
subst hd
simp
/-- The condition that `h : A.PairingCore` involves only inner horns. -/
class IsInner where
ne_zero (s : h.ι) : h.index s ≠ 0
ne_last (s : h.ι) : h.index s ≠ Fin.last _
instance [h.IsInner] [h.IsProper] : h.pairing.IsInner where
ne_zero x := by
obtain ⟨s, rfl⟩ := h.equivII.surjective x
rintro _ rfl
simpa using IsInner.ne_zero s
ne_last x := by
obtain ⟨s, rfl⟩ := h.equivII.surjective x
rintro _ rfl
simpa using IsInner.ne_last s
/-- The ancestrality relation on the index type of `h : A.PairingCore`. -/
def AncestralRel (s t : h.ι) : Prop :=
s ≠ t ∧ h.type₂ s < h.type₁ t
lemma ancestralRel_iff (s t : h.ι) :
h.AncestralRel s t ↔ h.pairing.AncestralRel (h.equivII s) (h.equivII t) := by
simp [AncestralRel, Pairing.AncestralRel]
/-- When the ancestrality relation is well founded, we say that `h : A.PairingCore`
is regular. -/
class IsRegular (h : A.PairingCore) extends h.IsProper where
wf (h) : WellFounded h.AncestralRel
instance [h.IsRegular] : h.pairing.IsRegular where
wf := by
have := IsRegular.wf h
rw [wellFounded_iff_isEmpty_descending_chain] at this ⊢
exact ⟨fun ⟨f, hf⟩ ↦ this.false
⟨fun n ↦ h.equivII.symm (f n), fun n ↦ by simpa [ancestralRel_iff] using hf n⟩⟩
end PairingCore
end SSet.Subcomplex |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/IsUniquelyCodimOneFace.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Simplices
/-!
# Simplices that are uniquely codimensional one faces
Let `X` be a simplicial set. If `x : X _⦋d⦌` and `y : X _⦋d + 1⦌`,
we say that `x` is uniquely a `1`-codimensional face of `y` if there
exists a unique `i : Fin (d + 2)` such that `X.δ i y = x`. In this file,
we extend this to a predicate `IsUniquelyCodimOneFace` involving two terms
in the type `X.S` of simplices of `X`. This is used in the
file `Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Pairing.lean` for the
study of strong (inner) anodyne extensions.
## References
* [Sean Moss, *Another approach to the Kan-Quillen model structure*][moss-2020]
-/
universe u
open CategoryTheory Simplicial
namespace SSet.S
variable {X : SSet.{u}} (x y : X.S)
/-- The property that a simplex is uniquely a `1`-codimensional face of another simplex -/
def IsUniquelyCodimOneFace : Prop :=
y.dim = x.dim + 1 ∧ ∃! (f : ⦋x.dim⦌ ⟶ ⦋y.dim⦌), Mono f ∧ X.map f.op y.simplex = x.simplex
namespace IsUniquelyCodimOneFace
lemma iff {d : ℕ} (x : X _⦋d⦌) (y : X _⦋d + 1⦌) :
IsUniquelyCodimOneFace (S.mk x) (S.mk y) ↔
∃! (i : Fin (d + 2)), X.δ i y = x := by
constructor
· rintro ⟨_, ⟨f, ⟨_, h₁⟩, h₂⟩⟩
obtain ⟨i, rfl⟩ := SimplexCategory.eq_δ_of_mono f
exact ⟨i, h₁, fun j hj ↦ SimplexCategory.δ_injective (h₂ _ ⟨inferInstance, hj⟩)⟩
· rintro ⟨i, h₁, h₂⟩
refine ⟨rfl, SimplexCategory.δ i, ⟨inferInstance, h₁⟩, fun f ⟨h₃, h₄⟩ ↦ ?_⟩
obtain ⟨j, rfl⟩ := SimplexCategory.eq_δ_of_mono f
obtain rfl : j = i := h₂ _ h₄
rfl
variable {x y} (hxy : IsUniquelyCodimOneFace x y)
include hxy in
lemma dim_eq : y.dim = x.dim + 1 := hxy.1
section
variable {d : ℕ} (hd : x.dim = d)
lemma cast : IsUniquelyCodimOneFace (x.cast hd) (y.cast (by rw [hxy.dim_eq, hd])) := by
simpa only [cast_eq_self]
lemma existsUnique_δ_cast_simplex :
∃! (i : Fin (d + 2)), X.δ i (y.cast (by rw [hxy.dim_eq, hd])).simplex =
(x.cast hd).simplex := by
simpa only [S.cast, iff] using hxy.cast hd
include hxy in
/-- When a `d`-dimensional simplex `x` is a `1`-codimensional face of `y`, this is
the only `i : Fin (d + 2)`, such that `X.δ i y = x` (with an abuse of notation:
see `δ_index` and `δ_eq_iff` for well typed statements). -/
noncomputable def index : Fin (d + 2) :=
(hxy.existsUnique_δ_cast_simplex hd).exists.choose
lemma δ_index :
X.δ (hxy.index hd) (y.cast (by rw [hxy.dim_eq, hd])).simplex = (x.cast hd).simplex :=
(hxy.existsUnique_δ_cast_simplex hd).exists.choose_spec
lemma δ_eq_iff (i : Fin (d + 2)) :
X.δ i (y.cast (by rw [hxy.dim_eq, hd])).simplex = (x.cast hd).simplex ↔
i = hxy.index hd :=
⟨fun h ↦ (hxy.existsUnique_δ_cast_simplex hd).unique h (hxy.δ_index hd),
by rintro rfl; apply δ_index⟩
end
end IsUniquelyCodimOneFace
end SSet.S |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Pairing.lean | import Mathlib.AlgebraicTopology.SimplicialSet.NonDegenerateSimplicesSubcomplex
import Mathlib.AlgebraicTopology.SimplicialSet.AnodyneExtensions.IsUniquelyCodimOneFace
/-!
# Pairings
In this file, we introduce the definition of a pairing for a subcomplex `A`
of a simplicial set `X`, following the ideas by Sean Moss,
*Another approach to the Kan-Quillen model structure*, who gave a
complete combinatorial characterization of strong (inner) anodyne extensions.
Strong (inner) anodyne extensions are transfinite compositions of pushouts of coproducts
of (inner) horn inclusions, i.e. this is similar to (inner) anodyne extensions but
without the stability property under retracts.
A pairing for `A` consists in the data of a partition of the nondegenerate
simplices of `X` not in `A` into type (I) simplices and type (II) simplices,
and of a bijection between the types of type (I) and type (II) simplices.
Indeed, the main observation is that when we attach a simplex along a horn
inclusion, exactly two nondegenerate simplices are added: this simplex,
and the unique face which is not in the image of the horn. The former shall be
considered as of type (I) and the latter as type (II).
We say that a pairing is *regular* (typeclass `Pairing.IsRegular`) when
- it is proper (`Pairing.IsProper`), i.e. any type (II) simplex is uniquely
a face of the corresponding type (I) simplex.
- a certain ancestrality relation is well founded.
When these conditions are satisfied, the inclusion `A.ι : A ⟶ X` is
a strong anodyne extension (TODO @joelriou), and the converse is also true
(if `A.ι` is a strong anodyne extension, then there is a regular pairing for `A` (TODO)).
## References
* [Sean Moss, *Another approach to the Kan-Quillen model structure*][moss-2020]
-/
universe u
namespace SSet.Subcomplex
variable {X : SSet.{u}} (A : X.Subcomplex)
/-- A pairing for a subcomplex `A` of a simplicial set `X` consists of a partition
of the nondegenerate simplices of `X` not in `A` in two types (I) and (II) of simplices,
and a bijection between the type (II) simplices and the type (I) simplices.
See the introduction of the file
`Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Pairing.lean`. -/
structure Pairing where
/-- the set of type (I) simplices -/
I : Set A.N
/-- the set of type (II) simplices -/
II : Set A.N
inter : I ∩ II = ∅
union : I ∪ II = Set.univ
/-- a bijection from the type (II) simplices to the type (I) simplices -/
p : II ≃ I
namespace Pairing
variable {A} (P : A.Pairing)
/-- A pairing is proper when each type (II) simplex
is uniquely a `1`-codimensional face of the corresponding (I)
simplex. -/
class IsProper where
isUniquelyCodimOneFace (x : P.II) :
S.IsUniquelyCodimOneFace x.1.toS (P.p x).1.toS
lemma isUniquelyCodimOneFace [P.IsProper] (x : P.II) :
S.IsUniquelyCodimOneFace x.1.toS (P.p x).1.toS :=
IsProper.isUniquelyCodimOneFace x
/-- The condition that a pairing only involves inner horns. -/
class IsInner [P.IsProper] : Prop where
ne_zero (x : P.II) {d : ℕ} (hd : x.1.dim = d) :
(P.isUniquelyCodimOneFace x).index hd ≠ 0
ne_last (x : P.II) {d : ℕ} (hd : x.1.dim = d) :
(P.isUniquelyCodimOneFace x).index hd ≠ Fin.last _
/-- The ancestrality relation on type (II) simplices. -/
def AncestralRel (x y : P.II) : Prop :=
x ≠ y ∧ x.1 < (P.p y).1
/-- A proper pairing is regular when the ancestrality relation
is well founded. -/
class IsRegular extends P.IsProper where
wf : WellFounded P.AncestralRel
section
variable [P.IsRegular]
lemma wf : WellFounded P.AncestralRel := IsRegular.wf
instance : IsWellFounded _ P.AncestralRel where
wf := P.wf
end
lemma exists_or (x : A.N) :
∃ (y : P.II), x = y ∨ x = P.p y := by
have := Set.mem_univ x
rw [← P.union, Set.mem_union] at this
obtain h | h := this
· obtain ⟨y, hy⟩ := P.p.surjective ⟨x, h⟩
exact ⟨y, Or.inr (by rw [hy])⟩
· exact ⟨⟨_, h⟩, Or.inl rfl⟩
lemma ne (x : P.I) (y : P.II) :
x.1 ≠ y.1 := by
obtain ⟨x, hx⟩ := x
obtain ⟨y, hy⟩ := y
rintro rfl
have : x ∈ P.I ∩ P.II := ⟨hx, hy⟩
simp [P.inter] at this
end Pairing
end SSet.Subcomplex |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SingularHomology/Basic.lean | import Mathlib.Algebra.Homology.AlternatingConst
import Mathlib.AlgebraicTopology.SingularSet
/-!
# Singular homology
In this file, we define the singular chain complex and singular homology of a topological space.
We also calculate the homology of a totally disconnected space as an example.
-/
noncomputable section
namespace AlgebraicTopology
open CategoryTheory Limits
universe w v u
variable (C : Type u) [Category.{v} C] [HasCoproducts.{w} C]
variable [Preadditive C] [CategoryWithHomology C] (n : ℕ)
/--
The singular chain complex associated to a simplicial set, with coefficients in `X : C`.
One can recover the ordinary singular chain complex when `C := Ab` and `X := ℤ`.
-/
def SSet.singularChainComplexFunctor :
C ⥤ SSet.{w} ⥤ ChainComplex C ℕ :=
(Functor.postcompose₂.obj (AlgebraicTopology.alternatingFaceMapComplex _)).obj
(sigmaConst ⋙ SimplicialObject.whiskering _ _)
/-- The singular chain complex functor with coefficients in `C`. -/
def singularChainComplexFunctor :
C ⥤ TopCat.{w} ⥤ ChainComplex C ℕ :=
SSet.singularChainComplexFunctor.{w} C ⋙ (Functor.whiskeringLeft _ _ _).obj TopCat.toSSet.{w}
/-- The `n`-th singular homology functor with coefficients in `C`. -/
def singularHomologyFunctor : C ⥤ TopCat.{w} ⥤ C :=
singularChainComplexFunctor C ⋙
(Functor.whiskeringRight _ _ _).obj (HomologicalComplex.homologyFunctor _ _ n)
section TotallyDisconnectedSpace
variable (R : C) (X : TopCat.{w}) [TotallyDisconnectedSpace X]
/-- If `X` is totally disconnected,
its singular chain complex is given by `R[X] ←0- R[X] ←𝟙- R[X] ←0- R[X] ⋯`,
where `R[X]` is the coproduct of copies of `R` indexed by elements of `X`. -/
noncomputable
def singularChainComplexFunctorIsoOfTotallyDisconnectedSpace :
((singularChainComplexFunctor C).obj R).obj X ≅
(ChainComplex.alternatingConst.obj (∐ fun _ : X ↦ R)) :=
(AlgebraicTopology.alternatingFaceMapComplex _).mapIso
(((SimplicialObject.whiskering _ _).obj _).mapIso
(TopCat.toSSetIsoConst X) ≪≫ Functor.constComp _ _ _) ≪≫
AlgebraicTopology.alternatingFaceMapComplexConst.app _
omit [CategoryWithHomology C] in
lemma singularChainComplexFunctor_exactAt_of_totallyDisconnectedSpace
(hn : n ≠ 0) :
(((singularChainComplexFunctor C).obj R).obj X).ExactAt n :=
have := hasCoproducts_shrink.{0, w} (C := C)
have : HasZeroObject C := ⟨_, initialIsInitial.isZero⟩
.of_iso (ChainComplex.alternatingConst_exactAt _ _ hn)
(singularChainComplexFunctorIsoOfTotallyDisconnectedSpace C R X).symm
lemma isZero_singularHomologyFunctor_of_totallyDisconnectedSpace (hn : n ≠ 0) :
IsZero (((singularHomologyFunctor C n).obj R).obj X) :=
have := hasCoproducts_shrink.{0, w} (C := C)
have : HasZeroObject C := ⟨_, initialIsInitial.isZero⟩
(singularChainComplexFunctor_exactAt_of_totallyDisconnectedSpace C n R X hn).isZero_homology
/-- The zeroth singular homology of a totally disconnected space is the
free `R`-module generated by elements of `X`. -/
noncomputable
def singularHomologyFunctorZeroOfTotallyDisconnectedSpace :
((singularHomologyFunctor C 0).obj R).obj X ≅ ∐ fun _ : X ↦ R :=
have := hasCoproducts_shrink.{0, w} (C := C)
have : HasZeroObject C := ⟨_, initialIsInitial.isZero⟩
(HomologicalComplex.homologyFunctor _ _ 0).mapIso
(singularChainComplexFunctorIsoOfTotallyDisconnectedSpace C R X) ≪≫
ChainComplex.alternatingConstHomologyZero _
end TotallyDisconnectedSpace
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/Quasicategory/StrictSegal.lean | import Mathlib.AlgebraicTopology.Quasicategory.Basic
import Mathlib.AlgebraicTopology.SimplicialSet.StrictSegal
/-!
# Strict Segal simplicial sets are quasicategories
In `AlgebraicTopology.SimplicialSet.StrictSegal`, we define the strict Segal
condition on a simplicial set `X`. We say that `X` is strict Segal if its
simplices are uniquely determined by their spine.
In this file, we prove that any simplicial set satisfying the strict Segal
condition is a quasicategory.
-/
universe u
open CategoryTheory
open Simplicial SimplicialObject SimplexCategory
namespace SSet.StrictSegal
/-- Any `StrictSegal` simplicial set is a `Quasicategory`. -/
theorem quasicategory {X : SSet.{u}} (sx : StrictSegal X) : Quasicategory X := by
apply quasicategory_of_filler X
intro n i σ₀ h₀ hₙ
use sx.spineToSimplex <| Path.map (horn.spineId i h₀ hₙ) σ₀
intro j hj
apply sx.spineInjective
ext k
dsimp only [spineEquiv, spine_arrow, Function.comp_apply, Equiv.coe_fn_mk]
rw [← types_comp_apply (σ₀.app _) (X.map _), ← σ₀.naturality]
let ksucc := k.succ.castSucc
obtain hlt | hgt | heq : ksucc < j ∨ j < ksucc ∨ j = ksucc := by cutsat
· rw [← spine_arrow, spine_δ_arrow_lt sx _ hlt]
dsimp only [Path.map_arrow, spine_arrow, Fin.coe_eq_castSucc]
apply congr_arg
apply Subtype.ext
dsimp [horn.face, CosimplicialObject.δ]
rw [Subcomplex.yonedaEquiv_coe, Subpresheaf.lift_ι, stdSimplex.map_apply,
Quiver.Hom.unop_op, stdSimplex.yonedaEquiv_map, Equiv.apply_symm_apply,
mkOfSucc_δ_lt hlt]
rfl
· rw [← spine_arrow, spine_δ_arrow_gt sx _ hgt]
dsimp only [Path.map_arrow, spine_arrow, Fin.coe_eq_castSucc]
apply congr_arg
apply Subtype.ext
dsimp [horn.face, CosimplicialObject.δ]
rw [Subcomplex.yonedaEquiv_coe, Subpresheaf.lift_ι, stdSimplex.map_apply,
Quiver.Hom.unop_op, stdSimplex.yonedaEquiv_map, Equiv.apply_symm_apply,
mkOfSucc_δ_gt hgt]
rfl
· obtain _ | n := n
· /- The only inner horn of `Δ[2]` does not contain the diagonal edge. -/
obtain rfl : k = 0 := by omega
fin_cases i <;> contradiction
· /- We construct the triangle in the standard simplex as a 2-simplex in
the horn. While the triangle is not contained in the inner horn `Λ[2, 1]`,
it suffices to inhabit `Λ[n + 3, i] _⦋2⦌`. -/
let triangle : (Λ[n + 3, i] : SSet.{u}) _⦋2⦌ :=
horn.primitiveTriangle i h₀ hₙ k (by cutsat)
/- The interval spanning from `k` to `k + 2` is equivalently the spine
of the triangle with vertices `k`, `k + 1`, and `k + 2`. -/
have hi : ((horn.spineId i h₀ hₙ).map σ₀).interval k 2 (by cutsat) =
X.spine 2 (σ₀.app _ triangle) := by
ext m
dsimp [spine_arrow, Path.map_interval, Path.map_arrow]
rw [← types_comp_apply (σ₀.app _) (X.map _), ← σ₀.naturality]
apply congr_arg
apply Subtype.ext
ext a : 1
fin_cases a <;> fin_cases m <;> rfl
rw [← spine_arrow, spine_δ_arrow_eq sx _ heq, hi]
simp only [spineToDiagonal, diagonal, spineToSimplex_spine_apply]
rw [← types_comp_apply (σ₀.app _) (X.map _), ← σ₀.naturality, types_comp_apply]
apply congr_arg
apply Subtype.ext
ext z : 1
dsimp [horn.face]
rw [Subcomplex.yonedaEquiv_coe, Subpresheaf.lift_ι, stdSimplex.map_apply,
Quiver.Hom.unop_op, stdSimplex.map_apply, Quiver.Hom.unop_op]
dsimp [CosimplicialObject.δ]
rw [stdSimplex.yonedaEquiv_map]
simp only [Equiv.apply_symm_apply, triangle]
rw [mkOfSucc_δ_eq heq]
fin_cases z <;> rfl
/-- Any simplicial set satisfying `IsStrictSegal` is a `Quasicategory`. -/
instance quasicategory' (X : SSet.{u}) [IsStrictSegal X] : Quasicategory X :=
quasicategory <| ofIsStrictSegal X
end SSet.StrictSegal |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/Quasicategory/Nerve.lean | import Mathlib.AlgebraicTopology.Quasicategory.StrictSegal
/-!
# The nerve of a category is a quasicategory
In `AlgebraicTopology.Quasicategory.StrictSegal`, we show that any
strict Segal simplicial set is a quasicategory.
In `AlgebraicTopology.SimplicialSet.StrictSegal`, we show that the nerve of a
category satisfies the strict Segal condition.
In this file, we prove as a direct consequence that the nerve of a category is
a quasicategory.
-/
universe v u
open SSet
namespace CategoryTheory.Nerve
/-- By virtue of satisfying the `StrictSegal` condition, the nerve of a
category is a `Quasicategory`. -/
instance quasicategory {C : Type u} [Category.{v} C] : Quasicategory (nerve C) := inferInstance
end CategoryTheory.Nerve |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/Quasicategory/TwoTruncated.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Basic
import Mathlib.AlgebraicTopology.SimplicialSet.CompStructTruncated
/-!
# 2-truncated quasicategories and homotopy relations
We define 2-truncated quasicategories `Quasicategory₂` by three horn-filling properties,
and the left and right homotopy relations `HomotopicL` and `HomotopicR` on the edges in a
2-truncated simplicial set.
We prove that for 2-truncated quasicategories, both homotopy relations are equivalence
relations, and that the left and right homotopy relations coincide.
## Implementation notes
Throughout this file, we make use of `Edge` and `CompStruct` to conveniently deal with
edges and triangles in a 2-truncated simplicial set.
-/
open CategoryTheory SimplicialObject.Truncated
namespace SSet.Truncated
open Edge CompStruct
/--
A 2-truncated quasicategory is a 2-truncated simplicial set with the properties:
* (2, 1)-filling: given two consecutive `Edge`s `e₀₁` and `e₁₂`, there exists a `CompStruct`
with (0, 1)-edge `e₀₁` and (0, 2)-edge `e₁₂`.
* (3, 1)-filling: given three `CompStruct`s `f₃`, `f₀` and `f₂` which form a (3, 1)-horn,
there exists a fourth `CompStruct` such that the four faces form the boundary
∂Δ[3] of a 3-simplex.
* (3, 2)-filling: given three `CompStruct`s `f₃`, `f₀` and `f₁` which form a (3, 2)-horn,
there exists a fourth `CompStruct` such that the four faces form the boundary
∂Δ[3] of a 3-simplex.
-/
class Quasicategory₂ (X : Truncated 2) where
fill21 {x₀ x₁ x₂ : X _⦋0⦌₂}
(e₀₁ : Edge x₀ x₁) (e₁₂ : Edge x₁ x₂) :
Nonempty (Σ e₀₂ : Edge x₀ x₂, CompStruct e₀₁ e₁₂ e₀₂)
fill31 {x₀ x₁ x₂ x₃ : X _⦋0⦌₂}
{e₀₁ : Edge x₀ x₁} {e₁₂ : Edge x₁ x₂} {e₂₃ : Edge x₂ x₃}
{e₀₂ : Edge x₀ x₂} {e₁₃ : Edge x₁ x₃} {e₀₃ : Edge x₀ x₃}
(f₃ : CompStruct e₀₁ e₁₂ e₀₂)
(f₀ : CompStruct e₁₂ e₂₃ e₁₃)
(f₂ : CompStruct e₀₁ e₁₃ e₀₃) :
Nonempty (CompStruct e₀₂ e₂₃ e₀₃)
fill32 {x₀ x₁ x₂ x₃ : X _⦋0⦌₂}
{e₀₁ : Edge x₀ x₁} {e₁₂ : Edge x₁ x₂} {e₂₃ : Edge x₂ x₃}
{e₀₂ : Edge x₀ x₂} {e₁₃ : Edge x₁ x₃} {e₀₃ : Edge x₀ x₃}
(f₃ : CompStruct e₀₁ e₁₂ e₀₂)
(f₀ : CompStruct e₁₂ e₂₃ e₁₃)
(f₁ : CompStruct e₀₂ e₂₃ e₀₃) :
Nonempty (CompStruct e₀₁ e₁₃ e₀₃)
/--
Two edges `f` and `g` are left homotopic if there is a `CompStruct` with
(0, 1)-edge `f`, (1, 2)-edge `id` and (0, 2)-edge `g`. We use `Nonempty` to
have a `Prop` valued `HomotopicL`.
-/
abbrev HomotopicL {X : Truncated 2} {x y : X _⦋0⦌₂} (f g : Edge x y) :=
Nonempty (CompStruct f (id y) g)
/--
Two edges `f` and `g` are right homotopic if there is a `CompStruct` with
(0, 1)-edge `id`, (1, 2)-edge `f`, and (0, 2)-edge `g`. We use `Nonempty` to
have a `Prop` valued `HomotopicR`.
-/
abbrev HomotopicR {X : Truncated 2} {x y : X _⦋0⦌₂} (f g : Edge x y) :=
Nonempty (CompStruct (id x) f g)
section homotopy_eqrel
variable {X : Truncated 2}
/--
Left homotopy relation is reflexive
-/
lemma HomotopicL.refl {x y : X _⦋0⦌₂} {f : Edge x y} : HomotopicL f f := ⟨compId f⟩
/--
Left homotopy relation is symmetric
-/
lemma HomotopicL.symm [Quasicategory₂ X] {x y : X _⦋0⦌₂} {f g : Edge x y} (hfg : HomotopicL f g) :
HomotopicL g f := by
rcases hfg with ⟨hfg⟩
exact Quasicategory₂.fill31 hfg (idComp (id y)) (compId f)
/--
Left homotopy relation is transitive
-/
lemma HomotopicL.trans [Quasicategory₂ X] {x y : X _⦋0⦌₂} {f g h : Edge x y} (hfg : HomotopicL f g)
(hgh : HomotopicL g h) : HomotopicL f h := by
rcases hfg with ⟨hfg⟩
rcases hgh with ⟨hgh⟩
exact Quasicategory₂.fill32 hfg (idComp (id y)) hgh
/--
Right homotopy relation is reflexive
-/
lemma HomotopicR.refl {x y : X _⦋0⦌₂} {f : Edge x y} : HomotopicR f f := ⟨idComp f⟩
/--
Right homotopy relation is symmetric
-/
lemma HomotopicR.symm [Quasicategory₂ X] {x y : X _⦋0⦌₂} {f g : Edge x y} (hfg : HomotopicR f g) :
HomotopicR g f := by
rcases hfg with ⟨hfg⟩
exact Quasicategory₂.fill32 (idComp (id x)) hfg (idComp f)
/--
Right homotopy relation is transitive
-/
lemma HomotopicR.trans [Quasicategory₂ X] {x y : X _⦋0⦌₂} {f g h : Edge x y} (hfg : HomotopicR f g)
(hgh : HomotopicR g h) : HomotopicR f h := by
rcases hfg with ⟨hfg⟩
rcases hgh with ⟨hgh⟩
exact Quasicategory₂.fill31 (idComp (id x)) hfg hgh
/--
In a 2-truncated quasicategory, left homotopy implies right homotopy
-/
lemma HomotopicL.homotopicR [Quasicategory₂ X] {x y : X _⦋0⦌₂} {f g : Edge x y}
(h : HomotopicL f g) : HomotopicR f g := by
rcases h with ⟨h⟩
exact Quasicategory₂.fill32 (idComp f) (compId f) h
/--
In a 2-truncated quasicategory, right homotopy implies left homotopy
-/
lemma HomotopicR.homotopicL [Quasicategory₂ X] {x y : X _⦋0⦌₂} {f g : Edge x y}
(h : HomotopicR f g) : HomotopicL f g := by
rcases h with ⟨h⟩
exact Quasicategory₂.fill31 (idComp f) (compId f) h
/--
In a 2-truncated quasicategory, the right and left homotopy relations coincide
-/
theorem homotopicL_iff_homotopicR [Quasicategory₂ X] {x y : X _⦋0⦌₂} {f g : Edge x y} :
HomotopicL f g ↔ HomotopicR f g :=
⟨HomotopicL.homotopicR, HomotopicR.homotopicL⟩
end homotopy_eqrel
end SSet.Truncated |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/Quasicategory/Basic.lean | import Mathlib.AlgebraicTopology.SimplicialSet.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/Quasicategory/Nerve.lean`,
we show that the nerve of a category is a quasicategory.
## TODO
- Generalize the definition to higher universes.
See the corresponding TODO in
`Mathlib/AlgebraicTopology/SimplicialSet/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] : SSet) ⟶ S)
(_h0 : 0 < i) (_hn : i < Fin.last (n+2)),
∃ σ : Δ[n+2] ⟶ S, σ₀ = Λ[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] : SSet) ⟶ S) : ∃ σ : Δ[n] ⟶ S, σ₀ = Λ[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] : SSet) ⟶ 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 ⟨yonedaEquiv.symm σ, ?_⟩
apply horn.hom_ext
intro j hj
rw [← h j hj, NatTrans.comp_app]
rfl
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/Basic.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Defs
import Mathlib.Data.Fintype.Sort
import Mathlib.Order.Category.NonemptyFinLinOrd
import Mathlib.Tactic.FinCases
import Mathlib.Tactic.Linarith
/-! # Basic properties of the simplex category
In `Mathlib/AlgebraicTopology/SimplexCategory/Defs.lean`, we define the simplex
category with objects `ℕ` and morphisms `n ⟶ m` the monotone maps from
`Fin (n + 1)` to `Fin (m + 1)`.
In this file, we define the generating maps for the simplex category, show that
this category is equivalent to `NonemptyFinLinOrd`, and establish basic
properties of its epimorphisms and monomorphisms.
-/
universe v
open Simplicial CategoryTheory Limits
namespace SimplexCategory
instance {n m : SimplexCategory} : DecidableEq (n ⟶ m) := fun a b =>
decidable_of_iff (a.toOrderHom = b.toOrderHom) SimplexCategory.Hom.ext_iff.symm
section Init
lemma congr_toOrderHom_apply {a b : SimplexCategory} {f g : a ⟶ b} (h : f = g)
(x : Fin (a.len + 1)) : f.toOrderHom x = g.toOrderHom x := by rw [h]
/-- 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
theorem const_fac_thru_zero (n m : SimplexCategory) (i : Fin (m.len + 1)) :
const n m i = const n ⦋0⦌ 0 ≫ SimplexCategory.const ⦋0⦌ m i := by
rw [const_comp]; rfl
theorem Hom.ext_zero_left {n : SimplexCategory} (f g : ⦋0⦌ ⟶ n)
(h0 : f.toOrderHom 0 = g.toOrderHom 0 := by rfl) : f = g := by
ext i; match i with | 0 => exact h0 ▸ rfl
theorem eq_const_of_zero {n : SimplexCategory} (f : ⦋0⦌ ⟶ n) :
f = const _ n (f.toOrderHom 0) := by
ext x; match x with | 0 => rfl
theorem exists_eq_const_of_zero {n : SimplexCategory} (f : ⦋0⦌ ⟶ n) :
∃ a, f = const _ n a := ⟨_, eq_const_of_zero _⟩
theorem eq_const_to_zero {n : SimplexCategory} (f : n ⟶ ⦋0⦌) :
f = const n _ 0 := by
ext : 3
apply @Subsingleton.elim (Fin 1)
theorem Hom.ext_one_left {n : SimplexCategory} (f g : ⦋1⦌ ⟶ n)
(h0 : f.toOrderHom 0 = g.toOrderHom 0 := by rfl)
(h1 : f.toOrderHom 1 = g.toOrderHom 1 := by rfl) : f = g := by
ext i
match i with
| 0 => exact h0 ▸ rfl
| 1 => exact h1 ▸ rfl
theorem eq_of_one_to_one (f : ⦋1⦌ ⟶ ⦋1⦌) :
(∃ a, f = const ⦋1⦌ _ a) ∨ f = 𝟙 _ := by
match e0 : f.toOrderHom 0, e1 : f.toOrderHom 1 with
| 0, 0 | 1, 1 =>
refine .inl ⟨f.toOrderHom 0, ?_⟩
ext i : 3
match i with
| 0 => rfl
| 1 => exact e1.trans e0.symm
| 0, 1 =>
right
ext i : 3
match i with
| 0 => exact e0
| 1 => exact e1
| 1, 0 =>
have := f.toOrderHom.monotone (by decide : (0 : Fin 2) ≤ 1)
rw [e0, e1] at this
exact Not.elim (by decide) this
/-- 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⦌ ⟶ ⦋m⦌ :=
SimplexCategory.Hom.mk f
/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out a specified `h : i ≤ j` in `Fin (n+1)`. -/
def mkOfLe {n} (i j : Fin (n + 1)) (h : i ≤ j) : ⦋1⦌ ⟶ ⦋n⦌ :=
SimplexCategory.mkHom {
toFun := fun | 0 => i | 1 => j
monotone' := fun
| 0, 0, _ | 1, 1, _ => le_rfl
| 0, 1, _ => h
}
@[simp]
lemma mkOfLe_refl {n} (j : Fin (n + 1)) :
mkOfLe j j (by cutsat) = ⦋1⦌.const ⦋n⦌ j := Hom.ext_one_left _ _
/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out the "diagonal composite" edge -/
def diag (n : ℕ) : ⦋1⦌ ⟶ ⦋n⦌ :=
mkOfLe 0 (Fin.last n) (Fin.zero_le _)
/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out the edge spanning the interval from `j` to `j + l`. -/
def intervalEdge {n} (j l : ℕ) (hjl : j + l ≤ n) : ⦋1⦌ ⟶ ⦋n⦌ :=
mkOfLe ⟨j, (by cutsat)⟩ ⟨j + l, (by cutsat)⟩ (Nat.le_add_right j l)
/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out the arrow `i ⟶ i+1` in `Fin (n+1)`. -/
def mkOfSucc {n} (i : Fin n) : ⦋1⦌ ⟶ ⦋n⦌ :=
SimplexCategory.mkHom {
toFun := fun | 0 => i.castSucc | 1 => i.succ
monotone' := fun
| 0, 0, _ | 1, 1, _ => le_rfl
| 0, 1, _ => Fin.castSucc_le_succ i
}
@[simp]
lemma mkOfSucc_homToOrderHom_zero {n} (i : Fin n) :
DFunLike.coe (F := Fin 2 →o Fin (n + 1)) (Hom.toOrderHom (mkOfSucc i)) 0 = i.castSucc := rfl
@[simp]
lemma mkOfSucc_homToOrderHom_one {n} (i : Fin n) :
DFunLike.coe (F := Fin 2 →o Fin (n + 1)) (Hom.toOrderHom (mkOfSucc i)) 1 = i.succ := rfl
@[simp]
lemma mkOfSucc_eq_id : mkOfSucc (0 : Fin 1) = 𝟙 _ := by decide
/-- The morphism `⦋2⦌ ⟶ ⦋n⦌` that picks out a specified composite of morphisms in `Fin (n+1)`. -/
def mkOfLeComp {n} (i j k : Fin (n + 1)) (h₁ : i ≤ j) (h₂ : j ≤ k) :
⦋2⦌ ⟶ ⦋n⦌ :=
SimplexCategory.mkHom {
toFun := fun | 0 => i | 1 => j | 2 => k
monotone' := fun
| 0, 0, _ | 1, 1, _ | 2, 2, _ => le_rfl
| 0, 1, _ => h₁
| 1, 2, _ => h₂
| 0, 2, _ => Fin.le_trans h₁ h₂
}
/-- The "inert" morphism associated to a subinterval `j ≤ i ≤ j + l` of `Fin (n + 1)`. -/
def subinterval {n} (j l : ℕ) (hjl : j + l ≤ n) :
⦋l⦌ ⟶ ⦋n⦌ :=
SimplexCategory.mkHom {
toFun := fun i => ⟨i.1 + j, (by cutsat)⟩
monotone' := fun i i' hii' => by simpa only [Fin.mk_le_mk, add_le_add_iff_right] using hii'
}
lemma const_subinterval_eq {n} (j l : ℕ) (hjl : j + l ≤ n) (i : Fin (l + 1)) :
⦋0⦌.const ⦋l⦌ i ≫ subinterval j l hjl =
⦋0⦌.const ⦋n⦌ ⟨j + i.1, lt_add_of_lt_add_right (Nat.add_lt_add_left i.2 j) hjl⟩ := by
rw [const_comp]
congr
ext
dsimp [subinterval]
rw [add_comm]
@[simp]
lemma mkOfSucc_subinterval_eq {n} (j l : ℕ) (hjl : j + l ≤ n) (i : Fin l) :
mkOfSucc i ≫ subinterval j l hjl =
mkOfSucc ⟨j + i.1, Nat.lt_of_lt_of_le (Nat.add_lt_add_left i.2 j) hjl⟩ := by
unfold subinterval mkOfSucc
ext (i : Fin 2)
match i with | 0 | 1 => simp; cutsat
@[simp]
lemma diag_subinterval_eq {n} (j l : ℕ) (hjl : j + l ≤ n) :
diag l ≫ subinterval j l hjl = intervalEdge j l hjl := by
unfold subinterval intervalEdge diag mkOfLe
ext (i : Fin 2)
match i with | 0 | 1 => simp <;> omega
instance (Δ : SimplexCategory) : Subsingleton (Δ ⟶ ⦋0⦌) where
allEq f g := by ext : 3; apply Subsingleton.elim (α := Fin 1)
theorem hom_zero_zero (f : ⦋0⦌ ⟶ ⦋0⦌) : f = 𝟙 _ := by
apply Subsingleton.elim
@[simp]
lemma eqToHom_toOrderHom {x y : SimplexCategory} (h : x = y) :
SimplexCategory.Hom.toOrderHom (eqToHom h) =
(Fin.castOrderIso (congrArg (fun t ↦ t.len + 1) h)).toOrderEmbedding.toOrderHom := by
subst h
rfl
end Init
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⦌ ⟶ ⦋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⦌ ⟶ ⦋n⦌ :=
mkHom i.predAboveOrderHom
/-- The generic case of the first simplicial identity -/
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) :
δ i ≫ δ j.succ = δ j ≫ δ i.castSucc := 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 : i.castSucc < 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 ≫ δ i.castSucc = δ i ≫ δ i.succ :=
(δ_comp_δ (le_refl i)).symm
@[reassoc]
theorem δ_comp_δ_self' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : j = i.castSucc) :
δ 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 ≤ j.castSucc) :
δ i.castSucc ≫ σ j.succ = σ j ≫ δ i := by
ext k : 3
dsimp [σ, δ]
rcases le_or_gt 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_gt 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⦌ := 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]
split_ifs
any_goals simp
all_goals cutsat
@[reassoc]
theorem δ_comp_σ_self' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = i.castSucc) :
δ j ≫ σ i = 𝟙 ⦋n⦌ := 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⦌ := 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⦌ := 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 : j.castSucc < i) :
δ i.succ ≫ σ j.castSucc = σ j ≫ δ i := by
ext k : 3
dsimp [δ, σ]
rcases le_or_gt k i with (hik | hik)
· rw [Fin.succAbove_of_castSucc_lt _ _ (Fin.castSucc_lt_succ_iff.mpr hik)]
rcases le_or_gt 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
| last => simp only [len_mk, Fin.predAbove_right_last]
| cast k =>
cases k using Fin.cases with
| zero =>
simp
| succ k =>
rcases le_or_gt 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_gt 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)]
lemma δ_zero_eq_const : δ (0 : Fin 2) = const _ _ 1 := by decide
lemma δ_one_eq_const : δ (1 : Fin 2) = const _ _ 0 := by decide
/--
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⦌ ⟶ ⦋n + 1⦌) (j : Fin (n + 2)) : ⦋m⦌ ⟶ ⦋n⦌ :=
f ≫ σ (Fin.predAbove 0 j)
lemma factor_δ_spec {m n : ℕ} (f : ⦋m⦌ ⟶ ⦋n + 1⦌) (j : Fin (n + 2))
(hj : ∀ (k : Fin (m + 1)), f.toOrderHom k ≠ j) :
factor_δ f j ≫ δ j = f := by
ext k : 3
cases j using Fin.cases <;> simp_all [factor_δ, δ, σ]
@[simp]
lemma δ_zero_mkOfSucc {n : ℕ} (i : Fin n) :
δ 0 ≫ mkOfSucc i = SimplexCategory.const _ ⦋n⦌ i.succ := by
ext x
fin_cases x
rfl
@[simp]
lemma δ_one_mkOfSucc {n : ℕ} (i : Fin n) :
δ 1 ≫ mkOfSucc i = SimplexCategory.const _ ⦋n⦌ i.castSucc := by
ext x
fin_cases x
rfl
/-- If `i + 1 < j`, `mkOfSucc i ≫ δ j` is the morphism `⦋1⦌ ⟶ ⦋n⦌` that
sends `0` and `1` to `i` and `i + 1`, respectively. -/
lemma mkOfSucc_δ_lt {n : ℕ} {i : Fin n} {j : Fin (n + 2)}
(h : i.succ.castSucc < j) :
mkOfSucc i ≫ δ j = mkOfSucc i.castSucc := by
ext x
fin_cases x
· simp [δ, Fin.succAbove_of_castSucc_lt _ _ (Nat.lt_trans _ h)]
· simp [δ, Fin.succAbove_of_castSucc_lt _ _ h]
/-- If `i + 1 > j`, `mkOfSucc i ≫ δ j` is the morphism `⦋1⦌ ⟶ ⦋n⦌` that
sends `0` and `1` to `i + 1` and `i + 2`, respectively. -/
lemma mkOfSucc_δ_gt {n : ℕ} {i : Fin n} {j : Fin (n + 2)}
(h : j < i.succ.castSucc) :
mkOfSucc i ≫ δ j = mkOfSucc i.succ := by
ext x
simp only [δ, len_mk, mkHom, comp_toOrderHom, Hom.toOrderHom_mk, OrderHom.comp_coe,
OrderEmbedding.toOrderHom_coe, Function.comp_apply, Fin.succAboveOrderEmb_apply]
fin_cases x <;> rw [Fin.succAbove_of_le_castSucc]
· rfl
· exact Nat.le_of_lt_succ h
· rfl
· exact Nat.le_of_lt h
/-- If `i + 1 = j`, `mkOfSucc i ≫ δ j` is the morphism `⦋1⦌ ⟶ ⦋n⦌` that
sends `0` and `1` to `i` and `i + 2`, respectively. -/
lemma mkOfSucc_δ_eq {n : ℕ} {i : Fin n} {j : Fin (n + 2)}
(h : j = i.succ.castSucc) :
mkOfSucc i ≫ δ j = intervalEdge i 2 (by cutsat) := by
ext x
fin_cases x
· subst h
simp only [δ, len_mk, Nat.reduceAdd, mkHom, comp_toOrderHom, Hom.toOrderHom_mk,
Fin.zero_eta, OrderHom.comp_coe, OrderEmbedding.toOrderHom_coe, Function.comp_apply,
mkOfSucc_homToOrderHom_zero, Fin.succAboveOrderEmb_apply,
Fin.castSucc_succAbove_castSucc, Fin.succAbove_succ_self]
rfl
· simp only [δ, len_mk, Nat.reduceAdd, mkHom, comp_toOrderHom, Hom.toOrderHom_mk, Fin.mk_one,
OrderHom.comp_coe, OrderEmbedding.toOrderHom_coe, Function.comp_apply,
mkOfSucc_homToOrderHom_one, Fin.succAboveOrderEmb_apply]
subst h
rw [Fin.succAbove_castSucc_self]
rfl
lemma mkOfSucc_one_eq_δ : mkOfSucc (1 : Fin 2) = δ 0 := by decide
lemma mkOfSucc_zero_eq_δ : mkOfSucc (0 : Fin 2) = δ 2 := by decide
theorem eq_of_one_to_two (f : ⦋1⦌ ⟶ ⦋2⦌) :
(∃ i, f = (δ (n := 1) i)) ∨ ∃ a, f = SimplexCategory.const _ _ a := by
have : f.toOrderHom 0 ≤ f.toOrderHom 1 := f.toOrderHom.monotone (by decide : (0 : Fin 2) ≤ 1)
match e0 : f.toOrderHom 0, e1 : f.toOrderHom 1 with
| 1, 2 =>
refine .inl ⟨0, ?_⟩
ext i : 3
match i with
| 0 => exact e0
| 1 => exact e1
| 0, 2 =>
refine .inl ⟨1, ?_⟩
ext i : 3
match i with
| 0 => exact e0
| 1 => exact e1
| 0, 1 =>
refine .inl ⟨2, ?_⟩
ext i : 3
match i with
| 0 => exact e0
| 1 => exact e1
| 0, 0 | 1, 1 | 2, 2 =>
refine .inr ⟨f.toOrderHom 0, ?_⟩
ext i : 3
match i with
| 0 => rfl
| 1 => exact e1.trans e0.symm
| 1, 0 | 2, 0 | 2, 1 =>
rw [e0, e1] at this
exact Not.elim (by decide) this
theorem eq_of_one_to_two' (f : ⦋1⦌ ⟶ ⦋2⦌) :
f = (δ (n := 1) 0) ∨ f = (δ (n := 1) 1) ∨ f = (δ (n := 1) 2) ∨
∃ a, f = SimplexCategory.const _ _ a :=
match eq_of_one_to_two f with
| .inl ⟨0, h⟩ => .inl h
| .inl ⟨1, h⟩ => .inr (.inl h)
| .inl ⟨2, h⟩ => .inr (.inr (.inl h))
| .inr h => .inr (.inr (.inr h))
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 := NonemptyFinLinOrd.ofHom f.toOrderHom
theorem skeletalFunctor.coe_map {Δ₁ Δ₂ : SimplexCategory} (f : Δ₁ ⟶ Δ₂) :
↑(skeletalFunctor.map f).hom = 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.hom, rfl⟩
instance : skeletalFunctor.Faithful where
map_injective {_ _ f g} h := by
ext : 3
exact CategoryTheory.congr_fun h _
instance : skeletalFunctor.EssSurj where
mem_essImage X :=
⟨⦋(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 := LinOrd.ofHom ⟨f, hf.monotone⟩
inv := LinOrd.ofHom ⟨f.symm, ?_⟩
hom_inv_id := by ext; apply f.symm_apply_apply
inv_hom_id := by ext; apply f.apply_symm_apply }
intro i j h
change f.symm i ≤ f.symm j
rw [← hf.le_iff_le]
change 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
section Concrete
instance : ConcreteCategory SimplexCategory (fun i j => Fin (i.len + 1) →o Fin (j.len + 1)) where
hom := Hom.toOrderHom
ofHom f := Hom.mk f
instance (x : SimplexCategory) : Fintype (ToType x) :=
inferInstanceAs (Fintype (Fin _))
instance (x : SimplexCategory) (n : ℕ) : OfNat (ToType x) n :=
inferInstanceAs (OfNat (Fin _) n)
lemma toType_apply (x : SimplexCategory) : ToType x = Fin (x.len + 1) := rfl
@[simp]
lemma concreteCategoryHom_id (n : SimplexCategory) : ConcreteCategory.hom (𝟙 n) = .id := rfl
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, ConcreteCategory.hom_ofHom]
/-- 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, ConcreteCategory.hom_ofHom]
/-- 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
simpa using Fintype.card_le_of_injective f.toOrderHom.toFun
(by dsimp; rwa [← mono_iff_injective])
theorem le_of_mono {n m : ℕ} (f : ⦋n⦌ ⟶ ⦋m⦌) [Mono f] : n ≤ m :=
len_le_of_mono f
/-- 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
simpa using Fintype.card_le_of_surjective f.toOrderHom.toFun
(by dsimp; rwa [← epi_iff_surjective])
theorem le_of_epi {n m : ℕ} (f : ⦋n⦌ ⟶ ⦋m⦌) [Epi f] : m ≤ n := len_le_of_epi f
lemma len_eq_of_isIso {x y : SimplexCategory} (f : x ⟶ y) [IsIso f] : x.len = y.len :=
le_antisymm (len_le_of_mono f) (len_le_of_epi f)
lemma eq_of_isIso {n m : ℕ} (f : ⦋n⦌ ⟶ ⦋m⦌) [IsIso f] : n = m :=
len_eq_of_isIso f
instance {n : ℕ} {i : Fin (n + 1)} : Epi (σ i) := by
simpa only [epi_iff_surjective] using Fin.predAbove_surjective i
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)
lemma isIso_iff_of_mono {n m : SimplexCategory} (f : n ⟶ m) [hf : Mono f] :
IsIso f ↔ n.len = m.len := by
refine ⟨fun _ ↦ len_eq_of_isIso f, fun h ↦ ?_⟩
obtain rfl : n = m := by aesop
rw [mono_iff_injective] at hf
exact isIso_of_bijective ⟨hf, by rwa [← Finite.injective_iff_surjective]⟩
instance {n : ℕ} {i : Fin (n + 2)} : Mono (δ i) := by
rw [mono_iff_injective]
exact Fin.succAbove_right_injective
lemma isIso_iff_of_epi {n m : SimplexCategory} (f : n ⟶ m) [hf : Epi f] :
IsIso f ↔ n.len = m.len := by
refine ⟨fun _ ↦ len_eq_of_isIso f, fun h ↦ ?_⟩
obtain rfl : n = m := by aesop
rw [epi_iff_surjective] at hf
exact isIso_of_bijective ⟨by rwa [Finite.injective_iff_surjective], hf⟩
instance : Balanced SimplexCategory where
isIso_of_mono_of_epi f _ _ := by
rw [isIso_iff_of_epi]
exact le_antisymm (len_le_of_mono f) (len_le_of_epi f)
/-- 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)
ext : 2
convert congr_arg (fun φ => (OrderEmbedding.toOrderHom φ)) (eq₁.trans eq₂.symm)
ext i : 2
rfl
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} (θ : ⦋n + 1⦌ ⟶ Δ')
(i : Fin (n + 1)) (hi : θ.toOrderHom (Fin.castSucc i) = θ.toOrderHom i.succ) :
∃ θ' : ⦋n⦌ ⟶ Δ', θ = σ i ≫ θ' := by
use δ i.succ ≫ θ
ext x : 3
simp only [len_mk, σ, mkHom, comp_toOrderHom, Hom.toOrderHom_mk, OrderHom.comp_coe,
Function.comp_apply, Fin.predAboveOrderHom_coe]
by_cases h' : x ≤ Fin.castSucc i
· rw [Fin.predAbove_of_le_castSucc i x h']
dsimp [δ]
rw [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' ⊢
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 [δ]
rw [Fin.succAbove_of_castSucc_lt i.succ]
exact Fin.lt_succ
· dsimp [δ]
rw [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'' ⊢
cutsat
theorem eq_σ_comp_of_not_injective {n : ℕ} {Δ' : SimplexCategory} (θ : ⦋n + 1⦌ ⟶ Δ')
(hθ : ¬Function.Injective θ.toOrderHom) :
∃ (i : Fin (n + 1)) (θ' : ⦋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, ?_⟩⟩
cutsat
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} (θ : Δ ⟶ ⦋n + 1⦌)
(i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ ⦋n⦌, θ = θ' ≫ δ i := by
use θ ≫ σ (.predAbove (.last n) i)
ext x : 3
suffices ∀ j ≠ i, i.succAbove (((Fin.last n).predAbove i).predAbove j) = j by
dsimp [δ, σ]
exact .symm <| this _ (hi _)
intro j hj
cases i using Fin.lastCases <;> simp [hj]
theorem eq_comp_δ_of_not_surjective {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ ⦋n + 1⦌)
(hθ : ¬Function.Surjective θ.toOrderHom) :
∃ (i : Fin (n + 2)) (θ' : Δ ⟶ ⦋n⦌), θ = θ' ≫ δ i := by
obtain ⟨i, hi⟩ := not_forall.mp hθ
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]
infer_instance
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
suffices IsIso i from 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]
infer_instance
theorem eq_σ_of_epi {n : ℕ} (θ : ⦋n + 1⦌ ⟶ ⦋n⦌) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
obtain ⟨i, θ', h⟩ := eq_σ_comp_of_not_injective θ (by
rw [← mono_iff_injective]
grind [→ le_of_mono])
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 : ℕ} (θ : ⦋n⦌ ⟶ ⦋n + 1⦌) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
obtain ⟨i, θ', h⟩ := eq_comp_δ_of_not_surjective θ (by
rw [← epi_iff_surjective]
grind [→ le_of_epi])
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 : Δ' ⟶ Δ) [Mono i] (hi' : Δ ≠ Δ') :
Δ'.len < Δ.len := by
grind [→ len_le_of_mono, SimplexCategory.ext]
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 e.hom) (len_le_of_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
theorem toCat.obj_eq_Fin (n : ℕ) : toCat.obj ⦋n⦌ = Fin (n + 1) := rfl
instance uniqueHomToZero {Δ : SimplexCategory} : Unique (Δ ⟶ ⦋0⦌) where
default := Δ.const _ 0
uniq := eq_const_to_zero
/-- The object `⦋0⦌` is terminal in `SimplexCategory`. -/
def isTerminalZero : IsTerminal (⦋0⦌ : SimplexCategory) :=
IsTerminal.ofUnique ⦋0⦌
instance : HasTerminal SimplexCategory :=
IsTerminal.hasTerminal isTerminalZero
/-- The isomorphism between the terminal object in `SimplexCategory` and `⦋0⦌`. -/
noncomputable def topIsoZero : ⊤_ SimplexCategory ≅ ⦋0⦌ :=
terminalIsoIsTerminal isTerminalZero
lemma δ_injective {n : ℕ} : Function.Injective (δ (n := n)) := by
intro i j hij
rw [← Fin.succAbove_left_inj]
ext k : 1
exact congr($hij k)
lemma σ_injective {n : ℕ} : Function.Injective (σ (n := n)) := by
intro i j hij
rw [← Fin.predAbove_left_inj]
ext k : 1
exact congr($hij k)
end SimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/Augmented.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic
deprecated_module (since := "2025-07-05") |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/Defs.lean | import Mathlib.CategoryTheory.Category.Preorder
import Mathlib.CategoryTheory.Opposites
import Mathlib.Order.Fin.Basic
import Mathlib.Util.Superscript
/-! # The simplex category
We construct a skeletal model of the simplex category, with objects `ℕ` and the
morphisms `n ⟶ m` being the monotone maps from `Fin (n + 1)` to `Fin (m + 1)`.
In `Mathlib/AlgebraicTopology/SimplexCategory/Basic.lean`, 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`.
## Notation
* `⦋n⦌` denotes the `n`-dimensional simplex. This notation is available with
`open Simplicial`.
* `⦋m⦌ₙ` denotes the `m`-dimensional simplex in the `n`-truncated simplex category.
The truncation proof `p : m ≤ n` can also be provided using the syntax `⦋m, p⦌ₙ`.
This notation is available with `open SimplexCategory.Truncated`.
-/
universe v
open CategoryTheory
/-- 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
-- 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⦌ = 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
/-- 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 _ := 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
@[ext]
theorem Hom.ext {a b : SimplexCategory} (f g : a ⟶ b) :
f.toOrderHom = g.toOrderHom → f = g :=
Hom.ext' _ _
/-- Homs in `SimplexCategory` are equivalent to order-preserving functions of finite linear
orders. -/
def homEquivOrderHom {a b : SimplexCategory} :
(a ⟶ b) ≃ (Fin (a.len + 1) →o Fin (b.len + 1)) where
toFun := Hom.toOrderHom
invFun := Hom.mk
/-- Homs in `SimplexCategory` are equivalent to functors between finite linear orders. -/
def homEquivFunctor {a b : SimplexCategory} :
(a ⟶ b) ≃ (Fin (a.len + 1) ⥤ Fin (b.len + 1)) :=
SimplexCategory.homEquivOrderHom.trans OrderHom.equivFunctor
/-- The truncated simplex category. -/
abbrev Truncated (n : ℕ) :=
ObjectProperty.FullSubcategory fun a : SimplexCategory => a.len ≤ n
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 :=
ObjectProperty.ι _
instance (n : ℕ) : (inclusion n : Truncated n ⥤ _).Full := ObjectProperty.full_ι _
instance (n : ℕ) : (inclusion n : Truncated n ⥤ _).Faithful := ObjectProperty.faithful_ι _
/-- A proof that the full subcategory inclusion is fully faithful -/
noncomputable def inclusion.fullyFaithful (n : ℕ) :
(inclusion n : Truncated n ⥤ _).op.FullyFaithful :=
Functor.FullyFaithful.ofFullyFaithful _
@[ext]
theorem Hom.ext {n} {a b : Truncated n} (f g : a ⟶ b) :
f.toOrderHom = g.toOrderHom → f = g := SimplexCategory.Hom.ext _ _
/-- A quick attempt to prove that `⦋m⦌` is `n`-truncated (`⦋m⦌.len ≤ n`). -/
scoped macro "trunc" : tactic =>
`(tactic| first | assumption | dsimp only [SimplexCategory.len_mk] <;> omega)
open Mathlib.Tactic (subscriptTerm) in
/-- For `m ≤ n`, `⦋m⦌ₙ` is the `m`-dimensional simplex in `Truncated n`. The
proof `p : m ≤ n` can also be provided using the syntax `⦋m, p⦌ₙ`. -/
scoped syntax:max (name := mkNotation)
"⦋" term ("," term)? "⦌" noWs subscriptTerm : term
scoped macro_rules
| `(⦋$m:term⦌$n:subscript) =>
`((⟨SimplexCategory.mk $m, by first | trunc |
fail "Failed to prove truncation property. Try writing `⦋m, by ...⦌ₙ`."⟩ :
SimplexCategory.Truncated $n))
| `(⦋$m:term, $p:term⦌$n:subscript) =>
`((⟨SimplexCategory.mk $m, $p⟩ : SimplexCategory.Truncated $n))
/-- Make a morphism in `Truncated n` from a morphism in `SimplexCategory`. This
is equivalent to `@id (⦋a⦌ₙ ⟶ ⦋b⦌ₙ) f`. -/
abbrev Hom.tr {n : ℕ} {a b : SimplexCategory} (f : a ⟶ b)
(ha : a.len ≤ n := by trunc) (hb : b.len ≤ n := by trunc) :
(⟨a, ha⟩ : Truncated n) ⟶ ⟨b, hb⟩ :=
f
@[simp]
lemma Hom.tr_id {n : ℕ} (a : SimplexCategory) (ha : a.len ≤ n := by trunc) :
Hom.tr (𝟙 a) ha = 𝟙 _ := rfl
@[reassoc]
lemma Hom.tr_comp {n : ℕ} {a b c : SimplexCategory} (f : a ⟶ b) (g : b ⟶ c)
(ha : a.len ≤ n := by trunc) (hb : b.len ≤ n := by trunc)
(hc : c.len ≤ n := by trunc) :
tr (f ≫ g) = tr f ≫ tr g :=
rfl
/-- The inclusion of `Truncated n` into `Truncated m` when `n ≤ m`. -/
def incl (n m : ℕ) (h : n ≤ m := by omega) : Truncated n ⥤ Truncated m where
obj a := ⟨a.1, a.2.trans h⟩
map := id
/-- For all `n ≤ m`, `inclusion n` factors through `Truncated m`. -/
def inclCompInclusion {n m : ℕ} (h : n ≤ m) :
incl n m ⋙ inclusion m ≅ inclusion n :=
Iso.refl _
end Truncated
end SimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/Truncated.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Basic
import Mathlib.CategoryTheory.Limits.Final
/-! # Properties of the truncated simplex category
We prove that for `n > 0`, the inclusion functor from the `n`-truncated simplex category to the
untruncated simplex category, and the inclusion functor from the `n`-truncated to the `m`-truncated
simplex category, for `n ≤ m` are initial.
-/
open Simplicial CategoryTheory
namespace SimplexCategory.Truncated
instance {d : ℕ} {n m : Truncated d} : DecidableEq (n ⟶ m) := fun a b =>
decidable_of_iff (a.toOrderHom = b.toOrderHom) SimplexCategory.Hom.ext_iff.symm
/-- For `0 < n`, the inclusion functor from the `n`-truncated simplex category to the untruncated
simplex category is initial. -/
instance initial_inclusion {n : ℕ} [NeZero n] : (inclusion n).Initial := by
have := Nat.pos_of_neZero n
constructor
intro Δ
have : Nonempty (CostructuredArrow (inclusion n) Δ) := ⟨⟨⦋0⦌ₙ, ⟨⟨⟩⟩, ⦋0⦌.const _ 0 ⟩⟩
apply zigzag_isConnected
rintro ⟨⟨Δ₁, hΔ₁⟩, ⟨⟨⟩⟩, f⟩ ⟨⟨Δ₂, hΔ₂⟩, ⟨⟨⟩⟩, f'⟩
apply Zigzag.trans (j₂ := ⟨⦋0⦌ₙ, ⟨⟨⟩⟩, ⦋0⦌.const _ (f 0)⟩)
(.of_inv <| CostructuredArrow.homMk <| Hom.tr <| ⦋0⦌.const _ 0)
by_cases hff' : f 0 ≤ f' 0
· trans ⟨⦋1⦌ₙ, ⟨⟨⟩⟩, mkOfLe (n := Δ.len) (f 0) (f' 0) hff'⟩
· apply Zigzag.of_hom <| CostructuredArrow.homMk <| Hom.tr <| ⦋0⦌.const _ 0
· trans ⟨⦋0⦌ₙ, ⟨⟨⟩⟩, ⦋0⦌.const _ (f' 0)⟩
· apply Zigzag.of_inv <| CostructuredArrow.homMk <| Hom.tr <| ⦋0⦌.const _ 1
· apply Zigzag.of_hom <| CostructuredArrow.homMk <| Hom.tr <| ⦋0⦌.const _ 0
· trans ⟨⦋1⦌ₙ, ⟨⟨⟩⟩, mkOfLe (n := Δ.len) (f' 0) (f 0) (le_of_not_ge hff')⟩
· apply Zigzag.of_hom <| CostructuredArrow.homMk <| Hom.tr <| ⦋0⦌.const _ 1
· trans ⟨⦋0⦌ₙ, ⟨⟨⟩⟩, ⦋0⦌.const _ (f' 0)⟩
· apply Zigzag.of_inv <| CostructuredArrow.homMk <| Hom.tr <| ⦋0⦌.const _ 0
· apply Zigzag.of_hom <| CostructuredArrow.homMk <| Hom.tr <| ⦋0⦌.const _ 0
/-- For `0 < n ≤ m`, the inclusion functor from the `n`-truncated simplex category to the
`m`-truncated simplex category is initial. -/
theorem initial_incl {n m : ℕ} [NeZero n] (hm : n ≤ m) : (incl n m).Initial := by
have : (incl n m hm ⋙ inclusion m).Initial :=
Functor.initial_of_natIso (inclCompInclusion _).symm
apply Functor.initial_of_comp_full_faithful _ (inclusion m)
/-- Abbreviation for face maps in the `n`-truncated simplex category. -/
abbrev δ (m : Nat) {n} (i : Fin (n + 2)) (hn := by decide) (hn' := by decide) :
(⟨⦋n⦌, hn⟩ : SimplexCategory.Truncated m) ⟶ ⟨⦋n + 1⦌, hn'⟩ := SimplexCategory.δ i
/-- Abbreviation for degeneracy maps in the `n`-truncated simplex category. -/
abbrev σ (m : Nat) {n} (i : Fin (n + 1)) (hn := by decide) (hn' := by decide) :
(⟨⦋n + 1⦌, hn⟩ : SimplexCategory.Truncated m) ⟶ ⟨⦋n⦌, hn'⟩ := SimplexCategory.σ i
section Two
/-- Abbreviation for face maps in the 2-truncated simplex category. -/
abbrev δ₂ {n} (i : Fin (n + 2)) (hn := by decide) (hn' := by decide) := δ 2 i hn hn'
/-- Abbreviation for face maps in the 2-truncated simplex category. -/
abbrev σ₂ {n} (i : Fin (n + 1)) (hn := by decide) (hn' := by decide) := σ 2 i hn hn'
@[reassoc (attr := simp)]
lemma δ₂_zero_comp_σ₂_zero {n} (hn := by decide) (hn' := by decide) :
δ₂ (n := n) 0 hn hn' ≫ σ₂ 0 hn' hn = 𝟙 _ := SimplexCategory.δ_comp_σ_self
@[reassoc]
lemma δ₂_zero_comp_σ₂_one : δ₂ (0 : Fin 3) ≫ σ₂ 1 = σ₂ 0 ≫ δ₂ 0 :=
SimplexCategory.δ_comp_σ_of_le (i := 0) (j := 0) (Fin.zero_le _)
@[reassoc (attr := simp)]
lemma δ₂_one_comp_σ₂_zero {n} (hn := by decide) (hn' := by decide) :
δ₂ (n := n) 1 hn hn' ≫ σ₂ 0 hn' hn = 𝟙 _ := SimplexCategory.δ_comp_σ_succ
@[reassoc (attr := simp)]
lemma δ₂_one_comp_σ₂_one {n} (hn := by decide) (hn' := by decide) :
δ₂ (n := n + 1) 1 hn hn' ≫ σ₂ 1 hn' hn = 𝟙 _ :=
SimplexCategory.δ_comp_σ_self (n := n + 1) (i := 1)
@[reassoc (attr := simp)]
lemma δ₂_two_comp_σ₂_one : δ₂ (2 : Fin 3) ≫ σ₂ 1 = 𝟙 _ :=
SimplexCategory.δ_comp_σ_succ' (by decide)
@[reassoc]
lemma δ₂_two_comp_σ₂_zero : δ₂ (2 : Fin 3) ≫ σ₂ 0 = σ₂ 0 ≫ δ₂ 1 :=
SimplexCategory.δ_comp_σ_of_gt' (by decide)
lemma δ₂_one_eq_const : δ₂ (1 : Fin 2) = const _ _ 0 := by decide
lemma δ₂_zero_eq_const : δ₂ (0 : Fin 2) = const _ _ 1 := by decide
@[reassoc]
lemma δ₂_zero_comp_δ₂_two : δ₂ (0 : Fin 2) ≫ δ₂ 2 = δ₂ 1 ≫ δ₂ 0 := by decide
end Two
end SimplexCategory.Truncated |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/MorphismProperty.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Basic
import Mathlib.CategoryTheory.MorphismProperty.Composition
/-!
# Properties of morphisms in the simplex category
In this file, we show that morphisms in the simplex category
are generated by faces and degeneracies. This is stated by
saying that if `W : MorphismProperty SimplexCategory` is
multiplicative, and contains faces and degeneracies, then `W = ⊤`.
This statement is deduced from a similar statement for
the category `SimplexCategory.Truncated d`.
-/
open CategoryTheory
namespace SimplexCategory
lemma Truncated.morphismProperty_eq_top
{d : ℕ} (W : MorphismProperty (Truncated d)) [W.IsMultiplicative]
(δ_mem : ∀ (n : ℕ) (hn : n < d) (i : Fin (n + 2)),
W (SimplexCategory.δ (n := n) i : ⟨.mk n, by dsimp; cutsat⟩ ⟶
⟨.mk (n + 1), by dsimp; cutsat⟩))
(σ_mem : ∀ (n : ℕ) (hn : n < d) (i : Fin (n + 1)),
W (SimplexCategory.σ (n := n) i : ⟨.mk (n + 1), by dsimp; cutsat⟩ ⟶
⟨.mk n, by dsimp; cutsat⟩)) :
W = ⊤ := by
ext ⟨a, ha⟩ ⟨b, hb⟩ f
simp only [MorphismProperty.top_apply, iff_true]
induction a using SimplexCategory.rec with | _ a
induction b using SimplexCategory.rec with | _ b
dsimp at ha hb
generalize h : a + b = c
induction c generalizing a b with
| zero =>
obtain rfl : a = 0 := by cutsat
obtain rfl : b = 0 := by cutsat
obtain rfl : f = 𝟙 _ := by
ext i : 3
apply Subsingleton.elim (α := Fin 1)
apply MorphismProperty.id_mem
| succ c hc =>
let f' : mk a ⟶ mk b := f
by_cases h₁ : Function.Surjective f'.toOrderHom; swap
· obtain _ | b := b
· exact (h₁ (fun _ ↦ ⟨0, Subsingleton.elim (α := Fin 1) _ _⟩)).elim
· obtain ⟨i, g', hf'⟩ := eq_comp_δ_of_not_surjective _ h₁
obtain rfl : f = (g' : _ ⟶ ⟨mk b, by dsimp; omega⟩) ≫ δ i := hf'
exact W.comp_mem _ _ (hc _ _ _ _ _ (by cutsat))
(δ_mem _ (by cutsat) _)
by_cases h₂ : Function.Injective f'.toOrderHom; swap
· obtain _ | a := a
· exact (h₂ (Function.injective_of_subsingleton (α := Fin 1) _)).elim
· obtain ⟨i, g', hf'⟩ := eq_σ_comp_of_not_injective _ h₂
obtain rfl : f = (by exact σ i) ≫ (g' : ⟨mk a, by dsimp; omega⟩ ⟶ _) := hf'
exact W.comp_mem _ _ (σ_mem _ (by cutsat) _) (hc _ _ _ _ _ (by cutsat))
rw [← epi_iff_surjective] at h₁
rw [← mono_iff_injective] at h₂
have := isIso_of_mono_of_epi f'
obtain rfl : a = b := len_eq_of_isIso f'
obtain rfl : f = 𝟙 _ := eq_id_of_mono f'
apply W.id_mem
lemma morphismProperty_eq_top
(W : MorphismProperty SimplexCategory) [W.IsMultiplicative]
(δ_mem : ∀ {n : ℕ} (i : Fin (n + 2)), W (SimplexCategory.δ i))
(σ_mem : ∀ {n : ℕ} (i : Fin (n + 1)), W (SimplexCategory.σ i)) :
W = ⊤ := by
have hW (d : ℕ) : W.inverseImage (Truncated.inclusion d) = ⊤ :=
Truncated.morphismProperty_eq_top _ (fun _ _ i ↦ δ_mem i)
(fun _ _ i ↦ σ_mem i)
ext a b f
simp only [MorphismProperty.top_apply, iff_true]
change W.inverseImage (Truncated.inclusion _)
(f : ⟨a, Nat.le_max_left _ _⟩ ⟶ ⟨b, Nat.le_max_right _ _⟩)
simp only [hW, MorphismProperty.top_apply]
end SimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/Rev.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Basic
/-!
# The covariant involution of the simplex category
In this file, we introduce the functor `rev : SimplexCategory ⥤ SimplexCategory`
which, via the equivalence between the simplex category and the
category of nonempty finite linearly ordered types, corresponds to
the *covariant* functor which sends a type `α` to `αᵒᵈ`.
-/
open CategoryTheory
namespace SimplexCategory
/-- The covariant involution `rev : SimplexCategory ⥤ SimplexCategory` which,
via the equivalence between the simplex category and the
category of nonempty finite linearly ordered types, corresponds to
the *covariant* functor which sends a type `α` to `αᵒᵈ`.
This functor sends the object `⦋n⦌` to `⦋n⦌` and a map `f : ⦋n⦌ ⟶ ⦋m⦌`
is sent to the monotone map `(i : Fin (n + 1)) ↦ (f i.rev).rev`. -/
@[simps obj]
def rev : SimplexCategory ⥤ SimplexCategory where
obj n := n
map {n m} f := Hom.mk ⟨fun i ↦ (f i.rev).rev, fun i j hij ↦ by
rw [Fin.rev_le_rev]
exact f.toOrderHom.monotone (by rwa [Fin.rev_le_rev])⟩
@[simp]
lemma rev_map_apply {n m : SimplexCategory} (f : n ⟶ m) (i : Fin (n.len + 1)) :
(rev.map f).toOrderHom (a := n) (b := m) i = (f.toOrderHom i.rev).rev := by
rfl
@[simp]
lemma rev_map_δ {n : ℕ} (i : Fin (n + 2)) :
rev.map (δ i) = δ i.rev := by
ext j : 3
rw [rev_map_apply]
dsimp [δ]
rw [Fin.succAbove_rev_right, Fin.rev_rev]
@[simp]
lemma rev_map_σ {n : ℕ} (i : Fin (n + 1)) :
rev.map (σ i) = σ i.rev := by
ext j : 3
rw [rev_map_apply]
dsimp [σ]
rw [Fin.predAbove_rev_right, Fin.rev_rev]
/-- The functor `SimplexCategory.rev : SimplexCategory ⥤ SimplexCategory`
is a covariant involution. -/
@[simps!]
def revCompRevIso : rev ⋙ rev ≅ 𝟭 _ :=
NatIso.ofComponents (fun _ ↦ Iso.refl _)
@[simp]
lemma rev_map_rev_map {n m : SimplexCategory} (f : n ⟶ m) :
rev.map (rev.map f) = f := by
aesop
/-- The functor `SimplexCategory.rev : SimplexCategory ⥤ SimplexCategory`
as an equivalence of category. -/
@[simps]
def revEquivalence : SimplexCategory ≌ SimplexCategory where
functor := rev
inverse := rev
unitIso := revCompRevIso.symm
counitIso := revCompRevIso
end SimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/Augmented/Monoidal.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic
import Mathlib.CategoryTheory.Monoidal.Category
/-!
# Monoidal structure on the augmented simplex category
This file defines a monoidal structure on `AugmentedSimplexCategory`.
The tensor product of objects is characterized by the fact that the initial object `star` is
also the unit, and the fact that `⦋m⦌ ⊗ ⦋n⦌ = ⦋m + n + 1⦌` for `n m : ℕ`.
Through the (not in mathlib) equivalence between `AugmentedSimplexCategory` and the category
of finite ordinals, the tensor products corresponds to ordinal sum.
As the unit of this structure is an initial object, for every `x y : AugmentedSimplexCategory`,
there are maps `AugmentedSimplexCategory.inl x y : x ⟶ x ⊗ y` and
`AugmentedSimplexCategory.inr x y : y ⟶ x ⊗ y`. The main API for working with the tensor product
of maps is given by `AugmentedSimplexCategory.tensorObj_hom_ext`, which characterizes maps
`x ⊗ y ⟶ z` in terms of their composition with these two maps. We also characterize the behaviour
of the associator isomorphism with respect to these maps.
-/
namespace AugmentedSimplexCategory
attribute [local aesop safe cases (rule_sets := [CategoryTheory])] CategoryTheory.WithInitial
open CategoryTheory MonoidalCategory
open scoped Simplicial
@[simp]
lemma eqToHom_toOrderHom {x y : SimplexCategory} (h : WithInitial.of x = WithInitial.of y) :
SimplexCategory.Hom.toOrderHom (WithInitial.down <| eqToHom h) =
(Fin.castOrderIso
(congrArg (fun t ↦ t + 1) (by injection h with h; rw [h]))).toOrderEmbedding.toOrderHom :=
SimplexCategory.eqToHom_toOrderHom (by injection h)
/-- An auxiliary definition for the tensor product of two objects in `AugmentedSimplexCategory`. -/
-- (Impl. note): This definition could easily be inlined in
-- the definition of `tensorObjOf` below, but having it type check directly as an element
-- of `SimplexCategory` avoids having to sprinkle `WithInitial.down` everywhere.
abbrev tensorObjOf (m n : SimplexCategory) : SimplexCategory := .mk (m.len + n.len + 1)
/-- The tensor product of two objects of `AugmentedSimplexCategory`. -/
def tensorObj (m n : AugmentedSimplexCategory) : AugmentedSimplexCategory :=
match m, n with
| .of m, .of n => .of <| tensorObjOf m n
| .star, x => x
| x, .star => x
/-- The action of the tensor product on maps coming from `SimplexCategory`. -/
def tensorHomOf {x₁ y₁ x₂ y₂ : SimplexCategory} (f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) :
tensorObjOf x₁ x₂ ⟶ tensorObjOf y₁ y₂ :=
letI f₁ : Fin ((x₁.len + 1) + (x₂.len + 1)) →o Fin ((y₁.len + 1) + (y₂.len + 1)) :=
{ toFun i :=
Fin.addCases
(motive := fun _ ↦ Fin <| (y₁.len + 1) + (y₂.len + 1))
(fun i ↦ (f₁.toOrderHom i).castAdd _)
(fun i ↦ (f₂.toOrderHom i).natAdd _)
i
monotone' i j h := by
cases i using Fin.addCases <;>
cases j using Fin.addCases <;>
rw [Fin.le_def] at h ⊢ <;>
simp [Fin.coe_castAdd, Fin.coe_natAdd, Fin.addCases_left,
Fin.addCases_right] at h ⊢
· case left.left i j => exact f₁.toOrderHom.monotone h
· case left.right i j => omega
· case right.left i j => omega
· case right.right i j => exact f₂.toOrderHom.monotone h }
(eqToHom (congrArg _ (Nat.succ_add _ _)).symm ≫ (SimplexCategory.mkHom f₁) ≫
eqToHom (congrArg _ (Nat.succ_add _ _)) : _ ⟶ ⦋y₁.len + y₂.len + 1⦌)
/-- The action of the tensor product on maps of `AugmentedSimplexCategory`. -/
def tensorHom {x₁ y₁ x₂ y₂ : AugmentedSimplexCategory} (f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) :
tensorObj x₁ x₂ ⟶ tensorObj y₁ y₂ :=
match x₁, y₁, x₂, y₂, f₁, f₂ with
| .of _, .of _, .of _, .of _, f₁, f₂ => tensorHomOf f₁ f₂
| .of _, .of y₁, .star, .of y₂, f₁, _ =>
f₁ ≫ ((SimplexCategory.mkHom <| (Fin.castAddOrderEmb (y₂.len + 1)).toOrderHom) ≫
eqToHom (congrArg _ (Nat.succ_add _ _)) : ⦋y₁.len⦌ ⟶ ⦋y₁.len + y₂.len + 1⦌)
| .star, .of y₁, .of _, .of y₂, _, f₂ =>
f₂ ≫ ((SimplexCategory.mkHom <| (Fin.natAddOrderEmb (y₁.len + 1)).toOrderHom) ≫
eqToHom (congrArg _ (Nat.succ_add _ _)) : ⦋y₂.len⦌ ⟶ ⦋y₁.len + y₂.len + 1⦌)
| .star, .star, .of _, .of _, _, f₂ => f₂
| .of _, .of _, .star, .star, f₁, _ => f₁
| .star, _, .star, _, _, _ => WithInitial.starInitial.to _
/-- The unit for the monoidal structure on `AugmentedSimplexCategory` is the initial object. -/
abbrev tensorUnit : AugmentedSimplexCategory := WithInitial.star
/-- The associator isomorphism for the monoidal structure on `AugmentedSimplexCategory` -/
def associator (x y z : AugmentedSimplexCategory) :
tensorObj (tensorObj x y) z ≅ tensorObj x (tensorObj y z) :=
match x, y, z with
| .of x, .of y, .of z =>
eqToIso (congrArg (fun j ↦ WithInitial.of <| SimplexCategory.mk j)
(by simp +arith))
| .star, .star, .star => Iso.refl _
| .star, .of _, .star => Iso.refl _
| .star, .star, .of _ => Iso.refl _
| .star, .of _, .of _ => Iso.refl _
| .of _, .star, .star => Iso.refl _
| .of _, .star, .of _ => Iso.refl _
| .of _, .of _, .star => Iso.refl _
/-- The left unitor isomorphism for the monoidal structure in `AugmentedSimplexCategory` -/
def leftUnitor (x : AugmentedSimplexCategory) :
tensorObj tensorUnit x ≅ x :=
match x with
| .of _ => Iso.refl _
| .star => Iso.refl _
/-- The right unitor isomorphism for the monoidal structure in `AugmentedSimplexCategory` -/
def rightUnitor (x : AugmentedSimplexCategory) :
tensorObj x tensorUnit ≅ x :=
match x with
| .of _ => Iso.refl _
| .star => Iso.refl _
instance : MonoidalCategoryStruct AugmentedSimplexCategory where
tensorObj := tensorObj
tensorHom := tensorHom
tensorUnit := tensorUnit
associator := associator
leftUnitor := leftUnitor
rightUnitor := rightUnitor
whiskerLeft x _ _ f := tensorHom (𝟙 x) f
whiskerRight f x := tensorHom f (𝟙 x)
@[local simp]
lemma id_tensorHom (x : AugmentedSimplexCategory) {y₁ y₂ : AugmentedSimplexCategory}
(f : y₁ ⟶ y₂) : 𝟙 x ⊗ₘ f = x ◁ f :=
rfl
@[local simp]
lemma tensorHom_id {x₁ x₂ : AugmentedSimplexCategory} (y : AugmentedSimplexCategory)
(f : x₁ ⟶ x₂) : f ⊗ₘ 𝟙 y = f ▷ y :=
rfl
@[local simp]
lemma whiskerLeft_id_star {x : AugmentedSimplexCategory} : x ◁ 𝟙 .star = 𝟙 _ := by
cases x <;>
rfl
@[local simp]
lemma id_star_whiskerRight {x : AugmentedSimplexCategory} : 𝟙 WithInitial.star ▷ x = 𝟙 _ := by
cases x <;>
rfl
/-- Thanks to `tensorUnit` being initial in `AugmentedSimplexCategory`, we get
a morphism `Δ ⟶ Δ ⊗ Δ'` for every pair of objects `Δ, Δ'`. -/
def inl (x y : AugmentedSimplexCategory) : x ⟶ x ⊗ y :=
(ρ_ x).inv ≫ _ ◁ (WithInitial.starInitial.to y)
/-- Thanks to `tensorUnit` being initial in `AugmentedSimplexCategory`, we get
a morphism `Δ' ⟶ Δ ⊗ Δ'` for every pair of objects `Δ, Δ'`. -/
def inr (x y : AugmentedSimplexCategory) : y ⟶ x ⊗ y :=
(λ_ y).inv ≫ (WithInitial.starInitial.to x) ▷ _
/-- To ease type checking, we also provide a version of inl that lives in
`SimplexCategory`. -/
abbrev inl' (x y : SimplexCategory) : x ⟶ tensorObjOf x y := WithInitial.down <| inl (.of x) (.of y)
/-- To ease type checking, we also provide a version of inr that lives in
`SimplexCategory`. -/
abbrev inr' (x y : SimplexCategory) : y ⟶ tensorObjOf x y := WithInitial.down <| inr (.of x) (.of y)
lemma inl'_eval (x y : SimplexCategory) (i : Fin (x.len + 1)) :
(inl' x y).toOrderHom i = (i.castAdd _).cast (Nat.succ_add x.len (y.len + 1)) := by
dsimp [inl', inl, MonoidalCategoryStruct.rightUnitor, MonoidalCategoryStruct.whiskerLeft,
tensorHom, WithInitial.down, rightUnitor, tensorObj]
ext
simp [OrderEmbedding.toOrderHom]
lemma inr'_eval (x y : SimplexCategory) (i : Fin (y.len + 1)) :
(inr' x y).toOrderHom i = (i.natAdd _).cast (Nat.succ_add x.len (y.len + 1)) := by
dsimp [inr', inr, MonoidalCategoryStruct.leftUnitor, MonoidalCategoryStruct.whiskerRight,
tensorHom, WithInitial.down, leftUnitor, tensorObj]
ext
simp [OrderEmbedding.toOrderHom]
/-- We can characterize morphisms out of a tensor product via their precomposition with `inl` and
`inr`. -/
@[ext]
theorem tensorObj_hom_ext {x y z : AugmentedSimplexCategory} (f g : x ⊗ y ⟶ z)
(h₁ : inl _ _ ≫ f = inl _ _ ≫ g)
(h₂ : inr _ _ ≫ f = inr _ _ ≫ g) : f = g :=
match x, y, z, f, g with
| .of x, .of y, .of z, f, g => by
change (tensorObjOf x y) ⟶ z at f g
change inl' _ _ ≫ f = inl' _ _ ≫ g at h₁
change inr' _ _ ≫ f = inr' _ _ ≫ g at h₂
ext i
let j : Fin ((x.len + 1) + (y.len + 1)) := i.cast (Nat.succ_add x.len (y.len + 1)).symm
have : i = j.cast (Nat.succ_add x.len (y.len + 1)) := rfl
rw [this]
cases j using Fin.addCases (m := x.len + 1) (n := y.len + 1) with
| left j =>
rw [SimplexCategory.Hom.ext_iff, OrderHom.ext_iff] at h₁
simpa [← inl'_eval, ConcreteCategory.hom, Fin.ext_iff] using congrFun h₁ j
| right j =>
rw [SimplexCategory.Hom.ext_iff, OrderHom.ext_iff] at h₂
simpa [← inr'_eval, ConcreteCategory.hom, Fin.ext_iff] using congrFun h₂ j
| .of x, .star, .of z, f, g => by
simp only [inl, Category.assoc, Iso.cancel_iso_inv_left, Limits.IsInitial.to_self,
whiskerLeft_id_star] at h₁
simpa [Category.id_comp f, Category.id_comp g] using h₁
| .star, .of y, .of z, f, g => by
simp only [inr, Category.assoc, Iso.cancel_iso_inv_left, Limits.IsInitial.to_self,
id_star_whiskerRight] at h₂
simpa [Category.id_comp f, Category.id_comp g] using h₂
| .star, .star, .of z, f, g => rfl
| .star, .star, .star, f, g => rfl
@[reassoc (attr := simp)]
lemma inl_comp_tensorHom {x₁ y₁ x₂ y₂ : AugmentedSimplexCategory}
(f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) : inl x₁ x₂ ≫ (f₁ ⊗ₘ f₂) = f₁ ≫ inl y₁ y₂ :=
match x₁, y₁, x₂, y₂, f₁, f₂ with
| .of x₁, .of y₁, .of x₂, .of y₂, f₁, f₂ => by
change inl' _ _ ≫ tensorHomOf _ _ = WithInitial.down f₁ ≫ inl' _ _
ext i : 3
dsimp [tensorHomOf]
have e₁ := inl'_eval x₁ x₂ i
have e₂ := inl'_eval y₁ y₂ <| (WithInitial.down f₁).toOrderHom i
simp only [SimplexCategory.len_mk] at e₁ e₂
rw [e₁, e₂]
simp only [SimplexCategory.eqToHom_toOrderHom, SimplexCategory.len_mk,
OrderEmbedding.toOrderHom_coe, OrderIso.coe_toOrderEmbedding, Fin.castOrderIso_apply,
Fin.cast_cast, Fin.cast_eq_self, Fin.cast_inj]
conv_lhs =>
change Fin.addCases
(fun i ↦ Fin.castAdd (y₂.len + 1) (f₁.toOrderHom i))
(fun i ↦ Fin.natAdd (y₁.len + 1) (f₂.toOrderHom i))
(Fin.castAdd (x₂.len + 1) i)
rw [Fin.addCases_left]
rfl
| _, _, .star, _, f₁, f₂ => by cat_disch
| .star, _, _, _, _, _ => rfl
@[reassoc (attr := simp)]
lemma inr_comp_tensorHom {x₁ y₁ x₂ y₂ : AugmentedSimplexCategory}
(f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) : inr x₁ x₂ ≫ (f₁ ⊗ₘ f₂) = f₂ ≫ inr y₁ y₂ :=
match x₁, y₁, x₂, y₂, f₁, f₂ with
| .of x₁, .of y₁, .of x₂, .of y₂, f₁, f₂ => by
change inr' _ _ ≫ tensorHomOf _ _ = WithInitial.down f₂ ≫ inr' _ _
ext i : 3
dsimp [tensorHomOf]
have e₁ := inr'_eval x₁ x₂ i
have e₂ := inr'_eval y₁ y₂ <| (WithInitial.down f₂).toOrderHom i
simp only [SimplexCategory.len_mk] at e₁ e₂
rw [e₁, e₂]
simp only [SimplexCategory.eqToHom_toOrderHom, SimplexCategory.len_mk,
Nat.succ_eq_add_one, OrderEmbedding.toOrderHom_coe,
OrderIso.coe_toOrderEmbedding, Fin.castOrderIso_apply,
Fin.cast_cast, Fin.cast_eq_self, Fin.cast_inj]
conv_lhs =>
change Fin.addCases
(fun i ↦ Fin.castAdd (y₂.len + 1) (f₁.toOrderHom i))
(fun i ↦ Fin.natAdd (y₁.len + 1) (f₂.toOrderHom i))
(Fin.natAdd (x₁.len + 1) i)
rw [Fin.addCases_right]
rfl
| .star, _, _, _, f₁, f₂ => by cat_disch
| _, _, .star, _, _, _ => rfl
@[reassoc (attr := simp)]
lemma inr_comp_associator (x y z : AugmentedSimplexCategory) :
inr _ _ ≫ (α_ x y z).hom = inr _ _ ≫ inr _ _ :=
match x, y, z with
| .of x, .of y, .of z => by
change inr' _ _ ≫ WithInitial.down _ = inr' _ _ ≫ inr' _ _
ext i : 3
dsimp [MonoidalCategoryStruct.associator, associator]
simp only [eqToHom_toOrderHom, SimplexCategory.len_mk, OrderEmbedding.toOrderHom_coe,
OrderIso.coe_toOrderEmbedding, Fin.castOrderIso_apply]
have e₁ := inr'_eval (tensorObjOf x y) z i
have e₂ := inr'_eval y z i
have e₃ := inr'_eval x (tensorObjOf y z) <|
Fin.cast (by simp +arith) <| i.natAdd (y.len + 1)
simp only [SimplexCategory.len_mk] at e₁ e₂ e₃
rw [e₁, e₂, e₃]
ext; simp +arith
| .star, _, _ => by cat_disch
| _, .star, _ => by cat_disch
| _, _, .star => by cat_disch
@[reassoc (attr := simp)]
lemma inl_comp_inl_comp_associator (x y z : AugmentedSimplexCategory) :
inl _ _ ≫ inl _ _ ≫ (α_ x y z).hom = inl _ _ :=
match x, y, z with
| .of x, .of y, .of z => by
change inl' _ _ ≫ inl' _ _ ≫ WithInitial.down _ = inl' _ _
ext i : 3
dsimp [MonoidalCategoryStruct.associator, associator]
have e₁ := inl'_eval x y i
have e₂ := inl'_eval x (tensorObjOf y z) i
have e₃ := inl'_eval (tensorObjOf x y) z <| Fin.cast (by simp +arith) <| i.castAdd (y.len + 1)
simp only [SimplexCategory.len_mk] at e₁ e₂ e₃
rw [e₁, e₂, e₃]
ext; simp +arith
| .star, _, _ => by cat_disch
| _, .star, _ => by cat_disch
| _, _, .star => by cat_disch
@[reassoc (attr := simp)]
lemma inr_comp_inl_comp_associator (x y z : AugmentedSimplexCategory) :
inr _ _ ≫ inl _ _ ≫ (α_ x y z).hom = inl _ _ ≫ inr _ _ :=
match x, y, z with
| .of x, .of y, .of z => by
change inr' _ _ ≫ inl' _ _ ≫ WithInitial.down _ = inl' _ _ ≫ inr' _ _
ext i : 3
dsimp [MonoidalCategoryStruct.associator, associator]
have e₁ := inl'_eval y z i
have e₂ := inr'_eval x y i
have e₃ := inl'_eval (tensorObjOf x y) z <| Fin.cast (by simp +arith) <| i.natAdd (x.len + 1)
have e₄ := inr'_eval x (tensorObjOf y z) <| Fin.cast (by simp +arith) <| i.castAdd (z.len + 1)
simp only [SimplexCategory.len_mk] at e₁ e₂ e₃ e₄
rw [e₁, e₂, e₃, e₄]
ext; simp +arith
| .star, _, _ => by cat_disch
| _, .star, _ => by cat_disch
| _, _, .star => by cat_disch
theorem tensorHom_comp_tensorHom {x₁ y₁ z₁ x₂ y₂ z₂ : AugmentedSimplexCategory}
(f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) (g₁ : y₁ ⟶ z₁) (g₂ : y₂ ⟶ z₂) :
(f₁ ⊗ₘ f₂) ≫ (g₁ ⊗ₘ g₂) = (f₁ ≫ g₁) ⊗ₘ (f₂ ≫ g₂) := by
cat_disch
theorem tensor_id (x y : AugmentedSimplexCategory) : (𝟙 x) ⊗ₘ (𝟙 y) = 𝟙 (x ⊗ y) := by
ext
· simpa [inl, MonoidalCategoryStruct.whiskerLeft, MonoidalCategoryStruct.whiskerRight] using
(tensorHom_comp_tensorHom (𝟙 x) (WithInitial.starInitial.to y) (𝟙 x) (𝟙 y))
· simpa [inr, MonoidalCategoryStruct.whiskerLeft, MonoidalCategoryStruct.whiskerRight] using
(tensorHom_comp_tensorHom (WithInitial.starInitial.to x) (𝟙 y) (𝟙 x) (𝟙 y))
instance : MonoidalCategory AugmentedSimplexCategory :=
MonoidalCategory.ofTensorHom
(id_tensorHom_id := tensor_id)
(tensorHom_comp_tensorHom := tensorHom_comp_tensorHom)
(pentagon := fun w x y z ↦ by ext <;> simp [-id_tensorHom, -tensorHom_id])
end AugmentedSimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/Augmented/Basic.lean | import Mathlib.CategoryTheory.WithTerminal.Basic
import Mathlib.AlgebraicTopology.SimplexCategory.Basic
import Mathlib.AlgebraicTopology.SimplicialObject.Basic
/-!
# The Augmented simplex category
This file defines the `AugmentedSimplexCategory` as the category obtained by adding an initial
object to `SimplexCategory` (using `CategoryTheory.WithInitial`).
This definition provides a canonical full and faithful inclusion functor
`inclusion : SimplexCategory ⥤ AugmentedSimplexCategory`.
We prove that functors out of `AugmentedSimplexCategory` are equivalent to augmented cosimplicial
objects and that functors out of `AugmentedSimplexCategoryᵒᵖ` are equivalent to augmented simplicial
objects, and we provide a translation of the main constrcutions on augmented (co)simplicial objects
(i.e `drop`, `point` and `toArrow`) in terms of these equivalences.
-/
open CategoryTheory
/-- The `AugmentedSimplexCategory` is the category obtained from `SimplexCategory` by adjoining an
initial object. -/
abbrev AugmentedSimplexCategory := WithInitial SimplexCategory
namespace AugmentedSimplexCategory
variable {C : Type*} [Category C]
/-- The canonical inclusion from `SimplexCategory` to `AugmentedSimplexCategory`. -/
@[simps!]
def inclusion : SimplexCategory ⥤ AugmentedSimplexCategory := WithInitial.incl
instance : inclusion.Full := inferInstanceAs WithInitial.incl.Full
instance : inclusion.Faithful := inferInstanceAs WithInitial.incl.Faithful
instance : Limits.HasInitial AugmentedSimplexCategory :=
inferInstanceAs <| Limits.HasInitial <| WithInitial _
/-- The equivalence between functors out of `AugmentedSimplexCategory` and augmented
cosimplicial objects. -/
@[simps!]
def equivAugmentedCosimplicialObject :
(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C :=
WithInitial.equivComma
/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
dropping the augmentation corresponds to precomposition with
`inclusion : SimplexCategory ⥤ AugmentedSimplexCategory`. -/
@[simps!]
def equivAugmentedCosimplicialObjectFunctorCompDropIso :
equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.drop ≅
(Functor.whiskeringLeft _ _ C).obj inclusion :=
.refl _
/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
taking the point of the augmentation corresponds to evaluation at the initial object. -/
@[simps!]
def equivAugmentedCosimplicialObjectFunctorCompPointIso :
equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.point ≅
((evaluation _ _).obj .star : (AugmentedSimplexCategory ⥤ C) ⥤ C) :=
.refl _
@[deprecated (since := "2025-08-22")] alias equivAugmentedCosimplicialObjecFunctorCompPointIso :=
equivAugmentedCosimplicialObjectFunctorCompPointIso
/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
the arrow attached to the cosimplicial object is the one obtained by evaluation at the unique arrow
`star ⟶ of [0]`. -/
@[simps!]
def equivAugmentedCosimplicialObjectFunctorCompToArrowIso :
equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.toArrow ≅
Functor.mapArrowFunctor _ C ⋙
(evaluation _ _ |>.obj <| .mk <| WithInitial.homTo <| .mk 0) :=
.refl _
/-- The equivalence between functors out of `AugmentedSimplexCategory` and augmented simplicial
objects. -/
@[simps!]
def equivAugmentedSimplicialObject :
(AugmentedSimplexCategoryᵒᵖ ⥤ C) ≌ SimplicialObject.Augmented C :=
WithInitial.opEquiv SimplexCategory |>.congrLeft |>.trans WithTerminal.equivComma
/-- Through the equivalence `(AugmentedSimplexCategoryᵒᵖ ⥤ C) ≌ SimplicialObject.Augmented C`,
dropping the augmentation corresponds to precomposition with
`inclusionᵒᵖ : SimplexCategoryᵒᵖ ⥤ AugmentedSimplexCategoryᵒᵖ`. -/
@[simps!]
def equivAugmentedSimplicialObjectFunctorCompDropIso :
equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.drop ≅
(Functor.whiskeringLeft _ _ C).obj inclusion.op :=
.refl _
/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
taking the point of the augmentation corresponds to evaluation at the initial object. -/
@[simps!]
def equivAugmentedSimplicialObjectFunctorCompPointIso :
equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.point ≅
(evaluation _ C).obj (.op .star) :=
.refl _
/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
the arrow attached to the cosimplicial object is the one obtained by evaluation at the unique arrow
`star ⟶ of [0]`. -/
@[simps!]
def equivAugmentedSimplicialObjectFunctorCompToArrowIso :
equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.toArrow ≅
Functor.mapArrowFunctor _ C ⋙
(evaluation _ _ |>.obj <| .mk <| .op <| WithInitial.homTo <| .mk 0) :=
.refl _
end AugmentedSimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/GeneratorsRelations/NormalForms.lean | import Mathlib.AlgebraicTopology.SimplexCategory.GeneratorsRelations.EpiMono
/-! # Normal forms for morphisms in `SimplexCategoryGenRel`.
In this file, we establish that `P_δ` and `P_σ` morphisms in `SimplexCategoryGenRel`
each admits a normal form.
In both cases, the normal forms are encoded as an integer `m`, and a strictly increasing
list of integers `[i₀,…,iₙ]` such that `iₖ ≤ m + k` for all `k`. We define a predicate
`isAdmissible m : List ℕ → Prop` encoding this property. And provide some lemmas to help
work with such lists.
Normal forms for `P_σ` morphisms are encoded by `m`-admissible lists, in which case the list
`[i₀,…,iₙ]` represents the morphism `σ iₙ ≫ ⋯ ≫ σ i₀ : .mk (m + n) ⟶ .mk n`.
Normal forms for `P_δ` morphisms are encoded by `(m + 1)`-admissible lists, in which case the list
`[i₀,…,iₙ]` represents the morphism `δ i₀ ≫ ⋯ ≫ δ iₙ : .mk n ⟶ .mk (m + n)`.
The results in this file are to be treated as implementation-only, and they only serve as stepping
stones towards proving that the canonical functor
`toSimplexCategory : SimplexCategoryGenRel ⥤ SimplexCategory` is an equivalence.
## References:
* [Kerodon Tag 04FQ](https://kerodon.net/tag/04FQ)
* [Kerodon Tag 04FT](https://kerodon.net/tag/04FT)
## TODOs:
- Show that every `P_δ` admits a unique normal form.
-/
namespace SimplexCategoryGenRel
open CategoryTheory
section AdmissibleLists
-- Impl. note: We are not bundling admissible lists as a subtype of `List ℕ` so that it remains
-- easier to perform inductive constructions and proofs on such lists, and we instead bundle
-- propositions asserting that various List constructions produce admissible lists.
variable (m : ℕ)
/-- A list of natural numbers `[i₀, ⋯, iₙ]` is said to be `m`-admissible (for `m : ℕ`) if
`i₀ < ⋯ < iₙ` and `iₖ ≤ m + k` for all `k`. This would suggest the definition
`L.IsChain (· < ·) ∧ ∀ k, (h : k < L.length) → L[k] ≤ m + k`.
However, we instead define `IsAdmissible` inductively and show, in
`isAdmissible_iff_isChain_and_le`, that this is equivalent to the non-inductive definition.
-/
@[mk_iff]
inductive IsAdmissible : (m : ℕ) → (L : List ℕ) → Prop
| nil (m : ℕ) : IsAdmissible m []
| singleton {m a} (ha : a ≤ m) : IsAdmissible m [a]
| cons_cons {m a b L'} (hab : a < b) (hbL : IsAdmissible (m + 1) (b :: L'))
(ha : a ≤ m) : IsAdmissible m (a :: b :: L')
attribute [simp, grind ←] IsAdmissible.nil
attribute [grind →] IsAdmissible.cons_cons
section IsAdmissible
variable {m a b : ℕ} {L : List ℕ}
@[simp, grind =]
theorem isAdmissible_singleton_iff : IsAdmissible m [a] ↔ a ≤ m :=
⟨fun | .singleton h => h, .singleton⟩
@[simp, grind =]
theorem isAdmissible_cons_cons_iff : IsAdmissible m (a :: b :: L) ↔
a < b ∧ IsAdmissible (m + 1) (b :: L) ∧ a ≤ m :=
⟨fun | .cons_cons hab hbL ha => ⟨hab, hbL, ha⟩, by grind⟩
theorem isAdmissible_cons_iff : IsAdmissible m (a :: L) ↔
a ≤ m ∧ ((_ : 0 < L.length) → a < L[0]) ∧ IsAdmissible (m + 1) L := by
cases L <;> grind
theorem isAdmissible_iff_isChain_and_le : IsAdmissible m L ↔
L.IsChain (· < ·) ∧ ∀ k, (h : k < L.length) → L[k] ≤ m + k := by
induction L using List.twoStepInduction generalizing m with
| nil => grind
| singleton _ => simp
| cons_cons _ _ _ _ IH =>
simp_rw [isAdmissible_cons_cons_iff, IH, List.length_cons, and_assoc,
List.isChain_cons_cons, and_assoc, and_congr_right_iff, and_comm]
exact fun _ _ => ⟨fun h => by grind,
fun h => ⟨h 0 (by grind), fun k _ => (h (k + 1) (by grind)).trans (by grind)⟩⟩
theorem isAdmissible_iff_pairwise_and_le : IsAdmissible m L ↔
L.Pairwise (· < ·) ∧ ∀ k, (h : k < L.length) → L[k] ≤ m + k := by
rw [isAdmissible_iff_isChain_and_le, List.isChain_iff_pairwise]
theorem isAdmissible_of_isChain_of_forall_getElem_le {m L} (hL : L.IsChain (· < ·))
(hL₂ : ∀ k, (h : k < L.length) → L[k] ≤ m + k) : IsAdmissible m L :=
isAdmissible_iff_isChain_and_le.mpr ⟨hL, hL₂⟩
namespace IsAdmissible
@[grind →] theorem isChain {m L} (hL : IsAdmissible m L) :
L.IsChain (· < ·) := (isAdmissible_iff_isChain_and_le.mp hL).1
@[grind →] theorem le {m} {L : List ℕ} (hL : IsAdmissible m L) : ∀ k (h : k < L.length),
L[k] ≤ m + k := (isAdmissible_iff_isChain_and_le.mp hL).2
/-- The tail of an `m`-admissible list is (m+1)-admissible. -/
@[grind →] lemma of_cons {m a L} (h : IsAdmissible m (a :: L)) :
IsAdmissible (m + 1) L := by cases L <;> grind
@[deprecated (since := "2025-10-15")]
alias tail := IsAdmissible.of_cons
lemma cons {m a L} (hL : IsAdmissible (m + 1) L) (ha : a ≤ m)
(ha' : (_ : 0 < L.length) → a < L[0]) : IsAdmissible m (a :: L) := by cases L <;> grind
theorem pairwise {m L} (hL : IsAdmissible m L) : L.Pairwise (· < ·) :=
hL.isChain.pairwise
@[deprecated (since := "2025-10-16")]
alias sorted := pairwise
/-- If `(a :: l)` is `m`-admissible then a is less than all elements of `l` -/
@[grind →]
lemma head_lt {m a L} (hL : IsAdmissible m (a :: L)) :
∀ a' ∈ L, a < a' := fun _ => L.rel_of_pairwise_cons hL.pairwise
@[grind →] lemma getElem_lt {m L} (hL : IsAdmissible m L)
{k : ℕ} {hk : k < L.length} : L[k] < m + L.length :=
(hL.le k hk).trans_lt (Nat.add_lt_add_left hk _)
/-- An element of a `m`-admissible list, as an element of the appropriate `Fin` -/
@[simps]
def getElemAsFin {m L} (hl : IsAdmissible m L) (k : ℕ)
(hK : k < L.length) : Fin (m + k + 1) :=
Fin.mk L[k] <| Nat.le_iff_lt_add_one.mp (by grind)
/-- The head of an `m`-admissible list. -/
@[simps!]
def head {m a L} (hl : IsAdmissible m (a :: L)) : Fin (m + 1) :=
hl.getElemAsFin 0 (by grind)
theorem mono {n} (hmn : m ≤ n) (hL : IsAdmissible m L) : IsAdmissible n L :=
isAdmissible_of_isChain_of_forall_getElem_le (by grind) (by grind)
end IsAdmissible
end IsAdmissible
/-- The construction `simplicialInsert` describes inserting an element in a list of integer and
moving it to its "right place" according to the simplicial relations. Somewhat miraculously,
the algorithm is the same for the first or the fifth simplicial relations, making it "valid"
when we treat the list as a normal form for a morphism satisfying `P_δ`, or for a morphism
satisfying `P_σ`!
This is similar in nature to `List.orderedInsert`, but note that we increment one of the element
every time we perform an exchange, making it a different construction. -/
@[local grind]
def simplicialInsert (a : ℕ) : List ℕ → List ℕ
| [] => [a]
| b :: l => if a < b then a :: b :: l else b :: simplicialInsert (a + 1) l
/-- `simplicialInsert` just adds one to the length. -/
lemma simplicialInsert_length (a : ℕ) (L : List ℕ) :
(simplicialInsert a L).length = L.length + 1 := by
induction L generalizing a <;> grind
/-- `simplicialInsert` preserves admissibility -/
theorem simplicialInsert_isAdmissible (L : List ℕ) (hL : IsAdmissible (m + 1) L) (j : ℕ)
(hj : j ≤ m) :
IsAdmissible m <| simplicialInsert j L := by
induction L generalizing j m with
| nil => exact IsAdmissible.singleton hj
| cons a L h_rec => cases L <;> grind
end AdmissibleLists
section NormalFormsP_σ
-- Impl note.: The definition is a bit awkward with the extra parameters, but this
-- is necessary in order to avoid some type theory hell when proving that `orderedInsert`
-- behaves as expected...
/-- Given a sequence `L = [ i 0, ..., i b ]`, `standardσ m L` i is the morphism
`σ (i b) ≫ … ≫ σ (i 0)`. The construction is provided for any list of natural numbers,
but it is intended to behave well only when the list is admissible. -/
def standardσ (L : List ℕ) {m₁ m₂ : ℕ} (h : m₂ + L.length = m₁) : mk m₁ ⟶ mk m₂ :=
match L with
| .nil => eqToHom (by grind)
| .cons a t => standardσ t (by grind) ≫ σ (Fin.ofNat _ a)
@[simp]
lemma standardσ_nil (m : ℕ) : standardσ .nil (by grind) = 𝟙 (mk m) := rfl
@[simp, reassoc]
lemma standardσ_cons (L : List ℕ) (a : ℕ) {m₁ m₂ : ℕ} (h : m₂ + (a :: L).length = m₁) :
standardσ (L.cons a) h = standardσ L (by grind) ≫ σ (Fin.ofNat _ a) := rfl
@[reassoc]
lemma standardσ_comp_standardσ (L₁ L₂ : List ℕ) {m₁ m₂ m₃ : ℕ}
(h : m₂ + L₁.length = m₁) (h' : m₃ + L₂.length = m₂) :
standardσ L₁ h ≫ standardσ L₂ h' = standardσ (L₂ ++ L₁) (by grind) := by
induction L₂ generalizing L₁ m₁ m₂ m₃ with
| nil =>
obtain rfl : m₃ = m₂ := by grind
simp
| cons a t H =>
dsimp at h' ⊢
obtain rfl : m₂ = (m₃ + t.length) + 1 := by grind
simp [reassoc_of% (H L₁ (m₁ := m₁) (m₂ := m₃ + t.length + 1) (m₃ := m₃ + 1)
(by grind) (by grind))]
variable (m : ℕ) (L : List ℕ)
/-- `simplicialEvalσ` is a lift to ℕ of `(toSimplexCategory.map (standardσ m L _ _)).toOrderHom`.
Rather than defining it as such, we define it inductively for less painful inductive reasoning,
(see `simplicialEvalσ_of_isAdmissible`).
It is expected to produce the correct result only if `L` is admissible, and values for
non-admissible lists should be considered junk values. Similarly, values for out-of-bounds inputs
are junk values. -/
@[local grind]
def simplicialEvalσ (L : List ℕ) : ℕ → ℕ :=
fun j ↦ match L with
| [] => j
| a :: L => if a < simplicialEvalσ L j then simplicialEvalσ L j - 1 else simplicialEvalσ L j
@[grind ←]
lemma simplicialEvalσ_of_le_mem (j : ℕ) (hj : ∀ k ∈ L, j ≤ k) : simplicialEvalσ L j = j := by
induction L with | nil => grind | cons _ _ _ => simp only [List.forall_mem_cons] at hj; grind
@[deprecated (since := "2025-10-16")]
alias simplicialEvalσ_of_lt_mem := simplicialEvalσ_of_le_mem
lemma simplicialEvalσ_monotone (L : List ℕ) : Monotone (simplicialEvalσ L) := by
induction L <;> grind [Monotone]
variable {m}
/- We prove that `simplicialEvalσ` is indeed a lift of
`(toSimplexCategory.map (standardσ m L _ _)).toOrderHom` when the list is admissible. -/
lemma simplicialEvalσ_of_isAdmissible
(m₁ m₂ : ℕ) (hL : IsAdmissible m₂ L) (hk : m₂ + L.length = m₁)
(j : ℕ) (hj : j < m₁ + 1) :
(toSimplexCategory.map <| standardσ L hk).toOrderHom ⟨j, hj⟩ =
simplicialEvalσ L j := by
induction L generalizing m₁ m₂ with
| nil =>
obtain rfl : m₁ = m₂ := by grind
simp [simplicialEvalσ]
| cons a L h_rec =>
simp only [List.length_cons] at hk
subst hk
set a₀ := hL.head
have aux (t : Fin (m₂ + 2)) :
(a₀.predAbove t : ℕ) = if a < ↑t then (t : ℕ) - 1 else ↑t := by
simp only [Fin.predAbove, a₀]
split_ifs with h₁ h₂ h₂
· rfl
· simp only [Fin.lt_def, Fin.coe_castSucc, IsAdmissible.head_val] at h₁; grind
· simp only [Fin.lt_def, Fin.coe_castSucc, IsAdmissible.head_val, not_lt] at h₁; grind
· rfl
have := h_rec _ _ hL.of_cons (by grind) hj
have ha₀ : Fin.ofNat (m₂ + 1) a = a₀ := by ext; simpa [a₀] using hL.head.prop
simpa only [toSimplexCategory_obj_mk, SimplexCategory.len_mk, standardσ_cons, Functor.map_comp,
toSimplexCategory_map_σ, SimplexCategory.σ, SimplexCategory.mkHom,
SimplexCategory.comp_toOrderHom, SimplexCategory.Hom.toOrderHom_mk, OrderHom.comp_coe,
Function.comp_apply, Fin.predAboveOrderHom_coe, simplicialEvalσ, ha₀, ← this] using aux _
/-- Performing a simplicial insertion in a list is the same as composition on the right by the
corresponding degeneracy operator. -/
lemma standardσ_simplicialInsert (hL : IsAdmissible (m + 1) L) (j : ℕ) (hj : j < m + 1)
(m₁ : ℕ) (hm₁ : m + L.length + 1 = m₁) :
standardσ (m₂ := m) (simplicialInsert j L) (m₁ := m₁)
(by simpa only [simplicialInsert_length, add_assoc]) =
standardσ (m₂ := m + 1) L (by grind) ≫ σ (Fin.ofNat _ j) := by
induction L generalizing m j with
| nil => simp [standardσ, simplicialInsert]
| cons a L h_rec =>
simp only [simplicialInsert]
split_ifs
· simp
· have : ∀ (j k : ℕ) (h : j < (k + 1)), Fin.ofNat (k + 1) j = j := by simp -- helps grind below
have : a < m + 2 := by grind -- helps grind below
have : σ (Fin.ofNat (m + 2) a) ≫ σ (.ofNat _ j) = σ (.ofNat _ (j + 1)) ≫ σ (.ofNat _ a) := by
convert σ_comp_σ_nat (n := m) a j (by grind) (by grind) (by grind) <;> grind
grind [standardσ_cons]
attribute [local grind! .] simplicialInsert_length simplicialInsert_isAdmissible in
/-- Using `standardσ_simplicialInsert`, we can prove that every morphism satisfying `P_σ` is equal
to some `standardσ` for some admissible list of indices. -/
theorem exists_normal_form_P_σ {x y : SimplexCategoryGenRel} (f : x ⟶ y) (hf : P_σ f) :
∃ L : List ℕ,
∃ m : ℕ, ∃ b : ℕ,
∃ h₁ : mk m = y, ∃ h₂ : x = mk (m + b), ∃ h : L.length = b,
IsAdmissible m L ∧ f = standardσ L (by rw [h, h₁.symm, h₂]; rfl) := by
induction hf with
| id n =>
use [], n.len, 0, rfl, rfl, rfl, IsAdmissible.nil _
rfl
| of f hf =>
cases hf with | @σ m k =>
use [k.val], m, 1, rfl, rfl, rfl, IsAdmissible.singleton k.is_le
simp [standardσ]
| @comp_of _ j x' g g' hg hg' h_rec =>
cases hg' with | @σ m k =>
obtain ⟨L₁, m₁, b₁, h₁', rfl, h', hL₁, e₁⟩ := h_rec
obtain rfl : m₁ = m + 1 := congrArg (fun x ↦ x.len) h₁'
use simplicialInsert k.val L₁, m, b₁ + 1, rfl, by grind, by grind, by grind
subst_vars
have := standardσ (m₁ := m + 1 + L₁.length) [] (by grind) ≫=
(standardσ_simplicialInsert L₁ hL₁ k k.prop _ rfl).symm
simp_all [Fin.ofNat_eq_cast, Fin.cast_val_eq_self, standardσ_comp_standardσ_assoc,
standardσ_comp_standardσ]
section MemIsAdmissible
lemma IsAdmissible.simplicialEvalσ_succ_getElem (hL : IsAdmissible m L)
{k : ℕ} {hk : k < L.length} : simplicialEvalσ L L[k] = simplicialEvalσ L (L[k] + 1) := by
induction L generalizing m k <;> grind [→ IsAdmissible.singleton]
local grind_pattern IsAdmissible.simplicialEvalσ_succ_getElem =>
IsAdmissible m L, simplicialEvalσ L L[k]
lemma mem_isAdmissible_of_lt_and_eval_eq_eval_add_one (hL : IsAdmissible m L)
(j : ℕ) (hj₁ : j < m + L.length) (hj₂ : simplicialEvalσ L j = simplicialEvalσ L (j + 1)) :
j ∈ L := by
induction L generalizing m with
| nil => grind
| cons a L h_rec =>
have := simplicialEvalσ_monotone L (a := a + 1)
rcases lt_trichotomy j a with h | h | h <;> grind
lemma lt_and_eval_eq_eval_add_one_of_mem_isAdmissible (hL : IsAdmissible m L) (j : ℕ) (hj : j ∈ L) :
j < m + L.length ∧ simplicialEvalσ L j = simplicialEvalσ L (j + 1) := by
grind [List.mem_iff_getElem]
/-- We can characterize elements in an admissible list as exactly those for which
`simplicialEvalσ` takes the same value twice in a row. -/
lemma mem_isAdmissible_iff (hL : IsAdmissible m L) (j : ℕ) :
j ∈ L ↔ j < m + L.length ∧ simplicialEvalσ L j = simplicialEvalσ L (j + 1) := by
grind [lt_and_eval_eq_eval_add_one_of_mem_isAdmissible,
mem_isAdmissible_of_lt_and_eval_eq_eval_add_one]
end MemIsAdmissible
end NormalFormsP_σ
end SimplexCategoryGenRel |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/GeneratorsRelations/EpiMono.lean | import Mathlib.AlgebraicTopology.SimplexCategory.GeneratorsRelations.Basic
/-! # Epi-mono factorization in the simplex category presented by generators and relations
This file aims to establish that there is a nice epi-mono factorization in `SimplexCategoryGenRel`.
More precisely, we introduce two morphism properties `P_δ` and `P_σ` that
single out morphisms that are compositions of `δ i` (resp. `σ i`).
The main result of this file is `exists_P_σ_P_δ_factorization`, which asserts that every
moprhism as a decomposition of a `P_σ` followed by a `P_δ`.
-/
namespace SimplexCategoryGenRel
open CategoryTheory
section EpiMono
/-- `δ i` is a split monomorphism thanks to the simplicial identities. -/
def splitMonoδ {n : ℕ} (i : Fin (n + 2)) : SplitMono (δ i) where
retraction := by
induction i using Fin.lastCases with
| last => exact σ (Fin.last n)
| cast i => exact σ i
id := by
cases i using Fin.lastCases
· simp only [Fin.lastCases_last]
exact δ_comp_σ_succ
· simp only [Fin.lastCases_castSucc]
exact δ_comp_σ_self
instance {n : ℕ} {i : Fin (n + 2)} : IsSplitMono (δ i) := .mk' <| splitMonoδ i
/-- `δ i` is a split epimorphism thanks to the simplicial identities. -/
def splitEpiσ {n : ℕ} (i : Fin (n + 1)) : SplitEpi (σ i) where
section_ := δ i.castSucc
id := δ_comp_σ_self
instance {n : ℕ} {i : Fin (n + 1)} : IsSplitEpi (σ i) := .mk' <| splitEpiσ i
/-- Auxiliary predicate to express that a morphism is purely a composition of `σ i`s. -/
abbrev P_σ := degeneracies.multiplicativeClosure
/-- Auxiliary predicate to express that a morphism is purely a composition of `δ i`s. -/
abbrev P_δ := faces.multiplicativeClosure
lemma P_σ.σ {n : ℕ} (i : Fin (n + 1)) : P_σ (σ i) := .of _ (.σ i)
lemma P_δ.δ {n : ℕ} (i : Fin (n + 2)) : P_δ (δ i) := .of _ (.δ i)
/-- All `P_σ` are split epis as composition of such. -/
lemma isSplitEpi_P_σ {x y : SimplexCategoryGenRel} {e : x ⟶ y} (he : P_σ e) : IsSplitEpi e := by
induction he with
| of x hx => cases hx; infer_instance
| id => infer_instance
| comp_of _ _ _ h => cases h; infer_instance
/-- All `P_δ` are split monos as composition of such. -/
lemma isSplitMono_P_δ {x y : SimplexCategoryGenRel} {m : x ⟶ y} (hm : P_δ m) :
IsSplitMono m := by
induction hm with
| of x hx => cases hx; infer_instance
| id => infer_instance
| comp_of _ _ _ h => cases h; infer_instance
lemma isSplitEpi_toSimplexCategory_map_of_P_σ {x y : SimplexCategoryGenRel} {e : x ⟶ y}
(he : P_σ e) : IsSplitEpi <| toSimplexCategory.map e := by
constructor
constructor
apply SplitEpi.map
exact isSplitEpi_P_σ he |>.exists_splitEpi.some
lemma isSplitMono_toSimplexCategory_map_of_P_δ {x y : SimplexCategoryGenRel} {m : x ⟶ y}
(hm : P_δ m) : IsSplitMono <| toSimplexCategory.map m := by
constructor
constructor
apply SplitMono.map
exact isSplitMono_P_δ hm |>.exists_splitMono.some
lemma eq_or_len_le_of_P_δ {x y : SimplexCategoryGenRel} {f : x ⟶ y} (h_δ : P_δ f) :
(∃ h : x = y, f = eqToHom h) ∨ x.len < y.len := by
induction h_δ with
| of _ hx => cases hx; right; simp
| id => left; use rfl; simp
| comp_of i u _ hg h' =>
rcases h' with ⟨e, _⟩ | h' <;>
apply Or.inr <;>
cases hg
· rw [e]
exact Nat.lt_add_one _
· exact Nat.lt_succ_of_lt h'
end EpiMono
section ExistenceOfFactorizations
/-- An auxiliary lemma to show that one can always use the simplicial identities to simplify a term
in the form `δ ≫ σ` into either an identity, or a term of the form `σ ≫ δ`. This is the crucial
special case to induct on to get an epi-mono factorization for all morphisms. -/
private lemma switch_δ_σ {n : ℕ} (i : Fin (n + 2)) (i' : Fin (n + 3)) :
δ i' ≫ σ i = 𝟙 _ ∨ ∃ j j', δ i' ≫ σ i = σ j ≫ δ j' := by
obtain h | rfl | h := lt_trichotomy i.castSucc i'
· rw [Fin.castSucc_lt_iff_succ_le] at h
obtain h | rfl := h.lt_or_eq
· obtain ⟨i', rfl⟩ := Fin.eq_succ_of_ne_zero (Fin.ne_zero_of_lt h)
rw [Fin.succ_lt_succ_iff] at h
obtain ⟨i, rfl⟩ := Fin.eq_castSucc_of_ne_last (Fin.ne_last_of_lt h)
exact Or.inr ⟨i, i', by rw [δ_comp_σ_of_gt h]⟩
· exact Or.inl δ_comp_σ_succ
· exact Or.inl δ_comp_σ_self
· obtain ⟨i', rfl⟩ := Fin.eq_castSucc_of_ne_last (Fin.ne_last_of_lt h)
rw [Fin.castSucc_lt_castSucc_iff] at h
obtain ⟨i, rfl⟩ := Fin.eq_succ_of_ne_zero (Fin.ne_zero_of_lt h)
rw [← Fin.le_castSucc_iff] at h
exact Or.inr ⟨i, i', by rw [δ_comp_σ_of_le h]⟩
/-- A low-dimensional special case of the previous -/
private lemma switch_δ_σ₀ (i : Fin 1) (i' : Fin 2) :
δ i' ≫ σ i = 𝟙 _ := by
fin_cases i; fin_cases i'
· exact δ_comp_σ_self
· exact δ_comp_σ_succ
private lemma factor_δ_σ {n : ℕ} (i : Fin (n + 1)) (i' : Fin (n + 2)) :
∃ (z : SimplexCategoryGenRel) (e : mk n ⟶ z) (m : z ⟶ mk n)
(_ : P_σ e) (_ : P_δ m), δ i' ≫ σ i = e ≫ m := by
cases n with
| zero => exact ⟨_, _, _, P_σ.id_mem _, P_δ.id_mem _, by simp [switch_δ_σ₀]⟩
| succ n =>
obtain h | ⟨j, j', h⟩ := switch_δ_σ i i'
· exact ⟨_, _, _, P_σ.id_mem _, P_δ.id_mem _, by simp [h]⟩
· exact ⟨_, _, _, P_σ.σ _, P_δ.δ _, h⟩
/-- An auxiliary lemma that shows there exists a factorization as a P_δ followed by a P_σ for
morphisms of the form `P_δ ≫ σ`. -/
private lemma factor_P_δ_σ {n : ℕ} (i : Fin (n + 1)) {x : SimplexCategoryGenRel}
(f : x ⟶ mk (n + 1)) (hf : P_δ f) : ∃ (z : SimplexCategoryGenRel) (e : x ⟶ z) (m : z ⟶ mk n)
(_ : P_σ e) (_ : P_δ m), f ≫ σ i = e ≫ m := by
induction n generalizing x with
| zero => cases hf with
| of _ h => cases h; exact factor_δ_σ _ _
| id => exact ⟨_, _, _, P_σ.σ i, P_δ.id_mem _, by simp⟩
| comp_of j f hf hg =>
obtain ⟨k⟩ := hg
obtain ⟨rfl, rfl⟩ | hf' := eq_or_len_le_of_P_δ hf
· simpa using factor_δ_σ i k
· simp at hf'
| succ n hn =>
cases hf with
| of _ h => cases h; exact factor_δ_σ _ _
| id n => exact ⟨_, _, _, P_σ.σ i, P_δ.id_mem _, by simp⟩
| comp_of f g hf hg =>
obtain ⟨k⟩ := hg
obtain ⟨rfl, rfl⟩ | h' := eq_or_len_le_of_P_δ hf
· simpa using factor_δ_σ i k
· obtain h'' | ⟨j, j', h''⟩ := switch_δ_σ i k
· exact ⟨_, _, _, P_σ.id_mem _, hf, by simp [h'']⟩
· obtain ⟨z, e, m, he, hm, fac⟩ := hn j f hf
exact ⟨z, e, m ≫ δ j', he, P_δ.comp_mem _ _ hm (P_δ.δ j'),
by simp [h'', reassoc_of% fac]⟩
/-- Any morphism in `SimplexCategoryGenRel` can be decomposed as a `P_σ` followed by a `P_δ`. -/
theorem exists_P_σ_P_δ_factorization {x y : SimplexCategoryGenRel} (f : x ⟶ y) :
∃ (z : SimplexCategoryGenRel) (e : x ⟶ z) (m : z ⟶ y)
(_ : P_σ e) (_ : P_δ m), f = e ≫ m := by
induction f with
| @id n => use (mk n), (𝟙 (mk n)), (𝟙 (mk n)), P_σ.id_mem _, P_δ.id_mem _; simp
| @comp_δ n n' f j h =>
obtain ⟨z, e, m, ⟨he, hm, rfl⟩⟩ := h
exact ⟨z, e, m ≫ δ j, he, P_δ.comp_mem _ _ hm (P_δ.δ _), by simp⟩
| @comp_σ n n' f j h =>
obtain ⟨z, e, m, ⟨he, hm, rfl⟩⟩ := h
cases hm with
| of g hg =>
rcases hg with ⟨i⟩
obtain ⟨_, _, _, ⟨he₁, hm₁, h₁⟩⟩ := factor_δ_σ j i
exact ⟨_, _, _, P_σ.comp_mem _ _ he he₁, hm₁,
by simp [← h₁]⟩
| @id n =>
exact ⟨mk n', e ≫ σ j, 𝟙 _, P_σ.comp_mem _ _ he (P_σ.σ _), P_δ.id_mem _, by simp⟩
| comp_of f g hf hg =>
cases n' with
| zero =>
cases hg
exact ⟨_, _, _, he, hf, by simp [switch_δ_σ₀]⟩
| succ n =>
rcases hg with ⟨i⟩
obtain h' | ⟨j', j'', h'⟩ := switch_δ_σ j i
· exact ⟨_, _, _, he, hf, by simp [h']⟩
· obtain ⟨_, _, m₁, ⟨he₁, hm₁, h₁⟩⟩ := factor_P_δ_σ j' f hf
exact ⟨_, _, m₁ ≫ δ j'', P_σ.comp_mem _ _ he he₁, P_δ.comp_mem _ _ hm₁ (P_δ.δ _),
by simp [← reassoc_of% h₁, h']⟩
instance : MorphismProperty.HasFactorization P_σ P_δ where
nonempty_mapFactorizationData f := by
obtain ⟨z, e, m, he, hm, fac⟩ := exists_P_σ_P_δ_factorization f
exact ⟨⟨z, e, m, fac.symm, he, hm⟩⟩
end ExistenceOfFactorizations
end SimplexCategoryGenRel |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplexCategory/GeneratorsRelations/Basic.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Basic
import Mathlib.CategoryTheory.PathCategory.Basic
/-! # Presentation of the simplex category by generators and relations.
We introduce `SimplexCategoryGenRel` as the category presented by generating
morphisms `δ i : [n] ⟶ [n + 1]` and `σ i : [n + 1] ⟶ [n]` and subject to the
simplicial identities, and we provide induction principles for reasoning about
objects and morphisms in this category.
This category admits a canonical functor `toSimplexCategory` to the usual simplex category.
The fact that this functor is an equivalence will be recorded in a separate file.
-/
open CategoryTheory
/-- The objects of the free simplex quiver are the natural numbers. -/
def FreeSimplexQuiver := ℕ
/-- Making an object of `FreeSimplexQuiver` out of a natural number. -/
def FreeSimplexQuiver.mk (n : ℕ) : FreeSimplexQuiver := n
/-- Getting back the natural number from the objects. -/
def FreeSimplexQuiver.len (x : FreeSimplexQuiver) : ℕ := x
namespace FreeSimplexQuiver
/-- A morphism in `FreeSimplexQuiver` is either a face map (`δ`) or a degeneracy map (`σ`). -/
inductive Hom : FreeSimplexQuiver → FreeSimplexQuiver → Type
| δ {n : ℕ} (i : Fin (n + 2)) : Hom (.mk n) (.mk (n + 1))
| σ {n : ℕ} (i : Fin (n + 1)) : Hom (.mk (n + 1)) (.mk n)
instance quiv : Quiver FreeSimplexQuiver where
Hom := FreeSimplexQuiver.Hom
/-- `FreeSimplexQuiver.δ i` represents the `i`-th face map `.mk n ⟶ .mk (n + 1)`. -/
abbrev δ {n : ℕ} (i : Fin (n + 2)) : FreeSimplexQuiver.mk n ⟶ .mk (n + 1) :=
FreeSimplexQuiver.Hom.δ i
/-- `FreeSimplexQuiver.σ i` represents `i`-th degeneracy map `.mk (n + 1) ⟶ .mk n`. -/
abbrev σ {n : ℕ} (i : Fin (n + 1)) : FreeSimplexQuiver.mk (n + 1) ⟶ .mk n :=
FreeSimplexQuiver.Hom.σ i
/-- `FreeSimplexQuiver.homRel` is the relation on morphisms freely generated on the
five simplicial identities. -/
inductive homRel : HomRel (Paths FreeSimplexQuiver)
| δ_comp_δ {n : ℕ} {i j : Fin (n + 2)} (H : i ≤ j) : homRel
((Paths.of FreeSimplexQuiver).map (δ i) ≫ (Paths.of FreeSimplexQuiver).map (δ j.succ))
((Paths.of FreeSimplexQuiver).map (δ j) ≫ (Paths.of FreeSimplexQuiver).map (δ i.castSucc))
| δ_comp_σ_of_le {n : ℕ} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ j.castSucc) : homRel
((Paths.of FreeSimplexQuiver).map (δ i.castSucc) ≫ (Paths.of FreeSimplexQuiver).map (σ j.succ))
((Paths.of FreeSimplexQuiver).map (σ j) ≫ (Paths.of FreeSimplexQuiver).map (δ i))
| δ_comp_σ_self {n : ℕ} {i : Fin (n + 1)} : homRel
((Paths.of FreeSimplexQuiver).map (δ i.castSucc) ≫ (Paths.of FreeSimplexQuiver).map (σ i)) (𝟙 _)
| δ_comp_σ_succ {n : ℕ} {i : Fin (n + 1)} : homRel
((Paths.of FreeSimplexQuiver).map (δ i.succ) ≫ (Paths.of FreeSimplexQuiver).map (σ i)) (𝟙 _)
| δ_comp_σ_of_gt {n : ℕ} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : j.castSucc < i) : homRel
((Paths.of FreeSimplexQuiver).map (δ i.succ) ≫ (Paths.of FreeSimplexQuiver).map (σ j.castSucc))
((Paths.of FreeSimplexQuiver).map (σ j) ≫ (Paths.of FreeSimplexQuiver).map (δ i))
| σ_comp_σ {n : ℕ} {i j : Fin (n + 1)} (H : i ≤ j) : homRel
((Paths.of FreeSimplexQuiver).map (σ i.castSucc) ≫ (Paths.of FreeSimplexQuiver).map (σ j))
((Paths.of FreeSimplexQuiver).map (σ j.succ) ≫ (Paths.of FreeSimplexQuiver).map (σ i))
end FreeSimplexQuiver
/-- SimplexCategory is the category presented by generators and relation by the simplicial
identities. -/
def SimplexCategoryGenRel := Quotient FreeSimplexQuiver.homRel
deriving Category
/-- `SimplexCategoryGenRel.mk` is the main constructor for objects of `SimplexCategoryGenRel`. -/
def SimplexCategoryGenRel.mk (n : ℕ) : SimplexCategoryGenRel where
as := (Paths.of FreeSimplexQuiver).obj n
namespace SimplexCategoryGenRel
/-- `SimplexCategoryGenRel.δ i` is the `i`-th face map `.mk n ⟶ .mk (n + 1)`. -/
abbrev δ {n : ℕ} (i : Fin (n + 2)) : mk n ⟶ mk (n + 1) :=
(Quotient.functor FreeSimplexQuiver.homRel).map <| (Paths.of FreeSimplexQuiver).map (.δ i)
/-- `SimplexCategoryGenRel.σ i` is the `i`-th degeneracy map `.mk (n + 1) ⟶ .mk n`. -/
abbrev σ {n : ℕ} (i : Fin (n + 1)) : mk (n + 1) ⟶ mk n :=
(Quotient.functor FreeSimplexQuiver.homRel).map <| (Paths.of FreeSimplexQuiver).map (.σ i)
/-- The length of an object of `SimplexCategoryGenRel`. -/
def len (x : SimplexCategoryGenRel) : ℕ := by rcases x with ⟨n⟩; exact n
@[simp]
lemma mk_len (n : ℕ) : len (mk n) = n := rfl
section InductionPrinciples
/-- A morphism is called a face if it is a `δ i` for some `i : Fin (n + 2)`. -/
inductive faces : MorphismProperty SimplexCategoryGenRel
| δ {n : ℕ} (i : Fin (n + 2)) : faces (δ i)
/-- A morphism is called a degeneracy if it is a `σ i` for some `i : Fin (n + 1)`. -/
inductive degeneracies : MorphismProperty SimplexCategoryGenRel
| σ {n : ℕ} (i : Fin (n + 1)) : degeneracies (σ i)
/-- A morphism is a generator if it is either a face or a degeneracy. -/
abbrev generators := faces ⊔ degeneracies
namespace generators
lemma δ {n : ℕ} (i : Fin (n + 2)) : generators (δ i) := le_sup_left (a := faces) _ (.δ i)
lemma σ {n : ℕ} (i : Fin (n + 1)) : generators (σ i) := le_sup_right (a := faces) _ (.σ i)
end generators
/-- A property is true for every morphism iff it holds for generators and is multiplicative. -/
lemma multiplicativeClosure_isGenerator_eq_top : generators.multiplicativeClosure = ⊤ := by
apply le_antisymm (by simp)
intro x y f _
apply CategoryTheory.Quotient.induction
apply Paths.induction
· exact generators.multiplicativeClosure.id_mem _
· rintro _ _ _ _ ⟨⟩ h
· exact generators.multiplicativeClosure.comp_mem _ _ h <| .of _ <| .δ _
· exact generators.multiplicativeClosure.comp_mem _ _ h <| .of _ <| .σ _
/-- An unrolled version of the induction principle obtained in the previous lemma. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
lemma hom_induction (P : MorphismProperty SimplexCategoryGenRel)
(id : ∀ {n : ℕ}, P (𝟙 (mk n)))
(comp_δ : ∀ {n m : ℕ} (u : mk n ⟶ mk m) (i : Fin (m + 2)), P u → P (u ≫ δ i))
(comp_σ : ∀ {n m : ℕ} (u : mk n ⟶ mk (m + 1)) (i : Fin (m + 1)), P u → P (u ≫ σ i))
{a b : SimplexCategoryGenRel} (f : a ⟶ b) :
P f :=
by
suffices generators.multiplicativeClosure ≤ P by
rw [multiplicativeClosure_isGenerator_eq_top, top_le_iff] at this
rw [this]
apply MorphismProperty.top_apply
intro _ _ f hf
induction hf with
| of f h =>
rcases h with ⟨⟨i⟩⟩ | ⟨⟨i⟩⟩
· simpa using (comp_δ (𝟙 _) i id)
· simpa using (comp_σ (𝟙 _) i id)
| id n => exact id
| comp_of f g hf hg hrec =>
rcases hg with ⟨⟨i⟩⟩ | ⟨⟨i⟩⟩
· simpa using (comp_δ f i hrec)
· simpa using (comp_σ f i hrec)
/-- An induction principle for reasoning about morphisms in SimplexCategoryGenRel, where we compose
with generators on the right. -/
lemma hom_induction' (P : MorphismProperty SimplexCategoryGenRel)
(id : ∀ {n : ℕ}, P (𝟙 (mk n)))
(δ_comp : ∀ {n m : ℕ} (u : mk (m + 1) ⟶ mk n)
(i : Fin (m + 2)), P u → P (δ i ≫ u))
(σ_comp : ∀ {n m : ℕ} (u : mk m ⟶ mk n)
(i : Fin (m + 1)), P u → P (σ i ≫ u)) {a b : SimplexCategoryGenRel} (f : a ⟶ b) :
P f := by
suffices generators.multiplicativeClosure' ≤ P by
rw [← MorphismProperty.multiplicativeClosure_eq_multiplicativeClosure',
multiplicativeClosure_isGenerator_eq_top, top_le_iff] at this
rw [this]
apply MorphismProperty.top_apply
intro _ _ f hf
induction hf with
| of f h =>
rcases h with ⟨⟨i⟩⟩ | ⟨⟨i⟩⟩
· simpa using (δ_comp (𝟙 _) i id)
· simpa using (σ_comp (𝟙 _) i id)
| id n => exact id
| of_comp f g hf hg hrec =>
rcases hf with ⟨⟨i⟩⟩ | ⟨⟨i⟩⟩
· simpa using (δ_comp g i hrec)
· simpa using (σ_comp g i hrec)
/-- An induction principle for reasoning about objects in `SimplexCategoryGenRel`. This should be
used instead of identifying an object with `mk` of its `len`. -/
@[elab_as_elim, cases_eliminator]
protected def rec {P : SimplexCategoryGenRel → Sort*}
(H : ∀ n : ℕ, P (.mk n)) :
∀ x : SimplexCategoryGenRel, P x := by
intro x
exact H x.len
/-- A basic `ext` lemma for objects of `SimplexCategoryGenRel`. -/
@[ext]
lemma ext {x y : SimplexCategoryGenRel} (h : x.len = y.len) : x = y := by
cases x
cases y
simp only [mk_len] at h
congr
end InductionPrinciples
section SimplicialIdentities
@[reassoc]
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) :
δ i ≫ δ j.succ = δ j ≫ δ i.castSucc := by
apply CategoryTheory.Quotient.sound
exact FreeSimplexQuiver.homRel.δ_comp_δ H
@[reassoc]
theorem δ_comp_σ_of_le {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ j.castSucc) :
δ i.castSucc ≫ σ j.succ = σ j ≫ δ i := by
apply CategoryTheory.Quotient.sound
exact FreeSimplexQuiver.homRel.δ_comp_σ_of_le H
@[reassoc]
theorem δ_comp_σ_self {n} {i : Fin (n + 1)} :
δ i.castSucc ≫ σ i = 𝟙 (mk n) := by
apply CategoryTheory.Quotient.sound
exact FreeSimplexQuiver.homRel.δ_comp_σ_self
@[reassoc]
theorem δ_comp_σ_succ {n} {i : Fin (n + 1)} : δ i.succ ≫ σ i = 𝟙 (mk n) := by
apply CategoryTheory.Quotient.sound
exact FreeSimplexQuiver.homRel.δ_comp_σ_succ
@[reassoc]
theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : j.castSucc < i) :
δ i.succ ≫ σ j.castSucc = σ j ≫ δ i := by
apply CategoryTheory.Quotient.sound
exact FreeSimplexQuiver.homRel.δ_comp_σ_of_gt H
@[reassoc]
theorem σ_comp_σ {n} {i j : Fin (n + 1)} (H : i ≤ j) :
σ i.castSucc ≫ σ j = σ j.succ ≫ σ i := by
apply CategoryTheory.Quotient.sound
exact FreeSimplexQuiver.homRel.σ_comp_σ H
/-- A version of δ_comp_δ with indices in ℕ satisfying relevant inequalities. -/
lemma δ_comp_δ_nat {n} (i j : ℕ) (hi : i < n + 2) (hj : j < n + 2) (H : i ≤ j) :
δ ⟨i, hi⟩ ≫ δ ⟨j + 1, by cutsat⟩ = δ ⟨j, hj⟩ ≫ δ ⟨i, by cutsat⟩ :=
δ_comp_δ (n := n) (i := ⟨i, by cutsat⟩) (j := ⟨j, by cutsat⟩) (by simpa)
/-- A version of σ_comp_σ with indices in ℕ satisfying relevant inequalities. -/
lemma σ_comp_σ_nat {n} (i j : ℕ) (hi : i < n + 1) (hj : j < n + 1) (H : i ≤ j) :
σ ⟨i, by cutsat⟩ ≫ σ ⟨j, hj⟩ = σ ⟨j + 1, by cutsat⟩ ≫ σ ⟨i, hi⟩ :=
σ_comp_σ (n := n) (i := ⟨i, by cutsat⟩) (j := ⟨j, by cutsat⟩) (by simpa)
end SimplicialIdentities
/-- The canonical functor from `SimplexCategoryGenRel` to SimplexCategory, which exists as the
simplicial identities hold in `SimplexCategory`. -/
def toSimplexCategory : SimplexCategoryGenRel ⥤ SimplexCategory :=
CategoryTheory.Quotient.lift _
(Paths.lift
{ obj := .mk
map f := match f with
| FreeSimplexQuiver.Hom.δ i => SimplexCategory.δ i
| FreeSimplexQuiver.Hom.σ i => SimplexCategory.σ i })
(fun _ _ _ _ h ↦ match h with
| .δ_comp_δ H => SimplexCategory.δ_comp_δ H
| .δ_comp_σ_of_le H => SimplexCategory.δ_comp_σ_of_le H
| .δ_comp_σ_self => SimplexCategory.δ_comp_σ_self
| .δ_comp_σ_succ => SimplexCategory.δ_comp_σ_succ
| .δ_comp_σ_of_gt H => SimplexCategory.δ_comp_σ_of_gt H
| .σ_comp_σ H => SimplexCategory.σ_comp_σ H)
@[simp]
lemma toSimplexCategory_obj_mk (n : ℕ) : toSimplexCategory.obj (mk n) = .mk n := rfl
@[simp]
lemma toSimplexCategory_map_δ {n : ℕ} (i : Fin (n + 2)) :
toSimplexCategory.map (δ i) = SimplexCategory.δ i := rfl
@[simp]
lemma toSimplexCategory_map_σ {n : ℕ} (i : Fin (n + 1)) :
toSimplexCategory.map (σ i) = SimplexCategory.σ i := rfl
@[simp]
lemma toSimplexCategory_len {x : SimplexCategoryGenRel} : (toSimplexCategory.obj x).len = x.len :=
rfl
end SimplexCategoryGenRel |
.lake/packages/mathlib/Mathlib/Testing/Plausible/Functions.lean | import Mathlib.Data.Finsupp.ToDFinsupp
import Mathlib.Algebra.Order.Group.Nat
import Mathlib.Data.Int.Range
import Mathlib.Data.List.Sigma
import Plausible.Functions
/-!
## `Plausible`: generators for functions
This file defines `Sampleable` instances for `ℤ → ℤ` injective functions.
Injective functions are generated by creating a list of numbers and
a permutation of that list. The permutation insures that every input
is mapped to a unique output. When an input is not found in the list
the input itself is used as an output.
Injective functions `f : α → α` could be generated easily instead of
`ℤ → ℤ` by generating a `List α`, removing duplicates and creating a
permutation. One has to be careful when generating the domain to make
it vast enough that, when generating arguments to apply `f` to,
they argument should be likely to lie in the domain of `f`. This is
the reason that injective functions `f : ℤ → ℤ` are generated by
fixing the domain to the range `[-2*size .. 2*size]`, with `size`
the size parameter of the `gen` monad.
Much of the machinery provided in this file is applicable to generate
injective functions of type `α → α` and new instances should be easy
to define.
Other classes of functions such as monotone functions can generated using
similar techniques. For monotone functions, generating two lists, sorting them
and matching them should suffice, with appropriate default values.
Some care must be taken for shrinking such functions to make sure
their defining property is invariant through shrinking. Injective
functions are an example of how complicated it can get.
-/
universe u v
variable {α : Type u} {β : Type v}
namespace Plausible
namespace TotalFunction
section Finsupp
variable [DecidableEq α]
/--
This theorem exists because plausible does not have access to dlookup but
mathlib has all the theory for it and wants to use it. We probably want to
bring these two together at some point.
-/
private theorem apply_eq_dlookup (m : List (Σ _ : α, β)) (y : β) (x : α) :
(withDefault m y).apply x = (m.dlookup x).getD y := by
dsimp only [apply]
congr 1
induction m with
| nil => simp
| cons p m ih =>
rcases p with ⟨fst, snd⟩
by_cases heq : fst = x
· simp [heq]
· rw [List.dlookup_cons_ne]
· simp [heq, ih]
· symm
simp [heq]
variable [Zero β] [DecidableEq β]
/-- Map a total_function to one whose default value is zero so that it represents a finsupp. -/
@[simp]
def zeroDefault : TotalFunction α β → TotalFunction α β
| .withDefault A _ => .withDefault A 0
/-- The support of a zero default `TotalFunction`. -/
@[simp]
def zeroDefaultSupp : TotalFunction α β → Finset α
| .withDefault A _ =>
List.toFinset <| (A.dedupKeys.filter fun ab => Sigma.snd ab ≠ 0).map Sigma.fst
/-- Create a finitely supported function from a total function by taking the default value to
zero. -/
def applyFinsupp (tf : TotalFunction α β) : α →₀ β where
support := zeroDefaultSupp tf
toFun := tf.zeroDefault.apply
mem_support_toFun := by
intro a
rcases tf with ⟨A, y⟩
simp only [zeroDefaultSupp, List.mem_map, List.mem_filter, exists_and_right,
List.mem_toFinset, exists_eq_right, Sigma.exists, Ne, zeroDefault]
rw [apply_eq_dlookup]
constructor
· rintro ⟨od, hval, hod⟩
have := List.mem_dlookup (List.nodupKeys_dedupKeys A) hval
rw [(_ : List.dlookup a A = od)]
· simpa using hod
· simpa [List.dlookup_dedupKeys]
· intro h
use (A.dlookup a).getD (0 : β)
rw [← List.dlookup_dedupKeys] at h ⊢
simp only [h, ← List.mem_dlookup_iff A.nodupKeys_dedupKeys, not_false_iff, Option.mem_def]
cases haA : List.dlookup a A.dedupKeys
· simp [haA] at h
· simp
variable [SampleableExt α] [SampleableExt β] [Repr α]
instance Finsupp.sampleableExt : SampleableExt (α →₀ β) where
proxy := TotalFunction α (SampleableExt.proxy β)
interp := fun f => (f.comp SampleableExt.interp).applyFinsupp
sample := SampleableExt.sample (α := α → β)
-- note: no way of shrinking the domain without an inverse to `interp`
shrink := { shrink := letI : Shrinkable α := {}; TotalFunction.shrink }
-- TODO: support a non-constant codomain type
instance DFinsupp.sampleableExt : SampleableExt (Π₀ _ : α, β) where
proxy := TotalFunction α (SampleableExt.proxy β)
interp := fun f => (f.comp SampleableExt.interp).applyFinsupp.toDFinsupp
sample := SampleableExt.sample (α := α → β)
-- note: no way of shrinking the domain without an inverse to `interp`
shrink := { shrink := letI : Shrinkable α := {}; TotalFunction.shrink }
end Finsupp
end TotalFunction
open _root_.List
/-- Data structure specifying a total function using a list of pairs
and a default value returned when the input is not in the domain of
the partial function.
`mapToSelf f` encodes `x ↦ f x` when `x ∈ f` and `x ↦ x`,
i.e. `x` to itself, otherwise.
We use `Σ` to encode mappings instead of `×` because we
rely on the association list API defined in `Mathlib/Data/List/Sigma.lean`.
-/
inductive InjectiveFunction (α : Type u) : Type u
| mapToSelf (xs : List (Σ _ : α, α)) :
xs.map Sigma.fst ~ xs.map Sigma.snd → List.Nodup (xs.map Sigma.snd) → InjectiveFunction α
instance : Inhabited (InjectiveFunction α) :=
⟨⟨[], List.Perm.nil, List.nodup_nil⟩⟩
namespace InjectiveFunction
/-- Apply a total function to an argument. -/
def apply [DecidableEq α] : InjectiveFunction α → α → α
| InjectiveFunction.mapToSelf m _ _, x => (m.dlookup x).getD x
/-- Produce a string for a given `InjectiveFunction`.
The output is of the form `[x₀ ↦ f x₀, .. xₙ ↦ f xₙ, x ↦ x]`.
Unlike for `TotalFunction`, the default value is not a constant
but the identity function.
-/
protected def repr [Repr α] : InjectiveFunction α → String
| InjectiveFunction.mapToSelf m _ _ => s! "[{TotalFunction.reprAux m}x ↦ x]"
instance (α : Type u) [Repr α] : Repr (InjectiveFunction α) where
reprPrec f _p := InjectiveFunction.repr f
/-- Interpret a list of pairs as a total function, defaulting to
the identity function when no entries are found for a given function -/
def List.applyId [DecidableEq α] (xs : List (α × α)) (x : α) : α :=
((xs.map Prod.toSigma).dlookup x).getD x
@[simp]
theorem List.applyId_cons [DecidableEq α] (xs : List (α × α)) (x y z : α) :
List.applyId ((y, z)::xs) x = if y = x then z else List.applyId xs x := by
simp only [List.applyId, List.dlookup, eq_rec_constant, Prod.toSigma, List.map]
split_ifs <;> rfl
open Function
open List
open Nat
theorem List.applyId_zip_eq [DecidableEq α] {xs ys : List α} (h₀ : List.Nodup xs)
(h₁ : xs.length = ys.length) (x y : α) (i : ℕ) (h₂ : xs[i]? = some x) :
List.applyId.{u} (xs.zip ys) x = y ↔ ys[i]? = some y := by
induction xs generalizing ys i with
| nil => cases h₂
| cons x' xs xs_ih =>
cases i
· simp only [length_cons, lt_add_iff_pos_left, add_pos_iff, Nat.lt_add_one, or_true,
getElem?_eq_getElem, getElem_cons_zero, Option.some.injEq] at h₂
subst h₂
cases ys
· cases h₁
· simp
· cases ys
· cases h₁
· obtain - | ⟨h₀, h₁⟩ := h₀
simp only [getElem?_cons_succ, zip_cons_cons, applyId_cons] at h₂ ⊢
rw [if_neg]
· apply xs_ih <;> solve_by_elim [Nat.succ.inj]
· apply h₀; apply List.mem_of_getElem? h₂
theorem applyId_mem_iff [DecidableEq α] {xs ys : List α} (h₀ : List.Nodup xs) (h₁ : xs ~ ys)
(x : α) : List.applyId.{u} (xs.zip ys) x ∈ ys ↔ x ∈ xs := by
simp only [List.applyId]
cases h₃ : List.dlookup x (List.map Prod.toSigma (xs.zip ys)) with
| none =>
dsimp [Option.getD]
rw [h₁.mem_iff]
| some val =>
have h₂ : ys.Nodup := h₁.nodup_iff.1 h₀
replace h₁ : xs.length = ys.length := h₁.length_eq
dsimp
induction xs generalizing ys with
| nil => contradiction
| cons x' xs xs_ih =>
rcases ys with - | ⟨y, ys⟩
· cases h₃
dsimp [List.dlookup] at h₃; split_ifs at h₃ with h
· rw [Option.some_inj] at h₃
subst x'; subst val
simp only [List.mem_cons, true_or]
· obtain - | ⟨h₀, h₅⟩ := h₀
obtain - | ⟨h₂, h₄⟩ := h₂
have h₆ := Nat.succ.inj h₁
specialize xs_ih h₅ h₃ h₄ h₆
simp only [Ne.symm h, xs_ih, List.mem_cons]
suffices val ∈ ys by tauto
rw [← Option.mem_def, List.mem_dlookup_iff] at h₃
· simp only [Prod.toSigma, List.mem_map, Prod.exists] at h₃
rcases h₃ with ⟨a, b, h₃, h₄, h₅⟩
apply (List.of_mem_zip h₃).2
simp only [List.NodupKeys, List.keys, comp_def, Prod.fst_toSigma, List.map_map]
rwa [List.map_fst_zip (le_of_eq h₆)]
theorem List.applyId_eq_self [DecidableEq α] {xs ys : List α} (x : α) :
x ∉ xs → List.applyId.{u} (xs.zip ys) x = x := by
intro h
dsimp [List.applyId]
rw [List.dlookup_eq_none.2]
· rfl
simp only [List.keys, not_exists, Prod.toSigma, exists_and_right, exists_eq_right, List.mem_map,
Function.comp_apply, List.map_map, Prod.exists]
intro y hy
exact h (List.of_mem_zip hy).1
theorem applyId_injective [DecidableEq α] {xs ys : List α} (h₀ : List.Nodup xs) (h₁ : xs ~ ys) :
Injective.{u + 1, u + 1} (List.applyId (xs.zip ys)) := by
intro x y h
by_cases hx : x ∈ xs <;> by_cases hy : y ∈ xs
· rw [List.mem_iff_getElem?] at hx hy
obtain ⟨i, hx⟩ := hx
obtain ⟨j, hy⟩ := hy
suffices some x = some y by injection this
have h₂ := h₁.length_eq
rw [List.applyId_zip_eq h₀ h₂ _ _ _ hx] at h
rw [← hx, ← hy]; congr
apply List.getElem?_inj _ (h₁.nodup_iff.1 h₀)
· symm; rw [h]
rw [← List.applyId_zip_eq] <;> assumption
· rw [← h₁.length_eq]
rw [List.getElem?_eq_some_iff] at hx
obtain ⟨hx, hx'⟩ := hx
exact hx
· rw [← applyId_mem_iff h₀ h₁] at hx hy
rw [h] at hx
contradiction
· rw [← applyId_mem_iff h₀ h₁] at hx hy
rw [h] at hx
contradiction
· rwa [List.applyId_eq_self, List.applyId_eq_self] at h <;> assumption
open TotalFunction (List.toFinmap')
open SampleableExt
/-- Remove a slice of length `m` at index `n` in a list and a permutation, maintaining the property
that it is a permutation.
-/
def Perm.slice [DecidableEq α] (n m : ℕ) :
(Σ' xs ys : List α, xs ~ ys ∧ ys.Nodup) → Σ' xs ys : List α, xs ~ ys ∧ ys.Nodup
| ⟨xs, ys, h, h'⟩ =>
let xs' := List.dropSlice n m xs
have h₀ : xs' ~ ys.inter xs' := List.Perm.dropSlice_inter _ _ h h'
⟨xs', ys.inter xs', h₀, h'.inter _⟩
/-- A list, in decreasing order, of sizes that should be
sliced off a list of length `n`
-/
def sliceSizes : ℕ → MLList Id ℕ+
| n =>
if h : 0 < n then
have : n / 2 < n := Nat.div_lt_self h (by decide : 1 < 2)
.cons ⟨_, h⟩ (sliceSizes <| n / 2)
else .nil
/-- Shrink a permutation of a list, slicing a segment in the middle.
The sizes of the slice being removed start at `n` (with `n` the length
of the list) and then `n / 2`, then `n / 4`, etc. down to 1. The slices
will be taken at index `0`, `n / k`, `2n / k`, `3n / k`, etc.
-/
protected def shrinkPerm {α : Type} [DecidableEq α] :
(Σ' xs ys : List α, xs ~ ys ∧ ys.Nodup) → List (Σ' xs ys : List α, xs ~ ys ∧ ys.Nodup)
| xs => do
let k := xs.1.length
let n ← (sliceSizes k).force
let i ← List.finRange <| k / n
pure <| Perm.slice (i * n) n xs
/-- Shrink an injective function slicing a segment in the middle of the domain and removing
the corresponding elements in the codomain, hence maintaining the property that
one is a permutation of the other.
-/
protected def shrink {α : Type} [DecidableEq α] :
InjectiveFunction α → List (InjectiveFunction α)
| ⟨_, h₀, h₁⟩ => do
let ⟨xs', ys', h₀, h₁⟩ ← InjectiveFunction.shrinkPerm ⟨_, _, h₀, h₁⟩
have h₃ : xs'.length ≤ ys'.length := le_of_eq (List.Perm.length_eq h₀)
have h₄ : ys'.length ≤ xs'.length := le_of_eq (List.Perm.length_eq h₀.symm)
pure
⟨(List.zip xs' ys').map Prod.toSigma,
by simp only [comp_def, List.map_fst_zip, List.map_snd_zip, *, Prod.fst_toSigma,
Prod.snd_toSigma, List.map_map],
by simp only [comp_def, List.map_snd_zip, *, Prod.snd_toSigma, List.map_map]⟩
/-- Create an injective function from one list and a permutation of that list. -/
protected def mk (xs ys : List α) (h : xs ~ ys) (h' : ys.Nodup) : InjectiveFunction α :=
have h₀ : xs.length ≤ ys.length := le_of_eq h.length_eq
have h₁ : ys.length ≤ xs.length := le_of_eq h.length_eq.symm
InjectiveFunction.mapToSelf (List.toFinmap' (xs.zip ys))
(by
simp only [List.toFinmap', comp_def, List.map_fst_zip, List.map_snd_zip, *,
List.map_map])
(by simp only [List.toFinmap', comp_def, List.map_snd_zip, *, List.map_map])
protected theorem injective [DecidableEq α] (f : InjectiveFunction α) : Injective (apply f) := by
obtain ⟨xs, hperm, hnodup⟩ := f
generalize h₀ : List.map Sigma.fst xs = xs₀
generalize h₁ : xs.map (@id ((Σ _ : α, α) → α) <| @Sigma.snd α fun _ : α => α) = xs₁
dsimp [id] at h₁
have hxs : xs = TotalFunction.List.toFinmap' (xs₀.zip xs₁) := by
rw [← h₀, ← h₁, List.toFinmap']; clear h₀ h₁ xs₀ xs₁ hperm hnodup
induction xs with
| nil => simp only [List.zip_nil_right, List.map_nil]
| cons xs_hd xs_tl xs_ih =>
simp only [Sigma.eta, List.zip_cons_cons,
List.map, List.cons_inj_right]
exact xs_ih
revert hperm hnodup
rw [hxs]; intro hperm hnodup
apply InjectiveFunction.applyId_injective
· rwa [← h₀, hxs, hperm.nodup_iff]
· rwa [← hxs, h₀, h₁] at hperm
instance : Arbitrary (InjectiveFunction ℤ) where
arbitrary := do
let ⟨sz⟩ ← Gen.up Gen.getSize
let xs' := Int.range (-(2 * sz + 2)) (2 * sz + 2)
let ys ← Gen.permutationOf xs'
have Hinj : Injective fun r : ℕ => -(2 * sz + 2 : ℤ) + ↑r := fun _x _y h =>
Int.ofNat.inj (add_right_injective _ h)
let r : InjectiveFunction ℤ :=
InjectiveFunction.mk.{0} xs' ys.1 ys.2 (ys.2.nodup_iff.1 <| List.nodup_range.map Hinj)
pure r
instance PiInjective.sampleableExt : SampleableExt { f : ℤ → ℤ // Function.Injective f } where
proxy := InjectiveFunction ℤ
interp f := ⟨apply f, f.injective⟩
shrink := {shrink := @InjectiveFunction.shrink ℤ _ }
end InjectiveFunction
open Function
instance Injective.testable (f : α → β)
[I : Testable (NamedBinder "x" <|
∀ x : α, NamedBinder "y" <| ∀ y : α, NamedBinder "H" <| f x = f y → x = y)] :
Testable (Injective f) :=
I
instance Monotone.testable [Preorder α] [Preorder β] (f : α → β)
[I : Testable (NamedBinder "x" <|
∀ x : α, NamedBinder "y" <| ∀ y : α, NamedBinder "H" <| x ≤ y → f x ≤ f y)] :
Testable (Monotone f) :=
I
instance Antitone.testable [Preorder α] [Preorder β] (f : α → β)
[I : Testable (NamedBinder "x" <|
∀ x : α, NamedBinder "y" <| ∀ y : α, NamedBinder "H" <| x ≤ y → f y ≤ f x)] :
Testable (Antitone f) :=
I
end Plausible |
.lake/packages/mathlib/Mathlib/Testing/Plausible/Testable.lean | import Plausible.Testable
import Mathlib.Logic.Basic
/-!
This module contains `Plausible.Testable` and `Plausible.PrintableProb` instances for mathlib types.
-/
namespace Plausible
namespace Testable
open TestResult
instance factTestable {p : Prop} [Testable p] : Testable (Fact p) where
run cfg min := do
let h ← runProp p cfg min
pure <| iff fact_iff h
end Testable
section PrintableProp
instance Fact.printableProp {p : Prop} [PrintableProp p] : PrintableProp (Fact p) where
printProp := printProp p
end PrintableProp
end Plausible |
.lake/packages/mathlib/Mathlib/Testing/Plausible/Sampleable.lean | import Mathlib.Data.Int.Order.Basic
import Mathlib.Data.List.Monad
import Mathlib.Data.PNat.Defs
import Plausible.Sampleable
/-!
This module contains `Plausible.Shrinkable` and `Plausible.SampleableExt` instances for mathlib
types.
-/
namespace Plausible
open Random Gen
section Shrinkers
instance Rat.shrinkable : Shrinkable Rat where
shrink r :=
(Shrinkable.shrink r.num).flatMap fun d => Nat.shrink r.den |>.map fun n => Rat.divInt d n
instance PNat.shrinkable : Shrinkable PNat where
shrink m := Nat.shrink m.natPred |>.map Nat.succPNat
end Shrinkers
section Samplers
open SampleableExt
instance Rat.Arbitrary : Arbitrary Rat where
arbitrary := do
let d ← choose Int (-(← getSize)) (← getSize)
(le_trans (Int.neg_nonpos_of_nonneg (Int.ofNat_zero_le _)) (Int.ofNat_zero_le _))
let n ← choose Nat 0 (← getSize) (Nat.zero_le _)
return Rat.divInt d n
instance Rat.sampleableExt : SampleableExt Rat := by infer_instance
instance PNat.Arbitrary : Arbitrary PNat where
arbitrary := do
let n ← chooseNat
return Nat.succPNat n
instance PNat.sampleableExt : SampleableExt PNat := by infer_instance
end Samplers
end Plausible |
.lake/packages/mathlib/Mathlib/Condensed/Module.lean | import Mathlib.Algebra.Category.ModuleCat.Abelian
import Mathlib.Algebra.Category.ModuleCat.Colimits
import Mathlib.Algebra.Category.ModuleCat.FilteredColimits
import Mathlib.Algebra.Category.ModuleCat.Adjunctions
import Mathlib.CategoryTheory.Sites.Abelian
import Mathlib.CategoryTheory.Sites.Adjunction
import Mathlib.CategoryTheory.Sites.LeftExact
import Mathlib.Condensed.Basic
/-!
# Condensed `R`-modules
This file defines condensed modules over a ring `R`.
## Main results
* Condensed `R`-modules form an abelian category.
* The forgetful functor from condensed `R`-modules to condensed sets has a left adjoint, sending a
condensed set to the corresponding *free* condensed `R`-module.
-/
universe u
open CategoryTheory
variable (R : Type (u + 1)) [Ring R]
/--
The category of condensed `R`-modules, defined as sheaves of `R`-modules over
`CompHaus` with respect to the coherent Grothendieck topology.
-/
abbrev CondensedMod := Condensed.{u} (ModuleCat.{u + 1} R)
noncomputable instance : Abelian (CondensedMod.{u} R) := sheafIsAbelian
/-- The forgetful functor from condensed `R`-modules to condensed sets. -/
def Condensed.forget : CondensedMod R ⥤ CondensedSet := sheafCompose _ (CategoryTheory.forget _)
/--
The left adjoint to the forgetful functor. The *free condensed `R`-module* on a condensed set.
-/
noncomputable
def Condensed.free : CondensedSet ⥤ CondensedMod R :=
Sheaf.composeAndSheafify _ (ModuleCat.free R)
/-- The condensed version of the free-forgetful adjunction. -/
noncomputable
def Condensed.freeForgetAdjunction : free R ⊣ forget R := Sheaf.adjunction _ (ModuleCat.adj R)
/--
The category of condensed abelian groups is defined as condensed `ℤ`-modules.
-/
abbrev CondensedAb := CondensedMod.{u} (ULift ℤ)
noncomputable example : Abelian CondensedAb.{u} := inferInstance
/-- The forgetful functor from condensed abelian groups to condensed sets. -/
abbrev Condensed.abForget : CondensedAb ⥤ CondensedSet := forget _
/-- The free condensed abelian group on a condensed set. -/
noncomputable abbrev Condensed.freeAb : CondensedSet ⥤ CondensedAb := free _
/-- The free-forgetful adjunction for condensed abelian groups. -/
noncomputable abbrev Condensed.setAbAdjunction : freeAb ⊣ abForget := freeForgetAdjunction _
namespace CondensedMod
lemma hom_naturality_apply {X Y : CondensedMod.{u} R} (f : X ⟶ Y) {S T : CompHausᵒᵖ} (g : S ⟶ T)
(x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) :=
NatTrans.naturality_apply f.val g x
end CondensedMod |
.lake/packages/mathlib/Mathlib/Condensed/Functors.lean | import Mathlib.CategoryTheory.Limits.Preserves.Ulift
import Mathlib.CategoryTheory.Sites.Coherent.CoherentSheaves
import Mathlib.CategoryTheory.Sites.Whiskering
import Mathlib.Condensed.Basic
import Mathlib.Topology.Category.Stonean.Basic
/-!
# Functors from categories of topological spaces to condensed sets
This file defines the embedding of the test objects (compact Hausdorff spaces) into condensed
sets.
## Main definitions
* `compHausToCondensed : CompHaus.{u} ⥤ CondensedSet.{u}` is essentially the yoneda presheaf
functor. We also define `profiniteToCondensed` and `stoneanToCondensed`.
-/
universe u v
open CategoryTheory Limits
section Universes
/-- Increase the size of the target category of condensed sets. -/
def Condensed.ulift : Condensed.{u} (Type u) ⥤ CondensedSet.{u} :=
sheafCompose (coherentTopology CompHaus) uliftFunctor.{u+1, u}
instance : Condensed.ulift.Full := show (sheafCompose _ _).Full from inferInstance
instance : Condensed.ulift.Faithful := show (sheafCompose _ _).Faithful from inferInstance
end Universes
section Topology
/-- The functor from `CompHaus` to `Condensed.{u} (Type u)` given by the Yoneda sheaf. -/
def compHausToCondensed' : CompHaus.{u} ⥤ Condensed.{u} (Type u) :=
(coherentTopology CompHaus).yoneda
/-- The yoneda presheaf as an actual condensed set. -/
def compHausToCondensed : CompHaus.{u} ⥤ CondensedSet.{u} :=
compHausToCondensed' ⋙ Condensed.ulift
/-- Dot notation for the value of `compHausToCondensed`. -/
abbrev CompHaus.toCondensed (S : CompHaus.{u}) : CondensedSet.{u} := compHausToCondensed.obj S
/-- The yoneda presheaf as a condensed set, restricted to profinite spaces. -/
def profiniteToCondensed : Profinite.{u} ⥤ CondensedSet.{u} :=
profiniteToCompHaus ⋙ compHausToCondensed
/-- Dot notation for the value of `profiniteToCondensed`. -/
abbrev Profinite.toCondensed (S : Profinite.{u}) : CondensedSet.{u} := profiniteToCondensed.obj S
/-- The yoneda presheaf as a condensed set, restricted to Stonean spaces. -/
def stoneanToCondensed : Stonean.{u} ⥤ CondensedSet.{u} :=
Stonean.toCompHaus ⋙ compHausToCondensed
/-- Dot notation for the value of `stoneanToCondensed`. -/
abbrev Stonean.toCondensed (S : Stonean.{u}) : CondensedSet.{u} := stoneanToCondensed.obj S
instance : compHausToCondensed'.Full :=
inferInstanceAs ((coherentTopology CompHaus).yoneda).Full
instance : compHausToCondensed'.Faithful :=
inferInstanceAs ((coherentTopology CompHaus).yoneda).Faithful
instance : compHausToCondensed.Full := inferInstanceAs (_ ⋙ _).Full
instance : compHausToCondensed.Faithful := inferInstanceAs (_ ⋙ _).Faithful
end Topology |
.lake/packages/mathlib/Mathlib/Condensed/Basic.lean | import Mathlib.CategoryTheory.Sites.Sheaf
import Mathlib.Topology.Category.CompHaus.EffectiveEpi
/-!
# Condensed Objects
This file defines the category of condensed objects in a category `C`, following the work
of Clausen-Scholze and Barwick-Haine.
## Implementation Details
We use the coherent Grothendieck topology on `CompHaus`, and define condensed objects in `C` to
be `C`-valued sheaves, with respect to this Grothendieck topology.
Note: Our definition more closely resembles "Pyknotic objects" in the sense of Barwick-Haine,
as we do not impose cardinality bounds, and manage universes carefully instead.
## References
- [barwickhaine2019]: *Pyknotic objects, I. Basic notions*, 2019.
- [scholze2019condensed]: *Lectures on Condensed Mathematics*, 2019.
-/
open CategoryTheory Limits
open CategoryTheory
universe u v w
/--
`Condensed.{u} C` is the category of condensed objects in a category `C`, which are
defined as sheaves on `CompHaus.{u}` with respect to the coherent Grothendieck topology.
-/
def Condensed (C : Type w) [Category.{v} C] :=
Sheaf (coherentTopology CompHaus.{u}) C
instance {C : Type w} [Category.{v} C] : Category (Condensed.{u} C) :=
show Category (Sheaf _ _) from inferInstance
/--
Condensed sets (types) with the appropriate universe levels, i.e. `Type (u+1)`-valued
sheaves on `CompHaus.{u}`.
-/
abbrev CondensedSet := Condensed.{u} (Type (u+1))
namespace Condensed
variable {C : Type w} [Category.{v} C]
@[simp]
lemma id_val (X : Condensed.{u} C) : (𝟙 X : X ⟶ X).val = 𝟙 _ := rfl
@[simp]
lemma comp_val {X Y Z : Condensed.{u} C} (f : X ⟶ Y) (g : Y ⟶ Z) : (f ≫ g).val = f.val ≫ g.val :=
rfl
@[ext]
lemma hom_ext {X Y : Condensed.{u} C} (f g : X ⟶ Y) (h : ∀ S, f.val.app S = g.val.app S) :
f = g := by
apply Sheaf.hom_ext
ext
exact h _
end Condensed
namespace CondensedSet
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
-- Note: `simp` can prove this when stated for `Condensed C` for a concrete category `C`.
-- However, it doesn't seem to see through the abbreviation `CondensedSet`
@[simp]
lemma hom_naturality_apply {X Y : CondensedSet.{u}} (f : X ⟶ Y) {S T : CompHausᵒᵖ} (g : S ⟶ T)
(x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) :=
NatTrans.naturality_apply f.val g x
end CondensedSet |
.lake/packages/mathlib/Mathlib/Condensed/TopComparison.lean | import Mathlib.CategoryTheory.Limits.Preserves.Opposites
import Mathlib.CategoryTheory.Sites.Coherent.SheafComparison
import Mathlib.Condensed.Basic
import Mathlib.Topology.Category.TopCat.Yoneda
/-!
# The functor from topological spaces to condensed sets
This file builds on the API from the file `TopCat.Yoneda`. If the forgetful functor to `TopCat` has
nice properties, like preserving pullbacks and finite coproducts, then this Yoneda presheaf
satisfies the sheaf condition for the regular and extensive topologies respectively.
We apply this API to `CompHaus` and define the functor
`topCatToCondensedSet : TopCat.{u+1} ⥤ CondensedSet.{u}`.
-/
universe w w' v u
open CategoryTheory Opposite Limits regularTopology ContinuousMap Topology
variable {C : Type u} [Category.{v} C] (G : C ⥤ TopCat.{w})
(X : Type w') [TopologicalSpace X]
/--
An auxiliary lemma to that allows us to use `IsQuotientMap.lift` in the proof of
`equalizerCondition_yonedaPresheaf`.
-/
theorem factorsThrough_of_pullbackCondition {Z B : C} {π : Z ⟶ B} [HasPullback π π]
[PreservesLimit (cospan π π) G]
{a : C(G.obj Z, X)}
(ha : a ∘ (G.map (pullback.fst _ _)) = a ∘ (G.map (pullback.snd π π))) :
Function.FactorsThrough a (G.map π) := by
intro x y hxy
let xy : G.obj (pullback π π) := (PreservesPullback.iso G π π).inv <|
(TopCat.pullbackIsoProdSubtype (G.map π) (G.map π)).inv ⟨(x, y), hxy⟩
have ha' := congr_fun ha xy
dsimp at ha'
have h₁ : ∀ y, G.map (pullback.fst _ _) ((PreservesPullback.iso G π π).inv y) =
pullback.fst (G.map π) (G.map π) y := by
simp only [← PreservesPullback.iso_inv_fst]; intro y; rfl
have h₂ : ∀ y, G.map (pullback.snd _ _) ((PreservesPullback.iso G π π).inv y) =
pullback.snd (G.map π) (G.map π) y := by
simp only [← PreservesPullback.iso_inv_snd]; intro y; rfl
rw [h₁, h₂, TopCat.pullbackIsoProdSubtype_inv_fst_apply,
TopCat.pullbackIsoProdSubtype_inv_snd_apply] at ha'
simpa using ha'
/--
If `G` preserves the relevant pullbacks and every effective epi in `C` is a quotient map (which is
the case when `C` is `CompHaus` or `Profinite`), then `yonedaPresheaf` satisfies the equalizer
condition which is required to be a sheaf for the regular topology.
-/
theorem equalizerCondition_yonedaPresheaf
[∀ (Z B : C) (π : Z ⟶ B) [EffectiveEpi π], PreservesLimit (cospan π π) G]
(hq : ∀ (Z B : C) (π : Z ⟶ B) [EffectiveEpi π], IsQuotientMap (G.map π)) :
EqualizerCondition (yonedaPresheaf G X) := by
apply EqualizerCondition.mk
intro Z B π _ _
refine ⟨fun a b h ↦ ?_, fun ⟨a, ha⟩ ↦ ?_⟩
· simp only [yonedaPresheaf, unop_op, Quiver.Hom.unop_op, Set.coe_setOf, MapToEqualizer,
Set.mem_setOf_eq, Subtype.mk.injEq, comp, ContinuousMap.mk.injEq] at h
simp only [yonedaPresheaf, unop_op]
ext x
obtain ⟨y, hy⟩ := (hq Z B π).surjective x
rw [← hy]
exact congr_fun h y
· simp only [yonedaPresheaf, comp, unop_op, Quiver.Hom.unop_op, Set.mem_setOf_eq,
ContinuousMap.mk.injEq] at ha
simp only [yonedaPresheaf, comp, unop_op, Quiver.Hom.unop_op, Set.coe_setOf,
MapToEqualizer, Set.mem_setOf_eq, Subtype.mk.injEq]
simp only [yonedaPresheaf, unop_op] at a
refine ⟨(hq Z B π).lift a (factorsThrough_of_pullbackCondition G X ha), ?_⟩
congr 1
exact DFunLike.ext'_iff.mp ((hq Z B π).lift_comp a (factorsThrough_of_pullbackCondition G X ha))
/--
If `G` preserves finite coproducts (which is the case when `C` is `CompHaus`, `Profinite` or
`Stonean`), then `yonedaPresheaf` preserves finite products, which is required to be a sheaf for
the extensive topology.
-/
noncomputable instance [PreservesFiniteCoproducts G] :
PreservesFiniteProducts (yonedaPresheaf G X) :=
have := preservesFiniteProducts_op G
⟨fun _ ↦ comp_preservesLimitsOfShape G.op (yonedaPresheaf' X)⟩
section
variable (P : TopCat.{u} → Prop) (X : TopCat.{max u w})
[CompHausLike.HasExplicitFiniteCoproducts.{0} P] [CompHausLike.HasExplicitPullbacks.{u} P]
(hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f)
/--
The sheaf on `CompHausLike P` of continuous maps to a topological space.
-/
@[simps! val_obj val_map]
def TopCat.toSheafCompHausLike :
have := CompHausLike.preregular hs
Sheaf (coherentTopology (CompHausLike.{u} P)) (Type (max u w)) where
val := yonedaPresheaf.{u, max u w} (CompHausLike.compHausLikeToTop.{u} P) X
cond := by
have := CompHausLike.preregular hs
rw [Presheaf.isSheaf_iff_preservesFiniteProducts_and_equalizerCondition]
refine ⟨inferInstance, ?_⟩
apply (config := { allowSynthFailures := true }) equalizerCondition_yonedaPresheaf
(CompHausLike.compHausLikeToTop.{u} P) X
intro Z B π he
apply IsQuotientMap.of_surjective_continuous (hs _ he) π.hom.continuous
/--
`TopCat.toSheafCompHausLike` yields a functor from `TopCat.{max u w}` to
`Sheaf (coherentTopology (CompHausLike.{u} P)) (Type (max u w))`.
-/
@[simps]
noncomputable def topCatToSheafCompHausLike :
have := CompHausLike.preregular hs
TopCat.{max u w} ⥤ Sheaf (coherentTopology (CompHausLike.{u} P)) (Type (max u w)) where
obj X := X.toSheafCompHausLike P hs
map f := ⟨⟨fun _ g ↦ f.hom.comp g, by aesop⟩⟩
end
/--
Associate to a `(u+1)`-small topological space the corresponding condensed set, given by
`yonedaPresheaf`.
-/
noncomputable abbrev TopCat.toCondensedSet (X : TopCat.{u + 1}) : CondensedSet.{u} :=
toSheafCompHausLike.{u+1} _ X (fun _ _ _ ↦ ((CompHaus.effectiveEpi_tfae _).out 0 2).mp)
/--
`TopCat.toCondensedSet` yields a functor from `TopCat.{u+1}` to `CondensedSet.{u}`.
-/
noncomputable abbrev topCatToCondensedSet : TopCat.{u+1} ⥤ CondensedSet.{u} :=
topCatToSheafCompHausLike.{u+1} _ (fun _ _ _ ↦ ((CompHaus.effectiveEpi_tfae _).out 0 2).mp) |
.lake/packages/mathlib/Mathlib/Condensed/CartesianClosed.lean | import Mathlib.CategoryTheory.Closed.Types
import Mathlib.CategoryTheory.Sites.CartesianClosed
import Mathlib.Condensed.Basic
import Mathlib.CategoryTheory.Sites.LeftExact
/-!
# Condensed sets form a Cartesian closed category
-/
universe u
noncomputable section
open CategoryTheory
instance : CartesianMonoidalCategory (CondensedSet.{u}) :=
inferInstanceAs (CartesianMonoidalCategory (Sheaf _ _))
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : CartesianClosed (CondensedSet.{u}) := inferInstanceAs (CartesianClosed (Sheaf _ _)) |
.lake/packages/mathlib/Mathlib/Condensed/Solid.lean | import Mathlib.CategoryTheory.Functor.KanExtension.Pointwise
import Mathlib.Condensed.Functors
import Mathlib.Condensed.Limits
/-!
# Solid modules
This file contains the definition of a solid `R`-module: `CondensedMod.isSolid R`. Solid modules
groups were introduced in [scholze2019condensed], Definition 5.1.
## Main definition
* `CondensedMod.IsSolid R`: the predicate on condensed `R`-modules describing the property of
being solid.
TODO (hard): prove that `((profiniteSolid ℤ).obj S).IsSolid` for `S : Profinite`.
TODO (slightly easier): prove that `((profiniteSolid 𝔽ₚ).obj S).IsSolid` for `S : Profinite`.
-/
universe u
variable (R : Type (u + 1)) [Ring R]
open CategoryTheory Limits Profinite Condensed
noncomputable section
namespace Condensed
/-- The free condensed `R`-module on a finite set. -/
abbrev finFree : FintypeCat.{u} ⥤ CondensedMod.{u} R :=
FintypeCat.toProfinite ⋙ profiniteToCondensed ⋙ free R
/-- The free condensed `R`-module on a profinite space. -/
abbrev profiniteFree : Profinite.{u} ⥤ CondensedMod.{u} R :=
profiniteToCondensed ⋙ free R
/-- The functor sending a profinite space `S` to the condensed `R`-module `R[S]^\solid`. -/
def profiniteSolid : Profinite.{u} ⥤ CondensedMod.{u} R :=
Functor.rightKanExtension FintypeCat.toProfinite (finFree R)
/-- The natural transformation `FintypeCat.toProfinite ⋙ profiniteSolid R ⟶ finFree R`
which is part of the assertion that `profiniteSolid R` is the (pointwise) right
Kan extension of `finFree R` along `FintypeCat.toProfinite`. -/
def profiniteSolidCounit : FintypeCat.toProfinite ⋙ profiniteSolid R ⟶ finFree R :=
Functor.rightKanExtensionCounit FintypeCat.toProfinite (finFree R)
instance : (profiniteSolid R).IsRightKanExtension (profiniteSolidCounit R) := by
dsimp only [profiniteSolidCounit, profiniteSolid]
infer_instance
/-- The functor `Profinite.{u} ⥤ CondensedMod.{u} R` is a pointwise
right Kan extension of `finFree R : FintypeCat.{u} ⥤ CondensedMod.{u} R`
along `FintypeCat.toProfinite`. -/
def profiniteSolidIsPointwiseRightKanExtension :
(Functor.RightExtension.mk _ (profiniteSolidCounit R)).IsPointwiseRightKanExtension :=
Functor.isPointwiseRightKanExtensionOfIsRightKanExtension _ _
/-- The natural transformation `R[S] ⟶ R[S]^\solid`. -/
def profiniteSolidification : profiniteFree R ⟶ profiniteSolid.{u} R :=
(profiniteSolid R).liftOfIsRightKanExtension (profiniteSolidCounit R) _ (𝟙 _)
end Condensed
/--
The predicate on condensed `R`-modules describing the property of being solid.
TODO: This is not the correct definition of solid `R`-modules for a general `R`. The correct one is
as follows: Use this to define solid modules over a finite type `ℤ`-algebra `R`. In particular this
gives a definition of solid modules over `ℤ[X]` (polynomials in one variable). Then a solid
`R`-module over a general ring `R` is the condition that for every `r ∈ R` and every ring
homomorphism `ℤ[X] → R` such that `X` maps to `r`, the underlying `ℤ[X]`-module is solid.
-/
class CondensedMod.IsSolid (A : CondensedMod.{u} R) : Prop where
isIso_solidification_map : ∀ X : Profinite.{u}, IsIso ((yoneda.obj A).map
((profiniteSolidification R).app X).op) |
.lake/packages/mathlib/Mathlib/Condensed/Explicit.lean | import Mathlib.Condensed.Module
import Mathlib.Condensed.Equivalence
/-!
# The explicit sheaf condition for condensed sets
We give the following three explicit descriptions of condensed objects:
* `Condensed.ofSheafStonean`: A finite-product-preserving presheaf on `Stonean`.
* `Condensed.ofSheafProfinite`: A finite-product-preserving presheaf on `Profinite`, satisfying
`EqualizerCondition`.
* `Condensed.ofSheafStonean`: A finite-product-preserving presheaf on `CompHaus`, satisfying
`EqualizerCondition`.
The property `EqualizerCondition` is defined in `Mathlib/CategoryTheory/Sites/RegularSheaves.lean`
and it says that for any effective epi `X ⟶ B` (in this case that is equivalent to being a
continuous surjection), the presheaf `F` exhibits `F(B)` as the equalizer of the two maps
`F(X) ⇉ F(X ×_B X)`
We also give variants for condensed objects in concrete categories whose forgetful functor
reflects finite limits (resp. products), where it is enough to check the sheaf condition after
postcomposing with the forgetful functor.
-/
universe u
open CategoryTheory Limits Opposite Functor Presheaf regularTopology
namespace Condensed
variable {A : Type*} [Category A]
/-- The condensed object associated to a finite-product-preserving presheaf on `Stonean`. -/
noncomputable def ofSheafStonean
[∀ X, HasLimitsOfShape (StructuredArrow X Stonean.toCompHaus.op) A]
(F : Stonean.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts F] :
Condensed A :=
StoneanCompHaus.equivalence A |>.functor.obj {
val := F
cond := by
rw [isSheaf_iff_preservesFiniteProducts_of_projective F]
exact ⟨fun _ ↦ inferInstance⟩ }
/--
The condensed object associated to a presheaf on `Stonean` whose postcomposition with the
forgetful functor preserves finite products.
-/
noncomputable def ofSheafForgetStonean
[∀ X, HasLimitsOfShape (StructuredArrow X Stonean.toCompHaus.op) A]
[HasForget A] [ReflectsFiniteProducts (CategoryTheory.forget A)]
(F : Stonean.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts (F ⋙ CategoryTheory.forget A)] :
Condensed A :=
StoneanCompHaus.equivalence A |>.functor.obj {
val := F
cond := by
apply isSheaf_coherent_of_projective_of_comp F (CategoryTheory.forget A)
rw [isSheaf_iff_preservesFiniteProducts_of_projective]
exact ⟨fun _ ↦ inferInstance⟩ }
/--
The condensed object associated to a presheaf on `Profinite` which preserves finite products and
satisfies the equalizer condition.
-/
noncomputable def ofSheafProfinite
[∀ X, HasLimitsOfShape (StructuredArrow X profiniteToCompHaus.op) A]
(F : Profinite.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts F]
(hF : EqualizerCondition F) : Condensed A :=
ProfiniteCompHaus.equivalence A |>.functor.obj {
val := F
cond := by
rw [isSheaf_iff_preservesFiniteProducts_and_equalizerCondition F]
exact ⟨⟨fun _ ↦ inferInstance⟩, hF⟩ }
/--
The condensed object associated to a presheaf on `Profinite` whose postcomposition with the
forgetful functor preserves finite products and satisfies the equalizer condition.
-/
noncomputable def ofSheafForgetProfinite
[∀ X, HasLimitsOfShape (StructuredArrow X profiniteToCompHaus.op) A]
[HasForget A] [ReflectsFiniteLimits (CategoryTheory.forget A)]
(F : Profinite.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts (F ⋙ CategoryTheory.forget A)]
(hF : EqualizerCondition (F ⋙ CategoryTheory.forget A)) :
Condensed A :=
ProfiniteCompHaus.equivalence A |>.functor.obj {
val := F
cond := by
apply isSheaf_coherent_of_hasPullbacks_of_comp F (CategoryTheory.forget A)
rw [isSheaf_iff_preservesFiniteProducts_and_equalizerCondition]
exact ⟨⟨fun _ ↦ inferInstance⟩, hF⟩ }
/--
The condensed object associated to a presheaf on `CompHaus` which preserves finite products and
satisfies the equalizer condition.
-/
noncomputable def ofSheafCompHaus
(F : CompHaus.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts F]
(hF : EqualizerCondition F) : Condensed A where
val := F
cond := by
rw [isSheaf_iff_preservesFiniteProducts_and_equalizerCondition F]
exact ⟨⟨fun _ ↦ inferInstance⟩, hF⟩
/--
The condensed object associated to a presheaf on `CompHaus` whose postcomposition with the
forgetful functor preserves finite products and satisfies the equalizer condition.
-/
noncomputable def ofSheafForgetCompHaus
[HasForget A] [ReflectsFiniteLimits (CategoryTheory.forget A)]
(F : CompHaus.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts (F ⋙ CategoryTheory.forget A)]
(hF : EqualizerCondition (F ⋙ CategoryTheory.forget A)) : Condensed A where
val := F
cond := by
apply isSheaf_coherent_of_hasPullbacks_of_comp F (CategoryTheory.forget A)
rw [isSheaf_iff_preservesFiniteProducts_and_equalizerCondition]
exact ⟨⟨fun _ ↦ inferInstance⟩, hF⟩
/-- A condensed object satisfies the equalizer condition. -/
theorem equalizerCondition (X : Condensed A) : EqualizerCondition X.val :=
isSheaf_iff_preservesFiniteProducts_and_equalizerCondition X.val |>.mp X.cond |>.2
/-- A condensed object preserves finite products. -/
noncomputable instance (X : Condensed A) : PreservesFiniteProducts X.val :=
isSheaf_iff_preservesFiniteProducts_and_equalizerCondition X.val |>.mp
X.cond |>.1
/-- A condensed object regarded as a sheaf on `Profinite` preserves finite products. -/
noncomputable instance (X : Sheaf (coherentTopology Profinite.{u}) A) :
PreservesFiniteProducts X.val :=
isSheaf_iff_preservesFiniteProducts_and_equalizerCondition X.val |>.mp
X.cond |>.1
/-- A condensed object regarded as a sheaf on `Profinite` satisfies the equalizer condition. -/
theorem equalizerCondition_profinite (X : Sheaf (coherentTopology Profinite.{u}) A) :
EqualizerCondition X.val :=
isSheaf_iff_preservesFiniteProducts_and_equalizerCondition X.val |>.mp X.cond |>.2
/-- A condensed object regarded as a sheaf on `Stonean` preserves finite products. -/
noncomputable instance (X : Sheaf (coherentTopology Stonean.{u}) A) :
PreservesFiniteProducts X.val :=
isSheaf_iff_preservesFiniteProducts_of_projective X.val |>.mp X.cond
end Condensed
namespace CondensedSet
/-- A `CondensedSet` version of `Condensed.ofSheafStonean`. -/
noncomputable abbrev ofSheafStonean (F : Stonean.{u}ᵒᵖ ⥤ Type (u + 1)) [PreservesFiniteProducts F] :
CondensedSet :=
Condensed.ofSheafStonean F
/-- A `CondensedSet` version of `Condensed.ofSheafProfinite`. -/
noncomputable abbrev ofSheafProfinite (F : Profinite.{u}ᵒᵖ ⥤ Type (u + 1))
[PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedSet :=
Condensed.ofSheafProfinite F hF
/-- A `CondensedSet` version of `Condensed.ofSheafCompHaus`. -/
noncomputable abbrev ofSheafCompHaus (F : CompHaus.{u}ᵒᵖ ⥤ Type (u + 1))
[PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedSet :=
Condensed.ofSheafCompHaus F hF
end CondensedSet
namespace CondensedMod
variable (R : Type (u + 1)) [Ring R]
/-- A `CondensedMod` version of `Condensed.ofSheafStonean`. -/
noncomputable abbrev ofSheafStonean (F : Stonean.{u}ᵒᵖ ⥤ ModuleCat.{u + 1} R)
[PreservesFiniteProducts F] : CondensedMod R :=
haveI : HasLimitsOfSize.{u, u + 1} (ModuleCat R) :=
hasLimitsOfSizeShrink.{u, u + 1, u + 1, u + 1} _
Condensed.ofSheafStonean F
/-- A `CondensedMod` version of `Condensed.ofSheafProfinite`. -/
noncomputable abbrev ofSheafProfinite (F : Profinite.{u}ᵒᵖ ⥤ ModuleCat.{u + 1} R)
[PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedMod R :=
haveI : HasLimitsOfSize.{u, u + 1} (ModuleCat R) :=
hasLimitsOfSizeShrink.{u, u + 1, u + 1, u + 1} _
Condensed.ofSheafProfinite F hF
/-- A `CondensedMod` version of `Condensed.ofSheafCompHaus`. -/
noncomputable abbrev ofSheafCompHaus (F : CompHaus.{u}ᵒᵖ ⥤ ModuleCat.{u + 1} R)
[PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedMod R :=
Condensed.ofSheafCompHaus F hF
end CondensedMod |
.lake/packages/mathlib/Mathlib/Condensed/TopCatAdjunction.lean | import Mathlib.Condensed.TopComparison
import Mathlib.Topology.Category.CompactlyGenerated
/-!
# The adjunction between condensed sets and topological spaces
This file defines the functor `condensedSetToTopCat : CondensedSet.{u} ⥤ TopCat.{u + 1}` which is
left adjoint to `topCatToCondensedSet : TopCat.{u + 1} ⥤ CondensedSet.{u}`. We prove that the counit
is bijective (but not in general an isomorphism) and conclude that the right adjoint is faithful.
The counit is an isomorphism for compactly generated spaces, and we conclude that the functor
`topCatToCondensedSet` is fully faithful when restricted to compactly generated spaces.
-/
universe u
open Condensed CondensedSet CategoryTheory CompHaus
variable (X : CondensedSet.{u})
/-- Auxiliary definition to define the topology on `X(*)` for a condensed set `X`. -/
private def CondensedSet.coinducingCoprod :
(Σ (i : (S : CompHaus.{u}) × X.val.obj ⟨S⟩), i.fst) → X.val.obj ⟨of PUnit⟩ :=
fun ⟨⟨_, i⟩, s⟩ ↦ X.val.map ((of PUnit.{u + 1}).const s).op i
/-- Let `X` be a condensed set. We define a topology on `X(*)` as the quotient topology of
all the maps from compact Hausdorff `S` spaces to `X(*)`, corresponding to elements of `X(S)`.
In other words, the topology coinduced by the map `CondensedSet.coinducingCoprod` above. -/
local instance : TopologicalSpace (X.val.obj ⟨CompHaus.of PUnit⟩) :=
TopologicalSpace.coinduced (coinducingCoprod X) inferInstance
/-- The object part of the functor `CondensedSet ⥤ TopCat` -/
abbrev CondensedSet.toTopCat : TopCat.{u + 1} := TopCat.of (X.val.obj ⟨of PUnit⟩)
namespace CondensedSet
lemma continuous_coinducingCoprod {S : CompHaus.{u}} (x : X.val.obj ⟨S⟩) :
Continuous fun a ↦ (X.coinducingCoprod ⟨⟨S, x⟩, a⟩) := by
suffices ∀ (i : (T : CompHaus.{u}) × X.val.obj ⟨T⟩),
Continuous (fun (a : i.fst) ↦ X.coinducingCoprod ⟨i, a⟩) from this ⟨_, _⟩
rw [← continuous_sigma_iff]
apply continuous_coinduced_rng
variable {X} {Y : CondensedSet} (f : X ⟶ Y)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
/-- The map part of the functor `CondensedSet ⥤ TopCat` -/
@[simps!]
def toTopCatMap : X.toTopCat ⟶ Y.toTopCat :=
TopCat.ofHom
{ toFun := f.val.app ⟨of PUnit⟩
continuous_toFun := by
rw [continuous_coinduced_dom]
apply continuous_sigma
intro ⟨S, x⟩
simp only [Function.comp_apply, coinducingCoprod]
rw [show (fun (a : S) ↦
f.val.app ⟨of PUnit⟩ (X.val.map ((of PUnit.{u + 1}).const a).op x)) = _
from funext fun a ↦ NatTrans.naturality_apply f.val ((of PUnit.{u + 1}).const a).op x]
exact continuous_coinducingCoprod Y _ }
end CondensedSet
/-- The functor `CondensedSet ⥤ TopCat` -/
@[simps]
def condensedSetToTopCat : CondensedSet.{u} ⥤ TopCat.{u + 1} where
obj X := X.toTopCat
map f := toTopCatMap f
namespace CondensedSet
/-- The counit of the adjunction `condensedSetToTopCat ⊣ topCatToCondensedSet` -/
noncomputable def topCatAdjunctionCounit (X : TopCat.{u + 1}) : X.toCondensedSet.toTopCat ⟶ X :=
TopCat.ofHom
{ toFun x := x.1 PUnit.unit
continuous_toFun := by
rw [continuous_coinduced_dom]
continuity }
/-- `simp`-normal form of the lemma that `@[simps]` would generate. -/
@[simp] lemma topCatAdjunctionCounit_hom_apply (X : TopCat) (x) :
-- We have to specify here to not infer the `TopologicalSpace` instance on `C(PUnit, X)`,
-- which suggests type synonyms are being unfolded too far somewhere.
DFunLike.coe (F := @ContinuousMap C(PUnit, X) X (_) _)
(TopCat.Hom.hom (topCatAdjunctionCounit X)) x =
x PUnit.unit := rfl
/-- The counit of the adjunction `condensedSetToTopCat ⊣ topCatToCondensedSet` is always bijective,
but not an isomorphism in general (the inverse isn't continuous unless `X` is compactly generated).
-/
noncomputable def topCatAdjunctionCounitEquiv (X : TopCat.{u + 1}) :
X.toCondensedSet.toTopCat ≃ X where
toFun := topCatAdjunctionCounit X
invFun x := ContinuousMap.const _ x
lemma topCatAdjunctionCounit_bijective (X : TopCat.{u + 1}) :
Function.Bijective (topCatAdjunctionCounit X) :=
(topCatAdjunctionCounitEquiv X).bijective
/-- The unit of the adjunction `condensedSetToTopCat ⊣ topCatToCondensedSet` -/
@[simps val_app val_app_apply]
noncomputable def topCatAdjunctionUnit (X : CondensedSet.{u}) : X ⟶ X.toTopCat.toCondensedSet where
val := {
app := fun S x ↦ {
toFun := fun s ↦ X.val.map ((of PUnit.{u + 1}).const s).op x
continuous_toFun := by
suffices ∀ (i : (T : CompHaus.{u}) × X.val.obj ⟨T⟩),
Continuous (fun (a : i.fst) ↦ X.coinducingCoprod ⟨i, a⟩) from this ⟨_, _⟩
rw [← continuous_sigma_iff]
apply continuous_coinduced_rng }
naturality := fun _ _ _ ↦ by
ext
simp only [TopCat.toSheafCompHausLike_val_obj,
Opposite.op_unop, types_comp_apply, TopCat.toSheafCompHausLike_val_map,
← FunctorToTypes.map_comp_apply]
rfl }
/-- The adjunction `condensedSetToTopCat ⊣ topCatToCondensedSet` -/
noncomputable def topCatAdjunction : condensedSetToTopCat.{u} ⊣ topCatToCondensedSet where
unit.app := topCatAdjunctionUnit
counit.app := topCatAdjunctionCounit
left_triangle_components Y := by
ext
change Y.val.map (𝟙 _) _ = _
simp
instance (X : TopCat) : Epi (topCatAdjunction.counit.app X) := by
rw [TopCat.epi_iff_surjective]
exact (topCatAdjunctionCounit_bijective _).2
instance : topCatToCondensedSet.Faithful := topCatAdjunction.faithful_R_of_epi_counit_app
open CompactlyGenerated
instance (X : CondensedSet.{u}) : UCompactlyGeneratedSpace.{u, u + 1} X.toTopCat := by
apply uCompactlyGeneratedSpace_of_continuous_maps
intro Y _ f h
rw [continuous_coinduced_dom, continuous_sigma_iff]
exact fun ⟨S, s⟩ ↦ h S ⟨_, continuous_coinducingCoprod X _⟩
instance (X : CondensedSet.{u}) :
UCompactlyGeneratedSpace.{u, u + 1} (condensedSetToTopCat.obj X) :=
inferInstanceAs (UCompactlyGeneratedSpace.{u, u + 1} X.toTopCat)
/-- The functor from condensed sets to topological spaces lands in compactly generated spaces. -/
def condensedSetToCompactlyGenerated : CondensedSet.{u} ⥤ CompactlyGenerated.{u, u + 1} where
obj X := CompactlyGenerated.of (condensedSetToTopCat.obj X)
map f := toTopCatMap f
/--
The functor from topological spaces to condensed sets restricted to compactly generated spaces.
-/
noncomputable def compactlyGeneratedToCondensedSet :
CompactlyGenerated.{u, u + 1} ⥤ CondensedSet.{u} :=
compactlyGeneratedToTop ⋙ topCatToCondensedSet
/--
The adjunction `condensedSetToTopCat ⊣ topCatToCondensedSet` restricted to compactly generated
spaces.
-/
noncomputable def compactlyGeneratedAdjunction :
condensedSetToCompactlyGenerated ⊣ compactlyGeneratedToCondensedSet :=
topCatAdjunction.restrictFullyFaithful (iC := 𝟭 _) (iD := compactlyGeneratedToTop)
(Functor.FullyFaithful.id _) fullyFaithfulCompactlyGeneratedToTop
(Iso.refl _) (Iso.refl _)
/--
The counit of the adjunction `condensedSetToCompactlyGenerated ⊣ compactlyGeneratedToCondensedSet`
is a homeomorphism.
-/
noncomputable def compactlyGeneratedAdjunctionCounitHomeo
(X : TopCat.{u + 1}) [UCompactlyGeneratedSpace.{u} X] :
X.toCondensedSet.toTopCat ≃ₜ X where
toEquiv := topCatAdjunctionCounitEquiv X
continuous_invFun := by
apply continuous_from_uCompactlyGeneratedSpace
exact fun _ _ ↦ continuous_coinducingCoprod X.toCondensedSet _
/--
The counit of the adjunction `condensedSetToCompactlyGenerated ⊣ compactlyGeneratedToCondensedSet`
is an isomorphism.
-/
noncomputable def compactlyGeneratedAdjunctionCounitIso (X : CompactlyGenerated.{u, u + 1}) :
condensedSetToCompactlyGenerated.obj (compactlyGeneratedToCondensedSet.obj X) ≅ X :=
isoOfHomeo (compactlyGeneratedAdjunctionCounitHomeo X.toTop)
instance : IsIso compactlyGeneratedAdjunction.counit := by
rw [NatTrans.isIso_iff_isIso_app]
intro X
exact inferInstanceAs (IsIso (compactlyGeneratedAdjunctionCounitIso X).hom)
/--
The functor from topological spaces to condensed sets restricted to compactly generated spaces
is fully faithful.
-/
noncomputable def fullyFaithfulCompactlyGeneratedToCondensedSet :
compactlyGeneratedToCondensedSet.FullyFaithful :=
compactlyGeneratedAdjunction.fullyFaithfulROfIsIsoCounit
end CondensedSet |
.lake/packages/mathlib/Mathlib/Condensed/Epi.lean | import Mathlib.CategoryTheory.ConcreteCategory.EpiMono
import Mathlib.CategoryTheory.Sites.Coherent.LocallySurjective
import Mathlib.CategoryTheory.Sites.EpiMono
import Mathlib.Condensed.Equivalence
import Mathlib.Condensed.Module
/-!
# Epimorphisms of condensed objects
This file characterises epimorphisms of condensed sets and condensed `R`-modules for any ring `R`,
as those morphisms which are objectwise surjective on `Stonean` (see
`CondensedSet.epi_iff_surjective_on_stonean` and `CondensedMod.epi_iff_surjective_on_stonean`).
-/
universe v u w u' v'
open CategoryTheory Sheaf Opposite Limits Condensed ConcreteCategory
namespace Condensed
variable (A : Type u') [Category.{v'} A] {FA : A → A → Type*} {CA : A → Type v'}
variable [∀ X Y, FunLike (FA X Y) (CA X) (CA Y)] [ConcreteCategory.{v'} A FA]
[HasFunctorialSurjectiveInjectiveFactorization A]
variable {X Y : Condensed.{u} A} (f : X ⟶ Y)
set_option Elab.async false in -- TODO: universe levels from type are unified in proof
variable
[(coherentTopology CompHaus).WEqualsLocallyBijective A]
[HasSheafify (coherentTopology CompHaus) A]
[(coherentTopology CompHaus.{u}).HasSheafCompose (CategoryTheory.forget A)]
[Balanced (Sheaf (coherentTopology CompHaus) A)]
[PreservesFiniteProducts (CategoryTheory.forget A)] in
lemma epi_iff_locallySurjective_on_compHaus : Epi f ↔
∀ (S : CompHaus) (y : ToType (Y.val.obj ⟨S⟩)),
(∃ (S' : CompHaus) (φ : S' ⟶ S) (_ : Function.Surjective φ) (x : ToType (X.val.obj ⟨S'⟩)),
f.val.app ⟨S'⟩ x = Y.val.map ⟨φ⟩ y) := by
rw [← isLocallySurjective_iff_epi', coherentTopology.isLocallySurjective_iff,
regularTopology.isLocallySurjective_iff]
simp_rw [((CompHaus.effectiveEpi_tfae _).out 0 2 :)]
set_option Elab.async false in -- TODO: universe levels from type are unified in proof
variable
[PreservesFiniteProducts (CategoryTheory.forget A)]
[∀ (X : CompHausᵒᵖ), HasLimitsOfShape (StructuredArrow X Stonean.toCompHaus.op) A]
[(extensiveTopology Stonean).WEqualsLocallyBijective A]
[HasSheafify (extensiveTopology Stonean) A]
[(extensiveTopology Stonean.{u}).HasSheafCompose (CategoryTheory.forget A)]
[Balanced (Sheaf (extensiveTopology Stonean) A)] in
lemma epi_iff_surjective_on_stonean : Epi f ↔
∀ (S : Stonean), Function.Surjective (f.val.app (op S.compHaus)) := by
rw [← (StoneanCompHaus.equivalence A).inverse.epi_map_iff_epi,
← Presheaf.coherentExtensiveEquivalence.functor.epi_map_iff_epi,
← isLocallySurjective_iff_epi']
exact extensiveTopology.isLocallySurjective_iff (D := A) _
end Condensed
namespace CondensedSet
variable {X Y : CondensedSet.{u}} (f : X ⟶ Y)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma epi_iff_locallySurjective_on_compHaus : Epi f ↔
∀ (S : CompHaus) (y : Y.val.obj ⟨S⟩),
(∃ (S' : CompHaus) (φ : S' ⟶ S) (_ : Function.Surjective φ) (x : X.val.obj ⟨S'⟩),
f.val.app ⟨S'⟩ x = Y.val.map ⟨φ⟩ y) :=
Condensed.epi_iff_locallySurjective_on_compHaus _ f
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma epi_iff_surjective_on_stonean : Epi f ↔
∀ (S : Stonean), Function.Surjective (f.val.app (op S.compHaus)) :=
Condensed.epi_iff_surjective_on_stonean _ f
end CondensedSet
namespace CondensedMod
variable (R : Type (u + 1)) [Ring R] {X Y : CondensedMod.{u} R} (f : X ⟶ Y)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma epi_iff_locallySurjective_on_compHaus : Epi f ↔
∀ (S : CompHaus) (y : Y.val.obj ⟨S⟩),
(∃ (S' : CompHaus) (φ : S' ⟶ S) (_ : Function.Surjective φ) (x : X.val.obj ⟨S'⟩),
f.val.app ⟨S'⟩ x = Y.val.map ⟨φ⟩ y) :=
Condensed.epi_iff_locallySurjective_on_compHaus _ f
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma epi_iff_surjective_on_stonean : Epi f ↔
∀ (S : Stonean), Function.Surjective (f.val.app (op S.compHaus)) :=
have : HasLimitsOfSize.{u, u + 1} (ModuleCat R) :=
hasLimitsOfSizeShrink.{u, u + 1, u + 1, u + 1} _
Condensed.epi_iff_surjective_on_stonean _ f
end CondensedMod |
.lake/packages/mathlib/Mathlib/Condensed/AB.lean | import Mathlib.Algebra.Category.ModuleCat.AB
import Mathlib.CategoryTheory.Abelian.GrothendieckAxioms.Sheaf
import Mathlib.CategoryTheory.Sites.Coherent.ExtensiveColimits
import Mathlib.Condensed.Equivalence
import Mathlib.Condensed.Limits
/-!
# AB axioms in condensed modules
This file proves that the category of condensed modules over a ring satisfies Grothendieck's axioms
AB5, AB4, and AB4*.
-/
universe u
open Condensed CategoryTheory Limits
namespace Condensed
variable (A J : Type*) [Category A] [Category J] [Preadditive A]
[∀ X, HasLimitsOfShape (StructuredArrow X Stonean.toCompHaus.op) A]
[HasWeakSheafify (coherentTopology CompHaus.{u}) A]
[HasWeakSheafify (extensiveTopology Stonean.{u}) A]
-- One of the `HasWeakSheafify` instances could be deduced from the other using the dense subsite
-- API, but when `A` is a concrete category, these will both be synthesized anyway.
set_option Elab.async false in -- TODO: universe levels from type are unified in proof
lemma hasExactColimitsOfShape [HasColimitsOfShape J A] [HasExactColimitsOfShape J A]
[HasFiniteLimits A] : HasExactColimitsOfShape J (Condensed.{u} A) := by
let e : Condensed.{u} A ≌ Sheaf (extensiveTopology Stonean.{u}) A :=
(StoneanCompHaus.equivalence A).symm.trans Presheaf.coherentExtensiveEquivalence
exact HasExactColimitsOfShape.domain_of_functor _ e.functor
set_option Elab.async false in -- TODO: universe levels from type are unified in proof
lemma hasExactLimitsOfShape [HasLimitsOfShape J A] [HasExactLimitsOfShape J A]
[HasFiniteColimits A] : HasExactLimitsOfShape J (Condensed.{u} A) := by
let e : Condensed.{u} A ≌ Sheaf (extensiveTopology Stonean.{u}) A :=
(StoneanCompHaus.equivalence A).symm.trans Presheaf.coherentExtensiveEquivalence
exact HasExactLimitsOfShape.domain_of_functor _ e.functor
section Module
variable (R : Type (u + 1)) [Ring R]
local instance : HasLimitsOfSize.{u, u + 1} (ModuleCat.{u + 1} R) :=
hasLimitsOfSizeShrink.{u, u + 1, u + 1, u} _
variable (X Y : CondensedMod.{u} R)
instance : AB5 (CondensedMod.{u} R) where
ofShape J _ _ := hasExactColimitsOfShape (ModuleCat R) J
attribute [local instance] Abelian.hasFiniteBiproducts
instance : AB4 (CondensedMod.{u} R) := AB4.of_AB5 _
instance : AB4Star (CondensedMod.{u} R) where
ofShape J := hasExactLimitsOfShape (ModuleCat R) (Discrete J)
end Module
end Condensed |
.lake/packages/mathlib/Mathlib/Condensed/Limits.lean | import Mathlib.Condensed.Module
/-!
# Limits in categories of condensed objects
This file adds some instances for limits in condensed sets and condensed modules.
-/
universe u
open CategoryTheory Limits
instance : HasLimits CondensedSet.{u} := by
change HasLimits (Sheaf _ _)
infer_instance
instance : HasLimitsOfSize.{u, u + 1} CondensedSet.{u} :=
hasLimitsOfSizeShrink.{u, u + 1, u + 1, u} _
variable (R : Type (u + 1)) [Ring R]
instance : HasLimits (CondensedMod.{u} R) :=
inferInstanceAs (HasLimits (Sheaf _ _))
instance : HasColimits (CondensedMod.{u} R) :=
inferInstanceAs (HasColimits (Sheaf _ _))
instance : HasLimitsOfSize.{u, u + 1} (CondensedMod.{u} R) :=
hasLimitsOfSizeShrink.{u, u + 1, u + 1, u} _
instance {A J : Type*} [Category A] [Category J] [HasColimitsOfShape J A]
[HasWeakSheafify (coherentTopology CompHaus.{u}) A] :
HasColimitsOfShape J (Condensed.{u} A) :=
inferInstanceAs (HasColimitsOfShape J (Sheaf _ _))
instance {A J : Type*} [Category A] [Category J] [HasLimitsOfShape J A] :
HasLimitsOfShape J (Condensed.{u} A) :=
inferInstanceAs (HasLimitsOfShape J (Sheaf _ _))
instance {A : Type*} [Category A] [HasFiniteLimits A] : HasFiniteLimits (Condensed.{u} A) :=
inferInstanceAs (HasFiniteLimits (Sheaf _ _))
instance {A : Type*} [Category A] [HasFiniteColimits A]
[HasWeakSheafify (coherentTopology CompHaus.{u}) A] : HasFiniteColimits (Condensed.{u} A) :=
inferInstanceAs (HasFiniteColimits (Sheaf _ _)) |
.lake/packages/mathlib/Mathlib/Condensed/Equivalence.lean | import Mathlib.Topology.Category.Profinite.EffectiveEpi
import Mathlib.Topology.Category.Stonean.EffectiveEpi
import Mathlib.Condensed.Basic
import Mathlib.CategoryTheory.Sites.Coherent.SheafComparison
/-!
# Sheaves on CompHaus are equivalent to sheaves on Stonean
The forgetful functor from extremally disconnected spaces `Stonean` to compact
Hausdorff spaces `CompHaus` has the marvellous property that it induces an equivalence of categories
between sheaves on these two sites. With the terminology of nLab, `Stonean` is a
*dense subsite* of `CompHaus`: see https://ncatlab.org/nlab/show/dense+sub-site
Since Stonean spaces are the projective objects in `CompHaus`, which has enough projectives,
and the notions of effective epimorphism, epimorphism and surjective continuous map are equivalent
in `CompHaus` and `Stonean`, we can use the general setup in
`Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean` to deduce the equivalence of
categories. We give the corresponding statements for `Profinite` as well.
## Main results
* `Condensed.StoneanCompHaus.equivalence`: the equivalence from coherent sheaves on `Stonean` to
coherent sheaves on `CompHaus` (i.e. condensed sets).
* `Condensed.StoneanProfinite.equivalence`: the equivalence from coherent sheaves on `Stonean` to
coherent sheaves on `Profinite`.
* `Condensed.ProfiniteCompHaus.equivalence`: the equivalence from coherent sheaves on `Profinite` to
coherent sheaves on `CompHaus` (i.e. condensed sets).
-/
universe u
open CategoryTheory Limits
namespace Condensed
namespace StoneanCompHaus
/-- The equivalence from coherent sheaves on `Stonean` to coherent sheaves on `CompHaus`
(i.e. condensed sets). -/
noncomputable
def equivalence (A : Type*) [Category A]
[∀ X, HasLimitsOfShape (StructuredArrow X Stonean.toCompHaus.op) A] :
Sheaf (coherentTopology Stonean) A ≌ Condensed.{u} A :=
coherentTopology.equivalence' Stonean.toCompHaus A
end StoneanCompHaus
namespace StoneanProfinite
instance : Stonean.toProfinite.PreservesEffectiveEpis where
preserves f h :=
((Profinite.effectiveEpi_tfae _).out 0 2).mpr (((Stonean.effectiveEpi_tfae _).out 0 2).mp h)
instance : Stonean.toProfinite.ReflectsEffectiveEpis where
reflects f h :=
((Stonean.effectiveEpi_tfae f).out 0 2).mpr (((Profinite.effectiveEpi_tfae _).out 0 2).mp h)
/--
An effective presentation of an `X : Profinite` with respect to the inclusion functor from `Stonean`
-/
noncomputable def stoneanToProfiniteEffectivePresentation (X : Profinite) :
Stonean.toProfinite.EffectivePresentation X where
p := X.presentation
f := Profinite.presentation.π X
effectiveEpi := ((Profinite.effectiveEpi_tfae _).out 0 1).mpr (inferInstance : Epi _)
instance : Stonean.toProfinite.EffectivelyEnough where
presentation X := ⟨stoneanToProfiniteEffectivePresentation X⟩
/-- The equivalence from coherent sheaves on `Stonean` to coherent sheaves on `Profinite`. -/
noncomputable
def equivalence (A : Type*) [Category A]
[∀ X, HasLimitsOfShape (StructuredArrow X Stonean.toProfinite.op) A] :
Sheaf (coherentTopology Stonean) A ≌ Sheaf (coherentTopology Profinite) A :=
coherentTopology.equivalence' Stonean.toProfinite A
end StoneanProfinite
namespace ProfiniteCompHaus
/-- The equivalence from coherent sheaves on `Profinite` to coherent sheaves on `CompHaus`
(i.e. condensed sets). -/
noncomputable
def equivalence (A : Type*) [Category A]
[∀ X, HasLimitsOfShape (StructuredArrow X profiniteToCompHaus.op) A] :
Sheaf (coherentTopology Profinite) A ≌ Condensed.{u} A :=
coherentTopology.equivalence' profiniteToCompHaus A
end ProfiniteCompHaus
variable {A : Type*} [Category A] (X : Condensed.{u} A)
lemma isSheafProfinite
[∀ Y, HasLimitsOfShape (StructuredArrow Y profiniteToCompHaus.{u}.op) A] :
Presheaf.IsSheaf (coherentTopology Profinite)
(profiniteToCompHaus.op ⋙ X.val) :=
((ProfiniteCompHaus.equivalence A).inverse.obj X).cond
lemma isSheafStonean
[∀ Y, HasLimitsOfShape (StructuredArrow Y Stonean.toCompHaus.{u}.op) A] :
Presheaf.IsSheaf (coherentTopology Stonean)
(Stonean.toCompHaus.op ⋙ X.val) :=
((StoneanCompHaus.equivalence A).inverse.obj X).cond
end Condensed |
.lake/packages/mathlib/Mathlib/Condensed/Discrete/Colimit.lean | import Mathlib.Condensed.Discrete.LocallyConstant
import Mathlib.Condensed.Equivalence
import Mathlib.Topology.Category.LightProfinite.Extend
/-!
# The condensed set given by left Kan extension from `FintypeCat` to `Profinite`.
This file provides the necessary API to prove that a condensed set `X` is discrete if and only if
for every profinite set `S = limᵢSᵢ`, `X(S) ≅ colimᵢX(Sᵢ)`, and the analogous result for light
condensed sets.
-/
universe u
noncomputable section
open CategoryTheory Functor Limits FintypeCat CompHausLike.LocallyConstant
namespace Condensed
section LocallyConstantAsColimit
variable {I : Type u} [Category.{u} I] [IsCofiltered I] {F : I ⥤ FintypeCat.{u}}
(c : Cone <| F ⋙ toProfinite) (X : Type (u + 1))
/-- The presheaf on `Profinite` of locally constant functions to `X`. -/
abbrev locallyConstantPresheaf : Profinite.{u}ᵒᵖ ⥤ Type (u + 1) :=
CompHausLike.LocallyConstant.functorToPresheaves.{u, u + 1}.obj X
/--
The functor `locallyConstantPresheaf` takes cofiltered limits of finite sets with surjective
projection maps to colimits.
-/
noncomputable def isColimitLocallyConstantPresheaf (hc : IsLimit c) [∀ i, Epi (c.π.app i)] :
IsColimit <| (locallyConstantPresheaf X).mapCocone c.op := by
refine Types.FilteredColimit.isColimitOf _ _ ?_ ?_
· intro (f : LocallyConstant c.pt X)
obtain ⟨j, h⟩ := Profinite.exists_locallyConstant.{_, u} c hc f
exact ⟨⟨j⟩, h⟩
· intro ⟨i⟩ ⟨j⟩ (fi : LocallyConstant _ _) (fj : LocallyConstant _ _)
(h : fi.comap (c.π.app i).hom = fj.comap (c.π.app j).hom)
obtain ⟨k, ki, kj, _⟩ := IsCofilteredOrEmpty.cone_objs i j
refine ⟨⟨k⟩, ki.op, kj.op, ?_⟩
dsimp
ext x
obtain ⟨x, hx⟩ := ((Profinite.epi_iff_surjective (c.π.app k)).mp inferInstance) x
rw [← hx]
change fi ((c.π.app k ≫ (F ⋙ toProfinite).map _) x) =
fj ((c.π.app k ≫ (F ⋙ toProfinite).map _) x)
have h := LocallyConstant.congr_fun h x
rwa [c.w, c.w]
@[simp]
lemma isColimitLocallyConstantPresheaf_desc_apply (hc : IsLimit c) [∀ i, Epi (c.π.app i)]
(s : Cocone ((F ⋙ toProfinite).op ⋙ locallyConstantPresheaf X))
(i : I) (f : LocallyConstant (toProfinite.obj (F.obj i)) X) :
(isColimitLocallyConstantPresheaf c X hc).desc s (f.comap (c.π.app i).hom) = s.ι.app ⟨i⟩ f := by
change ((((locallyConstantPresheaf X).mapCocone c.op).ι.app ⟨i⟩) ≫
(isColimitLocallyConstantPresheaf c X hc).desc s) _ = _
rw [(isColimitLocallyConstantPresheaf c X hc).fac]
/-- `isColimitLocallyConstantPresheaf` in the case of `S.asLimit`. -/
noncomputable def isColimitLocallyConstantPresheafDiagram (S : Profinite) :
IsColimit <| (locallyConstantPresheaf X).mapCocone S.asLimitCone.op :=
isColimitLocallyConstantPresheaf _ _ S.asLimit
@[simp]
lemma isColimitLocallyConstantPresheafDiagram_desc_apply (S : Profinite)
(s : Cocone (S.diagram.op ⋙ locallyConstantPresheaf X))
(i : DiscreteQuotient S) (f : LocallyConstant (S.diagram.obj i) X) :
(isColimitLocallyConstantPresheafDiagram X S).desc s (f.comap (S.asLimitCone.π.app i).hom) =
s.ι.app ⟨i⟩ f :=
isColimitLocallyConstantPresheaf_desc_apply S.asLimitCone X S.asLimit s i f
end LocallyConstantAsColimit
/--
Given a presheaf `F` on `Profinite`, `lanPresheaf F` is the left Kan extension of its
restriction to finite sets along the inclusion functor of finite sets into `Profinite`.
-/
abbrev lanPresheaf (F : Profinite.{u}ᵒᵖ ⥤ Type (u + 1)) : Profinite.{u}ᵒᵖ ⥤ Type (u + 1) :=
pointwiseLeftKanExtension toProfinite.op (toProfinite.op ⋙ F)
/--
To presheaves on `Profinite` whose restrictions to finite sets are isomorphic have isomorphic left
Kan extensions.
-/
def lanPresheafExt {F G : Profinite.{u}ᵒᵖ ⥤ Type (u + 1)}
(i : toProfinite.op ⋙ F ≅ toProfinite.op ⋙ G) : lanPresheaf F ≅ lanPresheaf G :=
leftKanExtensionUniqueOfIso _ (pointwiseLeftKanExtensionUnit _ _) i _
(pointwiseLeftKanExtensionUnit _ _)
@[simp]
lemma lanPresheafExt_hom {F G : Profinite.{u}ᵒᵖ ⥤ Type (u + 1)} (S : Profinite.{u}ᵒᵖ)
(i : toProfinite.op ⋙ F ≅ toProfinite.op ⋙ G) : (lanPresheafExt i).hom.app S =
colimMap (whiskerLeft (CostructuredArrow.proj toProfinite.op S) i.hom) := by
simp only [lanPresheaf, pointwiseLeftKanExtension_obj, lanPresheafExt,
leftKanExtensionUniqueOfIso_hom, pointwiseLeftKanExtension_desc_app]
apply colimit.hom_ext
aesop
@[simp]
lemma lanPresheafExt_inv {F G : Profinite.{u}ᵒᵖ ⥤ Type (u + 1)} (S : Profinite.{u}ᵒᵖ)
(i : toProfinite.op ⋙ F ≅ toProfinite.op ⋙ G) : (lanPresheafExt i).inv.app S =
colimMap (whiskerLeft (CostructuredArrow.proj toProfinite.op S) i.inv) := by
simp only [lanPresheaf, pointwiseLeftKanExtension_obj, lanPresheafExt,
leftKanExtensionUniqueOfIso_inv, pointwiseLeftKanExtension_desc_app]
apply colimit.hom_ext
aesop
variable {S : Profinite.{u}} {F : Profinite.{u}ᵒᵖ ⥤ Type (u + 1)}
instance : Final <| Profinite.Extend.functorOp S.asLimitCone :=
Profinite.Extend.functorOp_final S.asLimitCone S.asLimit
/--
A presheaf, which takes a profinite set written as a cofiltered limit to the corresponding
colimit, agrees with the left Kan extension of its restriction.
-/
def lanPresheafIso (hF : IsColimit <| F.mapCocone S.asLimitCone.op) :
(lanPresheaf F).obj ⟨S⟩ ≅ F.obj ⟨S⟩ :=
(Functor.Final.colimitIso (Profinite.Extend.functorOp S.asLimitCone) _).symm ≪≫
(colimit.isColimit _).coconePointUniqueUpToIso hF
@[simp]
lemma lanPresheafIso_hom (hF : IsColimit <| F.mapCocone S.asLimitCone.op) :
(lanPresheafIso hF).hom = colimit.desc _ (Profinite.Extend.cocone _ _) := by
simp [lanPresheafIso, Final.colimitIso]
rfl
/-- `lanPresheafIso` is natural in `S`. -/
def lanPresheafNatIso (hF : ∀ S : Profinite, IsColimit <| F.mapCocone S.asLimitCone.op) :
lanPresheaf F ≅ F :=
NatIso.ofComponents (fun ⟨S⟩ ↦ (lanPresheafIso (hF S)))
fun _ ↦ (by simpa using colimit.hom_ext fun _ ↦ (by simp))
@[simp]
lemma lanPresheafNatIso_hom_app (hF : ∀ S : Profinite, IsColimit <| F.mapCocone S.asLimitCone.op)
(S : Profiniteᵒᵖ) : (lanPresheafNatIso hF).hom.app S =
colimit.desc _ (Profinite.Extend.cocone _ _) := by
simp [lanPresheafNatIso]
/--
`lanPresheaf (locallyConstantPresheaf X)` is a sheaf for the coherent topology on `Profinite`.
-/
def lanSheafProfinite (X : Type (u + 1)) :
Sheaf (coherentTopology Profinite.{u}) (Type (u + 1)) where
val := lanPresheaf (locallyConstantPresheaf X)
cond := by
rw [Presheaf.isSheaf_of_iso_iff (lanPresheafNatIso
fun _ ↦ isColimitLocallyConstantPresheafDiagram _ _)]
exact ((CompHausLike.LocallyConstant.functor.{u, u + 1}
(hs := fun _ _ _ ↦ ((Profinite.effectiveEpi_tfae _).out 0 2).mp)).obj X).cond
/-- `lanPresheaf (locallyConstantPresheaf X)` as a condensed set. -/
def lanCondensedSet (X : Type (u + 1)) : CondensedSet.{u} :=
(ProfiniteCompHaus.equivalence _).functor.obj (lanSheafProfinite X)
variable (F : Profinite.{u}ᵒᵖ ⥤ Type (u + 1))
/--
The functor which takes a finite set to the set of maps into `F(*)` for a presheaf `F` on
`Profinite`.
-/
@[simps]
def finYoneda : FintypeCat.{u}ᵒᵖ ⥤ Type (u + 1) where
obj X := X.unop → F.obj (toProfinite.op.obj ⟨of PUnit.{u + 1}⟩)
map f g := g ∘ f.unop
/-- `locallyConstantPresheaf` restricted to finite sets is isomorphic to `finYoneda F`. -/
@[simps! hom_app]
def locallyConstantIsoFinYoneda :
toProfinite.op ⋙ (locallyConstantPresheaf (F.obj (toProfinite.op.obj ⟨of PUnit.{u + 1}⟩))) ≅
finYoneda F :=
NatIso.ofComponents fun Y ↦ {
hom := fun f ↦ f.1
inv := fun f ↦ ⟨f, @IsLocallyConstant.of_discrete _ _ _ ⟨rfl⟩ _⟩ }
/-- A finite set as a coproduct cocone in `Profinite` over itself. -/
def fintypeCatAsCofan (X : Profinite) :
Cofan (fun (_ : X) ↦ (Profinite.of (PUnit.{u + 1}))) :=
Cofan.mk X (fun x ↦ TopCat.ofHom (ContinuousMap.const _ x))
/-- A finite set is the coproduct of its points in `Profinite`. -/
def fintypeCatAsCofanIsColimit (X : Profinite) [Finite X] :
IsColimit (fintypeCatAsCofan X) := by
refine mkCofanColimit _ (fun t ↦ TopCat.ofHom ⟨fun x ↦ t.inj x PUnit.unit, ?_⟩) ?_
(fun _ _ h ↦ by ext x; exact CategoryTheory.congr_fun (h x) _)
· apply continuous_of_discreteTopology (α := X)
· aesop
variable [PreservesFiniteProducts F]
noncomputable instance (X : Profinite) [Finite X] :
PreservesLimitsOfShape (Discrete X) F :=
let X' := (Countable.toSmall.{0} X).equiv_small.choose
let e : X ≃ X' := (Countable.toSmall X).equiv_small.choose_spec.some
have : Finite X' := .of_equiv X e
preservesLimitsOfShape_of_equiv (Discrete.equivalence e.symm) F
/-- Auxiliary definition for `isoFinYoneda`. -/
def isoFinYonedaComponents (X : Profinite.{u}) [Finite X] :
F.obj ⟨X⟩ ≅ (X → F.obj ⟨Profinite.of PUnit.{u + 1}⟩) :=
(isLimitFanMkObjOfIsLimit F _ _
(Cofan.IsColimit.op (fintypeCatAsCofanIsColimit X))).conePointUniqueUpToIso
(Types.productLimitCone.{u, u + 1} fun _ ↦ F.obj ⟨Profinite.of PUnit.{u + 1}⟩).2
lemma isoFinYonedaComponents_hom_apply (X : Profinite.{u}) [Finite X] (y : F.obj ⟨X⟩) (x : X) :
(isoFinYonedaComponents F X).hom y x = F.map ((Profinite.of PUnit.{u + 1}).const x).op y := rfl
lemma isoFinYonedaComponents_inv_comp {X Y : Profinite.{u}} [Finite X] [Finite Y]
(f : Y → F.obj ⟨Profinite.of PUnit⟩) (g : X ⟶ Y) :
(isoFinYonedaComponents F X).inv (f ∘ g) = F.map g.op ((isoFinYonedaComponents F Y).inv f) := by
apply injective_of_mono (isoFinYonedaComponents F X).hom
simp only [CategoryTheory.inv_hom_id_apply]
ext x
rw [isoFinYonedaComponents_hom_apply]
simp only [← FunctorToTypes.map_comp_apply, ← op_comp, CompHausLike.const_comp,
← isoFinYonedaComponents_hom_apply, CategoryTheory.inv_hom_id_apply, Function.comp_apply]
/--
The restriction of a finite-product-preserving presheaf `F` on `Profinite` to the category of
finite sets is isomorphic to `finYoneda F`.
-/
@[simps!]
def isoFinYoneda : toProfinite.op ⋙ F ≅ finYoneda F :=
NatIso.ofComponents (fun X ↦ isoFinYonedaComponents F (toProfinite.obj X.unop)) fun _ ↦ by
simp only [comp_obj, op_obj, finYoneda_obj, Functor.comp_map, op_map]
ext
simp only [types_comp_apply, isoFinYonedaComponents_hom_apply, finYoneda_map,
op_obj, Function.comp_apply, ← FunctorToTypes.map_comp_apply]
rfl
/--
A presheaf `F`, which takes a profinite set written as a cofiltered limit to the corresponding
colimit, is isomorphic to the presheaf `LocallyConstant - F(*)`.
-/
def isoLocallyConstantOfIsColimit
(hF : ∀ S : Profinite, IsColimit <| F.mapCocone S.asLimitCone.op) :
F ≅ (locallyConstantPresheaf (F.obj (toProfinite.op.obj ⟨of PUnit.{u + 1}⟩))) :=
(lanPresheafNatIso hF).symm ≪≫
lanPresheafExt (isoFinYoneda F ≪≫ (locallyConstantIsoFinYoneda F).symm) ≪≫
lanPresheafNatIso fun _ ↦ isColimitLocallyConstantPresheafDiagram _ _
lemma isoLocallyConstantOfIsColimit_inv (X : Profinite.{u}ᵒᵖ ⥤ Type (u + 1))
[PreservesFiniteProducts X]
(hX : ∀ S : Profinite.{u}, (IsColimit <| X.mapCocone S.asLimitCone.op)) :
(isoLocallyConstantOfIsColimit X hX).inv =
(CompHausLike.LocallyConstant.counitApp.{u, u + 1} X) := by
dsimp [isoLocallyConstantOfIsColimit]
simp only [Category.assoc]
rw [Iso.inv_comp_eq]
ext S : 2
apply colimit.hom_ext
intro ⟨Y, _, g⟩
suffices _ ≫ (isoFinYonedaComponents _ _).inv ≫ X.map g =
(locallyConstantPresheaf _).map g ≫ counitAppApp (Opposite.unop S) X by
simpa [locallyConstantIsoFinYoneda, isoFinYoneda, counitApp]
erw [(counitApp.{u, u + 1} X).naturality]
simp only [← Category.assoc, op_obj, functorToPresheaves_obj_obj]
congr
ext f
simp only [types_comp_apply, counitApp_app]
apply presheaf_ext.{u, u + 1} (X := X) (Y := X) (f := f)
intro x
rw [incl_of_counitAppApp]
simp only [counitAppAppImage]
letI : Fintype (fiber.{u, u + 1} f x) :=
Fintype.ofInjective (sigmaIncl.{u, u + 1} f x).1 Subtype.val_injective
apply injective_of_mono (isoFinYonedaComponents X (fiber.{u, u + 1} f x)).hom
ext y
simp only [isoFinYonedaComponents_hom_apply, ← FunctorToTypes.map_comp_apply, ← op_comp]
rw [show (Profinite.of PUnit.{u + 1}).const y ≫ IsTerminal.from _ (fiber f x) = 𝟙 _ from rfl]
simp only [op_comp, FunctorToTypes.map_comp_apply, op_id, FunctorToTypes.map_id_apply]
rw [← isoFinYonedaComponents_inv_comp X _ (sigmaIncl.{u, u + 1} f x)]
simpa [← isoFinYonedaComponents_hom_apply] using x.map_eq_image f y
end Condensed
namespace LightCondensed
section LocallyConstantAsColimit
variable {F : ℕᵒᵖ ⥤ FintypeCat.{u}} (c : Cone <| F ⋙ toLightProfinite) (X : Type u)
/-- The presheaf on `LightProfinite` of locally constant functions to `X`. -/
abbrev locallyConstantPresheaf : LightProfiniteᵒᵖ ⥤ Type u :=
CompHausLike.LocallyConstant.functorToPresheaves.{u, u}.obj X
/--
The functor `locallyConstantPresheaf` takes sequential limits of finite sets with surjective
projection maps to colimits.
-/
noncomputable def isColimitLocallyConstantPresheaf (hc : IsLimit c) [∀ i, Epi (c.π.app i)] :
IsColimit <| (locallyConstantPresheaf X).mapCocone c.op := by
refine Types.FilteredColimit.isColimitOf _ _ ?_ ?_
· intro (f : LocallyConstant c.pt X)
obtain ⟨j, h⟩ := Profinite.exists_locallyConstant.{_, 0} (lightToProfinite.mapCone c)
(isLimitOfPreserves lightToProfinite hc) f
exact ⟨⟨j⟩, h⟩
· intro ⟨i⟩ ⟨j⟩ (fi : LocallyConstant _ _) (fj : LocallyConstant _ _)
(h : fi.comap (c.π.app i).hom = fj.comap (c.π.app j).hom)
obtain ⟨k, ki, kj, _⟩ := IsCofilteredOrEmpty.cone_objs i j
refine ⟨⟨k⟩, ki.op, kj.op, ?_⟩
dsimp
ext x
obtain ⟨x, hx⟩ := ((LightProfinite.epi_iff_surjective (c.π.app k)).mp inferInstance) x
rw [← hx]
change fi ((c.π.app k ≫ (F ⋙ toLightProfinite).map _) x) =
fj ((c.π.app k ≫ (F ⋙ toLightProfinite).map _) x)
have h := LocallyConstant.congr_fun h x
rwa [c.w, c.w]
@[simp]
lemma isColimitLocallyConstantPresheaf_desc_apply (hc : IsLimit c) [∀ i, Epi (c.π.app i)]
(s : Cocone ((F ⋙ toLightProfinite).op ⋙ locallyConstantPresheaf X))
(n : ℕᵒᵖ) (f : LocallyConstant (toLightProfinite.obj (F.obj n)) X) :
(isColimitLocallyConstantPresheaf c X hc).desc s (f.comap (c.π.app n).hom) = s.ι.app ⟨n⟩ f := by
change ((((locallyConstantPresheaf X).mapCocone c.op).ι.app ⟨n⟩) ≫
(isColimitLocallyConstantPresheaf c X hc).desc s) _ = _
rw [(isColimitLocallyConstantPresheaf c X hc).fac]
/-- `isColimitLocallyConstantPresheaf` in the case of `S.asLimit`. -/
noncomputable def isColimitLocallyConstantPresheafDiagram (S : LightProfinite) :
IsColimit <| (locallyConstantPresheaf X).mapCocone (coconeRightOpOfCone S.asLimitCone) :=
(Functor.Final.isColimitWhiskerEquiv (opOpEquivalence ℕ).inverse _).symm
(isColimitLocallyConstantPresheaf _ _ S.asLimit)
@[simp]
lemma isColimitLocallyConstantPresheafDiagram_desc_apply (S : LightProfinite)
(s : Cocone (S.diagram.rightOp ⋙ locallyConstantPresheaf X))
(n : ℕ) (f : LocallyConstant (S.diagram.obj ⟨n⟩) X) :
(isColimitLocallyConstantPresheafDiagram X S).desc s (f.comap (S.asLimitCone.π.app ⟨n⟩).hom) =
s.ι.app n f := by
change ((((locallyConstantPresheaf X).mapCocone (coconeRightOpOfCone S.asLimitCone)).ι.app n) ≫
(isColimitLocallyConstantPresheafDiagram X S).desc s) _ = _
rw [(isColimitLocallyConstantPresheafDiagram X S).fac]
end LocallyConstantAsColimit
instance (S : LightProfinite.{u}ᵒᵖ) :
HasColimitsOfShape (CostructuredArrow toLightProfinite.op S) (Type u) :=
hasColimitsOfShape_of_equivalence (asEquivalence (CostructuredArrow.pre Skeleton.incl.op _ S))
/--
Given a presheaf `F` on `LightProfinite`, `lanPresheaf F` is the left Kan extension of its
restriction to finite sets along the inclusion functor of finite sets into `Profinite`.
-/
abbrev lanPresheaf (F : LightProfinite.{u}ᵒᵖ ⥤ Type u) : LightProfinite.{u}ᵒᵖ ⥤ Type u :=
pointwiseLeftKanExtension toLightProfinite.op (toLightProfinite.op ⋙ F)
/--
To presheaves on `LightProfinite` whose restrictions to finite sets are isomorphic have isomorphic
left Kan extensions.
-/
def lanPresheafExt {F G : LightProfinite.{u}ᵒᵖ ⥤ Type u}
(i : toLightProfinite.op ⋙ F ≅ toLightProfinite.op ⋙ G) : lanPresheaf F ≅ lanPresheaf G :=
leftKanExtensionUniqueOfIso _ (pointwiseLeftKanExtensionUnit _ _) i _
(pointwiseLeftKanExtensionUnit _ _)
@[simp]
lemma lanPresheafExt_hom {F G : LightProfinite.{u}ᵒᵖ ⥤ Type u} (S : LightProfinite.{u}ᵒᵖ)
(i : toLightProfinite.op ⋙ F ≅ toLightProfinite.op ⋙ G) : (lanPresheafExt i).hom.app S =
colimMap (whiskerLeft (CostructuredArrow.proj toLightProfinite.op S) i.hom) := by
simp only [lanPresheaf, pointwiseLeftKanExtension_obj, lanPresheafExt,
leftKanExtensionUniqueOfIso_hom, pointwiseLeftKanExtension_desc_app]
apply colimit.hom_ext
aesop
@[simp]
lemma lanPresheafExt_inv {F G : LightProfinite.{u}ᵒᵖ ⥤ Type u} (S : LightProfinite.{u}ᵒᵖ)
(i : toLightProfinite.op ⋙ F ≅ toLightProfinite.op ⋙ G) : (lanPresheafExt i).inv.app S =
colimMap (whiskerLeft (CostructuredArrow.proj toLightProfinite.op S) i.inv) := by
simp only [lanPresheaf, pointwiseLeftKanExtension_obj, lanPresheafExt,
leftKanExtensionUniqueOfIso_inv, pointwiseLeftKanExtension_desc_app]
apply colimit.hom_ext
aesop
variable {S : LightProfinite.{u}} {F : LightProfinite.{u}ᵒᵖ ⥤ Type u}
instance : Final <| LightProfinite.Extend.functorOp S.asLimitCone :=
LightProfinite.Extend.functorOp_final S.asLimitCone S.asLimit
/--
A presheaf, which takes a light profinite set written as a sequential limit to the corresponding
colimit, agrees with the left Kan extension of its restriction.
-/
def lanPresheafIso (hF : IsColimit <| F.mapCocone (coconeRightOpOfCone S.asLimitCone)) :
(lanPresheaf F).obj ⟨S⟩ ≅ F.obj ⟨S⟩ :=
(Functor.Final.colimitIso (LightProfinite.Extend.functorOp S.asLimitCone) _).symm ≪≫
(colimit.isColimit _).coconePointUniqueUpToIso hF
@[simp]
lemma lanPresheafIso_hom (hF : IsColimit <| F.mapCocone (coconeRightOpOfCone S.asLimitCone)) :
(lanPresheafIso hF).hom = colimit.desc _ (LightProfinite.Extend.cocone _ _) := by
simp [lanPresheafIso, Final.colimitIso]
rfl
/-- `lanPresheafIso` is natural in `S`. -/
def lanPresheafNatIso
(hF : ∀ S : LightProfinite, IsColimit <| F.mapCocone (coconeRightOpOfCone S.asLimitCone)) :
lanPresheaf F ≅ F := by
refine NatIso.ofComponents
(fun ⟨S⟩ ↦ (lanPresheafIso (hF S))) fun _ ↦ ?_
simp only [lanPresheaf, pointwiseLeftKanExtension_obj, pointwiseLeftKanExtension_map,
lanPresheafIso_hom, Opposite.op_unop]
exact colimit.hom_ext fun _ ↦ (by simp)
@[simp]
lemma lanPresheafNatIso_hom_app
(hF : ∀ S : LightProfinite, IsColimit <| F.mapCocone (coconeRightOpOfCone S.asLimitCone))
(S : LightProfiniteᵒᵖ) : (lanPresheafNatIso hF).hom.app S =
colimit.desc _ (LightProfinite.Extend.cocone _ _) := by
simp [lanPresheafNatIso]
/--
`lanPresheaf (locallyConstantPresheaf X)` as a light condensed set.
-/
def lanLightCondSet (X : Type u) : LightCondSet.{u} where
val := lanPresheaf (locallyConstantPresheaf X)
cond := by
rw [Presheaf.isSheaf_of_iso_iff (lanPresheafNatIso
fun _ ↦ isColimitLocallyConstantPresheafDiagram _ _)]
exact (CompHausLike.LocallyConstant.functor.{u, u}
(hs := fun _ _ _ ↦ ((LightProfinite.effectiveEpi_iff_surjective _).mp)).obj X).cond
variable (F : LightProfinite.{u}ᵒᵖ ⥤ Type u)
/--
The functor which takes a finite set to the set of maps into `F(*)` for a presheaf `F` on
`LightProfinite`.
-/
@[simps]
def finYoneda : FintypeCat.{u}ᵒᵖ ⥤ Type u where
obj X := X.unop → F.obj (toLightProfinite.op.obj ⟨of PUnit.{u + 1}⟩)
map f g := g ∘ f.unop
/-- `locallyConstantPresheaf` restricted to finite sets is isomorphic to `finYoneda F`. -/
def locallyConstantIsoFinYoneda : toLightProfinite.op ⋙
(locallyConstantPresheaf (F.obj (toLightProfinite.op.obj ⟨of PUnit.{u + 1}⟩))) ≅ finYoneda F :=
NatIso.ofComponents fun Y ↦ {
hom := fun f ↦ f.1
inv := fun f ↦ ⟨f, @IsLocallyConstant.of_discrete _ _ _ ⟨rfl⟩ _⟩ }
/-- A finite set as a coproduct cocone in `LightProfinite` over itself. -/
def fintypeCatAsCofan (X : LightProfinite) :
Cofan (fun (_ : X) ↦ (LightProfinite.of (PUnit.{u + 1}))) :=
Cofan.mk X (fun x ↦ TopCat.ofHom (ContinuousMap.const _ x))
/-- A finite set is the coproduct of its points in `LightProfinite`. -/
def fintypeCatAsCofanIsColimit (X : LightProfinite) [Finite X] :
IsColimit (fintypeCatAsCofan X) := by
refine mkCofanColimit _ (fun t ↦ TopCat.ofHom ⟨fun x ↦ t.inj x PUnit.unit, ?_⟩) ?_
(fun _ _ h ↦ by ext x; exact CategoryTheory.congr_fun (h x) _)
· apply continuous_of_discreteTopology (α := X)
· aesop
variable [PreservesFiniteProducts F]
noncomputable instance (X : FintypeCat.{u}) : PreservesLimitsOfShape (Discrete X) F :=
let X' := (Countable.toSmall.{0} X).equiv_small.choose
let e : X ≃ X' := (Countable.toSmall X).equiv_small.choose_spec.some
have : Fintype X' := Fintype.ofEquiv X e
preservesLimitsOfShape_of_equiv (Discrete.equivalence e.symm) F
/-- Auxiliary definition for `isoFinYoneda`. -/
def isoFinYonedaComponents (X : LightProfinite.{u}) [Finite X] :
F.obj ⟨X⟩ ≅ (X → F.obj ⟨LightProfinite.of PUnit.{u + 1}⟩) :=
(isLimitFanMkObjOfIsLimit F _ _
(Cofan.IsColimit.op (fintypeCatAsCofanIsColimit X))).conePointUniqueUpToIso
(Types.productLimitCone.{u, u} fun _ ↦ F.obj ⟨LightProfinite.of PUnit.{u + 1}⟩).2
lemma isoFinYonedaComponents_hom_apply (X : LightProfinite.{u}) [Finite X] (y : F.obj ⟨X⟩)
(x : X) : (isoFinYonedaComponents F X).hom y x =
F.map ((LightProfinite.of PUnit.{u + 1}).const x).op y := rfl
lemma isoFinYonedaComponents_inv_comp {X Y : LightProfinite.{u}} [Finite X] [Finite Y]
(f : Y → F.obj ⟨LightProfinite.of PUnit⟩) (g : X ⟶ Y) :
(isoFinYonedaComponents F X).inv (f ∘ g) = F.map g.op ((isoFinYonedaComponents F Y).inv f) := by
apply injective_of_mono (isoFinYonedaComponents F X).hom
simp only [CategoryTheory.inv_hom_id_apply]
ext x
rw [isoFinYonedaComponents_hom_apply]
simp only [← FunctorToTypes.map_comp_apply, ← op_comp, CompHausLike.const_comp,
← isoFinYonedaComponents_hom_apply, CategoryTheory.inv_hom_id_apply, Function.comp_apply]
/--
The restriction of a finite-product-preserving presheaf `F` on `Profinite` to the category of
finite sets is isomorphic to `finYoneda F`.
-/
@[simps!]
def isoFinYoneda : toLightProfinite.op ⋙ F ≅ finYoneda F :=
NatIso.ofComponents (fun X ↦ isoFinYonedaComponents F (toLightProfinite.obj X.unop)) fun _ ↦ by
simp only [comp_obj, op_obj, finYoneda_obj, Functor.comp_map, op_map]
ext
simp only [types_comp_apply, isoFinYonedaComponents_hom_apply, finYoneda_map, op_obj,
Function.comp_apply,
← FunctorToTypes.map_comp_apply]
rfl
/--
A presheaf `F`, which takes a light profinite set written as a sequential limit to the corresponding
colimit, is isomorphic to the presheaf `LocallyConstant - F(*)`.
-/
def isoLocallyConstantOfIsColimit (hF : ∀ S : LightProfinite, IsColimit <|
F.mapCocone (coconeRightOpOfCone S.asLimitCone)) :
F ≅ (locallyConstantPresheaf
(F.obj (toLightProfinite.op.obj ⟨of PUnit.{u + 1}⟩))) :=
(lanPresheafNatIso hF).symm ≪≫
lanPresheafExt (isoFinYoneda F ≪≫ (locallyConstantIsoFinYoneda F).symm) ≪≫
lanPresheafNatIso fun _ ↦ isColimitLocallyConstantPresheafDiagram _ _
lemma isoLocallyConstantOfIsColimit_inv (X : LightProfinite.{u}ᵒᵖ ⥤ Type u)
[PreservesFiniteProducts X] (hX : ∀ S : LightProfinite.{u}, (IsColimit <|
X.mapCocone (coconeRightOpOfCone S.asLimitCone))) :
(isoLocallyConstantOfIsColimit X hX).inv =
(CompHausLike.LocallyConstant.counitApp.{u, u} X) := by
dsimp [isoLocallyConstantOfIsColimit]
simp only [Category.assoc]
rw [Iso.inv_comp_eq]
ext S : 2
apply colimit.hom_ext
intro ⟨Y, _, g⟩
suffices _ ≫ (isoFinYonedaComponents _ _).inv ≫ X.map g =
(locallyConstantPresheaf _).map g ≫ counitAppApp (Opposite.unop S) X by
simpa [locallyConstantIsoFinYoneda, isoFinYoneda, counitApp]
erw [(counitApp.{u, u} X).naturality]
simp only [← Category.assoc, op_obj, functorToPresheaves_obj_obj]
congr
ext f
simp only [types_comp_apply, counitApp_app]
apply presheaf_ext.{u, u} (X := X) (Y := X) (f := f)
intro x
rw [incl_of_counitAppApp]
simp only [counitAppAppImage]
letI : Fintype (fiber.{u, u} f x) :=
Fintype.ofInjective (sigmaIncl.{u, u} f x).1 Subtype.val_injective
apply injective_of_mono (isoFinYonedaComponents X (fiber.{u, u} f x)).hom
ext y
simp only [isoFinYonedaComponents_hom_apply, ← FunctorToTypes.map_comp_apply, ← op_comp]
rw [show (LightProfinite.of PUnit.{u + 1}).const y ≫ IsTerminal.from _ (fiber f x) = 𝟙 _ from rfl]
simp only [op_comp, FunctorToTypes.map_comp_apply, op_id, FunctorToTypes.map_id_apply]
rw [← isoFinYonedaComponents_inv_comp X _ (sigmaIncl.{u, u} f x)]
simpa [← isoFinYonedaComponents_hom_apply] using x.map_eq_image f y
end LightCondensed |
.lake/packages/mathlib/Mathlib/Condensed/Discrete/Characterization.lean | import Mathlib.Condensed.Discrete.Colimit
import Mathlib.Condensed.Discrete.Module
/-!
# Characterizing discrete condensed sets and `R`-modules.
This file proves a characterization of discrete condensed sets, discrete condensed `R`-modules over
a ring `R`, discrete light condensed sets, and discrete light condensed `R`-modules over a ring `R`.
see `CondensedSet.isDiscrete_tfae`, `CondensedMod.isDiscrete_tfae`, `LightCondSet.isDiscrete_tfae`,
and `LightCondMod.isDiscrete_tfae`.
Informally, we can say: The following conditions characterize a condensed set `X` as discrete
(`CondensedSet.isDiscrete_tfae`):
1. There exists a set `X'` and an isomorphism `X ≅ cst X'`, where `cst X'` denotes the constant
sheaf on `X'`.
2. The counit induces an isomorphism `cst X(*) ⟶ X`.
3. There exists a set `X'` and an isomorphism `X ≅ LocallyConstant · X'`.
4. The counit induces an isomorphism `LocallyConstant · X(*) ⟶ X`.
5. For every profinite set `S = limᵢSᵢ`, the canonical map `colimᵢX(Sᵢ) ⟶ X(S)` is an isomorphism.
The analogues for light condensed sets, condensed `R`-modules over any ring, and light
condensed `R`-modules are nearly identical (`CondensedMod.isDiscrete_tfae`,
`LightCondSet.isDiscrete_tfae`, and `LightCondMod.isDiscrete_tfae`).
-/
universe u
open CategoryTheory Limits Functor FintypeCat
namespace Condensed
variable {C : Type*} [Category C] [HasWeakSheafify (coherentTopology CompHaus.{u}) C]
/--
A condensed object is *discrete* if it is constant as a sheaf, i.e. isomorphic to a constant sheaf.
-/
abbrev IsDiscrete (X : Condensed.{u} C) := X.IsConstant (coherentTopology CompHaus)
end Condensed
namespace CondensedSet
open CompHausLike.LocallyConstant
lemma mem_locallyConstant_essImage_of_isColimit_mapCocone (X : CondensedSet.{u})
(h : ∀ S : Profinite.{u}, IsColimit <|
(profiniteToCompHaus.op ⋙ X.val).mapCocone S.asLimitCone.op) :
CondensedSet.LocallyConstant.functor.essImage X := by
let e : CondensedSet.{u} ≌ Sheaf (coherentTopology Profinite) _ :=
(Condensed.ProfiniteCompHaus.equivalence (Type (u + 1))).symm
let i : (e.functor.obj X).val ≅ (e.functor.obj (LocallyConstant.functor.obj _)).val :=
Condensed.isoLocallyConstantOfIsColimit _ h
exact ⟨_, ⟨e.functor.preimageIso ((sheafToPresheaf _ _).preimageIso i.symm)⟩⟩
/--
`CondensedSet.LocallyConstant.functor` is left adjoint to the forgetful functor from condensed
sets to sets.
-/
noncomputable abbrev LocallyConstant.adjunction :
CondensedSet.LocallyConstant.functor ⊣ Condensed.underlying (Type (u + 1)) :=
CompHausLike.LocallyConstant.adjunction _ _
open Condensed
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
open CondensedSet.LocallyConstant List in
theorem isDiscrete_tfae (X : CondensedSet.{u}) :
TFAE
[ X.IsDiscrete
, IsIso ((Condensed.discreteUnderlyingAdj _).counit.app X)
, (Condensed.discrete _).essImage X
, CondensedSet.LocallyConstant.functor.essImage X
, IsIso (CondensedSet.LocallyConstant.adjunction.counit.app X)
, Sheaf.IsConstant (coherentTopology Profinite)
((Condensed.ProfiniteCompHaus.equivalence _).inverse.obj X)
, ∀ S : Profinite.{u}, Nonempty
(IsColimit <| (profiniteToCompHaus.op ⋙ X.val).mapCocone S.asLimitCone.op)
] := by
tfae_have 1 ↔ 2 := Sheaf.isConstant_iff_isIso_counit_app _ _ _
tfae_have 1 ↔ 3 := ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩
tfae_have 1 ↔ 4 := Sheaf.isConstant_iff_mem_essImage _ CompHaus.isTerminalPUnit adjunction _
tfae_have 1 ↔ 5 :=
have : functor.Faithful := inferInstance
have : functor.Full := inferInstance
-- These `have` statements above shouldn't be needed, but they are.
Sheaf.isConstant_iff_isIso_counit_app' _ CompHaus.isTerminalPUnit adjunction _
tfae_have 1 ↔ 6 :=
(Sheaf.isConstant_iff_of_equivalence (coherentTopology Profinite)
(coherentTopology CompHaus) profiniteToCompHaus Profinite.isTerminalPUnit
CompHaus.isTerminalPUnit _).symm
tfae_have 7 → 4 := fun h ↦
mem_locallyConstant_essImage_of_isColimit_mapCocone X (fun S ↦ (h S).some)
tfae_have 4 → 7 := fun ⟨Y, ⟨i⟩⟩ S ↦
⟨IsColimit.mapCoconeEquiv (isoWhiskerLeft profiniteToCompHaus.op
((sheafToPresheaf _ _).mapIso i))
(Condensed.isColimitLocallyConstantPresheafDiagram Y S)⟩
tfae_finish
end CondensedSet
namespace CondensedMod
variable (R : Type (u + 1)) [Ring R]
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma isDiscrete_iff_isDiscrete_forget (M : CondensedMod R) :
M.IsDiscrete ↔ ((Condensed.forget R).obj M).IsDiscrete :=
Sheaf.isConstant_iff_forget (coherentTopology CompHaus)
(forget (ModuleCat R)) M CompHaus.isTerminalPUnit
instance : HasLimitsOfSize.{u, u + 1} (ModuleCat.{u + 1} R) :=
hasLimitsOfSizeShrink.{u, u + 1, u + 1, u + 1} _
open CondensedMod.LocallyConstant List in
theorem isDiscrete_tfae (M : CondensedMod.{u} R) :
TFAE
[ M.IsDiscrete
, IsIso ((Condensed.discreteUnderlyingAdj _).counit.app M)
, (Condensed.discrete _).essImage M
, (CondensedMod.LocallyConstant.functor R).essImage M
, IsIso ((CondensedMod.LocallyConstant.adjunction R).counit.app M)
, Sheaf.IsConstant (coherentTopology Profinite)
((Condensed.ProfiniteCompHaus.equivalence _).inverse.obj M)
, ∀ S : Profinite.{u}, Nonempty
(IsColimit <| (profiniteToCompHaus.op ⋙ M.val).mapCocone S.asLimitCone.op)
] := by
tfae_have 1 ↔ 2 := Sheaf.isConstant_iff_isIso_counit_app _ _ _
tfae_have 1 ↔ 3 := ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩
tfae_have 1 ↔ 4 := Sheaf.isConstant_iff_mem_essImage _ CompHaus.isTerminalPUnit (adjunction R) _
tfae_have 1 ↔ 5 :=
have : (functor R).Faithful := inferInstance
have : (functor R).Full := inferInstance
-- These `have` statements above shouldn't be needed, but they are.
Sheaf.isConstant_iff_isIso_counit_app' _ CompHaus.isTerminalPUnit (adjunction R) _
tfae_have 1 ↔ 6 :=
(Sheaf.isConstant_iff_of_equivalence (coherentTopology Profinite)
(coherentTopology CompHaus) profiniteToCompHaus Profinite.isTerminalPUnit
CompHaus.isTerminalPUnit _).symm
tfae_have 7 → 1 := by
intro h
rw [isDiscrete_iff_isDiscrete_forget, ((CondensedSet.isDiscrete_tfae _).out 0 6:)]
intro S
letI : PreservesFilteredColimitsOfSize.{u, u} (forget (ModuleCat R)) :=
preservesFilteredColimitsOfSize_shrink.{u, u + 1, u, u + 1} _
exact ⟨isColimitOfPreserves (forget (ModuleCat R)) (h S).some⟩
tfae_have 1 → 7 := by
intro h S
rw [isDiscrete_iff_isDiscrete_forget, ((CondensedSet.isDiscrete_tfae _).out 0 6:)] at h
letI : ReflectsFilteredColimitsOfSize.{u, u} (forget (ModuleCat R)) :=
reflectsFilteredColimitsOfSize_shrink.{u, u + 1, u, u + 1} _
exact ⟨isColimitOfReflects (forget (ModuleCat R)) (h S).some⟩
tfae_finish
end CondensedMod
namespace LightCondensed
variable {C : Type*} [Category C] [HasWeakSheafify (coherentTopology LightProfinite.{u}) C]
/--
A light condensed object is *discrete* if it is constant as a sheaf, i.e. isomorphic to a constant
sheaf.
-/
abbrev IsDiscrete (X : LightCondensed.{u} C) := X.IsConstant (coherentTopology LightProfinite)
end LightCondensed
namespace LightCondSet
lemma mem_locallyConstant_essImage_of_isColimit_mapCocone (X : LightCondSet.{u})
(h : ∀ S : LightProfinite.{u}, IsColimit <|
X.val.mapCocone (coconeRightOpOfCone S.asLimitCone)) :
LightCondSet.LocallyConstant.functor.essImage X := by
let i : X.val ≅ (LightCondSet.LocallyConstant.functor.obj _).val :=
LightCondensed.isoLocallyConstantOfIsColimit _ h
exact ⟨_, ⟨((sheafToPresheaf _ _).preimageIso i.symm)⟩⟩
/--
`LightCondSet.LocallyConstant.functor` is left adjoint to the forgetful functor from light condensed
sets to sets.
-/
noncomputable abbrev LocallyConstant.adjunction :
LightCondSet.LocallyConstant.functor ⊣ LightCondensed.underlying (Type u) :=
CompHausLike.LocallyConstant.adjunction _ _
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
open LightCondSet.LocallyConstant List in
theorem isDiscrete_tfae (X : LightCondSet.{u}) :
TFAE
[ X.IsDiscrete
, IsIso ((LightCondensed.discreteUnderlyingAdj _).counit.app X)
, (LightCondensed.discrete _).essImage X
, LightCondSet.LocallyConstant.functor.essImage X
, IsIso (LightCondSet.LocallyConstant.adjunction.counit.app X)
, ∀ S : LightProfinite.{u}, Nonempty
(IsColimit <| X.val.mapCocone (coconeRightOpOfCone S.asLimitCone))
] := by
tfae_have 1 ↔ 2 := Sheaf.isConstant_iff_isIso_counit_app _ _ _
tfae_have 1 ↔ 3 := ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩
tfae_have 1 ↔ 4 := Sheaf.isConstant_iff_mem_essImage _ LightProfinite.isTerminalPUnit adjunction X
tfae_have 1 ↔ 5 :=
have : functor.Faithful := inferInstance
have : functor.Full := inferInstance
-- These `have` statements above shouldn't be needed, but they are.
Sheaf.isConstant_iff_isIso_counit_app' _ LightProfinite.isTerminalPUnit adjunction X
tfae_have 6 → 4 := fun h ↦
mem_locallyConstant_essImage_of_isColimit_mapCocone X (fun S ↦ (h S).some)
tfae_have 4 → 6 := fun ⟨Y, ⟨i⟩⟩ S ↦
⟨IsColimit.mapCoconeEquiv ((sheafToPresheaf _ _).mapIso i)
(LightCondensed.isColimitLocallyConstantPresheafDiagram Y S)⟩
tfae_finish
end LightCondSet
namespace LightCondMod
variable (R : Type u) [Ring R]
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma isDiscrete_iff_isDiscrete_forget (M : LightCondMod R) :
M.IsDiscrete ↔ ((LightCondensed.forget R).obj M).IsDiscrete :=
Sheaf.isConstant_iff_forget (coherentTopology LightProfinite)
(forget (ModuleCat R)) M LightProfinite.isTerminalPUnit
open LightCondMod.LocallyConstant List in
theorem isDiscrete_tfae (M : LightCondMod.{u} R) :
TFAE
[ M.IsDiscrete
, IsIso ((LightCondensed.discreteUnderlyingAdj _).counit.app M)
, (LightCondensed.discrete _).essImage M
, (LightCondMod.LocallyConstant.functor R).essImage M
, IsIso ((LightCondMod.LocallyConstant.adjunction R).counit.app M)
, ∀ S : LightProfinite.{u}, Nonempty
(IsColimit <| M.val.mapCocone (coconeRightOpOfCone S.asLimitCone))
] := by
tfae_have 1 ↔ 2 := Sheaf.isConstant_iff_isIso_counit_app _ _ _
tfae_have 1 ↔ 3 := ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩
tfae_have 1 ↔ 4 := Sheaf.isConstant_iff_mem_essImage _
LightProfinite.isTerminalPUnit (adjunction R) _
tfae_have 1 ↔ 5 :=
have : (functor R).Faithful := inferInstance
have : (functor R).Full := inferInstance
-- These `have` statements above shouldn't be needed, but they are.
Sheaf.isConstant_iff_isIso_counit_app' _ LightProfinite.isTerminalPUnit (adjunction R) _
tfae_have 6 → 1 := by
intro h
rw [isDiscrete_iff_isDiscrete_forget, ((LightCondSet.isDiscrete_tfae _).out 0 5:)]
intro S
letI : PreservesFilteredColimitsOfSize.{0, 0} (forget (ModuleCat R)) :=
preservesFilteredColimitsOfSize_shrink.{0, u, 0, u} _
exact ⟨isColimitOfPreserves (forget (ModuleCat R)) (h S).some⟩
tfae_have 1 → 6 := by
intro h S
rw [isDiscrete_iff_isDiscrete_forget, ((LightCondSet.isDiscrete_tfae _).out 0 5:)] at h
letI : ReflectsFilteredColimitsOfSize.{0, 0} (forget (ModuleCat R)) :=
reflectsFilteredColimitsOfSize_shrink.{0, u, 0, u} _
exact ⟨isColimitOfReflects (forget (ModuleCat R)) (h S).some⟩
tfae_finish
end LightCondMod |
.lake/packages/mathlib/Mathlib/Condensed/Discrete/Module.lean | import Mathlib.CategoryTheory.Sites.ConstantSheaf
import Mathlib.Condensed.Discrete.LocallyConstant
import Mathlib.Condensed.Light.Module
import Mathlib.Condensed.Module
import Mathlib.Topology.LocallyConstant.Algebra
/-!
# Discrete condensed `R`-modules
This file provides the necessary API to prove that a condensed `R`-module is discrete if and only
if the underlying condensed set is (both for light condensed and condensed).
That is, it defines the functor `CondensedMod.LocallyConstant.functor` which takes an `R`-module to
the condensed `R`-modules given by locally constant maps to it, and proves that this functor is
naturally isomorphic to the constant sheaf functor (and the analogues for light condensed modules).
-/
universe w u
open CategoryTheory LocallyConstant CompHausLike Functor Category Functor Opposite
variable {P : TopCat.{u} → Prop}
namespace CompHausLike.LocallyConstantModule
variable (R : Type (max u w)) [Ring R]
/--
The functor from the category of `R`-modules to presheaves on `CompHausLike P` given by locally
constant maps.
-/
@[simps]
def functorToPresheaves : ModuleCat.{max u w} R ⥤ ((CompHausLike.{u} P)ᵒᵖ ⥤ ModuleCat R) where
obj X := {
obj := fun ⟨S⟩ ↦ ModuleCat.of R (LocallyConstant S X)
map := fun f ↦ ModuleCat.ofHom (comapₗ R f.unop.hom) }
map f := { app := fun S ↦ ModuleCat.ofHom (mapₗ R f.hom) }
variable [HasExplicitFiniteCoproducts.{0} P] [HasExplicitPullbacks.{u} P]
(hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f)
/-- `CompHausLike.LocallyConstantModule.functorToPresheaves` lands in sheaves. -/
@[simps]
def functor : haveI := CompHausLike.preregular hs
ModuleCat R ⥤ Sheaf (coherentTopology (CompHausLike.{u} P)) (ModuleCat R) where
obj X := {
val := (functorToPresheaves.{w, u} R).obj X
cond := by
have := CompHausLike.preregular hs
apply Presheaf.isSheaf_coherent_of_hasPullbacks_of_comp
(s := CategoryTheory.forget (ModuleCat R))
exact ((CompHausLike.LocallyConstant.functor P hs).obj _).cond }
map f := ⟨(functorToPresheaves.{w, u} R).map f⟩
end CompHausLike.LocallyConstantModule
namespace CondensedMod.LocallyConstant
open Condensed
variable (R : Type (u + 1)) [Ring R]
/-- `functorToPresheaves` in the case of `CompHaus`. -/
abbrev functorToPresheaves : ModuleCat.{u + 1} R ⥤ (CompHaus.{u}ᵒᵖ ⥤ ModuleCat R) :=
CompHausLike.LocallyConstantModule.functorToPresheaves.{u + 1, u} R
/-- `functorToPresheaves` as a functor to condensed modules. -/
abbrev functor : ModuleCat R ⥤ CondensedMod.{u} R :=
CompHausLike.LocallyConstantModule.functor.{u + 1, u} R
(fun _ _ _ ↦ ((CompHaus.effectiveEpi_tfae _).out 0 2).mp)
/-- Auxiliary definition for `functorIsoDiscrete`. -/
noncomputable def functorIsoDiscreteAux₁ (M : ModuleCat.{u + 1} R) :
M ≅ (ModuleCat.of R (LocallyConstant (CompHaus.of PUnit.{u + 1}) M)) where
hom := ModuleCat.ofHom (constₗ R)
inv := ModuleCat.ofHom (evalₗ R PUnit.unit)
/-- Auxiliary definition for `functorIsoDiscrete`. -/
noncomputable def functorIsoDiscreteAux₂ (M : ModuleCat R) :
(discrete _).obj M ≅ (discrete _).obj
(ModuleCat.of R (LocallyConstant (CompHaus.of PUnit.{u + 1}) M)) :=
(discrete _).mapIso (functorIsoDiscreteAux₁ R M)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance (M : ModuleCat R) : IsIso ((forget R).map
((discreteUnderlyingAdj (ModuleCat R)).counit.app ((functor R).obj M))) := by
dsimp [Condensed.forget, discreteUnderlyingAdj]
rw [← constantSheafAdj_counit_w]
refine IsIso.comp_isIso' inferInstance ?_
have : (constantSheaf (coherentTopology CompHaus) (Type (u + 1))).Faithful :=
inferInstanceAs (discrete _).Faithful
have : (constantSheaf (coherentTopology CompHaus) (Type (u + 1))).Full :=
inferInstanceAs (discrete _).Full
rw [← Sheaf.isConstant_iff_isIso_counit_app]
constructor
change (discrete _).essImage _
rw [essImage_eq_of_natIso CondensedSet.LocallyConstant.iso.symm]
exact obj_mem_essImage CondensedSet.LocallyConstant.functor M
/-- Auxiliary definition for `functorIsoDiscrete`. -/
noncomputable def functorIsoDiscreteComponents (M : ModuleCat R) :
(discrete _).obj M ≅ (functor R).obj M :=
have : (Condensed.forget R).ReflectsIsomorphisms :=
inferInstanceAs (sheafCompose _ _).ReflectsIsomorphisms
have : IsIso ((discreteUnderlyingAdj (ModuleCat R)).counit.app ((functor R).obj M)) :=
isIso_of_reflects_iso _ (Condensed.forget R)
functorIsoDiscreteAux₂ R M ≪≫ asIso ((discreteUnderlyingAdj _).counit.app ((functor R).obj M))
/--
`CondensedMod.LocallyConstant.functor` is naturally isomorphic to the constant sheaf functor from
`R`-modules to condensed `R`-modules.
-/
noncomputable def functorIsoDiscrete : functor R ≅ discrete _ :=
NatIso.ofComponents (fun M ↦ (functorIsoDiscreteComponents R M).symm) fun f ↦ by
dsimp
rw [Iso.eq_inv_comp, ← Category.assoc, Iso.comp_inv_eq]
dsimp [functorIsoDiscreteComponents]
rw [assoc, ← Iso.eq_inv_comp,
← (discreteUnderlyingAdj (ModuleCat R)).counit_naturality]
simp only [← assoc]
congr 1
rw [← Iso.comp_inv_eq]
apply Sheaf.hom_ext
simp [functorIsoDiscreteAux₂, ← Functor.map_comp]
rfl
/--
`CondensedMod.LocallyConstant.functor` is left adjoint to the forgetful functor from condensed
`R`-modules to `R`-modules.
-/
noncomputable def adjunction : functor R ⊣ underlying (ModuleCat R) :=
Adjunction.ofNatIsoLeft (discreteUnderlyingAdj _) (functorIsoDiscrete R).symm
/--
`CondensedMod.LocallyConstant.functor` is fully faithful.
-/
noncomputable def fullyFaithfulFunctor : (functor R).FullyFaithful :=
(adjunction R).fullyFaithfulLOfCompIsoId
(NatIso.ofComponents fun M ↦ (functorIsoDiscreteAux₁ R _).symm)
instance : (functor R).Faithful := (fullyFaithfulFunctor R).faithful
instance : (functor R).Full := (fullyFaithfulFunctor R).full
instance : (discrete (ModuleCat R)).Faithful :=
Functor.Faithful.of_iso (functorIsoDiscrete R)
instance : (constantSheaf (coherentTopology CompHaus) (ModuleCat R)).Faithful :=
inferInstanceAs (discrete (ModuleCat R)).Faithful
instance : (discrete (ModuleCat R)).Full :=
Functor.Full.of_iso (functorIsoDiscrete R)
instance : (constantSheaf (coherentTopology CompHaus) (ModuleCat R)).Full :=
inferInstanceAs (discrete (ModuleCat R)).Full
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (constantSheaf (coherentTopology CompHaus) (Type (u + 1))).Faithful :=
inferInstanceAs (discrete (Type (u + 1))).Faithful
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (constantSheaf (coherentTopology CompHaus) (Type (u + 1))).Full :=
inferInstanceAs (discrete (Type (u + 1))).Full
end CondensedMod.LocallyConstant
namespace LightCondMod.LocallyConstant
open LightCondensed
variable (R : Type u) [Ring R]
/-- `functorToPresheaves` in the case of `LightProfinite`. -/
abbrev functorToPresheaves : ModuleCat.{u} R ⥤ (LightProfinite.{u}ᵒᵖ ⥤ ModuleCat R) :=
CompHausLike.LocallyConstantModule.functorToPresheaves.{u, u} R
/-- `functorToPresheaves` as a functor to light condensed modules. -/
abbrev functor : ModuleCat R ⥤ LightCondMod.{u} R :=
CompHausLike.LocallyConstantModule.functor.{u, u} R
(fun _ _ _ ↦ (LightProfinite.effectiveEpi_iff_surjective _).mp)
/-- Auxiliary definition for `functorIsoDiscrete`. -/
noncomputable def functorIsoDiscreteAux₁ (M : ModuleCat.{u} R) :
M ≅ (ModuleCat.of R (LocallyConstant (LightProfinite.of PUnit.{u + 1}) M)) where
hom := ModuleCat.ofHom (constₗ R)
inv := ModuleCat.ofHom (evalₗ R PUnit.unit)
/-- Auxiliary definition for `functorIsoDiscrete`. -/
noncomputable def functorIsoDiscreteAux₂ (M : ModuleCat.{u} R) :
(discrete _).obj M ≅ (discrete _).obj
(ModuleCat.of R (LocallyConstant (LightProfinite.of PUnit.{u + 1}) M)) :=
(discrete _).mapIso (functorIsoDiscreteAux₁ R M)
-- Not stating this explicitly causes timeouts below.
instance : HasSheafify (coherentTopology LightProfinite.{u}) (ModuleCat.{u} R) :=
inferInstance
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance (M : ModuleCat R) :
IsIso ((LightCondensed.forget R).map
((discreteUnderlyingAdj (ModuleCat R)).counit.app
((functor R).obj M))) := by
dsimp [LightCondensed.forget, discreteUnderlyingAdj]
rw [← constantSheafAdj_counit_w]
refine IsIso.comp_isIso' inferInstance ?_
have : (constantSheaf (coherentTopology LightProfinite.{u}) (Type u)).Faithful :=
inferInstanceAs (discrete _).Faithful
have : (constantSheaf (coherentTopology LightProfinite.{u}) (Type u)).Full :=
inferInstanceAs (discrete (Type u)).Full
rw [← Sheaf.isConstant_iff_isIso_counit_app]
constructor
change (discrete _).essImage _
rw [essImage_eq_of_natIso LightCondSet.LocallyConstant.iso.symm]
exact obj_mem_essImage LightCondSet.LocallyConstant.functor M
/-- Auxiliary definition for `functorIsoDiscrete`. -/
noncomputable def functorIsoDiscreteComponents (M : ModuleCat R) :
(discrete _).obj M ≅ (functor R).obj M :=
have : (LightCondensed.forget R).ReflectsIsomorphisms :=
inferInstanceAs (sheafCompose _ _).ReflectsIsomorphisms
have : IsIso ((discreteUnderlyingAdj (ModuleCat R)).counit.app ((functor R).obj M)) :=
isIso_of_reflects_iso _ (LightCondensed.forget R)
functorIsoDiscreteAux₂ R M ≪≫ asIso ((discreteUnderlyingAdj _).counit.app ((functor R).obj M))
/--
`LightCondMod.LocallyConstant.functor` is naturally isomorphic to the constant sheaf functor from
`R`-modules to light condensed `R`-modules.
-/
noncomputable def functorIsoDiscrete : functor R ≅ discrete _ :=
NatIso.ofComponents (fun M ↦ (functorIsoDiscreteComponents R M).symm) fun f ↦ by
dsimp
rw [Iso.eq_inv_comp, ← Category.assoc, Iso.comp_inv_eq]
dsimp [functorIsoDiscreteComponents]
rw [Category.assoc, ← Iso.eq_inv_comp,
← (discreteUnderlyingAdj (ModuleCat R)).counit_naturality]
simp only [← assoc]
congr 1
rw [← Iso.comp_inv_eq]
apply Sheaf.hom_ext
simp [functorIsoDiscreteAux₂, ← Functor.map_comp]
rfl
/--
`LightCondMod.LocallyConstant.functor` is left adjoint to the forgetful functor from light condensed
`R`-modules to `R`-modules.
-/
noncomputable def adjunction : functor R ⊣ underlying (ModuleCat R) :=
Adjunction.ofNatIsoLeft (discreteUnderlyingAdj _) (functorIsoDiscrete R).symm
/--
`LightCondMod.LocallyConstant.functor` is fully faithful.
-/
noncomputable def fullyFaithfulFunctor : (functor R).FullyFaithful :=
(adjunction R).fullyFaithfulLOfCompIsoId
(NatIso.ofComponents fun M ↦ (functorIsoDiscreteAux₁ R _).symm)
instance : (functor R).Faithful := (fullyFaithfulFunctor R).faithful
instance : (functor R).Full := (fullyFaithfulFunctor R).full
instance : (discrete.{u} (ModuleCat R)).Faithful := Functor.Faithful.of_iso (functorIsoDiscrete R)
instance : (constantSheaf (coherentTopology LightProfinite.{u}) (ModuleCat.{u} R)).Faithful :=
inferInstanceAs (discrete.{u} (ModuleCat R)).Faithful
instance : (discrete (ModuleCat.{u} R)).Full :=
Functor.Full.of_iso (functorIsoDiscrete R)
instance : (constantSheaf (coherentTopology LightProfinite.{u}) (ModuleCat.{u} R)).Full :=
inferInstanceAs (discrete.{u} (ModuleCat.{u} R)).Full
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (constantSheaf (coherentTopology LightProfinite.{u}) (Type u)).Faithful :=
inferInstanceAs (discrete (Type u)).Faithful
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (constantSheaf (coherentTopology LightProfinite.{u}) (Type u)).Full :=
inferInstanceAs (discrete (Type u)).Full
end LightCondMod.LocallyConstant |
.lake/packages/mathlib/Mathlib/Condensed/Discrete/Basic.lean | import Mathlib.CategoryTheory.Sites.ConstantSheaf
import Mathlib.CategoryTheory.Sites.Equivalence
import Mathlib.Condensed.Basic
import Mathlib.Condensed.Light.Basic
import Mathlib.Condensed.Light.Instances
/-!
# Discrete-underlying adjunction
Given a category `C` with sheafification with respect to the coherent topology on compact Hausdorff
spaces, we define a functor `C ⥤ Condensed C` which associates to an object of `C` the
corresponding "discrete" condensed object (see `Condensed.discrete`).
In `Condensed.discreteUnderlyingAdj` we prove that this functor is left adjoint to the forgetful
functor from `Condensed C` to `C`.
We also give the variant `LightCondensed.discreteUnderlyingAdj` for light condensed objects.
The file `Mathlib/Condensed/Discrete/Characterization.lean` defines a predicate `IsDiscrete` on
condensed and light condensed objects, and provides several conditions on a (light) condensed
set or module that characterize it as discrete.
-/
universe u v w
open CategoryTheory Limits Opposite GrothendieckTopology
namespace Condensed
variable (C : Type w) [Category.{u + 1} C] [HasWeakSheafify (coherentTopology CompHaus.{u}) C]
/--
The discrete condensed object associated to an object of `C` is the constant sheaf at that object.
-/
@[simps!]
noncomputable def discrete : C ⥤ Condensed.{u} C := constantSheaf _ C
/--
The underlying object of a condensed object in `C` is the condensed object evaluated at a point.
This can be viewed as a sort of forgetful functor from `Condensed C` to `C`
-/
@[simps!]
noncomputable def underlying : Condensed.{u} C ⥤ C :=
(sheafSections _ _).obj ⟨CompHaus.of PUnit.{u + 1}⟩
/--
Discreteness is left adjoint to the forgetful functor. When `C` is `Type*`, this is analogous to
`TopCat.adj₁ : TopCat.discrete ⊣ forget TopCat`.
-/
noncomputable def discreteUnderlyingAdj : discrete C ⊣ underlying C :=
constantSheafAdj _ _ CompHaus.isTerminalPUnit
end Condensed
namespace LightCondensed
variable (C : Type w) [Category.{u} C] [HasSheafify (coherentTopology LightProfinite.{u}) C]
/--
The discrete light condensed object associated to an object of `C` is the constant sheaf at that
object.
-/
@[simps!]
noncomputable def discrete : C ⥤ LightCondensed.{u} C := constantSheaf _ C
/--
The underlying object of a condensed object in `C` is the light condensed object evaluated at a
point. This can be viewed as a sort of forgetful functor from `LightCondensed C` to `C`
-/
@[simps!]
noncomputable def underlying : LightCondensed.{u} C ⥤ C :=
(sheafSections _ _).obj (op (LightProfinite.of PUnit))
/--
Discreteness is left adjoint to the forgetful functor. When `C` is `Type*`, this is analogous to
`TopCat.adj₁ : TopCat.discrete ⊣ forget TopCat`.
-/
noncomputable def discreteUnderlyingAdj : discrete C ⊣ underlying C :=
constantSheafAdj _ _ CompHausLike.isTerminalPUnit
end LightCondensed
/-- A version of `LightCondensed.discrete` in the `LightCondSet` namespace -/
noncomputable abbrev LightCondSet.discrete := LightCondensed.discrete (Type u)
/-- A version of `LightCondensed.underlying` in the `LightCondSet` namespace -/
noncomputable abbrev LightCondSet.underlying := LightCondensed.underlying (Type u)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
/-- A version of `LightCondensed.discrete_underlying_adj` in the `LightCondSet` namespace -/
noncomputable abbrev LightCondSet.discreteUnderlyingAdj : discrete ⊣ underlying :=
LightCondensed.discreteUnderlyingAdj _ |
.lake/packages/mathlib/Mathlib/Condensed/Discrete/LocallyConstant.lean | import Mathlib.Condensed.Discrete.Basic
import Mathlib.Condensed.TopComparison
import Mathlib.Topology.Category.CompHausLike.SigmaComparison
import Mathlib.Topology.FiberPartition
/-!
# The sheaf of locally constant maps on `CompHausLike P`
This file proves that under suitable conditions, the functor from the category of sets to the
category of sheaves for the coherent topology on `CompHausLike P`, given by mapping a set to the
sheaf of locally constant maps to it, is left adjoint to the "underlying set" functor (evaluation
at the point).
We apply this to prove that the constant sheaf functor into (light) condensed sets is isomorphic to
the functor of sheaves of locally constant maps described above.
## Proof sketch
The hard part of this adjunction is to define the counit. Its components are defined as follows:
Let `S : CompHausLike P` and let `Y` be a finite-product-preserving presheaf on `CompHausLike P`
(e.g. a sheaf for the coherent topology). We need to define a map `LocallyConstant S Y(*) ⟶ Y(S)`.
Given a locally constant map `f : S → Y(*)`, let `S = S₁ ⊔ ⋯ ⊔ Sₙ` be the corresponding
decomposition of `S` into the fibers. Let `yᵢ ∈ Y(*)` denote the value of `f` on `Sᵢ` and denote
by `gᵢ` the canonical map `Y(*) → Y(Sᵢ)`. Our map then takes `f` to the image of
`(g₁(y₁), ⋯, gₙ(yₙ))` under the isomorphism `Y(S₁) × ⋯ × Y(Sₙ) ≅ Y(S₁ ⊔ ⋯ ⊔ Sₙ) = Y(S)`.
Now we need to prove that the counit is natural in `S : CompHausLike P` and
`Y : Sheaf (coherentTopology (CompHausLike P)) (Type _)`. There are two key lemmas in all
naturality proofs in this file (both lemmas are in the `CompHausLike.LocallyConstant` namespace):
* `presheaf_ext`: given `S`, `Y` and `f : LocallyConstant S Y(*)` like above, another presheaf
`X`, and two elements `x y : X(S)`, to prove that `x = y` it suffices to prove that for every
inclusion map `ιᵢ : Sᵢ ⟶ S`, `X(ιᵢ)(x) = X(ιᵢ)(y)`.
Here it is important that we set everything up in such a way that the `Sᵢ` are literally subtypes
of `S`.
* `incl_of_counitAppApp`: given `S`, `Y` and `f : LocallyConstant S Y(*)` like above, we have
`Y(ιᵢ)(ε_{S, Y}(f)) = gᵢ(yᵢ)` where `ε` denotes the counit and the other notation is like above.
## Main definitions
* `CompHausLike.LocallyConstant.functor`: the functor from the category of sets to the category of
sheaves for the coherent topology on `CompHausLike P`, which takes a set `X` to
`LocallyConstant - X`
- `CondensedSet.LocallyConstant.functor` is the above functor in the case of condensed sets.
- `LightCondSet.LocallyConstant.functor` is the above functor in the case of light condensed sets.
* `CompHausLike.LocallyConstant.adjunction`: the functor described above is left adjoint to the
"underlying set" functor `(sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩`, which takes
a sheaf `X` to the set `X(*)`.
* `CondensedSet.LocallyConstant.iso`: the functor `CondensedSet.LocallyConstant.functor` is
isomorphic to the functor `Condensed.discrete (Type _)` (the constant sheaf functor from sets to
condensed sets).
* `LightCondSet.LocallyConstant.iso`: the functor `LightCondSet.LocallyConstant.functor` is
isomorphic to the functor `LightCondensed.discrete (Type _)` (the constant sheaf functor from sets
to light condensed sets).
-/
universe u w
open CategoryTheory Limits LocallyConstant TopologicalSpace.Fiber Opposite Function Fiber
variable {P : TopCat.{u} → Prop}
namespace CompHausLike.LocallyConstant
/--
The functor from the category of sets to presheaves on `CompHausLike P` given by locally constant
maps.
-/
@[simps]
def functorToPresheaves : Type (max u w) ⥤ ((CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) where
obj X := {
obj := fun ⟨S⟩ ↦ LocallyConstant S X
map := fun f g ↦ g.comap f.unop.hom }
map f := { app := fun _ t ↦ t.map f }
/--
Locally constant maps are the same as continuous maps when the target is equipped with the discrete
topology
-/
@[simps]
def locallyConstantIsoContinuousMap (Y X : Type*) [TopologicalSpace Y] :
LocallyConstant Y X ≅ C(Y, TopCat.discrete.obj X) :=
letI : TopologicalSpace X := ⊥
haveI : DiscreteTopology X := ⟨rfl⟩
{ hom := fun f ↦ (f : C(Y, X))
inv := fun f ↦ ⟨f, (IsLocallyConstant.iff_continuous f).mpr f.2⟩ }
section Adjunction
variable [∀ (S : CompHausLike.{u} P) (p : S → Prop), HasProp P (Subtype p)]
section
variable {Q : CompHausLike.{u} P} {Z : Type max u w} (r : LocallyConstant Q Z) (a : Fiber r)
/-- A fiber of a locally constant map as a `CompHausLike P`. -/
def fiber : CompHausLike.{u} P := CompHausLike.of P a.val
instance : HasProp P (fiber r a) := inferInstanceAs (HasProp P (Subtype _))
/-- The inclusion map from a component of the coproduct induced by `f` into `S`. -/
def sigmaIncl : fiber r a ⟶ Q := ofHom _ (TopologicalSpace.Fiber.sigmaIncl _ a)
/-- The canonical map from the coproduct induced by `f` to `S` as an isomorphism in
`CompHausLike P`. -/
noncomputable def sigmaIso [HasExplicitFiniteCoproducts.{u} P] : (finiteCoproduct (fiber r)) ≅ Q :=
isoOfBijective (ofHom _ (sigmaIsoHom r)) ⟨sigmaIsoHom_inj r, sigmaIsoHom_surj r⟩
lemma sigmaComparison_comp_sigmaIso [HasExplicitFiniteCoproducts.{u} P]
(X : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) :
(X.mapIso (sigmaIso r).op).hom ≫ sigmaComparison X (fun a ↦ (fiber r a).1) ≫
(fun g ↦ g a) = X.map (sigmaIncl r a).op := by
ext
simp only [Functor.mapIso_hom, Iso.op_hom, types_comp_apply, sigmaComparison,
← FunctorToTypes.map_comp_apply]
rfl
end
variable {S : CompHausLike.{u} P} {Y : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w}
[HasProp P PUnit.{u + 1}] (f : LocallyConstant S (Y.obj (op (CompHausLike.of P PUnit.{u + 1}))))
/-- The projection of the counit. -/
noncomputable def counitAppAppImage : (a : Fiber f) → Y.obj ⟨fiber f a⟩ :=
fun a ↦ Y.map (CompHausLike.isTerminalPUnit.from _).op a.image
/--
The counit is defined as follows: given a locally constant map `f : S → Y(*)`, let
`S = S₁ ⊔ ⋯ ⊔ Sₙ` be the corresponding decomposition of `S` into the fibers. We need to provide an
element of `Y(S)`. It suffices to provide an element of `Y(Sᵢ)` for all `i`. Let `yᵢ ∈ Y(*)` denote
the value of `f` on `Sᵢ`. Our desired element is the image of `yᵢ` under the canonical map
`Y(*) → Y(Sᵢ)`.
-/
noncomputable def counitAppApp (S : CompHausLike.{u} P) (Y : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w)
[PreservesFiniteProducts Y] [HasExplicitFiniteCoproducts.{u} P] :
LocallyConstant S (Y.obj (op (CompHausLike.of P PUnit.{u + 1}))) ⟶ Y.obj ⟨S⟩ :=
fun r ↦ ((inv (sigmaComparison Y (fun a ↦ (fiber r a).1))) ≫
(Y.mapIso (sigmaIso r).op).inv) (counitAppAppImage r)
-- This is the key lemma to prove naturality of the counit:
/--
To check equality of two elements of `X(S)`, it suffices to check equality after composing with
each `X(S) → X(Sᵢ)`.
-/
lemma presheaf_ext (X : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w)
[PreservesFiniteProducts X] (x y : X.obj ⟨S⟩)
[HasExplicitFiniteCoproducts.{u} P]
(h : ∀ (a : Fiber f), X.map (sigmaIncl f a).op x = X.map (sigmaIncl f a).op y) : x = y := by
apply injective_of_mono (X.mapIso (sigmaIso f).op).hom
apply injective_of_mono (sigmaComparison X (fun a ↦ (fiber f a).1))
ext a
specialize h a
rw [← sigmaComparison_comp_sigmaIso] at h
exact h
lemma incl_of_counitAppApp [PreservesFiniteProducts Y] [HasExplicitFiniteCoproducts.{u} P]
(a : Fiber f) : Y.map (sigmaIncl f a).op (counitAppApp S Y f) = counitAppAppImage f a := by
rw [← sigmaComparison_comp_sigmaIso, Functor.mapIso_hom, Iso.op_hom, types_comp_apply]
simp only [counitAppApp, Functor.mapIso_inv, ← Iso.op_hom, types_comp_apply,
← FunctorToTypes.map_comp_apply, Iso.inv_hom_id, FunctorToTypes.map_id_apply]
exact congrFun (inv_hom_id_apply (asIso (sigmaComparison Y (fun a ↦ (fiber f a).1)))
(counitAppAppImage f)) _
variable {T : CompHausLike.{u} P} (g : T ⟶ S)
/--
This is an auxiliary definition, the details do not matter. What's important is that this map exists
so that the lemma `incl_comap` works.
-/
def componentHom (a : Fiber (f.comap g.hom)) :
fiber _ a ⟶ fiber _ (Fiber.mk f (g a.preimage)) :=
TopCat.ofHom
{ toFun x := ⟨g x.val, by
simp only [Fiber.mk, Set.mem_preimage, Set.mem_singleton_iff]
convert map_eq_image _ _ x
exact map_preimage_eq_image_map _ _ a⟩
continuous_toFun := by
exact Continuous.subtype_mk (g.hom.continuous.comp continuous_subtype_val) _ }
-- term mode gives "unknown free variable" error.
lemma incl_comap {S T : (CompHausLike P)ᵒᵖ}
(f : LocallyConstant S.unop (Y.obj (op (CompHausLike.of P PUnit.{u + 1}))))
(g : S ⟶ T) (a : Fiber (f.comap g.unop.hom)) :
g ≫ (sigmaIncl (f.comap g.unop.hom) a).op =
(sigmaIncl f _).op ≫ (componentHom f g.unop a).op :=
rfl
/-- The counit is natural in `S : CompHausLike P` -/
@[simps!]
noncomputable def counitApp [HasExplicitFiniteCoproducts.{u} P]
(Y : (CompHausLike.{u} P)ᵒᵖ ⥤ Type max u w) [PreservesFiniteProducts Y] :
(functorToPresheaves.obj (Y.obj (op (CompHausLike.of P PUnit.{u + 1})))) ⟶ Y where
app := fun ⟨S⟩ ↦ counitAppApp S Y
naturality := by
intro S T g
ext f
apply presheaf_ext (f.comap g.unop.hom)
intro a
simp only [op_unop, functorToPresheaves_obj_obj, types_comp_apply, functorToPresheaves_obj_map,
incl_of_counitAppApp, ← FunctorToTypes.map_comp_apply, incl_comap]
simp only [FunctorToTypes.map_comp_apply, incl_of_counitAppApp]
simp only [counitAppAppImage, ← FunctorToTypes.map_comp_apply, ← op_comp]
apply congrArg
exact image_eq_image_mk (g := g.unop) (a := a)
variable (P) (X : TopCat.{max u w})
[HasExplicitFiniteCoproducts.{0} P] [HasExplicitPullbacks P]
(hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f)
/-- `locallyConstantIsoContinuousMap` is a natural isomorphism. -/
noncomputable def functorToPresheavesIso (X : Type (max u w)) :
functorToPresheaves.{u, w}.obj X ≅ ((TopCat.discrete.obj X).toSheafCompHausLike P hs).val :=
NatIso.ofComponents (fun S ↦ locallyConstantIsoContinuousMap _ _)
/-- `CompHausLike.LocallyConstant.functorToPresheaves` lands in sheaves. -/
@[simps]
def functor :
haveI := CompHausLike.preregular hs
Type (max u w) ⥤ Sheaf (coherentTopology (CompHausLike.{u} P)) (Type (max u w)) where
obj X := {
val := functorToPresheaves.{u, w}.obj X
cond := by
rw [Presheaf.isSheaf_of_iso_iff (functorToPresheavesIso P hs X)]
exact ((TopCat.discrete.obj X).toSheafCompHausLike P hs).cond }
map f := ⟨functorToPresheaves.{u, w}.map f⟩
/--
`CompHausLike.LocallyConstant.functor` is naturally isomorphic to the restriction of
`topCatToSheafCompHausLike` to discrete topological spaces.
-/
noncomputable def functorIso :
functor.{u, w} P hs ≅ TopCat.discrete.{max w u} ⋙ topCatToSheafCompHausLike P hs :=
NatIso.ofComponents (fun X ↦ (fullyFaithfulSheafToPresheaf _ _).preimageIso
(functorToPresheavesIso P hs X))
/-- The counit is natural in both `S : CompHausLike P` and
`Y : Sheaf (coherentTopology (CompHausLike P)) (Type (max u w))` -/
@[simps]
noncomputable def counit [HasExplicitFiniteCoproducts.{u} P] : haveI := CompHausLike.preregular hs
(sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ ⋙ functor.{u, w} P hs ⟶
𝟭 (Sheaf (coherentTopology (CompHausLike.{u} P)) (Type (max u w))) where
app X := haveI := CompHausLike.preregular hs
⟨counitApp X.val⟩
naturality X Y g := by
have := CompHausLike.preregular hs
apply Sheaf.hom_ext
simp only [functor, Functor.comp_obj, Functor.flip_obj_obj,
sheafToPresheaf_obj, Functor.id_obj, Functor.comp_map, Functor.flip_obj_map,
sheafToPresheaf_map, Sheaf.comp_val, Functor.id_map]
ext S (f : LocallyConstant _ _)
simp only [FunctorToTypes.comp, counitApp_app]
apply presheaf_ext (f.map (g.val.app (op (CompHausLike.of P PUnit.{u + 1}))))
intro a
simp only [op_unop, functorToPresheaves_map_app, incl_of_counitAppApp]
apply presheaf_ext (f.comap (sigmaIncl _ _).hom)
intro b
simp only [counitAppAppImage, ← FunctorToTypes.map_comp_apply, ← op_comp,
map_apply, IsTerminal.comp_from, ← map_preimage_eq_image_map]
change (_ ≫ Y.val.map _) _ = (_ ≫ Y.val.map _) _
simp only [← g.val.naturality]
rw [show sigmaIncl (f.comap (sigmaIncl (f.map _) a).hom) b ≫ sigmaIncl (f.map _) a =
CompHausLike.ofHom P (X := fiber _ b) (sigmaInclIncl f _ a b) ≫ sigmaIncl f (Fiber.mk f _)
by ext; rfl]
simp only [op_comp, Functor.map_comp, types_comp_apply, incl_of_counitAppApp]
simp only [counitAppAppImage, ← FunctorToTypes.map_comp_apply, ← op_comp]
rw [mk_image]
change (X.val.map _ ≫ _) _ = (X.val.map _ ≫ _) _
simp only [g.val.naturality]
simp only [types_comp_apply]
have := map_preimage_eq_image (f := g.val.app _ ∘ f) (a := a)
simp only [Function.comp_apply] at this
rw [this]
apply congrArg
symm
convert (b.preimage).prop
exact (mem_iff_eq_image (g.val.app _ ∘ f) _ _).symm
/--
The unit of the adjunction is given by mapping each element to the corresponding constant map.
-/
@[simps]
def unit : 𝟭 _ ⟶ functor P hs ⋙ (sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ where
app _ x := LocallyConstant.const _ x
/-- The unit of the adjunction is an iso. -/
noncomputable def unitIso : 𝟭 (Type max u w) ≅ functor.{u, w} P hs ⋙
(sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ where
hom := unit P hs
inv := { app := fun _ f ↦ f.toFun PUnit.unit }
lemma adjunction_left_triangle [HasExplicitFiniteCoproducts.{u} P]
(X : Type max u w) : functorToPresheaves.{u, w}.map ((unit P hs).app X) ≫
((counit P hs).app ((functor P hs).obj X)).val = 𝟙 (functorToPresheaves.obj X) := by
ext ⟨S⟩ (f : LocallyConstant _ X)
simp only [Functor.id_obj, Functor.comp_obj, FunctorToTypes.comp, NatTrans.id_app,
functorToPresheaves_obj_obj, types_id_apply]
simp only [counit, counitApp_app]
have := CompHausLike.preregular hs
apply presheaf_ext
(X := ((functor P hs).obj X).val) (Y := ((functor.{u, w} P hs).obj X).val)
(f.map ((unit P hs).app X))
intro a
erw [incl_of_counitAppApp]
simp only [functor_obj_val, functorToPresheaves_obj_obj, Functor.id_obj,
counitAppAppImage, LocallyConstant.map_apply, functorToPresheaves_obj_map, Quiver.Hom.unop_op]
ext x
erw [← map_eq_image _ a x]
rfl
/--
`CompHausLike.LocallyConstant.functor` is left adjoint to the forgetful functor.
-/
@[simps]
noncomputable def adjunction [HasExplicitFiniteCoproducts.{u} P] :
functor.{u, w} P hs ⊣ (sheafSections _ _).obj ⟨CompHausLike.of P PUnit.{u + 1}⟩ where
unit := unit P hs
counit := counit P hs
left_triangle_components := by
intro X
simp only [Functor.comp_obj, Functor.id_obj, Functor.flip_obj_obj, sheafToPresheaf_obj,
functor_obj_val, functorToPresheaves_obj_obj]
apply Sheaf.hom_ext
rw [Sheaf.comp_val, Sheaf.id_val]
exact adjunction_left_triangle P hs X
right_triangle_components := by
intro X
ext (x : X.val.obj _)
simp only [Functor.comp_obj, Functor.id_obj, Functor.flip_obj_obj, sheafToPresheaf_obj,
functor_obj_val, functorToPresheaves_obj_obj, types_id_apply,
Functor.flip_obj_map, sheafToPresheaf_map, counit_app_val]
have := CompHausLike.preregular hs
letI : PreservesFiniteProducts ((sheafToPresheaf (coherentTopology _) _).obj X) :=
inferInstanceAs (PreservesFiniteProducts (Sheaf.val _))
apply presheaf_ext ((unit P hs).app _ x)
intro a
erw [incl_of_counitAppApp]
simp only [unit_app, counitAppAppImage, coe_const]
erw [← map_eq_image _ a ⟨PUnit.unit, by simp [mem_iff_eq_image, ← map_preimage_eq_image]⟩]
rfl
instance [HasExplicitFiniteCoproducts.{u} P] : IsIso (adjunction P hs).unit :=
inferInstanceAs (IsIso (unitIso P hs).hom)
end Adjunction
end CompHausLike.LocallyConstant
section Condensed
open Condensed CompHausLike
namespace CondensedSet.LocallyConstant
/-- The functor from sets to condensed sets given by locally constant maps into the set. -/
abbrev functor : Type (u + 1) ⥤ CondensedSet.{u} :=
CompHausLike.LocallyConstant.functor.{u, u + 1} (P := fun _ ↦ True)
(hs := fun _ _ _ ↦ ((CompHaus.effectiveEpi_tfae _).out 0 2).mp)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
/--
`CondensedSet.LocallyConstant.functor` is isomorphic to `Condensed.discrete`
(by uniqueness of adjoints).
-/
noncomputable def iso : functor ≅ discrete (Type (u + 1)) :=
(LocallyConstant.adjunction _ _).leftAdjointUniq (discreteUnderlyingAdj _)
/-- `CondensedSet.LocallyConstant.functor` is fully faithful. -/
noncomputable def functorFullyFaithful : functor.FullyFaithful :=
(LocallyConstant.adjunction.{u, u + 1} _ _).fullyFaithfulLOfIsIsoUnit
noncomputable instance : functor.Faithful := functorFullyFaithful.faithful
noncomputable instance : functor.Full := functorFullyFaithful.full
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (discrete (Type _)).Faithful := Functor.Faithful.of_iso iso
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
noncomputable instance : (discrete (Type _)).Full := Functor.Full.of_iso iso
end CondensedSet.LocallyConstant
namespace LightCondSet.LocallyConstant
/-- The functor from sets to light condensed sets given by locally constant maps into the set. -/
abbrev functor : Type u ⥤ LightCondSet.{u} :=
CompHausLike.LocallyConstant.functor.{u, u}
(P := fun X ↦ TotallyDisconnectedSpace X ∧ SecondCountableTopology X)
(hs := fun _ _ _ ↦ (LightProfinite.effectiveEpi_iff_surjective _).mp)
instance (S : LightProfinite.{u}) (p : S → Prop) :
HasProp (fun X ↦ TotallyDisconnectedSpace X ∧ SecondCountableTopology X) (Subtype p) :=
⟨⟨(inferInstance : TotallyDisconnectedSpace (Subtype p)),
(inferInstance : SecondCountableTopology {s | p s})⟩⟩
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
/--
`LightCondSet.LocallyConstant.functor` is isomorphic to `LightCondensed.discrete`
(by uniqueness of adjoints).
-/
noncomputable def iso : functor ≅ LightCondensed.discrete (Type u) :=
(LocallyConstant.adjunction _ _).leftAdjointUniq (LightCondensed.discreteUnderlyingAdj _)
/-- `LightCondSet.LocallyConstant.functor` is fully faithful. -/
noncomputable def functorFullyFaithful : functor.{u}.FullyFaithful :=
(LocallyConstant.adjunction _ _).fullyFaithfulLOfIsIsoUnit
instance : functor.{u}.Faithful := functorFullyFaithful.faithful
instance : LightCondSet.LocallyConstant.functor.Full := functorFullyFaithful.full
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (LightCondensed.discrete (Type u)).Faithful := Functor.Faithful.of_iso iso.{u}
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (LightCondensed.discrete (Type u)).Full := Functor.Full.of_iso iso.{u}
end LightCondSet.LocallyConstant
end Condensed |
.lake/packages/mathlib/Mathlib/Condensed/Light/Instances.lean | import Mathlib.Topology.Category.LightProfinite.EffectiveEpi
import Mathlib.CategoryTheory.Sites.Equivalence
/-!
# `HasSheafify` instances
In this file, we obtain a `HasSheafify (coherentTopology LightProfinite.{u}) (Type u)`
instance (and similarly for other concrete categories). These instances
are not obtained automatically because `LightProfinite.{u}` is a large category,
but as it is essentially small, the instances can be obtained using the results
in the file `CategoryTheory.Sites.Equivalence`.
-/
universe u u' v
open CategoryTheory Limits
namespace LightProfinite
variable (A : Type u') [Category.{u} A] [HasLimits A] [HasColimits A]
{FA : A → A → Type v} {CA : A → Type u}
[∀ X Y, FunLike (FA X Y) (CA X) (CA Y)] [ConcreteCategory A FA]
[PreservesFilteredColimits (forget A)]
[PreservesLimits (forget A)] [(forget A).ReflectsIsomorphisms]
instance hasSheafify :
HasSheafify (coherentTopology LightProfinite.{u}) A :=
hasSheafifyEssentiallySmallSite _ _
instance hasSheafify_type :
HasSheafify (coherentTopology LightProfinite.{u}) (Type u) :=
hasSheafifyEssentiallySmallSite _ _
instance : (coherentTopology LightProfinite.{u}).WEqualsLocallyBijective A :=
GrothendieckTopology.WEqualsLocallyBijective.ofEssentiallySmall _
end LightProfinite |
.lake/packages/mathlib/Mathlib/Condensed/Light/Module.lean | import Mathlib.Algebra.Category.ModuleCat.Abelian
import Mathlib.Algebra.Category.ModuleCat.Adjunctions
import Mathlib.Algebra.Category.ModuleCat.Colimits
import Mathlib.Algebra.Category.ModuleCat.FilteredColimits
import Mathlib.CategoryTheory.Sites.Abelian
import Mathlib.CategoryTheory.Sites.Adjunction
import Mathlib.CategoryTheory.Sites.Equivalence
import Mathlib.Condensed.Light.Basic
import Mathlib.Condensed.Light.Instances
/-!
# Light condensed `R`-modules
This file defines light condensed modules over a ring `R`.
## Main results
* Light condensed `R`-modules form an abelian category.
* The forgetful functor from light condensed `R`-modules to light condensed sets has a left
adjoint, sending a light condensed set to the corresponding *free* light condensed `R`-module.
-/
universe u
open CategoryTheory
variable (R : Type u) [Ring R]
/--
The category of light condensed `R`-modules, defined as sheaves of `R`-modules over
`LightProfinite.{u}` with respect to the coherent Grothendieck topology.
-/
abbrev LightCondMod := LightCondensed.{u} (ModuleCat.{u} R)
noncomputable instance : Abelian (LightCondMod.{u} R) := sheafIsAbelian
/-- The forgetful functor from light condensed `R`-modules to light condensed sets. -/
def LightCondensed.forget : LightCondMod R ⥤ LightCondSet :=
sheafCompose _ (CategoryTheory.forget _)
/--
The left adjoint to the forgetful functor. The *free light condensed `R`-module* on a light
condensed set.
-/
noncomputable
def LightCondensed.free : LightCondSet ⥤ LightCondMod R :=
Sheaf.composeAndSheafify _ (ModuleCat.free R)
/-- The condensed version of the free-forgetful adjunction. -/
noncomputable
def LightCondensed.freeForgetAdjunction : free R ⊣ forget R := Sheaf.adjunction _ (ModuleCat.adj R)
/--
The category of light condensed abelian groups, defined as sheaves of `ℤ`-modules over
`LightProfinite.{0}` with respect to the coherent Grothendieck topology.
-/
abbrev LightCondAb := LightCondMod ℤ
noncomputable example : Abelian LightCondAb := inferInstance
namespace LightCondMod
lemma hom_naturality_apply {X Y : LightCondMod.{u} R} (f : X ⟶ Y) {S T : LightProfiniteᵒᵖ}
(g : S ⟶ T) (x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) :=
NatTrans.naturality_apply f.val g x
end LightCondMod |
.lake/packages/mathlib/Mathlib/Condensed/Light/Functors.lean | import Mathlib.CategoryTheory.Sites.Coherent.CoherentSheaves
import Mathlib.Condensed.Light.Basic
/-!
# Functors from categories of topological spaces to light condensed sets
This file defines the embedding of the test objects (light profinite sets) into light condensed
sets.
## Main definitions
* `lightProfiniteToLightCondSet : LightProfinite.{u} ⥤ LightCondSet.{u}`
is the yoneda presheaf functor.
-/
universe u v
open CategoryTheory Limits
/-- The functor from `LightProfinite.{u}` to `LightCondSet.{u}` given by the Yoneda sheaf. -/
def lightProfiniteToLightCondSet : LightProfinite.{u} ⥤ LightCondSet.{u} :=
(coherentTopology LightProfinite).yoneda
/-- Dot notation for the value of `lightProfiniteToLightCondSet`. -/
abbrev LightProfinite.toCondensed (S : LightProfinite.{u}) : LightCondSet.{u} :=
lightProfiniteToLightCondSet.obj S
/-- `lightProfiniteToLightCondSet` is fully faithful. -/
abbrev lightProfiniteToLightCondSetFullyFaithful :
lightProfiniteToLightCondSet.FullyFaithful :=
(coherentTopology LightProfinite).yonedaFullyFaithful
instance : lightProfiniteToLightCondSet.Full :=
inferInstanceAs ((coherentTopology LightProfinite).yoneda).Full
instance : lightProfiniteToLightCondSet.Faithful :=
inferInstanceAs ((coherentTopology LightProfinite).yoneda).Faithful |
.lake/packages/mathlib/Mathlib/Condensed/Light/Basic.lean | import Mathlib.CategoryTheory.Sites.Sheaf
import Mathlib.Topology.Category.LightProfinite.EffectiveEpi
/-!
# Light condensed objects
This file defines the category of light condensed objects in a category `C`, following the work
of Clausen-Scholze (see https://www.youtube.com/playlist?list=PLx5f8IelFRgGmu6gmL-Kf_Rl_6Mm7juZO).
-/
universe u v w
open CategoryTheory Limits
/--
`LightCondensed.{u} C` is the category of light condensed objects in a category `C`, which are
defined as sheaves on `LightProfinite.{u}` with respect to the coherent Grothendieck topology.
-/
def LightCondensed (C : Type w) [Category.{v} C] :=
Sheaf (coherentTopology LightProfinite.{u}) C
instance {C : Type w} [Category.{v} C] : Category (LightCondensed.{u} C) :=
show Category (Sheaf _ _) from inferInstance
/--
Light condensed sets. Because `LightProfinite` is an essentially small category, we don't need the
same universe bump as in `CondensedSet`.
-/
abbrev LightCondSet := LightCondensed.{u} (Type u)
namespace LightCondensed
variable {C : Type w} [Category.{v} C]
@[simp]
lemma id_val (X : LightCondensed.{u} C) : (𝟙 X : X ⟶ X).val = 𝟙 _ := rfl
@[simp]
lemma comp_val {X Y Z : LightCondensed.{u} C} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).val = f.val ≫ g.val :=
rfl
@[ext]
lemma hom_ext {X Y : LightCondensed.{u} C} (f g : X ⟶ Y) (h : ∀ S, f.val.app S = g.val.app S) :
f = g := by
apply Sheaf.hom_ext
ext
exact h _
end LightCondensed
namespace LightCondSet
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
-- Note: `simp` can prove this when stated for `LightCondensed C` for a concrete category `C`.
-- However, it doesn't seem to see through the abbreviation `LightCondSet`
@[simp]
lemma hom_naturality_apply {X Y : LightCondSet.{u}} (f : X ⟶ Y) {S T : LightProfiniteᵒᵖ}
(g : S ⟶ T) (x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) :=
NatTrans.naturality_apply f.val g x
end LightCondSet |
.lake/packages/mathlib/Mathlib/Condensed/Light/TopComparison.lean | import Mathlib.Condensed.Light.Basic
import Mathlib.Condensed.TopComparison
/-!
# The functor from topological spaces to light condensed sets
We define the functor `topCatToLightCondSet : TopCat.{u} ⥤ LightCondSet.{u}`.
-/
universe u
open CategoryTheory
/--
Associate to a `u`-small topological space the corresponding light condensed set, given by
`yonedaPresheaf`.
-/
noncomputable abbrev TopCat.toLightCondSet (X : TopCat.{u}) : LightCondSet.{u} :=
toSheafCompHausLike.{u} _ X (fun _ _ _ ↦ (LightProfinite.effectiveEpi_iff_surjective _).mp)
/--
`TopCat.toLightCondSet` yields a functor from `TopCat.{u}` to `LightCondSet.{u}`.
-/
noncomputable abbrev topCatToLightCondSet : TopCat.{u} ⥤ LightCondSet.{u} :=
topCatToSheafCompHausLike.{u} _ (fun _ _ _ ↦ (LightProfinite.effectiveEpi_iff_surjective _).mp) |
.lake/packages/mathlib/Mathlib/Condensed/Light/CartesianClosed.lean | import Mathlib.CategoryTheory.Closed.Types
import Mathlib.CategoryTheory.Sites.CartesianClosed
import Mathlib.CategoryTheory.Sites.Equivalence
import Mathlib.Condensed.Light.Basic
import Mathlib.Condensed.Light.Instances
/-!
# Light condensed sets form a Cartesian closed category
-/
universe u
noncomputable section
open CategoryTheory
variable {C : Type u} [SmallCategory C]
instance : CartesianMonoidalCategory (LightCondSet.{u}) :=
inferInstanceAs (CartesianMonoidalCategory (Sheaf _ _))
instance : CartesianClosed (LightCondSet.{u}) := inferInstanceAs (CartesianClosed (Sheaf _ _)) |
.lake/packages/mathlib/Mathlib/Condensed/Light/Explicit.lean | import Mathlib.CategoryTheory.Sites.Coherent.SheafComparison
import Mathlib.Condensed.Light.Module
/-!
# The explicit sheaf condition for light condensed sets
We give explicit description of light condensed sets:
* `LightCondensed.ofSheafLightProfinite`: A finite-product-preserving presheaf on `LightProfinite`,
satisfying `EqualizerCondition`.
The property `EqualizerCondition` is defined in `Mathlib/CategoryTheory/Sites/RegularExtensive.lean`
and it says that for any effective epi `X ⟶ B` (in this case that is equivalent to being a
continuous surjection), the presheaf `F` exhibits `F(B)` as the equalizer of the two maps
`F(X) ⇉ F(X ×_B X)`
We also give variants for light condensed objects in concrete categories whose forgetful functor
reflects finite limits (resp. products), where it is enough to check the sheaf condition after
postcomposing with the forgetful functor.
-/
universe v u w
open CategoryTheory Limits Opposite Functor Presheaf regularTopology
variable {A : Type*} [Category A]
namespace LightCondensed
/--
The light condensed object associated to a presheaf on `LightProfinite` which preserves finite
products and satisfies the equalizer condition.
-/
@[simps]
noncomputable def ofSheafLightProfinite (F : LightProfinite.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts F]
(hF : EqualizerCondition F) : LightCondensed A where
val := F
cond := by
rw [isSheaf_iff_preservesFiniteProducts_and_equalizerCondition F]
exact ⟨⟨fun _ ↦ inferInstance⟩, hF⟩
/--
The light condensed object associated to a presheaf on `LightProfinite` whose postcomposition with
the forgetful functor preserves finite products and satisfies the equalizer condition.
-/
@[simps]
noncomputable def ofSheafForgetLightProfinite
[HasForget A] [ReflectsFiniteLimits (CategoryTheory.forget A)]
(F : LightProfinite.{u}ᵒᵖ ⥤ A) [PreservesFiniteProducts (F ⋙ CategoryTheory.forget A)]
(hF : EqualizerCondition (F ⋙ CategoryTheory.forget A)) : LightCondensed A where
val := F
cond := by
apply isSheaf_coherent_of_hasPullbacks_of_comp F (CategoryTheory.forget A)
rw [isSheaf_iff_preservesFiniteProducts_and_equalizerCondition]
exact ⟨⟨fun _ ↦ inferInstance⟩, hF⟩
/-- A light condensed object satisfies the equalizer condition. -/
theorem equalizerCondition (X : LightCondensed A) : EqualizerCondition X.val :=
isSheaf_iff_preservesFiniteProducts_and_equalizerCondition X.val |>.mp X.cond |>.2
/-- A light condensed object preserves finite products. -/
noncomputable instance (X : LightCondensed A) : PreservesFiniteProducts X.val :=
isSheaf_iff_preservesFiniteProducts_and_equalizerCondition X.val |>.mp X.cond |>.1
end LightCondensed
namespace LightCondSet
/-- A `LightCondSet` version of `LightCondensed.ofSheafLightProfinite`. -/
noncomputable abbrev ofSheafLightProfinite (F : LightProfinite.{u}ᵒᵖ ⥤ Type u)
[PreservesFiniteProducts F] (hF : EqualizerCondition F) : LightCondSet :=
LightCondensed.ofSheafLightProfinite F hF
end LightCondSet
namespace LightCondMod
variable (R : Type u) [Ring R]
/-- A `LightCondAb` version of `LightCondensed.ofSheafLightProfinite`. -/
noncomputable abbrev ofSheafLightProfinite (F : LightProfinite.{u}ᵒᵖ ⥤ ModuleCat.{u} R)
[PreservesFiniteProducts F] (hF : EqualizerCondition F) : LightCondMod.{u} R :=
LightCondensed.ofSheafLightProfinite F hF
end LightCondMod
namespace LightCondAb
/-- A `LightCondAb` version of `LightCondensed.ofSheafLightProfinite`. -/
noncomputable abbrev ofSheafLightProfinite (F : LightProfiniteᵒᵖ ⥤ ModuleCat ℤ)
[PreservesFiniteProducts F] (hF : EqualizerCondition F) : LightCondAb :=
LightCondMod.ofSheafLightProfinite ℤ F hF
end LightCondAb |
.lake/packages/mathlib/Mathlib/Condensed/Light/TopCatAdjunction.lean | import Mathlib.Condensed.Light.TopComparison
import Mathlib.Topology.Category.Sequential
import Mathlib.Topology.Category.LightProfinite.Sequence
/-!
# The adjunction between light condensed sets and topological spaces
This file defines the functor `lightCondSetToTopCat : LightCondSet.{u} ⥤ TopCat.{u}` which is
left adjoint to `topCatToLightCondSet : TopCat.{u} ⥤ LightCondSet.{u}`. We prove that the counit
is bijective (but not in general an isomorphism) and conclude that the right adjoint is faithful.
The counit is an isomorphism for sequential spaces, and we conclude that the functor
`topCatToLightCondSet` is fully faithful when restricted to sequential spaces.
-/
universe u
open LightCondensed LightCondSet CategoryTheory LightProfinite
namespace LightCondSet
variable (X : LightCondSet.{u})
/-- Auxiliary definition to define the topology on `X(*)` for a light condensed set `X`. -/
private def coinducingCoprod :
(Σ (i : (S : LightProfinite.{u}) × X.val.obj ⟨S⟩), i.fst) →
X.val.obj ⟨LightProfinite.of PUnit⟩ :=
fun ⟨⟨_, i⟩, s⟩ ↦ X.val.map ((of PUnit.{u+1}).const s).op i
/-- Let `X` be a light condensed set. We define a topology on `X(*)` as the quotient topology of
all the maps from light profinite sets `S` to `X(*)`, corresponding to elements of `X(S)`.
In other words, the topology coinduced by the map `LightCondSet.coinducingCoprod` above. -/
local instance underlyingTopologicalSpace :
TopologicalSpace (X.val.obj ⟨LightProfinite.of PUnit⟩) :=
TopologicalSpace.coinduced (coinducingCoprod X) inferInstance
/-- The object part of the functor `LightCondSet ⥤ TopCat` -/
abbrev toTopCat : TopCat.{u} := TopCat.of (X.val.obj ⟨LightProfinite.of PUnit⟩)
lemma continuous_coinducingCoprod {S : LightProfinite.{u}} (x : X.val.obj ⟨S⟩) :
Continuous fun a ↦ (X.coinducingCoprod ⟨⟨S, x⟩, a⟩) := by
suffices ∀ (i : (T : LightProfinite.{u}) × X.val.obj ⟨T⟩),
Continuous (fun (a : i.fst) ↦ X.coinducingCoprod ⟨i, a⟩) from this ⟨_, _⟩
rw [← continuous_sigma_iff]
apply continuous_coinduced_rng
variable {X} {Y : LightCondSet} (f : X ⟶ Y)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
/-- The map part of the functor `LightCondSet ⥤ TopCat` -/
@[simps!]
def toTopCatMap : X.toTopCat ⟶ Y.toTopCat :=
TopCat.ofHom
{ toFun := f.val.app ⟨LightProfinite.of PUnit⟩
continuous_toFun := by
rw [continuous_coinduced_dom]
apply continuous_sigma
intro ⟨S, x⟩
simp only [Function.comp_apply, coinducingCoprod]
rw [show (fun (a : S) ↦ f.val.app ⟨of PUnit⟩ (X.val.map ((of PUnit.{u+1}).const a).op x)) = _
from funext fun a ↦ NatTrans.naturality_apply f.val ((of PUnit.{u+1}).const a).op x]
exact continuous_coinducingCoprod _ _ }
/-- The functor `LightCondSet ⥤ TopCat` -/
@[simps]
def _root_.lightCondSetToTopCat : LightCondSet.{u} ⥤ TopCat.{u} where
obj X := X.toTopCat
map f := toTopCatMap f
/-- The counit of the adjunction `lightCondSetToTopCat ⊣ topCatToLightCondSet` -/
noncomputable def topCatAdjunctionCounit (X : TopCat.{u}) : X.toLightCondSet.toTopCat ⟶ X :=
TopCat.ofHom
{ toFun x := x.1 PUnit.unit
continuous_toFun := by
rw [continuous_coinduced_dom]
continuity }
/-- The counit of the adjunction `lightCondSetToTopCat ⊣ topCatToLightCondSet` is always bijective,
but not an isomorphism in general (the inverse isn't continuous unless `X` is sequential).
-/
noncomputable def topCatAdjunctionCounitEquiv (X : TopCat.{u}) : X.toLightCondSet.toTopCat ≃ X where
toFun := topCatAdjunctionCounit X
invFun x := ContinuousMap.const _ x
lemma topCatAdjunctionCounit_bijective (X : TopCat.{u}) :
Function.Bijective (topCatAdjunctionCounit X) :=
(topCatAdjunctionCounitEquiv X).bijective
/-- The unit of the adjunction `lightCondSetToTopCat ⊣ topCatToLightCondSet` -/
@[simps val_app val_app_apply]
noncomputable def topCatAdjunctionUnit (X : LightCondSet.{u}) : X ⟶ X.toTopCat.toLightCondSet where
val := {
app := fun S x ↦ {
toFun := fun s ↦ X.val.map ((of PUnit.{u+1}).const s).op x
continuous_toFun := by
suffices ∀ (i : (T : LightProfinite.{u}) × X.val.obj ⟨T⟩),
Continuous (fun (a : i.fst) ↦ X.coinducingCoprod ⟨i, a⟩) from this ⟨_, _⟩
rw [← continuous_sigma_iff]
apply continuous_coinduced_rng }
naturality := fun _ _ _ ↦ by
ext
simp only [TopCat.toSheafCompHausLike_val_obj, Opposite.op_unop, types_comp_apply,
TopCat.toSheafCompHausLike_val_map, ← FunctorToTypes.map_comp_apply]
rfl }
/-- The adjunction `lightCondSetToTopCat ⊣ topCatToLightCondSet` -/
noncomputable def topCatAdjunction : lightCondSetToTopCat.{u} ⊣ topCatToLightCondSet where
unit := { app := topCatAdjunctionUnit }
counit := { app := topCatAdjunctionCounit }
left_triangle_components Y := by
ext
change Y.val.map (𝟙 _) _ = _
simp
instance (X : TopCat) : Epi (topCatAdjunction.counit.app X) := by
rw [TopCat.epi_iff_surjective]
exact (topCatAdjunctionCounit_bijective _).2
instance : topCatToLightCondSet.Faithful := topCatAdjunction.faithful_R_of_epi_counit_app
open Sequential
instance (X : LightCondSet.{u}) : SequentialSpace X.toTopCat := by
apply SequentialSpace.coinduced
instance (X : LightCondSet.{u}) : SequentialSpace (lightCondSetToTopCat.obj X) :=
inferInstanceAs (SequentialSpace X.toTopCat)
/-- The functor from light condensed sets to topological spaces lands in sequential spaces. -/
def lightCondSetToSequential : LightCondSet.{u} ⥤ Sequential.{u} where
obj X := Sequential.of (lightCondSetToTopCat.obj X)
map f := toTopCatMap f
/--
The functor from topological spaces to light condensed sets restricted to sequential spaces.
-/
noncomputable def sequentialToLightCondSet :
Sequential.{u} ⥤ LightCondSet.{u} :=
sequentialToTop ⋙ topCatToLightCondSet
/--
The adjunction `lightCondSetToTopCat ⊣ topCatToLightCondSet` restricted to sequential
spaces.
-/
noncomputable def sequentialAdjunction :
lightCondSetToSequential ⊣ sequentialToLightCondSet :=
topCatAdjunction.restrictFullyFaithful (iC := 𝟭 _) (iD := sequentialToTop)
(Functor.FullyFaithful.id _) fullyFaithfulSequentialToTop
(Iso.refl _) (Iso.refl _)
/--
The counit of the adjunction `lightCondSetToSequential ⊣ sequentialToLightCondSet`
is a homeomorphism.
Note: for now, we only have `ℕ∪{∞}` as a light profinite set at universe level 0, which is why we
can only prove this for `X : TopCat.{0}`.
-/
noncomputable def sequentialAdjunctionHomeo (X : TopCat.{0}) [SequentialSpace X] :
X.toLightCondSet.toTopCat ≃ₜ X where
toEquiv := topCatAdjunctionCounitEquiv X
continuous_invFun := by
apply SeqContinuous.continuous
unfold SeqContinuous
intro f p h
let g := (topCatAdjunctionCounitEquiv X).invFun ∘ (OnePoint.continuousMapMkNat f p h)
change Filter.Tendsto (fun n : ℕ ↦ g n) _ _
erw [← OnePoint.continuous_iff_from_nat]
let x : X.toLightCondSet.val.obj ⟨(ℕ∪{∞})⟩ := OnePoint.continuousMapMkNat f p h
exact continuous_coinducingCoprod X.toLightCondSet x
/--
The counit of the adjunction `lightCondSetToSequential ⊣ sequentialToLightCondSet`
is an isomorphism.
Note: for now, we only have `ℕ∪{∞}` as a light profinite set at universe level 0, which is why we
can only prove this for `X : Sequential.{0}`.
-/
noncomputable def sequentialAdjunctionCounitIso (X : Sequential.{0}) :
lightCondSetToSequential.obj (sequentialToLightCondSet.obj X) ≅ X :=
isoOfHomeo (sequentialAdjunctionHomeo X.toTop)
instance : IsIso sequentialAdjunction.{0}.counit := by
rw [NatTrans.isIso_iff_isIso_app]
intro X
exact inferInstanceAs (IsIso (sequentialAdjunctionCounitIso X).hom)
/--
The functor from topological spaces to light condensed sets restricted to sequential spaces
is fully faithful.
Note: for now, we only have `ℕ∪{∞}` as a light profinite set at universe level 0, which is why we
can only prove this for the functor `Sequential.{0} ⥤ LightCondSet.{0}`.
-/
noncomputable def fullyFaithfulSequentialToLightCondSet :
sequentialToLightCondSet.{0}.FullyFaithful :=
sequentialAdjunction.fullyFaithfulROfIsIsoCounit
end LightCondSet |
.lake/packages/mathlib/Mathlib/Condensed/Light/Small.lean | import Mathlib.CategoryTheory.Sites.Equivalence
import Mathlib.Condensed.Light.Basic
/-!
# Equivalence of light condensed objects with sheaves on a small site
-/
universe u v w
open CategoryTheory
namespace LightCondensed
variable {C : Type w} [Category.{v} C]
variable (C) in
/--
The equivalence of categories from light condensed objects to sheaves on a small site
equivalent to light profinite sets.
-/
noncomputable abbrev equivSmall :
LightCondensed.{u} C ≌
Sheaf ((equivSmallModel.{u} LightProfinite.{u}).inverse.inducedTopology
(coherentTopology LightProfinite.{u})) C :=
(equivSmallModel LightProfinite).sheafCongr _ _ _
instance (X Y : LightCondensed.{u} C) : Small.{max u v} (X ⟶ Y) where
equiv_small :=
⟨(equivSmall C).functor.obj X ⟶ (equivSmall C).functor.obj Y,
⟨(equivSmall C).fullyFaithfulFunctor.homEquiv⟩⟩
end LightCondensed |
.lake/packages/mathlib/Mathlib/Condensed/Light/Epi.lean | import Mathlib.CategoryTheory.Limits.Shapes.SequentialProduct
import Mathlib.CategoryTheory.Sites.Coherent.SequentialLimit
import Mathlib.Condensed.Light.Limits
/-!
# Epimorphisms of light condensed objects
This file characterises epimorphisms in light condensed sets and modules as the locally surjective
morphisms. Here, the condition of locally surjective is phrased in terms of continuous surjections
of light profinite sets.
Further, we prove that the functor `lim : Discrete ℕ ⥤ LightCondMod R` preserves epimorphisms.
-/
universe v u w u' v'
open CategoryTheory Sheaf Limits HasForget GrothendieckTopology
namespace LightCondensed
variable (A : Type u') [Category.{v'} A] {FA : A → A → Type*} {CA : A → Type w}
variable [∀ X Y, FunLike (FA X Y) (CA X) (CA Y)] [ConcreteCategory.{w} A FA]
[PreservesFiniteProducts (CategoryTheory.forget A)]
variable {X Y : LightCondensed.{u} A} (f : X ⟶ Y)
lemma isLocallySurjective_iff_locallySurjective_on_lightProfinite : IsLocallySurjective f ↔
∀ (S : LightProfinite) (y : ToType (Y.val.obj ⟨S⟩)),
(∃ (S' : LightProfinite) (φ : S' ⟶ S) (_ : Function.Surjective φ)
(x : ToType (X.val.obj ⟨S'⟩)),
f.val.app ⟨S'⟩ x = Y.val.map ⟨φ⟩ y) := by
rw [coherentTopology.isLocallySurjective_iff,
regularTopology.isLocallySurjective_iff]
simp_rw [LightProfinite.effectiveEpi_iff_surjective]
end LightCondensed
namespace LightCondSet
variable {X Y : LightCondSet.{u}} (f : X ⟶ Y)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma epi_iff_locallySurjective_on_lightProfinite : Epi f ↔
∀ (S : LightProfinite) (y : Y.val.obj ⟨S⟩),
(∃ (S' : LightProfinite) (φ : S' ⟶ S) (_ : Function.Surjective φ) (x : X.val.obj ⟨S'⟩),
f.val.app ⟨S'⟩ x = Y.val.map ⟨φ⟩ y) := by
rw [← isLocallySurjective_iff_epi']
exact LightCondensed.isLocallySurjective_iff_locallySurjective_on_lightProfinite _ f
end LightCondSet
namespace LightCondMod
variable (R : Type u) [Ring R] {X Y : LightCondMod.{u} R} (f : X ⟶ Y)
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
lemma epi_iff_locallySurjective_on_lightProfinite : Epi f ↔
∀ (S : LightProfinite) (y : Y.val.obj ⟨S⟩),
(∃ (S' : LightProfinite) (φ : S' ⟶ S) (_ : Function.Surjective φ) (x : X.val.obj ⟨S'⟩),
f.val.app ⟨S'⟩ x = Y.val.map ⟨φ⟩ y) := by
rw [← isLocallySurjective_iff_epi']
exact LightCondensed.isLocallySurjective_iff_locallySurjective_on_lightProfinite _ f
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (LightCondensed.forget R).ReflectsEpimorphisms where
reflects f hf := by
rw [← Sheaf.isLocallySurjective_iff_epi'] at hf ⊢
exact (Presheaf.isLocallySurjective_iff_whisker_forget _ f.val).mpr hf
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
instance : (LightCondensed.forget R).PreservesEpimorphisms where
preserves f hf := by
rw [← Sheaf.isLocallySurjective_iff_epi'] at hf ⊢
exact (Presheaf.isLocallySurjective_iff_whisker_forget _ f.val).mp hf
end LightCondMod
namespace LightCondensed
variable (R : Type*) [Ring R]
variable {F : ℕᵒᵖ ⥤ LightCondMod R} {c : Cone F} (hc : IsLimit c)
(hF : ∀ n, Epi (F.map (homOfLE (Nat.le_succ n)).op))
attribute [local instance] Types.instFunLike Types.instConcreteCategory in
include hc hF in
lemma epi_π_app_zero_of_epi : Epi (c.π.app ⟨0⟩) := by
apply Functor.epi_of_epi_map (forget R)
change Epi (((forget R).mapCone c).π.app ⟨0⟩)
apply coherentTopology.epi_π_app_zero_of_epi
· simp only [LightProfinite.effectiveEpi_iff_surjective]
exact fun x h ↦ Concrete.surjective_π_app_zero_of_surjective_map (limit.isLimit x) h
· have := (freeForgetAdjunction R).isRightAdjoint
exact isLimitOfPreserves _ hc
· exact fun _ ↦ (forget R).map_epi _
end LightCondensed
open CategoryTheory.Limits.SequentialProduct
namespace LightCondensed
variable (n : ℕ)
attribute [local instance] functorMap_epi Abelian.hasFiniteBiproducts
variable {R : Type u} [Ring R] {M N : ℕ → LightCondMod.{u} R} (f : ∀ n, M n ⟶ N n) [∀ n, Epi (f n)]
instance : Epi (Limits.Pi.map f) := by
have : Limits.Pi.map f = (cone f).π.app ⟨0⟩ := rfl
rw [this]
exact epi_π_app_zero_of_epi R (isLimit f) (fun n ↦ by simpa using by infer_instance)
instance : (lim (J := Discrete ℕ) (C := LightCondMod R)).PreservesEpimorphisms where
preserves f _ := by
have : lim.map f = (Pi.isoLimit _).inv ≫ Limits.Pi.map (f.app ⟨·⟩) ≫ (Pi.isoLimit _).hom := by
apply limit.hom_ext
intro ⟨n⟩
simp only [lim_obj, lim_map, limMap, IsLimit.map, limit.isLimit_lift, limit.lift_π,
Cones.postcompose_obj_pt, limit.cone_x, Cones.postcompose_obj_π, NatTrans.comp_app,
Functor.const_obj_obj, limit.cone_π, Pi.isoLimit, Limits.Pi.map, Category.assoc,
limit.conePointUniqueUpToIso_hom_comp, Pi.cone_pt, Pi.cone_π, Discrete.natTrans_app,
Discrete.functor_obj_eq_as]
erw [IsLimit.conePointUniqueUpToIso_inv_comp_assoc]
rfl
rw [this]
infer_instance
end LightCondensed |
.lake/packages/mathlib/Mathlib/Condensed/Light/AB.lean | import Mathlib.Algebra.Category.ModuleCat.AB
import Mathlib.CategoryTheory.Abelian.GrothendieckAxioms.Sheaf
import Mathlib.Condensed.Light.Epi
/-!
# Grothendieck's AB axioms for light condensed modules
The category of light condensed `R`-modules over a ring satisfies the countable version of
Grothendieck's AB4* axiom
-/
universe u
open CategoryTheory Limits
namespace LightCondensed
variable {R : Type u} [Ring R]
attribute [local instance] Abelian.hasFiniteBiproducts
noncomputable instance : CountableAB4Star (LightCondMod.{u} R) :=
have := hasExactLimitsOfShape_of_preservesEpi (LightCondMod R) (Discrete ℕ)
CountableAB4Star.of_hasExactLimitsOfShape_nat _
instance : IsGrothendieckAbelian.{u} (LightCondMod.{u} R) :=
Sheaf.isGrothendieckAbelian_of_essentiallySmall _ _
end LightCondensed |
.lake/packages/mathlib/Mathlib/Condensed/Light/Limits.lean | import Mathlib.Condensed.Light.Module
/-!
# Limits in categories of light condensed objects
This file adds some instances for limits in light condensed sets and modules.
-/
universe u
open CategoryTheory Limits
instance : HasLimitsOfSize.{u, u} LightCondSet.{u} := by
change HasLimitsOfSize (Sheaf _ _)
infer_instance
instance : HasFiniteLimits LightCondSet.{u} := hasFiniteLimits_of_hasLimitsOfSize _
variable (R : Type u) [Ring R]
instance : HasLimitsOfSize.{u, u} (LightCondMod.{u} R) :=
inferInstanceAs (HasLimitsOfSize (Sheaf _ _))
instance : HasLimitsOfSize.{0, 0} (LightCondMod.{u} R) :=
inferInstanceAs (HasLimitsOfSize (Sheaf _ _))
instance : HasFiniteLimits (LightCondMod.{u} R) := hasFiniteLimits_of_hasLimitsOfSize _ |
.lake/packages/mathlib/Mathlib/RingTheory/FiniteStability.lean | import Mathlib.LinearAlgebra.TensorProduct.RightExactness
import Mathlib.RingTheory.FinitePresentation
import Mathlib.RingTheory.TensorProduct.MvPolynomial
/-!
# Stability of finiteness conditions in commutative algebra
In this file we show that `Algebra.FiniteType` and `Algebra.FinitePresentation` are
stable under base change.
-/
open scoped TensorProduct
universe w₁ w₂ w₃
variable {R : Type w₁} [CommRing R]
variable {A : Type w₂} [CommRing A] [Algebra R A]
variable (B : Type w₃) [CommRing B] [Algebra R B]
namespace Algebra
namespace FiniteType
theorem baseChangeAux_surj {σ : Type*} {f : MvPolynomial σ R →ₐ[R] A} (hf : Function.Surjective f) :
Function.Surjective (Algebra.TensorProduct.map (AlgHom.id B B) f) := by
change Function.Surjective (TensorProduct.map (AlgHom.id R B) f)
apply TensorProduct.map_surjective
· exact Function.RightInverse.surjective (congrFun rfl)
· exact hf
instance baseChange [hfa : FiniteType R A] : Algebra.FiniteType B (B ⊗[R] A) := by
rw [iff_quotient_mvPolynomial''] at *
obtain ⟨n, f, hf⟩ := hfa
let g : B ⊗[R] MvPolynomial (Fin n) R →ₐ[B] B ⊗[R] A :=
Algebra.TensorProduct.map (AlgHom.id B B) f
have : Function.Surjective g := baseChangeAux_surj B hf
use n, AlgHom.comp g (MvPolynomial.algebraTensorAlgEquiv R B).symm.toAlgHom
simpa
end FiniteType
namespace FinitePresentation
instance baseChange [FinitePresentation R A] : FinitePresentation B (B ⊗[R] A) := by
obtain ⟨n, f, hsurj, hfg⟩ := ‹FinitePresentation R A›
let g : B ⊗[R] MvPolynomial (Fin n) R →ₐ[B] B ⊗[R] A :=
Algebra.TensorProduct.map (AlgHom.id B B) f
have hgsurj : Function.Surjective g := Algebra.FiniteType.baseChangeAux_surj B hsurj
have hker_eq : RingHom.ker g = Ideal.map Algebra.TensorProduct.includeRight (RingHom.ker f) :=
Algebra.TensorProduct.lTensor_ker f hsurj
have hfgg : Ideal.FG (RingHom.ker g) := by
rw [hker_eq]
exact Ideal.FG.map hfg _
let g' : MvPolynomial (Fin n) B →ₐ[B] B ⊗[R] A :=
AlgHom.comp g (MvPolynomial.algebraTensorAlgEquiv R B).symm.toAlgHom
refine ⟨n, g', ?_, Ideal.fg_ker_comp _ _ ?_ hfgg ?_⟩
· simp_all [g, g']
· change Ideal.FG (RingHom.ker (AlgEquiv.symm (MvPolynomial.algebraTensorAlgEquiv R B)))
simp only [RingHom.ker_equiv]
exact Submodule.fg_bot
· simpa using EquivLike.surjective _
end FinitePresentation
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/FiniteLength.lean | import Mathlib.RingTheory.Artinian.Module
/-!
# Modules of finite length
We define modules of finite length (`IsFiniteLength`) to be finite iterated extensions of
simple modules, and show that a module is of finite length iff it is both Noetherian and Artinian,
iff it admits a composition series.
We do not make `IsFiniteLength` a class, instead we use `[IsNoetherian R M] [IsArtinian R M]`.
## Tags
Finite length, Composition series
-/
variable (R : Type*) [Ring R]
/-- A module of finite length is either trivial or a simple extension of a module known
to be of finite length. -/
inductive IsFiniteLength : ∀ (M : Type*) [AddCommGroup M] [Module R M], Prop
| of_subsingleton {M} [AddCommGroup M] [Module R M] [Subsingleton M] : IsFiniteLength M
| of_simple_quotient {M} [AddCommGroup M] [Module R M] {N : Submodule R M}
[IsSimpleModule R (M ⧸ N)] : IsFiniteLength N → IsFiniteLength M
attribute [nontriviality] IsFiniteLength.of_subsingleton
variable {R} {M N : Type*} [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
theorem LinearEquiv.isFiniteLength (e : M ≃ₗ[R] N)
(h : IsFiniteLength R M) : IsFiniteLength R N := by
induction h generalizing N with
| of_subsingleton =>
have := e.symm.toEquiv.subsingleton; exact .of_subsingleton
| @of_simple_quotient M _ _ S _ _ ih =>
have : IsSimpleModule R (N ⧸ Submodule.map (e : M →ₗ[R] N) S) :=
IsSimpleModule.congr (Submodule.Quotient.equiv S _ e rfl).symm
exact .of_simple_quotient (ih <| e.submoduleMap S)
variable (R M) in
theorem exists_compositionSeries_of_isNoetherian_isArtinian [IsNoetherian R M] [IsArtinian R M] :
∃ s : CompositionSeries (Submodule R M), s.head = ⊥ ∧ s.last = ⊤ := by
obtain ⟨f, f0, n, hn⟩ := exists_covBy_seq_of_wellFoundedLT_wellFoundedGT (Submodule R M)
exact ⟨⟨n, fun i ↦ f i, fun i ↦ hn.2 i i.2⟩, f0.eq_bot, hn.1.eq_top⟩
theorem isFiniteLength_of_exists_compositionSeries
(h : ∃ s : CompositionSeries (Submodule R M), s.head = ⊥ ∧ s.last = ⊤) :
IsFiniteLength R M :=
Submodule.topEquiv.isFiniteLength <| by
obtain ⟨s, s_head, s_last⟩ := h
rw [← s_last]
suffices ∀ i, IsFiniteLength R (s i) from this (Fin.last _)
intro i
induction i using Fin.induction with
| zero => change IsFiniteLength R s.head; rw [s_head]; exact .of_subsingleton
| succ i ih =>
let cov := s.step i
have := (covBy_iff_quot_is_simple cov.le).mp cov
have := ((s i.castSucc).comap (s i.succ).subtype).equivMapOfInjective
_ (Submodule.injective_subtype _)
rw [Submodule.map_comap_subtype, inf_of_le_right cov.le] at this
exact .of_simple_quotient (this.symm.isFiniteLength ih)
theorem isFiniteLength_iff_isNoetherian_isArtinian :
IsFiniteLength R M ↔ IsNoetherian R M ∧ IsArtinian R M :=
open scoped IsSimpleOrder in
⟨fun h ↦ h.rec (fun {M} _ _ _ ↦ ⟨inferInstance, inferInstance⟩) fun M _ _ {N} _ _ ⟨_, _⟩ ↦
⟨(isNoetherian_iff_submodule_quotient N).mpr ⟨‹_›, isNoetherian_iff'.mpr inferInstance⟩,
(isArtinian_iff_submodule_quotient N).mpr ⟨‹_›, inferInstance⟩⟩,
fun ⟨_, _⟩ ↦ isFiniteLength_of_exists_compositionSeries
(exists_compositionSeries_of_isNoetherian_isArtinian R M)⟩
theorem isFiniteLength_iff_exists_compositionSeries :
IsFiniteLength R M ↔ ∃ s : CompositionSeries (Submodule R M), s.head = ⊥ ∧ s.last = ⊤ :=
⟨fun h ↦ have ⟨_, _⟩ := isFiniteLength_iff_isNoetherian_isArtinian.mp h
exists_compositionSeries_of_isNoetherian_isArtinian R M,
isFiniteLength_of_exists_compositionSeries⟩
open scoped IsSimpleOrder in
theorem IsSemisimpleModule.finite_tfae [IsSemisimpleModule R M] :
List.TFAE [Module.Finite R M, IsNoetherian R M, IsArtinian R M, IsFiniteLength R M,
∃ s : Set (Submodule R M), s.Finite ∧ sSupIndep s ∧
sSup s = ⊤ ∧ ∀ m ∈ s, IsSimpleModule R m] := by
rw [isFiniteLength_iff_isNoetherian_isArtinian]
obtain ⟨s, hs⟩ := IsSemisimpleModule.exists_sSupIndep_sSup_simples_eq_top R M
tfae_have 1 ↔ 2 := ⟨fun _ ↦ inferInstance, fun _ ↦ inferInstance⟩
tfae_have 2 → 5 := fun _ ↦ ⟨s, WellFoundedGT.finite_of_sSupIndep hs.1, hs⟩
tfae_have 3 → 5 := fun _ ↦ ⟨s, WellFoundedLT.finite_of_sSupIndep hs.1, hs⟩
tfae_have 5 → 4 := fun ⟨s, fin, _, sSup_eq_top, simple⟩ ↦ by
rw [← isNoetherian_top_iff, ← Submodule.topEquiv.isArtinian_iff,
← sSup_eq_top, sSup_eq_iSup, ← iSup_subtype'']
rw [SetCoe.forall'] at simple
have := fin.to_subtype
exact ⟨isNoetherian_iSup, isArtinian_iSup⟩
tfae_have 4 → 2 := And.left
tfae_have 4 → 3 := And.right
tfae_finish
instance [IsSemisimpleModule R M] [Module.Finite R M] : IsArtinian R M :=
(IsSemisimpleModule.finite_tfae.out 0 2).mp ‹_›
variable {f : M →ₗ[R] N}
lemma IsFiniteLength.of_injective (H : IsFiniteLength R N) (hf : Function.Injective f) :
IsFiniteLength R M := by
rw [isFiniteLength_iff_isNoetherian_isArtinian] at H ⊢
cases H
exact ⟨isNoetherian_of_injective f hf, isArtinian_of_injective f hf⟩
lemma IsFiniteLength.of_surjective (H : IsFiniteLength R M) (hf : Function.Surjective f) :
IsFiniteLength R N := by
rw [isFiniteLength_iff_isNoetherian_isArtinian] at H ⊢
cases H
exact ⟨isNoetherian_of_surjective _ f (LinearMap.range_eq_top.mpr hf),
isArtinian_of_surjective _ f hf⟩
/- The following instances are now automatic:
example [IsSemisimpleRing R] : IsNoetherianRing R := inferInstance
example [IsSemisimpleRing R] : IsArtinianRing R := inferInstance
-/ |
.lake/packages/mathlib/Mathlib/RingTheory/Fintype.lean | import Mathlib.Data.ZMod.Basic
import Mathlib.Tactic.NormNum
/-!
# Some facts about finite rings
-/
open Finset ZMod
section Ring
variable {R : Type*} [Ring R] [Fintype R] [DecidableEq R]
lemma Finset.univ_of_card_le_two (h : Fintype.card R ≤ 2) :
(univ : Finset R) = {0, 1} := by
rcases subsingleton_or_nontrivial R
· exact le_antisymm (fun a _ ↦ by simp [Subsingleton.elim a 0]) (Finset.subset_univ _)
· refine (eq_of_subset_of_card_le (subset_univ _) ?_).symm
convert h
simp
lemma Finset.univ_of_card_le_three (h : Fintype.card R ≤ 3) :
(univ : Finset R) = {0, 1, -1} := by
refine (eq_of_subset_of_card_le (subset_univ _) ?_).symm
rcases lt_or_eq_of_le h with h | h
· apply card_le_card
rw [Finset.univ_of_card_le_two (Nat.lt_succ_iff.1 h)]
intro a ha
simp only [mem_insert, mem_singleton] at ha
rcases ha with rfl | rfl <;> simp
· have : Nontrivial R := by
refine Fintype.one_lt_card_iff_nontrivial.1 ?_
rw [h]
simp
rw [card_univ, h, card_insert_of_notMem, card_insert_of_notMem, card_singleton]
· rw [mem_singleton]
intro H
rw [← add_eq_zero_iff_eq_neg, one_add_one_eq_two] at H
apply_fun (ringEquivOfPrime R Nat.prime_three h).symm at H
simp only [map_ofNat, map_zero] at H
replace H : ((2 : ℕ) : ZMod 3) = 0 := H
rw [natCast_eq_zero_iff] at H
norm_num at H
· intro h
simp only [mem_insert, mem_singleton, zero_eq_neg] at h
rcases h with (h | h)
· exact zero_ne_one h
· exact zero_ne_one h.symm
end Ring
section MonoidWithZero
variable (M₀ : Type*) [MonoidWithZero M₀] [Nontrivial M₀]
open scoped Classical in
theorem card_units_lt [Fintype M₀] : Fintype.card M₀ˣ < Fintype.card M₀ :=
Fintype.card_lt_of_injective_of_notMem Units.val Units.val_injective not_isUnit_zero
lemma natCard_units_lt [Finite M₀] : Nat.card M₀ˣ < Nat.card M₀ := by
have : Fintype M₀ := Fintype.ofFinite M₀
simpa only [Fintype.card_eq_nat_card] using card_units_lt M₀
variable {M₀}
lemma orderOf_lt_card [Finite M₀] (a : M₀) : orderOf a < Nat.card M₀ := by
by_cases h : IsUnit a
· rw [← h.unit_spec, orderOf_units]
exact orderOf_le_card.trans_lt <| natCard_units_lt M₀
· rw [orderOf_eq_zero_iff'.mpr fun n hn ha ↦ h <| IsUnit.of_pow_eq_one ha hn.ne']
exact Nat.card_pos
end MonoidWithZero
lemma ZMod.orderOf_lt {n : ℕ} (hn : 1 < n) (a : ZMod n) : orderOf a < n :=
have : NeZero n := ⟨Nat.ne_zero_of_lt hn⟩
have : Nontrivial (ZMod n) := nontrivial_iff.mpr hn.ne'
(orderOf_lt_card a).trans_eq <| Nat.card_zmod n |
.lake/packages/mathlib/Mathlib/RingTheory/RingInvo.lean | import Mathlib.Algebra.Ring.Equiv
import Mathlib.Algebra.Ring.Opposite
/-!
# Ring involutions
This file defines a ring involution as a structure extending `R ≃+* Rᵐᵒᵖ`,
with the additional fact `f.involution : (f (f x).unop).unop = x`.
## Notation
We provide a coercion to a function `R → Rᵐᵒᵖ`.
## References
* <https://en.wikipedia.org/wiki/Involution_(mathematics)#Ring_theory>
## Tags
Ring involution
-/
variable {F : Type*} (R : Type*)
/-- A ring involution -/
structure RingInvo [Semiring R] extends R ≃+* Rᵐᵒᵖ where
/-- The requirement that the ring homomorphism is its own inverse -/
involution' : ∀ x, (toFun (toFun x).unop).unop = x
/-- The equivalence of rings underlying a ring involution. -/
add_decl_doc RingInvo.toRingEquiv
/-- `RingInvoClass F R` states that `F` is a type of ring involutions.
You should extend this class when you extend `RingInvo`. -/
class RingInvoClass (F R : Type*) [Semiring R] [EquivLike F R Rᵐᵒᵖ] : Prop
extends RingEquivClass F R Rᵐᵒᵖ where
/-- Every ring involution must be its own inverse -/
involution : ∀ (f : F) (x), (f (f x).unop).unop = x
/-- Turn an element of a type `F` satisfying `RingInvoClass F R` into an actual
`RingInvo`. This is declared as the default coercion from `F` to `RingInvo R`. -/
@[coe]
def RingInvoClass.toRingInvo {R} [Semiring R] [EquivLike F R Rᵐᵒᵖ] [RingInvoClass F R] (f : F) :
RingInvo R :=
{ (f : R ≃+* Rᵐᵒᵖ) with involution' := RingInvoClass.involution f }
namespace RingInvo
variable {R} [Semiring R] [EquivLike F R Rᵐᵒᵖ]
/-- Any type satisfying `RingInvoClass` can be cast into `RingInvo` via
`RingInvoClass.toRingInvo`. -/
instance [RingInvoClass F R] : CoeTC F (RingInvo R) :=
⟨RingInvoClass.toRingInvo⟩
instance : EquivLike (RingInvo R) R Rᵐᵒᵖ where
coe f := f.toFun
inv f := f.invFun
coe_injective' e f h₁ h₂ := by
rcases e with ⟨⟨tE, _⟩, _⟩; rcases f with ⟨⟨tF, _⟩, _⟩
cases tE
cases tF
congr
left_inv f := f.left_inv
right_inv f := f.right_inv
instance : RingInvoClass (RingInvo R) R where
map_add f := f.map_add'
map_mul f := f.map_mul'
involution f := f.involution'
/-- Construct a ring involution from a ring homomorphism. -/
def mk' (f : R →+* Rᵐᵒᵖ) (involution : ∀ r, (f (f r).unop).unop = r) : RingInvo R :=
{ f with
invFun := fun r => (f r.unop).unop
left_inv := fun r => involution r
right_inv := fun _ => MulOpposite.unop_injective <| involution _
involution' := involution }
@[simp]
theorem involution (f : RingInvo R) (x : R) : (f (f x).unop).unop = x :=
f.involution' x
-- We might want to restore the below instance if we remove `RingEquivClass.toRingEquiv`.
-- instance hasCoeToRingEquiv : Coe (RingInvo R) (R ≃+* Rᵐᵒᵖ) :=
-- ⟨RingInvo.toRingEquiv⟩
@[norm_cast]
theorem coe_ringEquiv (f : RingInvo R) (a : R) : (f : R ≃+* Rᵐᵒᵖ) a = f a :=
rfl
theorem map_eq_zero_iff (f : RingInvo R) {x : R} : f x = 0 ↔ x = 0 :=
f.toRingEquiv.map_eq_zero_iff
end RingInvo
open RingInvo
section CommRing
variable [CommRing R]
/-- The identity function of a `CommRing` is a ring involution. -/
protected def RingInvo.id : RingInvo R :=
{ RingEquiv.toOpposite R with involution' := fun _ => rfl }
instance : Inhabited (RingInvo R) :=
⟨RingInvo.id _⟩
end CommRing |
.lake/packages/mathlib/Mathlib/RingTheory/Length.lean | import Mathlib.Algebra.Exact
import Mathlib.LinearAlgebra.Basis.VectorSpace
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.Order.KrullDimension
import Mathlib.RingTheory.FiniteLength
/-!
# Length of modules
## Main results
- `Module.length`: `Module.length R M` is the length of `M` as an `R`-module.
- `Module.length_pos`: The length of a nontrivial module is positive
- `Module.length_ne_top`: The length of an Artinian and Noetherian module is finite.
- `Module.length_eq_add_of_exact`: Length is additive in exact sequences.
-/
variable (R M : Type*) [Ring R] [AddCommGroup M] [Module R M]
/-- The length of a module, defined as the krull dimension of its submodule lattice. -/
noncomputable
def Module.length : ℕ∞ :=
(Order.krullDim (Submodule R M)).unbot (by simp [Order.krullDim_eq_bot_iff])
lemma Module.coe_length :
(Module.length R M : WithBot ℕ∞) = Order.krullDim (Submodule R M) :=
WithBot.coe_unbot _ _
lemma Module.length_eq_height : Module.length R M = Order.height (⊤ : Submodule R M) := by
apply WithBot.coe_injective
rw [Module.coe_length, Order.height_top_eq_krullDim]
lemma Module.length_eq_coheight : Module.length R M = Order.coheight (⊥ : Submodule R M) := by
apply WithBot.coe_injective
rw [Module.coe_length, Order.coheight_bot_eq_krullDim]
variable {R M}
lemma Module.length_eq_zero_iff : Module.length R M = 0 ↔ Subsingleton M := by
rw [← WithBot.coe_inj, Module.coe_length, WithBot.coe_zero,
Order.krullDim_eq_zero_iff_of_orderTop, Submodule.subsingleton_iff]
@[simp, nontriviality]
lemma Module.length_eq_zero [Subsingleton M] : Module.length R M = 0 :=
Module.length_eq_zero_iff.mpr ‹_›
@[simp, nontriviality]
lemma Module.length_eq_zero_of_subsingleton_ring [Subsingleton R] : Module.length R M = 0 :=
have := Module.subsingleton R M
Module.length_eq_zero
lemma Module.length_pos_iff : 0 < Module.length R M ↔ Nontrivial M := by
rw [pos_iff_ne_zero, ne_eq, Module.length_eq_zero_iff, not_subsingleton_iff_nontrivial]
lemma Module.length_pos [Nontrivial M] : 0 < Module.length R M :=
Module.length_pos_iff.mpr ‹_›
lemma Module.length_compositionSeries (s : CompositionSeries (Submodule R M)) (h₁ : s.head = ⊥)
(h₂ : s.last = ⊤) : s.length = Module.length R M := by
have H := isFiniteLength_of_exists_compositionSeries ⟨s, h₁, h₂⟩
have := (isFiniteLength_iff_isNoetherian_isArtinian.mp H).1
have := (isFiniteLength_iff_isNoetherian_isArtinian.mp H).2
rw [← WithBot.coe_inj, Module.coe_length]
apply le_antisymm
· exact (Order.LTSeries.length_le_krullDim <| s.map ⟨id, fun h ↦ h.1⟩)
· rw [Order.krullDim, iSup_le_iff]
intro t
refine WithBot.coe_le_coe.mpr ?_
obtain ⟨t', i, hi, ht₁, ht₂⟩ := t.exists_relSeries_covBy_and_head_eq_bot_and_last_eq_bot
have := (s.jordan_holder t' (h₁.trans ht₁.symm) (h₂.trans ht₂.symm)).choose
have h : t.length ≤ t'.length := by simpa using Fintype.card_le_of_embedding i
have h' : t'.length = s.length := by simpa using Fintype.card_congr this.symm
simpa using h.trans h'.le
lemma Module.length_eq_top_iff_infiniteDimensionalOrder :
length R M = ⊤ ↔ InfiniteDimensionalOrder (Submodule R M) := by
rw [← WithBot.coe_inj, WithBot.coe_top, coe_length, Order.krullDim_eq_top_iff,
← not_finiteDimensionalOrder_iff]
lemma Module.length_ne_top_iff_finiteDimensionalOrder :
length R M ≠ ⊤ ↔ FiniteDimensionalOrder (Submodule R M) := by
rw [Ne, length_eq_top_iff_infiniteDimensionalOrder, ← not_finiteDimensionalOrder_iff, not_not]
lemma Module.length_ne_top_iff : Module.length R M ≠ ⊤ ↔ IsFiniteLength R M := by
refine ⟨fun h ↦ ?_, fun H ↦ ?_⟩
· rw [length_ne_top_iff_finiteDimensionalOrder] at h
rw [isFiniteLength_iff_isNoetherian_isArtinian, isNoetherian_iff, isArtinian_iff]
let R : SetRel (Submodule R M) (Submodule R M) :=
{(N₁, N₂) : Submodule R M × Submodule R M | N₁ < N₂}
change R.inv.IsWellFounded ∧ R.IsWellFounded
exact ⟨.of_finiteDimensional R.inv, .of_finiteDimensional R⟩
· obtain ⟨s, hs₁, hs₂⟩ := isFiniteLength_iff_exists_compositionSeries.mp H
rw [← length_compositionSeries s hs₁ hs₂]
simp
lemma Module.length_ne_top [IsArtinian R M] [IsNoetherian R M] : Module.length R M ≠ ⊤ := by
rw [length_ne_top_iff, isFiniteLength_iff_isNoetherian_isArtinian]
exact ⟨‹_›, ‹_›⟩
lemma Module.length_submodule {N : Submodule R M} :
Module.length R N = Order.height N := by
apply WithBot.coe_injective
rw [Order.height_eq_krullDim_Iic, coe_length, Order.krullDim_eq_of_orderIso (Submodule.mapIic _)]
lemma Module.length_quotient {N : Submodule R M} :
Module.length R (M ⧸ N) = Order.coheight N := by
apply WithBot.coe_injective
rw [Order.coheight_eq_krullDim_Ici, coe_length,
Order.krullDim_eq_of_orderIso (Submodule.comapMkQRelIso N)]
lemma LinearEquiv.length_eq {N : Type*} [AddCommGroup N] [Module R N] (e : M ≃ₗ[R] N) :
Module.length R M = Module.length R N := by
apply WithBot.coe_injective
rw [Module.coe_length, Module.coe_length,
Order.krullDim_eq_of_orderIso (Submodule.orderIsoMapComap e)]
lemma Module.length_bot :
Module.length R (⊥ : Submodule R M) = 0 :=
Module.length_eq_zero
@[simp] lemma Module.length_top :
Module.length R (⊤ : Submodule R M) = Module.length R M := by
rw [Module.length_submodule, Module.length_eq_height]
lemma Submodule.height_lt_top [IsArtinian R M] [IsNoetherian R M] (N : Submodule R M) :
Order.height N < ⊤ := by
simpa only [← Module.length_submodule] using Module.length_ne_top.lt_top
lemma Submodule.height_strictMono [IsArtinian R M] [IsNoetherian R M] :
StrictMono (Order.height : Submodule R M → ℕ∞) :=
fun N _ h ↦ Order.height_strictMono h N.height_lt_top
lemma Submodule.length_lt [IsArtinian R M] [IsNoetherian R M] {N : Submodule R M} (h : N ≠ ⊤) :
Module.length R N < Module.length R M := by
simpa [← Module.length_top (M := M), Module.length_submodule] using height_strictMono h.lt_top
variable {N P : Type*} [AddCommGroup N] [AddCommGroup P] [Module R N] [Module R P]
variable (f : N →ₗ[R] M) (g : M →ₗ[R] P) (hf : Function.Injective f) (hg : Function.Surjective g)
variable (H : Function.Exact f g)
include hf hg H in
/-- Length is additive in exact sequences. -/
lemma Module.length_eq_add_of_exact :
Module.length R M = Module.length R N + Module.length R P := by
by_cases hP : IsFiniteLength R P
· by_cases hN : IsFiniteLength R N
· obtain ⟨s, hs₁, hs₂⟩ := isFiniteLength_iff_exists_compositionSeries.mp hP
obtain ⟨t, ht₁, ht₂⟩ := isFiniteLength_iff_exists_compositionSeries.mp hN
let s' : CompositionSeries (Submodule R M) :=
s.map ⟨Submodule.comap g, Submodule.comap_covBy_of_surjective hg⟩
let t' : CompositionSeries (Submodule R M) :=
t.map ⟨Submodule.map f, Submodule.map_covBy_of_injective hf⟩
have hfg : Submodule.map f ⊤ = Submodule.comap g ⊥ := by
rw [Submodule.map_top, Submodule.comap_bot, LinearMap.exact_iff.mp H]
let r := t'.smash s' (by simpa [s', t', hs₁, ht₂] using hfg)
rw [← Module.length_compositionSeries s hs₁ hs₂,
← Module.length_compositionSeries t ht₁ ht₂,
← Module.length_compositionSeries r
(by simpa [r, t', ht₁, -Submodule.map_bot] using Submodule.map_bot f)
(by simpa [r, s', hs₂, -Submodule.comap_top] using Submodule.comap_top g)]
simp_rw [r, RelSeries.smash_length, Nat.cast_add, s', t', RelSeries.map_length]
· have := mt (IsFiniteLength.of_injective · hf) hN
rw [← Module.length_ne_top_iff, ne_eq, not_not] at hN this
rw [hN, this, top_add]
· have := mt (IsFiniteLength.of_surjective · hg) hP
rw [← Module.length_ne_top_iff, ne_eq, not_not] at hP this
rw [hP, this, add_top]
include hf in
lemma Module.length_le_of_injective : Module.length R N ≤ Module.length R M := by
rw [Module.length_eq_add_of_exact f (LinearMap.range f).mkQ hf
(Submodule.mkQ_surjective _) (LinearMap.exact_map_mkQ_range f)]
exact le_self_add
include hg in
lemma Module.length_le_of_surjective : Module.length R P ≤ Module.length R M := by
rw [Module.length_eq_add_of_exact (LinearMap.ker g).subtype g (Submodule.subtype_injective _) hg
(LinearMap.exact_subtype_ker_map g)]
exact le_add_self
variable (R M N) in
@[simp]
lemma Module.length_prod :
Module.length R (M × N) = Module.length R M + Module.length R N :=
Module.length_eq_add_of_exact _ _ LinearMap.inl_injective LinearMap.snd_surjective .inl_snd
variable (R) in
@[simp]
lemma Module.length_pi_of_fintype : ∀ {ι : Type*} [Fintype ι]
(M : ι → Type*) [∀ i, AddCommGroup (M i)] [∀ i, Module R (M i)],
Module.length R (Π i, M i) = ∑ i, Module.length R (M i) := by
apply Fintype.induction_empty_option
· intro α β _ e IH M _ _
let _ : Fintype α := .ofEquiv β e.symm
rw [← (LinearEquiv.piCongrLeft R M e).length_eq, IH, e.sum_comp (length R <| M ·)]
· intro M _ _
simp [Module.length_eq_zero]
· intro ι _ IH M _ _
rw [(LinearEquiv.piOptionEquivProd _).length_eq, Module.length_prod, IH, add_comm,
Fintype.sum_option, add_comm]
@[simp]
lemma Module.length_finsupp {ι : Type*} :
Module.length R (ι →₀ M) = ENat.card ι * Module.length R M := by
cases finite_or_infinite ι
· cases nonempty_fintype ι
simp [(Finsupp.linearEquivFunOnFinite R M ι).length_eq]
nontriviality M
rw [ENat.card_eq_top_of_infinite, ENat.top_mul length_pos.ne', ENat.eq_top_iff_forall_ge]
intro m
obtain ⟨s, hs⟩ := Infinite.exists_subset_card_eq ι m
have : length R (s →₀ M) = ↑m * length R M := by
simp [(Finsupp.linearEquivFunOnFinite R M _).length_eq, hs]
refine le_trans ?_ (Module.length_le_of_injective (Finsupp.lmapDomain M R ((↑) : s → ι))
(Finsupp.mapDomain_injective Subtype.val_injective))
rw [this]
exact ENat.self_le_mul_right _ length_pos.ne'
@[simp]
lemma Module.length_pi {ι : Type*} :
Module.length R (ι → M) = ENat.card ι * Module.length R M := by
cases finite_or_infinite ι
· cases nonempty_fintype ι
simp
nontriviality M
rw [ENat.card_eq_top_of_infinite, ENat.top_mul length_pos.ne', ← top_le_iff]
refine le_trans ?_ (Module.length_le_of_injective Finsupp.lcoeFun DFunLike.coe_injective)
simp [ENat.top_mul length_pos.ne']
attribute [nontriviality] rank_subsingleton'
variable (R M) in
lemma Module.length_of_free [Module.Free R M] :
Module.length R M = (Module.rank R M).toENat * Module.length R R := by
let b := Module.Free.chooseBasis R M
nontriviality R
nontriviality M
by_cases H : Module.length R R = ⊤
· rw [b.repr.length_eq, Module.length_finsupp, H, ENat.mul_top', ENat.mul_top']
congr 1
simp [ENat.card_eq_zero_iff_empty, rank_pos_of_free.ne']
rw [← ne_eq, Module.length_ne_top_iff, isFiniteLength_iff_isNoetherian_isArtinian] at H
cases H
let b := Module.Free.chooseBasis R M
rw [b.repr.length_eq, Module.length_finsupp, Free.rank_eq_card_chooseBasisIndex, ENat.card]
variable (R M) in
lemma Module.length_of_free_of_finite
[StrongRankCondition R] [Module.Free R M] [Module.Finite R M] :
Module.length R M = Module.finrank R M * Module.length R R := by
rw [length_of_free, Cardinal.toENat_eq_nat.mpr (finrank_eq_rank _ _).symm]
lemma Module.length_eq_one_iff :
Module.length R M = 1 ↔ IsSimpleModule R M := by
rw [← WithBot.coe_inj, Module.coe_length, WithBot.coe_one,
Order.krullDim_eq_one_iff_of_boundedOrder, isSimpleModule_iff]
variable (R M) in
@[simp]
lemma Module.length_eq_one [IsSimpleModule R M] :
Module.length R M = 1 :=
Module.length_eq_one_iff.mpr ‹_›
lemma Module.length_eq_rank
(K M : Type*) [DivisionRing K] [AddCommGroup M] [Module K M] :
Module.length K M = (Module.rank K M).toENat := by
simp [Module.length_of_free]
lemma Module.length_eq_finrank
(K M : Type*) [DivisionRing K] [AddCommGroup M] [Module K M] [Module.Finite K M] :
Module.length K M = Module.finrank K M := by
simp [Module.length_of_free] |
.lake/packages/mathlib/Mathlib/RingTheory/SurjectiveOnStalks.lean | import Mathlib.RingTheory.Localization.AtPrime.Basic
import Mathlib.RingTheory.TensorProduct.Basic
/-!
# Ring Homomorphisms surjective on stalks
In this file, we prove some results on ring homomorphisms surjective on stalks, to be used in
the development of immersions in algebraic geometry.
A ring homomorphism `R →+* S` is surjective on stalks if `R_p →+* S_q` is surjective for all pairs
of primes `p = f⁻¹(q)`. We show that this property is stable under composition and base change, and
that surjections and localizations satisfy this.
-/
variable {R : Type*} [CommRing R] (M : Submonoid R) {S : Type*} [CommRing S]
variable {T : Type*} [CommRing T]
variable {g : S →+* T} {f : R →+* S}
namespace RingHom
/--
A ring homomorphism `R →+* S` is surjective on stalks if `R_p →+* S_q` is surjective for all pairs
of primes `p = f⁻¹(q)`.
-/
def SurjectiveOnStalks (f : R →+* S) : Prop :=
∀ (P : Ideal S) (_ : P.IsPrime), Function.Surjective (Localization.localRingHom _ P f rfl)
/--
`R_p →+* S_q` is surjective if and only if
every `x : S` is of the form `f x / f r` for some `f r ∉ q`.
This is useful when proving `SurjectiveOnStalks`.
-/
lemma surjective_localRingHom_iff (P : Ideal S) [P.IsPrime] :
Function.Surjective (Localization.localRingHom _ P f rfl) ↔
∀ s : S, ∃ x r : R, ∃ c ∉ P, f r ∉ P ∧ c * f r * s = c * f x := by
constructor
· intro H y
obtain ⟨a, ha⟩ := H (IsLocalization.mk' _ y (1 : P.primeCompl))
obtain ⟨a, t, rfl⟩ := IsLocalization.exists_mk'_eq (P.comap f).primeCompl a
rw [Localization.localRingHom_mk', IsLocalization.mk'_eq_iff_eq,
Submonoid.coe_one, one_mul, IsLocalization.eq_iff_exists P.primeCompl] at ha
obtain ⟨c, hc⟩ := ha
simp only [← mul_assoc] at hc
exact ⟨_, _, _, c.2, t.2, hc.symm⟩
· refine fun H y ↦ Localization.ind (fun ⟨y, t, h⟩ ↦ ?_) y
simp only
obtain ⟨yx, ys, yc, hyc, hy, ey⟩ := H y
obtain ⟨tx, ts, yt, hyt, ht, et⟩ := H t
refine ⟨Localization.mk (yx * ts) ⟨ys * tx, Submonoid.mul_mem _ hy ?_⟩, ?_⟩
· exact fun H ↦ mul_mem (P.primeCompl.mul_mem hyt ht) h (et ▸ Ideal.mul_mem_left _ yt H)
· simp only [Localization.mk_eq_mk', Localization.localRingHom_mk', map_mul f,
IsLocalization.mk'_eq_iff_eq, IsLocalization.eq_iff_exists P.primeCompl]
refine ⟨⟨yc, hyc⟩ * ⟨yt, hyt⟩, ?_⟩
simp only [Submonoid.coe_mul]
convert congr($(ey.symm) * $(et)) using 1 <;> ring
lemma surjectiveOnStalks_iff_forall_ideal :
f.SurjectiveOnStalks ↔
∀ I : Ideal S, I ≠ ⊤ → ∀ s : S, ∃ x r : R, ∃ c ∉ I, f r ∉ I ∧ c * f r * s = c * f x := by
simp_rw [SurjectiveOnStalks, surjective_localRingHom_iff]
refine ⟨fun H I hI s ↦ ?_, fun H I hI ↦ H I hI.ne_top⟩
obtain ⟨M, hM, hIM⟩ := I.exists_le_maximal hI
obtain ⟨x, r, c, hc, hr, e⟩ := H M hM.isPrime s
exact ⟨x, r, c, fun h ↦ hc (hIM h), fun h ↦ hr (hIM h), e⟩
lemma surjectiveOnStalks_iff_forall_maximal :
f.SurjectiveOnStalks ↔ ∀ (I : Ideal S) (_ : I.IsMaximal),
Function.Surjective (Localization.localRingHom _ I f rfl) := by
refine ⟨fun H I hI ↦ H I hI.isPrime, fun H I hI ↦ ?_⟩
simp_rw [surjective_localRingHom_iff] at H ⊢
intro s
obtain ⟨M, hM, hIM⟩ := I.exists_le_maximal hI.ne_top
obtain ⟨x, r, c, hc, hr, e⟩ := H M hM s
exact ⟨x, r, c, fun h ↦ hc (hIM h), fun h ↦ hr (hIM h), e⟩
lemma surjectiveOnStalks_iff_forall_maximal' :
f.SurjectiveOnStalks ↔ ∀ I : Ideal S, I.IsMaximal →
∀ s : S, ∃ x r : R, ∃ c ∉ I, f r ∉ I ∧ c * f r * s = c * f x := by
simp only [surjectiveOnStalks_iff_forall_maximal, surjective_localRingHom_iff]
lemma surjectiveOnStalks_of_exists_div (h : ∀ x : S, ∃ r s : R, IsUnit (f s) ∧ f s * x = f r) :
SurjectiveOnStalks f :=
surjectiveOnStalks_iff_forall_ideal.mpr fun I hI x ↦
let ⟨r, s, hr, hr'⟩ := h x
⟨r, s, 1, by simpa [← Ideal.eq_top_iff_one], fun h ↦ hI (I.eq_top_of_isUnit_mem h hr), by simpa⟩
lemma surjectiveOnStalks_of_surjective (h : Function.Surjective f) :
SurjectiveOnStalks f :=
surjectiveOnStalks_iff_forall_ideal.mpr fun _ _ s ↦
let ⟨r, hr⟩ := h s
⟨r, 1, 1, by simpa [← Ideal.eq_top_iff_one], by simpa [← Ideal.eq_top_iff_one], by simp [hr]⟩
lemma SurjectiveOnStalks.comp (hg : SurjectiveOnStalks g) (hf : SurjectiveOnStalks f) :
SurjectiveOnStalks (g.comp f) := by
intro I hI
have := (hg I hI).comp (hf _ (hI.comap g))
rwa [← RingHom.coe_comp, ← Localization.localRingHom_comp] at this
lemma SurjectiveOnStalks.of_comp (hg : SurjectiveOnStalks (g.comp f)) :
SurjectiveOnStalks g := by
intro I hI
have := hg I hI
rw [Localization.localRingHom_comp (I.comap (g.comp f)) (I.comap g) _ _ rfl _ rfl,
RingHom.coe_comp] at this
exact this.of_comp
open TensorProduct
variable [Algebra R T] [Algebra R S] in
/--
If `R → T` is surjective on stalks, and `J` is some prime of `T`,
then every element `x` in `S ⊗[R] T` satisfies `(1 ⊗ r • t) * x = a ⊗ t` for some
`r : R`, `a : S`, and `t : T` such that `r • t ∉ J`.
-/
lemma SurjectiveOnStalks.exists_mul_eq_tmul
(hf₂ : (algebraMap R T).SurjectiveOnStalks)
(x : S ⊗[R] T) (J : Ideal T) (hJ : J.IsPrime) :
∃ (t : T) (r : R) (a : S), (r • t ∉ J) ∧
(1 : S) ⊗ₜ[R] (r • t) * x = a ⊗ₜ[R] t := by
induction x with
| zero =>
exact ⟨1, 1, 0, by rw [one_smul]; exact J.primeCompl.one_mem,
by rw [mul_zero, TensorProduct.zero_tmul]⟩
| tmul x₁ x₂ =>
obtain ⟨y, s, c, hs, hc, e⟩ := (surjective_localRingHom_iff _).mp (hf₂ J hJ) x₂
simp_rw [Algebra.smul_def]
refine ⟨c, s, y • x₁, J.primeCompl.mul_mem hc hs, ?_⟩
rw [Algebra.TensorProduct.tmul_mul_tmul, one_mul, mul_comm _ c, e,
TensorProduct.smul_tmul, Algebra.smul_def, mul_comm]
| add x₁ x₂ hx₁ hx₂ =>
obtain ⟨t₁, r₁, a₁, hr₁, e₁⟩ := hx₁
obtain ⟨t₂, r₂, a₂, hr₂, e₂⟩ := hx₂
have : (r₁ * r₂) • (t₁ * t₂) = (r₁ • t₁) * (r₂ • t₂) := by
simp_rw [← smul_eq_mul]; rw [smul_smul_smul_comm]
refine ⟨t₁ * t₂, r₁ * r₂, r₂ • a₁ + r₁ • a₂, this.symm ▸ J.primeCompl.mul_mem hr₁ hr₂, ?_⟩
rw [this, ← one_mul (1 : S), ← Algebra.TensorProduct.tmul_mul_tmul, mul_add, mul_comm (_ ⊗ₜ _),
mul_assoc, e₁, Algebra.TensorProduct.tmul_mul_tmul, one_mul, smul_mul_assoc,
← TensorProduct.smul_tmul, mul_comm (_ ⊗ₜ _), mul_assoc, e₂,
Algebra.TensorProduct.tmul_mul_tmul, one_mul, smul_mul_assoc, ← TensorProduct.smul_tmul,
TensorProduct.add_tmul, mul_comm t₁ t₂]
variable (S) in
lemma surjectiveOnStalks_of_isLocalization
[Algebra R S] [IsLocalization M S] :
SurjectiveOnStalks (algebraMap R S) := by
refine surjectiveOnStalks_of_exists_div fun s ↦ ?_
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq M s
exact ⟨x, s, IsLocalization.map_units S s, IsLocalization.mk'_spec' S x s⟩
lemma SurjectiveOnStalks.baseChange
[Algebra R T] [Algebra R S]
(hf : (algebraMap R T).SurjectiveOnStalks) :
(algebraMap S (S ⊗[R] T)).SurjectiveOnStalks := by
let g : T →+* S ⊗[R] T := Algebra.TensorProduct.includeRight.toRingHom
intro J hJ
rw [surjective_localRingHom_iff]
intro x
obtain ⟨t, r, a, ht, e⟩ := hf.exists_mul_eq_tmul x (J.comap g) inferInstance
refine ⟨a, algebraMap _ _ r, 1 ⊗ₜ (r • t), ht, ?_, ?_⟩
· intro H
simp only [Algebra.algebraMap_eq_smul_one (A := S), Algebra.TensorProduct.algebraMap_apply,
Algebra.algebraMap_self, id_apply, smul_tmul, ← Algebra.algebraMap_eq_smul_one (A := T)] at H
rw [Ideal.mem_comap, Algebra.smul_def, g.map_mul] at ht
exact ht (J.mul_mem_right _ H)
· simp only [tmul_smul, Algebra.TensorProduct.algebraMap_apply, Algebra.algebraMap_self,
RingHomCompTriple.comp_apply, Algebra.smul_mul_assoc, Algebra.TensorProduct.tmul_mul_tmul,
one_mul, mul_one, id_apply, ← e]
rw [Algebra.algebraMap_eq_smul_one, ← smul_tmul', smul_mul_assoc]
lemma surjectiveOnStalks_iff_of_isLocalHom [IsLocalRing S] [IsLocalHom f] :
f.SurjectiveOnStalks ↔ Function.Surjective f := by
refine ⟨fun H x ↦ ?_, fun h ↦ surjectiveOnStalks_of_surjective h⟩
obtain ⟨y, r, c, hc, hr, e⟩ :=
(surjective_localRingHom_iff _).mp (H (IsLocalRing.maximalIdeal _) inferInstance) x
simp only [IsLocalRing.mem_maximalIdeal, mem_nonunits_iff, not_not] at hc hr
refine ⟨(isUnit_of_map_unit f r hr).unit⁻¹ * y, ?_⟩
apply hr.mul_right_injective
apply hc.mul_right_injective
simp only [← map_mul, ← mul_assoc, IsUnit.mul_val_inv, one_mul, e]
end RingHom |
.lake/packages/mathlib/Mathlib/RingTheory/Presentation.lean | import Mathlib.RingTheory.Extension.Presentation.Basic
deprecated_module (since := "2025-05-11") |
.lake/packages/mathlib/Mathlib/RingTheory/IsTensorProduct.lean | import Mathlib.RingTheory.TensorProduct.Maps
/-!
# The characteristic predicate of tensor product
## Main definitions
- `IsTensorProduct`: A predicate on `f : M₁ →ₗ[R] M₂ →ₗ[R] M` expressing that `f` realizes `M` as
the tensor product of `M₁ ⊗[R] M₂`. This is defined by requiring the lift `M₁ ⊗[R] M₂ → M` to be
bijective.
- `IsBaseChange`: A predicate on an `R`-algebra `S` and a map `f : M →ₗ[R] N` with `N` being an
`S`-module, expressing that `f` realizes `N` as the base change of `M` along `R → S`.
- `Algebra.IsPushout`: A predicate on the following diagram of scalar towers
```
R → S
↓ ↓
R' → S'
```
asserting that is a pushout diagram (i.e. `S' = S ⊗[R] R'`)
## Main results
- `TensorProduct.isBaseChange`: `S ⊗[R] M` is the base change of `M` along `R → S`.
-/
universe u v₁ v₂ v₃ v₄
open TensorProduct
section IsTensorProduct
variable {R : Type*} [CommSemiring R]
variable {M₁ M₂ M M' : Type*}
variable [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M] [AddCommMonoid M']
variable [Module R M₁] [Module R M₂] [Module R M] [Module R M']
variable (f : M₁ →ₗ[R] M₂ →ₗ[R] M)
variable {N₁ N₂ N : Type*} [AddCommMonoid N₁] [AddCommMonoid N₂] [AddCommMonoid N]
variable [Module R N₁] [Module R N₂] [Module R N]
variable {g : N₁ →ₗ[R] N₂ →ₗ[R] N}
/-- Given a bilinear map `f : M₁ →ₗ[R] M₂ →ₗ[R] M`, `IsTensorProduct f` means that
`M` is the tensor product of `M₁` and `M₂` via `f`.
This is defined by requiring the lift `M₁ ⊗[R] M₂ → M` to be bijective.
-/
def IsTensorProduct : Prop :=
Function.Bijective (TensorProduct.lift f)
variable (R M N) {f}
theorem TensorProduct.isTensorProduct : IsTensorProduct (TensorProduct.mk R M N) := by
delta IsTensorProduct
convert_to Function.Bijective (LinearMap.id : M ⊗[R] N →ₗ[R] M ⊗[R] N) using 2
· apply TensorProduct.ext'
simp
· exact Function.bijective_id
namespace IsTensorProduct
variable {R M N}
/-- If `M` is the tensor product of `M₁` and `M₂`, it is linearly equivalent to `M₁ ⊗[R] M₂`. -/
@[simps! apply]
noncomputable def equiv (h : IsTensorProduct f) : M₁ ⊗[R] M₂ ≃ₗ[R] M :=
LinearEquiv.ofBijective _ h
@[simp]
theorem equiv_toLinearMap (h : IsTensorProduct f) :
h.equiv.toLinearMap = TensorProduct.lift f :=
rfl
@[simp]
theorem equiv_symm_apply (h : IsTensorProduct f) (x₁ : M₁) (x₂ : M₂) :
h.equiv.symm (f x₁ x₂) = x₁ ⊗ₜ x₂ := by
apply h.equiv.injective
refine (h.equiv.apply_symm_apply _).trans ?_
simp
/-- If `M` is the tensor product of `M₁` and `M₂`, we may lift a bilinear map `M₁ →ₗ[R] M₂ →ₗ[R] M'`
to a `M →ₗ[R] M'`. -/
noncomputable def lift (h : IsTensorProduct f) (f' : M₁ →ₗ[R] M₂ →ₗ[R] M') :
M →ₗ[R] M' :=
(TensorProduct.lift f').comp h.equiv.symm.toLinearMap
theorem lift_eq (h : IsTensorProduct f) (f' : M₁ →ₗ[R] M₂ →ₗ[R] M') (x₁ : M₁)
(x₂ : M₂) : h.lift f' (f x₁ x₂) = f' x₁ x₂ := by
simp [lift]
/-- The tensor product of a pair of linear maps between modules. -/
noncomputable def map (hf : IsTensorProduct f) (hg : IsTensorProduct g)
(i₁ : M₁ →ₗ[R] N₁) (i₂ : M₂ →ₗ[R] N₂) : M →ₗ[R] N :=
hg.equiv.toLinearMap.comp ((TensorProduct.map i₁ i₂).comp hf.equiv.symm.toLinearMap)
@[simp]
theorem map_eq (hf : IsTensorProduct f) (hg : IsTensorProduct g) (i₁ : M₁ →ₗ[R] N₁)
(i₂ : M₂ →ₗ[R] N₂) (x₁ : M₁) (x₂ : M₂) : hf.map hg i₁ i₂ (f x₁ x₂) = g (i₁ x₁) (i₂ x₂) := by
simp [map]
@[elab_as_elim]
theorem inductionOn (h : IsTensorProduct f) {motive : M → Prop} (m : M)
(zero : motive 0) (tmul : ∀ x y, motive (f x y))
(add : ∀ x y, motive x → motive y → motive (x + y)) : motive m := by
rw [← h.equiv.right_inv m]
generalize h.equiv.invFun m = y
change motive (TensorProduct.lift f y)
induction y with
| zero => rwa [map_zero]
| tmul _ _ =>
rw [TensorProduct.lift.tmul]
apply tmul
| add _ _ _ _ =>
rw [map_add]
apply add <;> assumption
lemma of_equiv (e : M₁ ⊗[R] M₂ ≃ₗ[R] M) (he : ∀ x y, e (x ⊗ₜ y) = f x y) :
IsTensorProduct f := by
have : TensorProduct.lift f = e := by
ext x y
simp [he]
simpa [IsTensorProduct, this] using e.bijective
section map
variable {P₁ P₂ P : Type*} [AddCommMonoid P₁] [AddCommMonoid P₂]
[AddCommMonoid P] [Module R P₁] [Module R P₂] [Module R P] {p : P₁ →ₗ[R] P₂ →ₗ[R] P}
(hf : IsTensorProduct f) (hg : IsTensorProduct g) (hp : IsTensorProduct p)
(i₁ : N₁ →ₗ[R] P₁) (j₁ : M₁ →ₗ[R] N₁) (i₂ : N₂ →ₗ[R] P₂) (j₂ : M₂ →ₗ[R] N₂)
theorem map_comp : hf.map hp (i₁ ∘ₗ j₁) (i₂ ∘ₗ j₂) = hg.map hp i₁ i₂ ∘ₗ hf.map hg j₁ j₂ :=
LinearMap.ext <| fun x ↦ hf.inductionOn x (by simp) (by simp) (fun _ _ h₁ h₂ ↦ by simp [h₁, h₂])
theorem map_map (x : M) :
hg.map hp i₁ i₂ ((hf.map hg j₁ j₂) x) = hf.map hp (i₁ ∘ₗ j₁) (i₂ ∘ₗ j₂) x :=
DFunLike.congr_fun (hf.map_comp hg hp i₁ j₁ i₂ j₂).symm x
@[simp]
theorem map_id :
hf.map hf (LinearMap.id : M₁ →ₗ[R] M₁) (LinearMap.id : M₂ →ₗ[R] M₂) = LinearMap.id :=
LinearMap.ext <| fun x ↦ hf.inductionOn x (by simp) (by simp) (fun _ _ h₁ h₂ ↦ by simp [h₁, h₂])
@[simp]
protected theorem map_one : hf.map hf (1 : M₁ →ₗ[R] M₁) (1 : M₂ →ₗ[R] M₂) = 1 :=
hf.map_id
protected theorem map_mul (i₁ i₂ : M₁ →ₗ[R] M₁) (j₁ j₂ : M₂ →ₗ[R] M₂) :
hf.map hf (i₁ * i₂) (j₁ * j₂) = hf.map hf i₁ j₁ * hf.map hf i₂ j₂ :=
hf.map_comp hf hf i₁ i₂ j₁ j₂
protected theorem map_pow (i : M₁ →ₗ[R] M₁) (j : M₂ →ₗ[R] M₂) (n : ℕ) :
hf.map hf i j ^ n = hf.map hf (i ^ n) (j ^ n) := by
induction n with
| zero => simp
| succ n ih => simp only [pow_succ, ih, hf.map_mul]
end map
end IsTensorProduct
end IsTensorProduct
section IsBaseChange
variable {R : Type*} {M : Type v₁} {N : Type v₂} (S : Type v₃)
variable [AddCommMonoid M] [AddCommMonoid N] [CommSemiring R]
variable [CommSemiring S] [Algebra R S] [Module R M] [Module R N] [Module S N] [IsScalarTower R S N]
variable (f : M →ₗ[R] N)
/-- Given an `R`-algebra `S` and an `R`-module `M`, an `S`-module `N` together with a map
`f : M →ₗ[R] N` is the base change of `M` to `S` if the map `S × M → N, (s, m) ↦ s • f m` is the
tensor product. -/
def IsBaseChange : Prop :=
IsTensorProduct
(((Algebra.linearMap S <| Module.End S (M →ₗ[R] N)).flip f).restrictScalars R)
variable {S f} (h : IsBaseChange S f)
variable {P Q : Type*} [AddCommMonoid P] [Module R P] [AddCommMonoid Q] [Module S Q]
section
variable [Module R Q] [IsScalarTower R S Q]
/-- Suppose `f : M →ₗ[R] N` is the base change of `M` along `R → S`. Then any `R`-linear map from
`M` to an `S`-module factors through `f`. -/
noncomputable nonrec def IsBaseChange.lift (g : M →ₗ[R] Q) : N →ₗ[S] Q :=
{ h.lift
(((Algebra.linearMap S <| Module.End S (M →ₗ[R] Q)).flip g).restrictScalars R) with
map_smul' := fun r x => by
let F := ((Algebra.linearMap S <| Module.End S (M →ₗ[R] Q)).flip g).restrictScalars R
have hF : ∀ (s : S) (m : M), h.lift F (s • f m) = s • g m := h.lift_eq F
change h.lift F (r • x) = r • h.lift F x
induction x using h.inductionOn with
| zero => rw [smul_zero, map_zero, smul_zero]
| tmul s m =>
change h.lift F (r • s • f m) = r • h.lift F (s • f m)
rw [← mul_smul, hF, hF, mul_smul]
| add x₁ x₂ e₁ e₂ => rw [map_add, smul_add, map_add, smul_add, e₁, e₂] }
nonrec theorem IsBaseChange.lift_eq (g : M →ₗ[R] Q) (x : M) : h.lift g (f x) = g x := by
have hF : ∀ (s : S) (m : M), h.lift g (s • f m) = s • g m := h.lift_eq _
convert hF 1 x <;> rw [one_smul]
theorem IsBaseChange.lift_comp (g : M →ₗ[R] Q) : ((h.lift g).restrictScalars R).comp f = g :=
LinearMap.ext (h.lift_eq g)
end
section
include h
@[elab_as_elim]
nonrec theorem IsBaseChange.inductionOn (x : N) (motive : N → Prop) (zero : motive 0)
(tmul : ∀ m : M, motive (f m)) (smul : ∀ (s : S) (n), motive n → motive (s • n))
(add : ∀ n₁ n₂, motive n₁ → motive n₂ → motive (n₁ + n₂)) : motive x :=
h.inductionOn x zero (fun _ _ => smul _ _ (tmul _)) add
theorem IsBaseChange.algHom_ext (g₁ g₂ : N →ₗ[S] Q) (e : ∀ x, g₁ (f x) = g₂ (f x)) : g₁ = g₂ := by
ext x
refine h.inductionOn x _ ?_ ?_ ?_ ?_
· rw [map_zero, map_zero]
· assumption
· intro s n e'
rw [g₁.map_smul, g₂.map_smul, e']
· intro x y e₁ e₂
rw [map_add, map_add, e₁, e₂]
theorem IsBaseChange.algHom_ext' [Module R Q] [IsScalarTower R S Q] (g₁ g₂ : N →ₗ[S] Q)
(e : (g₁.restrictScalars R).comp f = (g₂.restrictScalars R).comp f) : g₁ = g₂ :=
h.algHom_ext g₁ g₂ (LinearMap.congr_fun e)
end
variable (R M N S)
theorem TensorProduct.isBaseChange : IsBaseChange S (TensorProduct.mk R S M 1) := by
delta IsBaseChange
convert TensorProduct.isTensorProduct R S M using 1
ext s x
change s • (1 : S) ⊗ₜ[R] x = s ⊗ₜ[R] x
rw [TensorProduct.smul_tmul']
congr 1
exact mul_one _
variable {R M N S}
/-- The base change of `M` along `R → S` is linearly equivalent to `S ⊗[R] M`. -/
noncomputable nonrec def IsBaseChange.equiv : S ⊗[R] M ≃ₗ[S] N :=
{ h.equiv with
map_smul' := fun r x => by
change h.equiv (r • x) = r • h.equiv x
refine TensorProduct.induction_on x ?_ ?_ ?_
· rw [smul_zero, map_zero, smul_zero]
· intro x y
simp [smul_tmul', Algebra.linearMap_apply, smul_comm r x]
· intro x y hx hy
rw [map_add, smul_add, map_add, smul_add, hx, hy] }
theorem IsBaseChange.equiv_tmul (s : S) (m : M) : h.equiv (s ⊗ₜ m) = s • f m :=
rfl
theorem IsBaseChange.equiv_symm_apply (m : M) : h.equiv.symm (f m) = 1 ⊗ₜ m := by
rw [h.equiv.symm_apply_eq, h.equiv_tmul, one_smul]
lemma IsBaseChange.of_equiv (e : S ⊗[R] M ≃ₗ[S] N) (he : ∀ x, e (1 ⊗ₜ x) = f x) :
IsBaseChange S f := by
apply IsTensorProduct.of_equiv (e.restrictScalars R)
intro x y
simp [show x ⊗ₜ[R] y = x • (1 ⊗ₜ[R] y) by simp [smul_tmul'], he]
variable (R S) in
theorem IsBaseChange.linearMap : IsBaseChange S (Algebra.linearMap R S) :=
of_equiv (AlgebraTensorModule.rid R S S) fun x ↦ by
simpa using (Algebra.algebraMap_eq_smul_one x).symm
section
variable (A : Type*) [CommSemiring A]
variable [Algebra R A] [Algebra S A] [IsScalarTower R S A]
variable [Module S M] [IsScalarTower R S M]
variable [Module A N] [IsScalarTower S A N] [IsScalarTower R A N]
/-- If `N` is the base change of `M` to `A`, then `N ⊗[R] P` is the base change
of `M ⊗[R] P` to `A`. This is simply the isomorphism
`A ⊗[S] (M ⊗[R] P) ≃ₗ[A] (A ⊗[S] M) ⊗[R] P`. -/
lemma isBaseChange_tensorProduct_map {f : M →ₗ[S] N} (hf : IsBaseChange A f) :
IsBaseChange A (AlgebraTensorModule.map f (LinearMap.id (R := R) (M := P))) := by
let e : A ⊗[S] (M ⊗[R] P) ≃ₗ[A] N ⊗[R] P := (AlgebraTensorModule.assoc R S A A M P).symm.trans
(AlgebraTensorModule.congr hf.equiv (LinearEquiv.refl R P))
refine IsBaseChange.of_equiv e (fun x ↦ ?_)
induction x with
| zero => simp
| tmul => simp [e, IsBaseChange.equiv_tmul]
| add _ _ h1 h2 => simp [tmul_add, h1, h2]
end
variable (f) in
theorem IsBaseChange.of_lift_unique
(h : ∀ (Q : Type max v₁ v₂ v₃) [AddCommMonoid Q],
∀ [Module R Q] [Module S Q], ∀ [IsScalarTower R S Q],
∀ g : M →ₗ[R] Q, ∃! g' : N →ₗ[S] Q, (g'.restrictScalars R).comp f = g) :
IsBaseChange S f := by
obtain ⟨g, hg, -⟩ :=
h (ULift.{v₂} <| S ⊗[R] M)
(ULift.moduleEquiv.symm.toLinearMap.comp <| TensorProduct.mk R S M 1)
let f' : S ⊗[R] M →ₗ[R] N :=
TensorProduct.lift (((LinearMap.flip (AlgHom.toLinearMap (Algebra.ofId S
(Module.End S (M →ₗ[R] N))))) f).restrictScalars R)
change Function.Bijective f'
let f'' : S ⊗[R] M →ₗ[S] N := by
refine
{ f' with
map_smul' := fun s x =>
TensorProduct.induction_on x ?_ (fun s' y => smul_assoc s s' _) fun x y hx hy => ?_ }
· dsimp; rw [map_zero, smul_zero, map_zero, smul_zero]
· dsimp at *; rw [smul_add, map_add, map_add, smul_add, hx, hy]
simp_rw [DFunLike.ext_iff, LinearMap.comp_apply, LinearMap.restrictScalars_apply] at hg
let fe : S ⊗[R] M ≃ₗ[S] N :=
LinearEquiv.ofLinear f'' (ULift.moduleEquiv.toLinearMap.comp g) ?_ ?_
· exact fe.bijective
· rw [← LinearMap.cancel_left (ULift.moduleEquiv : ULift.{max v₁ v₃} N ≃ₗ[S] N).symm.injective]
refine (h (ULift.{max v₁ v₃} N) <| ULift.moduleEquiv.symm.toLinearMap.comp f).unique ?_ rfl
ext x
simp only [LinearMap.comp_apply, LinearMap.restrictScalars_apply, hg]
apply one_smul
· ext x
change (g <| (1 : S) • f x).down = _
rw [one_smul, hg]
rfl
theorem IsBaseChange.iff_lift_unique :
IsBaseChange S f ↔
∀ (Q : Type max v₁ v₂ v₃) [AddCommMonoid Q],
∀ [Module R Q] [Module S Q],
∀ [IsScalarTower R S Q],
∀ g : M →ₗ[R] Q, ∃! g' : N →ₗ[S] Q, (g'.restrictScalars R).comp f = g :=
⟨fun h => by
intro Q _ _ _ _ g
exact ⟨h.lift g, h.lift_comp g, fun g' e => h.algHom_ext' _ _ (e.trans (h.lift_comp g).symm)⟩,
IsBaseChange.of_lift_unique f⟩
theorem IsBaseChange.ofEquiv (e : M ≃ₗ[R] N) : IsBaseChange R e.toLinearMap := by
apply IsBaseChange.of_lift_unique
intro Q I₁ I₂ I₃ I₄ g
have : I₂ = I₃ := by
ext r q
change (by let _ := I₂; exact r • q) = (by let _ := I₃; exact r • q)
dsimp
rw [← one_smul R q, smul_smul, ← @smul_assoc _ _ _ (id _) (id _) (id _) I₄, smul_eq_mul]
cases this
refine
⟨g.comp e.symm.toLinearMap, by
ext
simp, ?_⟩
rintro y (rfl : _ = _)
ext
simp
variable {T O : Type*} [CommSemiring T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
variable [AddCommMonoid O] [Module R O] [Module S O] [Module T O] [IsScalarTower S T O]
variable [IsScalarTower R S O] [IsScalarTower R T O]
theorem IsBaseChange.comp {f : M →ₗ[R] N} (hf : IsBaseChange S f) {g : N →ₗ[S] O}
(hg : IsBaseChange T g) : IsBaseChange T ((g.restrictScalars R).comp f) := by
apply IsBaseChange.of_lift_unique
intro Q _ _ _ _ i
letI := Module.compHom Q (algebraMap S T)
haveI : IsScalarTower S T Q :=
⟨fun x y z => by
rw [Algebra.smul_def, mul_smul]
rfl⟩
have : IsScalarTower R S Q := by
refine ⟨fun x y z => ?_⟩
change (IsScalarTower.toAlgHom R S T) (x • y) • z = x • algebraMap S T y • z
rw [map_smul, smul_assoc]
rfl
refine
⟨hg.lift (hf.lift i), by
ext
simp [IsBaseChange.lift_eq], ?_⟩
rintro g' (e : _ = _)
refine hg.algHom_ext' _ _ (hf.algHom_ext' _ _ ?_)
rw [IsBaseChange.lift_comp, IsBaseChange.lift_comp, ← e]
ext
rfl
/-- If `N` is the base change of `M` to `S` and `O` the base change of `M` to `T`, then
`O` is the base change of `N` to `T`. -/
lemma IsBaseChange.of_comp {f : M →ₗ[R] N} (hf : IsBaseChange S f) {h : N →ₗ[S] O}
(hc : IsBaseChange T ((h : N →ₗ[R] O) ∘ₗ f)) :
IsBaseChange T h := by
apply IsBaseChange.of_lift_unique
intro Q _ _ _ _ r
letI : Module R Q := inferInstanceAs (Module R (RestrictScalars R S Q))
haveI : IsScalarTower R S Q := IsScalarTower.of_algebraMap_smul fun r ↦ congrFun rfl
haveI : IsScalarTower R T Q := IsScalarTower.of_algebraMap_smul fun r x ↦ by
simp [IsScalarTower.algebraMap_apply R S T]
let r' : M →ₗ[R] Q := r ∘ₗ f
let q : O →ₗ[T] Q := hc.lift r'
refine ⟨q, ?_, ?_⟩
· apply hf.algHom_ext'
simp [r', q, LinearMap.comp_assoc, hc.lift_comp]
· intro q' hq'
apply hc.algHom_ext'
apply_fun LinearMap.restrictScalars R at hq'
rw [← LinearMap.comp_assoc]
rw [show q'.restrictScalars R ∘ₗ h.restrictScalars R = _ from hq', hc.lift_comp]
/-- If `N` is the base change `M` to `S`, then `O` is the base change of `M` to `T` if and
only if `O` is the base change of `N` to `T`. -/
lemma IsBaseChange.comp_iff {f : M →ₗ[R] N} (hf : IsBaseChange S f) {h : N →ₗ[S] O} :
IsBaseChange T ((h : N →ₗ[R] O) ∘ₗ f) ↔ IsBaseChange T h :=
⟨fun hc ↦ IsBaseChange.of_comp hf hc, fun hh ↦ IsBaseChange.comp hf hh⟩
/-- Let `R` be a commutative ring, `S` be an `R`-algebra, `M` be an `R`-module, `P` be an `S`
module, `N` be the base change of `M` to `S`, then `P ⊗[S] N` is isomorphic to `P ⊗[R] M`
as `S`-modules. -/
noncomputable def IsBaseChange.tensorEquiv {f : M →ₗ[R] N} (hf : IsBaseChange S f) (P : Type*)
[AddCommGroup P] [Module R P] [Module S P] [IsScalarTower R S P] : P ⊗[S] N ≃ₗ[S] P ⊗[R] M :=
LinearEquiv.lTensor P hf.equiv.symm ≪≫ₗ AlgebraTensorModule.cancelBaseChange R S S P M
theorem IsBaseChange.map_id_lsmul_eq_lsmul_algebraMap
{f : M →ₗ[R] N} (hf : IsBaseChange S f) (x : R) :
hf.map hf LinearMap.id (LinearMap.lsmul R M x) = LinearMap.lsmul S N (algebraMap R S x) := by
ext y
refine IsTensorProduct.inductionOn hf y (by simp) ?_ (fun _ _ ha hb ↦ by simp [ha, hb])
intro s m
rw [hf.map_eq hf]
simpa using smul_comm x s (f m)
variable {R' S' : Type*} [CommSemiring R'] [CommSemiring S']
variable [Algebra R R'] [Algebra S S'] [Algebra R' S'] [Algebra R S']
variable [IsScalarTower R R' S'] [IsScalarTower R S S']
open IsScalarTower (toAlgHom algebraMap_apply)
variable (R S R' S')
/-- A type-class stating that the following diagram of scalar towers
```
R → S
↓ ↓
R' → S'
```
is a pushout diagram (i.e. `S' = S ⊗[R] R'`)
-/
@[mk_iff]
class Algebra.IsPushout : Prop where
out : IsBaseChange S (toAlgHom R R' S').toLinearMap
/-- The isomorphism `S' ≃ S ⊗[R] R` given `Algebra.IsPushout R S R' S'`. -/
noncomputable
def Algebra.IsPushout.equiv [h : Algebra.IsPushout R S R' S'] : S ⊗[R] R' ≃ₐ[S] S' where
__ := h.out.equiv
map_mul' x y := by
dsimp
induction x with
| zero => simp
| add x y _ _ => simp [*, add_mul]
| tmul a b =>
induction y with
| zero => simp
| add x y _ _ => simp [*, mul_add]
| tmul x y => simp [IsBaseChange.equiv_tmul, Algebra.smul_def, mul_mul_mul_comm]
commutes' := by simp [IsBaseChange.equiv_tmul, Algebra.smul_def]
lemma Algebra.IsPushout.equiv_tmul [h : Algebra.IsPushout R S R' S'] (a : S) (b : R') :
equiv R S R' S' (a ⊗ₜ b) = algebraMap _ _ a * algebraMap _ _ b :=
(h.out.equiv_tmul _ _).trans (Algebra.smul_def _ _)
lemma Algebra.IsPushout.equiv_symm_algebraMap_left [Algebra.IsPushout R S R' S'] (a : S) :
(equiv R S R' S').symm (algebraMap S S' a) = a ⊗ₜ 1 := by
rw [(equiv R S R' S').symm_apply_eq, equiv_tmul, map_one, mul_one]
lemma Algebra.IsPushout.equiv_symm_algebraMap_right [Algebra.IsPushout R S R' S'] (a : R') :
(equiv R S R' S').symm (algebraMap R' S' a) = 1 ⊗ₜ a := by
rw [(equiv R S R' S').symm_apply_eq, equiv_tmul, map_one, one_mul]
variable {R S R' S'}
@[symm]
theorem Algebra.IsPushout.symm (h : Algebra.IsPushout R S R' S') : Algebra.IsPushout R R' S S' where
out := .of_equiv
{ __ := (TensorProduct.comm R ..).toAddEquiv.trans (equiv R S R' S').toAddEquiv,
map_smul' _ x := x.induction_on (by simp) (fun _ _ ↦ by
simp [equiv_tmul, Algebra.smul_def, mul_left_comm]) (by simp+contextual) }
fun _ ↦ by simp [equiv_tmul]
variable (R S R' S')
theorem Algebra.IsPushout.comm : Algebra.IsPushout R S R' S' ↔ Algebra.IsPushout R R' S S' :=
⟨Algebra.IsPushout.symm, Algebra.IsPushout.symm⟩
instance : Algebra.IsPushout R R S S where
out := .of_equiv (TensorProduct.lid R S) fun _ ↦ by simp
instance : Algebra.IsPushout R S R S := .symm inferInstance
variable {R S R'}
attribute [local instance] Algebra.TensorProduct.rightAlgebra
instance TensorProduct.isPushout {R S T : Type*} [CommSemiring R] [CommSemiring S] [CommSemiring T]
[Algebra R S] [Algebra R T] : Algebra.IsPushout R S T (S ⊗[R] T) :=
⟨TensorProduct.isBaseChange R T S⟩
instance TensorProduct.isPushout' {R S T : Type*} [CommSemiring R] [CommSemiring S] [CommSemiring T]
[Algebra R S] [Algebra R T] : Algebra.IsPushout R T S (S ⊗[R] T) :=
Algebra.IsPushout.symm inferInstance
/-- If `S' = S ⊗[R] R'`, then any pair of `R`-algebra homomorphisms `f : S → A` and `g : R' → A`
such that `f x` and `g y` commutes for all `x, y` descends to a (unique) homomorphism `S' → A`.
-/
@[simps! -isSimp apply]
noncomputable def Algebra.pushoutDesc [H : Algebra.IsPushout R S R' S'] {A : Type*} [Semiring A]
[Algebra R A] (f : S →ₐ[R] A) (g : R' →ₐ[R] A) (hf : ∀ x y, f x * g y = g y * f x) :
S' →ₐ[R] A :=
(Algebra.TensorProduct.lift f g hf).comp
((Algebra.IsPushout.equiv R S R' S').symm.toAlgHom.restrictScalars R)
@[simp]
theorem Algebra.pushoutDesc_left [Algebra.IsPushout R S R' S'] {A : Type*} [Semiring A]
[Algebra R A] (f : S →ₐ[R] A) (g : R' →ₐ[R] A) (H) (x : S) :
Algebra.pushoutDesc S' f g H (algebraMap S S' x) = f x := by
simp [Algebra.pushoutDesc_apply]
theorem Algebra.lift_algHom_comp_left [Algebra.IsPushout R S R' S'] {A : Type*} [Semiring A]
[Algebra R A] (f : S →ₐ[R] A) (g : R' →ₐ[R] A) (H) :
(Algebra.pushoutDesc S' f g H).comp (toAlgHom R S S') = f :=
AlgHom.ext fun x => (Algebra.pushoutDesc_left S' f g H x :)
@[simp]
theorem Algebra.pushoutDesc_right [Algebra.IsPushout R S R' S'] {A : Type*} [Semiring A]
[Algebra R A] (f : S →ₐ[R] A) (g : R' →ₐ[R] A) (H) (x : R') :
Algebra.pushoutDesc S' f g H (algebraMap R' S' x) = g x := by
simp [Algebra.pushoutDesc_apply, Algebra.IsPushout.equiv_symm_algebraMap_right]
theorem Algebra.lift_algHom_comp_right [Algebra.IsPushout R S R' S'] {A : Type*} [Semiring A]
[Algebra R A] (f : S →ₐ[R] A) (g : R' →ₐ[R] A) (H) :
(Algebra.pushoutDesc S' f g H).comp (toAlgHom R R' S') = g :=
AlgHom.ext fun x => (Algebra.pushoutDesc_right S' f g H x :)
@[ext (iff := false)]
theorem Algebra.IsPushout.algHom_ext [H : Algebra.IsPushout R S R' S'] {A : Type*} [Semiring A]
[Algebra R A] {f g : S' →ₐ[R] A} (h₁ : f.comp (toAlgHom R R' S') = g.comp (toAlgHom R R' S'))
(h₂ : f.comp (toAlgHom R S S') = g.comp (toAlgHom R S S')) : f = g := by
ext x
refine H.1.inductionOn x _ ?_ ?_ ?_ ?_
· simp only [map_zero]
· exact AlgHom.congr_fun h₁
· intro s s' e
rw [Algebra.smul_def, map_mul, map_mul, e]
congr 1
exact (AlgHom.congr_fun h₂ s :)
· intro s₁ s₂ e₁ e₂
rw [map_add, map_add, e₁, e₂]
variable (R S R')
/--
Let the following be a commutative diagram of rings
```
R → S → T
↓ ↓ ↓
R' → S' → T'
```
where the left-hand square is a pushout. Then the following are equivalent:
- the big rectangle is a pushout.
- the right-hand square is a pushout.
Note that this is essentially the isomorphism `T ⊗[S] (S ⊗[R] R') ≃ₐ[T] T ⊗[R] R'`.
-/
lemma Algebra.IsPushout.comp_iff {T' : Type*} [CommSemiring T'] [Algebra R T']
[Algebra S' T'] [Algebra S T'] [Algebra T T'] [Algebra R' T']
[IsScalarTower R T T'] [IsScalarTower S T T'] [IsScalarTower S S' T']
[IsScalarTower R R' T'] [IsScalarTower R S' T'] [IsScalarTower R' S' T']
[Algebra.IsPushout R S R' S'] :
Algebra.IsPushout R T R' T' ↔ Algebra.IsPushout S T S' T' := by
let f : R' →ₗ[R] S' := (IsScalarTower.toAlgHom R R' S').toLinearMap
haveI : IsScalarTower R S T' := .of_algebraMap_eq fun x ↦ by
rw [algebraMap_apply R S' T', algebraMap_apply R S S', ← algebraMap_apply S S' T']
have heq : (toAlgHom S S' T').toLinearMap.restrictScalars R ∘ₗ f =
(toAlgHom R R' T').toLinearMap := by
ext x
simp [f, ← IsScalarTower.algebraMap_apply]
rw [isPushout_iff, isPushout_iff, ← heq, IsBaseChange.comp_iff]
exact Algebra.IsPushout.out
variable {R R' S S'} in
lemma Algebra.IsPushout.of_equiv [h : IsPushout R R' S S']
{T : Type*} [CommSemiring T] [Algebra R' T] [Algebra S T] [Algebra R T]
[IsScalarTower R S T] [IsScalarTower R R' T] (e : S' ≃ₐ[R'] T)
(he : e.toRingHom.comp (algebraMap S S') = algebraMap S T) :
IsPushout R R' S T := by
rw [isPushout_iff] at h ⊢
refine IsBaseChange.of_equiv (h.equiv ≪≫ₗ e.toLinearEquiv) fun x ↦ ?_
simpa [h.equiv_tmul] using DFunLike.congr_fun he x
namespace Algebra
variable (A B : Type*)
[CommRing A] [CommRing B] [Algebra R A] [Algebra R B] [Algebra A B] [Algebra S B]
[IsScalarTower R A B] [IsScalarTower R S B] [Algebra.IsPushout R S A B]
variable (M : Type*) [AddCommGroup M] [Module R M] [Module A M] [IsScalarTower R A M]
/-- (Implementation) If `B = S ⊗[R] A`, this is the canonical `R`-isomorphism:
`B ⊗[A] M ≃ₗ[S] S ⊗[R] M`. See `IsPushout.cancelBaseChange` for the `S`-linear version. -/
noncomputable
def IsPushout.cancelBaseChangeAux : B ⊗[A] M ≃ₗ[R] S ⊗[R] M :=
have : IsPushout R A S B := IsPushout.symm inferInstance
(AlgebraTensorModule.congr ((IsPushout.equiv R A S B).toLinearEquiv).symm
(LinearEquiv.refl _ _)).restrictScalars R ≪≫ₗ
(_root_.TensorProduct.comm _ _ _).restrictScalars R ≪≫ₗ
(AlgebraTensorModule.cancelBaseChange _ _ A _ _).restrictScalars R ≪≫ₗ
(_root_.TensorProduct.comm _ _ _).restrictScalars R
@[simp]
lemma IsPushout.cancelBaseChangeAux_symm_tmul (s : S) (m : M) :
(IsPushout.cancelBaseChangeAux R S A B M).symm (s ⊗ₜ m) = algebraMap S B s ⊗ₜ m := by
simp [IsPushout.cancelBaseChangeAux, IsPushout.equiv_tmul]
/-- If `B = S ⊗[R] A`, this is the canonical `S`-isomorphism: `B ⊗[A] M ≃ₗ[S] S ⊗[R] M`.
This is the cancelling on the left version of
`TensorProduct.AlgebraTensorModule.cancelBaseChange`. -/
noncomputable
def IsPushout.cancelBaseChange : B ⊗[A] M ≃ₗ[S] S ⊗[R] M :=
LinearEquiv.symm <|
AddEquiv.toLinearEquiv (IsPushout.cancelBaseChangeAux R S A B M).symm <| by
intro s x
induction x with
| zero => simp
| add x y hx hy => simp only [smul_add, map_add, hx, hy]
| tmul s' m => simp [Algebra.smul_def, TensorProduct.smul_tmul']
@[simp]
lemma IsPushout.cancelBaseChange_tmul (m : M) :
IsPushout.cancelBaseChange R S A B M (1 ⊗ₜ m) = 1 ⊗ₜ m := by
change ((cancelBaseChangeAux R S A B M).symm).symm (1 ⊗ₜ[A] m) = 1 ⊗ₜ[R] m
simp [cancelBaseChangeAux, TensorProduct.one_def]
@[simp]
lemma IsPushout.cancelBaseChange_symm_tmul (s : S) (m : M) :
(IsPushout.cancelBaseChange R S A B M).symm (s ⊗ₜ m) = algebraMap S B s ⊗ₜ m :=
IsPushout.cancelBaseChangeAux_symm_tmul R S A B M s m
end Algebra
end IsBaseChange |
.lake/packages/mathlib/Mathlib/RingTheory/PiTensorProduct.lean | import Mathlib.LinearAlgebra.PiTensorProduct
import Mathlib.Algebra.Algebra.Bilinear
import Mathlib.Algebra.Algebra.Equiv
import Mathlib.Data.Finset.NoncommProd
/-!
# Tensor product of `R`-algebras and rings
If `(Aᵢ)` is a family of `R`-algebras then the `R`-tensor product `⨂ᵢ Aᵢ` is an `R`-algebra as well
with structure map defined by `r ↦ r • 1`.
In particular if we take `R` to be `ℤ`, then this collapses into the tensor product of rings.
-/
open TensorProduct Function
variable {ι R' R : Type*} {A : ι → Type*}
namespace PiTensorProduct
noncomputable section AddCommMonoidWithOne
variable [CommSemiring R] [∀ i, AddCommMonoidWithOne (A i)] [∀ i, Module R (A i)]
instance instOne : One (⨂[R] i, A i) where
one := tprod R 1
lemma one_def : 1 = tprod R (1 : Π i, A i) := rfl
instance instAddCommMonoidWithOne : AddCommMonoidWithOne (⨂[R] i, A i) where
__ := inferInstanceAs (AddCommMonoid (⨂[R] i, A i))
__ := instOne
end AddCommMonoidWithOne
noncomputable section NonUnitalNonAssocSemiring
variable [CommSemiring R] [∀ i, NonUnitalNonAssocSemiring (A i)]
variable [∀ i, Module R (A i)] [∀ i, SMulCommClass R (A i) (A i)] [∀ i, IsScalarTower R (A i) (A i)]
attribute [aesop safe] mul_add mul_smul_comm smul_mul_assoc add_mul in
/--
The multiplication in tensor product of rings is induced by `(xᵢ) * (yᵢ) = (xᵢ * yᵢ)`
-/
def mul : (⨂[R] i, A i) →ₗ[R] (⨂[R] i, A i) →ₗ[R] (⨂[R] i, A i) :=
PiTensorProduct.piTensorHomMap₂ <| tprod R fun _ ↦ LinearMap.mul _ _
@[simp] lemma mul_tprod_tprod (x y : (i : ι) → A i) :
mul (tprod R x) (tprod R y) = tprod R (x * y) := by
simp only [mul, piTensorHomMap₂_tprod_tprod_tprod, LinearMap.mul_apply', Pi.mul_def]
instance instMul : Mul (⨂[R] i, A i) where
mul x y := mul x y
lemma mul_def (x y : ⨂[R] i, A i) : x * y = mul x y := rfl
@[simp] lemma tprod_mul_tprod (x y : (i : ι) → A i) :
tprod R x * tprod R y = tprod R (x * y) :=
mul_tprod_tprod x y
theorem _root_.SemiconjBy.tprod {a₁ a₂ a₃ : Π i, A i}
(ha : SemiconjBy a₁ a₂ a₃) :
SemiconjBy (tprod R a₁) (tprod R a₂) (tprod R a₃) := by
rw [SemiconjBy, tprod_mul_tprod, tprod_mul_tprod, ha]
nonrec theorem _root_.Commute.tprod {a₁ a₂ : Π i, A i} (ha : Commute a₁ a₂) :
Commute (tprod R a₁) (tprod R a₂) :=
ha.tprod
lemma smul_tprod_mul_smul_tprod (r s : R) (x y : Π i, A i) :
(r • tprod R x) * (s • tprod R y) = (r * s) • tprod R (x * y) := by
simp only [mul_def, map_smul, LinearMap.smul_apply, mul_tprod_tprod, mul_comm r s, mul_smul]
instance instNonUnitalNonAssocSemiring : NonUnitalNonAssocSemiring (⨂[R] i, A i) where
__ := instMul
__ := inferInstanceAs (AddCommMonoid (⨂[R] i, A i))
left_distrib _ _ _ := (mul _).map_add _ _
right_distrib _ _ _ := mul.map_add₂ _ _ _
zero_mul _ := mul.map_zero₂ _
mul_zero _ := map_zero (mul _)
end NonUnitalNonAssocSemiring
noncomputable section NonAssocSemiring
variable [CommSemiring R] [∀ i, NonAssocSemiring (A i)]
variable [∀ i, Module R (A i)] [∀ i, SMulCommClass R (A i) (A i)] [∀ i, IsScalarTower R (A i) (A i)]
protected lemma one_mul (x : ⨂[R] i, A i) : mul (tprod R 1) x = x := by
induction x using PiTensorProduct.induction_on with
| smul_tprod => simp
| add _ _ h1 h2 => simp [map_add, h1, h2]
protected lemma mul_one (x : ⨂[R] i, A i) : mul x (tprod R 1) = x := by
induction x using PiTensorProduct.induction_on with
| smul_tprod => simp
| add _ _ h1 h2 => simp [h1, h2]
instance instNonAssocSemiring : NonAssocSemiring (⨂[R] i, A i) where
__ := instNonUnitalNonAssocSemiring
one_mul := PiTensorProduct.one_mul
mul_one := PiTensorProduct.mul_one
variable (R) in
/-- `PiTensorProduct.tprod` as a `MonoidHom`. -/
@[simps]
def tprodMonoidHom : (Π i, A i) →* ⨂[R] i, A i where
toFun := tprod R
map_one' := rfl
map_mul' x y := (tprod_mul_tprod x y).symm
end NonAssocSemiring
noncomputable section NonUnitalSemiring
variable [CommSemiring R] [∀ i, NonUnitalSemiring (A i)]
variable [∀ i, Module R (A i)] [∀ i, SMulCommClass R (A i) (A i)] [∀ i, IsScalarTower R (A i) (A i)]
protected lemma mul_assoc (x y z : ⨂[R] i, A i) : mul (mul x y) z = mul x (mul y z) := by
-- restate as an equality of morphisms so that we can use `ext`
suffices LinearMap.llcomp R _ _ _ mul ∘ₗ mul =
(LinearMap.llcomp R _ _ _ LinearMap.lflip.toLinearMap <|
LinearMap.llcomp R _ _ _ mul.flip ∘ₗ mul).flip by
exact DFunLike.congr_fun (DFunLike.congr_fun (DFunLike.congr_fun this x) y) z
ext x y z
dsimp [← mul_def]
simpa only [tprod_mul_tprod] using congr_arg (tprod R) (mul_assoc x y z)
instance instNonUnitalSemiring : NonUnitalSemiring (⨂[R] i, A i) where
__ := instNonUnitalNonAssocSemiring
mul_assoc := PiTensorProduct.mul_assoc
end NonUnitalSemiring
noncomputable section Semiring
variable [CommSemiring R'] [CommSemiring R] [∀ i, Semiring (A i)]
variable [Algebra R' R] [∀ i, Algebra R (A i)] [∀ i, Algebra R' (A i)]
variable [∀ i, IsScalarTower R' R (A i)]
instance instSemiring : Semiring (⨂[R] i, A i) where
__ := instNonUnitalSemiring
__ := instNonAssocSemiring
instance instAlgebra : Algebra R' (⨂[R] i, A i) where
__ := hasSMul'
algebraMap :=
{ toFun := (· • 1)
map_one' := by simp
map_mul' r s := show (r * s) • 1 = mul (r • 1) (s • 1) by
rw [LinearMap.map_smul_of_tower, LinearMap.map_smul_of_tower, LinearMap.smul_apply, mul_comm,
mul_smul]
congr
change (1 : ⨂[R] i, A i) = 1 * 1
rw [mul_one]
map_zero' := by simp
map_add' := by simp [add_smul] }
commutes' r x := by
simp only [RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk]
change mul _ _ = mul _ _
rw [LinearMap.map_smul_of_tower, LinearMap.map_smul_of_tower, LinearMap.smul_apply]
change r • (1 * x) = r • (x * 1)
rw [mul_one, one_mul]
smul_def' r x := by
simp only [RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk]
change _ = mul _ _
rw [LinearMap.map_smul_of_tower, LinearMap.smul_apply]
change _ = r • (1 * x)
rw [one_mul]
lemma algebraMap_apply (r : R') (i : ι) [DecidableEq ι] :
algebraMap R' (⨂[R] i, A i) r = tprod R (Pi.mulSingle i (algebraMap R' (A i) r)) := by
change r • tprod R 1 = _
have : Pi.mulSingle i (algebraMap R' (A i) r) = update (fun i ↦ 1) i (r • 1) := by
rw [Algebra.algebraMap_eq_smul_one]; rfl
rw [this, ← smul_one_smul R r (1 : A i), MultilinearMap.map_update_smul, update_eq_self,
smul_one_smul, Pi.one_def]
/--
The map `Aᵢ ⟶ ⨂ᵢ Aᵢ` given by `a ↦ 1 ⊗ ... ⊗ a ⊗ 1 ⊗ ...`
-/
@[simps]
def singleAlgHom [DecidableEq ι] (i : ι) : A i →ₐ[R] ⨂[R] i, A i where
toFun a := tprod R (MonoidHom.mulSingle _ i a)
map_one' := by simp only [map_one]; rfl
map_mul' a a' := by simp [map_mul]
map_zero' := MultilinearMap.map_update_zero _ _ _
map_add' _ _ := MultilinearMap.map_update_add _ _ _ _ _
commutes' r := show tprodCoeff R _ _ = r • tprodCoeff R _ _ by
rw [Algebra.algebraMap_eq_smul_one, ← Pi.one_apply, MonoidHom.mulSingle_apply, Pi.mulSingle,
smul_tprodCoeff]
rfl
/--
Lifting a multilinear map to an algebra homomorphism from tensor product
-/
@[simps!]
def liftAlgHom {S : Type*} [Semiring S] [Algebra R S]
(f : MultilinearMap R A S)
(one : f 1 = 1) (mul : ∀ x y, f (x * y) = f x * f y) : (⨂[R] i, A i) →ₐ[R] S :=
AlgHom.ofLinearMap (lift f) (show lift f (tprod R 1) = 1 by simp [one]) <|
LinearMap.map_mul_iff _ |>.mpr <| by aesop
@[simp] lemma tprod_noncommProd {κ : Type*} (s : Finset κ) (x : κ → Π i, A i) (hx) :
tprod R (s.noncommProd x hx) = s.noncommProd (fun k => tprod R (x k))
(hx.imp fun _ _ => Commute.tprod) :=
Finset.map_noncommProd s x _ (tprodMonoidHom R)
/-- To show two algebra morphisms from finite tensor products are equal, it suffices to show that
they agree on elements of the form $1 ⊗ ⋯ ⊗ a ⊗ 1 ⊗ ⋯$. -/
@[ext high]
theorem algHom_ext {S : Type*} [Finite ι] [DecidableEq ι] [Semiring S] [Algebra R S]
⦃f g : (⨂[R] i, A i) →ₐ[R] S⦄ (h : ∀ i, f.comp (singleAlgHom i) = g.comp (singleAlgHom i)) :
f = g :=
AlgHom.toLinearMap_injective <| PiTensorProduct.ext <| MultilinearMap.ext fun x =>
suffices f.toMonoidHom.comp (tprodMonoidHom R) = g.toMonoidHom.comp (tprodMonoidHom R) from
DFunLike.congr_fun this x
MonoidHom.pi_ext fun i xi => DFunLike.congr_fun (h i) xi
end Semiring
noncomputable section Ring
variable [CommRing R] [∀ i, Ring (A i)] [∀ i, Algebra R (A i)]
instance instRing : Ring (⨂[R] i, A i) where
__ := instSemiring
__ := inferInstanceAs <| AddCommGroup (⨂[R] i, A i)
end Ring
noncomputable section CommSemiring
variable [CommSemiring R] [∀ i, CommSemiring (A i)] [∀ i, Algebra R (A i)]
protected lemma mul_comm (x y : ⨂[R] i, A i) : mul x y = mul y x := by
suffices mul (R := R) (A := A) = mul.flip from
DFunLike.congr_fun (DFunLike.congr_fun this x) y
ext x y
dsimp
simp only [mul_tprod_tprod, mul_tprod_tprod, mul_comm x y]
instance instCommSemiring : CommSemiring (⨂[R] i, A i) where
__ := instSemiring
__ := inferInstanceAs <| AddCommMonoid (⨂[R] i, A i)
mul_comm := PiTensorProduct.mul_comm
@[simp] lemma tprod_prod {κ : Type*} (s : Finset κ) (x : κ → Π i, A i) :
tprod R (∏ k ∈ s, x k) = ∏ k ∈ s, tprod R (x k) :=
map_prod (tprodMonoidHom R) x s
section
variable [Fintype ι]
variable (R ι)
/--
The algebra equivalence from the tensor product of the constant family with
value `R` to `R`, given by multiplication of the entries.
-/
noncomputable def constantBaseRingEquiv : (⨂[R] _ : ι, R) ≃ₐ[R] R :=
letI toFun := lift (MultilinearMap.mkPiAlgebra R ι R)
AlgEquiv.ofAlgHom
(AlgHom.ofLinearMap
toFun
((lift.tprod _).trans Finset.prod_const_one)
(by
-- one of these is required, the other is a performance optimization
letI : IsScalarTower R (⨂[R] x : ι, R) (⨂[R] x : ι, R) :=
IsScalarTower.right (R := R) (A := ⨂[R] (x : ι), R)
letI : SMulCommClass R (⨂[R] x : ι, R) (⨂[R] x : ι, R) :=
Algebra.to_smulCommClass (R := R) (A := ⨂[R] x : ι, R)
rw [LinearMap.map_mul_iff]
ext
change toFun (tprod R _ * tprod R _) = toFun (tprod R _) * toFun (tprod R _)
simp_rw [tprod_mul_tprod, toFun, lift.tprod, MultilinearMap.mkPiAlgebra_apply,
Pi.mul_apply, Finset.prod_mul_distrib]))
(Algebra.ofId _ _)
(by ext)
(by classical ext)
variable {R ι}
@[simp]
theorem constantBaseRingEquiv_tprod (x : ι → R) :
constantBaseRingEquiv ι R (tprod R x) = ∏ i, x i := by
simp [constantBaseRingEquiv]
@[simp]
theorem constantBaseRingEquiv_symm (r : R) :
(constantBaseRingEquiv ι R).symm r = algebraMap _ _ r := rfl
end
end CommSemiring
noncomputable section CommRing
variable [CommRing R] [∀ i, CommRing (A i)] [∀ i, Algebra R (A i)]
instance instCommRing : CommRing (⨂[R] i, A i) where
__ := instCommSemiring
__ := inferInstanceAs <| AddCommGroup (⨂[R] i, A i)
end CommRing
end PiTensorProduct |
.lake/packages/mathlib/Mathlib/RingTheory/Perfection.lean | import Mathlib.Algebra.CharP.Frobenius
import Mathlib.Algebra.CharP.Pi
import Mathlib.Algebra.CharP.Quotient
import Mathlib.Algebra.CharP.Subring
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.FieldTheory.Perfect
import Mathlib.RingTheory.Valuation.Integers
/-!
# Ring Perfection and Tilt
In this file we define the perfection of a ring of characteristic p, and the tilt of a field
given a valuation to `ℝ≥0`.
## TODO
Define the valuation on the tilt, and define a characteristic predicate for the tilt.
-/
universe u₁ u₂ u₃ u₄
open scoped NNReal
/-- The perfection of a monoid `M`, defined to be the projective limit of `M`
using the `p`-th power maps `M → M` indexed by the natural numbers, implemented as
`{ f : ℕ → M | ∀ n, f (n + 1) ^ p = f n }`. -/
def Monoid.perfection (M : Type u₁) [CommMonoid M] (p : ℕ) : Submonoid (ℕ → M) where
carrier := { f | ∀ n, f (n + 1) ^ p = f n }
one_mem' _ := one_pow _
mul_mem' hf hg n := (mul_pow _ _ _).trans <| congr_arg₂ _ (hf n) (hg n)
/-- The perfection of a ring `R` with characteristic `p`, as a subsemiring,
defined to be the projective limit of `R` using the Frobenius maps `R → R`
indexed by the natural numbers, implemented as `{ f : ℕ → R | ∀ n, f (n + 1) ^ p = f n }`. -/
def Ring.perfectionSubsemiring (R : Type u₁) [CommSemiring R] (p : ℕ) [hp : Fact p.Prime]
[CharP R p] : Subsemiring (ℕ → R) :=
{ Monoid.perfection R p with
zero_mem' := fun _ ↦ zero_pow hp.1.ne_zero
add_mem' := fun hf hg n => (map_add (frobenius R p) _ _).trans <| congr_arg₂ _ (hf n) (hg n) }
/-- The perfection of a ring `R` with characteristic `p`, as a subring,
defined to be the projective limit of `R` using the Frobenius maps `R → R`
indexed by the natural numbers, implemented as `{ f : ℕ → R | ∀ n, f (n + 1) ^ p = f n }`. -/
def Ring.perfectionSubring (R : Type u₁) [CommRing R] (p : ℕ) [hp : Fact p.Prime] [CharP R p] :
Subring (ℕ → R) :=
(Ring.perfectionSubsemiring R p).toSubring fun n => by
simp_rw [← frobenius_def, Pi.neg_apply, Pi.one_apply, RingHom.map_neg, RingHom.map_one]
/-- The perfection of a ring `R` with characteristic `p`,
defined to be the projective limit of `R` using the Frobenius maps `R → R`
indexed by the natural numbers, implemented as `{f : ℕ → R // ∀ n, f (n + 1) ^ p = f n}`. -/
def Ring.Perfection (R : Type u₁) [CommSemiring R] (p : ℕ) : Type u₁ :=
{ f // ∀ n : ℕ, (f : ℕ → R) (n + 1) ^ p = f n }
namespace Perfection
variable (R : Type u₁) [CommSemiring R] (p : ℕ) [hp : Fact p.Prime] [CharP R p]
instance commSemiring : CommSemiring (Ring.Perfection R p) :=
(Ring.perfectionSubsemiring R p).toCommSemiring
instance charP : CharP (Ring.Perfection R p) p :=
CharP.subsemiring (ℕ → R) p (Ring.perfectionSubsemiring R p)
instance ring (R : Type u₁) [CommRing R] [CharP R p] : Ring (Ring.Perfection R p) :=
(Ring.perfectionSubring R p).toRing
instance commRing (R : Type u₁) [CommRing R] [CharP R p] : CommRing (Ring.Perfection R p) :=
(Ring.perfectionSubring R p).toCommRing
instance : Inhabited (Ring.Perfection R p) := ⟨0⟩
/-- The `n`-th coefficient of an element of the perfection. -/
def coeff (n : ℕ) : Ring.Perfection R p →+* R where
toFun f := f.1 n
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
variable {R p}
@[ext]
theorem ext {f g : Ring.Perfection R p} (h : ∀ n, coeff R p n f = coeff R p n g) : f = g :=
Subtype.eq <| funext h
variable (R p)
/-- The `p`-th root of an element of the perfection. -/
def pthRoot : Ring.Perfection R p →+* Ring.Perfection R p where
toFun f := ⟨fun n => coeff R p (n + 1) f, fun _ => f.2 _⟩
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
variable {R p}
@[simp]
theorem coeff_mk (f : ℕ → R) (hf) (n : ℕ) : coeff R p n ⟨f, hf⟩ = f n := rfl
@[simp]
theorem coeff_pthRoot (f : Ring.Perfection R p) (n : ℕ) :
coeff R p n (pthRoot R p f) = coeff R p (n + 1) f := rfl
@[simp]
theorem coeff_pow_p (f : Ring.Perfection R p) (n : ℕ) :
coeff R p (n + 1) (f ^ p) = coeff R p n f := by rw [RingHom.map_pow]; exact f.2 n
@[simp]
theorem coeff_pow_p' (f : Ring.Perfection R p) (n : ℕ) : coeff R p (n + 1) f ^ p = coeff R p n f :=
f.2 n
@[simp]
theorem coeff_frobenius (f : Ring.Perfection R p) (n : ℕ) :
coeff R p (n + 1) (frobenius _ p f) = coeff R p n f := by apply coeff_pow_p f n
-- `coeff_pow_p f n` also works but is slow!
@[simp]
theorem coeff_iterate_frobenius (f : Ring.Perfection R p) (n m : ℕ) :
coeff R p (n + m) ((frobenius _ p)^[m] f) = coeff R p n f :=
Nat.recOn m rfl fun m ih => by
rw [Function.iterate_succ_apply', Nat.add_succ, coeff_frobenius, ih]
theorem coeff_iterate_frobenius' (f : Ring.Perfection R p) (n m : ℕ) (hmn : m ≤ n) :
coeff R p n ((frobenius _ p)^[m] f) = coeff R p (n - m) f :=
Eq.symm <| (coeff_iterate_frobenius _ _ m).symm.trans <| (tsub_add_cancel_of_le hmn).symm ▸ rfl
@[simp]
theorem pthRoot_frobenius : (pthRoot R p).comp (frobenius _ p) = RingHom.id _ :=
RingHom.ext fun x =>
ext fun n => by rw [RingHom.comp_apply, RingHom.id_apply, coeff_pthRoot, coeff_frobenius]
@[simp]
theorem frobenius_pthRoot : (frobenius _ p).comp (pthRoot R p) = RingHom.id _ :=
RingHom.ext fun x =>
ext fun n => by
rw [RingHom.comp_apply, RingHom.id_apply, RingHom.map_frobenius, coeff_pthRoot,
← @RingHom.map_frobenius (Ring.Perfection R p) _ R, coeff_frobenius]
theorem coeff_add_ne_zero {f : Ring.Perfection R p} {n : ℕ} (hfn : coeff R p n f ≠ 0) (k : ℕ) :
coeff R p (n + k) f ≠ 0 :=
Nat.recOn k hfn fun k ih h => ih <| by
rw [Nat.add_succ] at h
rw [← coeff_pow_p, RingHom.map_pow, h, zero_pow hp.1.ne_zero]
theorem coeff_ne_zero_of_le {f : Ring.Perfection R p} {m n : ℕ} (hfm : coeff R p m f ≠ 0)
(hmn : m ≤ n) : coeff R p n f ≠ 0 :=
let ⟨k, hk⟩ := Nat.exists_eq_add_of_le hmn
hk.symm ▸ coeff_add_ne_zero hfm k
variable (R p) in
instance perfectRing : PerfectRing (Ring.Perfection R p) p where
bijective_frobenius := Function.bijective_iff_has_inverse.mpr
⟨pthRoot R p,
DFunLike.congr_fun <| @frobenius_pthRoot R _ p _ _,
DFunLike.congr_fun <| @pthRoot_frobenius R _ p _ _⟩
@[simp]
theorem coeff_frobeniusEquiv_symm (f : Ring.Perfection R p) (n : ℕ) :
Perfection.coeff R p n ((frobeniusEquiv (Ring.Perfection R p) p).symm f) =
Perfection.coeff R p (n + 1) f := by
nth_rw 2 [← frobenius_apply_frobeniusEquiv_symm _ p f]
rw [coeff_frobenius]
@[simp]
theorem coeff_iterate_frobeniusEquiv_symm (f : Ring.Perfection R p) (n m : ℕ) :
Perfection.coeff _ p n ((frobeniusEquiv _ p).symm ^[m] f) =
Perfection.coeff _ p (n + m) f := by
induction m generalizing f n with
| zero => simp
| succ m ih =>
simp [ih, ← add_assoc]
variable (R p)
/-- Given rings `R` and `S` of characteristic `p`, with `R` being perfect,
any homomorphism `R →+* S` can be lifted to a homomorphism `R →+* Perfection S p`. -/
@[simps]
noncomputable def lift (R : Type u₁) [CommSemiring R] [CharP R p] [PerfectRing R p]
(S : Type u₂) [CommSemiring S] [CharP S p] : (R →+* S) ≃ (R →+* Ring.Perfection S p) where
toFun f :=
{ toFun := fun r => ⟨fun n => f (((frobeniusEquiv R p).symm : R →+* R)^[n] r),
fun n => by rw [← f.map_pow, Function.iterate_succ_apply', RingHom.coe_coe,
frobeniusEquiv_symm_pow_p]⟩
map_one' := ext fun _ => (congr_arg f <| iterate_map_one _ _).trans f.map_one
map_mul' := fun _ _ =>
ext fun _ => (congr_arg f <| iterate_map_mul _ _ _ _).trans <| f.map_mul _ _
map_zero' := ext fun _ => (congr_arg f <| iterate_map_zero _ _).trans f.map_zero
map_add' := fun _ _ =>
ext fun _ => (congr_arg f <| iterate_map_add _ _ _ _).trans <| f.map_add _ _ }
invFun := RingHom.comp <| coeff S p 0
right_inv f := RingHom.ext fun r => ext fun n =>
show coeff S p 0 (f (((frobeniusEquiv R p).symm)^[n] r)) = coeff S p n (f r) by
rw [← coeff_iterate_frobenius _ 0 n, zero_add, ← RingHom.map_iterate_frobenius,
Function.RightInverse.iterate (frobenius_apply_frobeniusEquiv_symm R p) n]
theorem hom_ext {R : Type u₁} [CommSemiring R] [CharP R p] [PerfectRing R p] {S : Type u₂}
[CommSemiring S] [CharP S p] {f g : R →+* Ring.Perfection S p}
(hfg : ∀ x, coeff S p 0 (f x) = coeff S p 0 (g x)) : f = g :=
(lift p R S).symm.injective <| RingHom.ext hfg
variable {R} {S : Type u₂} [CommSemiring S] [CharP S p]
/-- A ring homomorphism `R →+* S` induces `Perfection R p →+* Perfection S p`. -/
@[simps]
def map (φ : R →+* S) : Ring.Perfection R p →+* Ring.Perfection S p where
toFun f := ⟨fun n => φ (coeff R p n f), fun n => by rw [← φ.map_pow, coeff_pow_p']⟩
map_one' := Subtype.eq <| funext fun _ => φ.map_one
map_mul' _ _ := Subtype.eq <| funext fun _ => φ.map_mul _ _
map_zero' := Subtype.eq <| funext fun _ => φ.map_zero
map_add' _ _ := Subtype.eq <| funext fun _ => φ.map_add _ _
theorem coeff_map (φ : R →+* S) (f : Ring.Perfection R p) (n : ℕ) :
coeff S p n (map p φ f) = φ (coeff R p n f) := rfl
end Perfection
/-- A perfection map to a ring of characteristic `p` is a map that is isomorphic
to its perfection. -/
structure PerfectionMap (p : ℕ) [Fact p.Prime] {R : Type u₁} [CommSemiring R] [CharP R p]
{P : Type u₂} [CommSemiring P] [CharP P p] [PerfectRing P p] (π : P →+* R) : Prop where
injective : ∀ ⦃x y : P⦄,
(∀ n, π (((frobeniusEquiv P p).symm)^[n] x) = π (((frobeniusEquiv P p).symm)^[n] y)) → x = y
surjective : ∀ f : ℕ → R, (∀ n, f (n + 1) ^ p = f n) → ∃ x : P, ∀ n,
π (((frobeniusEquiv P p).symm)^[n] x) = f n
namespace PerfectionMap
variable {p : ℕ} [Fact p.Prime]
variable {R : Type u₁} [CommSemiring R] [CharP R p]
variable {P : Type u₃} [CommSemiring P] [CharP P p] [PerfectRing P p]
/-- Create a `PerfectionMap` from an isomorphism to the perfection. -/
theorem mk' {f : P →+* R} (g : P ≃+* Ring.Perfection R p) (hfg : Perfection.lift p P R f = g) :
PerfectionMap p f :=
{ injective := fun x y hxy =>
g.injective <|
(RingHom.ext_iff.1 hfg x).symm.trans <|
Eq.symm <| (RingHom.ext_iff.1 hfg y).symm.trans <| Perfection.ext fun n => (hxy n).symm
surjective := fun y hy =>
let ⟨x, hx⟩ := g.surjective ⟨y, hy⟩
⟨x, fun n =>
show Perfection.coeff R p n (Perfection.lift p P R f x) = Perfection.coeff R p n ⟨y, hy⟩ by
simp [hfg, hx]⟩ }
variable (p R P)
/-- The canonical perfection map from the perfection of a ring. -/
theorem of : PerfectionMap p (Perfection.coeff R p 0) :=
mk' (RingEquiv.refl _) <| (Equiv.apply_eq_iff_eq_symm_apply _).2 rfl
/-- For a perfect ring, it itself is the perfection. -/
theorem id [PerfectRing R p] : PerfectionMap p (RingHom.id R) :=
{ injective := fun _ _ hxy => hxy 0
surjective := fun f hf =>
⟨f 0, fun n =>
show ((frobeniusEquiv R p).symm)^[n] (f 0) = f n from
Nat.recOn n rfl fun n ih => injective_pow_p R p <| by
rw [Function.iterate_succ_apply', frobeniusEquiv_symm_pow_p, ih, hf]⟩ }
variable {p R P}
/-- A perfection map induces an isomorphism to the perfection. -/
noncomputable def equiv {π : P →+* R} (m : PerfectionMap p π) : P ≃+* Ring.Perfection R p :=
RingEquiv.ofBijective (Perfection.lift p P R π)
⟨fun _ _ hxy => m.injective fun n => (congr_arg (Perfection.coeff R p n) hxy :), fun f =>
let ⟨x, hx⟩ := m.surjective f.1 f.2
⟨x, Perfection.ext <| hx⟩⟩
theorem equiv_apply {π : P →+* R} (m : PerfectionMap p π) (x : P) :
m.equiv x = Perfection.lift p P R π x := rfl
theorem comp_equiv {π : P →+* R} (m : PerfectionMap p π) (x : P) :
Perfection.coeff R p 0 (m.equiv x) = π x := rfl
theorem comp_equiv' {π : P →+* R} (m : PerfectionMap p π) :
(Perfection.coeff R p 0).comp ↑m.equiv = π :=
RingHom.ext fun _ => rfl
theorem comp_symm_equiv {π : P →+* R} (m : PerfectionMap p π) (f : Ring.Perfection R p) :
π (m.equiv.symm f) = Perfection.coeff R p 0 f :=
(m.comp_equiv _).symm.trans <| congr_arg _ <| m.equiv.apply_symm_apply f
theorem comp_symm_equiv' {π : P →+* R} (m : PerfectionMap p π) :
π.comp ↑m.equiv.symm = Perfection.coeff R p 0 :=
RingHom.ext m.comp_symm_equiv
variable (p R P)
/-- Given rings `R` and `S` of characteristic `p`, with `R` being perfect,
any homomorphism `R →+* S` can be lifted to a homomorphism `R →+* P`,
where `P` is any perfection of `S`. -/
@[simps]
noncomputable def lift [PerfectRing R p] (S : Type u₂) [CommSemiring S] [CharP S p] (P : Type u₃)
[CommSemiring P] [CharP P p] [PerfectRing P p] (π : P →+* S) (m : PerfectionMap p π) :
(R →+* S) ≃ (R →+* P) where
toFun f := RingHom.comp ↑m.equiv.symm <| Perfection.lift p R S f
invFun f := π.comp f
left_inv f := by
simp_rw [← RingHom.comp_assoc, comp_symm_equiv']
exact (Perfection.lift p R S).symm_apply_apply f
right_inv f := by
exact RingHom.ext fun x => m.equiv.injective <| (m.equiv.apply_symm_apply _).trans
<| show Perfection.lift p R S (π.comp f) x = RingHom.comp (↑m.equiv) f x from
RingHom.ext_iff.1 (by rw [Equiv.apply_eq_iff_eq_symm_apply]; rfl) _
variable {R p}
theorem hom_ext [PerfectRing R p] {S : Type u₂} [CommSemiring S] [CharP S p] {P : Type u₃}
[CommSemiring P] [CharP P p] [PerfectRing P p] (π : P →+* S) (m : PerfectionMap p π)
{f g : R →+* P} (hfg : ∀ x, π (f x) = π (g x)) : f = g :=
(lift p R S P π m).symm.injective <| RingHom.ext hfg
variable {P} (p)
variable {S : Type u₂} [CommSemiring S] [CharP S p]
variable {Q : Type u₄} [CommSemiring Q] [CharP Q p] [PerfectRing Q p]
/-- A ring homomorphism `R →+* S` induces `P →+* Q`, a map of the respective perfections. -/
@[nolint unusedArguments]
noncomputable def map {π : P →+* R} (_ : PerfectionMap p π) {σ : Q →+* S} (n : PerfectionMap p σ)
(φ : R →+* S) : P →+* Q :=
lift p P S Q σ n <| φ.comp π
theorem comp_map {π : P →+* R} (m : PerfectionMap p π) {σ : Q →+* S} (n : PerfectionMap p σ)
(φ : R →+* S) : σ.comp (map p m n φ) = φ.comp π :=
(lift p P S Q σ n).symm_apply_apply _
theorem map_map {π : P →+* R} (m : PerfectionMap p π) {σ : Q →+* S} (n : PerfectionMap p σ)
(φ : R →+* S) (x : P) : σ (map p m n φ x) = φ (π x) :=
RingHom.ext_iff.1 (comp_map p m n φ) x
theorem map_eq_map (φ : R →+* S) : map p (of p R) (of p S) φ = Perfection.map p φ :=
hom_ext _ (of p S) fun f => by rw [map_map, Perfection.coeff_map]
end PerfectionMap
section ModP
variable (O : Type u₂) [CommRing O] (p : ℕ)
/-- `O/(p)` for `O`, ring of integers of `K`. -/
abbrev ModP :=
O ⧸ (Ideal.span {(p : O)} : Ideal O)
namespace ModP
instance commRing : CommRing (ModP O p) :=
Ideal.Quotient.commRing (Ideal.span {(p : O)} : Ideal O)
instance charP [Fact p.Prime] [hvp : Fact (¬ IsUnit (p : O))] : CharP (ModP O p) p :=
CharP.quotient O p <| hvp.1
instance nontrivial [hp : Fact p.Prime] [Fact (¬ IsUnit (p : O))] : Nontrivial (ModP O p) :=
CharP.nontrivial_of_char_ne_one hp.1.ne_one
end ModP
end ModP
section Perfectoid
variable (K : Type u₁) [Field K] (v : Valuation K ℝ≥0)
variable (O : Type u₂) [CommRing O] [Algebra O K] (hv : v.Integers O)
variable (p : ℕ)
namespace ModP
section Classical
attribute [local instance] Classical.dec
/-- For a field `K` with valuation `v : K → ℝ≥0` and ring of integers `O`,
a function `O/(p) → ℝ≥0` that sends `0` to `0` and `x + (p)` to `v(x)` as long as `x ∉ (p)`. -/
noncomputable def preVal (x : ModP O p) : ℝ≥0 :=
if x = 0 then 0 else v (algebraMap O K x.out)
variable {K v O p}
theorem preVal_zero : preVal K v O p 0 = 0 :=
if_pos rfl
include hv
theorem preVal_mk {x : O} (hx : (Ideal.Quotient.mk _ x : ModP O p) ≠ 0) :
preVal K v O p (Ideal.Quotient.mk _ x) = v (algebraMap O K x) := by
obtain ⟨r, hr⟩ : ∃ (a : O), a * (p : O) = (Ideal.Quotient.mk _ x).out - x :=
Ideal.mem_span_singleton'.1 <| Ideal.Quotient.eq.1 <| Quotient.sound' <| Quotient.mk_out' _
refine (if_neg hx).trans (v.map_eq_of_sub_lt <| lt_of_not_ge ?_)
rw [← RingHom.map_sub, ← hr, hv.le_iff_dvd]
exact fun hprx =>
hx (Ideal.Quotient.eq_zero_iff_mem.2 <| Ideal.mem_span_singleton.2 <| dvd_of_mul_left_dvd hprx)
theorem preVal_mul {x y : ModP O p} (hxy0 : x * y ≠ 0) :
preVal K v O p (x * y) = preVal K v O p x * preVal K v O p y := by
have hx0 : x ≠ 0 := mt (by rintro rfl; rw [zero_mul]) hxy0
have hy0 : y ≠ 0 := mt (by rintro rfl; rw [mul_zero]) hxy0
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y
rw [← map_mul (Ideal.Quotient.mk (Ideal.span {↑p})) r s] at hxy0 ⊢
rw [preVal_mk hv hx0, preVal_mk hv hy0, preVal_mk hv hxy0, RingHom.map_mul, v.map_mul]
theorem preVal_add (x y : ModP O p) :
preVal K v O p (x + y) ≤ max (preVal K v O p x) (preVal K v O p y) := by
by_cases hx0 : x = 0
· rw [hx0, zero_add]; exact le_max_right _ _
by_cases hy0 : y = 0
· rw [hy0, add_zero]; exact le_max_left _ _
by_cases hxy0 : x + y = 0
· rw [hxy0, preVal_zero]; exact zero_le _
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y
rw [← map_add (Ideal.Quotient.mk (Ideal.span {↑p})) r s] at hxy0 ⊢
rw [preVal_mk hv hx0, preVal_mk hv hy0, preVal_mk hv hxy0, RingHom.map_add]; exact v.map_add _ _
theorem v_p_lt_preVal {x : ModP O p} : v p < preVal K v O p x ↔ x ≠ 0 := by
refine ⟨fun h hx => by rw [hx, preVal_zero] at h; exact not_lt_zero' h,
fun h => lt_of_not_ge fun hp => h ?_⟩
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x
rw [preVal_mk hv h, ← map_natCast (algebraMap O K) p, hv.le_iff_dvd] at hp
· rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton]; exact hp
theorem preVal_eq_zero {x : ModP O p} : preVal K v O p x = 0 ↔ x = 0 :=
⟨fun hvx =>
by_contradiction fun hx0 : x ≠ 0 => by
rw [← v_p_lt_preVal (hv := hv), hvx] at hx0
exact not_lt_zero' hx0,
fun hx => hx.symm ▸ preVal_zero⟩
theorem v_p_lt_val {x : O} :
v p < v (algebraMap O K x) ↔ (Ideal.Quotient.mk _ x : ModP O p) ≠ 0 := by
rw [lt_iff_not_ge, not_iff_not, ← map_natCast (algebraMap O K) p, hv.le_iff_dvd,
Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton]
open NNReal
variable [hp : Fact p.Prime]
theorem mul_ne_zero_of_pow_p_ne_zero {x y : ModP O p} (hx : x ^ p ≠ 0) (hy : y ^ p ≠ 0) :
x * y ≠ 0 := by
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y
have h1p : (0 : ℝ) < 1 / p := one_div_pos.2 (Nat.cast_pos.2 hp.1.pos)
rw [← (Ideal.Quotient.mk (Ideal.span {(p : O)})).map_mul]
rw [← (Ideal.Quotient.mk (Ideal.span {(p : O)})).map_pow] at hx hy
rw [← v_p_lt_val hv] at hx hy ⊢
rw [RingHom.map_pow, v.map_pow, ← rpow_lt_rpow_iff h1p, ← rpow_natCast, ← rpow_mul,
mul_one_div_cancel (Nat.cast_ne_zero.2 hp.1.ne_zero : (p : ℝ) ≠ 0), rpow_one] at hx hy
rw [RingHom.map_mul, v.map_mul]; refine lt_of_le_of_lt ?_ (mul_lt_mul'' hx hy zero_le' zero_le')
by_cases hvp : v p = 0
· rw [hvp]; exact zero_le _
replace hvp := zero_lt_iff.2 hvp
conv_lhs => rw [← rpow_one (v p)]
rw [← rpow_add (ne_of_gt hvp)]
refine rpow_le_rpow_of_exponent_ge hvp (map_natCast (algebraMap O K) p ▸ hv.2 _) ?_
rw [← add_div, div_le_one (Nat.cast_pos.2 hp.1.pos : 0 < (p : ℝ))]; exact mod_cast hp.1.two_le
end Classical
end ModP
/-- Perfection of `O/(p)` where `O` is the ring of integers of `K`. -/
def PreTilt :=
Ring.Perfection (ModP O p) p
namespace PreTilt
variable [Fact p.Prime] [Fact (¬ IsUnit (p : O))]
instance : CommRing (PreTilt O p) :=
Perfection.commRing p _
instance : CharP (PreTilt O p) p :=
Perfection.charP (ModP O p) p
instance : PerfectRing (PreTilt O p) p :=
Perfection.perfectRing (ModP O p) p
section coeff
@[simp]
theorem coeff_frobenius (n : ℕ) (x : PreTilt O p) :
((Perfection.coeff (ModP O p) p (n + 1)) (((frobenius (PreTilt O p) p)) x)) =
((Perfection.coeff (ModP O p) p n) x):= by
simp [PreTilt]
@[simp]
theorem coeff_frobenius_pow (m n : ℕ) (x : PreTilt O p) :
((Perfection.coeff (ModP O p) p (m + n)) (((frobenius (PreTilt O p) p) ^[n]) x)) =
((Perfection.coeff (ModP O p) p m) x):= by
simp [PreTilt]
@[simp]
theorem coeff_frobeniusEquiv_symm (n : ℕ) (x : PreTilt O p) :
((Perfection.coeff (ModP O p) p n) (((frobeniusEquiv (PreTilt O p) p).symm) x)) =
((Perfection.coeff (ModP O p) p (n + 1)) x):= by
simp [PreTilt]
@[simp]
theorem coeff_iterate_frobeniusEquiv_symm (m n : ℕ) (x : PreTilt O p) :
((Perfection.coeff (ModP O p) p m) (((frobeniusEquiv (PreTilt O p) p).symm ^[n]) x)) =
((Perfection.coeff (ModP O p) p (m + n)) x):= by
simp [PreTilt]
end coeff
section Classical
open Perfection
open scoped Classical in
/-- The valuation `Perfection(O/(p)) → ℝ≥0` as a function.
Given `f ∈ Perfection(O/(p))`, if `f = 0` then output `0`;
otherwise output `preVal(f(n))^(p^n)` for any `n` such that `f(n) ≠ 0`. -/
noncomputable def valAux (f : PreTilt O p) : ℝ≥0 :=
if h : ∃ n, coeff _ _ n f ≠ 0 then
ModP.preVal K v O p (coeff _ _ (Nat.find h) f) ^ p ^ Nat.find h
else 0
variable {K v O p}
open scoped Classical in
theorem coeff_nat_find_add_ne_zero {f : PreTilt O p} {h : ∃ n, coeff _ _ n f ≠ 0} (k : ℕ) :
coeff _ _ (Nat.find h + k) f ≠ 0 :=
coeff_add_ne_zero (Nat.find_spec h) k
theorem valAux_zero : valAux K v O p 0 = 0 :=
dif_neg fun ⟨_, hn⟩ => hn rfl
include hv
theorem valAux_eq {f : PreTilt O p} {n : ℕ} (hfn : coeff _ _ n f ≠ 0) :
valAux K v O p f = ModP.preVal K v O p (coeff _ _ n f) ^ p ^ n := by
have h : ∃ n, coeff _ _ n f ≠ 0 := ⟨n, hfn⟩
rw [valAux, dif_pos h]
classical
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le (Nat.find_min' h hfn)
induction k with
| zero => rfl
| succ k ih => ?_
obtain ⟨x, hx⟩ := Ideal.Quotient.mk_surjective (coeff (ModP O p) p (Nat.find h + k + 1) f)
have h1 : (Ideal.Quotient.mk _ x : ModP O p) ≠ 0 := hx.symm ▸ hfn
have h2 : (Ideal.Quotient.mk _ (x ^ p) : ModP O p) ≠ 0 := by
erw [RingHom.map_pow, hx, ← RingHom.map_pow, coeff_pow_p]
exact coeff_nat_find_add_ne_zero k
erw [ih (coeff_nat_find_add_ne_zero k), ← hx, ← coeff_pow_p, RingHom.map_pow, ← hx,
← RingHom.map_pow, ModP.preVal_mk hv h1, ModP.preVal_mk hv h2, RingHom.map_pow, v.map_pow,
← pow_mul, pow_succ']
rfl
theorem valAux_one : valAux K v O p 1 = 1 :=
(valAux_eq (hv := hv) <| show coeff (ModP O p) p 0 1 ≠ 0 from one_ne_zero).trans <| by
rw [pow_zero, pow_one, RingHom.map_one, ← (Ideal.Quotient.mk _).map_one, ModP.preVal_mk hv,
RingHom.map_one, v.map_one]
change (1 : ModP O p) ≠ 0
exact one_ne_zero
theorem valAux_mul (f g : PreTilt O p) :
valAux K v O p (f * g) = valAux K v O p f * valAux K v O p g := by
by_cases hf : f = 0
· rw [hf, zero_mul, valAux_zero, zero_mul]
by_cases hg : g = 0
· rw [hg, mul_zero, valAux_zero, mul_zero]
obtain ⟨m, hm⟩ : ∃ n, coeff _ _ n f ≠ 0 := not_forall.1 fun h => hf <| Perfection.ext h
obtain ⟨n, hn⟩ : ∃ n, coeff _ _ n g ≠ 0 := not_forall.1 fun h => hg <| Perfection.ext h
replace hm := coeff_ne_zero_of_le hm (le_max_left m n)
replace hn := coeff_ne_zero_of_le hn (le_max_right m n)
have hfg : coeff _ _ (max m n + 1) (f * g) ≠ 0 := by
rw [RingHom.map_mul]
refine ModP.mul_ne_zero_of_pow_p_ne_zero (hv := hv) ?_ ?_
· rw [← RingHom.map_pow, coeff_pow_p f]; assumption
· rw [← RingHom.map_pow, coeff_pow_p g]; assumption
rw [valAux_eq hv (coeff_add_ne_zero hm 1),
valAux_eq hv (coeff_add_ne_zero hn 1), valAux_eq hv hfg]
rw [RingHom.map_mul] at hfg ⊢; rw [ModP.preVal_mul hv hfg, mul_pow]
theorem valAux_add (f g : PreTilt O p) :
valAux K v O p (f + g) ≤ max (valAux K v O p f) (valAux K v O p g) := by
by_cases hf : f = 0
· rw [hf, zero_add, valAux_zero, max_eq_right]; exact zero_le _
by_cases hg : g = 0
· rw [hg, add_zero, valAux_zero, max_eq_left]; exact zero_le _
by_cases hfg : f + g = 0
· rw [hfg, valAux_zero]; exact zero_le _
replace hf : ∃ n, coeff _ _ n f ≠ 0 := not_forall.1 fun h => hf <| Perfection.ext h
replace hg : ∃ n, coeff _ _ n g ≠ 0 := not_forall.1 fun h => hg <| Perfection.ext h
replace hfg : ∃ n, coeff _ _ n (f + g) ≠ 0 := not_forall.1 fun h => hfg <| Perfection.ext h
obtain ⟨m, hm⟩ := hf; obtain ⟨n, hn⟩ := hg; obtain ⟨k, hk⟩ := hfg
replace hm := coeff_ne_zero_of_le hm (le_trans (le_max_left m n) (le_max_left _ k))
replace hn := coeff_ne_zero_of_le hn (le_trans (le_max_right m n) (le_max_left _ k))
replace hk := coeff_ne_zero_of_le hk (le_max_right (max m n) k)
rw [valAux_eq hv hm, valAux_eq hv hn, valAux_eq hv hk, RingHom.map_add]
rcases le_max_iff.1
(ModP.preVal_add hv (coeff _ _ (max (max m n) k) f)
(coeff _ _ (max (max m n) k) g)) with h | h
· exact le_max_of_le_left (pow_le_pow_left' h _)
· exact le_max_of_le_right (pow_le_pow_left' h _)
variable (K v O p)
/-- The valuation `Perfection(O/(p)) → ℝ≥0`.
Given `f ∈ Perfection(O/(p))`, if `f = 0` then output `0`;
otherwise output `preVal(f(n))^(p^n)` for any `n` such that `f(n) ≠ 0`. -/
noncomputable def val : Valuation (PreTilt O p) ℝ≥0 where
toFun := valAux K v O p
map_one' := valAux_one hv
map_mul' := valAux_mul hv
map_zero' := valAux_zero
map_add_le_max' := valAux_add hv
variable {K v O p}
theorem map_eq_zero {f : PreTilt O p} : val K v O hv p f = 0 ↔ f = 0 := by
by_cases hf0 : f = 0
· rw [hf0]; exact iff_of_true (Valuation.map_zero _) rfl
obtain ⟨n, hn⟩ : ∃ n, coeff _ _ n f ≠ 0 := not_forall.1 fun h => hf0 <| Perfection.ext h
change valAux K v O p f = 0 ↔ f = 0; refine iff_of_false (fun hvf => hn ?_) hf0
rw [valAux_eq hv hn] at hvf
replace hvf := eq_zero_of_pow_eq_zero hvf
rwa [ModP.preVal_eq_zero hv] at hvf
end Classical
include hv
theorem isDomain : IsDomain (PreTilt O p) := by
have hp : Nat.Prime p := Fact.out
haveI : Nontrivial (PreTilt O p) := ⟨(CharP.nontrivial_of_char_ne_one hp.ne_one).1⟩
haveI : NoZeroDivisors (PreTilt O p) :=
⟨fun hfg => by
simp_rw [← map_eq_zero hv] at hfg ⊢; contrapose! hfg; rw [Valuation.map_mul]
exact mul_ne_zero hfg.1 hfg.2⟩
exact NoZeroDivisors.to_isDomain _
end PreTilt
/-- The tilt of a field, as defined in Perfectoid Spaces by Peter Scholze, as in
[scholze2011perfectoid]. Given a field `K` with valuation `K → ℝ≥0` and ring of integers `O`,
this is implemented as the fraction field of the perfection of `O/(p)`. -/
def Tilt [Fact p.Prime] [hvp : Fact (v p ≠ 1)] :=
have _ := Fact.mk <| mt hv.one_of_isUnit <| (map_natCast (algebraMap O K) p).symm ▸ hvp.1
FractionRing (PreTilt O p)
namespace Tilt
noncomputable instance [Fact p.Prime] [hvp : Fact (v p ≠ 1)] : Field (Tilt K v O hv p) :=
haveI := Fact.mk <| mt hv.one_of_isUnit <| (map_natCast (algebraMap O K) p).symm ▸ hvp.1
haveI := PreTilt.isDomain K v O hv p
FractionRing.field _
end Tilt
end Perfectoid |
.lake/packages/mathlib/Mathlib/RingTheory/Invariant.lean | import Mathlib.RingTheory.Invariant.Basic
deprecated_module (since := "2025-05-24") |
.lake/packages/mathlib/Mathlib/RingTheory/HopkinsLevitzki.lean | import Mathlib.Algebra.Module.Torsion.Basic
import Mathlib.RingTheory.FiniteLength
import Mathlib.RingTheory.Noetherian.Nilpotent
import Mathlib.RingTheory.Spectrum.Prime.Noetherian
import Mathlib.RingTheory.KrullDimension.Zero
/-!
## The Hopkins–Levitzki theorem
## Main results
* `IsSemiprimaryRing.isNoetherian_iff_isArtinian`: the Hopkins–Levitzki theorem, which states
that for a module over a semiprimary ring (in particular, an Artinian ring),
`IsNoetherian` is equivalent to `IsArtinian` (and therefore also to `IsFiniteLength`).
* In particular, for a module over an Artinian ring, `Module.Finite`, `IsNoetherian`, `IsArtinian`,
and `IsFiniteLength` are all equivalent (`IsArtinianRing.tfae`),
and a (left) Artinian ring is also (left) Noetherian.
* `isArtinianRing_iff_isNoetherianRing_krullDimLE_zero`: a commutative ring is Artinian iff
it is Noetherian with Krull dimension at most 0.
## Reference
* [F. Lorenz, *Algebra: Volume II: Fields with Structure, Algebras and Advanced Topics*][Lorenz2008]
-/
universe u
variable (R₀ R : Type*) (M : Type u) [Ring R₀] [Ring R] [Module R₀ R]
[AddCommGroup M] [Module R₀ M] [Module R M] [IsScalarTower R₀ R M]
namespace IsSemiprimaryRing
variable [IsSemiprimaryRing R]
@[elab_as_elim] protected theorem induction
{P : ∀ (M : Type u) [AddCommGroup M] [Module R₀ M] [Module R M], Prop}
(h0 : ∀ (M) [AddCommGroup M] [Module R₀ M] [Module R M] [IsScalarTower R₀ R M]
[IsSemisimpleModule R M], Module.IsTorsionBySet R M (Ring.jacobson R) → P M)
(h1 : ∀ (M) [AddCommGroup M] [Module R₀ M] [Module R M] [IsScalarTower R₀ R M],
let N := Ring.jacobson R • (⊤ : Submodule R M); P N → P (M ⧸ N) → P M) :
P M := by
have ⟨ss, n, hn⟩ := (isSemiprimaryRing_iff R).mp ‹_›
set Jac := Ring.jacobson R
replace hn : Jac ^ n ≤ Module.annihilator R M := hn ▸ bot_le
have {M} [AddCommGroup M] [Module R₀ M] [Module R M] [IsScalarTower R₀ R M] :
Jac ≤ Module.annihilator R M → P M := by
rw [← SetLike.coe_subset_coe, ← Module.isTorsionBySet_iff_subset_annihilator]
intro h
let _ := h.module
have := (h.semilinearMap.isSemisimpleModule_iff_of_bijective Function.bijective_id).2
inferInstance
exact h0 _ h
induction n generalizing M with
| zero => rw [Jac.pow_zero, Ideal.one_eq_top] at hn; exact this (le_top.trans hn)
| succ n ih => ?_
obtain _ | n := n
· rw [Jac.pow_one] at hn; exact this hn
refine h1 _ (ih _ ?_) (ih _ ?_)
· rwa [← Submodule.annihilator_top, Submodule.le_annihilator_iff, Jac.pow_succ,
Submodule.mul_smul, ← Submodule.le_annihilator_iff] at hn
· rw [← SetLike.coe_subset_coe, ← Module.isTorsionBySet_iff_subset_annihilator,
Module.isTorsionBySet_quotient_iff]
exact fun m i hi ↦ Submodule.smul_mem_smul (Ideal.pow_le_self n.succ_ne_zero hi) trivial
section
variable [IsScalarTower R₀ R R] [Module.Finite R₀ (R ⧸ Ring.jacobson R)]
private theorem finite_of_isNoetherian_or_isArtinian :
IsNoetherian R M ∨ IsArtinian R M → Module.Finite R₀ M := by
refine IsSemiprimaryRing.induction R₀ R M (P := fun M ↦ IsNoetherian R M ∨ IsArtinian R M →
Module.Finite R₀ M) (fun M _ _ _ _ _ hJ h ↦ ?_) (fun M _ _ _ _ hs hq h ↦ ?_)
· let _ := hJ.module
have := IsSemisimpleModule.finite_tfae (R := R) (M := M)
simp_rw [this.out 1 0, this.out 2 0, or_self,
hJ.semilinearMap.finite_iff_of_bijective Function.bijective_id] at h
exact .trans (R ⧸ Ring.jacobson R) M
· let N := (Ring.jacobson R • ⊤ : Submodule R M).restrictScalars R₀
have : Module.Finite R₀ N := by refine hs (h.imp ?_ ?_) <;> (intro; infer_instance)
have : Module.Finite R₀ (M ⧸ N) := by refine hq (h.imp ?_ ?_) <;> (intro; infer_instance)
exact .of_submodule_quotient N
theorem finite_of_isNoetherian [IsNoetherian R M] : Module.Finite R₀ M :=
finite_of_isNoetherian_or_isArtinian R₀ R M (.inl ‹_›)
theorem finite_of_isArtinian [IsArtinian R M] : Module.Finite R₀ M :=
finite_of_isNoetherian_or_isArtinian R₀ R M (.inr ‹_›)
end
variable {R M}
theorem isNoetherian_iff_isArtinian : IsNoetherian R M ↔ IsArtinian R M :=
IsSemiprimaryRing.induction R R M (P := fun M ↦ IsNoetherian R M ↔ IsArtinian R M)
(fun M _ _ _ _ _ _ ↦ IsSemisimpleModule.finite_tfae.out 1 2)
fun M _ _ _ _ h h' ↦ let N : Submodule R M := Ring.jacobson R • ⊤; by
simp_rw [isNoetherian_iff_submodule_quotient N, isArtinian_iff_submodule_quotient N, N, h, h']
theorem isNoetherian_iff_finite_of_jacobson_fg (fg : (Ring.jacobson R).FG) :
IsNoetherian R M ↔ Module.Finite R M :=
⟨fun _ ↦ inferInstance, IsSemiprimaryRing.induction R R M
(P := fun M ↦ Module.Finite R M → IsNoetherian R M)
(fun M _ _ _ _ _ _ ↦ (IsSemisimpleModule.finite_tfae.out 0 1).mp)
fun M _ _ _ _ hs hq fin ↦ (isNoetherian_iff_submodule_quotient (Ring.jacobson R • ⊤)).mpr
⟨hs (Module.Finite.iff_fg.mpr (.smul fg fin.1)), hq inferInstance⟩⟩
theorem isNoetherianRing_iff_jacobson_fg : IsNoetherianRing R ↔ (Ring.jacobson R).FG :=
⟨fun _ ↦ IsNoetherian.noetherian .., fun fg ↦
(IsSemiprimaryRing.isNoetherian_iff_finite_of_jacobson_fg fg).mpr inferInstance⟩
end IsSemiprimaryRing
theorem IsArtinianRing.tfae [IsArtinianRing R] :
List.TFAE [Module.Finite R M, IsNoetherian R M, IsArtinian R M, IsFiniteLength R M] := by
tfae_have 2 ↔ 3 := IsSemiprimaryRing.isNoetherian_iff_isArtinian
tfae_have 2 → 1 := fun _ ↦ inferInstance
tfae_have 1 → 3 := fun _ ↦ inferInstance
rw [isFiniteLength_iff_isNoetherian_isArtinian]
tfae_have 4 → 2 := And.left
tfae_have 2 → 4 := fun h ↦ ⟨h, tfae_2_iff_3.mp h⟩
tfae_finish
@[stacks 00JB "A ring is Artinian if and only if it has finite length as a module over itself."]
theorem isArtinianRing_iff_isFiniteLength : IsArtinianRing R ↔ IsFiniteLength R R :=
⟨fun h ↦ ((IsArtinianRing.tfae R R).out 2 3).mp h,
fun h ↦ (isFiniteLength_iff_isNoetherian_isArtinian.mp h).2⟩
@[stacks 00JB "A ring is Artinian if and only if it has finite length as a module over itself.
**Any such ring is both Artinian and Noetherian.**"]
instance [IsArtinianRing R] : IsNoetherianRing R := ((IsArtinianRing.tfae R R).out 2 1).mp ‹_›
/-- A finitely generated Artinian module over a commutative ring is Noetherian. This is not
necessarily the case over a noncommutative ring, see https://mathoverflow.net/a/61700. -/
theorem isNoetherian_of_finite_isArtinian {R} [CommRing R] [Module R M]
[Module.Finite R M] [IsArtinian R M] : IsNoetherian R M := by
obtain ⟨s, fin, span⟩ := Submodule.fg_def.mp (Module.finite_def.mp ‹_›)
rw [← s.iUnion_of_singleton_coe, Submodule.span_iUnion] at span
rw [← Set.finite_coe_iff] at fin
rw [← isNoetherian_top_iff, ← span]
have _ (i : M) : IsNoetherian R (Submodule.span R {i}) := by
rw [LinearMap.span_singleton_eq_range, ← (LinearMap.quotKerEquivRange _).isNoetherian_iff]
let e (I : Ideal R) : R ⧸ I →ₛₗ[Ideal.Quotient.mk I] R ⧸ I := ⟨.id _, fun _ _ ↦ rfl⟩
rw [(e _).isNoetherian_iff_of_bijective Function.bijective_id]
refine @instIsNoetherianRingOfIsArtinianRing _ _ ?_
rw [IsArtinianRing, ← (e _).isArtinian_iff_of_bijective Function.bijective_id,
(LinearMap.quotKerEquivRange _).isArtinian_iff]
infer_instance
infer_instance
theorem IsNoetherianRing.isArtinianRing_of_krullDimLE_zero {R} [CommRing R]
[IsNoetherianRing R] [Ring.KrullDimLE 0 R] : IsArtinianRing R :=
have eq := Ring.jacobson_eq_nilradical_of_krullDimLE_zero R
let Spec := {I : Ideal R | I.IsPrime}
have : Finite Spec :=
(minimalPrimes.finite_of_isNoetherianRing R).subset Ideal.mem_minimalPrimes_of_krullDimLE_zero
have (I : Spec) : I.1.IsPrime := I.2
have (I : Spec) : IsSemisimpleRing (R ⧸ I.1) := let _ := Ideal.Quotient.field I.1; inferInstance
have : IsSemisimpleRing (R ⧸ Ring.jacobson R) := by
rw [eq, nilradical_eq_sInf, sInf_eq_iInf']
exact (Ideal.quotientInfRingEquivPiQuotient _ fun I J ne ↦
Ideal.isCoprime_of_isMaximal <| Subtype.coe_ne_coe.mpr ne).symm.isSemisimpleRing
have : IsSemiprimaryRing R := ⟨this, eq ▸ IsNoetherianRing.isNilpotent_nilradical R⟩
IsSemiprimaryRing.isNoetherian_iff_isArtinian.mp ‹_›
@[stacks 00KH] theorem isArtinianRing_iff_isNoetherianRing_krullDimLE_zero {R} [CommRing R] :
IsArtinianRing R ↔ IsNoetherianRing R ∧ Ring.KrullDimLE 0 R :=
⟨fun _ ↦ ⟨inferInstance, inferInstance⟩, fun ⟨h, _⟩ ↦ h.isArtinianRing_of_krullDimLE_zero⟩
theorem isArtinianRing_iff_krullDimLE_zero {R : Type*} [CommRing R] [IsNoetherianRing R] :
IsArtinianRing R ↔ Ring.KrullDimLE 0 R := by
rwa [isArtinianRing_iff_isNoetherianRing_krullDimLE_zero, and_iff_right]
lemma isArtinianRing_iff_isNilpotent_maximalIdeal (R : Type*) [CommRing R] [IsNoetherianRing R]
[IsLocalRing R] : IsArtinianRing R ↔ IsNilpotent (IsLocalRing.maximalIdeal R) := by
rw [isArtinianRing_iff_krullDimLE_zero,
Ideal.FG.isNilpotent_iff_le_nilradical (IsNoetherian.noetherian _),
← and_iff_left (a := Ring.KrullDimLE 0 R) ‹IsLocalRing R›,
(Ring.krullDimLE_zero_and_isLocalRing_tfae R).out 0 3 rfl rfl,
IsLocalRing.isMaximal_iff, le_antisymm_iff, and_iff_right]
exact IsLocalRing.le_maximalIdeal (by simp [nilradical, Ideal.radical_eq_top]) |
.lake/packages/mathlib/Mathlib/RingTheory/Support.lean | import Mathlib.RingTheory.Ideal.Colon
import Mathlib.RingTheory.Localization.Finiteness
import Mathlib.RingTheory.Nakayama
import Mathlib.RingTheory.QuotSMulTop
import Mathlib.RingTheory.Spectrum.Prime.Basic
/-!
# Support of a module
## Main results
- `Module.support`: The support of an `R`-module as a subset of `Spec R`.
- `Module.mem_support_iff_exists_annihilator`: `p ∈ Supp M ↔ ∃ m, Ann(m) ≤ p`.
- `Module.support_eq_empty_iff`: `Supp M = ∅ ↔ M = 0`
- `Module.support_of_exact`: `Supp N = Supp M ∪ Supp P` for an exact sequence `0 → M → N → P → 0`.
- `Module.support_eq_zeroLocus`: If `M` is `R`-finite, then `Supp M = Z(Ann(M))`.
- `LocalizedModule.exists_subsingleton_away`:
If `M` is `R`-finite and `Mₚ = 0`, then `M[1/f] = 0` for some `p ∈ D(f)`.
Also see `Mathlib/RingTheory/Spectrum/Prime/Module.lean` for other results
depending on the Zariski topology.
## TODO
- Connect to associated primes once we have them in mathlib.
- Given an `R`-algebra `f : R → A` and a finite `R`-module `M`,
`Supp_A (A ⊗ M) = f♯ ⁻¹ Supp M` where `f♯ : Spec A → Spec R`. (stacks#0BUR)
-/
-- Basic files in `RingTheory` should avoid depending on the Zariski topology
-- See `Mathlib/RingTheory/Spectrum/Prime/Module.lean`
assert_not_exists TopologicalSpace
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] {p : PrimeSpectrum R}
variable (R M) in
/-- The support of a module, defined as the set of primes `p` such that `Mₚ ≠ 0`. -/
@[stacks 00L1]
def Module.support : Set (PrimeSpectrum R) :=
{ p | Nontrivial (LocalizedModule p.asIdeal.primeCompl M) }
lemma Module.mem_support_iff :
p ∈ Module.support R M ↔ Nontrivial (LocalizedModule p.asIdeal.primeCompl M) := Iff.rfl
lemma Module.notMem_support_iff :
p ∉ Module.support R M ↔ Subsingleton (LocalizedModule p.asIdeal.primeCompl M) :=
not_nontrivial_iff_subsingleton
@[deprecated (since := "2025-05-23")] alias Module.not_mem_support_iff := Module.notMem_support_iff
lemma Module.notMem_support_iff' :
p ∉ Module.support R M ↔ ∀ m : M, ∃ r ∉ p.asIdeal, r • m = 0 := by
simp only [notMem_support_iff, Ideal.primeCompl, LocalizedModule.subsingleton_iff,
Submonoid.mem_mk, Subsemigroup.mem_mk, Set.mem_compl_iff, SetLike.mem_coe]
@[deprecated (since := "2025-05-23")]
alias Module.not_mem_support_iff' := Module.notMem_support_iff'
lemma Module.mem_support_iff' :
p ∈ Module.support R M ↔ ∃ m : M, ∀ r ∉ p.asIdeal, r • m ≠ 0 := by
rw [← @not_not (_ ∈ _), notMem_support_iff']
push_neg
rfl
lemma Module.mem_support_iff_exists_annihilator :
p ∈ Module.support R M ↔ ∃ m : M, (R ∙ m).annihilator ≤ p.asIdeal := by
rw [Module.mem_support_iff']
simp_rw [not_imp_not, SetLike.le_def, Submodule.mem_annihilator_span_singleton]
lemma Module.mem_support_mono {p q : PrimeSpectrum R} (H : p ≤ q) (hp : p ∈ Module.support R M) :
q ∈ Module.support R M := by
rw [Module.mem_support_iff_exists_annihilator] at hp ⊢
exact ⟨_, hp.choose_spec.trans H⟩
lemma Module.mem_support_iff_of_span_eq_top {s : Set M} (hs : Submodule.span R s = ⊤) :
p ∈ Module.support R M ↔ ∃ m ∈ s, (R ∙ m).annihilator ≤ p.asIdeal := by
constructor
· contrapose
rw [notMem_support_iff, LocalizedModule.subsingleton_iff_ker_eq_top, ← top_le_iff,
← hs, Submodule.span_le, Set.subset_def]
simp_rw [SetLike.le_def, Submodule.mem_annihilator_span_singleton, SetLike.mem_coe,
LocalizedModule.mem_ker_mkLinearMap_iff]
push_neg
simp_rw [and_comm]
exact id
· intro ⟨m, _, hm⟩
exact mem_support_iff_exists_annihilator.mpr ⟨m, hm⟩
lemma Module.annihilator_le_of_mem_support (hp : p ∈ Module.support R M) :
Module.annihilator R M ≤ p.asIdeal := by
obtain ⟨m, hm⟩ := mem_support_iff_exists_annihilator.mp hp
exact le_trans ((Submodule.subtype _).annihilator_le_of_injective Subtype.val_injective) hm
lemma LocalizedModule.subsingleton_iff_support_subset {f : R} :
Subsingleton (LocalizedModule (.powers f) M) ↔
Module.support R M ⊆ PrimeSpectrum.zeroLocus {f} := by
rw [LocalizedModule.subsingleton_iff]
constructor
· rintro H x hx' f rfl
obtain ⟨m, hm⟩ := Module.mem_support_iff_exists_annihilator.mp hx'
obtain ⟨_, ⟨n, rfl⟩, e⟩ := H m
exact Ideal.IsPrime.mem_of_pow_mem inferInstance n
(hm ((Submodule.mem_annihilator_span_singleton _ _).mpr e))
· intro H m
by_cases h : (Submodule.span R {m}).annihilator = ⊤
· rw [Submodule.annihilator_eq_top_iff, Submodule.span_singleton_eq_bot] at h
exact ⟨1, one_mem _, by simpa using h⟩
obtain ⟨n, hn⟩ : f ∈ (Submodule.span R {m}).annihilator.radical := by
rw [Ideal.radical_eq_sInf, Ideal.mem_sInf]
rintro p ⟨hp, hp'⟩
simpa using H (Module.mem_support_iff_exists_annihilator (p := ⟨p, hp'⟩).mpr ⟨_, hp⟩)
exact ⟨_, ⟨n, rfl⟩, (Submodule.mem_annihilator_span_singleton _ _).mp hn⟩
lemma Module.support_eq_empty_iff :
Module.support R M = ∅ ↔ Subsingleton M := by
rw [← Set.subset_empty_iff, ← PrimeSpectrum.zeroLocus_singleton_one,
← LocalizedModule.subsingleton_iff_support_subset, LocalizedModule.subsingleton_iff,
subsingleton_iff_forall_eq 0]
simp only [Submonoid.powers_one, Submonoid.mem_bot, exists_eq_left, one_smul]
lemma Module.nonempty_support_iff :
(Module.support R M).Nonempty ↔ Nontrivial M := by
rw [Set.nonempty_iff_ne_empty, ne_eq,
Module.support_eq_empty_iff, ← not_subsingleton_iff_nontrivial]
lemma Module.nonempty_support_of_nontrivial [Nontrivial M] : (Module.support R M).Nonempty :=
Module.nonempty_support_iff.mpr ‹_›
lemma Module.support_eq_empty [Subsingleton M] :
Module.support R M = ∅ :=
Module.support_eq_empty_iff.mpr ‹_›
lemma Module.support_of_algebra {A : Type*} [Ring A] [Algebra R A] :
Module.support R A = PrimeSpectrum.zeroLocus (RingHom.ker (algebraMap R A)) := by
ext p
simp only [mem_support_iff', ne_eq, PrimeSpectrum.mem_zeroLocus, SetLike.coe_subset_coe]
refine ⟨fun ⟨m, hm⟩ x hx ↦ not_not.mp fun hx' ↦ ?_, fun H ↦ ⟨1, fun r hr e ↦ ?_⟩⟩
· simpa [Algebra.smul_def, (show _ = _ from hx)] using hm _ hx'
· exact hr (H ((Algebra.algebraMap_eq_smul_one _).trans e))
lemma Module.support_of_noZeroSMulDivisors [NoZeroSMulDivisors R M] [Nontrivial M] :
Module.support R M = Set.univ := by
simp only [Set.eq_univ_iff_forall, mem_support_iff', ne_eq, smul_eq_zero, not_or]
obtain ⟨x, hx⟩ := exists_ne (0 : M)
exact fun p ↦ ⟨x, fun r hr ↦ ⟨fun e ↦ hr (e ▸ p.asIdeal.zero_mem), hx⟩⟩
variable {N P : Type*} [AddCommGroup N] [Module R N] [AddCommGroup P] [Module R P]
variable (f : M →ₗ[R] N) (g : N →ₗ[R] P)
@[stacks 00L3 "(2)"]
lemma Module.support_subset_of_injective (hf : Function.Injective f) :
Module.support R M ⊆ Module.support R N := by
simp_rw [Set.subset_def, mem_support_iff']
rintro x ⟨m, hm⟩
exact ⟨f m, fun r hr ↦ by simpa using hf.ne (hm r hr)⟩
@[stacks 00L3 "(3)"]
lemma Module.support_subset_of_surjective (hf : Function.Surjective f) :
Module.support R N ⊆ Module.support R M := by
simp_rw [Set.subset_def, mem_support_iff']
rintro x ⟨m, hm⟩
obtain ⟨m, rfl⟩ := hf m
exact ⟨m, fun r hr e ↦ hm r hr (by simpa using congr(f $e))⟩
variable {f g} in
/-- Given an exact sequence `0 → M → N → P → 0` of `R`-modules, `Supp N = Supp M ∪ Supp P`. -/
@[stacks 00L3 "(4)"]
lemma Module.support_of_exact (h : Function.Exact f g)
(hf : Function.Injective f) (hg : Function.Surjective g) :
Module.support R N = Module.support R M ∪ Module.support R P := by
refine subset_antisymm ?_ (Set.union_subset (Module.support_subset_of_injective f hf)
(Module.support_subset_of_surjective g hg))
intro x
contrapose
simp only [Set.mem_union, not_or, and_imp, notMem_support_iff']
intro H₁ H₂ m
obtain ⟨r, hr, e₁⟩ := H₂ (g m)
rw [← map_smul, h] at e₁
obtain ⟨m', hm'⟩ := e₁
obtain ⟨s, hs, e₁⟩ := H₁ m'
exact ⟨_, x.asIdeal.primeCompl.mul_mem hs hr, by rw [mul_smul, ← hm', ← map_smul, e₁, map_zero]⟩
lemma LinearEquiv.support_eq (e : M ≃ₗ[R] N) :
Module.support R M = Module.support R N :=
(Module.support_subset_of_injective e.toLinearMap e.injective).antisymm
(Module.support_subset_of_surjective e.toLinearMap e.surjective)
section Finite
variable [Module.Finite R M]
open PrimeSpectrum
lemma Module.mem_support_iff_of_finite :
p ∈ Module.support R M ↔ Module.annihilator R M ≤ p.asIdeal := by
classical
obtain ⟨s, hs⟩ := ‹Module.Finite R M›
refine ⟨annihilator_le_of_mem_support, fun H ↦ (mem_support_iff_of_span_eq_top hs).mpr ?_⟩
simp only [SetLike.le_def, Submodule.mem_annihilator_span_singleton] at H ⊢
contrapose! H
choose x hx hx' using Subtype.forall'.mp H
refine ⟨s.attach.prod x, ?_, ?_⟩
· rw [← Submodule.annihilator_top, ← hs, Submodule.mem_annihilator_span]
intro m
obtain ⟨k, hk⟩ := Finset.dvd_prod_of_mem x (Finset.mem_attach _ m)
rw [hk, mul_comm, mul_smul, hx, smul_zero]
· exact p.asIdeal.primeCompl.prod_mem (fun x _ ↦ hx' x)
/-- If `M` is `R`-finite, then `Supp M = Z(Ann(M))`. -/
@[stacks 00L2]
lemma Module.support_eq_zeroLocus :
Module.support R M = zeroLocus (Module.annihilator R M) :=
Set.ext fun _ ↦ mem_support_iff_of_finite
/-- If `M` is a finite module such that `Mₚ = 0` for some `p`,
then `M[1/f] = 0` for some `p ∈ D(f)`. -/
lemma LocalizedModule.exists_subsingleton_away (p : Ideal R) [p.IsPrime]
[Subsingleton (LocalizedModule p.primeCompl M)] :
∃ f ∉ p, Subsingleton (LocalizedModule (.powers f) M) := by
have : ⟨p, inferInstance⟩ ∈ (Module.support R M)ᶜ := by
simpa [Module.notMem_support_iff]
rw [Module.support_eq_zeroLocus, ← Set.biUnion_of_singleton (Module.annihilator R M : Set R),
PrimeSpectrum.zeroLocus_iUnion₂, Set.compl_iInter₂, Set.mem_iUnion₂] at this
obtain ⟨f, hf, hf'⟩ := this
exact ⟨f, by simpa using hf', subsingleton_iff.mpr
fun m ↦ ⟨f, Submonoid.mem_powers f, Module.mem_annihilator.mp hf _⟩⟩
/-- `Supp(M/IM) = Supp(M) ∩ Z(I)`. -/
@[stacks 00L3 "(1)"]
theorem Module.support_quotient (I : Ideal R) :
support R (M ⧸ (I • ⊤ : Submodule R M)) = support R M ∩ zeroLocus I := by
apply subset_antisymm
· refine Set.subset_inter ?_ ?_
· exact Module.support_subset_of_surjective _ (Submodule.mkQ_surjective _)
· rw [support_eq_zeroLocus]
apply PrimeSpectrum.zeroLocus_anti_mono_ideal
rw [Submodule.annihilator_quotient]
exact fun x hx ↦ Submodule.mem_colon.mpr fun p ↦ Submodule.smul_mem_smul hx
· rintro p ⟨hp₁, hp₂⟩
rw [Module.mem_support_iff] at hp₁ ⊢
let Rₚ := Localization.AtPrime p.asIdeal
let Mₚ := LocalizedModule p.asIdeal.primeCompl M
set Mₚ' := LocalizedModule p.asIdeal.primeCompl (M ⧸ (I • ⊤ : Submodule R M))
let Mₚ'' := Mₚ ⧸ I.map (algebraMap R Rₚ) • (⊤ : Submodule Rₚ Mₚ)
let e : Mₚ' ≃ₗ[Rₚ] Mₚ'' := (localizedQuotientEquiv _ _).symm ≪≫ₗ
Submodule.quotEquivOfEq _ _ (by rw [Submodule.localized,
Submodule.localized'_smul, Ideal.localized'_eq_map, Submodule.localized'_top])
have : Nontrivial Mₚ'' := by
apply Submodule.Quotient.nontrivial_of_lt_top
rw [lt_top_iff_ne_top, ne_comm]
apply Submodule.top_ne_ideal_smul_of_le_jacobson_annihilator
refine trans ?_ (IsLocalRing.maximalIdeal_le_jacobson _)
rw [← Localization.AtPrime.map_eq_maximalIdeal]
exact Ideal.map_mono hp₂
exact e.nontrivial
open Pointwise in
@[simp]
theorem Module.support_quotSMulTop (x : R) :
support R (QuotSMulTop x M) = support R M ∩ zeroLocus {x} :=
(x • (⊤ : Submodule R M)).quotEquivOfEq (Ideal.span {x} • ⊤)
((⊤ : Submodule R M).ideal_span_singleton_smul x).symm |>.support_eq.trans <|
(support_quotient _).trans <| by rw [zeroLocus_span]
end Finite |
.lake/packages/mathlib/Mathlib/RingTheory/Henselian.lean | import Mathlib.Algebra.Polynomial.Taylor
import Mathlib.RingTheory.LocalRing.ResidueField.Basic
import Mathlib.RingTheory.AdicCompletion.Basic
/-!
# Henselian rings
In this file we set up the basic theory of Henselian (local) rings.
A ring `R` is *Henselian* at an ideal `I` if the following conditions hold:
* `I` is contained in the Jacobson radical of `R`
* for every polynomial `f` over `R`, with a *simple* root `a₀` over the quotient ring `R/I`,
there exists a lift `a : R` of `a₀` that is a root of `f`.
(Here, saying that a root `b` of a polynomial `g` is *simple* means that `g.derivative.eval b` is a
unit. Warning: if `R/I` is not a field then it is not enough to assume that `g` has a factorization
into monic linear factors in which `X - b` shows up only once; for example `1` is not a simple root
of `X^2-1` over `ℤ/4ℤ`.)
A local ring `R` is *Henselian* if it is Henselian at its maximal ideal.
In this case the first condition is automatic, and in the second condition we may ask for
`f.derivative.eval a ≠ 0`, since the quotient ring `R/I` is a field in this case.
## Main declarations
* `HenselianRing`: a typeclass on commutative rings,
asserting that the ring is Henselian at the ideal `I`.
* `HenselianLocalRing`: a typeclass on commutative rings, asserting that the ring is local Henselian
* `Field.henselian`: fields are Henselian local rings
* `Henselian.TFAE`: equivalent ways of expressing the Henselian property for local rings
* `IsAdicComplete.henselianRing`:
a ring `R` with ideal `I` that is `I`-adically complete is Henselian at `I`
## References
https://stacks.math.columbia.edu/tag/04GE
## TODO
After a good API for étale ring homomorphisms has been developed,
we can give more equivalent characterization of Henselian rings.
In particular, this can give a proof that factorizations into coprime polynomials can be lifted
from the residue field to the Henselian ring.
The following gist contains some code sketches in that direction.
https://gist.github.com/jcommelin/47d94e4af092641017a97f7f02bf9598
-/
noncomputable section
universe u v
open Polynomial IsLocalRing Function List
theorem isLocalHom_of_le_jacobson_bot {R : Type*} [CommRing R] (I : Ideal R)
(h : I ≤ Ideal.jacobson ⊥) : IsLocalHom (Ideal.Quotient.mk I) := by
constructor
intro a h
have : IsUnit (Ideal.Quotient.mk (Ideal.jacobson ⊥) a) := by
rw [isUnit_iff_exists_inv] at *
obtain ⟨b, hb⟩ := h
obtain ⟨b, rfl⟩ := Ideal.Quotient.mk_surjective b
use Ideal.Quotient.mk _ b
rw [← (Ideal.Quotient.mk _).map_one, ← (Ideal.Quotient.mk _).map_mul, Ideal.Quotient.eq] at hb ⊢
exact h hb
obtain ⟨⟨x, y, h1, h2⟩, rfl : x = _⟩ := this
obtain ⟨y, rfl⟩ := Ideal.Quotient.mk_surjective y
rw [← (Ideal.Quotient.mk _).map_mul, ← (Ideal.Quotient.mk _).map_one, Ideal.Quotient.eq,
Ideal.mem_jacobson_bot] at h1 h2
specialize h1 1
have h1 : IsUnit a ∧ IsUnit y := by simpa using h1
exact h1.1
/-- A ring `R` is *Henselian* at an ideal `I` if the following condition holds:
for every polynomial `f` over `R`, with a *simple* root `a₀` over the quotient ring `R/I`,
there exists a lift `a : R` of `a₀` that is a root of `f`.
(Here, saying that a root `b` of a polynomial `g` is *simple* means that `g.derivative.eval b` is a
unit. Warning: if `R/I` is not a field then it is not enough to assume that `g` has a factorization
into monic linear factors in which `X - b` shows up only once; for example `1` is not a simple root
of `X^2-1` over `ℤ/4ℤ`.) -/
class HenselianRing (R : Type*) [CommRing R] (I : Ideal R) : Prop where
jac : I ≤ Ideal.jacobson ⊥
is_henselian :
∀ (f : R[X]) (_ : f.Monic) (a₀ : R) (_ : f.eval a₀ ∈ I)
(_ : IsUnit (Ideal.Quotient.mk I (f.derivative.eval a₀))), ∃ a : R, f.IsRoot a ∧ a - a₀ ∈ I
/-- A local ring `R` is *Henselian* if the following condition holds:
for every polynomial `f` over `R`, with a *simple* root `a₀` over the residue field,
there exists a lift `a : R` of `a₀` that is a root of `f`.
(Recall that a root `b` of a polynomial `g` is *simple* if it is not a double root, so if
`g.derivative.eval b ≠ 0`.)
In other words, `R` is local Henselian if it is Henselian at the ideal `I`,
in the sense of `HenselianRing`. -/
class HenselianLocalRing (R : Type*) [CommRing R] : Prop extends IsLocalRing R where
is_henselian :
∀ (f : R[X]) (_ : f.Monic) (a₀ : R) (_ : f.eval a₀ ∈ maximalIdeal R)
(_ : IsUnit (f.derivative.eval a₀)), ∃ a : R, f.IsRoot a ∧ a - a₀ ∈ maximalIdeal R
-- see Note [lower instance priority]
instance (priority := 100) Field.henselian (K : Type*) [Field K] : HenselianLocalRing K where
is_henselian f _ a₀ h₁ _ := by
simp only [(maximalIdeal K).eq_bot_of_prime, Ideal.mem_bot] at h₁ ⊢
exact ⟨a₀, h₁, sub_self _⟩
theorem HenselianLocalRing.TFAE (R : Type u) [CommRing R] [IsLocalRing R] :
TFAE
[HenselianLocalRing R,
∀ f : R[X], f.Monic → ∀ a₀ : ResidueField R, aeval a₀ f = 0 →
aeval a₀ (derivative f) ≠ 0 → ∃ a : R, f.IsRoot a ∧ residue R a = a₀,
∀ {K : Type u} [Field K],
∀ (φ : R →+* K), Surjective φ → ∀ f : R[X], f.Monic → ∀ a₀ : K,
f.eval₂ φ a₀ = 0 → f.derivative.eval₂ φ a₀ ≠ 0 → ∃ a : R, f.IsRoot a ∧ φ a = a₀] := by
tfae_have 3 → 2
| H => H (residue R) Ideal.Quotient.mk_surjective
tfae_have 2 → 1
| H => by
constructor
intro f hf a₀ h₁ h₂
specialize H f hf (residue R a₀)
have aux := flip mem_nonunits_iff.mp h₂
simp only [aeval_def, ResidueField.algebraMap_eq, eval₂_at_apply, ←
Ideal.Quotient.eq_zero_iff_mem, ← IsLocalRing.mem_maximalIdeal] at H h₁ aux
obtain ⟨a, ha₁, ha₂⟩ := H h₁ aux
refine ⟨a, ha₁, ?_⟩
rw [← Ideal.Quotient.eq_zero_iff_mem]
rwa [← sub_eq_zero, ← RingHom.map_sub] at ha₂
tfae_have 1 → 3
| hR, K, _K, φ, hφ, f, hf, a₀, h₁, h₂ => by
obtain ⟨a₀, rfl⟩ := hφ a₀
have H := HenselianLocalRing.is_henselian f hf a₀
simp only [← ker_eq_maximalIdeal φ hφ, eval₂_at_apply, RingHom.mem_ker] at H h₁ h₂
obtain ⟨a, ha₁, ha₂⟩ := H h₁ (by
contrapose! h₂
rwa [← mem_nonunits_iff, ← mem_maximalIdeal, ← ker_eq_maximalIdeal φ hφ,
RingHom.mem_ker] at h₂)
refine ⟨a, ha₁, ?_⟩
rwa [φ.map_sub, sub_eq_zero] at ha₂
tfae_finish
instance (R : Type*) [CommRing R] [hR : HenselianLocalRing R] :
HenselianRing R (maximalIdeal R) where
jac := by
rw [Ideal.jacobson, le_sInf_iff]
rintro I ⟨-, hI⟩
exact (eq_maximalIdeal hI).ge
is_henselian := by
intro f hf a₀ h₁ h₂
refine HenselianLocalRing.is_henselian f hf a₀ h₁ ?_
contrapose! h₂
rw [← mem_nonunits_iff, ← IsLocalRing.mem_maximalIdeal, ← Ideal.Quotient.eq_zero_iff_mem] at h₂
rw [h₂]
exact not_isUnit_zero
-- see Note [lower instance priority]
/-- A ring `R` that is `I`-adically complete is Henselian at `I`. -/
instance (priority := 100) IsAdicComplete.henselianRing (R : Type*) [CommRing R] (I : Ideal R)
[IsAdicComplete I R] : HenselianRing R I where
jac := IsAdicComplete.le_jacobson_bot _
is_henselian := by
intro f _ a₀ h₁ h₂
classical
let f' := derivative f
-- we define a sequence `c n` by starting at `a₀` and then continually
-- applying the function sending `b` to `b - f(b)/f'(b)` (Newton's method).
-- Note that `f'.eval b` is a unit, because `b` has the same residue as `a₀` modulo `I`.
let c : ℕ → R := fun n => Nat.recOn n a₀ fun _ b => b - f.eval b * Ring.inverse (f'.eval b)
have hc : ∀ n, c (n + 1) = c n - f.eval (c n) * Ring.inverse (f'.eval (c n)) := by
intro n
simp only [c]
-- we now spend some time determining properties of the sequence `c : ℕ → R`
-- `hc_mod`: for every `n`, we have `c n ≡ a₀ [SMOD I]`
-- `hf'c` : for every `n`, `f'.eval (c n)` is a unit
-- `hfcI` : for every `n`, `f.eval (c n)` is contained in `I ^ (n+1)`
have hc_mod : ∀ n, c n ≡ a₀ [SMOD I] := by
intro n
induction n with
| zero => rfl
| succ n ih => ?_
rw [hc, sub_eq_add_neg, ← add_zero a₀]
refine ih.add ?_
rw [SModEq.zero, Ideal.neg_mem_iff]
refine I.mul_mem_right _ ?_
rw [← SModEq.zero] at h₁ ⊢
exact (ih.eval f).trans h₁
have hf'c : ∀ n, IsUnit (f'.eval (c n)) := by
intro n
haveI := isLocalHom_of_le_jacobson_bot I (IsAdicComplete.le_jacobson_bot I)
apply IsUnit.of_map (Ideal.Quotient.mk I)
convert h₂ using 1
exact SModEq.def.mp ((hc_mod n).eval _)
have hfcI : ∀ n, f.eval (c n) ∈ I ^ (n + 1) := by
intro n
induction n with
| zero => simpa only [Nat.rec_zero, zero_add, pow_one] using h₁
| succ n ih => ?_
rw [← taylor_eval_sub (c n), hc, sub_eq_add_neg, sub_eq_add_neg,
add_neg_cancel_comm]
rw [eval_eq_sum, sum_over_range' _ _ _ (lt_add_of_pos_right _ zero_lt_two), ←
Finset.sum_range_add_sum_Ico _ (Nat.le_add_left _ _)]
swap
· intro i
rw [zero_mul]
refine Ideal.add_mem _ ?_ ?_
· rw [← one_add_one_eq_two, Finset.sum_range_succ, Finset.range_one, Finset.sum_singleton,
taylor_coeff_zero, taylor_coeff_one, pow_zero, pow_one, mul_one, mul_neg,
mul_left_comm, Ring.mul_inverse_cancel _ (hf'c n), mul_one, add_neg_cancel]
exact Ideal.zero_mem _
· refine Submodule.sum_mem _ ?_
simp only [Finset.mem_Ico]
rintro i ⟨h2i, _⟩
have aux : n + 2 ≤ i * (n + 1) := by trans 2 * (n + 1) <;> nlinarith only [h2i]
refine Ideal.mul_mem_left _ _ (Ideal.pow_le_pow_right aux ?_)
rw [pow_mul']
exact Ideal.pow_mem_pow ((Ideal.neg_mem_iff _).2 <| Ideal.mul_mem_right _ _ ih) _
-- we are now in the position to show that `c : ℕ → R` is a Cauchy sequence
have aux : ∀ m n, m ≤ n → c m ≡ c n [SMOD (I ^ m • ⊤ : Ideal R)] := by
intro m n hmn
rw [← Ideal.one_eq_top, Ideal.smul_eq_mul, mul_one]
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmn
clear hmn
induction k with
| zero => rw [add_zero]
| succ k ih => ?_
rw [← add_assoc, hc, ← add_zero (c m), sub_eq_add_neg]
refine ih.add ?_
symm
rw [SModEq.zero, Ideal.neg_mem_iff]
refine Ideal.mul_mem_right _ _ (Ideal.pow_le_pow_right ?_ (hfcI _))
rw [add_assoc]
exact le_self_add
-- hence the sequence converges to some limit point `a`, which is the `a` we are looking for
obtain ⟨a, ha⟩ := IsPrecomplete.prec' c (aux _ _)
refine ⟨a, ?_, ?_⟩
· show f.IsRoot a
suffices ∀ n, f.eval a ≡ 0 [SMOD (I ^ n • ⊤ : Ideal R)] by exact IsHausdorff.haus' _ this
intro n
specialize ha n
rw [← Ideal.one_eq_top, Ideal.smul_eq_mul, mul_one] at ha ⊢
refine (ha.symm.eval f).trans ?_
rw [SModEq.zero]
exact Ideal.pow_le_pow_right le_self_add (hfcI _)
· show a - a₀ ∈ I
specialize ha (0 + 1)
rw [hc, pow_one, ← Ideal.one_eq_top, Ideal.smul_eq_mul, mul_one, sub_eq_add_neg] at ha
rw [← SModEq.sub_mem, ← add_zero a₀]
refine ha.symm.trans (SModEq.rfl.add ?_)
rw [SModEq.zero, Ideal.neg_mem_iff]
exact Ideal.mul_mem_right _ _ h₁ |
.lake/packages/mathlib/Mathlib/RingTheory/NoetherNormalization.lean | import Mathlib.Algebra.MvPolynomial.Monad
import Mathlib.Data.List.Indexes
import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Basic
/-!
# Noether normalization lemma
This file contains a proof by Nagata of the Noether normalization lemma.
## Main Results
Let `A` be a finitely generated algebra over a field `k`.
Then there exists a natural number `s` and an injective homomorphism
from `k[X_0, X_1, ..., X_(s-1)]` to `A` such that `A` is integral over `k[X_0, X_1, ..., X_(s-1)]`.
## Strategy of the proof
Suppose `f` is a nonzero polynomial in `n+1` variables.
First, we construct an algebra equivalence `T` from `k[X_0,...,X_n]` to itself such that
`f` is mapped to a polynomial in `X_0` with invertible leading coefficient.
More precisely, `T` maps `X_i` to `X_i + X_0 ^ r_i` when `i ≠ 0`, and `X_0` to `X_0`.
Here we choose `r_i` to be `up ^ i` where `up` is big enough, so that `T` maps
different monomials of `f` to polynomials with different degrees in `X_0`.
See `degreeOf_t_neq_of_neq`.
Secondly, we construct the following maps: let `I` be an ideal containing `f` and
let `φ : k[X_0,...X_{n-1}] ≃ₐ[k] k[X_1,...X_n][X]` be the natural isomorphism.
- `hom1 : k[X_0,...X_{n-1}] →ₐ[k[X_0,...X_{n-1}]] k[X_1,...X_n][X]/φ(T(I))`
- `eqv1 : k[X_1,...X_n][X]/φ(T(I)) ≃ₐ[k] k[X_0,...,X_n]/T(I)`
- `eqv2 : k[X_0,...,X_n]/T(I) ≃ₐ[k] k[X_0,...,X_n]/I`
- `hom2 : k[X_0,...X_(n-1)] →ₐ[k] k[X_0,...X_n]/I`
`hom1` is integral because `φ(T(I))` contains a monic polynomial. See `hom1_isIntegral`.
`hom2` is integral because it's the composition of integral maps. See `hom2_isIntegral`.
Finally We use induction to prove there is an injective map from `k[X_0,...,X_{s-1}]`
to `k[X_0,...,X_(n-1)]/I`.The case `n=0` is trivial.
For `n+1`, if `I = 0` there is nothing to do.
Otherwise, `hom2` induces a map `φ` by quotient kernel.
We use the inductive hypothesis on k[X_1,...,X_n] and the kernel of `hom2` to get `s, g`.
Composing `φ` and `g` we get the desired map since both `φ` and `g` are injective and integral.
## Reference
* <https://stacks.math.columbia.edu/tag/00OW>
## TODO
* In the final theorems, consider setting `s` equal to the Krull dimension of `R`.
-/
open Polynomial MvPolynomial Ideal BigOperators Nat RingHom List
variable {k : Type*} [Field k] {n : ℕ} (f : MvPolynomial (Fin (n + 1)) k)
variable (v w : Fin (n + 1) →₀ ℕ)
namespace NoetherNormalization
section equivT
/-- `up` is defined as `2 + f.totalDegree`. Any big enough number would work. -/
local notation3 "up" => 2 + f.totalDegree
variable {f v} in
private lemma lt_up (vlt : ∀ i, v i < up) : ∀ l ∈ ofFn v, l < up := by
grind
/-- `r` maps `(i : Fin (n + 1))` to `up ^ i`. -/
local notation3 "r" => fun (i : Fin (n + 1)) ↦ up ^ i.1
/-- We construct an algebra map `T1 f c` which maps `X_i` into `X_i + c • X_0 ^ r_i` when `i ≠ 0`
and `X_0` to `X_0`. -/
noncomputable abbrev T1 (c : k) :
MvPolynomial (Fin (n + 1)) k →ₐ[k] MvPolynomial (Fin (n + 1)) k :=
aeval fun i ↦ if i = 0 then X 0 else X i + c • X 0 ^ r i
private lemma t1_comp_t1_neg (c : k) : (T1 f c).comp (T1 f (-c)) = AlgHom.id _ _ := by
rw [comp_aeval, ← MvPolynomial.aeval_X_left]
ext i v
cases i using Fin.cases <;> simp
/- `T1 f 1` leads to an algebra equiv `T f`. -/
private noncomputable abbrev T := AlgEquiv.ofAlgHom (T1 f 1) (T1 f (-1))
(t1_comp_t1_neg f 1) (by simpa using t1_comp_t1_neg f (-1))
private lemma sum_r_mul_neq (vlt : ∀ i, v i < up) (wlt : ∀ i, w i < up) (neq : v ≠ w) :
∑ x : Fin (n + 1), r x * v x ≠ ∑ x : Fin (n + 1), r x * w x := by
intro h
refine neq <| Finsupp.ext <| congrFun <| ofFn_inj.mp ?_
apply ofDigits_inj_of_len_eq (Nat.lt_add_right f.totalDegree one_lt_two)
(by simp) (lt_up vlt) (lt_up wlt)
simpa only [ofDigits_eq_sum_mapIdx, mapIdx_eq_ofFn, get_ofFn, length_ofFn,
Fin.coe_cast, mul_comm, sum_ofFn] using h
private lemma degreeOf_zero_t {a : k} (ha : a ≠ 0) : ((T f) (monomial v a)).degreeOf 0 =
∑ i : Fin (n + 1), (r i) * v i := by
rw [← natDegree_finSuccEquiv, monomial_eq, Finsupp.prod_pow v fun a ↦ X a]
simp only [Fin.prod_univ_succ, Fin.sum_univ_succ, map_mul, map_prod, map_pow,
AlgEquiv.ofAlgHom_apply, MvPolynomial.aeval_C, MvPolynomial.aeval_X, if_pos, Fin.succ_ne_zero,
ite_false, one_smul, map_add, finSuccEquiv_X_zero, finSuccEquiv_X_succ, algebraMap_eq]
have h (i : Fin n) :
(Polynomial.C (X (R := k) i) + Polynomial.X ^ r i.succ) ^ v i.succ ≠ 0 :=
pow_ne_zero (v i.succ) (leadingCoeff_ne_zero.mp <| by simp [add_comm, leadingCoeff_X_pow_add_C])
rw [natDegree_mul (by simp [ha]) (mul_ne_zero (by simp) (Finset.prod_ne_zero_iff.mpr
(fun i _ ↦ h i))), natDegree_mul (by simp) (Finset.prod_ne_zero_iff.mpr (fun i _ ↦ h i)),
natDegree_prod _ _ (fun i _ ↦ h i), natDegree_finSuccEquiv, degreeOf_C]
simpa only [natDegree_pow, zero_add, natDegree_X, mul_one, Fin.val_zero, pow_zero, one_mul,
add_right_inj] using Finset.sum_congr rfl (fun i _ ↦ by
rw [add_comm (Polynomial.C _), natDegree_X_pow_add_C, mul_comm])
/- `T` maps different monomials of `f` to polynomials with different degrees in `X_0`. -/
private lemma degreeOf_t_neq_of_neq (hv : v ∈ f.support) (hw : w ∈ f.support) (neq : v ≠ w) :
(T f <| monomial v <| coeff v f).degreeOf 0 ≠
(T f <| monomial w <| coeff w f).degreeOf 0 := by
rw [degreeOf_zero_t _ _ <| mem_support_iff.mp hv, degreeOf_zero_t _ _ <| mem_support_iff.mp hw]
refine sum_r_mul_neq f v w (fun i ↦ ?_) (fun i ↦ ?_) neq <;>
exact lt_of_le_of_lt ((monomial_le_degreeOf i ‹_›).trans (degreeOf_le_totalDegree f i))
(by cutsat)
private lemma leadingCoeff_finSuccEquiv_t :
(finSuccEquiv k n ((T f) ((monomial v) (coeff v f)))).leadingCoeff =
algebraMap k _ (coeff v f) := by
rw [monomial_eq, Finsupp.prod_fintype]
· simp only [map_mul, map_prod, leadingCoeff_mul, leadingCoeff_prod]
rw [AlgEquiv.ofAlgHom_apply, algHom_C, algebraMap_eq, finSuccEquiv_apply,
eval₂Hom_C, coe_comp]
simp only [AlgEquiv.ofAlgHom_apply, Function.comp_apply, leadingCoeff_C, map_pow,
leadingCoeff_pow, algebraMap_eq]
have : ∀ j, ((finSuccEquiv k n) ((T1 f) 1 (X j))).leadingCoeff = 1 := fun j ↦ by
by_cases h : j = 0
· simp [h, finSuccEquiv_apply]
· simp only [aeval_eq_bind₁, bind₁_X_right, if_neg h, one_smul, map_add, map_pow]
obtain ⟨i, rfl⟩ := Fin.exists_succ_eq.mpr h
simp [finSuccEquiv_X_succ, finSuccEquiv_X_zero, add_comm]
simp only [this, one_pow, Finset.prod_const_one, mul_one]
exact fun i ↦ pow_zero _
/- `T` maps `f` into some polynomial in `X_0` such that the leading coefficient is invertible. -/
private lemma T_leadingcoeff_isUnit (fne : f ≠ 0) :
IsUnit (finSuccEquiv k n (T f f)).leadingCoeff := by
obtain ⟨v, vin, vs⟩ := Finset.exists_max_image f.support
(fun v ↦ (T f ((monomial v) (coeff v f))).degreeOf 0) (support_nonempty.mpr fne)
set h := fun w ↦ (MvPolynomial.monomial w) (coeff w f)
simp only [← natDegree_finSuccEquiv] at vs
replace vs : ∀ x ∈ f.support \ {v}, (finSuccEquiv k n ((T f) (h x))).degree <
(finSuccEquiv k n ((T f) (h v))).degree := by
intro x hx
obtain ⟨h1, h2⟩ := Finset.mem_sdiff.mp hx
apply degree_lt_degree <| lt_of_le_of_ne (vs x h1) ?_
simpa only [natDegree_finSuccEquiv]
using degreeOf_t_neq_of_neq f _ _ h1 vin <| ne_of_not_mem_cons h2
have coeff : (finSuccEquiv k n ((T f) (h v + ∑ x ∈ f.support \ {v}, h x))).leadingCoeff =
(finSuccEquiv k n ((T f) (h v))).leadingCoeff := by
simp only [map_add, map_sum]
rw [add_comm]
apply leadingCoeff_add_of_degree_lt <| (lt_of_le_of_lt <| degree_sum_le _ _) ?_
have h2 : h v ≠ 0 := by simpa [h] using mem_support_iff.mp vin
replace h2 : (finSuccEquiv k n ((T f) (h v))) ≠ 0 := fun eq ↦ h2 <|
by simpa only [map_eq_zero_iff _ (AlgEquiv.injective _)] using eq
exact (Finset.sup_lt_iff <| Ne.bot_lt (fun x ↦ h2 <| degree_eq_bot.mp x)).mpr vs
nth_rw 2 [← f.support_sum_monomial_coeff]
rw [Finset.sum_eq_add_sum_diff_singleton vin h]
rw [leadingCoeff_finSuccEquiv_t] at coeff
simpa only [coeff, algebraMap_eq] using (mem_support_iff.mp vin).isUnit.map MvPolynomial.C
end equivT
section intmaps
variable (I : Ideal (MvPolynomial (Fin (n + 1)) k))
/- `hom1` is a homomorphism from `k[X_0,...X_{n-1}]` to `k[X_1,...X_n][X]/φ(T(I))`,
where `φ` is the isomorphism from `k[X_0,...X_{n-1}]` to `k[X_1,...X_n][X]`. -/
private noncomputable abbrev hom1 : MvPolynomial (Fin n) k →ₐ[MvPolynomial (Fin n) k]
(MvPolynomial (Fin n) k)[X] ⧸ (I.map <| T f).map (finSuccEquiv k n) :=
(Quotient.mkₐ (MvPolynomial (Fin n) k) (map (finSuccEquiv k n) (map (T f) I))).comp
(Algebra.ofId (MvPolynomial (Fin n) k) ((MvPolynomial (Fin n) k)[X]))
/- `hom1 f I` is integral. -/
private lemma hom1_isIntegral (fne : f ≠ 0) (fi : f ∈ I) : (hom1 f I).IsIntegral := by
obtain u := T_leadingcoeff_isUnit f fne
exact (monic_of_isUnit_leadingCoeff_inv_smul u).quotient_isIntegral <|
Submodule.smul_of_tower_mem _ u.unit⁻¹.val <| mem_map_of_mem _ <| mem_map_of_mem _ fi
/- `eqv1` is the isomorphism from `k[X_1,...X_n][X]/φ(T(I))`
to `k[X_0,...,X_n]/T(I)`, induced by `φ`. -/
private noncomputable abbrev eqv1 :
((MvPolynomial (Fin n) k)[X] ⧸ (I.map (T f)).map (finSuccEquiv k n)) ≃ₐ[k]
MvPolynomial (Fin (n + 1)) k ⧸ I.map (T f) := quotientEquivAlg
((I.map (T f)).map (finSuccEquiv k n)) (I.map (T f)) (finSuccEquiv k n).symm <| by
set g := (finSuccEquiv k n)
have : g.symm.toRingEquiv.toRingHom.comp g = RingHom.id _ :=
g.toRingEquiv.symm_toRingHom_comp_toRingHom
calc
_ = Ideal.map ((RingHom.id _).comp <| T f) I := by rw [id_comp, Ideal.map_coe]
_ = (I.map (T f)).map (RingHom.id _) := by simp only [← Ideal.map_map, Ideal.map_coe]
_ = (I.map (T f)).map (g.symm.toAlgHom.toRingHom.comp g) :=
congrFun (congrArg Ideal.map this.symm) (I.map (T f))
_ = _ := by simp [← Ideal.map_map, Ideal.map_coe]
/- `eqv2` is the isomorphism from `k[X_0,...,X_n]/T(I)` into `k[X_0,...,X_n]/I`,
induced by `T`. -/
private noncomputable abbrev eqv2 :
(MvPolynomial (Fin (n + 1)) k ⧸ I.map (T f)) ≃ₐ[k] MvPolynomial (Fin (n + 1)) k ⧸ I :=
quotientEquivAlg (R₁ := k) (I.map (T f)) I (T f).symm <| by
calc
_ = I.map ((T f).symm.toRingEquiv.toRingHom.comp (T f)) := by
have : (T f).symm.toRingEquiv.toRingHom.comp (T f) = RingHom.id _ :=
RingEquiv.symm_toRingHom_comp_toRingHom _
rw [this, Ideal.map_id]
_ = _ := by
rw [← Ideal.map_map, Ideal.map_coe, Ideal.map_coe]
exact congrArg _ rfl
/- `hom2` is the composition of maps above, from `k[X_0,...X_(n-1)]` to `k[X_0,...X_n]/I`. -/
private noncomputable def hom2 : MvPolynomial (Fin n) k →ₐ[k] MvPolynomial (Fin (n + 1)) k ⧸ I :=
(eqv2 f I).toAlgHom.comp ((eqv1 f I).toAlgHom.comp ((hom1 f I).restrictScalars k))
/- `hom2 f I` is integral. -/
private lemma hom2_isIntegral (fne : f ≠ 0) (fi : f ∈ I) : (hom2 f I).IsIntegral :=
((hom1_isIntegral f I fne fi).trans _ _ <| isIntegral_of_surjective _ (eqv1 f I).surjective).trans
_ _ <| isIntegral_of_surjective _ (eqv2 f I).surjective
end intmaps
end NoetherNormalization
section mainthm
open NoetherNormalization
/-- There exists some `s ≤ n` and an integral injective algebra homomorphism
from `k[X_0,...,X_(s-1)]` to `k[X_0,...,X_(n-1)]/I` if `I ≠ ⊤`. -/
theorem exists_integral_inj_algHom_of_quotient (I : Ideal (MvPolynomial (Fin n) k))
(hi : I ≠ ⊤) : ∃ s ≤ n, ∃ g : (MvPolynomial (Fin s) k) →ₐ[k] ((MvPolynomial (Fin n) k) ⧸ I),
Function.Injective g ∧ g.IsIntegral := by
induction n with
| zero =>
refine ⟨0, le_rfl, Quotient.mkₐ k I, fun a b hab ↦ ?_,
isIntegral_of_surjective _ (Quotient.mkₐ_surjective k I)⟩
rw [Quotient.mkₐ_eq_mk, Ideal.Quotient.eq] at hab
by_contra neq
have eq := eq_C_of_isEmpty (a - b)
have ne : coeff 0 (a - b) ≠ 0 := fun h ↦ h ▸ eq ▸ sub_ne_zero_of_ne neq <| map_zero _
obtain ⟨c, _, eqr⟩ := isUnit_iff_exists.mp ne.isUnit
have one : c • (a - b) = 1 := by
rw [MvPolynomial.smul_eq_C_mul, eq, ← RingHom.map_mul, eqr, MvPolynomial.C_1]
exact hi ((eq_top_iff_one I).mpr (one ▸ I.smul_of_tower_mem c hab))
| succ d hd =>
by_cases eqi : I = 0
· have bij : Function.Bijective (Quotient.mkₐ k I) :=
(Quotient.mk_bijective_iff_eq_bot I).mpr eqi
exact ⟨d + 1, le_rfl, _, bij.1, isIntegral_of_surjective _ bij.2⟩
· obtain ⟨f, fi, fne⟩ := Submodule.exists_mem_ne_zero_of_ne_bot eqi
set ϕ := kerLiftAlg <| hom2 f I
have := Quotient.nontrivial hi
obtain ⟨s, _, g, injg, intg⟩ := hd (ker <| hom2 f I) (ker_ne_top <| hom2 f I)
have comp : (kerLiftAlg (hom2 f I)).comp (Quotient.mkₐ k <| ker <| hom2 f I) = (hom2 f I) :=
AlgHom.ext fun a ↦ by
simp only [AlgHom.coe_comp, Quotient.mkₐ_eq_mk, Function.comp_apply, kerLiftAlg_mk]
exact ⟨s, by cutsat, ϕ.comp g, (ϕ.coe_comp g) ▸ (kerLiftAlg_injective _).comp injg,
intg.trans _ _ <| (comp ▸ hom2_isIntegral f I fne fi).tower_top _ _⟩
variable (k R : Type*) [Field k] [CommRing R] [Nontrivial R] [a : Algebra k R]
[fin : Algebra.FiniteType k R]
/-- **Noether normalization lemma**
For a finitely generated algebra `A` over a field `k`,
there exists a natural number `s` and an injective homomorphism
from `k[X_0, X_1, ..., X_(s-1)]` to `A` such that `A` is integral over `k[X_0, X_1, ..., X_(s-1)]`.
-/
@[stacks 00OW]
theorem exists_integral_inj_algHom_of_fg : ∃ s, ∃ g : (MvPolynomial (Fin s) k) →ₐ[k] R,
Function.Injective g ∧ g.IsIntegral := by
obtain ⟨n, f, fsurj⟩ := Algebra.FiniteType.iff_quotient_mvPolynomial''.mp fin
set ϕ := quotientKerAlgEquivOfSurjective fsurj
obtain ⟨s, _, g, injg, intg⟩ := exists_integral_inj_algHom_of_quotient (ker f) (ker_ne_top _)
use s, ϕ.toAlgHom.comp g
simp only [AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, AlgHom.coe_coe,
EmbeddingLike.comp_injective, AlgHom.toRingHom_eq_coe]
exact ⟨injg, intg.trans _ _ (isIntegral_of_surjective _ ϕ.surjective)⟩
/-- For a finitely generated algebra `A` over a field `k`,
there exists a natural number `s` and an injective homomorphism
from `k[X_0, X_1, ..., X_(s-1)]` to `A` such that `A` is finite over `k[X_0, X_1, ..., X_(s-1)]`. -/
theorem exists_finite_inj_algHom_of_fg : ∃ s, ∃ g : (MvPolynomial (Fin s) k) →ₐ[k] R,
Function.Injective g ∧ g.Finite := by
obtain ⟨s, g, ⟨inj, int⟩⟩ := exists_integral_inj_algHom_of_fg k R
have h : algebraMap k R = g.toRingHom.comp (algebraMap k (MvPolynomial (Fin s) k)) := by
algebraize [g.toRingHom]
rw [IsScalarTower.algebraMap_eq k (MvPolynomial (Fin s) k), algebraMap_toAlgebra']
exact ⟨s, g, inj, int.to_finite
(h ▸ RingHom.finiteType_algebraMap.mpr fin).of_comp_finiteType⟩
end mainthm |
.lake/packages/mathlib/Mathlib/RingTheory/OrderOfVanishing.lean | import Mathlib.RingTheory.KrullDimension.NonZeroDivisors
import Mathlib.RingTheory.Length
import Mathlib.RingTheory.HopkinsLevitzki
/-!
# Order of vanishing
This file defines the order of vanishing of an element of a ring as the length of the quotient of
the ring by the ideal generated by that element. We also define the extension of this notion to the
field of fractions
-/
open LinearMap Pointwise IsLocalization Ideal WithZero
variable {R : Type*} {M : Type*} [AddCommMonoid M]
namespace Ring
variable (R) [Ring R]
/--
Order of vanishing function for elements of a ring.
-/
@[stacks 02MD]
noncomputable
def ord (x : R) : ℕ∞ := Module.length R (R ⧸ Ideal.span {x})
/--
The order of vanishing of `1` is `0`.
-/
@[simp]
lemma ord_one : ord R 1 = 0 := by
simp_all [ord,
Ideal.span_singleton_one, Submodule.Quotient.subsingleton_iff]
end Ring
variable [CommRing R] [Module R M]
/--
The map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a`
-/
def Ideal.mulQuot (a : R) (I : Ideal R) :
R ⧸ I →ₗ[R] R ⧸ (a • I) :=
Submodule.mapQ _ _ (LinearMap.mul R R a) (Submodule.le_comap_map _ _)
/--
The map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a` is injective if `a` is
a nonzero divisor.
-/
lemma Ideal.mulQuot_injective {a : R} (I : Ideal R) (ha : a ∈ nonZeroDivisors R) :
Function.Injective (Ideal.mulQuot a I) := by
simp only [mulQuot, Submodule.mapQ, ← ker_eq_bot]
apply Submodule.ker_liftQ_eq_bot'
apply le_antisymm
· have : Submodule.map (mul R R a) I = a • I := rfl
rw [le_ker_iff_map, Submodule.map_comp, this, Submodule.mkQ_map_self]
· have m : I = Submodule.comap (mul R R a) (a • I) := by
ext b
exact (Submodule.mul_mem_smul_iff ha).symm
simp [← m, ker_comp]
/--
The quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})`.
-/
def Ideal.quotOfMul (a : R) (I : Ideal R) :
(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a}) :=
Submodule.factor <| Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I
/--
The quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})` is surjective.
-/
lemma Ideal.quotOfMul_surjective {a : R} (I : Ideal R) :
Function.Surjective (Ideal.quotOfMul a I) := by
simp only [Ideal.quotOfMul]
exact Submodule.factor_surjective <|
Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I
/--
The sequence `R ⧸ I →ₗ[R] R ⧸ (a • I) →ₗ[R] R ⧸ (Ideal.span {a})` given by multiplication
by `a` then quotienting by the ideal generated by `a` is exact.
-/
lemma Ideal.exact_mulQuot_quotOfMul {a : R} (I : Ideal R) :
Function.Exact (Ideal.mulQuot a I) (Ideal.quotOfMul a I) := by
simp only [exact_iff]
have : ker (Ideal.quotOfMul a I) = a • ⊤ := by
simp only [← submodule_span_eq, quotOfMul, Submodule.factor, Submodule.mapQ, comp_id,
Submodule.ker_liftQ, Submodule.ker_mkQ, Submodule.map_span, Submodule.mkQ_apply,
Quotient.mk_eq_mk, Set.image_singleton, Quotient.smul_top]
simp [this, Ideal.mulQuot, Submodule.mapQ.eq_1, Submodule.range_liftQ,
range_comp, Ideal.Quotient.smul_top, ← Ideal.submodule_span_eq, LinearMap.map_span]
namespace Ring
variable (R)
/--
The order of vanishing of `a * b` is the order of vanishing of `a` plus the order
of vanishing of `b`.
-/
theorem ord_mul {a b : R} (hb : b ∈ nonZeroDivisors R) :
Ring.ord R (a * b) = Ring.ord R a + Ring.ord R b := by
have := Module.length_eq_add_of_exact (Ideal.mulQuot b (Ideal.span {a}))
(Ideal.quotOfMul b (Ideal.span {a})) (Ideal.mulQuot_injective (Ideal.span {a}) hb)
(Ideal.quotOfMul_surjective (Ideal.span {a}))
(Ideal.exact_mulQuot_quotOfMul (Ideal.span {a}))
simp only [Ring.ord, ← this]
have lem : (({b} : Set R) • Ideal.span {a}) = Ideal.span {b * a} := by
simp [← Ideal.submodule_span_eq, Submodule.set_smul_span]
have : (({b} : Set R) • Ideal.span {a}) = b • Ideal.span {a} := Submodule.singleton_set_smul
(Ideal.span {a}) b
rw [this] at lem
rw [lem, mul_comm]
open Classical in
/--
Zero-preserving monoid homomorphism from a nontrivial commutative ring `R` to `ℕᵐ⁰`.
Note that we cannot just use `fun x ↦ ord R x` without further assumptions on `R`.
This is because if R is finite length, then ord R 0 will be some non-top value,
meaning in this case `0` will not be mapped to `⊤`.
-/
@[stacks 02MD]
noncomputable
def ordMonoidWithZeroHom [Nontrivial R] : R →*₀ ℤᵐ⁰ where
toFun x := if x ∈ nonZeroDivisors R
then WithZero.map' (Nat.castAddMonoidHom ℤ).toMultiplicative (Ring.ord R x)
else 0
map_zero' := by
simp [nonZeroDivisors, exists_ne]
map_one' := by
simp [nonZeroDivisors, Ring.ord_one]
rfl
map_mul' := by
intro x y
split_ifs with _ _ b
· rw [← MonoidWithZeroHom.map_mul]
congr
exact ord_mul R b
all_goals simp_all [mul_mem_nonZeroDivisors]
/--
The quotient of a Noetherian ring of krull dimension less than or equal to `1` by a principal ideal
is of finite length.
-/
theorem _root_.isFiniteLength_quotient_span_singleton [IsNoetherianRing R]
[Ring.KrullDimLE 1 R] {x : R} (hx : x ∈ nonZeroDivisors R) :
IsFiniteLength R (R ⧸ Ideal.span {x}) := by
rw [isFiniteLength_iff_isNoetherian_isArtinian]
suffices IsArtinianRing (R ⧸ Ideal.span {x}) from
⟨isNoetherian_quotient (Ideal.span {x}),
isArtinian_of_surjective_algebraMap (Ideal.Quotient.mk_surjective (I := .span {x}))⟩
rw [isArtinianRing_iff_krullDimLE_zero, Ring.KrullDimLE, Order.krullDimLE_iff,
← WithBot.add_le_add_iff_right' (c := 1) (by simp) (WithBot.coe_eq_coe.not.mpr (by simp)),
Nat.cast_zero, zero_add]
exact (ringKrullDim_quotient_succ_le_of_nonZeroDivisor hx).trans (Order.KrullDimLE.krullDim_le)
variable [Nontrivial R] [IsNoetherianRing R] [Ring.KrullDimLE 1 R]
variable {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
/--
Order of vanishing function for elements of the fraction field defined as the extension of
`CommRing.ordMonoidWithZeroHom` to the field of fractions.
-/
@[stacks 02MD]
noncomputable
def ordFrac : K →*₀ ℤᵐ⁰ :=
letI f := (toLocalizationMap (nonZeroDivisors R) K).lift₀ (ordMonoidWithZeroHom R)
haveI : ∀ (y : ↥(nonZeroDivisors R)), IsUnit (ordMonoidWithZeroHom R ↑y) := by
intro y
simp only [isUnit_iff_ne_zero, ne_eq]
simp [ordMonoidWithZeroHom, ord]
have := Module.length_ne_top_iff.mpr <| isFiniteLength_quotient_span_singleton R y.2
have : ∀ k,
(WithZero.map' (AddMonoidHom.toMultiplicative (Nat.castAddMonoidHom ℤ))) k = 0 ↔ k = 0 := by
intro k
cases k
all_goals simp
simpa [this]
f this
lemma ordFrac_eq_ord (x : R) (hx : x ≠ 0) :
ordFrac R (algebraMap R K x) = ordMonoidWithZeroHom R x := by
have := (FaithfulSMul.algebraMap_injective R K).isDomain
refine (Submonoid.LocalizationMap.lift_eq ..).trans ?_
simp [ordMonoidWithZeroHom, mem_nonZeroDivisors_iff_ne_zero.mpr hx]
lemma ordFrac_eq_div (a : nonZeroDivisors R) (b : nonZeroDivisors R) :
ordFrac R (IsLocalization.mk' K a.1 b) =
ordMonoidWithZeroHom R a / ordMonoidWithZeroHom R b := by
simp [ordFrac_eq_ord]
end Ring |
.lake/packages/mathlib/Mathlib/RingTheory/IntegralDomain.lean | import Mathlib.Algebra.Polynomial.Roots
import Mathlib.Data.Fintype.Inv
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.Tactic.FieldSimp
/-!
# Integral domains
Assorted theorems about integral domains.
## Main theorems
* `isCyclic_of_subgroup_isDomain`: A finite subgroup of the units of an integral domain is cyclic.
* `Fintype.fieldOfDomain`: A finite integral domain is a field.
## Notes
Wedderburn's little theorem, which shows that all finite division rings are actually fields,
is in `Mathlib/RingTheory/LittleWedderburn.lean`.
## Tags
integral domain, finite integral domain, finite field
-/
section
open Finset Polynomial Function
section CancelMonoidWithZero
-- There doesn't seem to be a better home for these right now
variable {M : Type*} [CancelMonoidWithZero M] [Finite M]
theorem mul_right_bijective_of_finite₀ {a : M} (ha : a ≠ 0) : Bijective fun b => a * b :=
Finite.injective_iff_bijective.1 <| mul_right_injective₀ ha
theorem mul_left_bijective_of_finite₀ {a : M} (ha : a ≠ 0) : Bijective fun b => b * a :=
Finite.injective_iff_bijective.1 <| mul_left_injective₀ ha
/-- Every finite nontrivial cancel_monoid_with_zero is a group_with_zero. -/
def Fintype.groupWithZeroOfCancel (M : Type*) [CancelMonoidWithZero M] [DecidableEq M] [Fintype M]
[Nontrivial M] : GroupWithZero M :=
{ ‹Nontrivial M›,
‹CancelMonoidWithZero M› with
inv := fun a => if h : a = 0 then 0 else Fintype.bijInv (mul_right_bijective_of_finite₀ h) 1
mul_inv_cancel := fun a ha => by
simp only [dif_neg ha]
exact Fintype.rightInverse_bijInv _ _
inv_zero := by simp }
theorem exists_eq_pow_of_mul_eq_pow_of_coprime {R : Type*} [CommSemiring R] [IsDomain R]
[GCDMonoid R] [Subsingleton Rˣ] {a b c : R} {n : ℕ} (cp : IsCoprime a b) (h : a * b = c ^ n) :
∃ d : R, a = d ^ n := by
refine exists_eq_pow_of_mul_eq_pow (isUnit_of_dvd_one ?_) h
obtain ⟨x, y, hxy⟩ := cp
rw [← hxy]
exact dvd_add (dvd_mul_of_dvd_right (gcd_dvd_left _ _) _)
(dvd_mul_of_dvd_right (gcd_dvd_right _ _) _)
nonrec
theorem Finset.exists_eq_pow_of_mul_eq_pow_of_coprime {ι R : Type*} [CommSemiring R] [IsDomain R]
[GCDMonoid R] [Subsingleton Rˣ] {n : ℕ} {c : R} {s : Finset ι} {f : ι → R}
(h : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsCoprime (f i) (f j))
(hprod : ∏ i ∈ s, f i = c ^ n) : ∀ i ∈ s, ∃ d : R, f i = d ^ n := by
classical
intro i hi
rw [← insert_erase hi, prod_insert (notMem_erase i s)] at hprod
refine
exists_eq_pow_of_mul_eq_pow_of_coprime
(IsCoprime.prod_right fun j hj => h i hi j (erase_subset i s hj) fun hij => ?_) hprod
rw [hij] at hj
exact (s.notMem_erase _) hj
end CancelMonoidWithZero
variable {R : Type*} {G : Type*}
section Ring
variable [Ring R] [IsDomain R] [Fintype R]
/-- Every finite domain is a division ring. More generally, they are fields; this can be found in
`Mathlib/RingTheory/LittleWedderburn.lean`. -/
def Fintype.divisionRingOfIsDomain (R : Type*) [Ring R] [IsDomain R] [DecidableEq R] [Fintype R] :
DivisionRing R where
__ := (‹Ring R›:) -- this also works without the `( :)`, but it's slightly slow
__ := Fintype.groupWithZeroOfCancel R
nnqsmul := _
nnqsmul_def := fun _ _ => rfl
qsmul := _
qsmul_def := fun _ _ => rfl
/-- Every finite commutative domain is a field. More generally, commutativity is not required: this
can be found in `Mathlib/RingTheory/LittleWedderburn.lean`. -/
def Fintype.fieldOfDomain (R) [CommRing R] [IsDomain R] [DecidableEq R] [Fintype R] : Field R :=
{ Fintype.divisionRingOfIsDomain R, ‹CommRing R› with }
theorem Finite.isField_of_domain (R) [CommRing R] [IsDomain R] [Finite R] : IsField R := by
cases nonempty_fintype R
exact @Field.toIsField R (@Fintype.fieldOfDomain R _ _ (Classical.decEq R) _)
end Ring
variable [CommRing R] [IsDomain R] [Group G]
theorem card_nthRoots_subgroup_units [Fintype G] [DecidableEq G] (f : G →* R) (hf : Injective f)
{n : ℕ} (hn : 0 < n) (g₀ : G) :
#{g | g ^ n = g₀} ≤ Multiset.card (nthRoots n (f g₀)) := by
haveI : DecidableEq R := Classical.decEq _
calc
_ ≤ #(nthRoots n (f g₀)).toFinset :=
card_le_card_of_injOn f (by aesop (add safe unfold Set.MapsTo)) hf.injOn
_ ≤ _ := (nthRoots n (f g₀)).toFinset_card_le
/-- A finite subgroup of the unit group of an integral domain is cyclic. -/
theorem isCyclic_of_subgroup_isDomain [Finite G] (f : G →* R) (hf : Injective f) : IsCyclic G := by
classical
cases nonempty_fintype G
apply isCyclic_of_card_pow_eq_one_le
intro n hn
exact le_trans (card_nthRoots_subgroup_units f hf hn 1) (card_nthRoots n (f 1))
/-- The unit group of a finite integral domain is cyclic.
To support `ℤˣ` and other infinite monoids with finite groups of units, this requires only
`Finite Rˣ` rather than deducing it from `Finite R`. -/
instance [Finite Rˣ] : IsCyclic Rˣ :=
isCyclic_of_subgroup_isDomain (Units.coeHom R) Units.val_injective
section
variable (S : Subgroup Rˣ) [Finite S]
/-- A finite subgroup of the units of an integral domain is cyclic. -/
instance subgroup_units_cyclic : IsCyclic S :=
isCyclic_of_subgroup_isDomain { toFun s := (s.val : R), map_one' := rfl, map_mul' := by simp }
(Units.val_injective.comp Subtype.val_injective)
end
section EuclideanDivision
namespace Polynomial
variable (K : Type*) [Field K] [Algebra R[X] K] [IsFractionRing R[X] K]
theorem div_eq_quo_add_rem_div (f : R[X]) {g : R[X]} (hg : g.Monic) :
∃ q r : R[X], r.degree < g.degree ∧
(algebraMap R[X] K f) / (algebraMap R[X] K g) =
algebraMap R[X] K q + (algebraMap R[X] K r) / (algebraMap R[X] K g) := by
refine ⟨f /ₘ g, f %ₘ g, ?_, ?_⟩
· exact degree_modByMonic_lt _ hg
· have hg' : algebraMap R[X] K g ≠ 0 :=
(map_ne_zero_iff _ (IsFractionRing.injective R[X] K)).mpr (Monic.ne_zero hg)
field_simp
rw [add_comm, ← map_mul, ← map_add, modByMonic_add_div f hg]
end Polynomial
end EuclideanDivision
variable [Fintype G]
/-- In an integral domain, a sum indexed by a nontrivial homomorphism from a finite group is zero.
-/
theorem sum_hom_units_eq_zero (f : G →* R) (hf : f ≠ 1) : ∑ g : G, f g = 0 := by
classical
obtain ⟨x, hx⟩ : ∃ x : MonoidHom.range f.toHomUnits,
∀ y : MonoidHom.range f.toHomUnits, y ∈ Submonoid.powers x :=
IsCyclic.exists_monoid_generator
have hx1 : x ≠ 1 := by
rintro rfl
apply hf
ext g
rw [MonoidHom.one_apply]
obtain ⟨n, hn⟩ := hx ⟨f.toHomUnits g, g, rfl⟩
rwa [Subtype.ext_iff, Units.ext_iff, Subtype.coe_mk, MonoidHom.coe_toHomUnits, one_pow,
eq_comm] at hn
replace hx1 : (x.val : R) - 1 ≠ 0 := -- Porting note: was `(x : R)`
fun h => hx1 (Subtype.eq (Units.ext (sub_eq_zero.1 h)))
let c := #{g | f.toHomUnits g = 1}
calc
∑ g : G, f g = ∑ g : G, (f.toHomUnits g : R) := rfl
_ = ∑ u ∈ univ.image f.toHomUnits, #{g | f.toHomUnits g = u} • (u : R) :=
sum_comp ((↑) : Rˣ → R) f.toHomUnits
_ = ∑ u ∈ univ.image f.toHomUnits, c • (u : R) :=
(sum_congr rfl fun u hu => congr_arg₂ _ ?_ rfl)
-- remaining goal 1, proven below
-- Porting note: have to change `(b : R)` into `((b : Rˣ) : R)`
_ = ∑ b : MonoidHom.range f.toHomUnits, c • ((b : Rˣ) : R) :=
(Finset.sum_subtype _ (by simp) _)
_ = c • ∑ b : MonoidHom.range f.toHomUnits, ((b : Rˣ) : R) := smul_sum.symm
_ = c • (0 : R) := congr_arg₂ _ rfl ?_
-- remaining goal 2, proven below
_ = (0 : R) := smul_zero _
· -- remaining goal 1
show #{g : G | f.toHomUnits g = u} = c
apply MonoidHom.card_fiber_eq_of_mem_range f.toHomUnits
· simpa only [mem_image, mem_univ, true_and, Set.mem_range] using hu
· exact ⟨1, f.toHomUnits.map_one⟩
-- remaining goal 2
show (∑ b : MonoidHom.range f.toHomUnits, ((b : Rˣ) : R)) = 0
calc
(∑ b : MonoidHom.range f.toHomUnits, ((b : Rˣ) : R))
= ∑ n ∈ range (orderOf x), ((x : Rˣ) : R) ^ n :=
Eq.symm <|
sum_nbij (x ^ ·) (by simp only [mem_univ, forall_true_iff])
(by simpa using pow_injOn_Iio_orderOf)
(fun b _ => let ⟨n, hn⟩ := hx b
⟨n % orderOf x, mem_range.2 (Nat.mod_lt _ (orderOf_pos _)),
-- Porting note: have to `beta_reduce` to apply the function
by beta_reduce at hn ⊢; rw [pow_mod_orderOf, hn]⟩)
(by simp only [imp_true_iff, Subgroup.coe_pow,
Units.val_pow_eq_pow_val])
_ = 0 := ?_
rw [← mul_left_inj' hx1, zero_mul, geom_sum_mul]
norm_cast
simp [pow_orderOf_eq_one]
/-- In an integral domain, a sum indexed by a homomorphism from a finite group is zero,
unless the homomorphism is trivial, in which case the sum is equal to the cardinality of the group.
-/
theorem sum_hom_units (f : G →* R) [Decidable (f = 1)] :
∑ g : G, f g = if f = 1 then Fintype.card G else 0 := by
split_ifs with h
· simp [h]
· rw [Nat.cast_zero]
exact sum_hom_units_eq_zero f h
end |
.lake/packages/mathlib/Mathlib/RingTheory/MatrixPolynomialAlgebra.lean | import Mathlib.Data.Matrix.Basis
import Mathlib.Data.Matrix.Composition
import Mathlib.RingTheory.MatrixAlgebra
import Mathlib.RingTheory.PolynomialAlgebra
/-!
# Algebra isomorphism between matrices of polynomials and polynomials of matrices
We obtain the algebra isomorphism
```
def matPolyEquiv : Matrix n n R[X] ≃ₐ[R] (Matrix n n R)[X]
```
which is characterized by
```
coeff (matPolyEquiv m) k i j = coeff (m i j) k
```
We will use this algebra isomorphism to prove the Cayley-Hamilton theorem.
-/
universe u v w
open Polynomial TensorProduct
open Algebra.TensorProduct (algHomOfLinearMapTensorProduct includeLeft)
noncomputable section
variable (R A : Type*)
variable [CommSemiring R]
variable [Semiring A] [Algebra R A]
open Matrix
variable {R}
variable {n : Type w} [DecidableEq n] [Fintype n]
/--
The algebra isomorphism stating "matrices of polynomials are the same as polynomials of matrices".
(You probably shouldn't attempt to use this underlying definition ---
it's an algebra equivalence, and characterised extensionally by the lemma
`matPolyEquiv_coeff_apply` below.)
-/
noncomputable def matPolyEquiv : Matrix n n R[X] ≃ₐ[R] (Matrix n n R)[X] :=
((matrixEquivTensor n R R[X]).trans (Algebra.TensorProduct.comm R _ _)).trans
(polyEquivTensor R (Matrix n n R)).symm
@[simp] theorem matPolyEquiv_symm_C (M : Matrix n n R) : matPolyEquiv.symm (C M) = M.map C := by
simp [matPolyEquiv]
@[simp] theorem matPolyEquiv_map_C (M : Matrix n n R) : matPolyEquiv (M.map C) = C M := by
rw [← matPolyEquiv_symm_C, AlgEquiv.apply_symm_apply]
@[simp] theorem matPolyEquiv_symm_X :
matPolyEquiv.symm X = diagonal fun _ : n => (X : R[X]) := by
simp [matPolyEquiv, Matrix.smul_one_eq_diagonal]
@[simp] theorem matPolyEquiv_diagonal_X :
matPolyEquiv (diagonal fun _ : n => (X : R[X])) = X := by
rw [← matPolyEquiv_symm_X, AlgEquiv.apply_symm_apply]
open Finset
unseal Algebra.TensorProduct.mul in
theorem matPolyEquiv_coeff_apply_aux_1 (i j : n) (k : ℕ) (x : R) :
matPolyEquiv (single i j <| monomial k x) = monomial k (single i j x) := by
simp only [matPolyEquiv, AlgEquiv.trans_apply, matrixEquivTensor_apply_single]
apply (polyEquivTensor R (Matrix n n R)).injective
simp only [AlgEquiv.apply_symm_apply,Algebra.TensorProduct.comm_tmul,
polyEquivTensor_apply, eval₂_monomial]
simp only [one_pow,
Algebra.TensorProduct.tmul_pow]
rw [← smul_X_eq_monomial, ← TensorProduct.smul_tmul]
congr with i' <;> simp [single]
theorem matPolyEquiv_coeff_apply_aux_2 (i j : n) (p : R[X]) (k : ℕ) :
coeff (matPolyEquiv (single i j p)) k = single i j (coeff p k) := by
refine Polynomial.induction_on' p ?_ ?_
· intro p q hp hq
ext
simp [hp, hq, coeff_add, add_apply, single_add]
· intro k x
simp only [matPolyEquiv_coeff_apply_aux_1, coeff_monomial]
split_ifs <;>
· funext
simp
@[simp]
theorem matPolyEquiv_coeff_apply (m : Matrix n n R[X]) (k : ℕ) (i j : n) :
coeff (matPolyEquiv m) k i j = coeff (m i j) k := by
refine Matrix.induction_on' m ?_ ?_ ?_
· simp
· intro p q hp hq
simp [hp, hq]
· intro i' j' x
rw [matPolyEquiv_coeff_apply_aux_2]
dsimp [single]
split_ifs <;> rename_i h
· constructor
· simp
@[simp]
theorem matPolyEquiv_symm_apply_coeff (p : (Matrix n n R)[X]) (i j : n) (k : ℕ) :
coeff (matPolyEquiv.symm p i j) k = coeff p k i j := by
have t : p = matPolyEquiv (matPolyEquiv.symm p) := by simp
conv_rhs => rw [t]
simp only [matPolyEquiv_coeff_apply]
theorem matPolyEquiv_smul_one (p : R[X]) :
matPolyEquiv (p • (1 : Matrix n n R[X])) = p.map (algebraMap R (Matrix n n R)) := by
ext m i j
simp only [matPolyEquiv_coeff_apply, smul_apply, one_apply, smul_eq_mul, mul_ite, mul_one,
mul_zero, coeff_map, algebraMap_matrix_apply, Algebra.algebraMap_self, RingHom.id_apply]
split_ifs <;> simp
@[simp]
lemma matPolyEquiv_map_smul (p : R[X]) (M : Matrix n n R[X]) :
matPolyEquiv (p • M) = p.map (algebraMap _ _) * matPolyEquiv M := by
rw [← one_mul M, ← smul_mul_assoc, map_mul, matPolyEquiv_smul_one, one_mul]
theorem matPolyEquiv_symm_map_eval (M : (Matrix n n R)[X]) (r : R) :
(matPolyEquiv.symm M).map (eval r) = M.eval (scalar n r) := by
suffices ((aeval r).mapMatrix.comp matPolyEquiv.symm.toAlgHom : (Matrix n n R)[X] →ₐ[R] _) =
(eval₂AlgHom' (AlgHom.id R _) (scalar n r)
fun x => (scalar_commute _ (Commute.all _) _).symm) from
DFunLike.congr_fun this M
ext : 1
· ext M : 1
simp [Function.comp_def]
· simp
theorem matPolyEquiv_eval_eq_map (M : Matrix n n R[X]) (r : R) :
(matPolyEquiv M).eval (scalar n r) = M.map (eval r) := by
simpa only [AlgEquiv.symm_apply_apply] using (matPolyEquiv_symm_map_eval (matPolyEquiv M) r).symm
-- I feel like this should use `Polynomial.algHom_eval₂_algebraMap`
theorem matPolyEquiv_eval (M : Matrix n n R[X]) (r : R) (i j : n) :
(matPolyEquiv M).eval (scalar n r) i j = (M i j).eval r := by
rw [matPolyEquiv_eval_eq_map, map_apply]
theorem support_subset_support_matPolyEquiv (m : Matrix n n R[X]) (i j : n) :
support (m i j) ⊆ support (matPolyEquiv m) := by
intro k
contrapose
simp only [notMem_support_iff]
intro hk
rw [← matPolyEquiv_coeff_apply, hk, zero_apply]
theorem eval_det {R : Type*} [CommRing R] (M : Matrix n n R[X]) (r : R) :
Polynomial.eval r M.det = (Polynomial.eval (scalar n r) (matPolyEquiv M)).det := by
rw [Polynomial.eval, ← coe_eval₂RingHom, RingHom.map_det]
exact congr_arg det <| ext fun _ _ ↦ matPolyEquiv_eval _ _ _ _ |>.symm
lemma eval_det_add_X_smul {R : Type*} [CommRing R] (A : Matrix n n R[X]) (M : Matrix n n R) :
(det (A + (X : R[X]) • M.map C)).eval 0 = (det A).eval 0 := by
simp only [eval_det, map_zero, map_add, eval_add, Algebra.smul_def, map_mul]
simp only [Algebra.algebraMap_eq_smul_one, matPolyEquiv_smul_one, map_X, X_mul, eval_mul_X,
mul_zero, add_zero]
variable {A}
/-- Extend a ring hom `A → Mₙ(R)` to a ring hom `A[X] → Mₙ(R[X])`. -/
def RingHom.polyToMatrix (f : A →+* Matrix n n R) : A[X] →+* Matrix n n R[X] :=
matPolyEquiv.symm.toRingHom.comp (mapRingHom f)
variable {S : Type*} [CommSemiring S] (f : S →+* Matrix n n R)
lemma evalRingHom_mapMatrix_comp_polyToMatrix :
(evalRingHom 0).mapMatrix.comp f.polyToMatrix = f.comp (evalRingHom 0) := by
ext <;> simp [RingHom.polyToMatrix, - AlgEquiv.symm_toRingEquiv, diagonal, apply_ite]
lemma evalRingHom_mapMatrix_comp_compRingEquiv {m} [Fintype m] [DecidableEq m] :
(evalRingHom 0).mapMatrix.comp (compRingEquiv m n R[X]) =
(compRingEquiv m n R).toRingHom.comp (evalRingHom 0).mapMatrix.mapMatrix := by
ext; simp |
.lake/packages/mathlib/Mathlib/RingTheory/EisensteinCriterion.lean | import Mathlib.Data.Nat.Cast.WithTop
import Mathlib.RingTheory.Ideal.Quotient.Basic
import Mathlib.RingTheory.Polynomial.Content
import Mathlib.RingTheory.Prime
deprecated_module "Auto-generated deprecation" (since := "2025-04-11") |
.lake/packages/mathlib/Mathlib/RingTheory/PicardGroup.lean | import Mathlib.Algebra.Category.ModuleCat.Monoidal.Symmetric
import Mathlib.Algebra.Module.FinitePresentation
import Mathlib.Algebra.Module.LocalizedModule.Submodule
import Mathlib.CategoryTheory.Monoidal.Skeleton
import Mathlib.LinearAlgebra.Contraction
import Mathlib.LinearAlgebra.TensorProduct.Finiteness
import Mathlib.LinearAlgebra.TensorProduct.RightExactness
import Mathlib.LinearAlgebra.TensorProduct.Submodule
import Mathlib.RingTheory.Flat.Localization
import Mathlib.RingTheory.Localization.BaseChange
import Mathlib.RingTheory.LocalRing.Module
/-!
# The Picard group of a commutative ring
This file defines the Picard group `CommRing.Pic R` of a commutative ring `R` as the type of
invertible `R`-modules (in the sense that `M` is invertible if there exists another `R`-module
`N` such that `M ⊗[R] N ≃ₗ[R] R`) up to isomorphism, equipped with tensor product as multiplication.
## Main definition
- `Module.Invertible R M` says that the canonical map `Mᵛ ⊗[R] M → R` is an isomorphism.
To show that `M` is invertible, it suffices to provide an arbitrary `R`-module `N`
and an isomorphism `N ⊗[R] M ≃ₗ[R] R`, see `Module.Invertible.right`.
## Main results
- An invertible module is finite and projective (provided as instances).
- `Module.Invertible.free_iff_linearEquiv`: an invertible module is free iff it is isomorphic to
the ring, i.e. its class is trivial in the Picard group.
## References
- https://qchu.wordpress.com/2014/10/19/the-picard-groups/
- https://mathoverflow.net/questions/13768/what-is-the-right-definition-of-the-picard-group-of-a-commutative-ring
- https://mathoverflow.net/questions/375725/picard-group-vs-class-group
- [Weibel2013], https://sites.math.rutgers.edu/~weibel/Kbook/Kbook.I.pdf, Proposition 3.5.
- [Stacks: Picard groups of rings](https://stacks.math.columbia.edu/tag/0AFW)
## TODO
Show:
- The Picard group of a commutative domain is isomorphic to its ideal class group.
- All unique factorization domains have trivial Picard group.
- Invertible modules over a commutative ring have the same cardinality as the ring.
- Establish other characterizations of invertible modules, e.g. they are modules that
become free of rank one when localized at every prime ideal.
See [Stacks: Finite projective modules](https://stacks.math.columbia.edu/tag/00NX).
- Connect to invertible sheaves on `Spec R`. More generally, connect projective `R`-modules of
constant finite rank to locally free sheaves on `Spec R`.
- Exhibit isomorphism with sheaf cohomology `H¹(Spec R, 𝓞ˣ)`.
-/
open TensorProduct
universe u v
namespace Module
variable (R : Type u) (M : Type v) (N P Q A : Type*) [CommSemiring R] [CommSemiring A]
variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q] [Algebra R A]
variable [Module R M] [Module R N] [Module R P] [Module R Q]
/-- An `R`-module `M` is invertible if the canonical map `Mᵛ ⊗[R] M → R` is an isomorphism,
where `Mᵛ` is the `R`-dual of `M`. -/
protected class Invertible : Prop where
bijective : Function.Bijective (contractLeft R M)
namespace Invertible
/-- Promote the canonical map `Mᵛ ⊗[R] M → R` to a linear equivalence for invertible `M`. -/
noncomputable def linearEquiv [Module.Invertible R M] : Module.Dual R M ⊗[R] M ≃ₗ[R] R :=
.ofBijective _ Invertible.bijective
variable {R M N}
section LinearEquiv
variable (e : M ⊗[R] N ≃ₗ[R] R)
/-- The canonical isomorphism between a module and the result of tensoring it
from the left by two mutually dual invertible modules. -/
noncomputable abbrev leftCancelEquiv : M ⊗[R] (N ⊗[R] P) ≃ₗ[R] P :=
(TensorProduct.assoc R M N P).symm ≪≫ₗ e.rTensor P ≪≫ₗ TensorProduct.lid R P
/-- The canonical isomorphism between a module and the result of tensoring it
from the right by two mutually dual invertible modules. -/
noncomputable abbrev rightCancelEquiv : (P ⊗[R] M) ⊗[R] N ≃ₗ[R] P :=
TensorProduct.assoc R P M N ≪≫ₗ e.lTensor P ≪≫ₗ TensorProduct.rid R P
variable {P Q} in
theorem leftCancelEquiv_comp_lTensor_comp_symm (f : P →ₗ[R] Q) :
leftCancelEquiv Q e ∘ₗ (f.lTensor N).lTensor M ∘ₗ (leftCancelEquiv P e).symm = f := by
rw [← LinearMap.comp_assoc, LinearEquiv.comp_toLinearMap_symm_eq]; ext; simp
variable {P Q} in
theorem rightCancelEquiv_comp_rTensor_comp_symm (f : P →ₗ[R] Q) :
rightCancelEquiv Q e ∘ₗ (f.rTensor M).rTensor N ∘ₗ (rightCancelEquiv P e).symm = f := by
rw [← LinearMap.comp_assoc, LinearEquiv.comp_toLinearMap_symm_eq]; ext; simp
/-- If M is invertible, `rTensorHom M` admits an inverse. -/
noncomputable def rTensorInv : (P ⊗[R] M →ₗ[R] Q ⊗[R] M) →ₗ[R] (P →ₗ[R] Q) :=
((rightCancelEquiv Q e).congrRight ≪≫ₗ (rightCancelEquiv P e).congrLeft _ R) ∘ₗ
LinearMap.rTensorHom N
theorem rTensorInv_leftInverse : Function.LeftInverse (rTensorInv P Q e) (.rTensorHom M) :=
fun _ ↦ by
simp_rw [rTensorInv, LinearEquiv.coe_trans, LinearMap.comp_apply, LinearEquiv.coe_toLinearMap]
rw [← LinearEquiv.eq_symm_apply]
ext; simp [LinearEquiv.congrLeft, LinearEquiv.congrRight, LinearEquiv.arrowCongrAddEquiv]
theorem rTensorInv_injective : Function.Injective (rTensorInv P Q e) := by
simpa [rTensorInv] using (rTensorInv_leftInverse _ _ <| TensorProduct.comm R N M ≪≫ₗ e).injective
/-- If `M` is an invertible `R`-module, `(· ⊗[R] M)` is an auto-equivalence of the category
of `R`-modules. -/
@[simps!] noncomputable def rTensorEquiv : (P →ₗ[R] Q) ≃ₗ[R] (P ⊗[R] M →ₗ[R] Q ⊗[R] M) where
__ := LinearMap.rTensorHom M
invFun := rTensorInv P Q e
left_inv := rTensorInv_leftInverse P Q e
right_inv _ := rTensorInv_injective P Q e (by rw [LinearMap.toFun_eq_coe, rTensorInv_leftInverse])
open LinearMap in
/-- If there is an `R`-isomorphism between `M ⊗[R] N` and `R`,
the induced map `M → Nᵛ` is an isomorphism. -/
theorem bijective_curry : Function.Bijective (curry e.toLinearMap) := by
have : curry e.toLinearMap = ((TensorProduct.lid R N).congrLeft _ R ≪≫ₗ e.congrRight) ∘ₗ
rTensorHom N ∘ₗ (ringLmapEquivSelf R R M).symm.toLinearMap := by
rw [← LinearEquiv.toLinearMap_symm_comp_eq]; ext
simp [LinearEquiv.congrLeft, LinearEquiv.congrRight, LinearEquiv.arrowCongrAddEquiv]
simpa [this] using (rTensorEquiv R M <| TensorProduct.comm R N M ≪≫ₗ e).bijective
/-- Given `M ⊗[R] N ≃ₗ[R] R`, this is the induced isomorphism `M ≃ₗ[R] Nᵛ`. -/
noncomputable def linearEquivDual : M ≃ₗ[R] Dual R N := .ofBijective _ (bijective_curry e)
include e
protected theorem right : Module.Invertible R N where
bijective := by
rw [show contractLeft R N = ((linearEquivDual e).rTensor N).symm ≪≫ₗ e by
rw [LinearEquiv.coe_trans, LinearEquiv.eq_comp_toLinearMap_symm]; ext; rfl]
apply LinearEquiv.bijective
protected theorem left : Module.Invertible R M := .right (TensorProduct.comm R N M ≪≫ₗ e)
instance : Module.Invertible R R := .left (TensorProduct.lid R R)
end LinearEquiv
variable [Module.Invertible R M]
protected theorem congr (e : M ≃ₗ[R] N) : Module.Invertible R N :=
.right (e.symm.lTensor _ ≪≫ₗ linearEquiv R M)
variable (R M N)
instance : Module.Invertible R (Dual R M) := .left (linearEquiv R M)
instance [Module.Invertible R N] : Module.Invertible R (M ⊗[R] N) :=
.right (M := Dual R M ⊗[R] Dual R N) <| tensorTensorTensorComm .. ≪≫ₗ
congr (linearEquiv R M) (linearEquiv R N) ≪≫ₗ TensorProduct.lid R R
private theorem finite_projective : Module.Finite R M ∧ Projective R M := by
let N := Dual R M
let e : M ⊗[R] N ≃ₗ[R] R := TensorProduct.comm .. ≪≫ₗ linearEquiv R M
have ⟨S, hS⟩ := TensorProduct.exists_finset (e.symm 1)
let f : (S →₀ N) →ₗ[R] R := Finsupp.lsum R fun i ↦ e.toLinearMap ∘ₗ TensorProduct.mk R M N i.1.1
have : Function.Surjective f := by
rw [← LinearMap.range_eq_top, Ideal.eq_top_iff_one]
use Finsupp.equivFunOnFinite.symm fun i ↦ i.1.2
simp_rw [f, Finsupp.coe_lsum]
rw [Finsupp.sum_fintype _ _ fun _ ↦ map_zero _]
rwa [e.symm_apply_eq, map_sum, ← Finset.sum_coe_sort, eq_comm] at hS
have ⟨g, hg⟩ := projective_lifting_property f .id this
classical
let aux := finsuppRight R M N S ≪≫ₗ Finsupp.mapRange.linearEquiv e
let f' : (S →₀ R) →ₗ[R] M := TensorProduct.rid R M ∘ₗ f.lTensor M ∘ₗ aux.symm
let g' : M →ₗ[R] S →₀ R := aux ∘ₗ g.lTensor M ∘ₗ (TensorProduct.rid R M).symm
have : Function.Surjective f' := by simpa [f'] using LinearMap.lTensor_surjective _ this
refine ⟨.of_surjective f' this, .of_split g' f' <| LinearMap.ext fun m ↦ ?_⟩
simp [f', g', show f (g 1) = 1 from DFunLike.congr_fun hg 1]
instance : Module.Finite R M := (finite_projective R M).1
instance : Projective R M := (finite_projective R M).2
example : IsReflexive R M := inferInstance
section inj_surj_bij
variable {R N P}
theorem lTensor_injective_iff {f : N →ₗ[R] P} :
Function.Injective (f.lTensor M) ↔ Function.Injective f := by
refine ⟨fun h ↦ ?_, Flat.lTensor_preserves_injective_linearMap _⟩
rw [← leftCancelEquiv_comp_lTensor_comp_symm (linearEquiv R M) f]
simpa using Flat.lTensor_preserves_injective_linearMap _ h
theorem rTensor_injective_iff {f : N →ₗ[R] P} :
Function.Injective (f.rTensor M) ↔ Function.Injective f := by
rw [← LinearMap.lTensor_inj_iff_rTensor_inj, lTensor_injective_iff]
theorem lTensor_surjective_iff {f : N →ₗ[R] P} :
Function.Surjective (f.lTensor M) ↔ Function.Surjective f := by
refine ⟨fun h ↦ ?_, LinearMap.lTensor_surjective _⟩
rw [← leftCancelEquiv_comp_lTensor_comp_symm (linearEquiv R M) f]
simpa using LinearMap.lTensor_surjective _ h
theorem rTensor_surjective_iff {f : N →ₗ[R] P} :
Function.Surjective (f.rTensor M) ↔ Function.Surjective f := by
rw [← LinearMap.lTensor_surj_iff_rTensor_surj, lTensor_surjective_iff]
theorem lTensor_bijective_iff {f : N →ₗ[R] P} :
Function.Bijective (f.lTensor M) ↔ Function.Bijective f := by
simp_rw [Function.Bijective, lTensor_injective_iff, lTensor_surjective_iff]
theorem rTensor_bijective_iff {f : N →ₗ[R] P} :
Function.Bijective (f.rTensor M) ↔ Function.Bijective f := by
simp_rw [Function.Bijective, rTensor_injective_iff, rTensor_surjective_iff]
end inj_surj_bij
open Finsupp in
variable {R M} in
/-- An invertible module is free iff it is isomorphic to the ring, i.e. its class is trivial in
the Picard group. -/
theorem free_iff_linearEquiv : Free R M ↔ Nonempty (M ≃ₗ[R] R) := by
refine ⟨fun _ ↦ ?_, fun ⟨e⟩ ↦ .of_equiv e.symm⟩
nontriviality R
have e := (Free.chooseBasis R M).repr
have := card_eq_of_linearEquiv R <|
(finsuppTensorFinsupp' .. ≪≫ₗ linearEquivFunOnFinite R R _).symm ≪≫ₗ TensorProduct.congr
(linearEquivFunOnFinite R R _ ≪≫ₗ llift R R R _ ≪≫ₗ e.dualMap)
e.symm ≪≫ₗ linearEquiv R M ≪≫ₗ (.symm <| .funUnique Unit R R)
have : Unique (Free.ChooseBasisIndex R M) :=
(Fintype.card_eq_one_iff_nonempty_unique.mp (by simpa using this)).some
exact ⟨e ≪≫ₗ LinearEquiv.finsuppUnique R R _⟩
/- TODO: The ≤ direction holds for arbitrary invertible modules over any commutative **ring** by
considering the localization at a prime (which is free of rank 1) using the strong rank condition.
The ≥ direction fails in general but holds for domains and Noetherian rings without embedded
components, see https://math.stackexchange.com/q/5089900. -/
protected theorem finrank_eq_one [StrongRankCondition R] [Free R M] : finrank R M = 1 := by
cases subsingleton_or_nontrivial R
· rw [← rank_eq_one_iff_finrank_eq_one, rank_subsingleton]
· rw [(free_iff_linearEquiv.mp ‹_›).some.finrank_eq, finrank_self]
theorem rank_eq_one [StrongRankCondition R] [Free R M] : Module.rank R M = 1 :=
rank_eq_one_iff_finrank_eq_one.mpr (Invertible.finrank_eq_one R M)
open TensorProduct (comm lid) in
theorem toModuleEnd_bijective : Function.Bijective (toModuleEnd R (S := R) M) := by
have : toModuleEnd R (S := R) M = (lid R M).conj ∘ rTensorEquiv R R
(comm .. ≪≫ₗ linearEquiv R M) ∘ RingEquiv.moduleEndSelf R ∘ MulOpposite.opEquiv := by
ext; simp [LinearEquiv.conj, liftAux]
simpa [this] using MulOpposite.opEquiv.bijective
instance : FaithfulSMul R M where
eq_of_smul_eq_smul {_ _} h := (toModuleEnd_bijective R M).injective <| LinearMap.ext h
variable {R M N} in
private theorem bijective_self_of_surjective (f : R →ₗ[R] M) (hf : Function.Surjective f) :
Function.Bijective f where
left {r₁ r₂} eq := smul_left_injective' (α := M) <| funext fun m ↦ by
obtain ⟨r, rfl⟩ := hf m
simp_rw [← map_smul, smul_eq_mul, mul_comm _ r, ← smul_eq_mul, map_smul, eq]
right := hf
variable {R M N} in
/- Not true if `surjective` is replaced by `injective`: any nonzero element in an invertible
module over a domain generates a submodule isomorphic to the domain, which is not the whole
module unless the module is free. -/
theorem bijective_of_surjective [Module.Invertible R N] {f : M →ₗ[R] N}
(hf : Function.Surjective f) : Function.Bijective f := by
simpa [lTensor_bijective_iff] using bijective_self_of_surjective
(f.lTensor _ ∘ₗ (linearEquiv R M).symm.toLinearMap) (by simpa [lTensor_surjective_iff] using hf)
section LinearEquiv
variable {R M N} [Module.Invertible R N] {f : M →ₗ[R] N} {g : N →ₗ[R] M}
theorem rightInverse_of_leftInverse (hfg : Function.LeftInverse f g) :
Function.RightInverse f g :=
Function.rightInverse_of_injective_of_leftInverse
(bijective_of_surjective hfg.surjective).injective hfg
theorem leftInverse_of_rightInverse (hfg : Function.RightInverse f g) :
Function.LeftInverse f g :=
rightInverse_of_leftInverse hfg
variable (f g) in
theorem leftInverse_iff_rightInverse :
Function.LeftInverse f g ↔ Function.RightInverse f g :=
⟨rightInverse_of_leftInverse, leftInverse_of_rightInverse⟩
/-- If `f : M →ₗ[R] N` and `g : N →ₗ[R] M` where `M` and `N` are invertible `R`-modules, and `f` is
a left inverse of `g`, then in fact `f` is also the right inverse of `g`, and we promote this to
an `R`-module isomorphism. -/
def linearEquivOfLeftInverse (hfg : Function.LeftInverse f g) : M ≃ₗ[R] N :=
.ofLinear f g (LinearMap.ext hfg) (LinearMap.ext <| rightInverse_of_leftInverse hfg)
@[simp] lemma linearEquivOfLeftInverse_apply (hfg : Function.LeftInverse f g) (x : M) :
linearEquivOfLeftInverse hfg x = f x := rfl
@[simp] lemma linearEquivOfLeftInverse_symm_apply (hfg : Function.LeftInverse f g) (x : N) :
(linearEquivOfLeftInverse hfg).symm x = g x := rfl
/-- If `f : M →ₗ[R] N` and `g : N →ₗ[R] M` where `M` and `N` are invertible `R`-modules, and `f` is
a right inverse of `g`, then in fact `f` is also the left inverse of `g`, and we promote this to
an `R`-module isomorphism. -/
def linearEquivOfRightInverse (hfg : Function.RightInverse f g) : M ≃ₗ[R] N :=
.ofLinear f g (LinearMap.ext <| leftInverse_of_rightInverse hfg) (LinearMap.ext hfg)
@[simp] lemma linearEquivOfRightInverse_apply (hfg : Function.RightInverse f g) (x : M) :
linearEquivOfRightInverse hfg x = f x := rfl
@[simp] lemma linearEquivOfRightInverse_symm_apply (hfg : Function.RightInverse f g) (x : N) :
(linearEquivOfRightInverse hfg).symm x = g x := rfl
end LinearEquiv
section Algebra
section algEquivOfRing
variable (A : Type*) [Semiring A] [Algebra R A] [Module.Invertible R A]
/-- If an `R`-algebra `A` is also an invertible `R`-module, then it is in fact isomorphic to the
base ring `R`. The algebra structure gives us a map `A ⊗ A → A`, which after tensoring by `Aᵛ`
becomes a map `A → R`, which is the inverse map we seek. -/
noncomputable def algEquivOfRing : R ≃ₐ[R] A :=
let inv : A →ₗ[R] R :=
linearEquiv R A ∘ₗ
(LinearMap.mul' R A).lTensor (Dual R A) ∘ₗ
(leftCancelEquiv A (linearEquiv R A)).symm
have right : inv ∘ₗ Algebra.linearMap R A = LinearMap.id :=
let ⟨s, hs⟩ := exists_finset ((linearEquiv R A).symm 1)
LinearMap.ext_ring <| by simp [inv, hs, sum_tmul, map_sum, ← (LinearEquiv.symm_apply_eq _).1 hs]
{ linearEquivOfRightInverse (f := Algebra.linearMap R A) (g := inv) (LinearMap.ext_iff.1 right),
Algebra.ofId R A with }
variable {A} in
@[simp] lemma algEquivOfRing_apply (x : R) : algEquivOfRing R A x = algebraMap R A x := rfl
end algEquivOfRing
instance : Module.Invertible A (A ⊗[R] M) :=
.right (M := A ⊗[R] Dual R M) <| (AlgebraTensorModule.distribBaseChange ..).symm ≪≫ₗ
AlgebraTensorModule.congr (.refl A A) (linearEquiv R M) ≪≫ₗ AlgebraTensorModule.rid ..
variable {R M N A} in
theorem of_isLocalization (S : Submonoid R) [IsLocalization S A]
(f : M →ₗ[R] N) [IsLocalizedModule S f] [Module A N] [IsScalarTower R A N] :
Module.Invertible A N :=
.congr (IsLocalizedModule.isBaseChange S A f).equiv
instance (S : Submonoid R) : Module.Invertible (Localization S) (LocalizedModule S M) :=
of_isLocalization S (LocalizedModule.mkLinearMap S M)
instance (L) [AddCommMonoid L] [Module R L] [Module A L] [IsScalarTower R A L]
[Module.Invertible A L] : Module.Invertible A (L ⊗[R] M) :=
.congr (AlgebraTensorModule.cancelBaseChange R A A L M)
variable [FaithfulSMul R A] [Free A (A ⊗[R] M)]
/-- An invertible `R`-module embeds into an `R`-algebra that `R` injects into,
provided `A ⊗[R] M` is a free `A`-module. -/
noncomputable def embAlgebra : M →ₗ[R] A :=
(free_iff_linearEquiv.mp ‹_›).some.restrictScalars R ∘ₗ
(Algebra.ofId R A).toLinearMap.rTensor M ∘ₗ (TensorProduct.lid R M).symm
theorem embAlgebra_injective : Function.Injective (embAlgebra R M A) := by
simpa [embAlgebra] using
Flat.rTensor_preserves_injective_linearMap _ (FaithfulSMul.algebraMap_injective R A)
/-- An invertible `R`-module as a `R`-submodule of an `R`-algebra. -/
noncomputable def toSubmodule : Submodule R A := LinearMap.range (embAlgebra R M A)
end Algebra
end Invertible
end Module
section PicardGroup
open CategoryTheory Module
variable (R : Type u) [CommRing R]
instance (M : (Skeleton <| ModuleCat.{u} R)ˣ) : Module.Invertible R M :=
.right (Quotient.eq.mp M.inv_mul).some.toLinearEquiv
instance : Small.{u} (Skeleton <| ModuleCat.{u} R)ˣ :=
let sf := Σ n, Submodule R (Fin n → R)
have {M N : sf} : M = N → (_ ⧸ M.2) ≃ₗ[R] _ ⧸ N.2 := by rintro rfl; exact .refl ..
let f (M : (Skeleton <| ModuleCat.{u} R)ˣ) : sf := ⟨_, Finite.kerRepr R M⟩
small_of_injective (f := f) fun M N eq ↦ Units.ext <| Quotient.out_equiv_out.mp
⟨((Finite.reprEquiv R M).symm ≪≫ₗ this eq ≪≫ₗ Finite.reprEquiv R N).toModuleIso⟩
/-- The Picard group of a commutative ring R consists of the invertible R-modules,
up to isomorphism. -/
def CommRing.Pic (R : Type u) [CommRing R] : Type u :=
Shrink (Skeleton <| ModuleCat.{u} R)ˣ
open CommRing (Pic)
noncomputable instance : CommGroup (Pic R) := (equivShrink _).symm.commGroup
section CommRing
variable (M N : Type*) [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
[Module.Invertible R M] [Module.Invertible R N]
instance : Module.Invertible R (Finite.repr R M) := .congr (Finite.reprEquiv R M).symm
namespace CommRing.Pic
variable {R} in
/-- A representative of an element in the Picard group. -/
abbrev AsModule (M : Pic R) : Type u := ((equivShrink _).symm M).val
noncomputable instance : CoeSort (Pic R) (Type u) := ⟨AsModule⟩
private noncomputable def equivShrinkLinearEquiv (M : (Skeleton <| ModuleCat.{u} R)ˣ) :
(id <| equivShrink _ M : Pic R) ≃ₗ[R] M :=
have {M N : Skeleton (ModuleCat.{u} R)} : M = N → M ≃ₗ[R] N := by rintro rfl; exact .refl ..
this (by simp)
/-- The class of an invertible module in the Picard group. -/
protected noncomputable def mk : Pic R := equivShrink _ <|
letI M' := Finite.repr R M
.mkOfMulEqOne ⟦.of R M'⟧ ⟦.of R (Dual R M')⟧ <| by
rw [← toSkeleton, ← toSkeleton, mul_comm, ← Skeleton.toSkeleton_tensorObj]
exact Quotient.sound ⟨(Invertible.linearEquiv R _).toModuleIso⟩
/-- `mk R M` is indeed the class of `M`. -/
noncomputable def mk.linearEquiv : Pic.mk R M ≃ₗ[R] M :=
equivShrinkLinearEquiv R _ ≪≫ₗ (Quotient.mk_out (s := isIsomorphicSetoid _)
(ModuleCat.of R (Finite.repr R M))).some.toLinearEquiv ≪≫ₗ Finite.reprEquiv R M
variable {R M N}
theorem mk_eq_iff {N : Pic R} : Pic.mk R M = N ↔ Nonempty (M ≃ₗ[R] N) where
mp := (· ▸ ⟨(mk.linearEquiv R M).symm⟩)
mpr := fun ⟨e⟩ ↦ ((equivShrink _).apply_eq_iff_eq_symm_apply).mpr <|
Units.ext <| Quotient.mk_eq_iff_out.mpr ⟨(Finite.reprEquiv R M ≪≫ₗ e).toModuleIso⟩
theorem mk_eq_self {M : Pic R} : Pic.mk R M = M := mk_eq_iff.mpr ⟨.refl ..⟩
theorem ext_iff {M N : Pic R} : M = N ↔ Nonempty (M ≃ₗ[R] N) := by
rw [← mk_eq_iff, mk_eq_self]
theorem mk_eq_mk_iff : Pic.mk R M = Pic.mk R N ↔ Nonempty (M ≃ₗ[R] N) :=
let eN := mk.linearEquiv R N
mk_eq_iff.trans ⟨fun ⟨e⟩ ↦ ⟨e ≪≫ₗ eN⟩, fun ⟨e⟩ ↦ ⟨e ≪≫ₗ eN.symm⟩⟩
theorem mk_self : Pic.mk R R = 1 :=
congr_arg (equivShrink _) <| Units.ext <| Quotient.sound ⟨(Finite.reprEquiv R R).toModuleIso⟩
theorem mk_eq_one_iff : Pic.mk R M = 1 ↔ Nonempty (M ≃ₗ[R] R) := by
rw [← mk_self, mk_eq_mk_iff]
theorem mk_eq_one [Free R M] : Pic.mk R M = 1 :=
mk_eq_one_iff.mpr (Invertible.free_iff_linearEquiv.mp ‹_›)
theorem mk_tensor : Pic.mk R (M ⊗[R] N) = Pic.mk R M * Pic.mk R N :=
congr_arg (equivShrink _) <| Units.ext <| by
simp_rw [Pic.mk, Equiv.symm_apply_apply]
refine (Quotient.sound ?_).trans (Skeleton.toSkeleton_tensorObj ..)
exact ⟨(Finite.reprEquiv R _ ≪≫ₗ TensorProduct.congr
(Finite.reprEquiv R M).symm (Finite.reprEquiv R N).symm).toModuleIso⟩
theorem mk_dual : Pic.mk R (Dual R M) = (Pic.mk R M)⁻¹ :=
congr_arg (equivShrink _) <| Units.ext <| by
rw [Pic.mk, Equiv.symm_apply_apply]
exact Quotient.sound ⟨(Finite.reprEquiv R _ ≪≫ₗ (Finite.reprEquiv R _).dualMap).toModuleIso⟩
theorem inv_eq_dual (M : Pic R) : M⁻¹ = Pic.mk R (Dual R M) := by
rw [mk_dual, mk_eq_self]
theorem mul_eq_tensor (M N : Pic R) : M * N = Pic.mk R (M ⊗[R] N) := by
rw [mk_tensor, mk_eq_self, mk_eq_self]
theorem subsingleton_iff : Subsingleton (Pic R) ↔
∀ (M : Type u) [AddCommGroup M] [Module R M], Module.Invertible R M → Free R M :=
.trans ⟨fun _ M _ _ _ ↦ Subsingleton.elim ..,
fun h ↦ ⟨fun M N ↦ by rw [← mk_eq_self (M := M), ← mk_eq_self (M := N), h, h]⟩⟩ <|
forall₄_congr fun _ _ _ _ ↦ mk_eq_one_iff.trans Invertible.free_iff_linearEquiv.symm
instance [Subsingleton (Pic R)] : Free R M :=
have := subsingleton_iff.mp ‹_› (Finite.repr R M) inferInstance
.of_equiv (Finite.reprEquiv R M)
/- TODO: it's still true that an invertible module over a (commutative) local semiring is free;
in fact invertible modules over a semiring are Zariski-locally free.
See [BorgerJun2024], Theorem 11.7. -/
instance [IsLocalRing R] : Subsingleton (Pic R) :=
subsingleton_iff.mpr fun _ _ _ _ ↦ free_of_flat_of_isLocalRing
/-- The Picard group of a semilocal ring is trivial. -/
instance [Finite (MaximalSpectrum R)] : Subsingleton (Pic R) :=
subsingleton_iff.mpr fun _ _ _ _ ↦ free_of_flat_of_finrank_eq _ _ 1
fun _ ↦ let _ := @Ideal.Quotient.field; Invertible.finrank_eq_one ..
end CommRing.Pic
end CommRing
end PicardGroup
namespace Module.Invertible
variable (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] [Module.Invertible R M]
-- TODO: generalize to CommSemiring by generalizing `CommRing.Pic.instSubsingletonOfIsLocalRing`
theorem tensorProductComm_eq_refl : TensorProduct.comm R M M = .refl .. := by
let f (P : Ideal R) [P.IsMaximal] := LocalizedModule.mkLinearMap P.primeCompl M
let ff (P : Ideal R) [P.IsMaximal] := TensorProduct.map (f P) (f P)
refine LinearEquiv.toLinearMap_injective <| LinearMap.eq_of_localization_maximal _ ff _ ff _ _
fun P _ ↦ .trans (b := (TensorProduct.comm ..).toLinearMap) ?_ ?_
· apply IsLocalizedModule.linearMap_ext P.primeCompl (ff P) (ff P)
ext; dsimp
apply IsLocalizedModule.map_apply
let Rp := Localization P.primeCompl
have ⟨e⟩ := free_iff_linearEquiv.mp (inferInstance : Free Rp (LocalizedModule P.primeCompl M))
have e := e.restrictScalars R
ext x y
refine (congr e e ≪≫ₗ equivOfCompatibleSMul Rp ..).injective ?_
suffices e y ⊗ₜ[Rp] e x = e x ⊗ₜ e y by simpa [equivOfCompatibleSMul]
conv_lhs => rw [← mul_one (e y), ← smul_eq_mul, smul_tmul, smul_eq_mul,
mul_comm, ← smul_eq_mul, ← smul_tmul, smul_eq_mul, mul_one]
variable {R M} in
theorem tmul_comm {m₁ m₂ : M} : m₁ ⊗ₜ[R] m₂ = m₂ ⊗ₜ m₁ :=
DFunLike.congr_fun (tensorProductComm_eq_refl ..) (m₂ ⊗ₜ m₁)
end Module.Invertible
namespace Submodule
open Module Invertible
variable {R A : Type*} [CommSemiring R]
section Semiring
variable [Semiring A] [Algebra R A] [FaithfulSMul R A]
open LinearMap in
instance projective_unit (I : (Submodule R A)ˣ) : Projective R I := by
obtain ⟨T, T', hT, hT', one_mem⟩ := mem_span_mul_finite_of_mem_mul (I.inv_mul ▸ one_le.mp le_rfl)
classical
rw [← Set.image2_mul, ← Finset.coe_image₂, mem_span_finset] at one_mem
set S := T.image₂ (· * ·) T'
obtain ⟨r, hr⟩ := one_mem
choose a ha b hb eq using fun i : S ↦ Finset.mem_image₂.mp i.2
let f : I →ₗ[R] S → R := .pi fun i ↦ (LinearEquiv.ofInjective
(Algebra.linearMap R A) (FaithfulSMul.algebraMap_injective R A)).symm.comp <|
restrict (mulRight R (r i • a i)) fun x hx ↦ by
rw [← one_eq_range, ← I.mul_inv]; exact mul_mem_mul hx (I⁻¹.1.smul_mem _ <| hT <| ha i)
let g : (S → R) →ₗ[R] I := .lsum _ _ ℕ fun i ↦ .toSpanSingleton _ _ ⟨b i, hT' <| hb i⟩
refine .of_split f g (LinearMap.ext fun x ↦ Subtype.ext ?_)
simp only [f, g, lsum_apply, comp_apply, sum_apply, toSpanSingleton_apply, proj_apply, pi_apply]
simp_rw [restrict_apply, mulRight_apply, id_apply, coe_sum, coe_smul, Algebra.smul_def,
← Algebra.coe_linearMap, LinearEquiv.coe_toLinearMap, LinearEquiv.ofInjective_symm_apply,
mul_assoc, Algebra.coe_linearMap, ← Algebra.smul_def, ← Finset.mul_sum, eq,
(Finset.sum_coe_sort ..).trans hr.2, mul_one]
theorem projective_of_isUnit {I : Submodule R A} (hI : IsUnit I) : Projective R I :=
projective_unit hI.unit
end Semiring
section CommSemiring
variable [CommSemiring A] [Algebra R A] [FaithfulSMul R A]
(S : Submonoid R) [IsLocalization S A] (I J : (Submodule R A)ˣ)
/-- Given two invertible `R`-submodules in an `R`-algebra `A`, the `R`-linear map from
`I ⊗[R] J` to `I * J` induced by multiplication is an isomorphism. -/
noncomputable def tensorEquivMul : I ⊗[R] J ≃ₗ[R] I * J :=
.ofBijective (mulMap' ..) ⟨by
have := IsLocalization.flat A S
simpa [mulMap', mulMap_eq_mul'_comp_mapIncl] using
(IsLocalization.bijective_linearMap_mul' S A).1.comp
(Flat.tensorProduct_mapIncl_injective_of_left ..),
mulMap'_surjective _ _⟩
/-- Given an invertible `R`-submodule `I` in an `R`-algebra `A`, the `R`-linear map
from `I ⊗[R] I⁻¹` to `R` induced by multiplication is an isomorphism. -/
noncomputable def tensorInvEquiv : I ⊗[R] ↑I⁻¹ ≃ₗ[R] R :=
tensorEquivMul S I _ ≪≫ₗ .ofEq _ _ (I.mul_inv.trans one_eq_range) ≪≫ₗ
.symm (.ofInjective _ (FaithfulSMul.algebraMap_injective R A))
include S in
theorem _root_.Units.submodule_invertible : Module.Invertible R I := .left (tensorInvEquiv S I)
end CommSemiring
section CommRing
open CommRing Pic
variable (R A : Type*) [CommRing R] [CommRing A] [Algebra R A] [FaithfulSMul R A]
(S : Submonoid R) [IsLocalization S A]
/-- The group homomorphism from the invertible submodules
in a localization of `R` to the Picard group of `R`. -/
@[simps] noncomputable def unitsToPic : (Submodule R A)ˣ →* Pic R :=
haveI := Units.submodule_invertible S (A := A)
{ toFun I := Pic.mk R I
map_one' := mk_eq_one_iff.mpr
⟨.ofEq _ _ one_eq_range ≪≫ₗ .symm (.ofInjective _ (FaithfulSMul.algebraMap_injective R A))⟩
map_mul' I J := by rw [← mk_tensor, mk_eq_mk_iff]; exact ⟨(tensorEquivMul S I J).symm⟩ }
end CommRing
end Submodule |
.lake/packages/mathlib/Mathlib/RingTheory/Nakayama.lean | import Mathlib.RingTheory.Finiteness.Basic
import Mathlib.RingTheory.Finiteness.Nakayama
import Mathlib.RingTheory.Jacobson.Ideal
/-!
# Nakayama's lemma
This file contains some alternative statements of Nakayama's Lemma as found in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).
## Main statements
* `Submodule.eq_smul_of_le_smul_of_le_jacobson` - A version of (2) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV),
generalising to the Jacobson of any ideal.
* `Submodule.eq_bot_of_le_smul_of_le_jacobson_bot` - Statement (2) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).
* `Submodule.sup_smul_eq_sup_smul_of_le_smul_of_le_jacobson` - A version of (4) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV),
generalising to the Jacobson of any ideal.
* `Submodule.smul_le_of_le_smul_of_le_jacobson_bot` - Statement (4) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).
* `Submodule.le_span_of_map_mkQ_le_map_mkQ_span_of_le_jacobson_bot` - Statement (8) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV).
Note that a version of Statement (1) in
[Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV) can be found in
`RingTheory.Finiteness` under the name
`Submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul`
## References
* [Stacks: Nakayama's Lemma](https://stacks.math.columbia.edu/tag/00DV)
## Tags
Nakayama, Jacobson
-/
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]
open Ideal
namespace Submodule
/-- **Nakayama's Lemma** - A slightly more general version of (2) in
[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).
See also `eq_bot_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`. -/
@[stacks 00DV "(2)"]
theorem eq_smul_of_le_smul_of_le_jacobson {I J : Ideal R} {N : Submodule R M} (hN : N.FG)
(hIN : N ≤ I • N) (hIjac : I ≤ jacobson J) : N = J • N := by
refine le_antisymm ?_ (Submodule.smul_le.2 fun _ _ _ => Submodule.smul_mem _ _)
intro n hn
obtain ⟨r, hr⟩ := Submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul I N hN hIN
obtain ⟨s, hs⟩ := exists_mul_sub_mem_of_sub_one_mem_jacobson r (hIjac hr.1)
have : n = -(s * r - 1) • n := by
rw [neg_sub, sub_smul, mul_smul, hr.2 n hn, one_smul, smul_zero, sub_zero]
rw [this]
exact Submodule.smul_mem_smul (Submodule.neg_mem _ hs) hn
lemma eq_bot_of_eq_ideal_smul_of_le_jacobson_annihilator {I : Ideal R}
{N : Submodule R M} (hN : FG N) (hIN : N = I • N)
(hIjac : I ≤ N.annihilator.jacobson) : N = ⊥ :=
(eq_smul_of_le_smul_of_le_jacobson hN hIN.le hIjac).trans N.annihilator_smul
open Pointwise in
lemma eq_bot_of_eq_pointwise_smul_of_mem_jacobson_annihilator {r : R}
{N : Submodule R M} (hN : FG N) (hrN : N = r • N)
(hrJac : r ∈ N.annihilator.jacobson) : N = ⊥ :=
eq_bot_of_eq_ideal_smul_of_le_jacobson_annihilator hN
(Eq.trans hrN (ideal_span_singleton_smul r N).symm)
((span_singleton_le_iff_mem r _).mpr hrJac)
open Pointwise in
lemma eq_bot_of_set_smul_eq_of_subset_jacobson_annihilator {s : Set R}
{N : Submodule R M} (hN : FG N) (hsN : N = s • N)
(hsJac : s ⊆ N.annihilator.jacobson) : N = ⊥ :=
eq_bot_of_eq_ideal_smul_of_le_jacobson_annihilator hN
(Eq.trans hsN (span_smul_eq s N).symm) (span_le.mpr hsJac)
lemma top_ne_ideal_smul_of_le_jacobson_annihilator [Nontrivial M]
[Module.Finite R M] {I} (h : I ≤ (Module.annihilator R M).jacobson) :
(⊤ : Submodule R M) ≠ I • ⊤ := fun H => top_ne_bot <|
eq_bot_of_eq_ideal_smul_of_le_jacobson_annihilator Module.Finite.fg_top H <|
(congrArg (I ≤ Ideal.jacobson ·) annihilator_top).mpr h
open Pointwise in
lemma top_ne_set_smul_of_subset_jacobson_annihilator [Nontrivial M]
[Module.Finite R M] {s : Set R}
(h : s ⊆ (Module.annihilator R M).jacobson) :
(⊤ : Submodule R M) ≠ s • ⊤ :=
ne_of_ne_of_eq (top_ne_ideal_smul_of_le_jacobson_annihilator (span_le.mpr h))
(span_smul_eq _ _)
open Pointwise in
lemma top_ne_pointwise_smul_of_mem_jacobson_annihilator [Nontrivial M]
[Module.Finite R M] {r} (h : r ∈ (Module.annihilator R M).jacobson) :
(⊤ : Submodule R M) ≠ r • ⊤ :=
ne_of_ne_of_eq (top_ne_set_smul_of_subset_jacobson_annihilator <|
Set.singleton_subset_iff.mpr h) (singleton_set_smul ⊤ r)
/-- **Nakayama's Lemma** - Statement (2) in
[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).
See also `eq_smul_of_le_smul_of_le_jacobson` for a generalisation
to the `jacobson` of any ideal -/
@[stacks 00DV "(2)"]
theorem eq_bot_of_le_smul_of_le_jacobson_bot (I : Ideal R) (N : Submodule R M) (hN : N.FG)
(hIN : N ≤ I • N) (hIjac : I ≤ jacobson ⊥) : N = ⊥ := by
rw [eq_smul_of_le_smul_of_le_jacobson hN hIN hIjac, Submodule.bot_smul]
theorem sup_eq_sup_smul_of_le_smul_of_le_jacobson {I J : Ideal R} {N N' : Submodule R M}
(hN' : N'.FG) (hIJ : I ≤ jacobson J) (hNN : N' ≤ N ⊔ I • N') : N ⊔ N' = N ⊔ J • N' := by
have hNN' : N ⊔ N' = N ⊔ I • N' :=
le_antisymm (sup_le le_sup_left hNN)
(sup_le_sup_left (Submodule.smul_le.2 fun _ _ _ => Submodule.smul_mem _ _) _)
have h_comap :=
comap_injective_of_surjective (LinearMap.range_eq_top.1 N.range_mkQ)
have : (I • N').map N.mkQ = N'.map N.mkQ := by
simpa only [← h_comap.eq_iff, comap_map_mkQ, sup_comm, eq_comm] using hNN'
have :=
@Submodule.eq_smul_of_le_smul_of_le_jacobson _ _ _ _ _ I J (N'.map N.mkQ) (hN'.map _)
(by rw [← map_smul'', this]) hIJ
rwa [← map_smul'', ← h_comap.eq_iff, comap_map_eq, comap_map_eq, Submodule.ker_mkQ, sup_comm,
sup_comm (b := N)] at this
/-- **Nakayama's Lemma** - A slightly more general version of (4) in
[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).
See also `smul_le_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`. -/
@[stacks 00DV "(4)"]
theorem sup_smul_eq_sup_smul_of_le_smul_of_le_jacobson {I J : Ideal R} {N N' : Submodule R M}
(hN' : N'.FG) (hIJ : I ≤ jacobson J) (hNN : N' ≤ N ⊔ I • N') : N ⊔ I • N' = N ⊔ J • N' :=
((sup_le_sup_left smul_le_right _).antisymm (sup_le le_sup_left hNN)).trans
(sup_eq_sup_smul_of_le_smul_of_le_jacobson hN' hIJ hNN)
theorem le_of_le_smul_of_le_jacobson_bot {R M} [CommRing R] [AddCommGroup M] [Module R M]
{I : Ideal R} {N N' : Submodule R M} (hN' : N'.FG)
(hIJ : I ≤ jacobson ⊥) (hNN : N' ≤ N ⊔ I • N') : N' ≤ N := by
rw [← sup_eq_left, sup_eq_sup_smul_of_le_smul_of_le_jacobson hN' hIJ hNN, bot_smul, sup_bot_eq]
/-- **Nakayama's Lemma** - Statement (4) in
[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV).
See also `sup_smul_eq_sup_smul_of_le_smul_of_le_jacobson` for a generalisation
to the `jacobson` of any ideal -/
@[stacks 00DV "(4)"]
theorem smul_le_of_le_smul_of_le_jacobson_bot {I : Ideal R} {N N' : Submodule R M} (hN' : N'.FG)
(hIJ : I ≤ jacobson ⊥) (hNN : N' ≤ N ⊔ I • N') : I • N' ≤ N :=
smul_le_right.trans (le_of_le_smul_of_le_jacobson_bot hN' hIJ hNN)
open Pointwise in
@[stacks 00DV "(3) see `Submodule.localized₀_le_localized₀_of_smul_le` for the second conclusion."]
lemma exists_sub_one_mem_and_smul_le_of_fg_of_le_sup {I : Ideal R}
{N N' P : Submodule R M} (hN' : N'.FG) (hN'le : N' ≤ P) (hNN' : P ≤ N ⊔ I • N') :
∃ r : R, r - 1 ∈ I ∧ r • P ≤ N := by
have hNN'' : P ≤ N ⊔ N' := le_trans hNN' (by simpa using le_trans smul_le_right le_sup_right)
have h1 : P.map N.mkQ = N'.map N.mkQ := by
refine le_antisymm ?_ (map_mono hN'le)
simpa using map_mono (f := N.mkQ) hNN''
have h2 : P.map N.mkQ = (I • N').map N.mkQ := by
apply le_antisymm
· simpa using map_mono (f := N.mkQ) hNN'
· rw [h1]
simp [smul_le_right]
have hle : (P.map N.mkQ) ≤ I • P.map N.mkQ := by
conv_lhs => rw [h2]
simp [← h1]
obtain ⟨r, hmem, hr⟩ := exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul I _
(h1 ▸ hN'.map _) hle
refine ⟨r, hmem, fun x hx ↦ ?_⟩
induction hx using Submodule.smul_inductionOn_pointwise with
| smul₀ p hp =>
rw [← Submodule.Quotient.mk_eq_zero, Quotient.mk_smul]
exact hr _ ⟨p, hp, rfl⟩
| smul₁ _ _ _ h => exact N.smul_mem _ h
| add _ _ _ _ hx hy => exact N.add_mem hx hy
| zero => exact N.zero_mem
/-- **Nakayama's Lemma** - Statement (8) in
[Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV). -/
@[stacks 00DV "(8)"]
theorem le_span_of_map_mkQ_le_map_mkQ_span_of_le_jacobson_bot
{I : Ideal R} {N : Submodule R M} {t : Set M}
(hN : N.FG) (hIjac : I ≤ jacobson ⊥) (htspan : map (I • N).mkQ N ≤ map (I • N).mkQ (span R t)) :
N ≤ span R t := by
apply le_of_le_smul_of_le_jacobson_bot hN hIjac
apply_fun comap (I • N).mkQ at htspan
on_goal 2 => apply Submodule.comap_mono
simp only [comap_map_mkQ] at htspan
grw [sup_comm, ← htspan]
simp only [le_sup_right]
end Submodule |
.lake/packages/mathlib/Mathlib/RingTheory/Multiplicity.lean | import Mathlib.Algebra.GroupWithZero.Associated
import Mathlib.Algebra.Ring.Divisibility.Basic
import Mathlib.Algebra.Ring.Int.Defs
import Mathlib.Data.ENat.Basic
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
/-!
# Multiplicity of a divisor
For a commutative monoid, this file introduces the notion of multiplicity of a divisor and proves
several basic results on it.
## Main definitions
* `emultiplicity a b`: for two elements `a` and `b` of a commutative monoid returns the largest
number `n` such that `a ^ n ∣ b` or infinity, written `⊤`, if `a ^ n ∣ b` for all natural numbers
`n`.
* `multiplicity a b`: a `ℕ`-valued version of `multiplicity`, defaulting for `1` instead of `⊤`.
The reason for using `1` as a default value instead of `0` is to have `multiplicity_eq_zero_iff`.
* `FiniteMultiplicity a b`: a predicate denoting that the multiplicity of `a` in `b` is finite.
-/
assert_not_exists Field
variable {α β : Type*}
open Nat
/-- `FiniteMultiplicity a b` indicates that the multiplicity of `a` in `b` is finite. -/
abbrev FiniteMultiplicity [Monoid α] (a b : α) : Prop :=
∃ n : ℕ, ¬a ^ (n + 1) ∣ b
open scoped Classical in
/-- `emultiplicity a b` returns the largest natural number `n` such that
`a ^ n ∣ b`, as an `ℕ∞`. If `∀ n, a ^ n ∣ b` then it returns `⊤`. -/
noncomputable def emultiplicity [Monoid α] (a b : α) : ℕ∞ :=
if h : FiniteMultiplicity a b then Nat.find h else ⊤
/-- A `ℕ`-valued version of `emultiplicity`, returning `1` instead of `⊤`. -/
noncomputable def multiplicity [Monoid α] (a b : α) : ℕ :=
(emultiplicity a b).untopD 1
section Monoid
variable [Monoid α] [Monoid β] {a b : α}
@[simp]
theorem emultiplicity_eq_top :
emultiplicity a b = ⊤ ↔ ¬FiniteMultiplicity a b := by
simp [emultiplicity]
theorem emultiplicity_lt_top {a b : α} : emultiplicity a b < ⊤ ↔ FiniteMultiplicity a b := by
simp [lt_top_iff_ne_top, emultiplicity_eq_top]
theorem finiteMultiplicity_iff_emultiplicity_ne_top :
FiniteMultiplicity a b ↔ emultiplicity a b ≠ ⊤ := by simp
theorem finiteMultiplicity_of_emultiplicity_eq_natCast {n : ℕ} (h : emultiplicity a b = n) :
FiniteMultiplicity a b := by
by_contra nh
rw [← emultiplicity_eq_top, h] at nh
trivial
theorem multiplicity_eq_of_emultiplicity_eq_some {n : ℕ} (h : emultiplicity a b = n) :
multiplicity a b = n := by
simp [multiplicity, h]
rfl
theorem emultiplicity_ne_of_multiplicity_ne {n : ℕ} :
multiplicity a b ≠ n → emultiplicity a b ≠ n :=
mt multiplicity_eq_of_emultiplicity_eq_some
theorem FiniteMultiplicity.emultiplicity_eq_multiplicity (h : FiniteMultiplicity a b) :
emultiplicity a b = multiplicity a b := by
cases hm : emultiplicity a b
· simp [h] at hm
rw [multiplicity_eq_of_emultiplicity_eq_some hm]
theorem FiniteMultiplicity.emultiplicity_eq_iff_multiplicity_eq {n : ℕ}
(h : FiniteMultiplicity a b) : emultiplicity a b = n ↔ multiplicity a b = n := by
simp [h.emultiplicity_eq_multiplicity]
theorem emultiplicity_eq_iff_multiplicity_eq_of_ne_one {n : ℕ} (h : n ≠ 1) :
emultiplicity a b = n ↔ multiplicity a b = n := by
constructor
· exact multiplicity_eq_of_emultiplicity_eq_some
· intro h₂
simpa [multiplicity, WithTop.untopD_eq_iff, h] using h₂
theorem emultiplicity_eq_zero_iff_multiplicity_eq_zero :
emultiplicity a b = 0 ↔ multiplicity a b = 0 :=
emultiplicity_eq_iff_multiplicity_eq_of_ne_one zero_ne_one
@[simp]
theorem multiplicity_eq_one_of_not_finiteMultiplicity (h : ¬FiniteMultiplicity a b) :
multiplicity a b = 1 := by
simp [multiplicity, emultiplicity_eq_top.2 h]
@[simp]
theorem multiplicity_le_emultiplicity :
multiplicity a b ≤ emultiplicity a b := by
by_cases hf : FiniteMultiplicity a b
· simp [hf.emultiplicity_eq_multiplicity]
· simp [hf, emultiplicity_eq_top.2]
-- Cannot be @[simp] because `β`, `c`, and `d` cannot be inferred by `simp`.
theorem multiplicity_eq_of_emultiplicity_eq {c d : β}
(h : emultiplicity a b = emultiplicity c d) : multiplicity a b = multiplicity c d := by
unfold multiplicity
rw [h]
theorem multiplicity_le_of_emultiplicity_le {n : ℕ} (h : emultiplicity a b ≤ n) :
multiplicity a b ≤ n := by
exact_mod_cast multiplicity_le_emultiplicity.trans h
theorem FiniteMultiplicity.emultiplicity_le_of_multiplicity_le (hfin : FiniteMultiplicity a b)
{n : ℕ} (h : multiplicity a b ≤ n) : emultiplicity a b ≤ n := by
rw [emultiplicity_eq_multiplicity hfin]
assumption_mod_cast
theorem le_emultiplicity_of_le_multiplicity {n : ℕ} (h : n ≤ multiplicity a b) :
n ≤ emultiplicity a b := by
exact_mod_cast (WithTop.coe_mono h).trans multiplicity_le_emultiplicity
theorem FiniteMultiplicity.le_multiplicity_of_le_emultiplicity (hfin : FiniteMultiplicity a b)
{n : ℕ} (h : n ≤ emultiplicity a b) : n ≤ multiplicity a b := by
rw [emultiplicity_eq_multiplicity hfin] at h
assumption_mod_cast
theorem multiplicity_lt_of_emultiplicity_lt {n : ℕ} (h : emultiplicity a b < n) :
multiplicity a b < n := by
exact_mod_cast multiplicity_le_emultiplicity.trans_lt h
theorem FiniteMultiplicity.emultiplicity_lt_of_multiplicity_lt (hfin : FiniteMultiplicity a b)
{n : ℕ} (h : multiplicity a b < n) : emultiplicity a b < n := by
rw [emultiplicity_eq_multiplicity hfin]
assumption_mod_cast
theorem lt_emultiplicity_of_lt_multiplicity {n : ℕ} (h : n < multiplicity a b) :
n < emultiplicity a b := by
exact_mod_cast (WithTop.coe_strictMono h).trans_le multiplicity_le_emultiplicity
theorem FiniteMultiplicity.lt_multiplicity_of_lt_emultiplicity (hfin : FiniteMultiplicity a b)
{n : ℕ} (h : n < emultiplicity a b) : n < multiplicity a b := by
rw [emultiplicity_eq_multiplicity hfin] at h
assumption_mod_cast
theorem emultiplicity_pos_iff :
0 < emultiplicity a b ↔ 0 < multiplicity a b := by
simp [pos_iff_ne_zero, pos_iff_ne_zero, emultiplicity_eq_zero_iff_multiplicity_eq_zero]
theorem FiniteMultiplicity.def : FiniteMultiplicity a b ↔ ∃ n : ℕ, ¬a ^ (n + 1) ∣ b :=
Iff.rfl
theorem FiniteMultiplicity.not_dvd_of_one_right : FiniteMultiplicity a 1 → ¬a ∣ 1 :=
fun ⟨n, hn⟩ ⟨d, hd⟩ => hn ⟨d ^ (n + 1), (pow_mul_pow_eq_one (n + 1) hd.symm).symm⟩
@[norm_cast]
theorem Int.natCast_emultiplicity (a b : ℕ) :
emultiplicity (a : ℤ) (b : ℤ) = emultiplicity a b := by
unfold emultiplicity FiniteMultiplicity
congr! <;> norm_cast
@[norm_cast]
theorem Int.natCast_multiplicity (a b : ℕ) : multiplicity (a : ℤ) (b : ℤ) = multiplicity a b :=
multiplicity_eq_of_emultiplicity_eq (natCast_emultiplicity a b)
theorem FiniteMultiplicity.not_iff_forall : ¬FiniteMultiplicity a b ↔ ∀ n : ℕ, a ^ n ∣ b :=
⟨fun h n =>
Nat.casesOn n
(by
rw [_root_.pow_zero]
exact one_dvd _)
(by simpa [FiniteMultiplicity] using h),
by simp [FiniteMultiplicity]; tauto⟩
theorem FiniteMultiplicity.not_unit (h : FiniteMultiplicity a b) : ¬IsUnit a :=
let ⟨n, hn⟩ := h
hn ∘ IsUnit.dvd ∘ IsUnit.pow (n + 1)
theorem FiniteMultiplicity.mul_left {c : α} :
FiniteMultiplicity a (b * c) → FiniteMultiplicity a b := fun ⟨n, hn⟩ =>
⟨n, fun h => hn (h.trans (dvd_mul_right _ _))⟩
theorem pow_dvd_of_le_emultiplicity {k : ℕ} (hk : k ≤ emultiplicity a b) :
a ^ k ∣ b := by classical
cases k
· simp
unfold emultiplicity at hk
split at hk
· norm_cast at hk
simpa using (Nat.find_min _ (lt_of_succ_le hk))
· apply FiniteMultiplicity.not_iff_forall.mp ‹_›
theorem pow_dvd_of_le_multiplicity {k : ℕ} (hk : k ≤ multiplicity a b) :
a ^ k ∣ b := pow_dvd_of_le_emultiplicity (le_emultiplicity_of_le_multiplicity hk)
@[simp]
theorem pow_multiplicity_dvd (a b : α) : a ^ (multiplicity a b) ∣ b :=
pow_dvd_of_le_multiplicity le_rfl
theorem not_pow_dvd_of_emultiplicity_lt {m : ℕ} (hm : emultiplicity a b < m) :
¬a ^ m ∣ b := fun nh => by
unfold emultiplicity at hm
split at hm
· simp only [cast_lt, find_lt_iff] at hm
obtain ⟨n, hn1, hn2⟩ := hm
exact hn2 ((pow_dvd_pow _ hn1).trans nh)
· simp at hm
theorem FiniteMultiplicity.not_pow_dvd_of_multiplicity_lt (hf : FiniteMultiplicity a b) {m : ℕ}
(hm : multiplicity a b < m) : ¬a ^ m ∣ b := by
apply not_pow_dvd_of_emultiplicity_lt
rw [hf.emultiplicity_eq_multiplicity]
norm_cast
theorem multiplicity_pos_of_dvd (hdiv : a ∣ b) : 0 < multiplicity a b := by
refine Nat.pos_iff_ne_zero.2 fun h => ?_
simpa [hdiv] using FiniteMultiplicity.not_pow_dvd_of_multiplicity_lt
(by by_contra! nh; simp [nh] at h) (lt_one_iff.mpr h)
theorem emultiplicity_pos_of_dvd (hdiv : a ∣ b) : 0 < emultiplicity a b :=
lt_emultiplicity_of_lt_multiplicity (multiplicity_pos_of_dvd hdiv)
theorem emultiplicity_eq_of_dvd_of_not_dvd {k : ℕ} (hk : a ^ k ∣ b) (hsucc : ¬a ^ (k + 1) ∣ b) :
emultiplicity a b = k := by classical
have : FiniteMultiplicity a b := ⟨k, hsucc⟩
simp only [emultiplicity, this, ↓reduceDIte, Nat.cast_inj, find_eq_iff, hsucc, not_false_eq_true,
Decidable.not_not, true_and]
exact fun n hn ↦ (pow_dvd_pow _ hn).trans hk
theorem multiplicity_eq_of_dvd_of_not_dvd {k : ℕ} (hk : a ^ k ∣ b) (hsucc : ¬a ^ (k + 1) ∣ b) :
multiplicity a b = k :=
multiplicity_eq_of_emultiplicity_eq_some (emultiplicity_eq_of_dvd_of_not_dvd hk hsucc)
theorem le_emultiplicity_of_pow_dvd {k : ℕ} (hk : a ^ k ∣ b) :
k ≤ emultiplicity a b :=
le_of_not_gt fun hk' => not_pow_dvd_of_emultiplicity_lt hk' hk
theorem FiniteMultiplicity.le_multiplicity_of_pow_dvd (hf : FiniteMultiplicity a b)
{k : ℕ} (hk : a ^ k ∣ b) : k ≤ multiplicity a b :=
hf.le_multiplicity_of_le_emultiplicity (le_emultiplicity_of_pow_dvd hk)
theorem pow_dvd_iff_le_emultiplicity {k : ℕ} :
a ^ k ∣ b ↔ k ≤ emultiplicity a b :=
⟨le_emultiplicity_of_pow_dvd, pow_dvd_of_le_emultiplicity⟩
theorem FiniteMultiplicity.pow_dvd_iff_le_multiplicity (hf : FiniteMultiplicity a b) {k : ℕ} :
a ^ k ∣ b ↔ k ≤ multiplicity a b := by
exact_mod_cast hf.emultiplicity_eq_multiplicity ▸ pow_dvd_iff_le_emultiplicity
theorem emultiplicity_lt_iff_not_dvd {k : ℕ} :
emultiplicity a b < k ↔ ¬a ^ k ∣ b := by rw [pow_dvd_iff_le_emultiplicity, not_le]
theorem FiniteMultiplicity.multiplicity_lt_iff_not_dvd {k : ℕ} (hf : FiniteMultiplicity a b) :
multiplicity a b < k ↔ ¬a ^ k ∣ b := by rw [hf.pow_dvd_iff_le_multiplicity, not_le]
theorem emultiplicity_eq_coe {n : ℕ} :
emultiplicity a b = n ↔ a ^ n ∣ b ∧ ¬a ^ (n + 1) ∣ b := by
constructor
· intro h
constructor
· apply pow_dvd_of_le_emultiplicity
simp [h]
· apply not_pow_dvd_of_emultiplicity_lt
rw [h]
norm_cast
simp
· rw [and_imp]
apply emultiplicity_eq_of_dvd_of_not_dvd
theorem FiniteMultiplicity.multiplicity_eq_iff (hf : FiniteMultiplicity a b) {n : ℕ} :
multiplicity a b = n ↔ a ^ n ∣ b ∧ ¬a ^ (n + 1) ∣ b := by
simp [← emultiplicity_eq_coe, hf.emultiplicity_eq_multiplicity]
theorem emultiplicity_eq_ofNat {a b n : ℕ} [n.AtLeastTwo] :
emultiplicity a b = (ofNat(n) : ℕ∞) ↔ a ^ ofNat(n) ∣ b ∧ ¬a ^ (ofNat(n) + 1) ∣ b :=
emultiplicity_eq_coe
@[simp]
theorem FiniteMultiplicity.not_of_isUnit_left (b : α) (ha : IsUnit a) : ¬FiniteMultiplicity a b :=
(·.not_unit ha)
theorem FiniteMultiplicity.not_of_one_left (b : α) : ¬ FiniteMultiplicity 1 b := by simp
@[simp]
theorem emultiplicity_one_left (b : α) : emultiplicity 1 b = ⊤ :=
emultiplicity_eq_top.2 (FiniteMultiplicity.not_of_one_left _)
@[simp]
theorem FiniteMultiplicity.one_right (ha : FiniteMultiplicity a 1) : multiplicity a 1 = 0 := by
simp [ha.multiplicity_eq_iff, ha.not_dvd_of_one_right]
theorem FiniteMultiplicity.not_of_unit_left (a : α) (u : αˣ) : ¬ FiniteMultiplicity (u : α) a :=
FiniteMultiplicity.not_of_isUnit_left a u.isUnit
theorem emultiplicity_eq_zero :
emultiplicity a b = 0 ↔ ¬a ∣ b := by
by_cases hf : FiniteMultiplicity a b
· rw [← ENat.coe_zero, emultiplicity_eq_coe]
simp
· simpa [emultiplicity_eq_top.2 hf] using FiniteMultiplicity.not_iff_forall.1 hf 1
theorem multiplicity_eq_zero :
multiplicity a b = 0 ↔ ¬a ∣ b :=
(emultiplicity_eq_iff_multiplicity_eq_of_ne_one zero_ne_one).symm.trans emultiplicity_eq_zero
theorem emultiplicity_ne_zero :
emultiplicity a b ≠ 0 ↔ a ∣ b := by
simp [emultiplicity_eq_zero]
theorem multiplicity_ne_zero :
multiplicity a b ≠ 0 ↔ a ∣ b := by
simp [multiplicity_eq_zero]
theorem FiniteMultiplicity.exists_eq_pow_mul_and_not_dvd (hfin : FiniteMultiplicity a b) :
∃ c : α, b = a ^ multiplicity a b * c ∧ ¬a ∣ c := by
obtain ⟨c, hc⟩ := pow_multiplicity_dvd a b
refine ⟨c, hc, ?_⟩
rintro ⟨k, hk⟩
rw [hk, ← mul_assoc, ← _root_.pow_succ] at hc
have h₁ : a ^ (multiplicity a b + 1) ∣ b := ⟨k, hc⟩
exact (hfin.multiplicity_eq_iff.1 (by simp)).2 h₁
theorem emultiplicity_le_emultiplicity_iff {c d : β} :
emultiplicity a b ≤ emultiplicity c d ↔ ∀ n : ℕ, a ^ n ∣ b → c ^ n ∣ d := by classical
constructor
· exact fun h n hab ↦ pow_dvd_of_le_emultiplicity (le_trans (le_emultiplicity_of_pow_dvd hab) h)
· intro h
unfold emultiplicity
-- aesop? says
split
next h_1 =>
obtain ⟨w, h_1⟩ := h_1
split
next h_2 =>
simp_all only [cast_le, le_find_iff, lt_find_iff, Decidable.not_not, le_refl,
not_true_eq_false, not_false_eq_true, implies_true]
next h_2 => simp_all only [not_exists, Decidable.not_not, le_top]
next h_1 =>
simp_all only [not_exists, Decidable.not_not, not_true_eq_false, top_le_iff,
dite_eq_right_iff, ENat.coe_ne_top, imp_false, not_false_eq_true, implies_true]
theorem FiniteMultiplicity.multiplicity_le_multiplicity_iff {c d : β} (hab : FiniteMultiplicity a b)
(hcd : FiniteMultiplicity c d) :
multiplicity a b ≤ multiplicity c d ↔ ∀ n : ℕ, a ^ n ∣ b → c ^ n ∣ d := by
rw [← WithTop.coe_le_coe, ENat.some_eq_coe, ← hab.emultiplicity_eq_multiplicity,
← hcd.emultiplicity_eq_multiplicity]
apply emultiplicity_le_emultiplicity_iff
theorem emultiplicity_eq_emultiplicity_iff {c d : β} :
emultiplicity a b = emultiplicity c d ↔ ∀ n : ℕ, a ^ n ∣ b ↔ c ^ n ∣ d :=
⟨fun h n =>
⟨emultiplicity_le_emultiplicity_iff.1 h.le n, emultiplicity_le_emultiplicity_iff.1 h.ge n⟩,
fun h => le_antisymm (emultiplicity_le_emultiplicity_iff.2 fun n => (h n).mp)
(emultiplicity_le_emultiplicity_iff.2 fun n => (h n).mpr)⟩
theorem le_emultiplicity_map {F : Type*} [FunLike F α β] [MonoidHomClass F α β]
(f : F) {a b : α} :
emultiplicity a b ≤ emultiplicity (f a) (f b) :=
emultiplicity_le_emultiplicity_iff.2 fun n ↦ by rw [← map_pow]; exact map_dvd f
theorem emultiplicity_map_eq {F : Type*} [EquivLike F α β] [MulEquivClass F α β]
(f : F) {a b : α} : emultiplicity (f a) (f b) = emultiplicity a b := by
simp [emultiplicity_eq_emultiplicity_iff, ← map_pow, map_dvd_iff]
theorem multiplicity_map_eq {F : Type*} [EquivLike F α β] [MulEquivClass F α β]
(f : F) {a b : α} : multiplicity (f a) (f b) = multiplicity a b :=
multiplicity_eq_of_emultiplicity_eq (emultiplicity_map_eq f)
theorem emultiplicity_le_emultiplicity_of_dvd_right {a b c : α} (h : b ∣ c) :
emultiplicity a b ≤ emultiplicity a c :=
emultiplicity_le_emultiplicity_iff.2 fun _ hb => hb.trans h
theorem emultiplicity_eq_of_associated_right {a b c : α} (h : Associated b c) :
emultiplicity a b = emultiplicity a c :=
le_antisymm (emultiplicity_le_emultiplicity_of_dvd_right h.dvd)
(emultiplicity_le_emultiplicity_of_dvd_right h.symm.dvd)
theorem multiplicity_eq_of_associated_right {a b c : α} (h : Associated b c) :
multiplicity a b = multiplicity a c :=
multiplicity_eq_of_emultiplicity_eq (emultiplicity_eq_of_associated_right h)
theorem dvd_of_emultiplicity_pos {a b : α} (h : 0 < emultiplicity a b) : a ∣ b :=
pow_one a ▸ pow_dvd_of_le_emultiplicity (Order.add_one_le_of_lt h)
theorem dvd_of_multiplicity_pos {a b : α} (h : 0 < multiplicity a b) : a ∣ b :=
dvd_of_emultiplicity_pos (lt_emultiplicity_of_lt_multiplicity h)
theorem dvd_iff_multiplicity_pos {a b : α} : 0 < multiplicity a b ↔ a ∣ b :=
⟨dvd_of_multiplicity_pos, fun hdvd => Nat.pos_of_ne_zero (by simpa [multiplicity_eq_zero])⟩
theorem dvd_iff_emultiplicity_pos {a b : α} : 0 < emultiplicity a b ↔ a ∣ b :=
emultiplicity_pos_iff.trans dvd_iff_multiplicity_pos
theorem Nat.finiteMultiplicity_iff {a b : ℕ} : FiniteMultiplicity a b ↔ a ≠ 1 ∧ 0 < b := by
rw [← not_iff_not, FiniteMultiplicity.not_iff_forall, not_and_or, not_ne_iff, not_lt,
Nat.le_zero]
exact
⟨fun h =>
or_iff_not_imp_right.2 fun hb =>
have ha : a ≠ 0 := fun ha => hb <| zero_dvd_iff.mp <| by rw [ha] at h; exact h 1
Classical.by_contradiction fun ha1 : a ≠ 1 =>
have ha_gt_one : 1 < a :=
lt_of_not_ge fun _ =>
match a with
| 0 => ha rfl
| 1 => ha1 rfl
| b+2 => by cutsat
not_lt_of_ge (le_of_dvd (Nat.pos_of_ne_zero hb) (h b)) (b.lt_pow_self ha_gt_one),
fun h => by cases h <;> simp [*]⟩
alias ⟨_, Dvd.multiplicity_pos⟩ := dvd_iff_multiplicity_pos
end Monoid
section CommMonoid
variable [CommMonoid α]
theorem FiniteMultiplicity.mul_right {a b c : α} (hf : FiniteMultiplicity a (b * c)) :
FiniteMultiplicity a c := (mul_comm b c ▸ hf).mul_left
theorem emultiplicity_of_isUnit_right {a b : α} (ha : ¬IsUnit a)
(hb : IsUnit b) : emultiplicity a b = 0 :=
emultiplicity_eq_zero.mpr fun h ↦ ha (isUnit_of_dvd_unit h hb)
theorem multiplicity_of_isUnit_right {a b : α} (ha : ¬IsUnit a)
(hb : IsUnit b) : multiplicity a b = 0 :=
multiplicity_eq_zero.mpr fun h ↦ ha (isUnit_of_dvd_unit h hb)
theorem emultiplicity_of_one_right {a : α} (ha : ¬IsUnit a) : emultiplicity a 1 = 0 :=
emultiplicity_of_isUnit_right ha isUnit_one
theorem multiplicity_of_one_right {a : α} (ha : ¬IsUnit a) : multiplicity a 1 = 0 :=
multiplicity_of_isUnit_right ha isUnit_one
theorem emultiplicity_of_unit_right {a : α} (ha : ¬IsUnit a) (u : αˣ) : emultiplicity a u = 0 :=
emultiplicity_of_isUnit_right ha u.isUnit
theorem multiplicity_of_unit_right {a : α} (ha : ¬IsUnit a) (u : αˣ) : multiplicity a u = 0 :=
multiplicity_of_isUnit_right ha u.isUnit
theorem emultiplicity_le_emultiplicity_of_dvd_left {a b c : α} (hdvd : a ∣ b) :
emultiplicity b c ≤ emultiplicity a c :=
emultiplicity_le_emultiplicity_iff.2 fun n h => (pow_dvd_pow_of_dvd hdvd n).trans h
theorem emultiplicity_eq_of_associated_left {a b c : α} (h : Associated a b) :
emultiplicity b c = emultiplicity a c :=
le_antisymm (emultiplicity_le_emultiplicity_of_dvd_left h.dvd)
(emultiplicity_le_emultiplicity_of_dvd_left h.symm.dvd)
theorem multiplicity_eq_of_associated_left {a b c : α} (h : Associated a b) :
multiplicity b c = multiplicity a c :=
multiplicity_eq_of_emultiplicity_eq (emultiplicity_eq_of_associated_left h)
theorem emultiplicity_mk_eq_emultiplicity {a b : α} :
emultiplicity (Associates.mk a) (Associates.mk b) = emultiplicity a b := by
simp [emultiplicity_eq_emultiplicity_iff, ← Associates.mk_pow, Associates.mk_dvd_mk]
end CommMonoid
section MonoidWithZero
variable [MonoidWithZero α]
theorem FiniteMultiplicity.ne_zero {a b : α} (h : FiniteMultiplicity a b) : b ≠ 0 :=
let ⟨n, hn⟩ := h
fun hb => by simp [hb] at hn
@[simp]
theorem emultiplicity_zero (a : α) : emultiplicity a 0 = ⊤ :=
emultiplicity_eq_top.2 (fun v ↦ v.ne_zero rfl)
@[simp]
theorem emultiplicity_zero_eq_zero_of_ne_zero (a : α) (ha : a ≠ 0) : emultiplicity 0 a = 0 :=
emultiplicity_eq_zero.2 <| mt zero_dvd_iff.1 ha
@[simp]
theorem multiplicity_zero_eq_zero_of_ne_zero (a : α) (ha : a ≠ 0) : multiplicity 0 a = 0 :=
multiplicity_eq_zero.2 <| mt zero_dvd_iff.1 ha
end MonoidWithZero
section Semiring
variable [Semiring α]
theorem FiniteMultiplicity.or_of_add {p a b : α} (hf : FiniteMultiplicity p (a + b)) :
FiniteMultiplicity p a ∨ FiniteMultiplicity p b := by
by_contra! nh
obtain ⟨c, hc⟩ := hf
simp_all [dvd_add]
theorem min_le_emultiplicity_add {p a b : α} :
min (emultiplicity p a) (emultiplicity p b) ≤ emultiplicity p (a + b) := by
cases hm : min (emultiplicity p a) (emultiplicity p b)
· simp only [top_le_iff, min_eq_top, emultiplicity_eq_top] at hm ⊢
contrapose hm
simp only [not_and_or, not_not] at hm ⊢
exact hm.or_of_add
· apply le_emultiplicity_of_pow_dvd
simp [dvd_add, pow_dvd_of_le_emultiplicity, ← hm]
end Semiring
section Ring
variable [Ring α]
@[simp]
theorem FiniteMultiplicity.neg_iff {a b : α} :
FiniteMultiplicity a (-b) ↔ FiniteMultiplicity a b := by
unfold FiniteMultiplicity
congr! 3
simp only [dvd_neg]
alias ⟨_, FiniteMultiplicity.neg⟩ := FiniteMultiplicity.neg_iff
@[simp]
theorem emultiplicity_neg (a b : α) : emultiplicity a (-b) = emultiplicity a b := by
rw [emultiplicity_eq_emultiplicity_iff]
simp
@[simp]
theorem multiplicity_neg (a b : α) : multiplicity a (-b) = multiplicity a b :=
multiplicity_eq_of_emultiplicity_eq (emultiplicity_neg a b)
theorem Int.emultiplicity_natAbs (a : ℕ) (b : ℤ) :
emultiplicity a b.natAbs = emultiplicity (a : ℤ) b := by
rcases Int.natAbs_eq b with h | h <;> conv_rhs => rw [h]
· rw [Int.natCast_emultiplicity]
· rw [emultiplicity_neg, Int.natCast_emultiplicity]
theorem Int.multiplicity_natAbs (a : ℕ) (b : ℤ) :
multiplicity a b.natAbs = multiplicity (a : ℤ) b :=
multiplicity_eq_of_emultiplicity_eq (Int.emultiplicity_natAbs a b)
theorem emultiplicity_add_of_gt {p a b : α} (h : emultiplicity p b < emultiplicity p a) :
emultiplicity p (a + b) = emultiplicity p b := by
have : FiniteMultiplicity p b := finiteMultiplicity_iff_emultiplicity_ne_top.2 (by simp [·] at h)
rw [this.emultiplicity_eq_multiplicity] at *
apply emultiplicity_eq_of_dvd_of_not_dvd
· apply dvd_add
· apply pow_dvd_of_le_emultiplicity
exact h.le
· simp
· rw [dvd_add_right]
· apply this.not_pow_dvd_of_multiplicity_lt
simp
apply pow_dvd_of_le_emultiplicity
exact Order.add_one_le_of_lt h
theorem FiniteMultiplicity.multiplicity_add_of_gt {p a b : α} (hf : FiniteMultiplicity p b)
(h : multiplicity p b < multiplicity p a) :
multiplicity p (a + b) = multiplicity p b :=
multiplicity_eq_of_emultiplicity_eq <| emultiplicity_add_of_gt (hf.emultiplicity_eq_multiplicity ▸
(WithTop.coe_strictMono h).trans_le multiplicity_le_emultiplicity)
theorem emultiplicity_sub_of_gt {p a b : α} (h : emultiplicity p b < emultiplicity p a) :
emultiplicity p (a - b) = emultiplicity p b := by
rw [sub_eq_add_neg, emultiplicity_add_of_gt] <;> rw [emultiplicity_neg]; assumption
theorem multiplicity_sub_of_gt {p a b : α} (h : multiplicity p b < multiplicity p a)
(hfin : FiniteMultiplicity p b) : multiplicity p (a - b) = multiplicity p b := by
rw [sub_eq_add_neg, hfin.neg.multiplicity_add_of_gt] <;> rw [multiplicity_neg]; assumption
theorem emultiplicity_add_eq_min {p a b : α}
(h : emultiplicity p a ≠ emultiplicity p b) :
emultiplicity p (a + b) = min (emultiplicity p a) (emultiplicity p b) := by
rcases lt_trichotomy (emultiplicity p a) (emultiplicity p b) with (hab | _ | hab)
· rw [add_comm, emultiplicity_add_of_gt hab, min_eq_left]
exact le_of_lt hab
· contradiction
· rw [emultiplicity_add_of_gt hab, min_eq_right]
exact le_of_lt hab
theorem multiplicity_add_eq_min {p a b : α} (ha : FiniteMultiplicity p a)
(hb : FiniteMultiplicity p b) (h : multiplicity p a ≠ multiplicity p b) :
multiplicity p (a + b) = min (multiplicity p a) (multiplicity p b) := by
rcases lt_trichotomy (multiplicity p a) (multiplicity p b) with (hab | _ | hab)
· rw [add_comm, ha.multiplicity_add_of_gt hab, min_eq_left]
exact le_of_lt hab
· contradiction
· rw [hb.multiplicity_add_of_gt hab, min_eq_right]
exact le_of_lt hab
end Ring
section CancelCommMonoidWithZero
variable [CancelCommMonoidWithZero α]
theorem finiteMultiplicity_mul_aux {p : α} (hp : Prime p) {a b : α} :
∀ {n m : ℕ}, ¬p ^ (n + 1) ∣ a → ¬p ^ (m + 1) ∣ b → ¬p ^ (n + m + 1) ∣ a * b
| n, m => fun ha hb ⟨s, hs⟩ =>
have : p ∣ a * b := ⟨p ^ (n + m) * s, by simp [hs, pow_add, mul_comm, mul_left_comm]⟩
(hp.2.2 a b this).elim
(fun ⟨x, hx⟩ =>
have hn0 : 0 < n :=
Nat.pos_of_ne_zero fun hn0 => by simp [hx, hn0] at ha
have hpx : ¬p ^ (n - 1 + 1) ∣ x := fun ⟨y, hy⟩ =>
ha (hx.symm ▸ ⟨y, mul_right_cancel₀ hp.1 <| by
rw [tsub_add_cancel_of_le (succ_le_of_lt hn0)] at hy
simp [hy, pow_add, mul_comm, mul_left_comm]⟩)
have : 1 ≤ n + m := le_trans hn0 (Nat.le_add_right n m)
finiteMultiplicity_mul_aux hp hpx hb
⟨s, mul_right_cancel₀ hp.1 (by
rw [tsub_add_eq_add_tsub (succ_le_of_lt hn0), tsub_add_cancel_of_le this]
simp_all [mul_comm, mul_left_comm, pow_add])⟩)
fun ⟨x, hx⟩ =>
have hm0 : 0 < m :=
Nat.pos_of_ne_zero fun hm0 => by simp [hx, hm0] at hb
have hpx : ¬p ^ (m - 1 + 1) ∣ x := fun ⟨y, hy⟩ =>
hb
(hx.symm ▸
⟨y,
mul_right_cancel₀ hp.1 <| by
rw [tsub_add_cancel_of_le (succ_le_of_lt hm0)] at hy
simp [hy, pow_add, mul_comm, mul_left_comm]⟩)
finiteMultiplicity_mul_aux hp ha hpx
⟨s, mul_right_cancel₀ hp.1 (by
rw [add_assoc, tsub_add_cancel_of_le (succ_le_of_lt hm0)]
simp_all [mul_comm, mul_left_comm, pow_add])⟩
theorem Prime.finiteMultiplicity_mul {p a b : α} (hp : Prime p) :
FiniteMultiplicity p a → FiniteMultiplicity p b → FiniteMultiplicity p (a * b) :=
fun ⟨n, hn⟩ ⟨m, hm⟩ => ⟨n + m, finiteMultiplicity_mul_aux hp hn hm⟩
theorem FiniteMultiplicity.mul_iff {p a b : α} (hp : Prime p) :
FiniteMultiplicity p (a * b) ↔ FiniteMultiplicity p a ∧ FiniteMultiplicity p b :=
⟨fun h => ⟨h.mul_left, h.mul_right⟩, fun h =>
hp.finiteMultiplicity_mul h.1 h.2⟩
theorem FiniteMultiplicity.pow {p a : α} (hp : Prime p)
(hfin : FiniteMultiplicity p a) {k : ℕ} : FiniteMultiplicity p (a ^ k) :=
match k, hfin with
| 0, _ => ⟨0, by simp [mt isUnit_iff_dvd_one.2 hp.2.1]⟩
| k + 1, ha => by rw [_root_.pow_succ']; exact hp.finiteMultiplicity_mul ha (ha.pow hp)
@[simp]
theorem multiplicity_self {a : α} : multiplicity a a = 1 := by
by_cases ha : FiniteMultiplicity a a
· rw [ha.multiplicity_eq_iff]
simp only [pow_one, dvd_refl, reduceAdd, true_and]
rintro ⟨v, hv⟩
nth_rw 1 [← mul_one a] at hv
simp only [sq, mul_assoc, mul_eq_mul_left_iff] at hv
obtain hv | rfl := hv
· have : IsUnit a := .of_mul_eq_one v hv.symm
simpa [this] using ha.not_unit
· simpa using ha.ne_zero
· simp [ha]
@[simp]
theorem FiniteMultiplicity.emultiplicity_self {a : α} (hfin : FiniteMultiplicity a a) :
emultiplicity a a = 1 := by
simp [hfin.emultiplicity_eq_multiplicity]
theorem multiplicity_mul {p a b : α} (hp : Prime p) (hfin : FiniteMultiplicity p (a * b)) :
multiplicity p (a * b) = multiplicity p a + multiplicity p b := by
have hdiva : p ^ multiplicity p a ∣ a := pow_multiplicity_dvd ..
have hdivb : p ^ multiplicity p b ∣ b := pow_multiplicity_dvd ..
have hdiv : p ^ (multiplicity p a + multiplicity p b) ∣ a * b := by
rw [pow_add]; gcongr
have hsucc : ¬p ^ (multiplicity p a + multiplicity p b + 1) ∣ a * b :=
fun h =>
not_or_intro (hfin.mul_left.not_pow_dvd_of_multiplicity_lt (lt_succ_self _))
(hfin.mul_right.not_pow_dvd_of_multiplicity_lt (lt_succ_self _))
(_root_.succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul hp hdiva hdivb h)
rw [hfin.multiplicity_eq_iff]
exact ⟨hdiv, hsucc⟩
theorem emultiplicity_mul {p a b : α} (hp : Prime p) :
emultiplicity p (a * b) = emultiplicity p a + emultiplicity p b := by
by_cases hfin : FiniteMultiplicity p (a * b)
· rw [hfin.emultiplicity_eq_multiplicity, hfin.mul_left.emultiplicity_eq_multiplicity,
hfin.mul_right.emultiplicity_eq_multiplicity]
norm_cast
exact multiplicity_mul hp hfin
· rw [emultiplicity_eq_top.2 hfin, eq_comm, WithTop.add_eq_top, emultiplicity_eq_top,
emultiplicity_eq_top]
simpa only [FiniteMultiplicity.mul_iff hp, not_and_or] using hfin
theorem Finset.emultiplicity_prod {β : Type*} {p : α} (hp : Prime p) (s : Finset β) (f : β → α) :
emultiplicity p (∏ x ∈ s, f x) = ∑ x ∈ s, emultiplicity p (f x) := by classical
induction s using Finset.induction with
| empty =>
simp only [Finset.sum_empty, Finset.prod_empty]
exact emultiplicity_of_one_right hp.not_unit
| insert a s has ih => simpa [has, ← ih] using emultiplicity_mul hp
theorem emultiplicity_pow {p a : α} (hp : Prime p) {k : ℕ} :
emultiplicity p (a ^ k) = k * emultiplicity p a := by
induction k with
| zero => simp [emultiplicity_of_one_right hp.not_unit]
| succ k hk => simp [pow_succ, emultiplicity_mul hp, hk, add_mul]
protected theorem FiniteMultiplicity.multiplicity_pow {p a : α} (hp : Prime p)
(ha : FiniteMultiplicity p a) {k : ℕ} : multiplicity p (a ^ k) = k * multiplicity p a := by
exact_mod_cast (ha.pow hp).emultiplicity_eq_multiplicity ▸
ha.emultiplicity_eq_multiplicity ▸ emultiplicity_pow hp
theorem emultiplicity_pow_self {p : α} (h0 : p ≠ 0) (hu : ¬IsUnit p) (n : ℕ) :
emultiplicity p (p ^ n) = n := by
apply emultiplicity_eq_of_dvd_of_not_dvd
· rfl
· rw [pow_dvd_pow_iff h0 hu]
apply Nat.not_succ_le_self
theorem multiplicity_pow_self {p : α} (h0 : p ≠ 0) (hu : ¬IsUnit p) (n : ℕ) :
multiplicity p (p ^ n) = n :=
multiplicity_eq_of_emultiplicity_eq_some (emultiplicity_pow_self h0 hu n)
theorem emultiplicity_pow_self_of_prime {p : α} (hp : Prime p) (n : ℕ) :
emultiplicity p (p ^ n) = n :=
emultiplicity_pow_self hp.ne_zero hp.not_unit n
theorem multiplicity_pow_self_of_prime {p : α} (hp : Prime p) (n : ℕ) :
multiplicity p (p ^ n) = n :=
multiplicity_pow_self hp.ne_zero hp.not_unit n
end CancelCommMonoidWithZero
section Nat
theorem multiplicity_eq_zero_of_coprime {p a b : ℕ} (hp : p ≠ 1)
(hle : multiplicity p a ≤ multiplicity p b) (hab : Nat.Coprime a b) : multiplicity p a = 0 := by
apply Nat.eq_zero_of_not_pos
intro nh
have da : p ∣ a := by simpa [multiplicity_eq_zero] using nh.ne.symm
have db : p ∣ b := by simpa [multiplicity_eq_zero] using (nh.trans_le hle).ne.symm
have := Nat.dvd_gcd da db
rw [Coprime.gcd_eq_one hab, Nat.dvd_one] at this
exact hp this
end Nat
theorem Int.finiteMultiplicity_iff_finiteMultiplicity_natAbs {a b : ℤ} :
FiniteMultiplicity a b ↔ FiniteMultiplicity a.natAbs b.natAbs := by
simp only [FiniteMultiplicity.def, ← Int.natAbs_dvd_natAbs, Int.natAbs_pow]
theorem Int.finiteMultiplicity_iff {a b : ℤ} : FiniteMultiplicity a b ↔ a.natAbs ≠ 1 ∧ b ≠ 0 := by
rw [finiteMultiplicity_iff_finiteMultiplicity_natAbs, Nat.finiteMultiplicity_iff,
pos_iff_ne_zero, Int.natAbs_ne_zero]
instance Nat.decidableFiniteMultiplicity : DecidableRel fun a b : ℕ => FiniteMultiplicity a b :=
fun _ _ ↦ decidable_of_iff' _ Nat.finiteMultiplicity_iff
instance Int.decidableMultiplicityFinite : DecidableRel fun a b : ℤ => FiniteMultiplicity a b :=
fun _ _ ↦ decidable_of_iff' _ Int.finiteMultiplicity_iff |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraTower.lean | import Mathlib.Algebra.Algebra.Tower
import Mathlib.LinearAlgebra.Basis.Basic
/-!
# Towers of algebras
We set up the basic theory of algebra towers.
An algebra tower A/S/R is expressed by having instances of `Algebra A S`,
`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the
compatibility condition `(r • s) • a = r • (s • a)`.
In `FieldTheory/Tower.lean` we use this to prove the tower law for finite extensions,
that if `R` and `S` are both fields, then `[A:R] = [A:S] [S:A]`.
In this file we prepare the main lemma:
if `{bi | i ∈ I}` is an `R`-basis of `S` and `{cj | j ∈ J}` is an `S`-basis
of `A`, then `{bi cj | i ∈ I, j ∈ J}` is an `R`-basis of `A`. This statement does not require the
base rings to be a field, so we also generalize the lemma to rings in this file.
-/
open Module
open scoped Pointwise
variable (R S A B : Type*)
namespace IsScalarTower
section Semiring
variable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]
variable [Algebra R S] [Algebra S A] [Algebra S B] [Algebra R A] [Algebra R B]
variable [IsScalarTower R S A] [IsScalarTower R S B]
/-- Suppose that `R → S → A` is a tower of algebras.
If an element `r : R` is invertible in `S`, then it is invertible in `A`. -/
def Invertible.algebraTower (r : R) [Invertible (algebraMap R S r)] :
Invertible (algebraMap R A r) :=
Invertible.copy (Invertible.map (algebraMap S A) (algebraMap R S r)) (algebraMap R A r)
(IsScalarTower.algebraMap_apply R S A r)
/-- A natural number that is invertible when coerced to `R` is also invertible
when coerced to any `R`-algebra. -/
def invertibleAlgebraCoeNat (n : ℕ) [inv : Invertible (n : R)] : Invertible (n : A) :=
haveI : Invertible (algebraMap ℕ R n) := inv
Invertible.algebraTower ℕ R A n
end Semiring
end IsScalarTower
section AlgebraMapCoeffs
namespace Module.Basis
variable {R} {ι M : Type*} [CommSemiring R] [Semiring A] [AddCommMonoid M]
variable [Algebra R A] [Module A M] [Module R M] [IsScalarTower R A M]
variable (b : Basis ι R M) (h : Function.Bijective (algebraMap R A))
/-- If `R` and `A` have a bijective `algebraMap R A` and act identically on `M`,
then a basis for `M` as `R`-module is also a basis for `M` as `R'`-module. -/
@[simps! repr_apply_toFun]
noncomputable def algebraMapCoeffs : Basis ι A M :=
b.mapCoeffs (RingEquiv.ofBijective _ h) fun c x => by simp
@[simp]
theorem algebraMapCoeffs_repr (m : M) :
(b.algebraMapCoeffs A h).repr m = (b.repr m).mapRange (algebraMap R A) (map_zero _) := by
rfl
theorem algebraMapCoeffs_apply (i : ι) : b.algebraMapCoeffs A h i = b i :=
b.mapCoeffs_apply _ _ _
@[simp]
theorem coe_algebraMapCoeffs : (b.algebraMapCoeffs A h : ι → M) = b :=
b.coe_mapCoeffs _ _
end Module.Basis
end AlgebraMapCoeffs
section Semiring
open Finsupp
variable {R S A}
variable [Semiring R] [Semiring S] [AddCommMonoid A]
variable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]
theorem linearIndependent_smul {ι : Type*} {b : ι → S} {ι' : Type*} {c : ι' → A}
(hb : LinearIndependent R b) (hc : LinearIndependent S c) :
LinearIndependent R fun p : ι × ι' ↦ b p.1 • c p.2 := by
classical
rw [← linearIndependent_equiv' (.prodComm ..) (g := fun p : ι' × ι ↦ b p.2 • c p.1) rfl,
LinearIndependent, linearCombination_smul]
simpa using Function.Injective.comp hc
((mapRange_injective _ (map_zero _) hb).comp <| Equiv.injective _)
variable (R)
namespace Module.Basis
-- LinearIndependent is enough if S is a ring rather than semiring.
theorem isScalarTower_of_nonempty {ι} [Nonempty ι] (b : Basis ι S A) : IsScalarTower R S S :=
(b.repr.symm.comp <| lsingle <| Classical.arbitrary ι).isScalarTower_of_injective R
(b.repr.symm.injective.comp <| single_injective _)
theorem isScalarTower_finsupp {ι} (b : Basis ι S A) : IsScalarTower R S (ι →₀ S) :=
b.repr.symm.isScalarTower_of_injective R b.repr.symm.injective
variable {R} {ι ι' : Type*} [DecidableEq ι'] (b : Basis ι R S) (c : Basis ι' S A)
/-- `Basis.smulTower (b : Basis ι R S) (c : Basis ι S A)` is the `R`-basis on `A`
where the `(i, j)`th basis vector is `b i • c j`. -/
noncomputable
def smulTower : Basis (ι × ι') R A :=
haveI := c.isScalarTower_finsupp R
.ofRepr
(c.repr.restrictScalars R ≪≫ₗ
(Finsupp.lcongr (Equiv.refl _) b.repr ≪≫ₗ
((finsuppProdLEquiv R).symm ≪≫ₗ
Finsupp.lcongr (Equiv.prodComm ι' ι) (LinearEquiv.refl _ _))))
@[simp]
theorem smulTower_repr (x ij) :
(b.smulTower c).repr x ij = b.repr (c.repr x ij.2) ij.1 := by
simp [smulTower, Finsupp.uncurry_apply]
theorem smulTower_repr_mk (x i j) : (b.smulTower c).repr x (i, j) = b.repr (c.repr x j) i :=
b.smulTower_repr c x (i, j)
@[simp]
theorem smulTower_apply (ij) : (b.smulTower c) ij = b ij.1 • c ij.2 := by
classical
obtain ⟨i, j⟩ := ij
rw [Basis.apply_eq_iff]
ext ⟨i', j'⟩
rw [Basis.smulTower_repr, LinearEquiv.map_smul, Basis.repr_self, Finsupp.smul_apply,
Finsupp.single_apply]
dsimp only
split_ifs with hi
· simp [hi, Finsupp.single_apply]
· simp [hi]
/-- `Basis.smulTower (b : Basis ι R S) (c : Basis ι S A)` is the `R`-basis on `A`
where the `(i, j)`th basis vector is `b j • c i`. -/
noncomputable def smulTower' : Basis (ι' × ι) R A :=
(b.smulTower c).reindex (.prodComm ..)
theorem smulTower'_repr (x ij) :
(b.smulTower' c).repr x ij = b.repr (c.repr x ij.1) ij.2 := by
rw [smulTower', repr_reindex_apply, smulTower_repr]; rfl
theorem smulTower'_repr_mk (x i j) : (b.smulTower' c).repr x (i, j) = b.repr (c.repr x i) j :=
b.smulTower'_repr c x (i, j)
theorem smulTower'_apply (ij) : b.smulTower' c ij = b ij.2 • c ij.1 := by
rw [smulTower', reindex_apply, smulTower_apply]; rfl
end Module.Basis
end Semiring
section Ring
variable {R S}
variable [CommRing R] [Ring S] [Algebra R S]
theorem Module.Basis.algebraMap_injective {ι : Type*} [NoZeroDivisors R] [Nontrivial S]
(b : Basis ι R S) : Function.Injective (algebraMap R S) :=
have : NoZeroSMulDivisors R S := b.noZeroSMulDivisors
FaithfulSMul.algebraMap_injective R S
end Ring
section AlgHomTower
variable {A} {C D : Type*} [CommSemiring A] [CommSemiring C] [CommSemiring D] [Algebra A C]
[Algebra A D]
variable [CommSemiring B] [Algebra A B] [Algebra B C] [IsScalarTower A B C] (f : C →ₐ[A] D)
/-- Restrict the domain of an `AlgHom`. -/
def AlgHom.restrictDomain : B →ₐ[A] D :=
f.comp (IsScalarTower.toAlgHom A B C)
/-- Extend the scalars of an `AlgHom`. -/
def AlgHom.extendScalars : @AlgHom B C D _ _ _ _ (f.restrictDomain B).toRingHom.toAlgebra where
__ := f
commutes' := fun _ ↦ rfl
__ := (f.restrictDomain B).toRingHom.toAlgebra
variable {B}
/-- `AlgHom`s from the top of a tower are equivalent to a pair of `AlgHom`s. -/
def algHomEquivSigma :
(C →ₐ[A] D) ≃ Σ f : B →ₐ[A] D, @AlgHom B C D _ _ _ _ f.toRingHom.toAlgebra where
toFun f := ⟨f.restrictDomain B, f.extendScalars B⟩
invFun fg :=
let _ := fg.1.toRingHom.toAlgebra
fg.2.restrictScalars A
left_inv f := by
dsimp only
ext
rfl
right_inv := by
rintro ⟨⟨⟨⟨⟨f, _⟩, _⟩, _⟩, _⟩, ⟨⟨⟨⟨g, _⟩, _⟩, _⟩, hg⟩⟩
obtain rfl : f = fun x => g (algebraMap B C x) := by
ext x
exact (hg x).symm
rfl
end AlgHomTower |
.lake/packages/mathlib/Mathlib/RingTheory/AdjoinRoot.lean | import Mathlib.Algebra.Algebra.Defs
import Mathlib.Algebra.Polynomial.FieldDivision
import Mathlib.FieldTheory.Minpoly.Basic
import Mathlib.RingTheory.Adjoin.Basic
import Mathlib.RingTheory.FinitePresentation
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Ideal.Quotient.Noetherian
import Mathlib.RingTheory.PowerBasis
import Mathlib.RingTheory.PrincipalIdealDomain
import Mathlib.RingTheory.Polynomial.Quotient
/-!
# Adjoining roots of polynomials
This file defines the commutative ring `AdjoinRoot f`, the ring R[X]/(f) obtained from a
commutative ring `R` and a polynomial `f : R[X]`. If furthermore `R` is a field and `f` is
irreducible, the field structure on `AdjoinRoot f` is constructed.
We suggest stating results on `IsAdjoinRoot` instead of `AdjoinRoot` to achieve higher
generality, since `IsAdjoinRoot` works for all different constructions of `R[α]`
including `AdjoinRoot f = R[X]/(f)` itself.
## Main definitions and results
The main definitions are in the `AdjoinRoot` namespace.
* `mk f : R[X] →+* AdjoinRoot f`, the natural ring homomorphism.
* `of f : R →+* AdjoinRoot f`, the natural ring homomorphism.
* `root f : AdjoinRoot f`, the image of X in R[X]/(f).
* `lift (i : R →+* S) (x : S) (h : f.eval₂ i x = 0) : (AdjoinRoot f) →+* S`, the ring
homomorphism from R[X]/(f) to S extending `i : R →+* S` and sending `X` to `x`.
* `lift_hom (x : S) (hfx : aeval x f = 0) : AdjoinRoot f →ₐ[R] S`, the algebra
homomorphism from R[X]/(f) to S extending `algebraMap R S` and sending `X` to `x`
* `equiv : (AdjoinRoot f →ₐ[F] E) ≃ {x // x ∈ f.aroots E}` a
bijection between algebra homomorphisms from `AdjoinRoot` and roots of `f` in `S`
-/
noncomputable section
open Algebra (FinitePresentation FiniteType)
open Ideal Module Polynomial
variable {R S T K : Type*}
/-- Adjoin a root of a polynomial `f` to a commutative ring `R`. We define the new ring
as the quotient of `R[X]` by the principal ideal generated by `f`. -/
def AdjoinRoot [CommRing R] (f : R[X]) : Type _ :=
Polynomial R ⧸ (span {f} : Ideal R[X])
namespace AdjoinRoot
section CommRing
variable [CommRing R] (f g : R[X])
instance instCommRing : CommRing (AdjoinRoot f) :=
Ideal.Quotient.commRing _
instance : Inhabited (AdjoinRoot f) :=
⟨0⟩
instance : DecidableEq (AdjoinRoot f) :=
Classical.decEq _
protected theorem nontrivial [IsDomain R] (h : degree f ≠ 0) : Nontrivial (AdjoinRoot f) :=
Ideal.Quotient.nontrivial
(by
simp_rw [Ne, span_singleton_eq_top, Polynomial.isUnit_iff, not_exists, not_and]
rintro x hx rfl
exact h (degree_C hx.ne_zero))
/-- Ring homomorphism from `R[x]` to `AdjoinRoot f` sending `X` to the `root`. -/
def mk : R[X] →+* AdjoinRoot f :=
Ideal.Quotient.mk _
@[elab_as_elim]
theorem induction_on {C : AdjoinRoot f → Prop} (x : AdjoinRoot f) (ih : ∀ p : R[X], C (mk f p)) :
C x :=
Quotient.inductionOn' x ih
/-- Embedding of the original ring `R` into `AdjoinRoot f`. -/
def of : R →+* AdjoinRoot f :=
(mk f).comp C
instance instSMulAdjoinRoot [DistribSMul S R] [IsScalarTower S R R] : SMul S (AdjoinRoot f) :=
Submodule.Quotient.instSMul' _
instance [DistribSMul S R] [IsScalarTower S R R] : DistribSMul S (AdjoinRoot f) :=
Submodule.Quotient.distribSMul' _
@[simp]
theorem smul_mk [DistribSMul S R] [IsScalarTower S R R] (a : S) (x : R[X]) :
a • mk f x = mk f (a • x) :=
rfl
theorem smul_of [DistribSMul S R] [IsScalarTower S R R] (a : S) (x : R) :
a • of f x = of f (a • x) := by rw [of, RingHom.comp_apply, RingHom.comp_apply, smul_mk, smul_C]
instance (R₁ R₂ : Type*) [SMul R₁ R₂] [DistribSMul R₁ R] [DistribSMul R₂ R] [IsScalarTower R₁ R R]
[IsScalarTower R₂ R R] [IsScalarTower R₁ R₂ R] (f : R[X]) :
IsScalarTower R₁ R₂ (AdjoinRoot f) :=
Submodule.Quotient.isScalarTower _ _
instance (R₁ R₂ : Type*) [DistribSMul R₁ R] [DistribSMul R₂ R] [IsScalarTower R₁ R R]
[IsScalarTower R₂ R R] [SMulCommClass R₁ R₂ R] (f : R[X]) :
SMulCommClass R₁ R₂ (AdjoinRoot f) :=
Submodule.Quotient.smulCommClass _ _
instance isScalarTower_right [DistribSMul S R] [IsScalarTower S R R] :
IsScalarTower S (AdjoinRoot f) (AdjoinRoot f) :=
Ideal.Quotient.isScalarTower_right
instance [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] (f : R[X]) :
DistribMulAction S (AdjoinRoot f) :=
Submodule.Quotient.distribMulAction' _
/-- `R[x]/(f)` is `R`-algebra -/
@[stacks 09FX "second part"]
instance [CommSemiring S] [Algebra S R] : Algebra S (AdjoinRoot f) :=
Ideal.Quotient.algebra S
/- TODO : generalise base ring -/
/-- `R`-algebra homomorphism from `R[x]` to `AdjoinRoot f` sending `X` to the `root`. -/
def mkₐ : R[X] →ₐ[R] AdjoinRoot f :=
Ideal.Quotient.mkₐ R _
@[simp, norm_cast] theorem mkₐ_toRingHom : ↑(mkₐ f) = mk f := rfl
@[simp] theorem coe_mkₐ : ⇑(mkₐ f) = mk f := rfl
@[simp]
theorem algebraMap_eq : algebraMap R (AdjoinRoot f) = of f :=
rfl
variable (S) in
theorem algebraMap_eq' [CommSemiring S] [Algebra S R] :
algebraMap S (AdjoinRoot f) = (of f).comp (algebraMap S R) :=
rfl
instance finiteType [CommSemiring S] [Algebra S R] [FiniteType S R] :
FiniteType S (AdjoinRoot f) := by
unfold AdjoinRoot; infer_instance
instance finitePresentation [CommRing S] [Algebra S R] [FinitePresentation S R] :
FinitePresentation S (AdjoinRoot f) := .quotient (Submodule.fg_span_singleton f)
/-- The adjoined root. -/
def root : AdjoinRoot f :=
mk f X
section Algebra
variable [CommSemiring S] [Semiring T] [Algebra S R] [Algebra S T] (p : R[X])
variable (S) in
/-- Embedding of the original ring `R` into `AdjoinRoot p`. -/
abbrev ofAlgHom : R →ₐ[S] AdjoinRoot p := Algebra.algHom S R <| AdjoinRoot p
@[simp] lemma toRingHom_ofAlgHom : ofAlgHom S p = of p := rfl
@[simp] lemma coe_ofAlgHom : ⇑(ofAlgHom S p) = of p := rfl
@[ext]
lemma algHom_ext' {f g : AdjoinRoot p →ₐ[S] T}
(hAlg : f.comp (ofAlgHom S p) = g.comp (ofAlgHom S p))
(hRoot : f (root p) = g (root p)) : f = g := by
apply Ideal.Quotient.algHom_ext
ext x
· simpa using congr($(hAlg) x)
· simpa
end Algebra
variable {f g}
instance hasCoeT : CoeTC R (AdjoinRoot f) :=
⟨of f⟩
/-- Two `R`-`AlgHom` from `AdjoinRoot f` to the same `R`-algebra are the same iff
they agree on `root f`. -/
@[ext]
theorem algHom_ext [Semiring S] [Algebra R S] {g₁ g₂ : AdjoinRoot f →ₐ[R] S}
(h : g₁ (root f) = g₂ (root f)) : g₁ = g₂ :=
Ideal.Quotient.algHom_ext R <| Polynomial.algHom_ext h
@[simp]
theorem mk_eq_mk {g h : R[X]} : mk f g = mk f h ↔ f ∣ g - h :=
Ideal.Quotient.eq.trans Ideal.mem_span_singleton
@[simp]
theorem mk_eq_zero {g : R[X]} : mk f g = 0 ↔ f ∣ g :=
mk_eq_mk.trans <| by rw [sub_zero]
@[simp]
theorem mk_self : mk f f = 0 :=
Quotient.sound' <| QuotientAddGroup.leftRel_apply.mpr (mem_span_singleton.2 <| by simp)
@[simp]
theorem mk_C (x : R) : mk f (C x) = x :=
rfl
@[simp]
theorem mk_X : mk f X = root f :=
rfl
theorem mk_ne_zero_of_degree_lt (hf : Monic f) {g : R[X]} (h0 : g ≠ 0) (hd : degree g < degree f) :
mk f g ≠ 0 :=
mk_eq_zero.not.2 <| hf.not_dvd_of_degree_lt h0 hd
theorem mk_ne_zero_of_natDegree_lt (hf : Monic f) {g : R[X]} (h0 : g ≠ 0)
(hd : natDegree g < natDegree f) : mk f g ≠ 0 :=
mk_eq_zero.not.2 <| hf.not_dvd_of_natDegree_lt h0 hd
theorem aeval_eq_of_algebra [CommRing S] [Algebra R S] (f : S[X]) (p : R[X]) :
aeval (root f) p = mk f (map (algebraMap R S) p) := by
induction p using Polynomial.induction_on with
| C a =>
simp only [Polynomial.aeval_C, Polynomial.map_C, mk_C]
rw [IsScalarTower.algebraMap_apply R S]
simp
| add p q _ _ => simp_all
| monomial n a _ => simp_all [pow_add, ← mul_assoc]
@[simp]
theorem aeval_eq (p : R[X]) : aeval (root f) p = mk f p := by
rw [aeval_eq_of_algebra, Algebra.algebraMap_self, Polynomial.map_id]
theorem adjoinRoot_eq_top : Algebra.adjoin R ({root f} : Set (AdjoinRoot f)) = ⊤ := by
refine Algebra.eq_top_iff.2 fun x => ?_
induction x using AdjoinRoot.induction_on with
| ih p => exact (Algebra.adjoin_singleton_eq_range_aeval R (root f)).symm ▸ ⟨p, aeval_eq p⟩
@[simp]
theorem eval₂_root (f : R[X]) : f.eval₂ (of f) (root f) = 0 := by
rw [← algebraMap_eq, ← aeval_def, aeval_eq, mk_self]
theorem isRoot_root (f : R[X]) : IsRoot (f.map (of f)) (root f) := by
rw [IsRoot, eval_map, eval₂_root]
theorem isAlgebraic_root (hf : f ≠ 0) : IsAlgebraic R (root f) :=
⟨f, hf, eval₂_root f⟩
theorem of.injective_of_degree_ne_zero [IsDomain R] (hf : f.degree ≠ 0) :
Function.Injective (AdjoinRoot.of f) := by
rw [injective_iff_map_eq_zero]
intro p hp
rw [AdjoinRoot.of, RingHom.comp_apply, AdjoinRoot.mk_eq_zero] at hp
by_cases h : f = 0
· exact C_eq_zero.mp (eq_zero_of_zero_dvd (by rwa [h] at hp))
· contrapose! hf with h_contra
rw [← degree_C h_contra]
apply le_antisymm (degree_le_of_dvd hp (by rwa [Ne, C_eq_zero])) _
rwa [degree_C h_contra, zero_le_degree_iff]
variable [CommRing S]
/-- Lift a ring homomorphism `i : R →+* S` to `AdjoinRoot f →+* S`. -/
def lift (i : R →+* S) (x : S) (h : f.eval₂ i x = 0) : AdjoinRoot f →+* S := by
apply Ideal.Quotient.lift _ (eval₂RingHom i x)
intro g H
rcases mem_span_singleton.1 H with ⟨y, hy⟩
rw [hy, RingHom.map_mul, coe_eval₂RingHom, h, zero_mul]
variable {i : R →+* S} {a : S} (h : f.eval₂ i a = 0)
@[simp]
theorem lift_mk (g : R[X]) : lift i a h (mk f g) = g.eval₂ i a :=
Ideal.Quotient.lift_mk _ _ _
@[simp]
theorem lift_root : lift i a h (root f) = a := by rw [root, lift_mk, eval₂_X]
@[simp]
theorem lift_of {x : R} : lift i a h x = i x := by rw [← mk_C x, lift_mk, eval₂_C]
@[simp]
theorem lift_comp_of : (lift i a h).comp (of f) = i :=
RingHom.ext fun _ => @lift_of _ _ _ _ _ _ _ h _
section
variable [CommRing T] [Algebra S R] [Algebra S T] (p : R[X])
/-- Produce an algebra homomorphism `AdjoinRoot f →ₐ[R] S` sending `root f` to
a root of `f` in `S`. -/
def liftAlgHom (i : R →ₐ[S] T) (x : T) (h : p.eval₂ i x = 0) : AdjoinRoot p →ₐ[S] T where
__ := lift i.toRingHom _ h
commutes' r := by simp [lift_of h, AdjoinRoot.algebraMap_eq']
@[simp] lemma toRingHom_liftAlgHom (i : R →ₐ[S] T) (x : T) (h) :
(liftAlgHom p i x h : AdjoinRoot p →+* T) = lift i.toRingHom _ h := rfl
lemma coe_liftAlgHom (i : R →ₐ[S] T) (x : T) (h) : ⇑(liftAlgHom p i x h) = lift i.toRingHom _ h :=
rfl
@[simp]
lemma liftAlgHom_of (i : R →ₐ[S] T) (x : T) (h) (r : R) : liftAlgHom p i x h (of p r) = i r := by
simp [liftAlgHom]
@[simp]
lemma liftAlgHom_mk (i : R →ₐ[S] T) (x : T) (h) (f : R[X]) :
liftAlgHom p i x h (mk p f) = eval₂ i x f := rfl
@[simp]
lemma liftAlgHom_root (i : R →ₐ[S] T) (x : T) (h) : liftAlgHom p i x h (root p) = x := by
simp [liftAlgHom]
end
section deprecated
variable (f) [Algebra R S]
/-- Produce an algebra homomorphism `AdjoinRoot f →ₐ[R] S` sending `root f` to
a root of `f` in `S`. -/
@[deprecated liftAlgHom (since := "2025-10-10")]
def liftHom (x : S) (hfx : aeval x f = 0) : AdjoinRoot f →ₐ[R] S :=
liftAlgHom _ _ x hfx
set_option linter.deprecated false in
@[deprecated toRingHom_liftAlgHom (since := "2025-10-10")]
theorem coe_liftHom (x : S) (hfx : aeval x f = 0) :
(liftHom f x hfx : AdjoinRoot f →+* S) = lift (algebraMap R S) x hfx :=
rfl
@[simp]
theorem aeval_algHom_eq_zero (ϕ : AdjoinRoot f →ₐ[R] S) : aeval (ϕ (root f)) f = 0 := by
have h : ϕ.toRingHom.comp (of f) = algebraMap R S := RingHom.ext_iff.mpr ϕ.commutes
rw [aeval_def, ← h, ← RingHom.map_zero ϕ.toRingHom, ← eval₂_root f, hom_eval₂]
rfl
@[simp]
theorem liftAlgHom_eq_algHom (ϕ : AdjoinRoot f →ₐ[R] S) :
liftAlgHom f (Algebra.ofId R S) (ϕ (root f)) (aeval_algHom_eq_zero f ϕ) = ϕ := by
suffices AlgHom.equalizer ϕ (liftAlgHom f _ (ϕ (root f)) (aeval_algHom_eq_zero f ϕ)) = ⊤ by
exact (AlgHom.ext fun x => (SetLike.ext_iff.mp this x).mpr Algebra.mem_top).symm
rw [eq_top_iff, ← adjoinRoot_eq_top, Algebra.adjoin_le_iff, Set.singleton_subset_iff]
exact (@lift_root _ _ _ _ _ _ _ (aeval_algHom_eq_zero f ϕ)).symm
set_option linter.deprecated false in
@[deprecated liftAlgHom_eq_algHom (since := "2025-10-10")]
theorem liftHom_eq_algHom (f : R[X]) (ϕ : AdjoinRoot f →ₐ[R] S) :
liftHom f (ϕ (root f)) (aeval_algHom_eq_zero f ϕ) = ϕ := liftAlgHom_eq_algHom ..
variable (hfx : aeval a f = 0)
set_option linter.deprecated false in
@[deprecated liftAlgHom_mk (since := "2025-10-10")]
theorem liftHom_mk {g : R[X]} : liftAlgHom f _ a hfx (mk f g) = aeval a g := by simp [aeval]
set_option linter.deprecated false in
@[deprecated liftAlgHom_root (since := "2025-10-10")]
theorem liftHom_root : liftHom f a hfx (root f) = a :=
lift_root hfx
set_option linter.deprecated false in
@[deprecated liftAlgHom_of (since := "2025-10-10")]
theorem liftHom_of {x : R} : liftHom f a hfx (of f x) = algebraMap _ _ x :=
lift_of hfx
end deprecated
section AdjoinInv
@[simp]
theorem root_isInv (r : R) : of _ r * root (C r * X - 1) = 1 := by
convert sub_eq_zero.1 ((eval₂_sub _).symm.trans <| eval₂_root <| C r * X - 1) <;>
simp only [eval₂_mul, eval₂_C, eval₂_X, eval₂_one]
theorem algHom_subsingleton {S : Type*} [CommRing S] [Algebra R S] {r : R} :
Subsingleton (AdjoinRoot (C r * X - 1) →ₐ[R] S) :=
⟨fun f g =>
algHom_ext
(@inv_unique _ _ (algebraMap R S r) _ _
(by rw [← f.commutes, ← map_mul, algebraMap_eq, root_isInv, map_one])
(by rw [← g.commutes, ← map_mul, algebraMap_eq, root_isInv, map_one]))⟩
end AdjoinInv
section Prime
theorem isDomain_of_prime (hf : Prime f) : IsDomain (AdjoinRoot f) :=
(Ideal.Quotient.isDomain_iff_prime (span {f} : Ideal R[X])).mpr <|
(Ideal.span_singleton_prime hf.ne_zero).mpr hf
theorem noZeroSMulDivisors_of_prime_of_degree_ne_zero [IsDomain R] (hf : Prime f)
(hf' : f.degree ≠ 0) : NoZeroSMulDivisors R (AdjoinRoot f) :=
haveI := isDomain_of_prime hf
NoZeroSMulDivisors.iff_algebraMap_injective.mpr (of.injective_of_degree_ne_zero hf')
end Prime
/-- The canonical algebraic homomorphism from `AdjoinRoot f` to `AdjoinRoot g`, where
the polynomial `g : K[X]` divides `f`. -/
noncomputable def algHomOfDvd (f g : R[X]) (hgf : g ∣ f) : AdjoinRoot f →ₐ[R] AdjoinRoot g :=
liftAlgHom f (Algebra.ofId ..) (root g) <| (aeval_eq _).trans <| by simp [mk_eq_zero, hgf]
lemma coe_algHomOfDvd (f g : R[X]) (hgf) :
⇑(algHomOfDvd f g hgf) =
liftAlgHom f (Algebra.ofId ..) (root g) ((aeval_eq _).trans <| by simp [mk_eq_zero, hgf]) :=
rfl
/-- `algHomOfDvd` sends `AdjoinRoot.root f` to `AdjoinRoot.root q`. -/
@[simp] lemma algHomOfDvd_root (f g : R[X]) (hgf) : algHomOfDvd f g hgf (root f) = root g := by
simp [algHomOfDvd]
/-- The canonical algebraic equivalence between `AdjoinRoot p` and `AdjoinRoot g`,
where the two polynomials `f g : R[X]` are associated. -/
noncomputable def algEquivOfAssociated (f g : R[X]) (hfg : Associated f g) :
AdjoinRoot f ≃ₐ[R] AdjoinRoot g :=
.ofAlgHom (algHomOfDvd f g hfg.symm.dvd) (algHomOfDvd g f hfg.dvd) (by ext; simp) (by ext; simp)
lemma coe_algEquivOfAssociated (f g : R[X]) (hfg) :
⇑(algEquivOfAssociated f g hfg) = algHomOfDvd f g hfg.symm.dvd := rfl
@[simp] lemma algEquivOfAssociated_symm (f g : R[X]) (hfg) :
(algEquivOfAssociated f g hfg).symm = algEquivOfAssociated g f hfg.symm := rfl
lemma algEquivOfAssociated_toAlgHom (f g : R[X]) (hfg) :
(algEquivOfAssociated f g hfg).toAlgHom = algHomOfDvd f g hfg.symm.dvd := rfl
/-- `algEquivOfAssociated` sends `AdjoinRoot.root f` to `AdjoinRoot.root g`. -/
@[simp] lemma algEquivOfAssociated_root (f g : R[X]) (hfg) :
algEquivOfAssociated f g hfg (root f) = root g := by
rw [coe_algEquivOfAssociated, algHomOfDvd_root]
/-- The canonical algebraic equivalence between `AdjoinRoot f` and `AdjoinRoot g`, where
the two polynomials `f g : R[X]` are equal. -/
noncomputable def algEquivOfEq (f g : R[X]) (hfg : f = g) : AdjoinRoot f ≃ₐ[R] AdjoinRoot g :=
algEquivOfAssociated f g (by rw [hfg])
lemma coe_algEquivOfEq (f g : R[X]) (hfg) :
⇑(algEquivOfEq f g hfg) = algHomOfDvd f g hfg.symm.dvd := rfl
@[simp] lemma algEquivOfEq_symm (f g : R[X]) (hfg) :
(algEquivOfEq f g hfg).symm = algEquivOfEq g f hfg.symm := rfl
lemma algEquivOfEq_toAlgHom (f g : R[X]) (hfg) :
(algEquivOfEq f g hfg).toAlgHom = algHomOfDvd f g hfg.symm.dvd := rfl
/-- `algEquivOfEq` sends `AdjoinRoot.root f` to `AdjoinRoot.root g`. -/
lemma algEquivOfEq_root (f g : R[X]) (hfg) : algEquivOfEq f g hfg (root f) = root g := by
rw [coe_algEquivOfEq, algHomOfDvd_root]
@[deprecated (since := "2025-10-10")] alias algHomOfDvd_apply_root := algHomOfDvd_root
@[deprecated (since := "2025-10-10")] alias algEquivOfEq_apply_root := algEquivOfEq_root
@[deprecated (since := "2025-10-10")]
alias algEquivOfAssociated_apply_root := algEquivOfAssociated_root
end CommRing
section Irreducible
variable [Field K] {f : K[X]}
instance span_maximal_of_irreducible [Fact (Irreducible f)] : (span {f}).IsMaximal :=
PrincipalIdealRing.isMaximal_of_irreducible <| Fact.out
noncomputable instance instGroupWithZero [Fact (Irreducible f)] : GroupWithZero (AdjoinRoot f) :=
Quotient.groupWithZero (span {f} : Ideal K[X])
/-- If `R` is a field and `f` is irreducible, then `AdjoinRoot f` is a field -/
@[stacks 09FX "first part, see also 09FI"]
noncomputable instance instField [Fact (Irreducible f)] : Field (AdjoinRoot f) where
__ := instCommRing _
__ := instGroupWithZero
nnqsmul := (· • ·)
qsmul := (· • ·)
nnratCast_def q := by
rw [← map_natCast (of f), ← map_natCast (of f), ← map_div₀, ← NNRat.cast_def]; rfl
ratCast_def q := by
rw [← map_natCast (of f), ← map_intCast (of f), ← map_div₀, ← Rat.cast_def]; rfl
nnqsmul_def q x :=
AdjoinRoot.induction_on f (C := fun y ↦ q • y = (of f) q * y) x fun p ↦ by
simp only [smul_mk, of, RingHom.comp_apply, ← (mk f).map_mul, Polynomial.nnqsmul_eq_C_mul]
qsmul_def q x :=
-- Porting note: I gave the explicit motive and changed `rw` to `simp`.
AdjoinRoot.induction_on f (C := fun y ↦ q • y = (of f) q * y) x fun p ↦ by
simp only [smul_mk, of, RingHom.comp_apply, ← (mk f).map_mul, Polynomial.qsmul_eq_C_mul]
theorem coe_injective (h : degree f ≠ 0) : Function.Injective ((↑) : K → AdjoinRoot f) :=
have := AdjoinRoot.nontrivial f h
(of f).injective
theorem coe_injective' [Fact (Irreducible f)] : Function.Injective ((↑) : K → AdjoinRoot f) :=
(of f).injective
variable (f)
theorem mul_div_root_cancel [Fact (Irreducible f)] :
(X - C (root f)) * ((f.map (of f)) / (X - C (root f))) = f.map (of f) :=
(isRoot_root _).mul_div_eq
end Irreducible
section IsNoetherianRing
instance [CommRing R] [IsNoetherianRing R] {f : R[X]} : IsNoetherianRing (AdjoinRoot f) :=
Ideal.Quotient.isNoetherianRing _
end IsNoetherianRing
section PowerBasis
variable [CommRing R] {g : R[X]}
theorem isIntegral_root' (hg : g.Monic) : IsIntegral R (root g) :=
⟨g, hg, eval₂_root g⟩
/-- `AdjoinRoot.modByMonicHom` sends the equivalence class of `f` mod `g` to `f %ₘ g`.
This is a well-defined right inverse to `AdjoinRoot.mk`, see `AdjoinRoot.mk_leftInverse`. -/
def modByMonicHom (hg : g.Monic) : AdjoinRoot g →ₗ[R] R[X] :=
(Submodule.liftQ _ (Polynomial.modByMonicHom g)
fun f (hf : f ∈ (Ideal.span {g}).restrictScalars R) =>
(mem_ker_modByMonic hg).mpr (Ideal.mem_span_singleton.mp hf)).comp <|
(Submodule.Quotient.restrictScalarsEquiv R (Ideal.span {g} : Ideal R[X])).symm.toLinearMap
@[simp]
theorem modByMonicHom_mk (hg : g.Monic) (f : R[X]) : modByMonicHom hg (mk g f) = f %ₘ g :=
rfl
theorem mk_leftInverse (hg : g.Monic) : Function.LeftInverse (mk g) (modByMonicHom hg) := by
intro f
induction f using AdjoinRoot.induction_on
rw [modByMonicHom_mk hg, mk_eq_mk, modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel_left,
dvd_neg]
apply dvd_mul_right
theorem mk_surjective : Function.Surjective (mk g) :=
Ideal.Quotient.mk_surjective
/-- The elements `1, root g, ..., root g ^ (d - 1)` form a basis for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
def powerBasisAux' (hg : g.Monic) : Basis (Fin g.natDegree) R (AdjoinRoot g) :=
.ofEquivFun
{ toFun := fun f i => (modByMonicHom hg f).coeff i
invFun := fun c => mk g <| ∑ i : Fin g.natDegree, monomial i (c i)
map_add' := fun f₁ f₂ =>
funext fun i => by simp only [(modByMonicHom hg).map_add, coeff_add, Pi.add_apply]
map_smul' := fun f₁ f₂ =>
funext fun i => by
simp only [(modByMonicHom hg).map_smul, coeff_smul, Pi.smul_apply, RingHom.id_apply]
left_inv f := AdjoinRoot.induction_on _ f fun f => Eq.symm <| mk_eq_mk.mpr <| by
simp only [modByMonicHom_mk, sum_modByMonic_coeff hg degree_le_natDegree]
rw [modByMonic_eq_sub_mul_div _ hg, sub_sub_cancel]
exact dvd_mul_right _ _
right_inv := fun x =>
funext fun i => by
nontriviality R
simp only [modByMonicHom_mk]
rw [(modByMonic_eq_self_iff hg).mpr, finset_sum_coeff]
· simp_rw [coeff_monomial, Fin.val_eq_val, Finset.sum_ite_eq', if_pos (Finset.mem_univ _)]
· simp_rw [← C_mul_X_pow_eq_monomial]
exact (degree_eq_natDegree <| hg.ne_zero).symm ▸ degree_sum_fin_lt _ }
-- This lemma could be autogenerated by `@[simps]` but unfortunately that would require
-- unfolding that causes a timeout.
-- This lemma should have the simp tag but this causes a lint issue.
theorem powerBasisAux'_repr_symm_apply (hg : g.Monic) (c : Fin g.natDegree →₀ R) :
(powerBasisAux' hg).repr.symm c = mk g (∑ i : Fin _, monomial i (c i)) :=
rfl
-- This lemma could be autogenerated by `@[simps]` but unfortunately that would require
-- unfolding that causes a timeout.
@[simp]
theorem powerBasisAux'_repr_apply_to_fun (hg : g.Monic) (f : AdjoinRoot g) (i : Fin g.natDegree) :
(powerBasisAux' hg).repr f i = (modByMonicHom hg f).coeff ↑i :=
rfl
/-- The power basis `1, root g, ..., root g ^ (d - 1)` for `AdjoinRoot g`,
where `g` is a monic polynomial of degree `d`. -/
@[simps]
def powerBasis' (hg : g.Monic) : PowerBasis R (AdjoinRoot g) where
gen := root g
dim := g.natDegree
basis := powerBasisAux' hg
basis_eq_pow i := by
simp only [powerBasisAux', Basis.coe_ofEquivFun, LinearEquiv.coe_symm_mk]
rw [Finset.sum_eq_single i]
· rw [Pi.single_eq_same, monomial_one_right_eq_X_pow, (mk g).map_pow, mk_X]
· intro j _ hj
rw [← monomial_zero_right _, Pi.single_eq_of_ne hj]
-- Fix `DecidableEq` mismatch
· intros
have := Finset.mem_univ i
contradiction
lemma _root_.Polynomial.Monic.free_adjoinRoot (hg : g.Monic) : Module.Free R (AdjoinRoot g) :=
.of_basis (powerBasis' hg).basis
lemma _root_.Polynomial.Monic.finite_adjoinRoot (hg : g.Monic) : Module.Finite R (AdjoinRoot g) :=
.of_basis (powerBasis' hg).basis
/-- An unwrapped version of `AdjoinRoot.free_of_monic` for better discoverability. -/
lemma _root_.Polynomial.Monic.free_quotient (hg : g.Monic) :
Module.Free R (R[X] ⧸ Ideal.span {g}) :=
hg.free_adjoinRoot
/-- An unwrapped version of `AdjoinRoot.finite_of_monic` for better discoverability. -/
lemma _root_.Polynomial.Monic.finite_quotient (hg : g.Monic) :
Module.Finite R (R[X] ⧸ Ideal.span {g}) :=
hg.finite_adjoinRoot
variable [Field K] {f : K[X]}
theorem isIntegral_root (hf : f ≠ 0) : IsIntegral K (root f) :=
(isAlgebraic_root hf).isIntegral
theorem minpoly_root (hf : f ≠ 0) : minpoly K (root f) = f * C f.leadingCoeff⁻¹ := by
have f'_monic : Monic _ := monic_mul_leadingCoeff_inv hf
refine (minpoly.unique K _ f'_monic ?_ ?_).symm
· rw [map_mul, aeval_eq, mk_self, zero_mul]
intro q q_monic q_aeval
have commutes : (lift (algebraMap K (AdjoinRoot f)) (root f) q_aeval).comp (mk q) = mk f := by
ext
· simp only [RingHom.comp_apply, mk_C, lift_of]
rfl
· simp only [RingHom.comp_apply, mk_X, lift_root]
rw [degree_eq_natDegree f'_monic.ne_zero, degree_eq_natDegree q_monic.ne_zero,
Nat.cast_le, natDegree_mul hf, natDegree_C, add_zero]
· apply natDegree_le_of_dvd
· have : mk f q = 0 := by rw [← commutes, RingHom.comp_apply, mk_self, RingHom.map_zero]
exact mk_eq_zero.1 this
· exact q_monic.ne_zero
· rwa [Ne, C_eq_zero, inv_eq_zero, leadingCoeff_eq_zero]
/-- The elements `1, root f, ..., root f ^ (d - 1)` form a basis for `AdjoinRoot f`,
where `f` is an irreducible polynomial over a field of degree `d`. -/
def powerBasisAux (hf : f ≠ 0) : Basis (Fin f.natDegree) K (AdjoinRoot f) := by
let f' := f * C f.leadingCoeff⁻¹
have deg_f' : f'.natDegree = f.natDegree := by
rw [natDegree_mul hf, natDegree_C, add_zero]
· rwa [Ne, C_eq_zero, inv_eq_zero, leadingCoeff_eq_zero]
have minpoly_eq : minpoly K (root f) = f' := minpoly_root hf
apply Basis.mk (v := fun i : Fin f.natDegree ↦ root f ^ i.val)
· rw [← deg_f', ← minpoly_eq]
exact linearIndependent_pow (root f)
· rintro y -
rw [← deg_f', ← minpoly_eq]
apply (isIntegral_root hf).mem_span_pow
obtain ⟨g⟩ := y
use g
rw [aeval_eq]
rfl
/-- The power basis `1, root f, ..., root f ^ (d - 1)` for `AdjoinRoot f`,
where `f` is an irreducible polynomial over a field of degree `d`. -/
@[simps!]
def powerBasis (hf : f ≠ 0) : PowerBasis K (AdjoinRoot f) where
gen := root f
dim := f.natDegree
basis := powerBasisAux hf
basis_eq_pow := by simp [powerBasisAux]
theorem minpoly_powerBasis_gen (hf : f ≠ 0) :
minpoly K (powerBasis hf).gen = f * C f.leadingCoeff⁻¹ := by
rw [powerBasis_gen, minpoly_root hf]
theorem minpoly_powerBasis_gen_of_monic (hf : f.Monic) (hf' : f ≠ 0 := hf.ne_zero) :
minpoly K (powerBasis hf').gen = f := by
rw [minpoly_powerBasis_gen hf', hf.leadingCoeff, inv_one, C.map_one, mul_one]
/--
See `finrank_quotient_span_eq_natDegree'` for a version over a ring when `f` is monic.
-/
theorem _root_.finrank_quotient_span_eq_natDegree {f : K[X]} :
Module.finrank K (K[X] ⧸ Ideal.span {f}) = f.natDegree := by
by_cases hf : f = 0
· rw [hf, natDegree_zero,
((Submodule.quotEquivOfEqBot _ (by simp)).restrictScalars K).finrank_eq]
exact finrank_of_not_finite Polynomial.not_finite
rw [PowerBasis.finrank]
exact AdjoinRoot.powerBasis_dim hf
end PowerBasis
section Equiv
section minpoly
variable [CommRing R] [CommRing S] [Algebra R S] (x : S) (R)
open Algebra Polynomial
/-- The surjective algebra morphism `R[X]/(minpoly R x) → R[x]`.
If `R` is a integrally closed domain and `x` is integral, this is an isomorphism,
see `minpoly.equivAdjoin`. -/
def Minpoly.toAdjoin : AdjoinRoot (minpoly R x) →ₐ[R] adjoin R ({x} : Set S) :=
liftAlgHom _ (Algebra.ofId R <| adjoin R {x}) ⟨x, self_mem_adjoin_singleton R x⟩
(by change aeval _ _ = _; simp [← Subalgebra.coe_eq_zero, aeval_subalgebra_coe])
variable {R x}
@[simp]
theorem Minpoly.coe_toAdjoin :
⇑(Minpoly.toAdjoin R x) = liftAlgHom (minpoly R x) (Algebra.ofId R <| adjoin R {x})
⟨x, self_mem_adjoin_singleton R x⟩
(by change aeval _ _ = _; simp [← Subalgebra.coe_eq_zero, aeval_subalgebra_coe]) := rfl
@[deprecated (since := "2025-07-21")] alias Minpoly.toAdjoin_apply := Minpoly.coe_toAdjoin
@[deprecated (since := "2025-07-21")] alias Minpoly.toAdjoin_apply' := Minpoly.coe_toAdjoin
theorem Minpoly.coe_toAdjoin_mk_X : Minpoly.toAdjoin R x (mk (minpoly R x) X) = x := by simp
@[deprecated (since := "2025-07-21")] alias Minpoly.toAdjoin.apply_X := Minpoly.coe_toAdjoin_mk_X
variable (R x)
theorem Minpoly.toAdjoin.surjective : Function.Surjective (Minpoly.toAdjoin R x) := by
rw [← AlgHom.range_eq_top, _root_.eq_top_iff, ← adjoin_adjoin_coe_preimage]
exact adjoin_le fun ⟨y₁, y₂⟩ h ↦ ⟨mk (minpoly R x) X, by simpa using h.symm⟩
end minpoly
section Equiv'
variable [CommRing R] [CommRing S] [Algebra R S]
variable (g : R[X]) (pb : PowerBasis R S)
/-- If `S` is an extension of `R` with power basis `pb` and `g` is a monic polynomial over `R`
such that `pb.gen` has a minimal polynomial `g`, then `S` is isomorphic to `AdjoinRoot g`.
Compare `PowerBasis.equivOfRoot`, which would require
`h₂ : aeval pb.gen (minpoly R (root g)) = 0`; that minimal polynomial is not
guaranteed to be identical to `g`. -/
@[simps -fullyApplied]
def equiv' (h₁ : aeval (root g) (minpoly R pb.gen) = 0) (h₂ : aeval pb.gen g = 0) :
AdjoinRoot g ≃ₐ[R] S where
__ := AdjoinRoot.liftAlgHom g _ pb.gen h₂
toFun := AdjoinRoot.liftAlgHom g _ pb.gen h₂
invFun := pb.lift (root g) h₁
left_inv x := AdjoinRoot.induction_on _ x fun x => by
change pb.lift _ _ (aeval _ _) = _; rw [pb.lift_aeval, aeval_eq]
right_inv x := by
nontriviality S
obtain ⟨f, _hf, rfl⟩ := pb.exists_eq_aeval x
rw [pb.lift_aeval, aeval_eq, liftAlgHom_mk, Polynomial.aeval_def, Algebra.toRingHom_ofId]
-- This lemma should have the simp tag but this causes a lint issue.
theorem equiv'_toAlgHom (h₁ : aeval (root g) (minpoly R pb.gen) = 0) (h₂ : aeval pb.gen g = 0) :
(equiv' g pb h₁ h₂).toAlgHom = AdjoinRoot.liftAlgHom g _ pb.gen h₂ :=
rfl
-- This lemma should have the simp tag but this causes a lint issue.
theorem equiv'_symm_toAlgHom (h₁ : aeval (root g) (minpoly R pb.gen) = 0)
(h₂ : aeval pb.gen g = 0) : (equiv' g pb h₁ h₂).symm.toAlgHom = pb.lift (root g) h₁ :=
rfl
end Equiv'
section Field
variable (L F : Type*) [Field F] [CommRing L] [IsDomain L] [Algebra F L]
/-- If `L` is a field extension of `F` and `f` is a polynomial over `F` then the set
of maps from `F[x]/(f)` into `L` is in bijection with the set of roots of `f` in `L`. -/
def equiv (f : F[X]) (hf : f ≠ 0) :
(AdjoinRoot f →ₐ[F] L) ≃ { x // x ∈ f.aroots L } :=
(powerBasis hf).liftEquiv'.trans
((Equiv.refl _).subtypeEquiv fun x => by
rw [powerBasis_gen, minpoly_root hf, aroots_mul, aroots_C, add_zero, Equiv.refl_apply]
exact (monic_mul_leadingCoeff_inv hf).ne_zero)
end Field
end Equiv
-- TODO: consider splitting the file here. In the current mathlib3, the only result
-- that depends any of these lemmas was
-- `normalizedFactorsMapEquivNormalizedFactorsMinPolyMk` in `NumberTheory.KummerDedekind`
-- that uses
-- `PowerBasis.quotientEquivQuotientMinpolyMap == PowerBasis.quotientEquivQuotientMinpolyMap`
section
open Ideal DoubleQuot Polynomial
variable [CommRing R] (I : Ideal R) (f : R[X])
/-- The natural isomorphism `R[α]/(I[α]) ≅ R[α]/((I[x] ⊔ (f)) / (f))` for `α` a root of
`f : R[X]` and `I : Ideal R`.
See `adjoin_root.quot_map_of_equiv` for the isomorphism with `(R/I)[X] / (f mod I)`. -/
def quotMapOfEquivQuotMapCMapSpanMk :
AdjoinRoot f ⧸ I.map (of f) ≃+*
AdjoinRoot f ⧸ (I.map (C : R →+* R[X])).map (Ideal.Quotient.mk (span {f})) :=
Ideal.quotEquivOfEq (by rw [of, AdjoinRoot.mk, Ideal.map_map])
@[simp]
theorem quotMapOfEquivQuotMapCMapSpanMk_mk (x : AdjoinRoot f) :
quotMapOfEquivQuotMapCMapSpanMk I f (Ideal.Quotient.mk (I.map (of f)) x) =
Ideal.Quotient.mk (Ideal.map (Ideal.Quotient.mk (span {f})) (I.map (C : R →+* R[X]))) x := rfl
--this lemma should have the simp tag but this causes a lint issue
theorem quotMapOfEquivQuotMapCMapSpanMk_symm_mk (x : AdjoinRoot f) :
(quotMapOfEquivQuotMapCMapSpanMk I f).symm
(Ideal.Quotient.mk ((I.map (C : R →+* R[X])).map (Ideal.Quotient.mk (span {f}))) x) =
Ideal.Quotient.mk (I.map (of f)) x := by
rw [quotMapOfEquivQuotMapCMapSpanMk, Ideal.quotEquivOfEq_symm]
exact Ideal.quotEquivOfEq_mk _ _
/-- The natural isomorphism `R[α]/((I[x] ⊔ (f)) / (f)) ≅ (R[x]/I[x])/((f) ⊔ I[x] / I[x])`
for `α` a root of `f : R[X]` and `I : Ideal R` -/
def quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk :
AdjoinRoot f ⧸ (I.map (C : R →+* R[X])).map (Ideal.Quotient.mk (span ({f} : Set R[X]))) ≃+*
(R[X] ⧸ I.map (C : R →+* R[X])) ⧸
(span ({f} : Set R[X])).map (Ideal.Quotient.mk (I.map (C : R →+* R[X]))) :=
quotQuotEquivComm (Ideal.span ({f} : Set R[X])) (I.map (C : R →+* R[X]))
-- This lemma should have the simp tag but this causes a lint issue.
theorem quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_mk (p : R[X]) :
quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk I f (Ideal.Quotient.mk _ (mk f p)) =
quotQuotMk (I.map C) (span {f}) p :=
rfl
@[simp]
theorem quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_symm_quotQuotMk (p : R[X]) :
(quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk I f).symm (quotQuotMk (I.map C) (span {f}) p) =
Ideal.Quotient.mk (Ideal.map (Ideal.Quotient.mk (span {f})) (I.map (C : R →+* R[X])))
(mk f p) :=
rfl
/-- The natural isomorphism `(R/I)[x]/(f mod I) ≅ (R[x]/I*R[x])/(f mod I[x])` where
`f : R[X]` and `I : Ideal R` -/
def Polynomial.quotQuotEquivComm :
(R ⧸ I)[X] ⧸ span ({f.map (Ideal.Quotient.mk I)} : Set (Polynomial (R ⧸ I))) ≃+*
(R[X] ⧸ (I.map C)) ⧸ span ({(Ideal.Quotient.mk (I.map C)) f} : Set (R[X] ⧸ (I.map C))) :=
quotientEquiv (span ({f.map (Ideal.Quotient.mk I)} : Set (Polynomial (R ⧸ I))))
(span {Ideal.Quotient.mk (I.map Polynomial.C) f}) (polynomialQuotientEquivQuotientPolynomial I)
(by
rw [map_span, Set.image_singleton, RingEquiv.coe_toRingHom,
polynomialQuotientEquivQuotientPolynomial_map_mk I f])
@[simp]
theorem Polynomial.quotQuotEquivComm_mk (p : R[X]) :
(Polynomial.quotQuotEquivComm I f) (Ideal.Quotient.mk _ (p.map (Ideal.Quotient.mk I))) =
Ideal.Quotient.mk (span ({(Ideal.Quotient.mk (I.map C)) f} : Set (R[X] ⧸ (I.map C))))
(Ideal.Quotient.mk (I.map C) p) := by
simp only [Polynomial.quotQuotEquivComm, quotientEquiv_mk,
polynomialQuotientEquivQuotientPolynomial_map_mk]
@[simp]
theorem Polynomial.quotQuotEquivComm_symm_mk_mk (p : R[X]) :
(Polynomial.quotQuotEquivComm I f).symm (Ideal.Quotient.mk (span
({(Ideal.Quotient.mk (I.map C)) f} : Set (R[X] ⧸ (I.map C)))) (Ideal.Quotient.mk (I.map C) p)) =
Ideal.Quotient.mk (span {f.map (Ideal.Quotient.mk I)}) (p.map (Ideal.Quotient.mk I)) := by
simp only [Polynomial.quotQuotEquivComm, quotientEquiv_symm_mk,
polynomialQuotientEquivQuotientPolynomial_symm_mk]
/-- The natural isomorphism `R[α]/I[α] ≅ (R/I)[X]/(f mod I)` for `α` a root of `f : R[X]`
and `I : Ideal R`. -/
def quotAdjoinRootEquivQuotPolynomialQuot :
AdjoinRoot f ⧸ I.map (of f) ≃+*
(R ⧸ I)[X] ⧸ span ({f.map (Ideal.Quotient.mk I)} : Set (R ⧸ I)[X]) :=
(quotMapOfEquivQuotMapCMapSpanMk I f).trans
((quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk I f).trans
((Ideal.quotEquivOfEq (by rw [map_span, Set.image_singleton])).trans
(Polynomial.quotQuotEquivComm I f).symm))
@[simp]
theorem quotAdjoinRootEquivQuotPolynomialQuot_mk_of (p : R[X]) :
quotAdjoinRootEquivQuotPolynomialQuot I f (Ideal.Quotient.mk (I.map (of f)) (mk f p)) =
Ideal.Quotient.mk (span ({f.map (Ideal.Quotient.mk I)} : Set (R ⧸ I)[X]))
(p.map (Ideal.Quotient.mk I)) := rfl
@[simp]
theorem quotAdjoinRootEquivQuotPolynomialQuot_symm_mk_mk (p : R[X]) :
(quotAdjoinRootEquivQuotPolynomialQuot I f).symm
(Ideal.Quotient.mk (span ({f.map (Ideal.Quotient.mk I)} : Set (R ⧸ I)[X]))
(p.map (Ideal.Quotient.mk I))) =
Ideal.Quotient.mk (I.map (of f)) (mk f p) := by
rw [quotAdjoinRootEquivQuotPolynomialQuot, RingEquiv.symm_trans_apply,
RingEquiv.symm_trans_apply, RingEquiv.symm_trans_apply, RingEquiv.symm_symm,
Polynomial.quotQuotEquivComm_mk, Ideal.quotEquivOfEq_symm, Ideal.quotEquivOfEq_mk, ←
RingHom.comp_apply, ← DoubleQuot.quotQuotMk,
quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_symm_quotQuotMk,
quotMapOfEquivQuotMapCMapSpanMk_symm_mk]
/-- Promote `AdjoinRoot.quotAdjoinRootEquivQuotPolynomialQuot` to an alg_equiv. -/
@[simps!]
noncomputable def quotEquivQuotMap (f : R[X]) (I : Ideal R) :
(AdjoinRoot f ⧸ Ideal.map (of f) I) ≃ₐ[R]
(R ⧸ I)[X] ⧸ Ideal.span ({Polynomial.map (Ideal.Quotient.mk I) f} : Set (R ⧸ I)[X]) :=
AlgEquiv.ofRingEquiv
(show ∀ x, (quotAdjoinRootEquivQuotPolynomialQuot I f) (algebraMap R _ x) = algebraMap R _ x
from fun x => by
have :
algebraMap R (AdjoinRoot f ⧸ Ideal.map (of f) I) x =
Ideal.Quotient.mk (Ideal.map (AdjoinRoot.of f) I) ((mk f) (C x)) :=
rfl
rw [this, quotAdjoinRootEquivQuotPolynomialQuot_mk_of, map_C, Quotient.alg_map_eq]
simp only [RingHom.comp_apply, Quotient.algebraMap_eq, Polynomial.algebraMap_apply])
@[simp]
theorem quotEquivQuotMap_apply_mk (f g : R[X]) (I : Ideal R) :
AdjoinRoot.quotEquivQuotMap f I (Ideal.Quotient.mk (Ideal.map (of f) I) (AdjoinRoot.mk f g)) =
Ideal.Quotient.mk (Ideal.span ({Polynomial.map (Ideal.Quotient.mk I) f} : Set (R ⧸ I)[X]))
(g.map (Ideal.Quotient.mk I)) := by
rw [AdjoinRoot.quotEquivQuotMap_apply, AdjoinRoot.quotAdjoinRootEquivQuotPolynomialQuot_mk_of]
theorem quotEquivQuotMap_symm_apply_mk (f g : R[X]) (I : Ideal R) :
(AdjoinRoot.quotEquivQuotMap f I).symm (Ideal.Quotient.mk _
(Polynomial.map (Ideal.Quotient.mk I) g)) =
Ideal.Quotient.mk (Ideal.map (of f) I) (AdjoinRoot.mk f g) := by
rw [AdjoinRoot.quotEquivQuotMap_symm_apply,
AdjoinRoot.quotAdjoinRootEquivQuotPolynomialQuot_symm_mk_mk]
end
end AdjoinRoot
namespace PowerBasis
open AdjoinRoot AlgEquiv
variable [CommRing R] [CommRing S] [Algebra R S]
/-- Let `α` have minimal polynomial `f` over `R` and `I` be an ideal of `R`,
then `R[α] / (I) = (R[x] / (f)) / pS = (R/p)[x] / (f mod p)`. -/
@[simps!]
noncomputable def quotientEquivQuotientMinpolyMap (pb : PowerBasis R S) (I : Ideal R) :
(S ⧸ I.map (algebraMap R S)) ≃ₐ[R]
Polynomial (R ⧸ I) ⧸
Ideal.span ({(minpoly R pb.gen).map (Ideal.Quotient.mk I)} : Set (Polynomial (R ⧸ I))) :=
(ofRingEquiv
(show ∀ x,
(Ideal.quotientEquiv _ (Ideal.map (AdjoinRoot.of (minpoly R pb.gen)) I)
(AdjoinRoot.equiv' (minpoly R pb.gen) pb
(by rw [AdjoinRoot.aeval_eq, AdjoinRoot.mk_self])
(minpoly.aeval _ _)).symm.toRingEquiv
(by rw [Ideal.map_map, AlgEquiv.toRingEquiv_eq_coe,
← AlgEquiv.coe_ringHom_commutes, ← AdjoinRoot.algebraMap_eq,
AlgHom.comp_algebraMap]))
(algebraMap R (S ⧸ I.map (algebraMap R S)) x) = algebraMap R _ x from fun x => by
rw [← Ideal.Quotient.mk_algebraMap, Ideal.quotientEquiv_apply,
RingHom.toFun_eq_coe, Ideal.quotientMap_mk, AlgEquiv.toRingEquiv_eq_coe,
RingEquiv.coe_toRingHom, AlgEquiv.coe_ringEquiv, AlgEquiv.commutes,
Quotient.mk_algebraMap])).trans (AdjoinRoot.quotEquivQuotMap _ _)
-- This lemma should have the simp tag but this causes a lint issue.
theorem quotientEquivQuotientMinpolyMap_apply_mk (pb : PowerBasis R S) (I : Ideal R) (g : R[X]) :
pb.quotientEquivQuotientMinpolyMap I (Ideal.Quotient.mk (I.map (algebraMap R S))
(aeval pb.gen g)) = Ideal.Quotient.mk
(Ideal.span ({(minpoly R pb.gen).map (Ideal.Quotient.mk I)} : Set (Polynomial (R ⧸ I))))
(g.map (Ideal.Quotient.mk I)) := by
rw [PowerBasis.quotientEquivQuotientMinpolyMap, AlgEquiv.trans_apply, AlgEquiv.ofRingEquiv_apply,
quotientEquiv_mk, AlgEquiv.coe_ringEquiv', AdjoinRoot.equiv'_symm_apply, PowerBasis.lift_aeval,
AdjoinRoot.aeval_eq, AdjoinRoot.quotEquivQuotMap_apply_mk]
-- This lemma should have the simp tag but this causes a lint issue.
theorem quotientEquivQuotientMinpolyMap_symm_apply_mk (pb : PowerBasis R S) (I : Ideal R)
(g : R[X]) :
(pb.quotientEquivQuotientMinpolyMap I).symm (Ideal.Quotient.mk (Ideal.span
({(minpoly R pb.gen).map (Ideal.Quotient.mk I)} : Set (Polynomial (R ⧸ I))))
(g.map (Ideal.Quotient.mk I))) = Ideal.Quotient.mk (I.map (algebraMap R S))
(aeval pb.gen g) := by
simp [quotientEquivQuotientMinpolyMap, aeval_def]
end PowerBasis
/-- If `L / K` is an integral extension, `K` is a domain, `L` is a field, then any irreducible
polynomial over `L` divides some monic irreducible polynomial over `K`. -/
theorem Irreducible.exists_dvd_monic_irreducible_of_isIntegral {K L : Type*}
[CommRing K] [IsDomain K] [Field L] [Algebra K L] [Algebra.IsIntegral K L] {f : L[X]}
(hf : Irreducible f) : ∃ g : K[X], g.Monic ∧ Irreducible g ∧ f ∣ g.map (algebraMap K L) := by
haveI := Fact.mk hf
have h := hf.ne_zero
have h2 := isIntegral_trans (R := K) _ (AdjoinRoot.isIntegral_root h)
have h3 := (AdjoinRoot.minpoly_root h) ▸ minpoly.dvd_map_of_isScalarTower K L (AdjoinRoot.root f)
exact ⟨_, minpoly.monic h2, minpoly.irreducible h2, dvd_of_mul_right_dvd h3⟩ |
.lake/packages/mathlib/Mathlib/RingTheory/LittleWedderburn.lean | import Mathlib.Algebra.GroupWithZero.Action.Center
import Mathlib.GroupTheory.ClassEquation
import Mathlib.RingTheory.Polynomial.Cyclotomic.Eval
/-!
# Wedderburn's Little Theorem
This file proves Wedderburn's Little Theorem.
## Main Declarations
* `littleWedderburn`: a finite division ring is a field.
## Future work
A couple simple generalisations are possible:
* A finite ring is commutative iff all its nilpotents lie in the center.
[Chintala, Vineeth, *Sorry, the Nilpotents Are in the Center*][chintala2020]
* A ring is commutative if all its elements have finite order.
[Dolan, S. W., *A Proof of Jacobson's Theorem*][dolan1975]
When alternativity is added to Mathlib, one could formalise the Artin-Zorn theorem, which states
that any finite alternative division ring is in fact a field.
https://en.wikipedia.org/wiki/Artin%E2%80%93Zorn_theorem
If interested, generalisations to semifields could be explored. The theory of semi-vector spaces is
not clear, but assuming that such a theory could be found where every module considered in the
below proof is free, then the proof works nearly verbatim.
-/
open scoped Polynomial
open Fintype
/-! Everything in this namespace is internal to the proof of Wedderburn's little theorem. -/
namespace LittleWedderburn
variable (D : Type*) [DivisionRing D]
private def InductionHyp : Prop :=
∀ {R : Subring D}, R < ⊤ → ∀ ⦃x y⦄, x ∈ R → y ∈ R → x * y = y * x
namespace InductionHyp
open Module Polynomial
variable {D}
private def field (hD : InductionHyp D) {R : Subring D} (hR : R < ⊤)
[Fintype D] [DecidableEq D] [DecidablePred (· ∈ R)] :
Field R :=
{ show DivisionRing R from Fintype.divisionRingOfIsDomain R with
mul_comm := fun x y ↦ Subtype.ext <| hD hR x.2 y.2 }
/-- We prove that if every subring of `D` is central, then so is `D`. -/
private theorem center_eq_top [Finite D] (hD : InductionHyp D) : Subring.center D = ⊤ := by
classical
cases nonempty_fintype D
set Z := Subring.center D
-- We proceed by contradiction; that is, we assume the center is strictly smaller than `D`.
by_contra! hZ
letI : Field Z := hD.field hZ.lt_top
set q := card Z with card_Z
have hq : 1 < q := by rw [card_Z]; exact one_lt_card
let n := finrank Z D
have card_D : card D = q ^ n := Module.card_eq_pow_finrank
have h1qn : 1 ≤ q ^ n := by rw [← card_D]; exact card_pos
-- We go about this by looking at the class equation for `Dˣ`:
-- `q ^ n - 1 = q - 1 + ∑ x : conjugacy classes (D ∖ Dˣ), |x|`.
-- The next few lines gets the equation into basically this form over `ℤ`.
have key := Group.card_center_add_sum_card_noncenter_eq_card (Dˣ)
rw [card_congr (show _ ≃* Zˣ from Subgroup.centerUnitsEquivUnitsCenter D).toEquiv,
card_units, ← card_Z, card_units, card_D] at key
-- By properties of the cyclotomic function, we have that `Φₙ(q) ∣ q ^ n - 1`; however, when
-- `n ≠ 1`, then `¬Φₙ(q) | q - 1`; so if the sum over the conjugacy classes is divisible by
-- `Φₙ(q)`, then `n = 1`, and therefore the vector space is trivial, as desired.
let Φₙ := cyclotomic n ℤ
apply_fun (Nat.cast : ℕ → ℤ) at key
rw [Nat.cast_add, Nat.cast_sub h1qn, Nat.cast_sub hq.le, Nat.cast_one, Nat.cast_pow] at key
suffices Φₙ.eval ↑q ∣ ↑(∑ x ∈ (ConjClasses.noncenter Dˣ).toFinset, x.carrier.toFinset.card) by
have contra : Φₙ.eval _ ∣ _ := eval_dvd (cyclotomic.dvd_X_pow_sub_one n ℤ) (x := (q : ℤ))
rw [eval_sub, eval_X_pow, eval_one, ← key, Int.dvd_add_left this] at contra
refine (Nat.le_of_dvd ?_ ?_).not_gt (sub_one_lt_natAbs_cyclotomic_eval (n := n) ?_ hq.ne')
· exact tsub_pos_of_lt hq
· convert Int.natAbs_dvd_natAbs.mpr contra
clear_value q
simp only [eq_comm, Int.natAbs_eq_iff, Nat.cast_sub hq.le, Nat.cast_one, neg_sub, true_or]
· by_contra! h
obtain ⟨x, hx⟩ := finrank_le_one_iff.mp h
refine not_le_of_gt hZ.lt_top (fun y _ ↦ Subring.mem_center_iff.mpr fun z ↦ ?_)
obtain ⟨r, rfl⟩ := hx y
obtain ⟨s, rfl⟩ := hx z
rw [smul_mul_smul_comm, smul_mul_smul_comm, mul_comm]
rw [Nat.cast_sum]
apply Finset.dvd_sum
rintro ⟨x⟩ hx
simp -zeta only [ConjClasses.quot_mk_eq_mk, Set.mem_toFinset] at hx ⊢
set Zx := Subring.centralizer ({↑x} : Set D)
-- The key thing is then to note that for all conjugacy classes `x`, `|x|` is given by
-- `|Dˣ| / |Zxˣ|`, where `Zx` is the centralizer of `x`; but `Zx` is an algebra over `Z`, and
-- therefore `|Zxˣ| = q ^ d - 1`, where `d` is the dimension of `D` as a vector space over `Z`.
-- We therefore get that `|x| = (q ^ n - 1) / (q ^ d - 1)`, and as `d` is a strict divisor of `n`,
-- we do have that `Φₙ(q) | (q ^ n - 1) / (q ^ d - 1)`; extending this over the whole sum
-- gives us the desired contradiction..
rw [Set.toFinset_card, ConjClasses.card_carrier, ← card_congr
(show Zxˣ ≃* _ from unitsCentralizerEquiv _ x).toEquiv, card_units, card_D]
have hZx : Zx ≠ ⊤ := by
by_contra! hZx
refine (ConjClasses.mk_bijOn (Dˣ)).mapsTo (Set.subset_center_units ?_) hx
exact Subring.centralizer_eq_top_iff_subset.mp hZx <| Set.mem_singleton _
letI : Field Zx := hD.field hZx.lt_top
letI : Algebra Z Zx := (Subring.inclusion <| Subring.center_le_centralizer {(x : D)}).toAlgebra
let d := finrank Z Zx
have card_Zx : card Zx = q ^ d := Module.card_eq_pow_finrank
have h1qd : 1 ≤ q ^ d := by rw [← card_Zx]; exact card_pos
haveI : IsScalarTower Z Zx D := ⟨fun x y z ↦ mul_assoc _ _ _⟩
rw [card_units, card_Zx, Int.natCast_div, Nat.cast_sub h1qd, Nat.cast_sub h1qn, Nat.cast_one,
Nat.cast_pow, Nat.cast_pow]
apply Int.dvd_div_of_mul_dvd
have aux : ∀ {k : ℕ}, ((X : ℤ[X]) ^ k - 1).eval ↑q = (q : ℤ) ^ k - 1 := by
simp only [eval_X, eval_one, eval_pow, eval_sub, forall_const]
rw [← aux, ← aux, ← eval_mul]
refine map_dvd (evalRingHom ↑q) (X_pow_sub_one_mul_cyclotomic_dvd_X_pow_sub_one_of_dvd ℤ ?_)
refine Nat.mem_properDivisors.mpr ⟨⟨_, (finrank_mul_finrank Z Zx D).symm⟩, ?_⟩
rw [← Nat.pow_lt_pow_iff_right hq, ← card_D, ← card_Zx]
obtain ⟨b, -, hb⟩ := SetLike.exists_of_lt hZx.lt_top
refine card_lt_of_injective_of_notMem _ Subtype.val_injective (?_ : b ∉ _)
rintro ⟨b, rfl⟩
exact hb b.2
end InductionHyp
private theorem center_eq_top [Finite D] : Subring.center D = ⊤ := by
classical
cases nonempty_fintype D
induction hn : Fintype.card D using Nat.strong_induction_on generalizing D with | _ n IH
apply InductionHyp.center_eq_top
intro R hR x y hx hy
suffices (⟨y, hy⟩ : R) ∈ Subring.center R by
rw [Subring.mem_center_iff] at this
simpa using this ⟨x, hx⟩
let R_dr : DivisionRing R := Fintype.divisionRingOfIsDomain R
rw [IH (Fintype.card R) _ R inferInstance rfl]
· trivial
rw [← hn, ← Subring.card_top D]
convert Set.card_lt_card hR
end LittleWedderburn
open LittleWedderburn
/-- A finite division ring is a field. See `Finite.isDomain_to_isField` and
`Fintype.divisionRingOfIsDomain` for more general statements, but these create data, and therefore
may cause diamonds if used improperly. -/
instance (priority := 100) littleWedderburn (D : Type*) [DivisionRing D] [Finite D] : Field D :=
{ ‹DivisionRing D› with
mul_comm := fun x y ↦ by simp [Subring.mem_center_iff.mp ?_ x, center_eq_top D] }
alias Finite.divisionRing_to_field := littleWedderburn
/-- A finite domain is a field. See also `littleWedderburn` and `Fintype.divisionRingOfIsDomain`. -/
theorem Finite.isDomain_to_isField (D : Type*) [Finite D] [Ring D] [IsDomain D] : IsField D := by
classical
cases nonempty_fintype D
let _ := Fintype.divisionRingOfIsDomain D
let _ := littleWedderburn D
exact Field.toIsField D |
.lake/packages/mathlib/Mathlib/RingTheory/IsPrimary.lean | import Mathlib.LinearAlgebra.Quotient.Basic
import Mathlib.RingTheory.Ideal.Operations
/-!
# Primary submodules
A proper submodule `S : Submodule R M` is primary iff
`r • x ∈ S` implies `x ∈ S` or `∃ n : ℕ, r ^ n • (⊤ : Submodule R M) ≤ S`.
## Main results
* `Submodule.isPrimary_iff_zero_divisor_quotient_imp_nilpotent_smul`:
A `N : Submodule R M` is primary if any zero divisor on `M ⧸ N` is nilpotent.
See https://mathoverflow.net/questions/3910/primary-decomposition-for-modules
for a comparison of this definition (a la Atiyah-Macdonald) vs "locally nilpotent" (Matsumura).
## Implementation details
This is a generalization of `Ideal.IsPrimary`. For brevity, the pointwise instances are used
to define the nilpotency of `r : R`.
## References
* [M. F. Atiyah and I. G. Macdonald, *Introduction to commutative algebra*][atiyah-macdonald]
Chapter 4, Exercise 21.
-/
open Pointwise
namespace Submodule
section CommSemiring
variable {R M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
/-- A proper submodule `S : Submodule R M` is primary iff
`r • x ∈ S` implies `x ∈ S` or `∃ n : ℕ, r ^ n • (⊤ : Submodule R M) ≤ S`.
This generalizes `Ideal.IsPrimary`. -/
protected def IsPrimary (S : Submodule R M) : Prop :=
S ≠ ⊤ ∧ ∀ {r : R} {x : M}, r • x ∈ S → x ∈ S ∨ ∃ n : ℕ, (r ^ n • ⊤ : Submodule R M) ≤ S
variable {S : Submodule R M}
lemma IsPrimary.ne_top (h : S.IsPrimary) : S ≠ ⊤ := h.left
end CommSemiring
section CommRing
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] {S : Submodule R M}
lemma isPrimary_iff_zero_divisor_quotient_imp_nilpotent_smul :
S.IsPrimary ↔ S ≠ ⊤ ∧ ∀ (r : R) (x : M ⧸ S), x ≠ 0 → r • x = 0 →
∃ n : ℕ, r ^ n • (⊤ : Submodule R (M ⧸ S)) = ⊥ := by
refine (and_congr_right fun _ ↦ ?_)
simp_rw [S.mkQ_surjective.forall, ← map_smul, ne_eq, ← LinearMap.mem_ker, ker_mkQ]
congr! 2
rw [forall_comm, ← or_iff_not_imp_left,
← LinearMap.range_eq_top.mpr S.mkQ_surjective, ← map_top]
simp_rw [eq_bot_iff, ← map_pointwise_smul, map_le_iff_le_comap, comap_bot, ker_mkQ]
end CommRing
end Submodule |
.lake/packages/mathlib/Mathlib/RingTheory/Filtration.lean | import Mathlib.Algebra.Polynomial.Module.Basic
import Mathlib.RingTheory.Finiteness.Nakayama
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.ReesAlgebra
/-!
# `I`-filtrations of modules
This file contains the definitions and basic results around (stable) `I`-filtrations of modules.
## Main results
- `Ideal.Filtration`:
An `I`-filtration on the module `M` is a sequence of decreasing submodules `N i` such that
`∀ i, I • (N i) ≤ N (i + 1)`. Note that we do not require the filtration to start from `⊤`.
- `Ideal.Filtration.Stable`: An `I`-filtration is stable if `I • (N i) = N (i + 1)` for large
enough `i`.
- `Ideal.Filtration.submodule`: The associated module `⨁ Nᵢ` of a filtration, implemented as a
submodule of `M[X]`.
- `Ideal.Filtration.submodule_fg_iff_stable`: If `F.N i` are all finitely generated, then
`F.Stable` iff `F.submodule.FG`.
- `Ideal.Filtration.Stable.of_le`: In a finite module over a Noetherian ring,
if `F' ≤ F`, then `F.Stable → F'.Stable`.
- `Ideal.exists_pow_inf_eq_pow_smul`: **Artin-Rees lemma**.
given `N ≤ M`, there exists a `k` such that `IⁿM ⊓ N = Iⁿ⁻ᵏ(IᵏM ⊓ N)` for all `n ≥ k`.
- `Ideal.iInf_pow_eq_bot_of_isLocalRing`:
**Krull's intersection theorem** (`⨅ i, I ^ i = ⊥`) for Noetherian local rings.
- `Ideal.iInf_pow_eq_bot_of_isDomain`:
**Krull's intersection theorem** (`⨅ i, I ^ i = ⊥`) for Noetherian domains.
-/
variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R)
open Polynomial
open scoped Polynomial
/-- An `I`-filtration on the module `M` is a sequence of decreasing submodules `N i` such that
`I • (N i) ≤ N (i + 1)`. Note that we do not require the filtration to start from `⊤`. -/
@[ext]
structure Ideal.Filtration (M : Type*) [AddCommGroup M] [Module R M] where
N : ℕ → Submodule R M
mono : ∀ i, N (i + 1) ≤ N i
smul_le : ∀ i, I • N i ≤ N (i + 1)
variable (F F' : I.Filtration M) {I}
namespace Ideal.Filtration
theorem pow_smul_le (i j : ℕ) : I ^ i • F.N j ≤ F.N (i + j) := by
induction i with
| zero => simp
| succ _ ih =>
rw [pow_succ', mul_smul, add_assoc, add_comm 1, ← add_assoc]
exact (smul_mono_right _ ih).trans (F.smul_le _)
theorem pow_smul_le_pow_smul (i j k : ℕ) : I ^ (i + k) • F.N j ≤ I ^ k • F.N (i + j) := by
rw [add_comm, pow_add, mul_smul]
exact smul_mono_right _ (F.pow_smul_le i j)
protected theorem antitone : Antitone F.N :=
antitone_nat_of_succ_le F.mono
/-- The trivial `I`-filtration of `N`. -/
@[simps]
def _root_.Ideal.trivialFiltration (I : Ideal R) (N : Submodule R M) : I.Filtration M where
N _ := N
mono _ := le_rfl
smul_le _ := Submodule.smul_le_right
/-- The `sup` of two `I.Filtration`s is an `I.Filtration`. -/
instance : Max (I.Filtration M) :=
⟨fun F F' =>
⟨F.N ⊔ F'.N, fun i => sup_le_sup (F.mono i) (F'.mono i), fun i =>
(Submodule.smul_sup _ _ _).trans_le <| sup_le_sup (F.smul_le i) (F'.smul_le i)⟩⟩
/-- The `sSup` of a family of `I.Filtration`s is an `I.Filtration`. -/
instance : SupSet (I.Filtration M) :=
⟨fun S =>
{ N := sSup (Ideal.Filtration.N '' S)
mono := fun i => by
apply sSup_le_sSup_of_isCofinalFor _
rintro _ ⟨⟨_, F, hF, rfl⟩, rfl⟩
exact ⟨_, ⟨⟨_, F, hF, rfl⟩, rfl⟩, F.mono i⟩
smul_le := fun i => by
rw [sSup_eq_iSup', iSup_apply, Submodule.smul_iSup, iSup_apply]
apply iSup_mono _
rintro ⟨_, F, hF, rfl⟩
exact F.smul_le i }⟩
/-- The `inf` of two `I.Filtration`s is an `I.Filtration`. -/
instance : Min (I.Filtration M) :=
⟨fun F F' =>
⟨F.N ⊓ F'.N, fun i => inf_le_inf (F.mono i) (F'.mono i), fun i =>
(smul_inf_le _ _ _).trans <| inf_le_inf (F.smul_le i) (F'.smul_le i)⟩⟩
/-- The `sInf` of a family of `I.Filtration`s is an `I.Filtration`. -/
instance : InfSet (I.Filtration M) :=
⟨fun S =>
{ N := sInf (Ideal.Filtration.N '' S)
mono := fun i => by
apply sInf_le_sInf_of_isCoinitialFor _
rintro _ ⟨⟨_, F, hF, rfl⟩, rfl⟩
exact ⟨_, ⟨⟨_, F, hF, rfl⟩, rfl⟩, F.mono i⟩
smul_le := fun i => by
rw [sInf_eq_iInf', iInf_apply, iInf_apply]
refine smul_iInf_le.trans ?_
apply iInf_mono _
rintro ⟨_, F, hF, rfl⟩
exact F.smul_le i }⟩
instance : Top (I.Filtration M) :=
⟨I.trivialFiltration ⊤⟩
instance : Bot (I.Filtration M) :=
⟨I.trivialFiltration ⊥⟩
@[simp]
theorem sup_N : (F ⊔ F').N = F.N ⊔ F'.N :=
rfl
@[simp]
theorem sSup_N (S : Set (I.Filtration M)) : (sSup S).N = sSup (Ideal.Filtration.N '' S) :=
rfl
@[simp]
theorem inf_N : (F ⊓ F').N = F.N ⊓ F'.N :=
rfl
@[simp]
theorem sInf_N (S : Set (I.Filtration M)) : (sInf S).N = sInf (Ideal.Filtration.N '' S) :=
rfl
@[simp]
theorem top_N : (⊤ : I.Filtration M).N = ⊤ :=
rfl
@[simp]
theorem bot_N : (⊥ : I.Filtration M).N = ⊥ :=
rfl
@[simp]
theorem iSup_N {ι : Sort*} (f : ι → I.Filtration M) : (iSup f).N = ⨆ i, (f i).N :=
congr_arg sSup (Set.range_comp _ _).symm
@[simp]
theorem iInf_N {ι : Sort*} (f : ι → I.Filtration M) : (iInf f).N = ⨅ i, (f i).N :=
congr_arg sInf (Set.range_comp _ _).symm
instance : CompleteLattice (I.Filtration M) :=
Function.Injective.completeLattice Ideal.Filtration.N
(fun _ _ => Ideal.Filtration.ext) sup_N inf_N
(fun _ => sSup_image) (fun _ => sInf_image) top_N bot_N
instance : Inhabited (I.Filtration M) :=
⟨⊥⟩
/-- An `I` filtration is stable if `I • F.N n = F.N (n+1)` for large enough `n`. -/
def Stable : Prop :=
∃ n₀, ∀ n ≥ n₀, I • F.N n = F.N (n + 1)
/-- The trivial stable `I`-filtration of `N`. -/
@[simps]
def _root_.Ideal.stableFiltration (I : Ideal R) (N : Submodule R M) : I.Filtration M where
N i := I ^ i • N
mono i := by rw [add_comm, pow_add, mul_smul]; exact Submodule.smul_le_right
smul_le i := by rw [add_comm, pow_add, mul_smul, pow_one]
theorem _root_.Ideal.stableFiltration_stable (I : Ideal R) (N : Submodule R M) :
(I.stableFiltration N).Stable := by
use 0
intro n _
dsimp
rw [add_comm, pow_add, mul_smul, pow_one]
variable {F F'}
theorem Stable.exists_pow_smul_eq (h : F.Stable) : ∃ n₀, ∀ k, F.N (n₀ + k) = I ^ k • F.N n₀ := by
obtain ⟨n₀, hn⟩ := h
use n₀
intro k
induction k with
| zero => simp
| succ _ ih => rw [← add_assoc, ← hn, ih, add_comm, pow_add, mul_smul, pow_one]; cutsat
theorem Stable.exists_pow_smul_eq_of_ge (h : F.Stable) :
∃ n₀, ∀ n ≥ n₀, F.N n = I ^ (n - n₀) • F.N n₀ := by
obtain ⟨n₀, hn₀⟩ := h.exists_pow_smul_eq
use n₀
intro n hn
convert hn₀ (n - n₀)
rw [add_comm, tsub_add_cancel_of_le hn]
theorem stable_iff_exists_pow_smul_eq_of_ge :
F.Stable ↔ ∃ n₀, ∀ n ≥ n₀, F.N n = I ^ (n - n₀) • F.N n₀ := by
refine ⟨Stable.exists_pow_smul_eq_of_ge, fun h => ⟨h.choose, fun n hn => ?_⟩⟩
rw [h.choose_spec n hn, h.choose_spec (n + 1) (by cutsat), smul_smul, ← pow_succ',
tsub_add_eq_add_tsub hn]
theorem Stable.exists_forall_le (h : F.Stable) (e : F.N 0 ≤ F'.N 0) :
∃ n₀, ∀ n, F.N (n + n₀) ≤ F'.N n := by
obtain ⟨n₀, hF⟩ := h
use n₀
intro n
induction n with
| zero => refine (F.antitone ?_).trans e; simp
| succ n hn =>
rw [add_right_comm, ← hF]
· exact (smul_mono_right _ hn).trans (F'.smul_le _)
simp
theorem Stable.bounded_difference (h : F.Stable) (h' : F'.Stable) (e : F.N 0 = F'.N 0) :
∃ n₀, ∀ n, F.N (n + n₀) ≤ F'.N n ∧ F'.N (n + n₀) ≤ F.N n := by
obtain ⟨n₁, h₁⟩ := h.exists_forall_le (le_of_eq e)
obtain ⟨n₂, h₂⟩ := h'.exists_forall_le (le_of_eq e.symm)
use max n₁ n₂
intro n
refine ⟨(F.antitone ?_).trans (h₁ n), (F'.antitone ?_).trans (h₂ n)⟩ <;> simp
open PolynomialModule
variable (F F')
/-- The `R[IX]`-submodule of `M[X]` associated with an `I`-filtration. -/
protected noncomputable def submodule : Submodule (reesAlgebra I) (PolynomialModule R M) where
carrier := { f | ∀ i, f i ∈ F.N i }
add_mem' hf hg i := Submodule.add_mem _ (hf i) (hg i)
zero_mem' _ := Submodule.zero_mem _
smul_mem' r f hf i := by
rw [Subalgebra.smul_def, PolynomialModule.smul_apply]
apply Submodule.sum_mem
rintro ⟨j, k⟩ e
rw [Finset.mem_antidiagonal] at e
subst e
exact F.pow_smul_le j k (Submodule.smul_mem_smul (r.2 j) (hf k))
@[simp]
theorem mem_submodule (f : PolynomialModule R M) : f ∈ F.submodule ↔ ∀ i, f i ∈ F.N i :=
Iff.rfl
theorem inf_submodule : (F ⊓ F').submodule = F.submodule ⊓ F'.submodule := by
ext
exact forall_and
variable (I M)
/-- `Ideal.Filtration.submodule` as an `InfHom`. -/
noncomputable def submoduleInfHom :
InfHom (I.Filtration M) (Submodule (reesAlgebra I) (PolynomialModule R M)) where
toFun := Ideal.Filtration.submodule
map_inf' := inf_submodule
variable {I M}
theorem submodule_closure_single :
AddSubmonoid.closure (⋃ i, single R i '' (F.N i : Set M)) = F.submodule.toAddSubmonoid := by
apply le_antisymm
· rw [AddSubmonoid.closure_le, Set.iUnion_subset_iff]
rintro i _ ⟨m, hm, rfl⟩ j
rw [single_apply]
split_ifs with h
· rwa [← h]
· exact (F.N j).zero_mem
· intro f hf
rw [← f.sum_single]
apply AddSubmonoid.sum_mem _ _
rintro c -
exact AddSubmonoid.subset_closure (Set.subset_iUnion _ c <| Set.mem_image_of_mem _ (hf c))
theorem submodule_span_single :
Submodule.span (reesAlgebra I) (⋃ i, single R i '' (F.N i : Set M)) = F.submodule := by
rw [← Submodule.span_closure, submodule_closure_single, Submodule.coe_toAddSubmonoid]
exact Submodule.span_eq (Filtration.submodule F)
theorem submodule_eq_span_le_iff_stable_ge (n₀ : ℕ) :
F.submodule = Submodule.span _ (⋃ i ≤ n₀, single R i '' (F.N i : Set M)) ↔
∀ n ≥ n₀, I • F.N n = F.N (n + 1) := by
rw [← submodule_span_single,
← (Submodule.span_mono (Set.iUnion₂_subset_iUnion _ _)).ge_iff_eq',
Submodule.span_le, Set.iUnion_subset_iff]
constructor
· intro H n hn
refine (F.smul_le n).antisymm ?_
intro x hx
obtain ⟨l, hl⟩ := (Finsupp.mem_span_iff_linearCombination _ _ _).mp (H _ ⟨x, hx, rfl⟩)
replace hl := congr_arg (fun f : ℕ →₀ M => f (n + 1)) hl
dsimp only at hl
rw [PolynomialModule.single_apply, if_pos rfl] at hl
rw [← hl, Finsupp.linearCombination_apply, Finsupp.sum_apply]
apply Submodule.sum_mem _ _
rintro ⟨_, _, ⟨n', rfl⟩, _, ⟨hn', rfl⟩, m, hm, rfl⟩ -
dsimp only [Subtype.coe_mk]
rw [Subalgebra.smul_def, smul_single_apply, if_pos (show n' ≤ n + 1 by cutsat)]
have e : n' ≤ n := by omega
have := F.pow_smul_le_pow_smul (n - n') n' 1
rw [tsub_add_cancel_of_le e, pow_one, add_comm _ 1, ← add_tsub_assoc_of_le e, add_comm] at this
exact this (Submodule.smul_mem_smul ((l _).2 <| n + 1 - n') hm)
· let F' := Submodule.span (reesAlgebra I) (⋃ i ≤ n₀, single R i '' (F.N i : Set M))
intro hF i
have : ∀ i ≤ n₀, single R i '' (F.N i : Set M) ⊆ F' := fun i hi =>
-- Porting note: need to add hint for `s`
(Set.subset_iUnion₂ (s := fun i _ => (single R i '' (N F i : Set M))) i hi).trans
Submodule.subset_span
induction i with
| zero => exact this _ (zero_le _)
| succ j hj => ?_
by_cases hj' : j.succ ≤ n₀
· exact this _ hj'
simp only [not_le, Nat.lt_succ_iff] at hj'
rw [← hF _ hj']
rintro _ ⟨m, hm, rfl⟩
refine Submodule.smul_induction_on hm (fun r hr m' hm' => ?_) (fun x y hx hy => ?_)
· rw [add_comm, ← monomial_smul_single]
exact F'.smul_mem
⟨_, reesAlgebra.monomial_mem.mpr (by rwa [pow_one])⟩ (hj <| Set.mem_image_of_mem _ hm')
· rw [map_add]
exact F'.add_mem hx hy
/-- If the components of a filtration are finitely generated, then the filtration is stable iff
its associated submodule of is finitely generated. -/
theorem submodule_fg_iff_stable (hF' : ∀ i, (F.N i).FG) : F.submodule.FG ↔ F.Stable := by
classical
delta Ideal.Filtration.Stable
simp_rw [← F.submodule_eq_span_le_iff_stable_ge]
constructor
· rintro H
refine H.stabilizes_of_iSup_eq
⟨fun n₀ => Submodule.span _ (⋃ (i : ℕ) (_ : i ≤ n₀), single R i '' ↑(F.N i)), ?_⟩ ?_
· intro n m e
rw [Submodule.span_le, Set.iUnion₂_subset_iff]
intro i hi
refine Set.Subset.trans ?_ Submodule.subset_span
refine @Set.subset_iUnion₂ _ _ _ (fun i => fun _ => ↑((single R i) '' ((N F i) : Set M))) i ?_
exact hi.trans e
· dsimp
rw [← Submodule.span_iUnion, ← submodule_span_single]
congr 1
ext
simp only [Set.mem_iUnion, Set.mem_image, SetLike.mem_coe, exists_prop]
constructor
· rintro ⟨-, i, -, e⟩; exact ⟨i, e⟩
· rintro ⟨i, e⟩; exact ⟨i, i, le_refl i, e⟩
· rintro ⟨n, hn⟩
rw [hn]
simp_rw [Submodule.span_iUnion₂, ← Finset.mem_range_succ_iff, iSup_subtype']
apply Submodule.fg_iSup
rintro ⟨i, hi⟩
obtain ⟨s, hs⟩ := hF' i
have : Submodule.span (reesAlgebra I) (s.image (lsingle R i) : Set (PolynomialModule R M)) =
Submodule.span _ (single R i '' (F.N i : Set M)) := by
rw [Finset.coe_image, ← Submodule.span_span_of_tower R, ← Submodule.map_span, hs]; rfl
rw [Subtype.coe_mk, ← this]
exact ⟨_, rfl⟩
variable {F}
theorem Stable.of_le [IsNoetherianRing R] [Module.Finite R M] (hF : F.Stable)
{F' : I.Filtration M} (hf : F' ≤ F) : F'.Stable := by
rw [← submodule_fg_iff_stable] at hF ⊢
any_goals intro i; exact IsNoetherian.noetherian _
have := isNoetherian_of_fg_of_noetherian _ hF
rw [isNoetherian_submodule] at this
exact this _ (OrderHomClass.mono (submoduleInfHom M I) hf)
theorem Stable.inter_right [IsNoetherianRing R] [Module.Finite R M] (hF : F.Stable) :
(F ⊓ F').Stable :=
hF.of_le inf_le_left
theorem Stable.inter_left [IsNoetherianRing R] [Module.Finite R M] (hF : F.Stable) :
(F' ⊓ F).Stable :=
hF.of_le inf_le_right
end Ideal.Filtration
variable (I)
/-- **Artin-Rees lemma** -/
theorem Ideal.exists_pow_inf_eq_pow_smul [IsNoetherianRing R] [Module.Finite R M]
(N : Submodule R M) : ∃ k : ℕ, ∀ n ≥ k, I ^ n • ⊤ ⊓ N = I ^ (n - k) • (I ^ k • ⊤ ⊓ N) :=
((I.stableFiltration_stable ⊤).inter_right (I.trivialFiltration N)).exists_pow_smul_eq_of_ge
theorem Ideal.mem_iInf_smul_pow_eq_bot_iff [IsNoetherianRing R] [Module.Finite R M] (x : M) :
x ∈ (⨅ i : ℕ, I ^ i • ⊤ : Submodule R M) ↔ ∃ r : I, (r : R) • x = x := by
let N := (⨅ i : ℕ, I ^ i • ⊤ : Submodule R M)
have hN : ∀ k, (I.stableFiltration ⊤ ⊓ I.trivialFiltration N).N k = N :=
fun k => inf_eq_right.mpr ((iInf_le _ k).trans <| le_of_eq <| by simp)
constructor
· obtain ⟨r, hr₁, hr₂⟩ :=
Submodule.exists_mem_and_smul_eq_self_of_fg_of_le_smul I N (IsNoetherian.noetherian N) (by
obtain ⟨k, hk⟩ := (I.stableFiltration_stable ⊤).inter_right (I.trivialFiltration N)
have := hk k (le_refl _)
rw [hN, hN] at this
exact le_of_eq this.symm)
intro H
exact ⟨⟨r, hr₁⟩, hr₂ _ H⟩
· rintro ⟨r, eq⟩
rw [Submodule.mem_iInf]
intro i
induction i with
| zero => simp
| succ i hi =>
rw [add_comm, pow_add, ← smul_smul, pow_one, ← eq]
exact Submodule.smul_mem_smul r.prop hi
theorem Ideal.iInf_pow_smul_eq_bot_of_le_jacobson [IsNoetherianRing R]
[Module.Finite R M] (h : I ≤ Ideal.jacobson ⊥) : (⨅ i : ℕ, I ^ i • ⊤ : Submodule R M) = ⊥ := by
rw [eq_bot_iff]
intro x hx
obtain ⟨r, hr⟩ := (I.mem_iInf_smul_pow_eq_bot_iff x).mp hx
have := isUnit_of_sub_one_mem_jacobson_bot (1 - r.1) (by simpa using h r.2)
apply this.smul_left_cancel.mp
simp [sub_smul, hr]
open IsLocalRing in
theorem Ideal.iInf_pow_smul_eq_bot_of_isLocalRing [IsNoetherianRing R] [IsLocalRing R]
[Module.Finite R M] (h : I ≠ ⊤) : (⨅ i : ℕ, I ^ i • ⊤ : Submodule R M) = ⊥ :=
Ideal.iInf_pow_smul_eq_bot_of_le_jacobson _
((le_maximalIdeal h).trans (maximalIdeal_le_jacobson _))
/-- **Krull's intersection theorem** for Noetherian local rings. -/
theorem Ideal.iInf_pow_eq_bot_of_isLocalRing [IsNoetherianRing R] [IsLocalRing R] (h : I ≠ ⊤) :
⨅ i : ℕ, I ^ i = ⊥ := by
convert I.iInf_pow_smul_eq_bot_of_isLocalRing (M := R) h
ext i
rw [smul_eq_mul, ← Ideal.one_eq_top, mul_one]
/-- Also see `Ideal.isIdempotentElem_iff_eq_bot_or_top` for integral domains. -/
theorem Ideal.isIdempotentElem_iff_eq_bot_or_top_of_isLocalRing {R} [CommRing R]
[IsNoetherianRing R] [IsLocalRing R] (I : Ideal R) :
IsIdempotentElem I ↔ I = ⊥ ∨ I = ⊤ := by
constructor
· intro H
by_cases I = ⊤; · exact Or.inr ‹_›
refine Or.inl (eq_bot_iff.mpr ?_)
rw [← Ideal.iInf_pow_eq_bot_of_isLocalRing I ‹_›]
apply le_iInf
rintro (_ | n) <;> simp [H.pow_succ_eq]
· rintro (rfl | rfl) <;> simp [IsIdempotentElem]
open IsLocalRing in
theorem Ideal.iInf_pow_smul_eq_bot_of_noZeroSMulDivisors
[IsNoetherianRing R] [NoZeroSMulDivisors R M]
[Module.Finite R M] (h : I ≠ ⊤) : (⨅ i : ℕ, I ^ i • ⊤ : Submodule R M) = ⊥ := by
rw [eq_bot_iff]
intro x hx
by_contra hx'
have := Ideal.mem_iInf_smul_pow_eq_bot_iff I x
obtain ⟨r, hr⟩ := this.mp hx
have := smul_left_injective _ hx' (hr.trans (one_smul _ x).symm)
exact I.eq_top_iff_one.not.mp h (this ▸ r.prop)
/-- **Krull's intersection theorem** for Noetherian domains. -/
theorem Ideal.iInf_pow_eq_bot_of_isDomain [IsNoetherianRing R] [IsDomain R] (h : I ≠ ⊤) :
⨅ i : ℕ, I ^ i = ⊥ := by
convert I.iInf_pow_smul_eq_bot_of_noZeroSMulDivisors (M := R) h
simp |
.lake/packages/mathlib/Mathlib/RingTheory/Conductor.lean | import Mathlib.RingTheory.Localization.Submodule
import Mathlib.RingTheory.PowerBasis
/-!
# The conductor ideal
This file defines the conductor ideal of an element `x` of `R`-algebra `S`. This is the ideal of
`S` consisting of all elements `a` such that for all `b` in `S`, the product `a * b` lies in the
`R`subalgebra of `S` generated by `x`.
-/
variable (R : Type*) {S : Type*} [CommRing R] [CommRing S] [Algebra R S]
open Ideal Polynomial DoubleQuot UniqueFactorizationMonoid Algebra RingHom
local notation:max R "<" x:max ">" => adjoin R ({x} : Set S)
/-- Let `S / R` be a ring extension and `x : S`, then the conductor of `R<x>` is the
biggest ideal of `S` contained in `R<x>`. -/
def conductor (x : S) : Ideal S where
carrier := {a | ∀ b : S, a * b ∈ R<x>}
zero_mem' b := by simp only [zero_mul, zero_mem]
add_mem' ha hb c := by simpa only [add_mul] using Subalgebra.add_mem _ (ha c) (hb c)
smul_mem' c a ha b := by simpa only [smul_eq_mul, mul_left_comm, mul_assoc] using ha (c * b)
variable {R} {x : S}
theorem conductor_eq_of_eq {y : S} (h : (R<x> : Set S) = R<y>) : conductor R x = conductor R y :=
Ideal.ext fun _ => forall_congr' fun _ => Set.ext_iff.mp h _
theorem conductor_subset_adjoin : (conductor R x : Set S) ⊆ R<x> := fun y hy => by
simpa only [mul_one] using hy 1
theorem mem_conductor_iff {y : S} : y ∈ conductor R x ↔ ∀ b : S, y * b ∈ R<x> :=
⟨fun h => h, fun h => h⟩
theorem conductor_eq_top_of_adjoin_eq_top (h : R<x> = ⊤) : conductor R x = ⊤ := by
simp only [Ideal.eq_top_iff_one, mem_conductor_iff, h, mem_top, forall_const]
theorem conductor_eq_top_of_powerBasis (pb : PowerBasis R S) : conductor R pb.gen = ⊤ :=
conductor_eq_top_of_adjoin_eq_top pb.adjoin_gen_eq_top
theorem adjoin_eq_top_of_conductor_eq_top {x : S} (h : conductor R x = ⊤) :
Algebra.adjoin R {x} = ⊤ :=
Algebra.eq_top_iff.mpr fun y ↦
one_mul y ▸ (mem_conductor_iff).mp ((Ideal.eq_top_iff_one (conductor R x)).mp h) y
theorem conductor_eq_top_iff_adjoin_eq_top {x : S} :
conductor R x = ⊤ ↔ Algebra.adjoin R {x} = ⊤ :=
⟨fun h ↦ adjoin_eq_top_of_conductor_eq_top h, fun h ↦ conductor_eq_top_of_adjoin_eq_top h⟩
open IsLocalization in
lemma mem_coeSubmodule_conductor {L} [CommRing L] [Algebra S L] [Algebra R L]
[IsScalarTower R S L] [NoZeroSMulDivisors S L] {x : S} {y : L} :
y ∈ coeSubmodule L (conductor R x) ↔ ∀ z : S,
y * (algebraMap S L) z ∈ Algebra.adjoin R {algebraMap S L x} := by
cases subsingleton_or_nontrivial L
· rw [Subsingleton.elim (coeSubmodule L _) ⊤, Subsingleton.elim (Algebra.adjoin R _) ⊤]; simp
trans ∀ z, y * (algebraMap S L) z ∈ (Algebra.adjoin R {x}).map (IsScalarTower.toAlgHom R S L)
· simp only [coeSubmodule, Submodule.mem_map, Algebra.linearMap_apply, Subalgebra.mem_map,
IsScalarTower.coe_toAlgHom']
constructor
· rintro ⟨y, hy, rfl⟩ z
exact ⟨_, hy z, map_mul _ _ _⟩
· intro H
obtain ⟨y, _, e⟩ := H 1
rw [map_one, mul_one] at e
subst e
simp only [← map_mul, (FaithfulSMul.algebraMap_injective S L).eq_iff,
exists_eq_right] at H
exact ⟨_, H, rfl⟩
· rw [AlgHom.map_adjoin, Set.image_singleton]; rfl
variable {I : Ideal R}
/-- This technical lemma tell us that if `C` is the conductor of `R<x>` and `I` is an ideal of `R`
then `p * (I * S) ⊆ I * R<x>` for any `p` in `C ∩ R` -/
theorem prod_mem_ideal_map_of_mem_conductor {p : R} {z : S}
(hp : p ∈ Ideal.comap (algebraMap R S) (conductor R x)) (hz' : z ∈ I.map (algebraMap R S)) :
algebraMap R S p * z ∈ algebraMap R<x> S '' ↑(I.map (algebraMap R R<x>)) := by
rw [Ideal.map, Ideal.span, Finsupp.mem_span_image_iff_linearCombination] at hz'
obtain ⟨l, H, H'⟩ := hz'
rw [Finsupp.linearCombination_apply] at H'
rw [← H', mul_comm, Finsupp.sum_mul]
have lem : ∀ {a : R}, a ∈ I → l a • algebraMap R S a * algebraMap R S p ∈
algebraMap R<x> S '' I.map (algebraMap R R<x>) := by
intro a ha
rw [Algebra.id.smul_eq_mul, mul_assoc, mul_comm, mul_assoc, Set.mem_image]
refine Exists.intro
(algebraMap R R<x> a * ⟨l a * algebraMap R S p,
show l a * algebraMap R S p ∈ R<x> from ?h⟩) ?_
case h =>
rw [mul_comm]
exact mem_conductor_iff.mp (Ideal.mem_comap.mp hp) _
· refine ⟨?_, ?_⟩
· rw [mul_comm]
apply Ideal.mul_mem_left (I.map (algebraMap R R<x>)) _ (Ideal.mem_map_of_mem _ ha)
· simp only [RingHom.map_mul, mul_comm (algebraMap R S p) (l a)]
rfl
refine Finset.sum_induction _ (fun u => u ∈ algebraMap R<x> S '' I.map (algebraMap R R<x>))
(fun a b => ?_) ?_ ?_
· rintro ⟨z, hz, rfl⟩ ⟨y, hy, rfl⟩
rw [← RingHom.map_add]
exact ⟨z + y, Ideal.add_mem _ (SetLike.mem_coe.mp hz) hy, rfl⟩
· exact ⟨0, SetLike.mem_coe.mpr <| Ideal.zero_mem _, RingHom.map_zero _⟩
· intro y hy
exact lem ((Finsupp.mem_supported _ l).mp H hy)
/-- A technical result telling us that `(I * S) ∩ R<x> = I * R<x>` for any ideal `I` of `R`. -/
theorem comap_map_eq_map_adjoin_of_coprime_conductor
(hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)
(h_alg : Function.Injective (algebraMap R<x> S)) :
(I.map (algebraMap R S)).comap (algebraMap R<x> S) = I.map (algebraMap R R<x>) := by
apply le_antisymm
· -- This is adapted from [Neukirch1992]. Let `C = (conductor R x)`. The idea of the proof
-- is that since `I` and `C ∩ R` are coprime, we have
-- `(I * S) ∩ R<x> ⊆ (I + C) * ((I * S) ∩ R<x>) ⊆ I * R<x> + I * C * S ⊆ I * R<x>`.
intro y hy
obtain ⟨z, hz⟩ := y
obtain ⟨p, hp, q, hq, hpq⟩ := Submodule.mem_sup.mp ((Ideal.eq_top_iff_one _).mp hx)
have temp : algebraMap R S p * z + algebraMap R S q * z = z := by
simp only [← add_mul, ← RingHom.map_add (algebraMap R S), hpq, map_one, one_mul]
suffices z ∈ algebraMap R<x> S '' I.map (algebraMap R R<x>) ↔
(⟨z, hz⟩ : R<x>) ∈ I.map (algebraMap R R<x>) by
rw [← this, ← temp]
obtain ⟨a, ha⟩ := (Set.mem_image _ _ _).mp (prod_mem_ideal_map_of_mem_conductor hp
(show z ∈ I.map (algebraMap R S) by rwa [Ideal.mem_comap] at hy))
use a + algebraMap R R<x> q * ⟨z, hz⟩
refine ⟨Ideal.add_mem (I.map (algebraMap R R<x>)) ha.left ?_, by
simp only [ha.right, map_add, map_mul, add_right_inj]; rfl⟩
rw [mul_comm]
exact Ideal.mul_mem_left (I.map (algebraMap R R<x>)) _ (Ideal.mem_map_of_mem _ hq)
refine ⟨fun h => ?_,
fun h => (Set.mem_image _ _ _).mpr (Exists.intro ⟨z, hz⟩ ⟨by simp [h], rfl⟩)⟩
obtain ⟨x₁, hx₁, hx₂⟩ := (Set.mem_image _ _ _).mp h
have : x₁ = ⟨z, hz⟩ := by
apply h_alg
simp only [hx₂, algebraMap_eq_smul_one]
rw [Submonoid.mk_smul, smul_eq_mul, mul_one]
rwa [← this]
· -- The converse inclusion is trivial
have : algebraMap R S = (algebraMap _ S).comp (algebraMap R R<x>) := by ext; rfl
rw [this, ← Ideal.map_map]
apply Ideal.le_comap_map
/-- The canonical morphism of rings from `R<x> ⧸ (I*R<x>)` to `S ⧸ (I*S)` is an isomorphism
when `I` and `(conductor R x) ∩ R` are coprime. -/
noncomputable def quotAdjoinEquivQuotMap (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)
(h_alg : Function.Injective (algebraMap R<x> S)) :
R<x> ⧸ I.map (algebraMap R R<x>) ≃+* S ⧸ I.map (algebraMap R S) := by
let f : R<x> ⧸ I.map (algebraMap R R<x>) →+* S ⧸ I.map (algebraMap R S) :=
(Ideal.Quotient.lift (I.map (algebraMap R R<x>))
((Ideal.Quotient.mk (I.map (algebraMap R S))).comp (algebraMap R<x> S)) (fun r hr => by
have : algebraMap R S = (algebraMap R<x> S).comp (algebraMap R R<x>) := by ext; rfl
rw [RingHom.comp_apply, Ideal.Quotient.eq_zero_iff_mem, this, ← Ideal.map_map]
exact Ideal.mem_map_of_mem _ hr))
refine RingEquiv.ofBijective f ⟨?_, ?_⟩
· --the kernel of the map is clearly `(I * S) ∩ R<x>`. To get injectivity, we need to show that
--this is contained in `I * R<x>`, which is the content of the previous lemma.
refine RingHom.lift_injective_of_ker_le_ideal _ _ fun u hu => ?_
rwa [RingHom.mem_ker, RingHom.comp_apply, Ideal.Quotient.eq_zero_iff_mem, ← Ideal.mem_comap,
comap_map_eq_map_adjoin_of_coprime_conductor hx h_alg] at hu
· -- Surjectivity follows from the surjectivity of the canonical map `R<x> → S ⧸ (I * S)`,
-- which in turn follows from the fact that `I * S + (conductor R x) = S`.
refine Ideal.Quotient.lift_surjective_of_surjective _ _ fun y => ?_
obtain ⟨z, hz⟩ := Ideal.Quotient.mk_surjective y
have : z ∈ conductor R x ⊔ I.map (algebraMap R S) := by
suffices conductor R x ⊔ I.map (algebraMap R S) = ⊤ by simp only [this, Submodule.mem_top]
rw [Ideal.eq_top_iff_one] at hx ⊢
replace hx := Ideal.mem_map_of_mem (algebraMap R S) hx
rw [Ideal.map_sup, RingHom.map_one] at hx
exact (sup_le_sup
(show ((conductor R x).comap (algebraMap R S)).map (algebraMap R S) ≤ conductor R x
from Ideal.map_comap_le)
(le_refl (I.map (algebraMap R S)))) hx
rw [← Ideal.mem_quotient_iff_mem_sup, hz, Ideal.mem_map_iff_of_surjective] at this
· obtain ⟨u, hu, hu'⟩ := this
use ⟨u, conductor_subset_adjoin hu⟩
simp only [← hu']
rfl
· exact Ideal.Quotient.mk_surjective
@[simp]
theorem quotAdjoinEquivQuotMap_apply_mk (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤)
(h_alg : Function.Injective (algebraMap R<x> S)) (a : R<x>) :
quotAdjoinEquivQuotMap hx h_alg (Ideal.Quotient.mk (I.map (algebraMap R R<x>)) a) =
Ideal.Quotient.mk (I.map (algebraMap R S)) ↑a := rfl |
.lake/packages/mathlib/Mathlib/RingTheory/Extension.lean | import Mathlib.RingTheory.Extension.Basic
deprecated_module (since := "2025-05-11") |
.lake/packages/mathlib/Mathlib/RingTheory/Discriminant.lean | import Mathlib.Algebra.Order.BigOperators.Group.LocallyFinite
import Mathlib.RingTheory.Norm.Transitivity
import Mathlib.RingTheory.Trace.Basic
/-!
# Discriminant of a family of vectors
Given an `A`-algebra `B` and `b`, an `ι`-indexed family of elements of `B`, we define the
*discriminant* of `b` as the determinant of the matrix whose `(i j)`-th element is the trace of
`b i * b j`.
## Main definition
* `Algebra.discr A b` : the discriminant of `b : ι → B`.
## Main results
* `Algebra.discr_zero_of_not_linearIndependent` : if `b` is not linear independent, then
`Algebra.discr A b = 0`.
* `Algebra.discr_of_matrix_vecMul` and `Algebra.discr_of_matrix_mulVec` : formulas relating
`Algebra.discr A ι b` with `Algebra.discr A (b ᵥ* P.map (algebraMap A B))` and
`Algebra.discr A (P.map (algebraMap A B) *ᵥ b)`.
* `Algebra.discr_not_zero_of_basis` : over a field, if `b` is a basis, then
`Algebra.discr K b ≠ 0`.
* `Algebra.discr_eq_det_embeddingsMatrixReindex_pow_two` : if `L/K` is a field extension and
`b : ι → L`, then `discr K b` is the square of the determinant of the matrix whose `(i, j)`
coefficient is `σⱼ (b i)`, where `σⱼ : L →ₐ[K] E` is the embedding in an algebraically closed
field `E` corresponding to `j : ι` via a bijection `e : ι ≃ (L →ₐ[K] E)`.
* `Algebra.discr_powerBasis_eq_prod` : the discriminant of a power basis.
* `Algebra.discr_isIntegral` : if `K` and `L` are fields and `IsScalarTower R K L`, if
`b : ι → L` satisfies `∀ i, IsIntegral R (b i)`, then `IsIntegral R (discr K b)`.
* `Algebra.discr_mul_isIntegral_mem_adjoin` : let `K` be the fraction field of an integrally
closed domain `R` and let `L` be a finite separable extension of `K`. Let `B : PowerBasis K L`
be such that `IsIntegral R B.gen`. Then for all, `z : L` we have
`(discr K B.basis) • z ∈ adjoin R ({B.gen} : Set L)`.
## Implementation details
Our definition works for any `A`-algebra `B`, but note that if `B` is not free as an `A`-module,
then `trace A B = 0` by definition, so `discr A b = 0` for any `b`.
-/
universe u v w z
open scoped Matrix
open Matrix Module Fintype Polynomial Finset IntermediateField
namespace Algebra
variable (A : Type u) {B : Type v} (C : Type z) {ι : Type w} [DecidableEq ι]
variable [CommRing A] [CommRing B] [Algebra A B] [CommRing C] [Algebra A C]
section Discr
/-- Given an `A`-algebra `B` and `b`, an `ι`-indexed family of elements of `B`, we define
`discr A ι b` as the determinant of `traceMatrix A ι b`. -/
noncomputable def discr (A : Type u) {B : Type v} [CommRing A] [CommRing B] [Algebra A B]
[Fintype ι] (b : ι → B) := (traceMatrix A b).det
theorem discr_def [Fintype ι] (b : ι → B) : discr A b = (traceMatrix A b).det := rfl
variable {A C} in
/-- Mapping a family of vectors along an `AlgEquiv` preserves the discriminant. -/
theorem discr_eq_discr_of_algEquiv [Fintype ι] (b : ι → B) (f : B ≃ₐ[A] C) :
Algebra.discr A b = Algebra.discr A (f ∘ b) := by
rw [discr_def]; congr; ext
simp_rw [traceMatrix_apply, traceForm_apply, Function.comp, ← map_mul f, trace_eq_of_algEquiv]
variable {ι' : Type*} [Fintype ι'] [Fintype ι] [DecidableEq ι']
section Basic
@[simp]
theorem discr_reindex (b : Basis ι A B) (f : ι ≃ ι') : discr A (b ∘ ⇑f.symm) = discr A b := by
classical rw [← Basis.coe_reindex, discr_def, traceMatrix_reindex, det_reindex_self, ← discr_def]
/-- If `b` is not linear independent, then `Algebra.discr A b = 0`. -/
theorem discr_zero_of_not_linearIndependent [IsDomain A] {b : ι → B}
(hli : ¬LinearIndependent A b) : discr A b = 0 := by
classical
obtain ⟨g, hg, i, hi⟩ := Fintype.not_linearIndependent_iff.1 hli
have : (traceMatrix A b) *ᵥ g = 0 := by
ext i
have : ∀ j, (trace A B) (b i * b j) * g j = (trace A B) (g j • b j * b i) := by
intro j
simp [mul_comm]
simp only [mulVec, dotProduct, traceMatrix_apply, Pi.zero_apply, traceForm_apply, fun j =>
this j, ← map_sum, ← sum_mul, hg, zero_mul, LinearMap.map_zero]
by_contra h
rw [discr_def] at h
simp [Matrix.eq_zero_of_mulVec_eq_zero h this] at hi
variable {A}
/-- Relation between `Algebra.discr A ι b` and
`Algebra.discr A (b ᵥ* P.map (algebraMap A B))`. -/
theorem discr_of_matrix_vecMul (b : ι → B) (P : Matrix ι ι A) :
discr A (b ᵥ* P.map (algebraMap A B)) = P.det ^ 2 * discr A b := by
rw [discr_def, traceMatrix_of_matrix_vecMul, det_mul, det_mul, det_transpose, mul_comm, ←
mul_assoc, discr_def, pow_two]
/-- Relation between `Algebra.discr A ι b` and
`Algebra.discr A ((P.map (algebraMap A B)) *ᵥ b)`. -/
theorem discr_of_matrix_mulVec (b : ι → B) (P : Matrix ι ι A) :
discr A (P.map (algebraMap A B) *ᵥ b) = P.det ^ 2 * discr A b := by
rw [discr_def, traceMatrix_of_matrix_mulVec, det_mul, det_mul, det_transpose, mul_comm, ←
mul_assoc, discr_def, pow_two]
end Basic
section Field
variable (K : Type u) {L : Type v} (E : Type z) [Field K] [Field L] [Field E]
variable [Algebra K L] [Algebra K E]
variable [Module.Finite K L] [IsAlgClosed E]
/-- If `b` is a basis of a finite separable field extension `L/K`, then `Algebra.discr K b ≠ 0`. -/
theorem discr_not_zero_of_basis [Algebra.IsSeparable K L] (b : Basis ι K L) :
discr K b ≠ 0 := by
rw [discr_def, traceMatrix_of_basis, ← LinearMap.BilinForm.nondegenerate_iff_det_ne_zero]
exact traceForm_nondegenerate _ _
/-- If `b` is a basis of a finite separable field extension `L/K`,
then `Algebra.discr K b` is a unit. -/
theorem discr_isUnit_of_basis [Algebra.IsSeparable K L] (b : Basis ι K L) : IsUnit (discr K b) :=
IsUnit.mk0 _ (discr_not_zero_of_basis _ _)
variable (b : ι → L) (pb : PowerBasis K L)
/-- If `L/K` is a field extension and `b : ι → L`, then `discr K b` is the square of the
determinant of the matrix whose `(i, j)` coefficient is `σⱼ (b i)`, where `σⱼ : L →ₐ[K] E` is the
embedding in an algebraically closed field `E` corresponding to `j : ι` via a bijection
`e : ι ≃ (L →ₐ[K] E)`. -/
theorem discr_eq_det_embeddingsMatrixReindex_pow_two
[Algebra.IsSeparable K L] (e : ι ≃ (L →ₐ[K] E)) :
algebraMap K E (discr K b) = (embeddingsMatrixReindex K E b e).det ^ 2 := by
rw [discr_def, RingHom.map_det, RingHom.mapMatrix_apply,
traceMatrix_eq_embeddingsMatrixReindex_mul_trans, det_mul, det_transpose, pow_two]
/-- The discriminant of a power basis. -/
theorem discr_powerBasis_eq_prod (e : Fin pb.dim ≃ (L →ₐ[K] E)) [Algebra.IsSeparable K L] :
algebraMap K E (discr K pb.basis) =
∏ i : Fin pb.dim, ∏ j ∈ Ioi i, (e j pb.gen - e i pb.gen) ^ 2 := by
rw [discr_eq_det_embeddingsMatrixReindex_pow_two K E pb.basis e,
embeddingsMatrixReindex_eq_vandermonde, det_transpose, det_vandermonde, ← prod_pow]
congr; ext i
rw [← prod_pow]
/-- A variation of `Algebra.discr_powerBasis_eq_prod`. -/
theorem discr_powerBasis_eq_prod' [Algebra.IsSeparable K L] (e : Fin pb.dim ≃ (L →ₐ[K] E)) :
algebraMap K E (discr K pb.basis) =
∏ i : Fin pb.dim, ∏ j ∈ Ioi i, -((e j pb.gen - e i pb.gen) * (e i pb.gen - e j pb.gen)) := by
rw [discr_powerBasis_eq_prod _ _ _ e]
congr; ext i; congr; ext j
ring
local notation "n" => finrank K L
/-- A variation of `Algebra.discr_powerBasis_eq_prod`. -/
theorem discr_powerBasis_eq_prod'' [Algebra.IsSeparable K L] (e : Fin pb.dim ≃ (L →ₐ[K] E)) :
algebraMap K E (discr K pb.basis) =
(-1) ^ (n * (n - 1) / 2) *
∏ i : Fin pb.dim, ∏ j ∈ Ioi i, (e j pb.gen - e i pb.gen) * (e i pb.gen - e j pb.gen) := by
rw [discr_powerBasis_eq_prod' _ _ _ e]
simp_rw [fun i j => neg_eq_neg_one_mul ((e j pb.gen - e i pb.gen) * (e i pb.gen - e j pb.gen)),
prod_mul_distrib]
congr
simp only [prod_pow_eq_pow_sum, prod_const]
congr
rw [← @Nat.cast_inj ℚ, Nat.cast_sum]
have : ∀ x : Fin pb.dim, ↑x + 1 ≤ pb.dim := by simp [Nat.succ_le_iff, Fin.is_lt]
simp_rw [Fin.card_Ioi, Nat.sub_sub, add_comm 1]
simp only [Nat.cast_sub, this, Finset.card_fin, nsmul_eq_mul, sum_const, sum_sub_distrib,
Nat.cast_add, Nat.cast_one, sum_add_distrib, mul_one]
rw [← Nat.cast_sum, ← @Finset.sum_range ℕ _ pb.dim fun i => i, sum_range_id]
have hn : n = pb.dim := by
rw [← AlgHom.card K L E, ← Fintype.card_fin pb.dim]
-- FIXME: Without the `Fintype` namespace, why does it complain about `Finset.card_congr` being
-- deprecated?
exact Fintype.card_congr e.symm
have h₂ : 2 ∣ pb.dim * (pb.dim - 1) := pb.dim.even_mul_pred_self.two_dvd
have hne : ((2 : ℕ) : ℚ) ≠ 0 := by simp
have hle : 1 ≤ pb.dim := by
rw [← hn, Nat.one_le_iff_ne_zero, ← zero_lt_iff, Module.finrank_pos_iff]
infer_instance
rw [hn, Nat.cast_div h₂ hne, Nat.cast_mul, Nat.cast_sub hle]
ring
/-- Formula for the discriminant of a power basis using the norm of the field extension. -/
theorem discr_powerBasis_eq_norm [Algebra.IsSeparable K L] :
discr K pb.basis =
(-1) ^ (n * (n - 1) / 2) *
norm K (aeval pb.gen (minpoly K pb.gen).derivative) := by
let E := AlgebraicClosure L
letI := fun a b : E => Classical.propDecidable (Eq a b)
have e : Fin pb.dim ≃ (L →ₐ[K] E) := by
refine equivOfCardEq ?_
rw [Fintype.card_fin, AlgHom.card]
exact (PowerBasis.finrank pb).symm
have hnodup : ((minpoly K pb.gen).aroots E).Nodup :=
nodup_roots (Separable.map (Algebra.IsSeparable.isSeparable K pb.gen))
have hroots : ∀ σ : L →ₐ[K] E, σ pb.gen ∈ (minpoly K pb.gen).aroots E := by
intro σ
rw [mem_roots, IsRoot.def, eval_map, ← aeval_def, aeval_algHom_apply]
repeat' simp [minpoly.ne_zero (Algebra.IsSeparable.isIntegral K pb.gen)]
apply (algebraMap K E).injective
rw [RingHom.map_mul, RingHom.map_pow, RingHom.map_neg, RingHom.map_one,
discr_powerBasis_eq_prod'' _ _ _ e]
congr
rw [norm_eq_prod_embeddings, prod_prod_Ioi_mul_eq_prod_prod_off_diag]
conv_rhs =>
congr
rfl
ext σ
rw [← aeval_algHom_apply,
aeval_root_derivative_of_splits (minpoly.monic (Algebra.IsSeparable.isIntegral K pb.gen))
(IsAlgClosed.splits_codomain _) (hroots σ),
← Finset.prod_mk _ (hnodup.erase _)]
rw [Finset.prod_sigma', Finset.prod_sigma']
refine prod_bij' (fun i _ ↦ ⟨e i.2, e i.1 pb.gen⟩)
(fun σ hσ ↦ ⟨e.symm (PowerBasis.lift pb σ.2 ?_), e.symm σ.1⟩) ?_ ?_ ?_ ?_ (fun i _ ↦ by simp)
<;> simp only [mem_sigma, mem_univ, Finset.mem_mk, hnodup.mem_erase_iff, IsRoot.def,
mem_roots', mem_singleton, true_and, mem_compl, Sigma.forall, Equiv.apply_symm_apply,
PowerBasis.lift_gen, implies_true, Equiv.symm_apply_apply,
Sigma.ext_iff, Equiv.symm_apply_eq, heq_eq_eq, and_true] at *
· simpa only [aeval_def, eval₂_eq_eval_map] using hσ.2.2
· exact fun a b hba ↦ ⟨fun h ↦ hba <| e.injective <| pb.algHom_ext h.symm, hroots _⟩
· rintro a b hba ha
rw [ha, PowerBasis.lift_gen] at hba
exact hba.1 rfl
· exact fun a b _ ↦ pb.algHom_ext <| pb.lift_gen _ _
section Integral
variable {R : Type z} [CommRing R] [Algebra R K] [Algebra R L] [IsScalarTower R K L]
/-- If `K` and `L` are fields and `IsScalarTower R K L`, and `b : ι → L` satisfies
` ∀ i, IsIntegral R (b i)`, then `IsIntegral R (discr K b)`. -/
theorem discr_isIntegral {b : ι → L} (h : ∀ i, IsIntegral R (b i)) : IsIntegral R (discr K b) := by
classical
rw [discr_def]
exact IsIntegral.det fun i j ↦ isIntegral_trace ((h i).mul (h j))
/-- Let `K` be the fraction field of an integrally closed domain `R` and let `L` be a finite
separable extension of `K`. Let `B : PowerBasis K L` be such that `IsIntegral R B.gen`.
Then for all, `z : L` that are integral over `R`, we have
`(discr K B.basis) • z ∈ adjoin R ({B.gen} : Set L)`. -/
theorem discr_mul_isIntegral_mem_adjoin [Algebra.IsSeparable K L] [IsIntegrallyClosed R]
[IsFractionRing R K] {B : PowerBasis K L} (hint : IsIntegral R B.gen) {z : L}
(hz : IsIntegral R z) : discr K B.basis • z ∈ adjoin R ({B.gen} : Set L) := by
have hinv : IsUnit (traceMatrix K B.basis).det := by
simpa [← discr_def] using discr_isUnit_of_basis _ B.basis
have H :
(traceMatrix K B.basis).det • (traceMatrix K B.basis) *ᵥ (B.basis.equivFun z) =
(traceMatrix K B.basis).det • fun i => trace K L (z * B.basis i) := by
congr; exact traceMatrix_of_basis_mulVec _ _
have cramer := mulVec_cramer (traceMatrix K B.basis) fun i => trace K L (z * B.basis i)
suffices ∀ i, ((traceMatrix K B.basis).det • B.basis.equivFun z) i ∈ (⊥ : Subalgebra R K) by
rw [← B.basis.sum_repr z, Finset.smul_sum]
refine Subalgebra.sum_mem _ fun i _ => ?_
replace this := this i
rw [← discr_def, Pi.smul_apply, mem_bot] at this
obtain ⟨r, hr⟩ := this
rw [Basis.equivFun_apply] at hr
rw [← smul_assoc, ← hr, algebraMap_smul]
refine Subalgebra.smul_mem _ ?_ _
rw [B.basis_eq_pow i]
exact Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton _)) _
intro i
rw [← H, ← mulVec_smul] at cramer
replace cramer := congr_arg (mulVec (traceMatrix K B.basis)⁻¹) cramer
rw [mulVec_mulVec, nonsing_inv_mul _ hinv, mulVec_mulVec, nonsing_inv_mul _ hinv, one_mulVec,
one_mulVec] at cramer
rw [← congr_fun cramer i, cramer_apply, det_apply]
refine
Subalgebra.sum_mem _ fun σ _ => Subalgebra.zsmul_mem _ (Subalgebra.prod_mem _ fun j _ => ?_) _
by_cases hji : j = i
· simp only [updateCol_apply, hji, PowerBasis.coe_basis]
exact mem_bot.2 (IsIntegrallyClosed.isIntegral_iff.1 <| isIntegral_trace (hz.mul <| hint.pow _))
· simp only [updateCol_apply, hji, PowerBasis.coe_basis]
exact mem_bot.2
(IsIntegrallyClosed.isIntegral_iff.1 <| isIntegral_trace <| (hint.pow _).mul (hint.pow _))
end Integral
end Field
section Int
/-- Two (finite) ℤ-bases have the same discriminant. -/
theorem discr_eq_discr (b : Basis ι ℤ A) (b' : Basis ι ℤ A) :
Algebra.discr ℤ b = Algebra.discr ℤ b' := by
convert Algebra.discr_of_matrix_vecMul b' (b'.toMatrix b)
· rw [Basis.toMatrix_map_vecMul]
· suffices IsUnit (b'.toMatrix b).det by
rw [Int.isUnit_iff, ← sq_eq_one_iff] at this
rw [this, one_mul]
rw [← LinearMap.toMatrix_id_eq_basis_toMatrix b b']
exact LinearEquiv.isUnit_det (LinearEquiv.refl ℤ A) b b'
end Int
end Discr
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/ClassGroup.lean | import Mathlib.RingTheory.DedekindDomain.Ideal.Basic
/-!
# The ideal class group
This file defines the ideal class group `ClassGroup R` of fractional ideals of `R`
inside its field of fractions.
## Main definitions
- `toPrincipalIdeal` sends an invertible `x : K` to an invertible fractional ideal
- `ClassGroup` is the quotient of invertible fractional ideals modulo `toPrincipalIdeal.range`
- `ClassGroup.mk0` sends a nonzero integral ideal in a Dedekind domain to its class
## Main results
- `ClassGroup.mk0_eq_mk0_iff` shows the equivalence with the "classical" definition,
where `I ~ J` iff `x I = y J` for `x y ≠ (0 : R)`
## Implementation details
The definition of `ClassGroup R` involves `FractionRing R`. However, the API should be completely
identical no matter the choice of field of fractions for `R`.
-/
variable {R K : Type*} [CommRing R] [Field K] [Algebra R K] [IsFractionRing R K]
open scoped nonZeroDivisors
open IsLocalization IsFractionRing FractionalIdeal Units
section
variable (R K)
/-- `toPrincipalIdeal R K x` sends `x ≠ 0 : K` to the fractional `R`-ideal generated by `x` -/
irreducible_def toPrincipalIdeal : Kˣ →* (FractionalIdeal R⁰ K)ˣ :=
{ toFun := fun x =>
⟨spanSingleton _ x, spanSingleton _ x⁻¹, by
simp only [spanSingleton_one, Units.mul_inv', spanSingleton_mul_spanSingleton], by
simp only [spanSingleton_one, Units.inv_mul', spanSingleton_mul_spanSingleton]⟩
map_mul' := fun x y =>
ext (by simp only [Units.val_mul, spanSingleton_mul_spanSingleton])
map_one' := ext (by simp only [spanSingleton_one, Units.val_one]) }
variable {R K}
@[simp]
theorem coe_toPrincipalIdeal (x : Kˣ) :
(toPrincipalIdeal R K x : FractionalIdeal R⁰ K) = spanSingleton _ (x : K) := by
simp only [toPrincipalIdeal]; rfl
@[simp]
theorem toPrincipalIdeal_eq_iff {I : (FractionalIdeal R⁰ K)ˣ} {x : Kˣ} :
toPrincipalIdeal R K x = I ↔ spanSingleton R⁰ (x : K) = I := by
simp only [toPrincipalIdeal]; exact Units.ext_iff
theorem mem_principal_ideals_iff {I : (FractionalIdeal R⁰ K)ˣ} :
I ∈ (toPrincipalIdeal R K).range ↔ ∃ x : K, spanSingleton R⁰ x = I := by
simp only [MonoidHom.mem_range, toPrincipalIdeal_eq_iff]
constructor <;> rintro ⟨x, hx⟩
· exact ⟨x, hx⟩
· refine ⟨Units.mk0 x ?_, hx⟩
rintro rfl
simp [I.ne_zero.symm] at hx
instance PrincipalIdeals.normal : (toPrincipalIdeal R K).range.Normal :=
Subgroup.normal_of_comm _
end
variable (R)
variable [IsDomain R]
/-- The ideal class group of `R` is the group of invertible fractional ideals
modulo the principal ideals. -/
def ClassGroup :=
(FractionalIdeal R⁰ (FractionRing R))ˣ ⧸ (toPrincipalIdeal R (FractionRing R)).range
noncomputable instance : CommGroup (ClassGroup R) :=
QuotientGroup.Quotient.commGroup (toPrincipalIdeal R (FractionRing R)).range
noncomputable instance : Inhabited (ClassGroup R) := ⟨1⟩
variable {R}
/-- Send a nonzero fractional ideal to the corresponding class in the class group. -/
noncomputable def ClassGroup.mk : (FractionalIdeal R⁰ K)ˣ →* ClassGroup R :=
(QuotientGroup.mk' (toPrincipalIdeal R (FractionRing R)).range).comp
(Units.map (FractionalIdeal.canonicalEquiv R⁰ K (FractionRing R)))
lemma ClassGroup.mk_def (I : (FractionalIdeal R⁰ K)ˣ) :
ClassGroup.mk I =
(QuotientGroup.mk' (toPrincipalIdeal R (FractionRing R)).range)
(Units.map (FractionalIdeal.canonicalEquiv R⁰ K (FractionRing R)) I) := rfl
-- Can't be `@[simp]` because it can't figure out the quotient relation.
theorem ClassGroup.Quot_mk_eq_mk (I : (FractionalIdeal R⁰ (FractionRing R))ˣ) :
Quot.mk _ I = ClassGroup.mk I := by
rw [ClassGroup.mk_def, canonicalEquiv_self, RingEquiv.coe_monoidHom_refl, Units.map_id,
MonoidHom.id_apply, QuotientGroup.mk'_apply]
rfl
theorem ClassGroup.mk_eq_mk {I J : (FractionalIdeal R⁰ <| FractionRing R)ˣ} :
ClassGroup.mk I = ClassGroup.mk J ↔
∃ x : (FractionRing R)ˣ, I * toPrincipalIdeal R (FractionRing R) x = J := by
rw [mk_def, mk_def, QuotientGroup.mk'_eq_mk']
simp [RingEquiv.coe_monoidHom_refl, MonoidHom.mem_range, -toPrincipalIdeal_eq_iff]
theorem ClassGroup.mk_eq_mk_of_coe_ideal {I J : (FractionalIdeal R⁰ <| FractionRing R)ˣ}
{I' J' : Ideal R} (hI : (I : FractionalIdeal R⁰ <| FractionRing R) = I')
(hJ : (J : FractionalIdeal R⁰ <| FractionRing R) = J') :
ClassGroup.mk I = ClassGroup.mk J ↔
∃ x y : R, x ≠ 0 ∧ y ≠ 0 ∧ Ideal.span {x} * I' = Ideal.span {y} * J' := by
rw [ClassGroup.mk_eq_mk]
constructor
· rintro ⟨x, rfl⟩
rw [Units.val_mul, hI, coe_toPrincipalIdeal, mul_comm,
spanSingleton_mul_coeIdeal_eq_coeIdeal] at hJ
exact ⟨_, _, sec_fst_ne_zero x.ne_zero,
sec_snd_ne_zero (R := R) le_rfl (x : FractionRing R), hJ⟩
· rintro ⟨x, y, hx, hy, h⟩
have : IsUnit (mk' (FractionRing R) x ⟨y, mem_nonZeroDivisors_of_ne_zero hy⟩) := by
simpa only [isUnit_iff_ne_zero, ne_eq, mk'_eq_zero_iff_eq_zero] using hx
refine ⟨this.unit, ?_⟩
rw [mul_comm, ← Units.val_inj, Units.val_mul, coe_toPrincipalIdeal]
convert
(mk'_mul_coeIdeal_eq_coeIdeal (FractionRing R) <| mem_nonZeroDivisors_of_ne_zero hy).2 h
theorem ClassGroup.mk_eq_one_of_coe_ideal {I : (FractionalIdeal R⁰ <| FractionRing R)ˣ}
{I' : Ideal R} (hI : (I : FractionalIdeal R⁰ <| FractionRing R) = I') :
ClassGroup.mk I = 1 ↔ ∃ x : R, x ≠ 0 ∧ I' = Ideal.span {x} := by
rw [← map_one (ClassGroup.mk (R := R) (K := FractionRing R)),
ClassGroup.mk_eq_mk_of_coe_ideal hI]
any_goals rfl
constructor
· rintro ⟨x, y, hx, hy, h⟩
rw [Ideal.mul_top] at h
rcases Ideal.mem_span_singleton_mul.mp ((Ideal.span_singleton_le_iff_mem _).mp h.ge) with
⟨i, _hi, rfl⟩
rw [← Ideal.span_singleton_mul_span_singleton, Ideal.span_singleton_mul_right_inj hx] at h
exact ⟨i, by grobner, h⟩
· rintro ⟨x, hx, rfl⟩
exact ⟨1, x, one_ne_zero, hx, by rw [Ideal.span_singleton_one, Ideal.top_mul, Ideal.mul_top]⟩
variable (K)
/-- Induction principle for the class group: to show something holds for all `x : ClassGroup R`,
we can choose a fraction field `K` and show it holds for the equivalence class of each
`I : FractionalIdeal R⁰ K`. -/
@[elab_as_elim]
theorem ClassGroup.induction {P : ClassGroup R → Prop}
(h : ∀ I : (FractionalIdeal R⁰ K)ˣ, P (ClassGroup.mk I)) (x : ClassGroup R) : P x :=
QuotientGroup.induction_on x fun I => by
have : I = (Units.mapEquiv (canonicalEquiv R⁰ K (FractionRing R)).toMulEquiv)
(Units.mapEquiv (canonicalEquiv R⁰ (FractionRing R) K).toMulEquiv I) := by
simp [← Units.val_inj]
rw [congr_arg (QuotientGroup.mk (s := (toPrincipalIdeal R (FractionRing R)).range)) this]
exact h _
/-- The definition of the class group does not depend on the choice of field of fractions. -/
noncomputable def ClassGroup.equiv :
ClassGroup R ≃* (FractionalIdeal R⁰ K)ˣ ⧸ (toPrincipalIdeal R K).range := by
haveI : Subgroup.map
(Units.mapEquiv (canonicalEquiv R⁰ (FractionRing R) K).toMulEquiv).toMonoidHom
(toPrincipalIdeal R (FractionRing R)).range = (toPrincipalIdeal R K).range := by
ext I
simp only [Subgroup.mem_map, mem_principal_ideals_iff]
constructor
· rintro ⟨I, ⟨x, hx⟩, rfl⟩
refine ⟨FractionRing.algEquiv R K x, ?_⟩
simp only [RingEquiv.toMulEquiv_eq_coe, MulEquiv.coe_toMonoidHom, coe_mapEquiv, ← hx,
RingEquiv.coe_toMulEquiv, canonicalEquiv_spanSingleton]
rfl
· rintro ⟨x, hx⟩
refine ⟨Units.mapEquiv (canonicalEquiv R⁰ K (FractionRing R)).toMulEquiv I,
⟨(FractionRing.algEquiv R K).symm x, ?_⟩, Units.ext ?_⟩
· simp only [RingEquiv.toMulEquiv_eq_coe, coe_mapEquiv, ← hx, RingEquiv.coe_toMulEquiv,
canonicalEquiv_spanSingleton]
rfl
· simp only [RingEquiv.toMulEquiv_eq_coe, MulEquiv.coe_toMonoidHom, coe_mapEquiv,
RingEquiv.coe_toMulEquiv, canonicalEquiv_canonicalEquiv, canonicalEquiv_self,
RingEquiv.refl_apply]
exact @QuotientGroup.congr (FractionalIdeal R⁰ (FractionRing R))ˣ _ (FractionalIdeal R⁰ K)ˣ _
(toPrincipalIdeal R (FractionRing R)).range (toPrincipalIdeal R K).range _ _
(Units.mapEquiv (FractionalIdeal.canonicalEquiv R⁰ (FractionRing R) K).toMulEquiv) this
@[simp]
theorem ClassGroup.equiv_mk (K' : Type*) [Field K'] [Algebra R K'] [IsFractionRing R K']
(I : (FractionalIdeal R⁰ K)ˣ) :
ClassGroup.equiv K' (ClassGroup.mk I) =
QuotientGroup.mk' _ (Units.mapEquiv (↑(FractionalIdeal.canonicalEquiv R⁰ K K')) I) := by
-- `simp` can't apply `ClassGroup.mk_def` and `rw` can't unfold `ClassGroup`.
rw [ClassGroup.equiv, ClassGroup.mk_def]
simp only [ClassGroup, QuotientGroup.congr_mk']
congr
rw [← Units.val_inj, Units.coe_mapEquiv, Units.coe_mapEquiv, Units.coe_map]
exact FractionalIdeal.canonicalEquiv_canonicalEquiv _ _ _ _ _
@[simp]
theorem ClassGroup.mk_canonicalEquiv (K' : Type*) [Field K'] [Algebra R K'] [IsFractionRing R K']
(I : (FractionalIdeal R⁰ K)ˣ) :
ClassGroup.mk (Units.map (↑(canonicalEquiv R⁰ K K')) I : (FractionalIdeal R⁰ K')ˣ) =
ClassGroup.mk I := by
rw [ClassGroup.mk_def, ClassGroup.mk_def, ← MonoidHom.comp_apply (Units.map _),
← Units.map_comp, ← RingEquiv.coe_monoidHom_trans,
FractionalIdeal.canonicalEquiv_trans_canonicalEquiv]
/-- Send a nonzero integral ideal to an invertible fractional ideal. -/
noncomputable def FractionalIdeal.mk0 [IsDedekindDomain R] :
(Ideal R)⁰ →* (FractionalIdeal R⁰ K)ˣ where
toFun I := Units.mk0 I (coeIdeal_ne_zero.mpr <| mem_nonZeroDivisors_iff_ne_zero.mp I.2)
map_one' := by simp
map_mul' x y := by simp
@[simp]
theorem FractionalIdeal.coe_mk0 [IsDedekindDomain R] (I : (Ideal R)⁰) :
(FractionalIdeal.mk0 K I : FractionalIdeal R⁰ K) = I := rfl
theorem FractionalIdeal.canonicalEquiv_mk0 [IsDedekindDomain R] (K' : Type*) [Field K']
[Algebra R K'] [IsFractionRing R K'] (I : (Ideal R)⁰) :
FractionalIdeal.canonicalEquiv R⁰ K K' (FractionalIdeal.mk0 K I) =
FractionalIdeal.mk0 K' I := by
simp only [FractionalIdeal.coe_mk0, FractionalIdeal.canonicalEquiv_coeIdeal]
@[simp]
theorem FractionalIdeal.map_canonicalEquiv_mk0 [IsDedekindDomain R] (K' : Type*) [Field K']
[Algebra R K'] [IsFractionRing R K'] (I : (Ideal R)⁰) :
Units.map (↑(FractionalIdeal.canonicalEquiv R⁰ K K')) (FractionalIdeal.mk0 K I) =
FractionalIdeal.mk0 K' I :=
Units.ext (FractionalIdeal.canonicalEquiv_mk0 K K' I)
/-- Send a nonzero ideal to the corresponding class in the class group. -/
noncomputable def ClassGroup.mk0 [IsDedekindDomain R] : (Ideal R)⁰ →* ClassGroup R :=
ClassGroup.mk.comp (FractionalIdeal.mk0 (FractionRing R))
@[simp]
theorem ClassGroup.mk_mk0 [IsDedekindDomain R] (I : (Ideal R)⁰) :
ClassGroup.mk (FractionalIdeal.mk0 K I) = ClassGroup.mk0 I := by
rw [ClassGroup.mk0, MonoidHom.comp_apply, ← ClassGroup.mk_canonicalEquiv K (FractionRing R),
FractionalIdeal.map_canonicalEquiv_mk0]
@[simp]
theorem ClassGroup.equiv_mk0 [IsDedekindDomain R] (I : (Ideal R)⁰) :
ClassGroup.equiv K (ClassGroup.mk0 I) =
QuotientGroup.mk' (toPrincipalIdeal R K).range (FractionalIdeal.mk0 K I) := by
rw [ClassGroup.mk0, MonoidHom.comp_apply, ClassGroup.equiv_mk]
congr 1
simp [← Units.val_inj]
theorem ClassGroup.mk0_eq_mk0_iff_exists_fraction_ring [IsDedekindDomain R] {I J : (Ideal R)⁰} :
ClassGroup.mk0 I =
ClassGroup.mk0 J ↔ ∃ (x : _) (_ : x ≠ (0 : K)), spanSingleton R⁰ x * I = J := by
refine (ClassGroup.equiv K).injective.eq_iff.symm.trans ?_
simp only [ClassGroup.equiv_mk0, QuotientGroup.mk'_eq_mk', mem_principal_ideals_iff,
Units.ext_iff, Units.val_mul, FractionalIdeal.coe_mk0, exists_prop]
constructor
· rintro ⟨X, ⟨x, hX⟩, hx⟩
refine ⟨x, ?_, ?_⟩
· rintro rfl; simp [X.ne_zero.symm] at hX
simpa only [hX, mul_comm] using hx
· rintro ⟨x, hx, eq_J⟩
refine ⟨Units.mk0 _ (spanSingleton_ne_zero_iff.mpr hx), ⟨x, rfl⟩, ?_⟩
simpa only [mul_comm] using eq_J
variable {K}
theorem ClassGroup.mk0_eq_mk0_iff [IsDedekindDomain R] {I J : (Ideal R)⁰} :
ClassGroup.mk0 I = ClassGroup.mk0 J ↔
∃ (x y : R) (_hx : x ≠ 0) (_hy : y ≠ 0), Ideal.span {x} * (I : Ideal R) =
Ideal.span {y} * J := by
refine (ClassGroup.mk0_eq_mk0_iff_exists_fraction_ring (FractionRing R)).trans ⟨?_, ?_⟩
· rintro ⟨z, hz, h⟩
obtain ⟨x, ⟨y, hy⟩, rfl⟩ := IsLocalization.exists_mk'_eq R⁰ z
refine ⟨x, y, ?_, mem_nonZeroDivisors_iff_ne_zero.mp hy, ?_⟩
· rintro hx; apply hz
rw [hx, IsFractionRing.mk'_eq_div, map_zero, zero_div]
· exact (FractionalIdeal.mk'_mul_coeIdeal_eq_coeIdeal _ hy).mp h
· rintro ⟨x, y, hx, hy, h⟩
have hy' : y ∈ R⁰ := mem_nonZeroDivisors_iff_ne_zero.mpr hy
refine ⟨IsLocalization.mk' _ x ⟨y, hy'⟩, ?_, ?_⟩
· contrapose! hx
rwa [mk'_eq_iff_eq_mul, zero_mul, ← (algebraMap R (FractionRing R)).map_zero,
(IsFractionRing.injective R (FractionRing R)).eq_iff] at hx
· exact (FractionalIdeal.mk'_mul_coeIdeal_eq_coeIdeal _ hy').mpr h
/-- Maps a nonzero fractional ideal to an integral representative in the class group. -/
noncomputable def ClassGroup.integralRep (I : FractionalIdeal R⁰ (FractionRing R)) :
Ideal R := I.num
theorem ClassGroup.integralRep_mem_nonZeroDivisors
{I : FractionalIdeal R⁰ (FractionRing R)} (hI : I ≠ 0) :
I.num ∈ (Ideal R)⁰ := by
rwa [mem_nonZeroDivisors_iff_ne_zero, ne_eq, FractionalIdeal.num_eq_zero_iff]
theorem ClassGroup.mk0_integralRep [IsDedekindDomain R]
(I : (FractionalIdeal R⁰ (FractionRing R))ˣ) :
ClassGroup.mk0 ⟨ClassGroup.integralRep I, ClassGroup.integralRep_mem_nonZeroDivisors I.ne_zero⟩
= ClassGroup.mk I := by
rw [← ClassGroup.mk_mk0 (FractionRing R), eq_comm, ClassGroup.mk_eq_mk]
have fd_ne_zero : (algebraMap R (FractionRing R)) I.1.den ≠ 0 := by
exact IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors (SetLike.coe_mem _)
refine ⟨Units.mk0 (algebraMap R _ I.1.den) fd_ne_zero, ?_⟩
apply Units.ext
rw [mul_comm, val_mul, coe_toPrincipalIdeal, val_mk0]
exact FractionalIdeal.den_mul_self_eq_num' R⁰ (FractionRing R) I
theorem ClassGroup.mk0_surjective [IsDedekindDomain R] :
Function.Surjective (ClassGroup.mk0 : (Ideal R)⁰ → ClassGroup R) := by
rintro ⟨I⟩
refine ⟨⟨ClassGroup.integralRep I.1, ClassGroup.integralRep_mem_nonZeroDivisors I.ne_zero⟩, ?_⟩
rw [ClassGroup.mk0_integralRep, ClassGroup.Quot_mk_eq_mk]
theorem ClassGroup.mk_eq_one_iff {I : (FractionalIdeal R⁰ K)ˣ} :
ClassGroup.mk I = 1 ↔ (I : Submodule R K).IsPrincipal := by
rw [← (ClassGroup.equiv K).injective.eq_iff]
simp only [equiv_mk, canonicalEquiv_self, RingEquiv.coe_mulEquiv_refl, QuotientGroup.mk'_apply,
map_one, QuotientGroup.eq_one_iff, MonoidHom.mem_range, Units.ext_iff,
coe_toPrincipalIdeal, coe_mapEquiv, MulEquiv.refl_apply]
refine ⟨fun ⟨x, hx⟩ => ⟨⟨x, by rw [← hx, coe_spanSingleton]⟩⟩, ?_⟩
intro hI
obtain ⟨x, hx⟩ := @Submodule.IsPrincipal.principal _ _ _ _ _ _ hI
have hx' : (I : FractionalIdeal R⁰ K) = spanSingleton R⁰ x := by
apply Subtype.coe_injective
simp only [val_eq_coe, hx, coe_spanSingleton]
refine ⟨Units.mk0 x ?_, ?_⟩
· intro x_eq; apply Units.ne_zero I; simp [hx', x_eq]
· simp [hx']
theorem ClassGroup.mk0_eq_one_iff [IsDedekindDomain R] {I : Ideal R} (hI : I ∈ (Ideal R)⁰) :
ClassGroup.mk0 ⟨I, hI⟩ = 1 ↔ I.IsPrincipal :=
ClassGroup.mk_eq_one_iff.trans (coeSubmodule_isPrincipal R _)
theorem ClassGroup.mk0_eq_mk0_inv_iff [IsDedekindDomain R] {I J : (Ideal R)⁰} :
ClassGroup.mk0 I = (ClassGroup.mk0 J)⁻¹ ↔
∃ x ≠ (0 : R), I * J = Ideal.span {x} := by
rw [eq_inv_iff_mul_eq_one, ← map_mul, ClassGroup.mk0_eq_one_iff,
Submodule.isPrincipal_iff, Submonoid.coe_mul]
refine ⟨fun ⟨a, ha⟩ ↦ ⟨a, ?_, ha⟩, fun ⟨a, _, ha⟩ ↦ ⟨a, ha⟩⟩
by_contra!
rw [this, Submodule.span_zero_singleton] at ha
exact nonZeroDivisors.coe_ne_zero _ <| J.prop.2 _ ha
/-- The class group of principal ideal domain is finite (in fact a singleton).
See `ClassGroup.fintypeOfAdmissibleOfFinite` for a finiteness proof that works for rings of integers
of global fields.
-/
noncomputable instance [IsPrincipalIdealRing R] : Fintype (ClassGroup R) where
elems := {1}
complete := by
refine ClassGroup.induction (R := R) (FractionRing R) (fun I => ?_)
rw [Finset.mem_singleton]
exact ClassGroup.mk_eq_one_iff.mpr (I : FractionalIdeal R⁰ (FractionRing R)).isPrincipal
/-- The class number of a principal ideal domain is `1`. -/
theorem card_classGroup_eq_one [IsPrincipalIdealRing R] : Fintype.card (ClassGroup R) = 1 := by
rw [Fintype.card_eq_one_iff]
use 1
refine ClassGroup.induction (R := R) (FractionRing R) (fun I => ?_)
exact ClassGroup.mk_eq_one_iff.mpr (I : FractionalIdeal R⁰ (FractionRing R)).isPrincipal
/-- The class number is `1` iff the ring of integers is a principal ideal domain. -/
theorem card_classGroup_eq_one_iff [IsDedekindDomain R] [Fintype (ClassGroup R)] :
Fintype.card (ClassGroup R) = 1 ↔ IsPrincipalIdealRing R := by
constructor; swap; · intros; convert card_classGroup_eq_one (R := R)
rw [Fintype.card_eq_one_iff]
rintro ⟨I, hI⟩
have eq_one : ∀ J : ClassGroup R, J = 1 := fun J => (hI J).trans (hI 1).symm
refine ⟨fun I => ?_⟩
by_cases hI : I = ⊥
· rw [hI]; exact bot_isPrincipal
· exact (ClassGroup.mk0_eq_one_iff (mem_nonZeroDivisors_iff_ne_zero.mpr hI)).mp (eq_one _) |
.lake/packages/mathlib/Mathlib/RingTheory/EuclideanDomain.lean | import Mathlib.Algebra.GCDMonoid.Basic
import Mathlib.Algebra.EuclideanDomain.Basic
import Mathlib.RingTheory.Ideal.Basic
import Mathlib.RingTheory.PrincipalIdealDomain
/-!
# Lemmas about Euclidean domains
Various about Euclidean domains are proved; all of them seem to be true
more generally for principal ideal domains, so these lemmas should
probably be reproved in more generality and this file perhaps removed?
## Tags
euclidean domain
-/
section
open EuclideanDomain Set Ideal
section GCDMonoid
variable {R : Type*} [EuclideanDomain R] [GCDMonoid R] {p q : R}
theorem left_div_gcd_ne_zero {p q : R} (hp : p ≠ 0) : p / GCDMonoid.gcd p q ≠ 0 := by
obtain ⟨r, hr⟩ := GCDMonoid.gcd_dvd_left p q
obtain ⟨pq0, r0⟩ : GCDMonoid.gcd p q ≠ 0 ∧ r ≠ 0 := mul_ne_zero_iff.mp (hr ▸ hp)
nth_rw 1 [hr]
rw [mul_comm, mul_div_cancel_right₀ _ pq0]
exact r0
theorem right_div_gcd_ne_zero {p q : R} (hq : q ≠ 0) : q / GCDMonoid.gcd p q ≠ 0 := by
obtain ⟨r, hr⟩ := GCDMonoid.gcd_dvd_right p q
obtain ⟨pq0, r0⟩ : GCDMonoid.gcd p q ≠ 0 ∧ r ≠ 0 := mul_ne_zero_iff.mp (hr ▸ hq)
nth_rw 1 [hr]
rw [mul_comm, mul_div_cancel_right₀ _ pq0]
exact r0
theorem isCoprime_div_gcd_div_gcd (hq : q ≠ 0) :
IsCoprime (p / GCDMonoid.gcd p q) (q / GCDMonoid.gcd p q) :=
(gcd_isUnit_iff _ _).1 <|
isUnit_gcd_of_eq_mul_gcd
(EuclideanDomain.mul_div_cancel' (gcd_ne_zero_of_right hq) <| gcd_dvd_left _ _).symm
(EuclideanDomain.mul_div_cancel' (gcd_ne_zero_of_right hq) <| gcd_dvd_right _ _).symm <|
gcd_ne_zero_of_right hq
/-- This is a version of `isCoprime_div_gcd_div_gcd` which replaces the `q ≠ 0` assumption with
`gcd p q ≠ 0`. -/
theorem isCoprime_div_gcd_div_gcd_of_gcd_ne_zero (hpq : GCDMonoid.gcd p q ≠ 0) :
IsCoprime (p / GCDMonoid.gcd p q) (q / GCDMonoid.gcd p q) :=
(gcd_isUnit_iff _ _).1 <|
isUnit_gcd_of_eq_mul_gcd
(EuclideanDomain.mul_div_cancel' (hpq) <| gcd_dvd_left _ _).symm
(EuclideanDomain.mul_div_cancel' (hpq) <| gcd_dvd_right _ _).symm <| hpq
end GCDMonoid
namespace EuclideanDomain
/-- Create a `GCDMonoid` whose `GCDMonoid.gcd` matches `EuclideanDomain.gcd`. -/
def gcdMonoid (R) [EuclideanDomain R] [DecidableEq R] : GCDMonoid R where
gcd := gcd
lcm := lcm
gcd_dvd_left := gcd_dvd_left
gcd_dvd_right := gcd_dvd_right
dvd_gcd := dvd_gcd
gcd_mul_lcm a b := by rw [EuclideanDomain.gcd_mul_lcm]
lcm_zero_left := lcm_zero_left
lcm_zero_right := lcm_zero_right
variable {α : Type*} [EuclideanDomain α]
theorem span_gcd [DecidableEq α] (x y : α) :
span ({gcd x y} : Set α) = span ({x, y} : Set α) :=
letI := EuclideanDomain.gcdMonoid α
_root_.span_gcd x y
theorem gcd_isUnit_iff [DecidableEq α] {x y : α} : IsUnit (gcd x y) ↔ IsCoprime x y :=
letI := EuclideanDomain.gcdMonoid α
_root_.gcd_isUnit_iff x y
-- this should be proved for UFDs surely?
theorem isCoprime_of_dvd {x y : α} (nonzero : ¬(x = 0 ∧ y = 0))
(H : ∀ z ∈ nonunits α, z ≠ 0 → z ∣ x → ¬z ∣ y) : IsCoprime x y :=
letI := Classical.decEq α
letI := EuclideanDomain.gcdMonoid α
_root_.isCoprime_of_dvd x y nonzero H
-- this should be proved for UFDs surely?
theorem dvd_or_coprime (x y : α) (h : Irreducible x) :
x ∣ y ∨ IsCoprime x y :=
letI := Classical.decEq α
letI := EuclideanDomain.gcdMonoid α
_root_.dvd_or_isCoprime x y h
end EuclideanDomain
end |
.lake/packages/mathlib/Mathlib/RingTheory/PrincipalIdealDomain.lean | import Mathlib.Algebra.EuclideanDomain.Basic
import Mathlib.Algebra.EuclideanDomain.Field
import Mathlib.Algebra.GCDMonoid.Basic
import Mathlib.RingTheory.Ideal.Prod
import Mathlib.RingTheory.Ideal.Nonunits
import Mathlib.RingTheory.Noetherian.UniqueFactorizationDomain
/-!
# Principal ideal rings, principal ideal domains, and Bézout rings
A principal ideal ring (PIR) is a ring in which all left ideals are principal. A
principal ideal domain (PID) is an integral domain which is a principal ideal ring.
The definition of `IsPrincipalIdealRing` can be found in `Mathlib/RingTheory/Ideal/Span.lean`.
## Main definitions
Note that for principal ideal domains, one should use
`[IsDomain R] [IsPrincipalIdealRing R]`. There is no explicit definition of a PID.
Theorems about PID's are in the `PrincipalIdealRing` namespace.
- `IsBezout`: the predicate saying that every finitely generated left ideal is principal.
- `generator`: a generator of a principal ideal (or more generally submodule)
- `to_uniqueFactorizationMonoid`: a PID is a unique factorization domain
## Main results
- `Ideal.IsPrime.to_maximal_ideal`: a non-zero prime ideal in a PID is maximal.
- `EuclideanDomain.to_principal_ideal_domain` : a Euclidean domain is a PID.
- `IsBezout.nonemptyGCDMonoid`: Every Bézout domain is a GCD domain.
-/
universe u v
variable {R : Type u} {M : Type v}
open Set Function
open Submodule
section
variable [Semiring R] [AddCommMonoid M] [Module R M]
instance bot_isPrincipal : (⊥ : Submodule R M).IsPrincipal :=
⟨⟨0, by simp⟩⟩
instance top_isPrincipal : (⊤ : Submodule R R).IsPrincipal :=
⟨⟨1, Ideal.span_singleton_one.symm⟩⟩
variable (R)
/-- A Bézout ring is a ring whose finitely generated ideals are principal. -/
class IsBezout : Prop where
/-- Any finitely generated ideal is principal. -/
isPrincipal_of_FG : ∀ I : Ideal R, I.FG → I.IsPrincipal
instance (priority := 100) IsBezout.of_isPrincipalIdealRing [IsPrincipalIdealRing R] : IsBezout R :=
⟨fun I _ => IsPrincipalIdealRing.principal I⟩
instance (priority := 100) DivisionSemiring.isPrincipalIdealRing (K : Type u) [DivisionSemiring K] :
IsPrincipalIdealRing K where
principal S := by
rcases Ideal.eq_bot_or_top S with (rfl | rfl)
· apply bot_isPrincipal
· apply top_isPrincipal
end
namespace Submodule.IsPrincipal
variable [AddCommMonoid M]
section Semiring
variable [Semiring R] [Module R M]
@[simp]
theorem _root_.Ideal.span_singleton_generator (I : Ideal R) [I.IsPrincipal] :
Ideal.span ({generator I} : Set R) = I :=
Eq.symm (Classical.choose_spec (principal I))
@[simp]
theorem generator_mem (S : Submodule R M) [S.IsPrincipal] : generator S ∈ S := by
have : generator S ∈ span R {generator S} := subset_span (mem_singleton _)
convert this
exact span_singleton_generator S |>.symm
theorem mem_iff_eq_smul_generator (S : Submodule R M) [S.IsPrincipal] {x : M} :
x ∈ S ↔ ∃ s : R, x = s • generator S := by
simp_rw [@eq_comm _ x, ← mem_span_singleton, span_singleton_generator]
theorem eq_bot_iff_generator_eq_zero (S : Submodule R M) [S.IsPrincipal] :
S = ⊥ ↔ generator S = 0 := by rw [← @span_singleton_eq_bot R M, span_singleton_generator]
protected lemma fg {S : Submodule R M} (h : S.IsPrincipal) : S.FG :=
⟨{h.generator}, by simp only [Finset.coe_singleton, span_singleton_generator]⟩
-- See note [lower instance priority]
instance (priority := 100) _root_.PrincipalIdealRing.isNoetherianRing [IsPrincipalIdealRing R] :
IsNoetherianRing R where
noetherian S := (IsPrincipalIdealRing.principal S).fg
-- See note [lower instance priority]
instance (priority := 100) _root_.IsPrincipalIdealRing.of_isNoetherianRing_of_isBezout
[IsNoetherianRing R] [IsBezout R] : IsPrincipalIdealRing R where
principal S := IsBezout.isPrincipal_of_FG S (IsNoetherian.noetherian S)
end Semiring
section CommSemiring
variable [CommSemiring R] [Module R M]
theorem associated_generator_span_self [IsDomain R] (r : R) :
Associated (generator <| Ideal.span {r}) r := by
rw [← Ideal.span_singleton_eq_span_singleton]
exact Ideal.span_singleton_generator _
theorem mem_iff_generator_dvd (S : Ideal R) [S.IsPrincipal] {x : R} : x ∈ S ↔ generator S ∣ x :=
(mem_iff_eq_smul_generator S).trans (exists_congr fun a => by simp only [mul_comm, smul_eq_mul])
theorem prime_generator_of_isPrime (S : Ideal R) [S.IsPrincipal] [is_prime : S.IsPrime]
(ne_bot : S ≠ ⊥) : Prime (generator S) :=
⟨fun h => ne_bot ((eq_bot_iff_generator_eq_zero S).2 h), fun h =>
is_prime.ne_top (S.eq_top_of_isUnit_mem (generator_mem S) h), fun _ _ => by
simpa only [← mem_iff_generator_dvd S] using is_prime.2⟩
-- Note that the converse may not hold if `ϕ` is not injective.
theorem generator_map_dvd_of_mem {N : Submodule R M} (ϕ : M →ₗ[R] R) [(N.map ϕ).IsPrincipal] {x : M}
(hx : x ∈ N) : generator (N.map ϕ) ∣ ϕ x := by
rw [← mem_iff_generator_dvd, Submodule.mem_map]
exact ⟨x, hx, rfl⟩
-- Note that the converse may not hold if `ϕ` is not injective.
theorem generator_submoduleImage_dvd_of_mem {N O : Submodule R M} (hNO : N ≤ O) (ϕ : O →ₗ[R] R)
[(ϕ.submoduleImage N).IsPrincipal] {x : M} (hx : x ∈ N) :
generator (ϕ.submoduleImage N) ∣ ϕ ⟨x, hNO hx⟩ := by
rw [← mem_iff_generator_dvd, LinearMap.mem_submoduleImage_of_le hNO]
exact ⟨x, hx, rfl⟩
theorem dvd_generator_span_iff {r : R} {s : Set R} [(Ideal.span s).IsPrincipal] :
r ∣ generator (Ideal.span s) ↔ ∀ x ∈ s, r ∣ x where
mp h x hx := h.trans <| (mem_iff_generator_dvd _).mp (Ideal.subset_span hx)
mpr h := have : (span R s).IsPrincipal := ‹_›
span_induction h (dvd_zero _) (fun _ _ _ _ ↦ dvd_add) (fun _ _ _ ↦ (·.mul_left _))
(generator_mem _)
end CommSemiring
end Submodule.IsPrincipal
namespace IsBezout
section
variable [Ring R]
instance span_pair_isPrincipal [IsBezout R] (x y : R) : (Ideal.span {x, y}).IsPrincipal := by
classical exact isPrincipal_of_FG (Ideal.span {x, y}) ⟨{x, y}, by simp⟩
variable (x y : R) [(Ideal.span {x, y}).IsPrincipal]
/-- A choice of gcd of two elements in a Bézout domain.
Note that the choice is usually not unique. -/
noncomputable def gcd : R := Submodule.IsPrincipal.generator (Ideal.span {x, y})
theorem span_gcd : Ideal.span {gcd x y} = Ideal.span {x, y} :=
Ideal.span_singleton_generator _
end
variable [CommRing R] (x y z : R) [(Ideal.span {x, y}).IsPrincipal]
theorem gcd_dvd_left : gcd x y ∣ x :=
(Submodule.IsPrincipal.mem_iff_generator_dvd _).mp (Ideal.subset_span (by simp))
theorem gcd_dvd_right : gcd x y ∣ y :=
(Submodule.IsPrincipal.mem_iff_generator_dvd _).mp (Ideal.subset_span (by simp))
variable {x y z} in
theorem dvd_gcd (hx : z ∣ x) (hy : z ∣ y) : z ∣ gcd x y := by
rw [← Ideal.span_singleton_le_span_singleton] at hx hy ⊢
rw [span_gcd, Ideal.span_insert, sup_le_iff]
exact ⟨hx, hy⟩
theorem gcd_eq_sum : ∃ a b : R, a * x + b * y = gcd x y :=
Ideal.mem_span_pair.mp (by rw [← span_gcd]; apply Ideal.subset_span; simp)
variable {x y}
theorem _root_.IsRelPrime.isCoprime (h : IsRelPrime x y) : IsCoprime x y := by
rw [← Ideal.isCoprime_span_singleton_iff, Ideal.isCoprime_iff_sup_eq, ← Ideal.span_union,
Set.singleton_union, ← span_gcd, Ideal.span_singleton_eq_top]
exact h (gcd_dvd_left x y) (gcd_dvd_right x y)
theorem _root_.isRelPrime_iff_isCoprime : IsRelPrime x y ↔ IsCoprime x y :=
⟨IsRelPrime.isCoprime, IsCoprime.isRelPrime⟩
variable (R)
/-- Any Bézout domain is a GCD domain. This is not an instance since `GCDMonoid` contains data,
and this might not be how we would like to construct it. -/
noncomputable def toGCDDomain [IsBezout R] [IsDomain R] [DecidableEq R] : GCDMonoid R :=
gcdMonoidOfGCD (gcd · ·) (gcd_dvd_left · ·) (gcd_dvd_right · ·) dvd_gcd
instance nonemptyGCDMonoid [IsBezout R] [IsDomain R] : Nonempty (GCDMonoid R) := by
classical exact ⟨toGCDDomain R⟩
theorem associated_gcd_gcd [IsDomain R] [GCDMonoid R] :
Associated (IsBezout.gcd x y) (GCDMonoid.gcd x y) :=
gcd_greatest_associated (gcd_dvd_left _ _) (gcd_dvd_right _ _) (fun _ => dvd_gcd)
end IsBezout
namespace IsPrime
open Submodule.IsPrincipal Ideal
-- TODO -- for a non-ID one could perhaps prove that if p < q are prime then q maximal;
-- 0 isn't prime in a non-ID PIR but the Krull dimension is still <= 1.
-- The below result follows from this, but we could also use the below result to
-- prove this (quotient out by p).
theorem to_maximal_ideal [CommRing R] [IsDomain R] [IsPrincipalIdealRing R] {S : Ideal R}
[hpi : IsPrime S] (hS : S ≠ ⊥) : IsMaximal S :=
isMaximal_iff.2
⟨(ne_top_iff_one S).1 hpi.1, by
intro T x hST hxS hxT
obtain ⟨z, hz⟩ := (mem_iff_generator_dvd _).1 (hST <| generator_mem S)
cases hpi.mem_or_mem (show generator T * z ∈ S from hz ▸ generator_mem S) with
| inl h =>
have hTS : T ≤ S := by
rwa [← T.span_singleton_generator, Ideal.span_le, singleton_subset_iff]
exact (hxS <| hTS hxT).elim
| inr h =>
obtain ⟨y, hy⟩ := (mem_iff_generator_dvd _).1 h
have : generator S ≠ 0 := mt (eq_bot_iff_generator_eq_zero _).2 hS
rw [← mul_one (generator S), hy, mul_left_comm, mul_right_inj' this] at hz
exact hz.symm ▸ T.mul_mem_right _ (generator_mem T)⟩
end IsPrime
section
open EuclideanDomain
variable [EuclideanDomain R]
theorem mod_mem_iff {S : Ideal R} {x y : R} (hy : y ∈ S) : x % y ∈ S ↔ x ∈ S :=
⟨fun hxy => div_add_mod x y ▸ S.add_mem (S.mul_mem_right _ hy) hxy, fun hx =>
(mod_eq_sub_mul_div x y).symm ▸ S.sub_mem hx (S.mul_mem_right _ hy)⟩
-- see Note [lower instance priority]
instance (priority := 100) EuclideanDomain.to_principal_ideal_domain : IsPrincipalIdealRing R where
principal S := by classical exact
⟨if h : { x : R | x ∈ S ∧ x ≠ 0 }.Nonempty then
have wf : WellFounded (EuclideanDomain.r : R → R → Prop) := EuclideanDomain.r_wellFounded
have hmin : WellFounded.min wf { x : R | x ∈ S ∧ x ≠ 0 } h ∈ S ∧
WellFounded.min wf { x : R | x ∈ S ∧ x ≠ 0 } h ≠ 0 :=
WellFounded.min_mem wf { x : R | x ∈ S ∧ x ≠ 0 } h
⟨WellFounded.min wf { x : R | x ∈ S ∧ x ≠ 0 } h,
Submodule.ext fun x => ⟨fun hx =>
div_add_mod x (WellFounded.min wf { x : R | x ∈ S ∧ x ≠ 0 } h) ▸
(Ideal.mem_span_singleton.2 <| dvd_add (dvd_mul_right _ _) <| by
have : x % WellFounded.min wf { x : R | x ∈ S ∧ x ≠ 0 } h ∉
{ x : R | x ∈ S ∧ x ≠ 0 } :=
fun h₁ => WellFounded.not_lt_min wf _ h h₁ (mod_lt x hmin.2)
have : x % WellFounded.min wf { x : R | x ∈ S ∧ x ≠ 0 } h = 0 := by
simp only [not_and_or, Set.mem_setOf_eq, not_ne_iff] at this
exact this.neg_resolve_left <| (mod_mem_iff hmin.1).2 hx
simp [*]),
fun hx =>
let ⟨y, hy⟩ := Ideal.mem_span_singleton.1 hx
hy.symm ▸ S.mul_mem_right _ hmin.1⟩⟩
else ⟨0, Submodule.ext fun a => by
rw [← @Submodule.bot_coe R R _ _ _, span_eq, Submodule.mem_bot]
exact ⟨fun haS => by_contra fun ha0 => h ⟨a, ⟨haS, ha0⟩⟩,
fun h₁ => h₁.symm ▸ S.zero_mem⟩⟩⟩
end
theorem IsField.isPrincipalIdealRing {R : Type*} [Ring R] (h : IsField R) :
IsPrincipalIdealRing R :=
@EuclideanDomain.to_principal_ideal_domain R (@Field.toEuclideanDomain R h.toField)
namespace PrincipalIdealRing
open IsPrincipalIdealRing
theorem isMaximal_of_irreducible [CommSemiring R] [IsPrincipalIdealRing R] {p : R}
(hp : Irreducible p) : Ideal.IsMaximal (span R ({p} : Set R)) :=
⟨⟨mt Ideal.span_singleton_eq_top.1 hp.1, fun I hI => by
rcases principal I with ⟨a, rfl⟩
rw [Ideal.submodule_span_eq, Ideal.span_singleton_eq_top]
rcases Ideal.span_singleton_le_span_singleton.1 (le_of_lt hI) with ⟨b, rfl⟩
refine (of_irreducible_mul hp).resolve_right (mt (fun hb => ?_) (not_le_of_gt hI))
rw [Ideal.submodule_span_eq, Ideal.submodule_span_eq,
Ideal.span_singleton_le_span_singleton, IsUnit.mul_right_dvd hb]⟩⟩
variable [CommRing R] [IsDomain R] [IsPrincipalIdealRing R]
section
open scoped Classical in
/-- `factors a` is a multiset of irreducible elements whose product is `a`, up to units -/
noncomputable def factors (a : R) : Multiset R :=
if h : a = 0 then ∅ else Classical.choose (WfDvdMonoid.exists_factors a h)
theorem factors_spec (a : R) (h : a ≠ 0) :
(∀ b ∈ factors a, Irreducible b) ∧ Associated (factors a).prod a := by
unfold factors; rw [dif_neg h]
exact Classical.choose_spec (WfDvdMonoid.exists_factors a h)
theorem ne_zero_of_mem_factors {R : Type v} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R]
{a b : R} (ha : a ≠ 0) (hb : b ∈ factors a) : b ≠ 0 :=
Irreducible.ne_zero ((factors_spec a ha).1 b hb)
theorem mem_submonoid_of_factors_subset_of_units_subset (s : Submonoid R) {a : R} (ha : a ≠ 0)
(hfac : ∀ b ∈ factors a, b ∈ s) (hunit : ∀ c : Rˣ, (c : R) ∈ s) : a ∈ s := by
rcases (factors_spec a ha).2 with ⟨c, hc⟩
rw [← hc]
exact mul_mem (multiset_prod_mem _ hfac) (hunit _)
/-- If a `RingHom` maps all units and all factors of an element `a` into a submonoid `s`, then it
also maps `a` into that submonoid. -/
theorem ringHom_mem_submonoid_of_factors_subset_of_units_subset {R S : Type*} [CommRing R]
[IsDomain R] [IsPrincipalIdealRing R] [NonAssocSemiring S] (f : R →+* S) (s : Submonoid S)
(a : R) (ha : a ≠ 0) (h : ∀ b ∈ factors a, f b ∈ s) (hf : ∀ c : Rˣ, f c ∈ s) : f a ∈ s :=
mem_submonoid_of_factors_subset_of_units_subset (s.comap f.toMonoidHom) ha h hf
-- see Note [lower instance priority]
/-- A principal ideal domain has unique factorization -/
instance (priority := 100) to_uniqueFactorizationMonoid : UniqueFactorizationMonoid R :=
{ (IsNoetherianRing.wfDvdMonoid : WfDvdMonoid R) with
irreducible_iff_prime := irreducible_iff_prime }
end
end PrincipalIdealRing
section Surjective
open Submodule
variable {S N F : Type*} [Semiring R] [AddCommMonoid M] [AddCommMonoid N] [Semiring S]
variable [Module R M] [Module R N] [FunLike F R S] [RingHomClass F R S]
theorem Submodule.IsPrincipal.map (f : M →ₗ[R] N) {S : Submodule R M}
(hI : IsPrincipal S) : IsPrincipal (map f S) :=
⟨⟨f (IsPrincipal.generator S), by
rw [← Set.image_singleton, ← map_span, span_singleton_generator]⟩⟩
theorem Submodule.IsPrincipal.of_comap (f : M →ₗ[R] N) (hf : Function.Surjective f)
(S : Submodule R N) [hI : IsPrincipal (S.comap f)] : IsPrincipal S := by
rw [← Submodule.map_comap_eq_of_surjective hf S]
exact hI.map f
theorem Submodule.IsPrincipal.map_ringHom (f : F) {I : Ideal R}
(hI : IsPrincipal I) : IsPrincipal (Ideal.map f I) :=
⟨⟨f (IsPrincipal.generator I), by
rw [Ideal.submodule_span_eq, ← Set.image_singleton, ← Ideal.map_span,
Ideal.span_singleton_generator]⟩⟩
theorem Ideal.IsPrincipal.of_comap (f : F) (hf : Function.Surjective f) (I : Ideal S)
[hI : IsPrincipal (I.comap f)] : IsPrincipal I := by
rw [← map_comap_of_surjective f hf I]
exact hI.map_ringHom f
/-- The surjective image of a principal ideal ring is again a principal ideal ring. -/
theorem IsPrincipalIdealRing.of_surjective [IsPrincipalIdealRing R] (f : F)
(hf : Function.Surjective f) : IsPrincipalIdealRing S :=
⟨fun I => Ideal.IsPrincipal.of_comap f hf I⟩
theorem isPrincipalIdealRing_prod_iff :
IsPrincipalIdealRing (R × S) ↔ IsPrincipalIdealRing R ∧ IsPrincipalIdealRing S where
mp h := ⟨h.of_surjective (RingHom.fst R S) Prod.fst_surjective,
h.of_surjective (RingHom.snd R S) Prod.snd_surjective⟩
mpr := fun ⟨_, _⟩ ↦ inferInstance
theorem isPrincipalIdealRing_pi_iff {ι} [Finite ι] {R : ι → Type*} [∀ i, Semiring (R i)] :
IsPrincipalIdealRing (Π i, R i) ↔ ∀ i, IsPrincipalIdealRing (R i) where
mp h i := h.of_surjective (Pi.evalRingHom R i) (Function.surjective_eval _)
mpr _ := inferInstance
end Surjective
section
open Ideal
variable [CommRing R]
section Bezout
variable [IsBezout R]
theorem isCoprime_of_dvd (x y : R) (nonzero : ¬(x = 0 ∧ y = 0))
(H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y) : IsCoprime x y :=
(isRelPrime_of_no_nonunits_factors nonzero H).isCoprime
theorem dvd_or_isCoprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y :=
h.dvd_or_isRelPrime.imp_right IsRelPrime.isCoprime
/-- See also `Irreducible.isRelPrime_iff_not_dvd`. -/
theorem Irreducible.coprime_iff_not_dvd {p n : R} (hp : Irreducible p) :
IsCoprime p n ↔ ¬p ∣ n := by rw [← isRelPrime_iff_isCoprime, hp.isRelPrime_iff_not_dvd]
/-- See also `Irreducible.coprime_iff_not_dvd'`. -/
theorem Irreducible.dvd_iff_not_isCoprime {p n : R} (hp : Irreducible p) : p ∣ n ↔ ¬IsCoprime p n :=
iff_not_comm.2 hp.coprime_iff_not_dvd
theorem Irreducible.coprime_pow_of_not_dvd {p a : R} (m : ℕ) (hp : Irreducible p) (h : ¬p ∣ a) :
IsCoprime a (p ^ m) :=
(hp.coprime_iff_not_dvd.2 h).symm.pow_right
theorem Irreducible.isCoprime_or_dvd {p : R} (hp : Irreducible p) (i : R) : IsCoprime p i ∨ p ∣ i :=
(_root_.em _).imp_right hp.dvd_iff_not_isCoprime.2
variable [IsDomain R]
section GCD
variable [GCDMonoid R]
theorem IsBezout.span_gcd_eq_span_gcd (x y : R) :
span {GCDMonoid.gcd x y} = span {IsBezout.gcd x y} := by
rw [Ideal.span_singleton_eq_span_singleton]
exact associated_of_dvd_dvd
(IsBezout.dvd_gcd (GCDMonoid.gcd_dvd_left _ _) <| GCDMonoid.gcd_dvd_right _ _)
(GCDMonoid.dvd_gcd (IsBezout.gcd_dvd_left _ _) <| IsBezout.gcd_dvd_right _ _)
theorem span_gcd (x y : R) : span {gcd x y} = span {x, y} := by
rw [← IsBezout.span_gcd, IsBezout.span_gcd_eq_span_gcd]
theorem gcd_dvd_iff_exists (a b : R) {z} : gcd a b ∣ z ↔ ∃ x y, z = a * x + b * y := by
simp_rw [mul_comm a, mul_comm b, @eq_comm _ z, ← Ideal.mem_span_pair, ← span_gcd,
Ideal.mem_span_singleton]
/-- **Bézout's lemma** -/
theorem exists_gcd_eq_mul_add_mul (a b : R) : ∃ x y, gcd a b = a * x + b * y := by
rw [← gcd_dvd_iff_exists]
theorem gcd_isUnit_iff (x y : R) : IsUnit (gcd x y) ↔ IsCoprime x y := by
rw [IsCoprime, ← Ideal.mem_span_pair, ← span_gcd, ← span_singleton_eq_top, eq_top_iff_one]
end GCD
theorem Prime.coprime_iff_not_dvd {p n : R} (hp : Prime p) : IsCoprime p n ↔ ¬p ∣ n :=
hp.irreducible.coprime_iff_not_dvd
theorem exists_associated_pow_of_mul_eq_pow' {a b c : R} (hab : IsCoprime a b) {k : ℕ}
(h : a * b = c ^ k) : ∃ d : R, Associated (d ^ k) a := by
classical
letI := IsBezout.toGCDDomain R
exact exists_associated_pow_of_mul_eq_pow ((gcd_isUnit_iff _ _).mpr hab) h
theorem exists_associated_pow_of_associated_pow_mul {a b c : R} (hab : IsCoprime a b) {k : ℕ}
(h : Associated (c ^ k) (a * b)) : ∃ d : R, Associated (d ^ k) a := by
obtain ⟨u, hu⟩ := h.symm
exact exists_associated_pow_of_mul_eq_pow'
((isCoprime_mul_unit_right_right u.isUnit a b).mpr hab) <| mul_assoc a _ _ ▸ hu
end Bezout
variable [IsDomain R] [IsPrincipalIdealRing R]
theorem isCoprime_of_irreducible_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
(H : ∀ z : R, Irreducible z → z ∣ x → ¬z ∣ y) : IsCoprime x y :=
(WfDvdMonoid.isRelPrime_of_no_irreducible_factors nonzero H).isCoprime
theorem isCoprime_of_prime_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
(H : ∀ z : R, Prime z → z ∣ x → ¬z ∣ y) : IsCoprime x y :=
isCoprime_of_irreducible_dvd nonzero fun z zi ↦ H z zi.prime
end
section PrincipalOfPrime
namespace Ideal
variable (R) [Semiring R]
/-- `nonPrincipals R` is the set of all ideals of `R` that are not principal ideals. -/
abbrev nonPrincipals := { I : Ideal R | ¬I.IsPrincipal }
variable {R}
theorem nonPrincipals_eq_empty_iff : nonPrincipals R = ∅ ↔ IsPrincipalIdealRing R := by
simp [Set.eq_empty_iff_forall_notMem, isPrincipalIdealRing_iff]
/-- Any chain in the set of non-principal ideals has an upper bound which is non-principal.
(Namely, the union of the chain is such an upper bound.)
If you want the existence of a maximal non-principal ideal see
`Ideal.exists_maximal_not_isPrincipal`. -/
theorem nonPrincipals_zorn (hR : ¬IsPrincipalIdealRing R) (c : Set (Ideal R))
(hs : c ⊆ nonPrincipals R) (hchain : IsChain (· ≤ ·) c) :
∃ I ∈ nonPrincipals R, ∀ J ∈ c, J ≤ I := by
by_cases H : c.Nonempty
· obtain ⟨K, hKmem⟩ := Set.nonempty_def.1 H
refine ⟨sSup c, fun ⟨x, hx⟩ ↦ ?_, fun _ ↦ le_sSup⟩
have hxmem : x ∈ sSup c := hx.symm ▸ Submodule.mem_span_singleton_self x
obtain ⟨J, hJc, hxJ⟩ := (Submodule.mem_sSup_of_directed ⟨K, hKmem⟩ hchain.directedOn).1 hxmem
have hsSupJ : sSup c = J := le_antisymm (by simp [hx, Ideal.span_le, hxJ]) (le_sSup hJc)
exact hs hJc ⟨hsSupJ ▸ ⟨x, hx⟩⟩
· simpa [Set.not_nonempty_iff_eq_empty.1 H, isPrincipalIdealRing_iff] using hR
theorem exists_maximal_not_isPrincipal (hR : ¬IsPrincipalIdealRing R) :
∃ I : Ideal R, Maximal (¬·.IsPrincipal) I :=
zorn_le₀ _ (nonPrincipals_zorn hR)
end Ideal
end PrincipalOfPrime
section PrincipalOfPrime_old
variable (R) [CommRing R]
/-- `nonPrincipals R` is the set of all ideals of `R` that are not principal ideals. -/
@[deprecated Ideal.nonPrincipals (since := "2025-09-30")]
def nonPrincipals :=
{ I : Ideal R | ¬I.IsPrincipal }
@[deprecated "Not necessary anymore since Ideal.nonPrincipals is an abrev." (since := "2025-09-30")]
theorem nonPrincipals_def {I : Ideal R} : I ∈ { I : Ideal R | ¬I.IsPrincipal } ↔ ¬I.IsPrincipal :=
Iff.rfl
variable {R}
@[deprecated Ideal.nonPrincipals_eq_empty_iff (since := "2025-09-30")]
theorem nonPrincipals_eq_empty_iff :
{ I : Ideal R | ¬I.IsPrincipal } = ∅ ↔ IsPrincipalIdealRing R := by
simp [Set.eq_empty_iff_forall_notMem, isPrincipalIdealRing_iff]
/-- Any chain in the set of non-principal ideals has an upper bound which is non-principal.
(Namely, the union of the chain is such an upper bound.)
-/
@[deprecated Ideal.nonPrincipals_zorn (since := "2025-09-30")]
theorem nonPrincipals_zorn (c : Set (Ideal R)) (hs : c ⊆ { I : Ideal R | ¬I.IsPrincipal })
(hchain : IsChain (· ≤ ·) c) {K : Ideal R} (hKmem : K ∈ c) :
∃ I ∈ { I : Ideal R | ¬I.IsPrincipal }, ∀ J ∈ c, J ≤ I := by
refine ⟨sSup c, ?_, fun J hJ => le_sSup hJ⟩
rintro ⟨x, hx⟩
have hxmem : x ∈ sSup c := hx.symm ▸ Submodule.mem_span_singleton_self x
obtain ⟨J, hJc, hxJ⟩ := (Submodule.mem_sSup_of_directed ⟨K, hKmem⟩ hchain.directedOn).1 hxmem
have hsSupJ : sSup c = J := le_antisymm (by simp [hx, Ideal.span_le, hxJ]) (le_sSup hJc)
specialize hs hJc
rw [← hsSupJ, hx] at hs
exact hs ⟨⟨x, rfl⟩⟩
end PrincipalOfPrime_old |
.lake/packages/mathlib/Mathlib/RingTheory/Frobenius.lean | import Mathlib.FieldTheory.Finite.Basic
import Mathlib.RingTheory.Invariant.Basic
import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots
import Mathlib.RingTheory.Unramified.Locus
/-!
# Frobenius elements
In algebraic number theory, if `L/K` is a finite Galois extension of number fields, with rings of
integers `𝓞L/𝓞K`, and if `q` is prime ideal of `𝓞L` lying over a prime ideal `p` of `𝓞K`, then
there exists a **Frobenius element** `Frob p` in `Gal(L/K)` with the property that
`Frob p x ≡ x ^ #(𝓞K/p) (mod q)` for all `x ∈ 𝓞L`.
Following `RingTheory/Invariant.lean`, we develop the theory in the setting that
there is a finite group `G` acting on a ring `S`, and `R` is the fixed subring of `S`.
## Main results
Let `S/R` be an extension of rings, `Q` be a prime of `S`,
and `P := R ∩ Q` with finite residue field of cardinality `q`.
- `AlgHom.IsArithFrobAt`: We say that a `φ : S →ₐ[R] S` is an (arithmetic) Frobenius at `Q`
if `φ x ≡ x ^ q (mod Q)` for all `x : S`.
- `AlgHom.IsArithFrobAt.apply_of_pow_eq_one`:
Suppose `S` is a domain and `φ` is a Frobenius at `Q`,
then `φ ζ = ζ ^ q` for any `m`-th root of unity `ζ` with `q ∤ m`.
- `AlgHom.IsArithFrobAt.eq_of_isUnramifiedAt`:
Suppose `S` is Noetherian, `Q` contains all zero-divisors, and the extension is unramified at `Q`.
Then the Frobenius is unique (if exists).
Let `G` be a finite group acting on a ring `S`, and `R` is the fixed subring of `S`.
- `IsArithFrobAt`: We say that a `σ : G` is an (arithmetic) Frobenius at `Q`
if `σ • x ≡ x ^ q (mod Q)` for all `x : S`.
- `IsArithFrobAt.mul_inv_mem_inertia`:
Two Frobenius elements at `Q` differ by an element in the inertia subgroup of `Q`.
- `IsArithFrobAt.conj`: If `σ` is a Frobenius at `Q`, then `τστ⁻¹` is a Frobenius at `σ • Q`.
- `IsArithFrobAt.exists_of_isInvariant`: Frobenius element exists.
-/
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S]
/-- `φ : S →ₐ[R] S` is an (arithmetic) Frobenius at `Q` if
`φ x ≡ x ^ #(R/p) (mod Q)` for all `x : S` (`AlgHom.IsArithFrobAt`). -/
def AlgHom.IsArithFrobAt (φ : S →ₐ[R] S) (Q : Ideal S) : Prop :=
∀ x, φ x - x ^ Nat.card (R ⧸ Q.under R) ∈ Q
namespace AlgHom.IsArithFrobAt
variable {φ ψ : S →ₐ[R] S} {Q : Ideal S} (H : φ.IsArithFrobAt Q)
include H
lemma mk_apply (x) : Ideal.Quotient.mk Q (φ x) = x ^ Nat.card (R ⧸ Q.under R) := by
rw [← map_pow, Ideal.Quotient.eq]
exact H x
lemma finite_quotient : _root_.Finite (R ⧸ Q.under R) := by
by_contra! h
obtain rfl : Q = ⊤ := by simpa [Nat.card_eq_zero_of_infinite, ← Ideal.eq_top_iff_one] using H 0
simp only [Ideal.comap_top] at h
exact not_finite (R ⧸ (⊤ : Ideal R))
lemma card_pos : 0 < Nat.card (R ⧸ Q.under R) :=
have := H.finite_quotient
Nat.card_pos
lemma le_comap : Q ≤ Q.comap φ := by
intro x hx
simp_all only [Ideal.mem_comap, ← Ideal.Quotient.eq_zero_iff_mem (I := Q), H.mk_apply,
zero_pow_eq, ite_eq_right_iff, H.card_pos.ne', false_implies]
/-- A Frobenius element at `Q` restricts to the Frobenius map on `S ⧸ Q`. -/
def restrict : S ⧸ Q →ₐ[R ⧸ Q.under R] S ⧸ Q where
toRingHom := Ideal.quotientMap Q φ H.le_comap
commutes' x := by
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
exact DFunLike.congr_arg (Ideal.Quotient.mk Q) (φ.commutes x)
lemma restrict_apply (x : S ⧸ Q) :
H.restrict x = x ^ Nat.card (R ⧸ Q.under R) := by
obtain ⟨x, rfl⟩ := Ideal.Quotient.mk_surjective x
exact H.mk_apply x
lemma restrict_mk (x : S) : H.restrict ↑x = ↑(φ x) := rfl
lemma restrict_injective [Q.IsPrime] :
Function.Injective H.restrict := by
rw [injective_iff_map_eq_zero]
intro x hx
simpa [restrict_apply, H.card_pos.ne'] using hx
lemma comap_eq [Q.IsPrime] : Q.comap φ = Q := by
refine le_antisymm (fun x hx ↦ ?_) H.le_comap
rwa [← Ideal.Quotient.eq_zero_iff_mem, ← H.restrict_injective.eq_iff, map_zero, restrict_mk,
Ideal.Quotient.eq_zero_iff_mem, ← Ideal.mem_comap]
/-- Suppose `S` is a domain, and `φ : S →ₐ[R] S` is a Frobenius at `Q : Ideal S`.
Let `ζ` be a `m`-th root of unity with `Q ∤ m`, then `φ` sends `ζ` to `ζ ^ q`. -/
lemma apply_of_pow_eq_one [IsDomain S] {ζ : S} {m : ℕ} (hζ : ζ ^ m = 1) (hk' : ↑m ∉ Q) :
φ ζ = ζ ^ Nat.card (R ⧸ Q.under R) := by
set q := Nat.card (R ⧸ Q.under R)
have hm : m ≠ 0 := by rintro rfl; exact hk' (by simp)
obtain ⟨k, hk, hζ⟩ := IsPrimitiveRoot.exists_pos hζ hm
have hk' : ↑k ∉ Q := fun h ↦ hk' (Q.mem_of_dvd (Nat.cast_dvd_cast (hζ.2 m ‹_›)) h)
have : NeZero k := ⟨hk.ne'⟩
obtain ⟨i, hi, e⟩ := hζ.eq_pow_of_pow_eq_one (ξ := φ ζ) (by rw [← map_pow, hζ.1, map_one])
have (j : _) : 1 - ζ ^ ((q + k - i) * j) ∈ Q := by
rw [← Ideal.mul_unit_mem_iff_mem _ ((hζ.isUnit NeZero.out).pow (i * j)),
sub_mul, one_mul, ← pow_add, ← add_mul, tsub_add_cancel_of_le (by linarith), add_mul,
pow_add, pow_mul _ k, hζ.1, one_pow, mul_one, pow_mul, e, ← map_pow, mul_comm, pow_mul]
exact H _
have h₁ := sum_mem (t := Finset.range k) fun j _ ↦ this j
have h₂ := geom_sum_mul (ζ ^ (q + k - i)) k
rw [pow_right_comm, hζ.1, one_pow, sub_self, mul_eq_zero, sub_eq_zero] at h₂
rcases h₂ with h₂ | h₂
· simp [h₂, pow_mul, hk'] at h₁
replace h₂ := congr($h₂ * ζ ^ i)
rw [one_mul, ← pow_add, tsub_add_cancel_of_le (by linarith), pow_add, hζ.1, mul_one] at h₂
rw [h₂, e]
/-- A Frobenius element at `Q` restricts to an automorphism of `S_Q`. -/
noncomputable
def localize [Q.IsPrime] : Localization.AtPrime Q →ₐ[R] Localization.AtPrime Q where
toRingHom := Localization.localRingHom _ _ φ H.comap_eq.symm
commutes' x := by
simp [IsScalarTower.algebraMap_apply R S (Localization.AtPrime Q),
Localization.localRingHom_to_map]
@[simp]
lemma localize_algebraMap [Q.IsPrime] (x : S) :
H.localize (algebraMap _ _ x) = algebraMap _ _ (φ x) :=
Localization.localRingHom_to_map _ _ _ H.comap_eq.symm _
open IsLocalRing nonZeroDivisors
lemma isArithFrobAt_localize [Q.IsPrime] : H.localize.IsArithFrobAt (maximalIdeal _) := by
have h : Nat.card (R ⧸ (maximalIdeal _).comap (algebraMap R (Localization.AtPrime Q))) =
Nat.card (R ⧸ Q.under R) := by
congr 2
rw [IsScalarTower.algebraMap_eq R S (Localization.AtPrime Q), ← Ideal.comap_comap,
Localization.AtPrime.comap_maximalIdeal]
intro x
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq Q.primeCompl x
simp only [localize, coe_mk, Localization.localRingHom_mk', RingHom.coe_coe, h,
← IsLocalization.mk'_pow]
rw [← IsLocalization.mk'_sub,
IsLocalization.AtPrime.mk'_mem_maximal_iff (Localization.AtPrime Q) Q]
simp only [SubmonoidClass.coe_pow, ← Ideal.Quotient.eq_zero_iff_mem]
simp [H.mk_apply]
/-- Suppose `S` is Noetherian and `Q` is a prime of `S` containing all zero divisors.
If `S/R` is unramified at `Q`, then the Frobenius `φ : S →ₐ[R] S` over `Q` is unique. -/
lemma eq_of_isUnramifiedAt
(H' : ψ.IsArithFrobAt Q) [Q.IsPrime] (hQ : Q.primeCompl ≤ S⁰)
[Algebra.IsUnramifiedAt R Q] [IsNoetherianRing S] : φ = ψ := by
have : H.localize = H'.localize := by
have : IsNoetherianRing (Localization.AtPrime Q) :=
IsLocalization.isNoetherianRing Q.primeCompl _ inferInstance
apply Algebra.FormallyUnramified.ext_of_iInf _
(Ideal.iInf_pow_eq_bot_of_isLocalRing (maximalIdeal _) Ideal.IsPrime.ne_top')
intro x
rw [H.isArithFrobAt_localize.mk_apply, H'.isArithFrobAt_localize.mk_apply]
ext x
apply IsLocalization.injective (Localization.AtPrime Q) hQ
rw [← H.localize_algebraMap, ← H'.localize_algebraMap, this]
end AlgHom.IsArithFrobAt
variable (R) in
/--
Suppose `S` is an `R` algebra, `M` is a monoid acting on `S` whose action is trivial on `R`
`σ : M` is an (arithmetic) Frobenius at an ideal `Q` of `S` if `σ • x ≡ x ^ q (mod Q)` for all `x`.
-/
abbrev IsArithFrobAt {M : Type*} [Monoid M] [MulSemiringAction M S] [SMulCommClass M R S]
(σ : M) (Q : Ideal S) : Prop :=
(MulSemiringAction.toAlgHom R S σ).IsArithFrobAt Q
namespace IsArithFrobAt
open scoped Pointwise
variable {G : Type*} [Group G] [MulSemiringAction G S] [SMulCommClass G R S]
variable {Q : Ideal S} {σ σ' : G}
lemma mul_inv_mem_inertia (H : IsArithFrobAt R σ Q) (H' : IsArithFrobAt R σ' Q) :
σ * σ'⁻¹ ∈ Q.toAddSubgroup.inertia G := by
intro x
simpa [mul_smul] using sub_mem (H (σ'⁻¹ • x)) (H' (σ'⁻¹ • x))
lemma conj (H : IsArithFrobAt R σ Q) (τ : G) : IsArithFrobAt R (τ * σ * τ⁻¹) (τ • Q) := by
intro x
have : (Q.map (MulSemiringAction.toRingEquiv G S τ)).under R = Q.under R := by
rw [← Ideal.comap_symm, ← Ideal.comap_coe, Ideal.under, Ideal.comap_comap]
congr 1
exact (MulSemiringAction.toAlgEquiv R S τ).symm.toAlgHom.comp_algebraMap
rw [Ideal.pointwise_smul_eq_comap, Ideal.mem_comap]
simpa [smul_sub, mul_smul, this] using H (τ⁻¹ • x)
variable [Finite G] [Algebra.IsInvariant R S G]
variable (R G Q) in
attribute [local instance] Ideal.Quotient.field in
/-- Let `G` be a finite group acting on `S`, and `R` be the fixed subring.
If `Q` is a prime of `S` with finite residue field,
then there exists a Frobenius element `σ : G` at `Q`. -/
lemma exists_of_isInvariant [Q.IsPrime] [Finite (S ⧸ Q)] : ∃ σ : G, IsArithFrobAt R σ Q := by
let P := Q.under R
have := Algebra.IsInvariant.isIntegral R S G
have : Q.IsMaximal := Ideal.Quotient.maximal_of_isField _ (Finite.isField_of_domain (S ⧸ Q))
have : P.IsMaximal := Ideal.isMaximal_comap_of_isIntegral_of_isMaximal Q
obtain ⟨p, hc⟩ := CharP.exists (R ⧸ P)
have : Finite (R ⧸ P) := .of_injective _ Ideal.algebraMap_quotient_injective
cases nonempty_fintype (R ⧸ P)
obtain ⟨k, hp, hk⟩ := FiniteField.card (R ⧸ P) p
have := CharP.of_ringHom_of_ne_zero (algebraMap (R ⧸ P) (S ⧸ Q)) p hp.ne_zero
have : ExpChar (S ⧸ Q) p := .prime hp
let l : (S ⧸ Q) ≃ₐ[R ⧸ P] S ⧸ Q :=
{ __ := iterateFrobeniusEquiv (S ⧸ Q) p k,
commutes' r := by
dsimp [iterateFrobenius_def]
rw [← map_pow, ← hk, FiniteField.pow_card] }
obtain ⟨σ, hσ⟩ := Ideal.Quotient.stabilizerHom_surjective G P Q l
refine ⟨σ, fun x ↦ ?_⟩
rw [← Ideal.Quotient.eq, Nat.card_eq_fintype_card, hk]
exact DFunLike.congr_fun hσ (Ideal.Quotient.mk Q x)
variable (S G) in
lemma exists_primesOver_isConj (P : Ideal R)
(hP : ∃ Q : Ideal.primesOver P S, Finite (S ⧸ Q.1)) :
∃ σ : Ideal.primesOver P S → G, (∀ Q, IsArithFrobAt R (σ Q) Q.1) ∧
(∀ Q₁ Q₂, IsConj (σ Q₁) (σ Q₂)) := by
obtain ⟨⟨Q, hQ₁, hQ₂⟩, hQ₃⟩ := hP
have (Q' : Ideal.primesOver P S) : ∃ σ : G, Q'.1 = σ • Q :=
Algebra.IsInvariant.exists_smul_of_under_eq R S G _ _ (hQ₂.over.symm.trans Q'.2.2.over)
choose τ hτ using this
obtain ⟨σ, hσ⟩ := exists_of_isInvariant R G Q
refine ⟨fun Q' ↦ τ Q' * σ * (τ Q')⁻¹, fun Q' ↦ hτ Q' ▸ hσ.conj (τ Q'), fun Q₁ Q₂ ↦
.trans (.symm (isConj_iff.mpr ⟨τ Q₁, rfl⟩)) (isConj_iff.mpr ⟨τ Q₂, rfl⟩)⟩
variable (R G Q)
/-- Let `G` be a finite group acting on `S`, `R` be the fixed subring, and `Q` be a prime of `S`
with finite residue field. This is an arbitrary choice of a Frobenius over `Q`. It is chosen so that
the Frobenius elements of `Q₁` and `Q₂` are conjugate if they lie over the same prime. -/
noncomputable
def _root_.arithFrobAt [Q.IsPrime] [Finite (S ⧸ Q)] : G :=
(exists_primesOver_isConj S G (Q.under R)
⟨⟨Q, ‹_›, ⟨rfl⟩⟩, ‹Finite (S ⧸ Q)›⟩).choose ⟨Q, ‹_›, ⟨rfl⟩⟩
protected lemma arithFrobAt [Q.IsPrime] [Finite (S ⧸ Q)] : IsArithFrobAt R (arithFrobAt R G Q) Q :=
(exists_primesOver_isConj S G (Q.under R)
⟨⟨Q, ‹_›, ⟨rfl⟩⟩, ‹Finite (S ⧸ Q)›⟩).choose_spec.1 ⟨Q, ‹_›, ⟨rfl⟩⟩
lemma _root_.isConj_arithFrobAt
[Q.IsPrime] [Finite (S ⧸ Q)] (Q' : Ideal S) [Q'.IsPrime] [Finite (S ⧸ Q')]
(H : Q.under R = Q'.under R) : IsConj (arithFrobAt R G Q) (arithFrobAt R G Q') := by
obtain ⟨P, hP, h₁, h₂⟩ : ∃ P : Ideal R, P.IsPrime ∧ P = Q.under R ∧ P = Q'.under R :=
⟨Q.under R, inferInstance, rfl, H⟩
convert (exists_primesOver_isConj S G P
⟨⟨Q, ‹_›, ⟨h₁⟩⟩, ‹Finite (S ⧸ Q)›⟩).choose_spec.2 ⟨Q, ‹_›, ⟨h₁⟩⟩ ⟨Q', ‹_›, ⟨h₂⟩⟩
· subst h₁; rfl
· subst h₂; rfl
end IsArithFrobAt |
.lake/packages/mathlib/Mathlib/RingTheory/Bezout.lean | import Mathlib.RingTheory.PrincipalIdealDomain
/-!
# Bézout rings
A Bézout ring (Bezout ring) is a ring whose finitely generated ideals are principal.
Notable examples include principal ideal rings, valuation rings, and the ring of algebraic integers.
## Main results
- `IsBezout.iff_span_pair_isPrincipal`: It suffices to verify every `span {x, y}` is principal.
- `IsBezout.TFAE`: For a Bézout domain, Noetherian ↔ PID ↔ UFD ↔ ACCP
-/
universe u v
variable {R : Type u} [CommRing R]
namespace IsBezout
theorem iff_span_pair_isPrincipal :
IsBezout R ↔ ∀ x y : R, (Ideal.span {x, y} : Ideal R).IsPrincipal := by
classical
constructor
· intro H x y; infer_instance
· intro H
constructor
apply Submodule.fg_induction
· exact fun _ => ⟨⟨_, rfl⟩⟩
· rintro _ _ ⟨⟨x, rfl⟩⟩ ⟨⟨y, rfl⟩⟩; rw [← Submodule.span_insert]; exact H _ _
theorem _root_.Function.Surjective.isBezout {S : Type v} [CommRing S] (f : R →+* S)
(hf : Function.Surjective f) [IsBezout R] : IsBezout S := by
rw [iff_span_pair_isPrincipal]
intro x y
obtain ⟨⟨x, rfl⟩, ⟨y, rfl⟩⟩ := hf x, hf y
use f (gcd x y)
trans Ideal.map f (Ideal.span {gcd x y})
· rw [span_gcd, Ideal.map_span, Set.image_insert_eq, Set.image_singleton]
· rw [Ideal.map_span, Set.image_singleton]; rfl
theorem TFAE [IsBezout R] [IsDomain R] :
List.TFAE
[IsNoetherianRing R, IsPrincipalIdealRing R, UniqueFactorizationMonoid R, WfDvdMonoid R] := by
classical
tfae_have 1 → 2
| _ => inferInstance
tfae_have 2 → 3
| _ => inferInstance
tfae_have 3 → 4
| _ => inferInstance
tfae_have 4 → 1
| ⟨h⟩ => by
rw [isNoetherianRing_iff, isNoetherian_iff_fg_wellFounded]
refine ⟨RelEmbedding.wellFounded ?_ h⟩
have : ∀ I : { J : Ideal R // J.FG }, ∃ x : R, (I : Ideal R) = Ideal.span {x} :=
fun ⟨I, hI⟩ => (IsBezout.isPrincipal_of_FG I hI).1
choose f hf using this
exact
{ toFun := f
inj' := fun x y e => by ext1; rw [hf, hf, e]
map_rel_iff' := by
dsimp
intro a b
rw [← Ideal.span_singleton_lt_span_singleton, ← hf, ← hf]
rfl }
tfae_finish
end IsBezout |
.lake/packages/mathlib/Mathlib/RingTheory/CotangentLocalizationAway.lean | import Mathlib.RingTheory.Extension.Cotangent.LocalizationAway
deprecated_module (since := "2025-05-11") |
.lake/packages/mathlib/Mathlib/RingTheory/NormTrace.lean | import Mathlib.RingTheory.Norm.Defs
import Mathlib.RingTheory.Trace.Defs
/-!
# Relation between norms and traces
-/
open Module
lemma Algebra.norm_one_add_smul {A B} [CommRing A] [CommRing B] [Algebra A B]
[Module.Free A B] [Module.Finite A B] (a : A) (x : B) :
∃ r : A, Algebra.norm A (1 + a • x) = 1 + Algebra.trace A B x * a + r * a ^ 2 := by
classical
let ι := Module.Free.ChooseBasisIndex A B
let b : Basis ι A B := Module.Free.chooseBasis _ _
haveI : Fintype ι := inferInstance
clear_value ι b
simp_rw [Algebra.norm_eq_matrix_det b, Algebra.trace_eq_matrix_trace b]
simp only [map_add, map_one, map_smul, Matrix.det_one_add_smul a]
exact ⟨_, rfl⟩ |
.lake/packages/mathlib/Mathlib/RingTheory/PolynomialAlgebra.lean | import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.RingTheory.IsTensorProduct
/-!
# Base change of polynomial algebras
Given `[CommSemiring R] [Semiring A] [Algebra R A]` we show `A[X] ≃ₐ[R] (A ⊗[R] R[X])`.
-/
-- This file should not become entangled with `RingTheory/MatrixAlgebra`.
assert_not_exists Matrix
universe u v w
open Polynomial TensorProduct
open Algebra.TensorProduct (algHomOfLinearMapTensorProduct includeLeft)
noncomputable section
variable (R A : Type*)
variable [CommSemiring R]
variable [Semiring A] [Algebra R A]
namespace PolyEquivTensor
/-- (Implementation detail).
The function underlying `A ⊗[R] R[X] →ₐ[R] A[X]`,
as a bilinear function of two arguments.
-/
def toFunBilinear : A →ₗ[A] R[X] →ₗ[R] A[X] :=
LinearMap.toSpanSingleton A _ (aeval (Polynomial.X : A[X])).toLinearMap
theorem toFunBilinear_apply_apply (a : A) (p : R[X]) :
toFunBilinear R A a p = a • (aeval X) p := rfl
@[simp] theorem toFunBilinear_apply_eq_smul (a : A) (p : R[X]) :
toFunBilinear R A a p = a • p.map (algebraMap R A) := rfl
theorem toFunBilinear_apply_eq_sum (a : A) (p : R[X]) :
toFunBilinear R A a p = p.sum fun n r ↦ monomial n (a * algebraMap R A r) := by
conv_lhs => rw [toFunBilinear_apply_eq_smul, ← p.sum_monomial_eq, sum, Polynomial.map_sum]
simp [Finset.smul_sum, sum, ← smul_eq_mul]
/-- (Implementation detail).
The function underlying `A ⊗[R] R[X] →ₐ[R] A[X]`,
as a linear map.
-/
def toFunLinear : A ⊗[R] R[X] →ₗ[R] A[X] :=
TensorProduct.lift (toFunBilinear R A)
@[simp]
theorem toFunLinear_tmul_apply (a : A) (p : R[X]) :
toFunLinear R A (a ⊗ₜ[R] p) = toFunBilinear R A a p :=
rfl
-- We apparently need to provide the decidable instance here
-- in order to successfully rewrite by this lemma.
theorem toFunLinear_mul_tmul_mul_aux_1 (p : R[X]) (k : ℕ) (h : Decidable ¬p.coeff k = 0) (a : A) :
ite (¬coeff p k = 0) (a * (algebraMap R A) (coeff p k)) 0 =
a * (algebraMap R A) (coeff p k) := by classical split_ifs <;> simp [*]
theorem toFunLinear_mul_tmul_mul_aux_2 (k : ℕ) (a₁ a₂ : A) (p₁ p₂ : R[X]) :
a₁ * a₂ * (algebraMap R A) ((p₁ * p₂).coeff k) =
(Finset.antidiagonal k).sum fun x =>
a₁ * (algebraMap R A) (coeff p₁ x.1) * (a₂ * (algebraMap R A) (coeff p₂ x.2)) := by
simp_rw [mul_assoc, Algebra.commutes, ← Finset.mul_sum, mul_assoc, ← Finset.mul_sum]
congr
simp_rw [Algebra.commutes (coeff p₂ _), coeff_mul, map_sum, RingHom.map_mul]
theorem toFunLinear_mul_tmul_mul (a₁ a₂ : A) (p₁ p₂ : R[X]) :
(toFunLinear R A) ((a₁ * a₂) ⊗ₜ[R] (p₁ * p₂)) =
(toFunLinear R A) (a₁ ⊗ₜ[R] p₁) * (toFunLinear R A) (a₂ ⊗ₜ[R] p₂) := by
classical
simp only [toFunLinear_tmul_apply, toFunBilinear_apply_eq_sum]
ext k
simp_rw [coeff_sum, coeff_monomial, sum_def, Finset.sum_ite_eq', mem_support_iff, Ne]
conv_rhs => rw [coeff_mul]
simp_rw [finset_sum_coeff, coeff_monomial, Finset.sum_ite_eq', mem_support_iff, Ne, mul_ite,
mul_zero, ite_mul, zero_mul]
simp_rw [← ite_zero_mul (¬coeff p₁ _ = 0) (a₁ * (algebraMap R A) (coeff p₁ _))]
simp_rw [← mul_ite_zero (¬coeff p₂ _ = 0) _ (_ * _)]
simp_rw [toFunLinear_mul_tmul_mul_aux_1, toFunLinear_mul_tmul_mul_aux_2]
theorem toFunLinear_one_tmul_one :
toFunLinear R A (1 ⊗ₜ[R] 1) = 1 := by
rw [toFunLinear_tmul_apply, toFunBilinear_apply_apply, Polynomial.aeval_one, one_smul]
/-- (Implementation detail).
The algebra homomorphism `A ⊗[R] R[X] →ₐ[R] A[X]`.
-/
def toFunAlgHom : A ⊗[R] R[X] →ₐ[R] A[X] :=
algHomOfLinearMapTensorProduct (toFunLinear R A) (toFunLinear_mul_tmul_mul R A)
(toFunLinear_one_tmul_one R A)
@[simp] theorem toFunAlgHom_apply_tmul_eq_smul (a : A) (p : R[X]) :
toFunAlgHom R A (a ⊗ₜ[R] p) = a • p.map (algebraMap R A) := rfl
theorem toFunAlgHom_apply_tmul (a : A) (p : R[X]) :
toFunAlgHom R A (a ⊗ₜ[R] p) = p.sum fun n r => monomial n (a * (algebraMap R A) r) :=
toFunBilinear_apply_eq_sum R A _ _
/-- (Implementation detail.)
The bare function `A[X] → A ⊗[R] R[X]`.
(We don't need to show that it's an algebra map, thankfully --- just that it's an inverse.)
-/
def invFun (p : A[X]) : A ⊗[R] R[X] :=
p.eval₂ (includeLeft : A →ₐ[R] A ⊗[R] R[X]) ((1 : A) ⊗ₜ[R] (X : R[X]))
@[simp]
theorem invFun_add {p q} : invFun R A (p + q) = invFun R A p + invFun R A q := by
simp only [invFun, eval₂_add]
theorem invFun_monomial (n : ℕ) (a : A) :
invFun R A (monomial n a) = (a ⊗ₜ[R] 1) * 1 ⊗ₜ[R] X ^ n :=
eval₂_monomial _ _
theorem left_inv (x : A ⊗ R[X]) : invFun R A ((toFunAlgHom R A) x) = x := by
refine TensorProduct.induction_on x ?_ ?_ ?_
· simp [invFun]
· intro a p
dsimp only [invFun]
rw [toFunAlgHom_apply_tmul, eval₂_sum]
simp_rw [eval₂_monomial, AlgHom.coe_toRingHom, Algebra.TensorProduct.tmul_pow, one_pow,
Algebra.TensorProduct.includeLeft_apply, Algebra.TensorProduct.tmul_mul_tmul, mul_one,
one_mul, ← Algebra.commutes, ← Algebra.smul_def, smul_tmul, sum_def, ← tmul_sum]
conv_rhs => rw [← sum_C_mul_X_pow_eq p]
simp only [Algebra.smul_def]
rfl
· intro p q hp hq
simp only [map_add, invFun_add, hp, hq]
theorem right_inv (x : A[X]) : (toFunAlgHom R A) (invFun R A x) = x := by
refine Polynomial.induction_on' x ?_ ?_
· intro p q hp hq
simp only [invFun_add, map_add, hp, hq]
· intro n a
rw [invFun_monomial, Algebra.TensorProduct.tmul_pow,
one_pow, Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul, toFunAlgHom_apply_tmul,
X_pow_eq_monomial, sum_monomial_index] <;>
simp
/-- (Implementation detail)
The equivalence, ignoring the algebra structure, `(A ⊗[R] R[X]) ≃ A[X]`.
-/
def equiv : A ⊗[R] R[X] ≃ A[X] where
toFun := toFunAlgHom R A
invFun := invFun R A
left_inv := left_inv R A
right_inv := right_inv R A
end PolyEquivTensor
open PolyEquivTensor
/-- The `R`-algebra isomorphism `A[X] ≃ₐ[R] (A ⊗[R] R[X])`.
-/
def polyEquivTensor : A[X] ≃ₐ[R] A ⊗[R] R[X] :=
AlgEquiv.symm { PolyEquivTensor.toFunAlgHom R A, PolyEquivTensor.equiv R A with }
@[simp]
theorem polyEquivTensor_apply (p : A[X]) :
polyEquivTensor R A p =
p.eval₂ (includeLeft : A →ₐ[R] A ⊗[R] R[X]) ((1 : A) ⊗ₜ[R] (X : R[X])) :=
rfl
@[simp]
theorem polyEquivTensor_symm_apply_tmul_eq_smul (a : A) (p : R[X]) :
(polyEquivTensor R A).symm (a ⊗ₜ p) = a • p.map (algebraMap R A) := rfl
theorem polyEquivTensor_symm_apply_tmul (a : A) (p : R[X]) :
(polyEquivTensor R A).symm (a ⊗ₜ p) = p.sum fun n r => monomial n (a * algebraMap R A r) :=
toFunAlgHom_apply_tmul _ _ _ _
section
variable (A : Type*) [CommSemiring A] [Algebra R A]
/-- The `A`-algebra isomorphism `A[X] ≃ₐ[A] A ⊗[R] R[X]` (when `A` is commutative). -/
def polyEquivTensor' : A[X] ≃ₐ[A] A ⊗[R] R[X] where
__ := polyEquivTensor R A
commutes' a := by simp
/-- `polyEquivTensor' R A` is the same as `polyEquivTensor R A` as a function. -/
@[simp] theorem coe_polyEquivTensor' : ⇑(polyEquivTensor' R A) = polyEquivTensor R A := rfl
@[simp] theorem coe_polyEquivTensor'_symm :
⇑(polyEquivTensor' R A).symm = (polyEquivTensor R A).symm := rfl
end
/-- If `A` is an `R`-algebra, then `A[X]` is an `R[X]` algebra.
This gives a diamond for `Algebra R[X] R[X][X]`, so this is not a global instance. -/
@[reducible] def Polynomial.algebra : Algebra R[X] A[X] :=
(mapRingHom (algebraMap R A)).toAlgebra' fun _ _ ↦ by
ext; rw [coeff_mul, ← Finset.Nat.sum_antidiagonal_swap, coeff_mul]; simp [Algebra.commutes]
attribute [local instance] Polynomial.algebra
@[simp]
theorem Polynomial.algebraMap_def : algebraMap R[X] A[X] = mapRingHom (algebraMap R A) := rfl
instance : IsScalarTower R R[X] A[X] := .of_algebraMap_eq' (mapRingHom_comp_C _).symm
instance [FaithfulSMul R A] : FaithfulSMul R[X] A[X] :=
(faithfulSMul_iff_algebraMap_injective ..).mpr
(map_injective _ <| FaithfulSMul.algebraMap_injective ..)
variable {S : Type*} [CommSemiring S] [Algebra R S]
instance : Algebra.IsPushout R S R[X] S[X] where
out := .of_equiv (polyEquivTensor' R S).symm fun _ ↦
(polyEquivTensor_symm_apply_tmul_eq_smul ..).trans <| one_smul ..
instance : Algebra.IsPushout R R[X] S S[X] := .symm inferInstance |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.