source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/GroupTheory/Congruence/BigOperators.lean | import Mathlib.Algebra.BigOperators.Group.Multiset.Basic
import Mathlib.Algebra.BigOperators.Group.List.Lemmas
import Mathlib.GroupTheory.Congruence.Defs
import Mathlib.Algebra.BigOperators.Group.Finset.Defs
/-!
# Interactions between `∑, ∏` and `(Add)Con`
-/
namespace Con
/-- Multiplicative congruence relations preserve product indexed by a list. -/
@[to_additive /-- Additive congruence relations preserve sum indexed by a list. -/]
protected theorem list_prod {ι M : Type*} [MulOneClass M] (c : Con M) {l : List ι} {f g : ι → M}
(h : ∀ x ∈ l, c (f x) (g x)) :
c (l.map f).prod (l.map g).prod := by
induction l with
| nil =>
simpa only [List.map_nil, List.prod_nil] using c.refl 1
| cons x xs ih =>
rw [List.map_cons, List.map_cons, List.prod_cons, List.prod_cons]
exact c.mul (h _ <| .head _) <| ih fun k hk ↦ h _ (.tail _ hk)
/-- Multiplicative congruence relations preserve product indexed by a multiset. -/
@[to_additive /-- Additive congruence relations preserve sum indexed by a multiset. -/]
protected theorem multiset_prod {ι M : Type*} [CommMonoid M] (c : Con M) {s : Multiset ι}
{f g : ι → M} (h : ∀ x ∈ s, c (f x) (g x)) :
c (s.map f).prod (s.map g).prod := by
rcases s; simpa using c.list_prod h
/-- Multiplicative congruence relations preserve finite product. -/
@[to_additive /-- Additive congruence relations preserve finite sum. -/]
protected theorem finset_prod {ι M : Type*} [CommMonoid M] (c : Con M) (s : Finset ι)
{f g : ι → M} (h : ∀ i ∈ s, c (f i) (g i)) :
c (s.prod f) (s.prod g) :=
c.multiset_prod h
end Con |
.lake/packages/mathlib/Mathlib/GroupTheory/Congruence/Hom.lean | import Mathlib.Algebra.Group.Hom.Defs
import Mathlib.GroupTheory.Congruence.Defs
/-!
# Congruence relations and homomorphisms
This file contains elementary definitions involving congruence relations and morphisms.
## Main definitions
* `Con.ker`: the kernel of a monoid homomorphism as a congruence relation
* `Con.mk'`: the map from a monoid to its quotient by a congruence relation
* `Con.lift`: the homomorphism on the quotient given that the congruence is in the kernel
* `Con.map`: homomorphism from a smaller to a larger quotient
## Tags
congruence, congruence relation, quotient, quotient by congruence relation, monoid,
quotient monoid
-/
variable (M : Type*) {N : Type*} {P : Type*}
open Function Setoid
variable {M}
namespace Con
section Mul
variable {F} [Mul M] [Mul N] [Mul P] [FunLike F M N] [MulHomClass F M N]
/-- The natural homomorphism from a magma to its quotient by a congruence relation. -/
@[to_additive (attr := simps) /-- The natural homomorphism from an additive magma to its quotient by
an additive congruence relation. -/]
def mkMulHom (c : Con M) : MulHom M c.Quotient where
toFun := (↑)
map_mul' _ _ := rfl
/-- The kernel of a multiplicative homomorphism as a congruence relation. -/
@[to_additive /-- The kernel of an additive homomorphism as an additive congruence relation. -/]
def ker (f : F) : Con M where
toSetoid := Setoid.ker f
mul' h1 h2 := by
dsimp [Setoid.ker, onFun] at *
rw [map_mul, h1, h2, map_mul]
@[to_additive (attr := norm_cast)]
theorem ker_coeMulHom (f : F) : ker (f : MulHom M N) = ker f := rfl
/-- The definition of the congruence relation defined by a monoid homomorphism's kernel. -/
@[to_additive (attr := simp) /-- The definition of the additive congruence relation defined by an
`AddMonoid` homomorphism's kernel. -/]
theorem ker_rel (f : F) {x y} : ker f x y ↔ f x = f y :=
Iff.rfl
@[to_additive (attr := simp) /-- The kernel of the quotient map induced by an additive congruence
relation `c` equals `c`. -/]
theorem ker_mkMulHom_eq (c : Con M) : ker (mkMulHom c) = c :=
ext fun _ _ => Quotient.eq''
/-- Given a function `f`, the smallest congruence relation containing the binary relation on `f`'s
image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)`
by a congruence relation `c`.' -/
@[to_additive /-- Given a function `f`, the smallest additive congruence relation containing the
binary relation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the
elements of `f⁻¹(y)` by an additive congruence relation `c`.' -/]
def mapGen {c : Con M} (f : M → N) : Con N :=
conGen <| Relation.Map c f f
/-- Given a surjective multiplicative-preserving function `f` whose kernel is contained in a
congruence relation `c`, the congruence relation on `f`'s codomain defined by '`x ≈ y` iff the
elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.' -/
@[to_additive /-- Given a surjective addition-preserving function `f` whose kernel is contained in
an additive congruence relation `c`, the additive congruence relation on `f`'s codomain defined
by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.' -/]
def mapOfSurjective {c : Con M} (f : F) (h : ker f ≤ c) (hf : Surjective f) : Con N where
__ := c.toSetoid.mapOfSurjective f h hf
mul' h₁ h₂ := by
rcases h₁ with ⟨a, b, h1, rfl, rfl⟩
rcases h₂ with ⟨p, q, h2, rfl, rfl⟩
exact ⟨a * p, b * q, c.mul h1 h2, map_mul f _ _, map_mul f _ _⟩
/-- A specialization of 'the smallest congruence relation containing a congruence relation `c`
equals `c`'. -/
@[to_additive /-- A specialization of 'the smallest additive congruence relation containing
an additive congruence relation `c` equals `c`'. -/]
theorem mapOfSurjective_eq_mapGen {c : Con M} {f : F} (h : ker f ≤ c) (hf : Surjective f) :
c.mapGen f = c.mapOfSurjective f h hf := by
rw [← conGen_of_con (c.mapOfSurjective f h hf)]; rfl
/-- Given a congruence relation `c` on a type `M` with a multiplication, the order-preserving
bijection between the set of congruence relations containing `c` and the congruence relations
on the quotient of `M` by `c`. -/
@[to_additive /-- Given an additive congruence relation `c` on a type `M` with an addition,
the order-preserving bijection between the set of additive congruence relations containing `c` and
the additive congruence relations on the quotient of `M` by `c`. -/]
def correspondence {c : Con M} : { d // c ≤ d } ≃o Con c.Quotient where
toFun d :=
d.1.mapOfSurjective (mkMulHom c) (by rw [Con.ker_mkMulHom_eq]; exact d.2) <|
Quotient.mk_surjective
invFun d :=
⟨comap ((↑) : M → c.Quotient) (fun _ _ => rfl) d, fun x y h =>
show d x y by rw [c.eq.2 h]; exact d.refl _⟩
left_inv d :=
Subtype.ext_iff.2 <|
ext fun x y =>
⟨fun ⟨a, b, H, hx, hy⟩ =>
d.1.trans (d.1.symm <| d.2 <| c.eq.1 hx) <| d.1.trans H <| d.2 <| c.eq.1 hy,
fun h => ⟨_, _, h, rfl, rfl⟩⟩
right_inv d :=
ext fun x y =>
⟨fun ⟨_, _, H, hx, hy⟩ =>
hx ▸ hy ▸ H,
Con.induction_on₂ x y fun w z h => ⟨w, z, h, rfl, rfl⟩⟩
map_rel_iff' {s t} := by
constructor
· intro h x y hs
rcases h ⟨x, y, hs, rfl, rfl⟩ with ⟨a, b, ht, hx, hy⟩
exact t.1.trans (t.1.symm <| t.2 <| c.eq.1 hx) (t.1.trans ht (t.2 <| c.eq.1 hy))
· exact Relation.map_mono
end Mul
section MulOneClass
variable [MulOneClass M] [MulOneClass N] [MulOneClass P] {c : Con M}
variable (c)
/-- The natural homomorphism from a monoid to its quotient by a congruence relation. -/
@[to_additive /-- The natural homomorphism from an `AddMonoid` to its quotient by an additive
congruence relation. -/]
def mk' : M →* c.Quotient where
__ := mkMulHom c
map_one' := rfl
variable (x y : M)
/-- The kernel of the natural homomorphism from a monoid to its quotient by a congruence
relation `c` equals `c`. -/
@[to_additive (attr := simp) /-- The kernel of the natural homomorphism from an `AddMonoid` to its
quotient by an additive congruence relation `c` equals `c`. -/]
theorem mk'_ker : ker c.mk' = c :=
ext fun _ _ => c.eq
variable {c}
/-- The natural homomorphism from a monoid to its quotient by a congruence relation is
surjective. -/
@[to_additive /-- The natural homomorphism from an `AddMonoid` to its quotient by a congruence
relation is surjective. -/]
theorem mk'_surjective : Surjective c.mk' :=
Quotient.mk''_surjective
@[to_additive (attr := simp)]
theorem coe_mk' : (c.mk' : M → c.Quotient) = ((↑) : M → c.Quotient) :=
rfl
@[to_additive]
theorem ker_apply {f : M →* P} {x y} : ker f x y ↔ f x = f y := Iff.rfl
/-- Given a monoid homomorphism `f : N → M` and a congruence relation `c` on `M`, the congruence
relation induced on `N` by `f` equals the kernel of `c`'s quotient homomorphism composed with
`f`. -/
@[to_additive /-- Given an `AddMonoid` homomorphism `f : N → M` and an additive congruence relation
`c` on `M`, the additive congruence relation induced on `N` by `f` equals the kernel of `c`'s
quotient homomorphism composed with `f`. -/]
theorem comap_eq {f : N →* M} : comap f f.map_mul c = ker (c.mk'.comp f) :=
ext fun x y => show c _ _ ↔ c.mk' _ = c.mk' _ by rw [← c.eq]; rfl
variable (c) (f : M →* P)
/-- The homomorphism on the quotient of a monoid by a congruence relation `c` induced by a
homomorphism constant on `c`'s equivalence classes. -/
@[to_additive /-- The homomorphism on the quotient of an `AddMonoid` by an additive congruence
relation `c` induced by a homomorphism constant on `c`'s equivalence classes. -/]
def lift (H : c ≤ ker f) : c.Quotient →* P where
toFun x := (Con.liftOn x f) fun _ _ h => H h
map_one' := by rw [← f.map_one]; rfl
map_mul' x y := Con.induction_on₂ x y fun m n => by
dsimp only [← coe_mul, Con.liftOn_coe]
rw [map_mul]
variable {c f}
/-- The diagram describing the universal property for quotients of monoids commutes. -/
@[to_additive /-- The diagram describing the universal property for quotients of `AddMonoid`s
commutes. -/]
theorem lift_mk' (H : c ≤ ker f) (x) : c.lift f H (c.mk' x) = f x :=
rfl
/-- The diagram describing the universal property for quotients of monoids commutes. -/
@[to_additive (attr := simp) /-- The diagram describing the universal property for quotients of
`AddMonoid`s commutes. -/]
theorem lift_coe (H : c ≤ ker f) (x : M) : c.lift f H x = f x :=
rfl
/-- The diagram describing the universal property for quotients of monoids commutes. -/
@[to_additive (attr := simp) /-- The diagram describing the universal property for quotients of
`AddMonoid`s commutes. -/]
theorem lift_comp_mk' (H : c ≤ ker f) : (c.lift f H).comp c.mk' = f := by ext; rfl
/-- Given a homomorphism `f` from the quotient of a monoid by a congruence relation, `f` equals the
homomorphism on the quotient induced by `f` composed with the natural map from the monoid to
the quotient. -/
@[to_additive (attr := simp) /-- Given a homomorphism `f` from the quotient of an `AddMonoid` by an
additive congruence relation, `f` equals the homomorphism on the quotient induced by `f` composed
with the natural map from the `AddMonoid` to the quotient. -/]
theorem lift_apply_mk' (f : c.Quotient →* P) :
(c.lift (f.comp c.mk') fun x y h => show f ↑x = f ↑y by rw [c.eq.2 h]) = f := by
ext x; rcases x with ⟨⟩; rfl
/-- Homomorphisms on the quotient of a monoid by a congruence relation `c` are equal if their
compositions with `c.mk'` are equal. -/
@[to_additive (attr := ext) /-- Homomorphisms on the quotient of an `AddMonoid` by an additive
congruence relation `c` are equal if their compositions with `c.mk'` are equal. -/]
lemma hom_ext {f g : c.Quotient →* P} (h : f.comp c.mk' = g.comp c.mk') : f = g := by
rw [← lift_apply_mk' f, ← lift_apply_mk' g]
congr 1
/-- Homomorphisms on the quotient of a monoid by a congruence relation are equal if they
are equal on elements that are coercions from the monoid. -/
@[to_additive /-- Homomorphisms on the quotient of an `AddMonoid` by an additive congruence relation
are equal if they are equal on elements that are coercions from the `AddMonoid`. -/]
theorem lift_funext (f g : c.Quotient →* P) (h : ∀ a : M, f a = g a) : f = g :=
hom_ext <| DFunLike.ext _ _ h
/-- The uniqueness part of the universal property for quotients of monoids. -/
@[to_additive /-- The uniqueness part of the universal property for quotients of `AddMonoid`s. -/]
theorem lift_unique (H : c ≤ ker f) (g : c.Quotient →* P) (Hg : g.comp c.mk' = f) :
g = c.lift f H :=
hom_ext Hg
/-- Surjective monoid homomorphisms constant on a congruence relation `c`'s equivalence classes
induce a surjective homomorphism on `c`'s quotient. -/
@[to_additive /-- Surjective `AddMonoid` homomorphisms constant on an additive congruence
relation `c`'s equivalence classes induce a surjective homomorphism on `c`'s quotient. -/]
theorem lift_surjective_of_surjective (h : c ≤ ker f) (hf : Surjective f) :
Surjective (c.lift f h) := fun y =>
(Exists.elim (hf y)) fun w hw => ⟨w, (lift_mk' h w).symm ▸ hw⟩
variable (c f)
/-- Given a monoid homomorphism `f` from `M` to `P`, the kernel of `f` is the unique congruence
relation on `M` whose induced map from the quotient of `M` to `P` is injective. -/
@[to_additive /-- Given an `AddMonoid` homomorphism `f` from `M` to `P`, the kernel of `f`
is the unique additive congruence relation on `M` whose induced map from the quotient of `M`
to `P` is injective. -/]
theorem ker_eq_lift_of_injective (H : c ≤ ker f) (h : Injective (c.lift f H)) : ker f = c :=
toSetoid_inj <| Setoid.ker_eq_lift_of_injective f H h
variable {c}
/-- The homomorphism induced on the quotient of a monoid by the kernel of a monoid homomorphism. -/
@[to_additive /-- The homomorphism induced on the quotient of an `AddMonoid` by the kernel
of an `AddMonoid` homomorphism. -/]
def kerLift : (ker f).Quotient →* P :=
((ker f).lift f) fun _ _ => id
variable {f}
/-- The diagram described by the universal property for quotients of monoids, when the congruence
relation is the kernel of the homomorphism, commutes. -/
@[to_additive (attr := simp) /-- The diagram described by the universal property for quotients
of `AddMonoid`s, when the additive congruence relation is the kernel of the homomorphism,
commutes. -/]
theorem kerLift_mk (x : M) : kerLift f x = f x :=
rfl
/-- A monoid homomorphism `f` induces an injective homomorphism on the quotient by `f`'s kernel. -/
@[to_additive /-- An `AddMonoid` homomorphism `f` induces an injective homomorphism on the quotient
by `f`'s kernel. -/]
theorem kerLift_injective (f : M →* P) : Injective (kerLift f) := fun x y =>
Quotient.inductionOn₂' x y fun _ _ => (ker f).eq.2
/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, `d`'s quotient
map induces a homomorphism from the quotient by `c` to the quotient by `d`. -/
@[to_additive /-- Given additive congruence relations `c, d` on an `AddMonoid` such that `d`
contains `c`, `d`'s quotient map induces a homomorphism from the quotient by `c` to the quotient
by `d`. -/]
def map (c d : Con M) (h : c ≤ d) : c.Quotient →* d.Quotient :=
(c.lift d.mk') fun x y hc => show (ker d.mk') x y from (mk'_ker d).symm ▸ h hc
/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, the definition of
the homomorphism from the quotient by `c` to the quotient by `d` induced by `d`'s quotient map. -/
@[to_additive /-- Given additive congruence relations `c, d` on an `AddMonoid` such that `d`
contains `c`, the definition of the homomorphism from the quotient by `c` to the quotient by `d`
induced by `d`'s quotient map. -/]
theorem map_apply {c d : Con M} (h : c ≤ d) (x) :
c.map d h x = c.lift d.mk' (fun _ _ hc => d.eq.2 <| h hc) x :=
rfl
end MulOneClass
end Con |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/Alternating.lean | import Mathlib.Algebra.Ring.CharZero
import Mathlib.Data.Fintype.Units
import Mathlib.GroupTheory.IndexNormal
import Mathlib.GroupTheory.Perm.Fin
import Mathlib.GroupTheory.Subgroup.Simple
import Mathlib.Logic.Equiv.Fin.Rotate
import Mathlib.Tactic.IntervalCases
/-!
# Alternating Groups
The alternating group on a finite type `α` is the subgroup of the permutation group `Perm α`
consisting of the even permutations.
## Main definitions
* `alternatingGroup α` is the alternating group on `α`, defined as a `Subgroup (Perm α)`.
## Main results
* `alternatingGroup.index_eq_two` shows that the index of the alternating group is two.
* `two_mul_card_alternatingGroup` shows that the alternating group is half as large as
the permutation group it is a subgroup of.
* `closure_three_cycles_eq_alternating` shows that the alternating group is
generated by 3-cycles.
* `alternatingGroup.isSimpleGroup_five` shows that the alternating group on `Fin 5` is simple.
The proof shows that the normal closure of any non-identity element of this group contains a
3-cycle.
* `Equiv.Perm.eq_alternatingGroup_of_index_eq_two` shows that a subgroup of index 2
of `Equiv.Perm α` is the alternating group.
* `Equiv.Perm.alternatingGroup_le_of_index_le_two` shows that a subgroup of index at most 2
of `Equiv.Perm α` contains the alternating group.
* `Equiv.Perm.alternatingGroup.center_eq_bot`: when `4 ≤ Nat.card α`,
then center of `alternatingGroup α` is trivial.
## Instances
* The alternating group is a characteristic subgroup of the permutation group.
## Tags
alternating group permutation simple characteristic index
## TODO
* Show that `alternatingGroup α` is simple if and only if `Fintype.card α ≠ 4`.
-/
-- An example on how to determine the order of an element of a finite group.
example : orderOf (-1 : ℤˣ) = 2 :=
orderOf_eq_prime (Int.units_sq _) (by decide)
open Equiv Equiv.Perm Subgroup Fintype
variable (α : Type*) [Fintype α] [DecidableEq α]
/-- The alternating group on a finite type, realized as a subgroup of `Equiv.Perm`.
For $A_n$, use `alternatingGroup (Fin n)`. -/
def alternatingGroup : Subgroup (Perm α) :=
sign.ker
instance alternatingGroup.instFintype : Fintype (alternatingGroup α) :=
@Subtype.fintype _ _ sign.decidableMemKer _
instance [Subsingleton α] : Unique (alternatingGroup α) :=
⟨⟨1⟩, fun ⟨p, _⟩ => Subtype.eq (Subsingleton.elim p _)⟩
variable {α}
theorem alternatingGroup_eq_sign_ker : alternatingGroup α = sign.ker :=
rfl
namespace Equiv.Perm
@[simp]
theorem mem_alternatingGroup {f : Perm α} : f ∈ alternatingGroup α ↔ sign f = 1 :=
sign.mem_ker
theorem prod_list_swap_mem_alternatingGroup_iff_even_length {l : List (Perm α)}
(hl : ∀ g ∈ l, IsSwap g) : l.prod ∈ alternatingGroup α ↔ Even l.length := by
rw [mem_alternatingGroup, sign_prod_list_swap hl, neg_one_pow_eq_one_iff_even]
decide
theorem IsThreeCycle.mem_alternatingGroup {f : Perm α} (h : IsThreeCycle f) :
f ∈ alternatingGroup α :=
Perm.mem_alternatingGroup.mpr h.sign
theorem finRotate_bit1_mem_alternatingGroup {n : ℕ} :
finRotate (2 * n + 1) ∈ alternatingGroup (Fin (2 * n + 1)) := by
rw [mem_alternatingGroup, sign_finRotate, pow_mul, pow_two, Int.units_mul_self, one_pow]
end Equiv.Perm
@[simp]
theorem alternatingGroup.index_eq_two [Nontrivial α] :
(alternatingGroup α).index = 2 := by
rw [alternatingGroup, index_ker, MonoidHom.range_eq_top.mpr (sign_surjective α)]
simp_rw [mem_top, Nat.card_eq_fintype_card, card_subtype_true, card_units_int]
@[nontriviality]
theorem alternatingGroup.index_eq_one [Subsingleton α] : (alternatingGroup α).index = 1 := by
rw [Subgroup.index_eq_one]; apply Subsingleton.elim
/-- The group isomorphism between `alternatingGroup`s induced by the given `Equiv`. -/
@[simps ! apply_coe]
def Equiv.altCongrHom {β : Type*} [Fintype β] [DecidableEq β] (e : α ≃ β) :
↥(alternatingGroup α) ≃* ↥(alternatingGroup β) :=
e.permCongrHom.subgroupMap (alternatingGroup α) |>.trans <|
MulEquiv.subgroupCongr <| by simp [Subgroup.ext_iff, Subgroup.map_equiv_eq_comap_symm]
theorem two_mul_nat_card_alternatingGroup [Nontrivial α] :
2 * Nat.card (alternatingGroup α) = Nat.card (Perm α) := by
simp only [← alternatingGroup.index_eq_two (α := α), index_mul_card]
theorem two_mul_card_alternatingGroup [Nontrivial α] :
2 * card (alternatingGroup α) = card (Perm α) := by
simp only [← Nat.card_eq_fintype_card, two_mul_nat_card_alternatingGroup]
theorem card_alternatingGroup [Nontrivial α] :
card (alternatingGroup α) = (card α).factorial / 2 :=
Nat.eq_div_of_mul_eq_right two_ne_zero (two_mul_card_alternatingGroup.trans card_perm)
theorem nat_card_alternatingGroup [Nontrivial α] :
Nat.card (alternatingGroup α) = (Nat.card α).factorial / 2 := by
simp only [Nat.card_eq_fintype_card, card_alternatingGroup]
namespace alternatingGroup
open Equiv.Perm
instance normal : (alternatingGroup α).Normal :=
sign.normal_ker
theorem isConj_of {σ τ : alternatingGroup α} (hc : IsConj (σ : Perm α) (τ : Perm α))
(hσ : (σ : Perm α).support.card + 2 ≤ Fintype.card α) : IsConj σ τ := by
obtain ⟨σ, hσ⟩ := σ
obtain ⟨τ, hτ⟩ := τ
obtain ⟨π, hπ⟩ := isConj_iff.1 hc
rw [Subtype.coe_mk, Subtype.coe_mk] at hπ
rcases Int.units_eq_one_or (Perm.sign π) with h | h
· rw [isConj_iff]
refine ⟨⟨π, mem_alternatingGroup.mp h⟩, Subtype.val_injective ?_⟩
simpa only [Subtype.val, Subgroup.coe_mul, coe_inv, coe_mk] using hπ
· have h2 : 2 ≤ σ.supportᶜ.card := by
rw [Finset.card_compl, le_tsub_iff_left σ.support.card_le_univ]
exact hσ
obtain ⟨a, ha, b, hb, ab⟩ := Finset.one_lt_card.1 h2
refine isConj_iff.2 ⟨⟨π * swap a b, ?_⟩, Subtype.val_injective ?_⟩
· rw [mem_alternatingGroup, MonoidHom.map_mul, h, sign_swap ab, Int.units_mul_self]
· simp only [← hπ, Subgroup.coe_mul]
have hd : Disjoint (swap a b) σ := by
rw [disjoint_iff_disjoint_support, support_swap ab, Finset.disjoint_insert_left,
Finset.disjoint_singleton_left]
exact ⟨Finset.mem_compl.1 ha, Finset.mem_compl.1 hb⟩
simp [mul_assoc, hd.commute.eq]
theorem isThreeCycle_isConj (h5 : 5 ≤ Fintype.card α) {σ τ : alternatingGroup α}
(hσ : IsThreeCycle (σ : Perm α)) (hτ : IsThreeCycle (τ : Perm α)) : IsConj σ τ :=
alternatingGroup.isConj_of (isConj_iff_cycleType_eq.2 (hσ.trans hτ.symm))
(by rwa [hσ.card_support])
end alternatingGroup
namespace Equiv.Perm
open alternatingGroup
@[simp]
theorem closure_three_cycles_eq_alternating :
closure { σ : Perm α | IsThreeCycle σ } = alternatingGroup α :=
closure_eq_of_le _ (fun _ hσ => mem_alternatingGroup.2 hσ.sign) fun σ hσ => by
suffices hind :
∀ (n : ℕ) (l : List (Perm α)) (_ : ∀ g, g ∈ l → IsSwap g) (_ : l.length = 2 * n),
l.prod ∈ closure { σ : Perm α | IsThreeCycle σ } by
obtain ⟨l, rfl, hl⟩ := truncSwapFactors σ
obtain ⟨n, hn⟩ := (prod_list_swap_mem_alternatingGroup_iff_even_length hl).1 hσ
rw [← two_mul] at hn
exact hind n l hl hn
intro n
induction n with intro l hl hn
| zero => simp [List.length_eq_zero_iff.1 hn, one_mem]
| succ n ih =>
rw [Nat.mul_succ] at hn
obtain ⟨a, l, rfl⟩ := l.exists_of_length_succ hn
rw [List.length_cons, Nat.succ_inj] at hn
obtain ⟨b, l, rfl⟩ := l.exists_of_length_succ hn
rw [List.prod_cons, List.prod_cons, ← mul_assoc]
rw [List.length_cons, Nat.succ_inj] at hn
exact
mul_mem
(IsSwap.mul_mem_closure_three_cycles (hl a List.mem_cons_self)
(hl b (List.mem_cons_of_mem a List.mem_cons_self)))
(ih _ (fun g hg => hl g (List.mem_cons_of_mem _ (List.mem_cons_of_mem _ hg))) hn)
/-- A key lemma to prove $A_5$ is simple. Shows that any normal subgroup of an alternating group on
at least 5 elements is the entire alternating group if it contains a 3-cycle. -/
theorem IsThreeCycle.alternating_normalClosure (h5 : 5 ≤ Fintype.card α) {f : Perm α}
(hf : IsThreeCycle f) :
normalClosure ({⟨f, hf.mem_alternatingGroup⟩} : Set (alternatingGroup α)) = ⊤ :=
eq_top_iff.2
(by
have hi : Function.Injective (alternatingGroup α).subtype := Subtype.coe_injective
refine eq_top_iff.1 (map_injective hi (le_antisymm (map_mono le_top) ?_))
rw [← MonoidHom.range_eq_map, range_subtype, normalClosure, MonoidHom.map_closure]
refine (le_of_eq closure_three_cycles_eq_alternating.symm).trans (closure_mono ?_)
intro g h
obtain ⟨c, rfl⟩ := isConj_iff.1 (isConj_iff_cycleType_eq.2 (hf.trans h.symm))
refine ⟨⟨c * f * c⁻¹, h.mem_alternatingGroup⟩, ?_, rfl⟩
rw [Group.mem_conjugatesOfSet_iff]
exact ⟨⟨f, hf.mem_alternatingGroup⟩, Set.mem_singleton _, isThreeCycle_isConj h5 hf h⟩)
/-- Part of proving $A_5$ is simple. Shows that the square of any element of $A_5$ with a 3-cycle in
its cycle decomposition is a 3-cycle, so the normal closure of the original element must be
$A_5$. -/
theorem isThreeCycle_sq_of_three_mem_cycleType_five {g : Perm (Fin 5)} (h : 3 ∈ cycleType g) :
IsThreeCycle (g * g) := by
obtain ⟨c, g', rfl, hd, _, h3⟩ := mem_cycleType_iff.1 h
simp only [mul_assoc]
rw [hd.commute.eq, ← mul_assoc g']
suffices hg' : orderOf g' ∣ 2 by
rw [← pow_two, orderOf_dvd_iff_pow_eq_one.1 hg', one_mul]
exact (card_support_eq_three_iff.1 h3).isThreeCycle_sq
rw [← lcm_cycleType, Multiset.lcm_dvd]
intro n hn
rw [le_antisymm (two_le_of_mem_cycleType hn) (le_trans (le_card_support_of_mem_cycleType hn) _)]
apply le_of_add_le_add_left
rw [← hd.card_support_mul, h3]
exact (c * g').support.card_le_univ
end Equiv.Perm
namespace alternatingGroup
open Equiv.Perm
theorem eq_bot_of_card_le_two (h2 : card α ≤ 2) : alternatingGroup α = ⊥ := by
nontriviality α
suffices hα' : card α = 2 by
rw [Subgroup.eq_bot_iff_card, ← Nat.mul_right_inj (a := 2) (by simp),
Nat.card_eq_fintype_card, two_mul_card_alternatingGroup, mul_one, card_perm, hα',
Nat.factorial_two]
exact h2.antisymm Fintype.one_lt_card
theorem nontrivial_of_three_le_card (h3 : 3 ≤ card α) : Nontrivial (alternatingGroup α) := by
haveI := Fintype.one_lt_card_iff_nontrivial.1 (lt_trans (by decide) h3)
rw [← Fintype.one_lt_card_iff_nontrivial]
refine lt_of_mul_lt_mul_left ?_ (le_of_lt Nat.prime_two.pos)
rw [two_mul_card_alternatingGroup, card_perm, ← Nat.succ_le_iff]
exact le_trans h3 (card α).self_le_factorial
instance {n : ℕ} : Nontrivial (alternatingGroup (Fin (n + 3))) :=
nontrivial_of_three_le_card
(by
rw [card_fin]
exact le_add_left (le_refl 3))
/-- The normal closure of the 5-cycle `finRotate 5` within $A_5$ is the whole group. This will be
used to show that the normal closure of any 5-cycle within $A_5$ is the whole group. -/
theorem normalClosure_finRotate_five : normalClosure ({⟨finRotate 5,
finRotate_bit1_mem_alternatingGroup (n := 2)⟩} : Set (alternatingGroup (Fin 5))) = ⊤ :=
eq_top_iff.2
(by
have h3 :
IsThreeCycle (Fin.cycleRange 2 * finRotate 5 * (Fin.cycleRange 2)⁻¹ * (finRotate 5)⁻¹) :=
card_support_eq_three_iff.1 (by decide)
rw [← h3.alternating_normalClosure (by rw [card_fin])]
refine normalClosure_le_normal ?_
rw [Set.singleton_subset_iff, SetLike.mem_coe]
have h :
(⟨finRotate 5, finRotate_bit1_mem_alternatingGroup (n := 2)⟩ : alternatingGroup (Fin 5)) ∈
normalClosure _ :=
SetLike.mem_coe.1 (subset_normalClosure (Set.mem_singleton _))
-- Porting note: added `:` to help the elaborator (otherwise we get a timeout)
exact (mul_mem (Subgroup.normalClosure_normal.conj_mem _ h
⟨Fin.cycleRange 2, Fin.isThreeCycle_cycleRange_two.mem_alternatingGroup⟩) (inv_mem h) :))
/-- The normal closure of $(04)(13)$ within $A_5$ is the whole group. This will be
used to show that the normal closure of any permutation of cycle type $(2,2)$ is the whole group.
-/
theorem normalClosure_swap_mul_swap_five :
normalClosure
({⟨swap 0 4 * swap 1 3, mem_alternatingGroup.2 (by decide)⟩} :
Set (alternatingGroup (Fin 5))) =
⊤ := by
let g1 := (⟨swap 0 2 * swap 0 1, mem_alternatingGroup.2 (by decide)⟩ : alternatingGroup (Fin 5))
let g2 := (⟨swap 0 4 * swap 1 3, mem_alternatingGroup.2 (by decide)⟩ : alternatingGroup (Fin 5))
have h5 : g1 * g2 * g1⁻¹ * g2⁻¹ =
⟨finRotate 5, finRotate_bit1_mem_alternatingGroup (n := 2)⟩ := by
rw [Subtype.ext_iff]
simp only [Subgroup.coe_mul, Subgroup.coe_inv]
decide
rw [eq_top_iff, ← normalClosure_finRotate_five]
refine normalClosure_le_normal ?_
rw [Set.singleton_subset_iff, SetLike.mem_coe, ← h5]
have h : g2 ∈ normalClosure {g2} :=
SetLike.mem_coe.1 (subset_normalClosure (Set.mem_singleton _))
exact mul_mem (Subgroup.normalClosure_normal.conj_mem _ h g1) (inv_mem h)
/-- Shows that any non-identity element of $A_5$ whose cycle decomposition consists only of swaps
is conjugate to $(04)(13)$. This is used to show that the normal closure of such a permutation
in $A_5$ is $A_5$. -/
theorem isConj_swap_mul_swap_of_cycleType_two {g : Perm (Fin 5)} (ha : g ∈ alternatingGroup (Fin 5))
(h1 : g ≠ 1) (h2 : ∀ n, n ∈ cycleType (g : Perm (Fin 5)) → n = 2) :
IsConj (swap 0 4 * swap 1 3) g := by
have h := g.support.card_le_univ
rw [← Multiset.eq_replicate_card] at h2
rw [← sum_cycleType, h2, Multiset.sum_replicate, smul_eq_mul] at h
have h : Multiset.card g.cycleType ≤ 3 :=
le_of_mul_le_mul_right (le_trans h (by norm_num only [card_fin])) (by simp)
rw [mem_alternatingGroup, sign_of_cycleType, h2] at ha
norm_num at ha
rw [pow_add, pow_mul, Int.units_pow_two, one_mul, neg_one_pow_eq_one_iff_even] at ha
swap; · decide
rw [isConj_iff_cycleType_eq, h2]
interval_cases h_1 : Multiset.card g.cycleType
· exact (h1 (card_cycleType_eq_zero.1 h_1)).elim
· simp at ha
· have h04 : (0 : Fin 5) ≠ 4 := by decide
have h13 : (1 : Fin 5) ≠ 3 := by decide
rw [Disjoint.cycleType_mul, (isCycle_swap h04).cycleType, (isCycle_swap h13).cycleType,
card_support_swap h04, card_support_swap h13]
· simp
· rw [disjoint_iff_disjoint_support, support_swap h04, support_swap h13]
decide
· contradiction
/-- Shows that $A_5$ is simple by taking an arbitrary non-identity element and showing by casework
on its cycle type that its normal closure is all of $A_5$. -/
instance isSimpleGroup_five : IsSimpleGroup (alternatingGroup (Fin 5)) :=
⟨fun H => by
intro Hn
refine or_not.imp id fun Hb => ?_
rw [eq_bot_iff_forall] at Hb
push_neg at Hb
obtain ⟨⟨g, gA⟩, gH, g1⟩ : ∃ x : ↥(alternatingGroup (Fin 5)), x ∈ H ∧ x ≠ 1 := Hb
-- `g` is a non-identity alternating permutation in a normal subgroup `H` of $A_5$.
rw [← SetLike.mem_coe, ← Set.singleton_subset_iff] at gH
refine eq_top_iff.2 (le_trans (ge_of_eq ?_) (normalClosure_le_normal gH))
-- It suffices to show that the normal closure of `g` in $A_5$ is $A_5$.
by_cases h2 : ∀ n ∈ g.cycleType, n = 2
-- If the cycle decomposition of `g` consists entirely of swaps, then the cycle type is $(2,2)$.
-- This means that it is conjugate to $(04)(13)$, whose normal closure is $A_5$.
· rw [Ne, Subtype.ext_iff] at g1
exact
(isConj_swap_mul_swap_of_cycleType_two gA g1 h2).normalClosure_eq_top_of
normalClosure_swap_mul_swap_five
push_neg at h2
obtain ⟨n, ng, n2⟩ : ∃ n : ℕ, n ∈ g.cycleType ∧ n ≠ 2 := h2
-- `n` is the size of a non-swap cycle in the decomposition of `g`.
have n2' : 2 < n := lt_of_le_of_ne (two_le_of_mem_cycleType ng) n2.symm
have n5 : n ≤ 5 := le_trans ?_ g.support.card_le_univ
-- We check that `2 < n ≤ 5`, so that `interval_cases` has a precise range to check.
swap
· obtain ⟨m, hm⟩ := Multiset.exists_cons_of_mem ng
rw [← sum_cycleType, hm, Multiset.sum_cons]
exact le_add_right le_rfl
interval_cases n
-- This breaks into cases `n = 3`, `n = 4`, `n = 5`.
-- If `n = 3`, then `g` has a 3-cycle in its decomposition, so `g^2` is a 3-cycle.
-- `g^2` is in the normal closure of `g`, so that normal closure must be $A_5$.
· rw [eq_top_iff, ← (isThreeCycle_sq_of_three_mem_cycleType_five ng).alternating_normalClosure
(by rw [card_fin])]
refine normalClosure_le_normal ?_
rw [Set.singleton_subset_iff, SetLike.mem_coe]
have h := SetLike.mem_coe.1 (subset_normalClosure
(G := alternatingGroup (Fin 5)) (Set.mem_singleton ⟨g, gA⟩))
exact mul_mem h h
· -- The case `n = 4` leads to contradiction, as no element of $A_5$ includes a 4-cycle.
have con := mem_alternatingGroup.1 gA
rw [sign_of_cycleType, cycleType_of_card_le_mem_cycleType_add_two (by decide) ng] at con
have : Odd 5 := by decide
simp [this] at con
· -- If `n = 5`, then `g` is itself a 5-cycle, conjugate to `finRotate 5`.
refine (isConj_iff_cycleType_eq.2 ?_).normalClosure_eq_top_of normalClosure_finRotate_five
rw [cycleType_of_card_le_mem_cycleType_add_two (by decide) ng, cycleType_finRotate]⟩
theorem center_eq_bot (hα4 : 4 ≤ Nat.card α) :
Subgroup.center (alternatingGroup α) = ⊥ := by
rw [eq_bot_iff]
rintro ⟨g, hg⟩ hg'
simp only [Subgroup.mem_bot]
simp only [← Subtype.coe_inj, Subgroup.coe_one, ← support_eq_empty_iff,
Finset.eq_empty_iff_forall_notMem]
intro a ha
have hab : g a ≠ a := by rw [← mem_support]; exact ha
have : 2 ≤ (({a, g a} : Finset α)ᶜ).card := by
rw [← Nat.add_le_add_iff_left, Finset.card_add_card_compl]
rw [← Nat.card_eq_fintype_card]
rw [Finset.card_pair hab.symm]
exact hα4
rw [← Nat.lt_iff_add_one_le, Finset.one_lt_card_iff] at this
obtain ⟨c, d, hc, hd, hcd⟩ := this
simp only [Finset.compl_insert, Finset.mem_erase, ← ne_eq, Finset.mem_compl,
Finset.mem_singleton] at hc hd
let k := swap (g a) d * swap (g a) c
have hka : k • a = a := by
simp only [Perm.smul_def, coe_mul, Function.comp_apply, k]
rw [swap_apply_of_ne_of_ne (x := a) hab.symm hc.1.symm]
rw [swap_apply_of_ne_of_ne hab.symm hd.1.symm]
have hkga : k • (g a) = c := by
simp only [Perm.smul_def, coe_mul, Function.comp_apply, swap_apply_left, k]
rw [swap_apply_of_ne_of_ne hc.2 hcd]
suffices k • (⟨g, hg⟩ : alternatingGroup α) • a ≠ c by
apply this; simp [← hkga]
suffices k • (⟨g, hg⟩ : alternatingGroup α) • a = (⟨g, hg⟩ : alternatingGroup α) • k • a by
rw [this, hka]; exact hc.right.symm
rw [Subgroup.mem_center_iff] at hg'
suffices k ∈ alternatingGroup α by
simp only [← Subgroup.mk_smul k this, ← mul_smul, hg']
simp [k, hc.2.symm, hd.2.symm]
end alternatingGroup
namespace Equiv.Perm
open Subgroup Group
/-- The alternating group is the only subgroup of index 2 of the permutation group. -/
theorem eq_alternatingGroup_of_index_eq_two {G : Subgroup (Equiv.Perm α)} (hG : G.index = 2) :
G = alternatingGroup α := by
nontriviality α
obtain ⟨_, ⟨a, b, hab, rfl⟩, habG⟩ : ∃ g : Perm α, g.IsSwap ∧ g ∉ G := by
by_contra! h
suffices G = ⊤ by rw [this, Subgroup.index_top] at hG; cases hG
rwa [eq_top_iff, ← closure_isSwap, G.closure_le]
ext g
refine swap_induction_on g (iff_of_true G.one_mem <| map_one _) fun g x y hxy ih ↦ ?_
rw [mul_mem_iff_of_index_two hG, mul_mem_iff_of_index_two alternatingGroup.index_eq_two, ih]
refine iff_congr (iff_of_false ?_ (by cases (sign_swap hxy).symm.trans ·)) Iff.rfl
contrapose! habG
rw [← (isConj_iff.mp <| isConj_swap hxy hab).choose_spec]
exact (normal_of_index_eq_two hG).conj_mem _ habG _
/-- A subgroup of the permutation group of index ≤ 2 contains the alternating group. -/
theorem alternatingGroup_le_of_index_le_two
{G : Subgroup (Equiv.Perm α)} (hG : G.index ≤ 2) :
alternatingGroup α ≤ G := by
rcases G.index.eq_zero_or_pos with h | h
· exact (index_ne_zero_of_finite h).elim
rcases (Nat.succ_le_iff.mpr h).eq_or_lt' with h | h
· exact index_eq_one.mp h ▸ le_top
rw [eq_alternatingGroup_of_index_eq_two (hG.antisymm h)]
end Equiv.Perm
/-- The alternating group is a characteristic subgroup of the permutation group. -/
instance : (alternatingGroup α).Characteristic where
fixed φ := by
nontriviality α
apply eq_alternatingGroup_of_index_eq_two
rw [index_comap_of_surjective _ (Equiv.surjective _), alternatingGroup.index_eq_two] |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean | import Mathlib.Data.Finite.Sum
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.GroupAction.CardCommute
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.GroupTheory.SpecificGroups.KleinFour
/-!
# Dihedral Groups
We define the dihedral groups `DihedralGroup n`, with elements `r i` and `sr i` for `i : ZMod n`.
For `n ≠ 0`, `DihedralGroup n` represents the symmetry group of the regular `n`-gon. `r i`
represents the rotations of the `n`-gon by `2πi/n`, and `sr i` represents the reflections of the
`n`-gon. `DihedralGroup 0` corresponds to the infinite dihedral group.
-/
assert_not_exists Ideal TwoSidedIdeal
/-- For `n ≠ 0`, `DihedralGroup n` represents the symmetry group of the regular `n`-gon.
`r i` represents the rotations of the `n`-gon by `2πi/n`, and `sr i` represents the reflections of
the `n`-gon. `DihedralGroup 0` corresponds to the infinite dihedral group.
-/
inductive DihedralGroup (n : ℕ) : Type
| r : ZMod n → DihedralGroup n
| sr : ZMod n → DihedralGroup n
deriving DecidableEq
namespace DihedralGroup
variable {n : ℕ}
/-- Multiplication of the dihedral group.
-/
private def mul : DihedralGroup n → DihedralGroup n → DihedralGroup n
| r i, r j => r (i + j)
| r i, sr j => sr (j - i)
| sr i, r j => sr (i + j)
| sr i, sr j => r (j - i)
/-- The identity `1` is the rotation by `0`.
-/
private def one : DihedralGroup n :=
r 0
instance : Inhabited (DihedralGroup n) :=
⟨one⟩
/-- The inverse of an element of the dihedral group.
-/
private def inv : DihedralGroup n → DihedralGroup n
| r i => r (-i)
| sr i => sr i
/-- The group structure on `DihedralGroup n`.
-/
instance : Group (DihedralGroup n) where
mul := mul
mul_assoc := by rintro (a | a) (b | b) (c | c) <;> simp only [(· * ·), mul] <;> ring_nf
one := one
one_mul := by
rintro (a | a)
· exact congr_arg r (zero_add a)
· exact congr_arg sr (sub_zero a)
mul_one := by
rintro (a | a)
· exact congr_arg r (add_zero a)
· exact congr_arg sr (add_zero a)
inv := inv
inv_mul_cancel := by
rintro (a | a)
· exact congr_arg r (neg_add_cancel a)
· exact congr_arg r (sub_self a)
@[simp]
theorem r_mul_r (i j : ZMod n) : r i * r j = r (i + j) :=
rfl
@[simp]
theorem r_mul_sr (i j : ZMod n) : r i * sr j = sr (j - i) :=
rfl
@[simp]
theorem sr_mul_r (i j : ZMod n) : sr i * r j = sr (i + j) :=
rfl
@[simp]
theorem sr_mul_sr (i j : ZMod n) : sr i * sr j = r (j - i) :=
rfl
@[simp]
theorem inv_r (i : ZMod n) : (r i)⁻¹ = r (-i) :=
rfl
@[simp]
theorem inv_sr (i : ZMod n) : (sr i)⁻¹ = sr i :=
rfl
@[simp]
theorem r_zero : r 0 = (1 : DihedralGroup n) :=
rfl
theorem one_def : (1 : DihedralGroup n) = r 0 :=
rfl
@[simp]
theorem r_pow (i : ZMod n) (k : ℕ) : (r i) ^ k = r (i * k : ZMod n) := by
induction k with
| zero => simp only [pow_zero, Nat.cast_zero, mul_zero, r_zero]
| succ k IH =>
rw [pow_add, pow_one, IH, r_mul_r, Nat.cast_add, Nat.cast_one, r.injEq, mul_add, mul_one]
@[simp]
theorem r_zpow (i : ZMod n) (k : ℤ) : (r i) ^ k = r (i * k : ZMod n) := by
cases k <;> simp [r_pow, neg_mul_eq_mul_neg]
private def fintypeHelper : (ZMod n) ⊕ (ZMod n) ≃ DihedralGroup n where
invFun
| r j => .inl j
| sr j => .inr j
toFun
| .inl j => r j
| .inr j => sr j
left_inv := by rintro (x | x) <;> rfl
right_inv := by rintro (x | x) <;> rfl
/-- If `0 < n`, then `DihedralGroup n` is a finite group.
-/
instance [NeZero n] : Fintype (DihedralGroup n) :=
Fintype.ofEquiv _ fintypeHelper
instance : Infinite (DihedralGroup 0) :=
DihedralGroup.fintypeHelper.infinite_iff.mp inferInstance
instance : Nontrivial (DihedralGroup n) :=
⟨⟨r 0, sr 0, by simp_rw [ne_eq, reduceCtorEq, not_false_eq_true]⟩⟩
/-- If `0 < n`, then `DihedralGroup n` has `2n` elements.
-/
theorem card [NeZero n] : Fintype.card (DihedralGroup n) = 2 * n := by
rw [← Fintype.card_eq.mpr ⟨fintypeHelper⟩, Fintype.card_sum, ZMod.card, two_mul]
theorem nat_card : Nat.card (DihedralGroup n) = 2 * n := by
cases n
· rw [Nat.card_eq_zero_of_infinite]
· rw [Nat.card_eq_fintype_card, card]
theorem r_one_pow (k : ℕ) : (r 1 : DihedralGroup n) ^ k = r k := by
simp only [r_pow, one_mul]
theorem r_one_zpow (k : ℤ) : (r 1 : DihedralGroup n) ^ k = r k := by
simp only [r_zpow, one_mul]
theorem r_one_pow_n : r (1 : ZMod n) ^ n = 1 := by
simp
theorem sr_mul_self (i : ZMod n) : sr i * sr i = 1 := by
simp
/-- If `0 < n`, then `sr i` has order 2.
-/
@[simp]
theorem orderOf_sr (i : ZMod n) : orderOf (sr i) = 2 := by
apply orderOf_eq_prime
· rw [sq, sr_mul_self]
· simp [← r_zero]
/-- If `0 < n`, then `r 1` has order `n`.
-/
@[simp]
theorem orderOf_r_one : orderOf (r 1 : DihedralGroup n) = n := by
rcases eq_zero_or_neZero n with (rfl | hn)
· rw [orderOf_eq_zero_iff']
intro n hn
rw [r_one_pow, one_def]
apply mt r.inj
simpa using hn.ne'
· apply (Nat.le_of_dvd (NeZero.pos n) <|
orderOf_dvd_of_pow_eq_one <| @r_one_pow_n n).lt_or_eq.resolve_left
intro h
have h1 : (r 1 : DihedralGroup n) ^ orderOf (r 1) = 1 := pow_orderOf_eq_one _
rw [r_one_pow] at h1
injection h1 with h2
rw [← ZMod.val_eq_zero, ZMod.val_natCast, Nat.mod_eq_of_lt h] at h2
exact absurd h2.symm (orderOf_pos _).ne
/-- If `0 < n`, then `i : ZMod n` has order `n / gcd n i`.
-/
theorem orderOf_r [NeZero n] (i : ZMod n) : orderOf (r i) = n / Nat.gcd n i.val := by
conv_lhs => rw [← ZMod.natCast_zmod_val i]
rw [← r_one_pow, orderOf_pow, orderOf_r_one]
theorem exponent : Monoid.exponent (DihedralGroup n) = lcm n 2 := by
rcases eq_zero_or_neZero n with (rfl | hn)
· exact Monoid.exponent_eq_zero_of_order_zero orderOf_r_one
apply Nat.dvd_antisymm
· apply Monoid.exponent_dvd_of_forall_pow_eq_one
rintro (m | m)
· rw [← orderOf_dvd_iff_pow_eq_one, orderOf_r]
refine Nat.dvd_trans ⟨gcd n m.val, ?_⟩ (dvd_lcm_left n 2)
exact (Nat.div_mul_cancel (Nat.gcd_dvd_left n m.val)).symm
· rw [← orderOf_dvd_iff_pow_eq_one, orderOf_sr]
exact dvd_lcm_right n 2
· apply lcm_dvd
· convert Monoid.order_dvd_exponent (r (1 : ZMod n))
exact orderOf_r_one.symm
· convert Monoid.order_dvd_exponent (sr (0 : ZMod n))
exact (orderOf_sr 0).symm
lemma not_commutative : ∀ {n : ℕ}, n ≠ 1 → n ≠ 2 →
¬Std.Commutative fun (x y : DihedralGroup n) => x * y
| 0, _, _ => fun ⟨h'⟩ ↦ by simpa using h' (r 1) (sr 0)
| n + 3, _, _ => by
rintro ⟨h'⟩
specialize h' (r 1) (sr 0)
rw [r_mul_sr, zero_sub, sr_mul_r, zero_add, sr.injEq, neg_eq_iff_add_eq_zero,
one_add_one_eq_two, ← ZMod.val_eq_zero, ZMod.val_two_eq_two_mod] at h'
simpa using Nat.le_of_dvd Nat.zero_lt_two <| Nat.dvd_of_mod_eq_zero h'
lemma commutative_iff : Std.Commutative (fun x y : DihedralGroup n ↦ x * y) ↔ n = 1 ∨ n = 2 where
mp := by contrapose!; rintro ⟨h1, h2⟩; exact not_commutative h1 h2
mpr := by rintro (rfl | rfl) <;> exact ⟨by decide⟩
lemma not_isCyclic (h1 : n ≠ 1) : ¬ IsCyclic (DihedralGroup n) := fun h => by
by_cases h2 : n = 2
· simpa [exponent, card, h2] using h.exponent_eq_card
· exact not_commutative h1 h2 h.commutative
lemma isCyclic_iff : IsCyclic (DihedralGroup n) ↔ n = 1 where
mp := not_imp_not.mp not_isCyclic
mpr h := h ▸ isCyclic_of_prime_card (p := 2) nat_card
instance : IsKleinFour (DihedralGroup 2) where
card_four := DihedralGroup.nat_card
exponent_two := DihedralGroup.exponent
/-- If n is odd, then the Dihedral group of order $2n$ has $n(n+3)$ pairs (represented as
$n + n + n + n*n$) of commuting elements. -/
@[simps]
def oddCommuteEquiv (hn : Odd n) : { p : DihedralGroup n × DihedralGroup n // Commute p.1 p.2 } ≃
ZMod n ⊕ ZMod n ⊕ ZMod n ⊕ ZMod n × ZMod n :=
let u := ZMod.unitOfCoprime 2 (Nat.prime_two.coprime_iff_not_dvd.mpr hn.not_two_dvd_nat)
have hu : ∀ a : ZMod n, a + a = 0 ↔ a = 0 := fun _ => ZMod.add_self_eq_zero_iff_eq_zero hn
{ toFun := fun
| ⟨⟨sr i, r _⟩, _⟩ => Sum.inl i
| ⟨⟨r _, sr j⟩, _⟩ => Sum.inr (Sum.inl j)
| ⟨⟨sr i, sr j⟩, _⟩ => Sum.inr (Sum.inr (Sum.inl (i + j)))
| ⟨⟨r i, r j⟩, _⟩ => Sum.inr (Sum.inr (Sum.inr ⟨i, j⟩))
invFun := fun
| .inl i => ⟨⟨sr i, r 0⟩, congrArg sr ((add_zero i).trans (sub_zero i).symm)⟩
| .inr (.inl j) => ⟨⟨r 0, sr j⟩, congrArg sr ((sub_zero j).trans (add_zero j).symm)⟩
| .inr (.inr (.inl k)) => ⟨⟨sr (u⁻¹ * k), sr (u⁻¹ * k)⟩, rfl⟩
| .inr (.inr (.inr ⟨i, j⟩)) => ⟨⟨r i, r j⟩, congrArg r (add_comm i j)⟩
left_inv := fun
| ⟨⟨r _, r _⟩, _⟩ => rfl
| ⟨⟨r i, sr j⟩, h⟩ => by
simpa [- r_zero, sub_eq_add_neg, neg_eq_iff_add_eq_zero, hu, eq_comm (a := i) (b := 0)]
using h.eq
| ⟨⟨sr i, r j⟩, h⟩ => by
simpa [- r_zero, sub_eq_add_neg, eq_neg_iff_add_eq_zero, hu, eq_comm (a := j) (b := 0)]
using h.eq
| ⟨⟨sr i, sr j⟩, h⟩ => by
replace h := r.inj h
rw [← neg_sub, neg_eq_iff_add_eq_zero, hu, sub_eq_zero] at h
rw [Subtype.ext_iff, Prod.ext_iff, sr.injEq, sr.injEq, h, and_self, ← two_mul]
exact u.inv_mul_cancel_left j
right_inv := fun
| .inl _ => rfl
| .inr (.inl _) => rfl
| .inr (.inr (.inl k)) =>
congrArg (Sum.inr ∘ Sum.inr ∘ Sum.inl) <| two_mul (u⁻¹ * k) ▸ u.mul_inv_cancel_left k
| .inr (.inr (.inr ⟨_, _⟩)) => rfl }
@[deprecated (since := "2025-05-07")] alias OddCommuteEquiv := oddCommuteEquiv
@[deprecated (since := "2025-05-07")] alias
OddCommuteEquiv_apply := DihedralGroup.oddCommuteEquiv_apply
@[deprecated (since := "2025-05-07")] alias
OddCommuteEquiv_symm_apply := DihedralGroup.oddCommuteEquiv_symm_apply
/-- If n is odd, then the Dihedral group of order $2n$ has $n(n+3)$ pairs of commuting elements. -/
lemma card_commute_odd (hn : Odd n) :
Nat.card { p : DihedralGroup n × DihedralGroup n // Commute p.1 p.2 } = n * (n + 3) := by
have hn' : NeZero n := ⟨hn.pos.ne'⟩
simp_rw [Nat.card_congr (oddCommuteEquiv hn), Nat.card_sum, Nat.card_prod, Nat.card_zmod]
ring
lemma card_conjClasses_odd (hn : Odd n) :
Nat.card (ConjClasses (DihedralGroup n)) = (n + 3) / 2 := by
rw [← Nat.mul_div_mul_left _ 2 hn.pos, ← card_commute_odd hn, mul_comm,
card_comm_eq_card_conjClasses_mul_card, nat_card, Nat.mul_div_left _ (mul_pos two_pos hn.pos)]
end DihedralGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/Cyclic.lean | import Mathlib.Algebra.Group.TypeTags.Finite
import Mathlib.Algebra.Order.Hom.TypeTags
import Mathlib.Data.Nat.Totient
import Mathlib.Data.ZMod.Aut
import Mathlib.Data.ZMod.QuotientGroup
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.Subgroup.Simple
import Mathlib.Tactic.Group
/-!
# Cyclic groups
A group `G` is called cyclic if there exists an element `g : G` such that every element of `G` is of
the form `g ^ n` for some `n : ℕ`. This file only deals with the predicate on a group to be cyclic.
For the concrete cyclic group of order `n`, see `Data.ZMod.Basic`.
## Main definitions
* `IsCyclic` is a predicate on a group stating that the group is cyclic.
## Main statements
* `isCyclic_of_prime_card` proves that a finite group of prime order is cyclic.
* `isSimpleGroup_of_prime_card`, `IsSimpleGroup.isCyclic`,
and `IsSimpleGroup.prime_card` classify finite simple abelian groups.
* `IsCyclic.exponent_eq_card`: For a finite cyclic group `G`, the exponent is equal to
the group's cardinality.
* `IsCyclic.exponent_eq_zero_of_infinite`: Infinite cyclic groups have exponent zero.
* `IsCyclic.iff_exponent_eq_card`: A finite commutative group is cyclic iff its exponent
is equal to its cardinality.
## Tags
cyclic group
-/
assert_not_exists Ideal TwoSidedIdeal
variable {α G G' : Type*} {a : α}
section Cyclic
open Subgroup
@[to_additive]
theorem IsCyclic.exists_generator [Group α] [IsCyclic α] : ∃ g : α, ∀ x, x ∈ zpowers g :=
exists_zpow_surjective α
@[to_additive]
theorem isCyclic_iff_exists_zpowers_eq_top [Group α] : IsCyclic α ↔ ∃ g : α, zpowers g = ⊤ := by
simp only [eq_top_iff', mem_zpowers_iff]
exact ⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩
@[to_additive]
protected theorem Subgroup.isCyclic_iff_exists_zpowers_eq_top [Group α] (H : Subgroup α) :
IsCyclic H ↔ ∃ g : α, Subgroup.zpowers g = H := by
rw [isCyclic_iff_exists_zpowers_eq_top]
simp_rw [← (map_injective H.subtype_injective).eq_iff, ← MonoidHom.range_eq_map,
H.range_subtype, MonoidHom.map_zpowers, Subtype.exists, coe_subtype, exists_prop]
exact exists_congr fun g ↦ and_iff_right_of_imp fun h ↦ h ▸ mem_zpowers g
@[to_additive]
instance (priority := 100) isCyclic_of_subsingleton [Group α] [Subsingleton α] : IsCyclic α :=
⟨⟨1, fun _ => ⟨0, Subsingleton.elim _ _⟩⟩⟩
@[simp]
theorem isCyclic_multiplicative_iff [SubNegMonoid α] :
IsCyclic (Multiplicative α) ↔ IsAddCyclic α :=
⟨fun H ↦ ⟨H.1⟩, fun H ↦ ⟨H.1⟩⟩
instance isCyclic_multiplicative [AddGroup α] [IsAddCyclic α] : IsCyclic (Multiplicative α) :=
isCyclic_multiplicative_iff.mpr inferInstance
@[simp]
theorem isAddCyclic_additive_iff [DivInvMonoid α] : IsAddCyclic (Additive α) ↔ IsCyclic α :=
⟨fun H ↦ ⟨H.1⟩, fun H ↦ ⟨H.1⟩⟩
instance isAddCyclic_additive [Group α] [IsCyclic α] : IsAddCyclic (Additive α) :=
isAddCyclic_additive_iff.mpr inferInstance
@[to_additive]
instance IsCyclic.commutative [Group α] [IsCyclic α] :
Std.Commutative (· * · : α → α → α) where
comm x y :=
let ⟨_, hg⟩ := IsCyclic.exists_generator (α := α)
let ⟨_, hx⟩ := hg x
let ⟨_, hy⟩ := hg y
hy ▸ hx ▸ zpow_mul_comm _ _ _
/-- A cyclic group is always commutative. This is not an `instance` because often we have a better
proof of `CommGroup`. -/
@[to_additive
/-- A cyclic group is always commutative. This is not an `instance` because often we have
a better proof of `AddCommGroup`. -/]
def IsCyclic.commGroup [hg : Group α] [IsCyclic α] : CommGroup α :=
{ hg with mul_comm := commutative.comm }
instance [Group G] (H : Subgroup G) [IsCyclic H] : IsMulCommutative H :=
⟨IsCyclic.commutative⟩
variable [Group α] [Group G] [Group G']
/-- A non-cyclic multiplicative group is non-trivial. -/
@[to_additive /-- A non-cyclic additive group is non-trivial. -/]
theorem Nontrivial.of_not_isCyclic (nc : ¬IsCyclic α) : Nontrivial α := by
contrapose! nc
exact @isCyclic_of_subsingleton _ _ nc
@[to_additive]
theorem MonoidHom.map_cyclic [h : IsCyclic G] (σ : G →* G) :
∃ m : ℤ, ∀ g : G, σ g = g ^ m := by
obtain ⟨h, hG⟩ := IsCyclic.exists_generator (α := G)
obtain ⟨m, hm⟩ := hG (σ h)
refine ⟨m, fun g => ?_⟩
obtain ⟨n, rfl⟩ := hG g
rw [MonoidHom.map_zpow, ← hm, ← zpow_mul, ← zpow_mul']
@[to_additive]
lemma isCyclic_iff_exists_orderOf_eq_natCard [Finite α] :
IsCyclic α ↔ ∃ g : α, orderOf g = Nat.card α := by
simp_rw [isCyclic_iff_exists_zpowers_eq_top, ← card_eq_iff_eq_top, Nat.card_zpowers]
@[to_additive]
lemma isCyclic_iff_exists_natCard_le_orderOf [Finite α] :
IsCyclic α ↔ ∃ g : α, Nat.card α ≤ orderOf g := by
rw [isCyclic_iff_exists_orderOf_eq_natCard]
apply exists_congr
intro g
exact ⟨Eq.ge, le_antisymm orderOf_le_card⟩
@[to_additive]
theorem isCyclic_of_orderOf_eq_card [Finite α] (x : α) (hx : orderOf x = Nat.card α) :
IsCyclic α :=
isCyclic_iff_exists_orderOf_eq_natCard.mpr ⟨x, hx⟩
@[to_additive]
theorem isCyclic_of_card_le_orderOf [Finite α] (x : α) (hx : Nat.card α ≤ orderOf x) :
IsCyclic α :=
isCyclic_iff_exists_natCard_le_orderOf.mpr ⟨x, hx⟩
@[to_additive]
theorem Subgroup.eq_bot_or_eq_top_of_prime_card
(H : Subgroup G) [hp : Fact (Nat.card G).Prime] : H = ⊥ ∨ H = ⊤ := by
have : Finite G := Nat.finite_of_card_ne_zero hp.1.ne_zero
have := card_subgroup_dvd_card H
rwa [Nat.dvd_prime hp.1, ← eq_bot_iff_card, card_eq_iff_eq_top] at this
/-- Any non-identity element of a finite group of prime order generates the group. -/
@[to_additive /-- Any non-identity element of a finite group of prime order generates the group. -/]
theorem zpowers_eq_top_of_prime_card {p : ℕ}
[hp : Fact p.Prime] (h : Nat.card G = p) {g : G} (hg : g ≠ 1) : zpowers g = ⊤ := by
subst h
have := (zpowers g).eq_bot_or_eq_top_of_prime_card
rwa [zpowers_eq_bot, or_iff_right hg] at this
@[to_additive]
theorem mem_zpowers_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card G = p) {g g' : G} (hg : g ≠ 1) : g' ∈ zpowers g := by
simp_rw [zpowers_eq_top_of_prime_card h hg, Subgroup.mem_top]
@[to_additive]
theorem mem_powers_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card G = p) {g g' : G} (hg : g ≠ 1) : g' ∈ Submonoid.powers g := by
have : Finite G := Nat.finite_of_card_ne_zero (h ▸ hp.1.ne_zero)
rw [mem_powers_iff_mem_zpowers]
exact mem_zpowers_of_prime_card h hg
@[to_additive]
theorem powers_eq_top_of_prime_card {p : ℕ}
[hp : Fact p.Prime] (h : Nat.card G = p) {g : G} (hg : g ≠ 1) : Submonoid.powers g = ⊤ := by
ext x
simp [mem_powers_of_prime_card h hg]
/-- A finite group of prime order is cyclic. -/
@[to_additive /-- A finite group of prime order is cyclic. -/]
theorem isCyclic_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card α = p) : IsCyclic α := by
have : Finite α := Nat.finite_of_card_ne_zero (h ▸ hp.1.ne_zero)
have : Nontrivial α := Finite.one_lt_card_iff_nontrivial.mp (h ▸ hp.1.one_lt)
obtain ⟨g, hg⟩ : ∃ g : α, g ≠ 1 := exists_ne 1
exact ⟨g, fun g' ↦ mem_zpowers_of_prime_card h hg⟩
/-- A finite group of order dividing a prime is cyclic. -/
@[to_additive /-- A finite group of order dividing a prime is cyclic. -/]
theorem isCyclic_of_card_dvd_prime {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card α ∣ p) : IsCyclic α := by
rcases (Nat.dvd_prime hp.out).mp h with h | h
· exact @isCyclic_of_subsingleton α _ (Nat.card_eq_one_iff_unique.mp h).1
· exact isCyclic_of_prime_card h
@[to_additive]
theorem isCyclic_of_surjective {F : Type*} [hH : IsCyclic G']
[FunLike F G' G] [MonoidHomClass F G' G] (f : F) (hf : Function.Surjective f) :
IsCyclic G := by
obtain ⟨x, hx⟩ := hH
refine ⟨f x, fun a ↦ ?_⟩
obtain ⟨a, rfl⟩ := hf a
obtain ⟨n, rfl⟩ := hx a
exact ⟨n, (map_zpow _ _ _).symm⟩
@[to_additive]
theorem MulEquiv.isCyclic (e : G ≃* G') :
IsCyclic G ↔ IsCyclic G' :=
⟨fun _ ↦ isCyclic_of_surjective e e.surjective,
fun _ ↦ isCyclic_of_surjective e.symm e.symm.surjective⟩
@[to_additive]
theorem orderOf_eq_card_of_forall_mem_zpowers {g : α} (hx : ∀ x, x ∈ zpowers g) :
orderOf g = Nat.card α := by
rw [← Nat.card_zpowers, (zpowers g).eq_top_iff'.mpr hx, card_top]
@[to_additive]
theorem orderOf_eq_card_of_forall_mem_powers {g : α} (hx : ∀ x, x ∈ Submonoid.powers g) :
orderOf g = Nat.card α := by
rw [orderOf_eq_card_of_forall_mem_zpowers]
exact fun x ↦ Submonoid.powers_le_zpowers _ (hx _)
@[to_additive]
theorem orderOf_eq_card_of_zpowers_eq_top {g : G} (h : Subgroup.zpowers g = ⊤) :
orderOf g = Nat.card G :=
orderOf_eq_card_of_forall_mem_zpowers fun _ ↦ h.ge (Subgroup.mem_top _)
@[to_additive]
theorem exists_pow_ne_one_of_isCyclic [G_cyclic : IsCyclic G]
{k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Nat.card G) : ∃ a : G, a ^ k ≠ 1 := by
have : Finite G := Nat.finite_of_card_ne_zero (Nat.ne_zero_of_lt k_lt_card_G)
rcases G_cyclic with ⟨a, ha⟩
use a
contrapose! k_lt_card_G
convert orderOf_le_of_pow_eq_one k_pos.bot_lt k_lt_card_G
rw [← Nat.card_zpowers, eq_comm, card_eq_iff_eq_top, eq_top_iff]
exact fun x _ ↦ ha x
@[to_additive]
theorem Infinite.orderOf_eq_zero_of_forall_mem_zpowers [Infinite α] {g : α}
(h : ∀ x, x ∈ zpowers g) : orderOf g = 0 := by
rw [orderOf_eq_card_of_forall_mem_zpowers h, Nat.card_eq_zero_of_infinite]
@[to_additive]
instance Bot.isCyclic : IsCyclic (⊥ : Subgroup α) :=
⟨⟨1, fun x => ⟨0, Subtype.eq <| (zpow_zero (1 : α)).trans <| Eq.symm (Subgroup.mem_bot.1 x.2)⟩⟩⟩
@[to_additive]
instance Subgroup.isCyclic [IsCyclic α] (H : Subgroup α) : IsCyclic H :=
haveI := Classical.propDecidable
let ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
if hx : ∃ x : α, x ∈ H ∧ x ≠ (1 : α) then
let ⟨x, hx₁, hx₂⟩ := hx
let ⟨k, hk⟩ := hg x
have hk : g ^ k = x := hk
have hex : ∃ n : ℕ, 0 < n ∧ g ^ n ∈ H :=
⟨k.natAbs,
Nat.pos_of_ne_zero fun h => hx₂ <| by
rw [← hk, Int.natAbs_eq_zero.mp h, zpow_zero], by
rcases k with k | k
· rw [Int.ofNat_eq_coe, Int.natAbs_cast k, ← zpow_natCast, ← Int.ofNat_eq_coe, hk]
exact hx₁
· rw [Int.natAbs_negSucc, ← Subgroup.inv_mem_iff H]; simp_all⟩
⟨⟨⟨g ^ Nat.find hex, (Nat.find_spec hex).2⟩, fun ⟨x, hx⟩ =>
let ⟨k, hk⟩ := hg x
have hk : g ^ k = x := hk
have hk₂ : g ^ ((Nat.find hex : ℤ) * (k / Nat.find hex : ℤ)) ∈ H := by
rw [zpow_mul]
apply H.zpow_mem
exact mod_cast (Nat.find_spec hex).2
have hk₃ : g ^ (k % Nat.find hex : ℤ) ∈ H :=
(Subgroup.mul_mem_cancel_right H hk₂).1 <| by
rw [← zpow_add, Int.emod_add_mul_ediv, hk]; exact hx
have hk₄ : k % Nat.find hex = (k % Nat.find hex).natAbs := by
rw [Int.natAbs_of_nonneg
(Int.emod_nonneg _ (Int.natCast_ne_zero_iff_pos.2 (Nat.find_spec hex).1))]
have hk₅ : g ^ (k % Nat.find hex).natAbs ∈ H := by rwa [← zpow_natCast, ← hk₄]
have hk₆ : (k % (Nat.find hex : ℤ)).natAbs = 0 :=
by_contradiction fun h =>
Nat.find_min hex
(Int.ofNat_lt.1 <| by
rw [← hk₄]; exact Int.emod_lt_of_pos _ (Int.natCast_pos.2 (Nat.find_spec hex).1))
⟨Nat.pos_of_ne_zero h, hk₅⟩
⟨k / (Nat.find hex : ℤ),
Subtype.ext_iff.2
(by
suffices g ^ ((Nat.find hex : ℤ) * (k / Nat.find hex : ℤ)) = x by simpa [zpow_mul]
rw [Int.mul_ediv_cancel'
(Int.dvd_of_emod_eq_zero (Int.natAbs_eq_zero.mp hk₆)),
hk])⟩⟩⟩
else by
have : H = (⊥ : Subgroup α) :=
Subgroup.ext fun x =>
⟨fun h => by simp at *; tauto, fun h => by rw [Subgroup.mem_bot.1 h]; exact H.one_mem⟩
subst this; infer_instance
@[to_additive]
theorem isCyclic_of_injective [IsCyclic G'] (f : G →* G') (hf : Function.Injective f) :
IsCyclic G :=
isCyclic_of_surjective (MonoidHom.ofInjective hf).symm (MonoidHom.ofInjective hf).symm.surjective
@[to_additive]
lemma Subgroup.isCyclic_of_le {H H' : Subgroup G} (h : H ≤ H') [IsCyclic H'] : IsCyclic H :=
isCyclic_of_injective (Subgroup.inclusion h) (Subgroup.inclusion_injective h)
open Finset Nat
section Classical
open scoped Classical in
@[to_additive IsAddCyclic.card_nsmul_eq_zero_le]
theorem IsCyclic.card_pow_eq_one_le [DecidableEq α] [Fintype α] [IsCyclic α] {n : ℕ} (hn0 : 0 < n) :
#{a : α | a ^ n = 1} ≤ n :=
let ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
calc
#{a : α | a ^ n = 1} ≤
#(zpowers (g ^ (Fintype.card α / Nat.gcd n (Fintype.card α))) : Set α).toFinset :=
card_le_card fun x hx =>
let ⟨m, hm⟩ := show x ∈ Submonoid.powers g from mem_powers_iff_mem_zpowers.2 <| hg x
Set.mem_toFinset.2
⟨(m / (Fintype.card α / Nat.gcd n (Fintype.card α)) : ℕ), by
dsimp at hm
have hgmn : g ^ (m * Nat.gcd n (Fintype.card α)) = 1 := by
rw [pow_mul, hm, ← pow_gcd_card_eq_one_iff]; exact (mem_filter.1 hx).2
dsimp only
rw [zpow_natCast, ← pow_mul, Nat.mul_div_cancel_left', hm]
refine Nat.dvd_of_mul_dvd_mul_right (gcd_pos_of_pos_left (Fintype.card α) hn0) ?_
conv_lhs =>
rw [Nat.div_mul_cancel (Nat.gcd_dvd_right _ _), ← Nat.card_eq_fintype_card,
← orderOf_eq_card_of_forall_mem_zpowers hg]
exact orderOf_dvd_of_pow_eq_one hgmn⟩
_ ≤ n := by
let ⟨m, hm⟩ := Nat.gcd_dvd_right n (Fintype.card α)
have hm0 : 0 < m :=
Nat.pos_of_ne_zero fun hm0 => by
rw [hm0, mul_zero, Fintype.card_eq_zero_iff] at hm
exact hm.elim' 1
simp only [Set.toFinset_card, SetLike.coe_sort_coe]
rw [Fintype.card_zpowers, orderOf_pow g, orderOf_eq_card_of_forall_mem_zpowers hg,
Nat.card_eq_fintype_card]
nth_rw 2 [hm]; nth_rw 3 [hm]
rw [Nat.mul_div_cancel_left _ (gcd_pos_of_pos_left _ hn0), gcd_mul_left_left, hm,
Nat.mul_div_cancel _ hm0]
exact le_of_dvd hn0 (Nat.gcd_dvd_left _ _)
end Classical
@[to_additive]
theorem IsCyclic.exists_monoid_generator [Finite α] [IsCyclic α] :
∃ x : α, ∀ y : α, y ∈ Submonoid.powers x := by
simp_rw [mem_powers_iff_mem_zpowers]
exact IsCyclic.exists_generator
@[to_additive]
lemma IsCyclic.exists_ofOrder_eq_natCard [h : IsCyclic α] : ∃ g : α, orderOf g = Nat.card α := by
obtain ⟨g, hg⟩ := h.exists_generator
use g
rw [← card_zpowers g, (eq_top_iff' (zpowers g)).mpr hg]
exact Nat.card_congr (Equiv.Set.univ α)
variable (G) in
/-- A distributive action of a monoid on a finite cyclic group of order `n` factors through an
action on `ZMod n`. -/
noncomputable def MulDistribMulAction.toMonoidHomZModOfIsCyclic (M : Type*) [Monoid M]
[IsCyclic G] [MulDistribMulAction M G] {n : ℕ} (hn : Nat.card G = n) : M →* ZMod n where
toFun m := (MulDistribMulAction.toMonoidHom G m).map_cyclic.choose
map_one' := by
obtain ⟨g, hg⟩ := IsCyclic.exists_ofOrder_eq_natCard (α := G)
rw [← Int.cast_one, ZMod.intCast_eq_intCast_iff, ← hn, ← hg, ← zpow_eq_zpow_iff_modEq,
zpow_one, ← (MulDistribMulAction.toMonoidHom G 1).map_cyclic.choose_spec,
MulDistribMulAction.toMonoidHom_apply, one_smul]
map_mul' m n := by
obtain ⟨g, hg⟩ := IsCyclic.exists_ofOrder_eq_natCard (α := G)
rw [← Int.cast_mul, ZMod.intCast_eq_intCast_iff, ← hn, ← hg, ← zpow_eq_zpow_iff_modEq,
zpow_mul', ← (MulDistribMulAction.toMonoidHom G m).map_cyclic.choose_spec,
← (MulDistribMulAction.toMonoidHom G n).map_cyclic.choose_spec,
← (MulDistribMulAction.toMonoidHom G (m * n)).map_cyclic.choose_spec,
MulDistribMulAction.toMonoidHom_apply, MulDistribMulAction.toMonoidHom_apply,
MulDistribMulAction.toMonoidHom_apply, mul_smul]
theorem MulDistribMulAction.toMonoidHomZModOfIsCyclic_apply {M : Type*} [Monoid M] [IsCyclic G]
[MulDistribMulAction M G] {n : ℕ} (hn : Nat.card G = n) (m : M) (g : G) (k : ℤ)
(h : toMonoidHomZModOfIsCyclic G M hn m = k) : m • g = g ^ k := by
rw [← MulDistribMulAction.toMonoidHom_apply,
(MulDistribMulAction.toMonoidHom G m).map_cyclic.choose_spec g, zpow_eq_zpow_iff_modEq]
apply Int.ModEq.of_dvd (Int.natCast_dvd_natCast.mpr (orderOf_dvd_natCard g))
rwa [hn, ← ZMod.intCast_eq_intCast_iff]
section
variable [Fintype α]
@[to_additive]
theorem IsCyclic.unique_zpow_zmod (ha : ∀ x : α, x ∈ zpowers a) (x : α) :
∃! n : ZMod (Fintype.card α), x = a ^ n.val := by
obtain ⟨n, rfl⟩ := ha x
refine ⟨n, (?_ : a ^ n = _), fun y (hy : a ^ n = _) ↦ ?_⟩
· rw [← zpow_natCast, zpow_eq_zpow_iff_modEq, orderOf_eq_card_of_forall_mem_zpowers ha,
Int.modEq_comm, Int.modEq_iff_add_fac, Nat.card_eq_fintype_card, ← ZMod.intCast_eq_iff]
· rw [← zpow_natCast, zpow_eq_zpow_iff_modEq, orderOf_eq_card_of_forall_mem_zpowers ha,
Nat.card_eq_fintype_card, ← ZMod.intCast_eq_intCast_iff] at hy
simp [hy]
variable [DecidableEq α]
@[to_additive]
theorem IsCyclic.image_range_orderOf (ha : ∀ x : α, x ∈ zpowers a) :
Finset.image (fun i => a ^ i) (range (orderOf a)) = univ := by
simp only [_root_.image_range_orderOf, Set.eq_univ_iff_forall.mpr ha, Set.toFinset_univ]
@[to_additive]
theorem IsCyclic.image_range_card (ha : ∀ x : α, x ∈ zpowers a) :
Finset.image (fun i => a ^ i) (range (Nat.card α)) = univ := by
rw [← orderOf_eq_card_of_forall_mem_zpowers ha, IsCyclic.image_range_orderOf ha]
@[to_additive]
lemma IsCyclic.ext [Finite G] [IsCyclic G] {d : ℕ} {a b : ZMod d}
(hGcard : Nat.card G = d) (h : ∀ t : G, t ^ a.val = t ^ b.val) : a = b := by
have : NeZero (Nat.card G) := ⟨Nat.card_pos.ne'⟩
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := G)
specialize h g
subst hGcard
rw [pow_eq_pow_iff_modEq, orderOf_eq_card_of_forall_mem_zpowers hg,
← ZMod.natCast_eq_natCast_iff] at h
simpa [ZMod.natCast_val, ZMod.cast_id'] using h
end
section Totient
variable [DecidableEq α] [Fintype α] (hn : ∀ n : ℕ, 0 < n → #{a : α | a ^ n = 1} ≤ n)
include hn
@[to_additive]
private theorem card_pow_eq_one_eq_orderOf_aux (a : α) : #{b : α | b ^ orderOf a = 1} = orderOf a :=
le_antisymm (hn _ (orderOf_pos a))
(calc
orderOf a = @Fintype.card (zpowers a) (id _) := Fintype.card_zpowers.symm
_ ≤
@Fintype.card (({b : α | b ^ orderOf a = 1} : Finset _) : Set α)
(Fintype.ofFinset _ fun _ => Iff.rfl) :=
(@Fintype.card_le_of_injective (zpowers a)
(({b : α | b ^ orderOf a = 1} : Finset _) : Set α) (id _) (id _)
(fun b =>
⟨b.1,
mem_filter.2
⟨mem_univ _, by
let ⟨i, hi⟩ := b.2
rw [← hi, ← zpow_natCast, ← zpow_mul, mul_comm, zpow_mul, zpow_natCast,
pow_orderOf_eq_one, one_zpow]⟩⟩)
fun _ _ h => Subtype.eq (Subtype.mk.inj h))
_ = #{b : α | b ^ orderOf a = 1} := Fintype.card_ofFinset _ _
)
-- Use φ for `Nat.totient`
open Nat
@[to_additive]
private theorem card_orderOf_eq_totient_aux₁ {d : ℕ} (hd : d ∣ Fintype.card α)
(hpos : 0 < #{a : α | orderOf a = d}) : #{a : α | orderOf a = d} = φ d := by
induction d using Nat.strongRec' with | _ d IH
rcases Decidable.eq_or_ne d 0 with (rfl | hd0)
· cases Fintype.card_ne_zero (eq_zero_of_zero_dvd hd)
rcases Finset.card_pos.1 hpos with ⟨a, ha'⟩
have ha : orderOf a = d := (mem_filter.1 ha').2
have h1 :
(∑ m ∈ d.properDivisors, #{a : α | orderOf a = m}) =
∑ m ∈ d.properDivisors, φ m := by
refine Finset.sum_congr rfl fun m hm => ?_
simp only [mem_properDivisors] at hm
refine IH m hm.2 (hm.1.trans hd) (Finset.card_pos.2 ⟨a ^ (d / m), ?_⟩)
rw [mem_filter_univ, orderOf_pow a, ha, Nat.gcd_eq_right (div_dvd_of_dvd hm.1),
Nat.div_div_self hm.1 hd0]
have h2 :
(∑ m ∈ d.divisors, #{a : α | orderOf a = m}) =
∑ m ∈ d.divisors, φ m := by
rw [sum_card_orderOf_eq_card_pow_eq_one hd0, sum_totient,
← ha, card_pow_eq_one_eq_orderOf_aux hn a]
simpa [← cons_self_properDivisors hd0, ← h1] using h2
@[to_additive]
theorem card_orderOf_eq_totient_aux₂ {d : ℕ} (hd : d ∣ Fintype.card α) :
#{a : α | orderOf a = d} = φ d := by
let c := Fintype.card α
have hc0 : 0 < c := Fintype.card_pos_iff.2 ⟨1⟩
apply card_orderOf_eq_totient_aux₁ hn hd
by_contra h0
-- Must qualify `Finset.card_eq_zero` because of https://github.com/leanprover/lean4/issues/2849
simp_rw [not_lt, Nat.le_zero, Finset.card_eq_zero] at h0
apply lt_irrefl c
calc
c = ∑ m ∈ c.divisors, #{a : α | orderOf a = m} := by
simp only [sum_card_orderOf_eq_card_pow_eq_one hc0.ne']
apply congr_arg card
simp [c]
_ = ∑ m ∈ c.divisors.erase d, #{a : α | orderOf a = m} := by
rw [eq_comm]
refine sum_subset (erase_subset _ _) fun m hm₁ hm₂ => ?_
have : m = d := by
contrapose! hm₂
exact mem_erase_of_ne_of_mem hm₂ hm₁
simp [this, h0]
_ ≤ ∑ m ∈ c.divisors.erase d, φ m := by
refine sum_le_sum fun m hm => ?_
have hmc : m ∣ c := by
simp only [mem_erase, mem_divisors] at hm
tauto
obtain h1 | h1 := (#{a : α | orderOf a = m}).eq_zero_or_pos
· simp [h1]
· simp [card_orderOf_eq_totient_aux₁ hn hmc h1]
_ < ∑ m ∈ c.divisors, φ m :=
sum_erase_lt_of_pos (mem_divisors.2 ⟨hd, hc0.ne'⟩) (totient_pos.2 (pos_of_dvd_of_pos hd hc0))
_ = c := sum_totient _
@[to_additive isAddCyclic_of_card_nsmul_eq_zero_le, stacks 09HX "This theorem is stronger than \
09HX. It removes the abelian condition, and requires only `≤` instead of `=`."]
theorem isCyclic_of_card_pow_eq_one_le : IsCyclic α :=
have : Finset.Nonempty {a : α | orderOf a = Nat.card α} :=
card_pos.1 <| by
rw [Nat.card_eq_fintype_card, card_orderOf_eq_totient_aux₂ hn dvd_rfl, totient_pos]
apply Fintype.card_pos
let ⟨x, hx⟩ := this
isCyclic_of_orderOf_eq_card x (Finset.mem_filter.1 hx).2
end Totient
@[to_additive]
lemma IsCyclic.card_orderOf_eq_totient [IsCyclic α] [Fintype α] {d : ℕ} (hd : d ∣ Fintype.card α) :
#{a : α | orderOf a = d} = totient d := by
classical apply card_orderOf_eq_totient_aux₂ (fun n => IsCyclic.card_pow_eq_one_le) hd
/-- A finite group of prime order is simple. -/
@[to_additive /-- A finite group of prime order is simple. -/]
theorem isSimpleGroup_of_prime_card {p : ℕ} [hp : Fact p.Prime]
(h : Nat.card α = p) : IsSimpleGroup α := by
subst h
have : Finite α := Nat.finite_of_card_ne_zero hp.1.ne_zero
have : Nontrivial α := Finite.one_lt_card_iff_nontrivial.mp hp.1.one_lt
exact ⟨fun H _ => H.eq_bot_or_eq_top_of_prime_card⟩
end Cyclic
section QuotientCenter
open Subgroup
variable [Group G] [Group G']
/-- A group is commutative if the quotient by the center is cyclic.
Also see `commGroupOfCyclicCenterQuotient` for the `CommGroup` instance. -/
@[to_additive
/-- A group is commutative if the quotient by the center is cyclic.
Also see `addCommGroupOfCyclicCenterQuotient` for the `AddCommGroup` instance. -/]
theorem commutative_of_cyclic_center_quotient [IsCyclic G'] (f : G →* G') (hf : f.ker ≤ center G)
(a b : G) : a * b = b * a :=
let ⟨⟨x, y, (hxy : f y = x)⟩, (hx : ∀ a : f.range, a ∈ zpowers _)⟩ :=
IsCyclic.exists_generator (α := f.range)
let ⟨m, hm⟩ := hx ⟨f a, a, rfl⟩
let ⟨n, hn⟩ := hx ⟨f b, b, rfl⟩
have hm : x ^ m = f a := by simpa [Subtype.ext_iff] using hm
have hn : x ^ n = f b := by simpa [Subtype.ext_iff] using hn
have ha : y ^ (-m) * a ∈ center G :=
hf (by rw [f.mem_ker, f.map_mul, f.map_zpow, hxy, zpow_neg x m, hm, inv_mul_cancel])
have hb : y ^ (-n) * b ∈ center G :=
hf (by rw [f.mem_ker, f.map_mul, f.map_zpow, hxy, zpow_neg x n, hn, inv_mul_cancel])
calc
a * b = y ^ m * (y ^ (-m) * a * y ^ n) * (y ^ (-n) * b) := by simp [mul_assoc]
_ = y ^ m * (y ^ n * (y ^ (-m) * a)) * (y ^ (-n) * b) := by rw [mem_center_iff.1 ha]
_ = y ^ m * y ^ n * y ^ (-m) * (a * (y ^ (-n) * b)) := by simp [mul_assoc]
_ = y ^ m * y ^ n * y ^ (-m) * (y ^ (-n) * b * a) := by rw [mem_center_iff.1 hb]
_ = b * a := by group
/-- A group is commutative if the quotient by the center is cyclic. -/
@[to_additive
/-- A group is commutative if the quotient by the center is cyclic. -/]
def commGroupOfCyclicCenterQuotient [IsCyclic G'] (f : G →* G') (hf : f.ker ≤ center G) :
CommGroup G :=
{ show Group G by infer_instance with mul_comm := commutative_of_cyclic_center_quotient f hf }
end QuotientCenter
namespace IsSimpleGroup
section CommGroup
variable [CommGroup α] [IsSimpleGroup α]
@[to_additive]
instance (priority := 100) isCyclic : IsCyclic α := by
nontriviality α
obtain ⟨g, hg⟩ := exists_ne (1 : α)
have : Subgroup.zpowers g = ⊤ :=
(eq_bot_or_eq_top (Subgroup.zpowers g)).resolve_left (Subgroup.zpowers_ne_bot.2 hg)
exact ⟨⟨g, (Subgroup.eq_top_iff' _).1 this⟩⟩
@[to_additive]
theorem prime_card [Finite α] : (Nat.card α).Prime := by
have h0 : 0 < Nat.card α := Nat.card_pos
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := α)
rw [Nat.prime_def]
refine ⟨Finite.one_lt_card_iff_nontrivial.2 inferInstance, fun n hn => ?_⟩
refine (IsSimpleOrder.eq_bot_or_eq_top (Subgroup.zpowers (g ^ n))).symm.imp ?_ ?_
· intro h
have hgo := orderOf_pow (n := n) g
rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.gcd_eq_right_iff_dvd.2 hn,
orderOf_eq_card_of_forall_mem_zpowers, eq_comm,
Nat.div_eq_iff_eq_mul_left (Nat.pos_of_dvd_of_pos hn h0) hn] at hgo
· exact (mul_left_cancel₀ (ne_of_gt h0) ((mul_one (Nat.card α)).trans hgo)).symm
· intro x
rw [h]
exact Subgroup.mem_top _
· intro h
apply le_antisymm (Nat.le_of_dvd h0 hn)
rw [← orderOf_eq_card_of_forall_mem_zpowers hg]
apply orderOf_le_of_pow_eq_one (Nat.pos_of_dvd_of_pos hn h0)
rw [← Subgroup.mem_bot, ← h]
exact Subgroup.mem_zpowers _
end CommGroup
end IsSimpleGroup
@[to_additive]
theorem CommGroup.is_simple_iff_isCyclic_and_prime_card [Finite α] [CommGroup α] :
IsSimpleGroup α ↔ IsCyclic α ∧ (Nat.card α).Prime := by
constructor
· intro h
exact ⟨IsSimpleGroup.isCyclic, IsSimpleGroup.prime_card⟩
· rintro ⟨_, hp⟩
haveI : Fact (Nat.card α).Prime := ⟨hp⟩
exact isSimpleGroup_of_prime_card rfl
section SpecificInstances
instance : IsAddCyclic ℤ := ⟨1, fun n ↦ ⟨n, by simp only [smul_eq_mul, mul_one]⟩⟩
instance ZMod.instIsAddCyclic (n : ℕ) : IsAddCyclic (ZMod n) :=
isAddCyclic_of_surjective (Int.castRingHom _) ZMod.intCast_surjective
instance ZMod.instIsSimpleAddGroup {p : ℕ} [Fact p.Prime] : IsSimpleAddGroup (ZMod p) :=
AddCommGroup.is_simple_iff_isAddCyclic_and_prime_card.2
⟨inferInstance, by simpa using (Fact.out : p.Prime)⟩
end SpecificInstances
section EquivInt
/-- A linearly-ordered additive abelian group is cyclic iff it is isomorphic to `ℤ` as an ordered
additive monoid. -/
lemma LinearOrderedAddCommGroup.isAddCyclic_iff_nonempty_equiv_int {A : Type*}
[AddCommGroup A] [LinearOrder A] [IsOrderedAddMonoid A] [Nontrivial A] :
IsAddCyclic A ↔ Nonempty (A ≃+o ℤ) := by
refine ⟨?_, fun ⟨e⟩ ↦ e.isAddCyclic.mpr inferInstance⟩
rintro ⟨g, hs⟩
have h_ne : g ≠ 0 := by
obtain ⟨a, ha⟩ := exists_ne (0 : A)
obtain ⟨m, rfl⟩ := hs a
aesop
wlog hg' : 0 < g
· exact this (g := -g) (by simpa using neg_surjective.comp hs) (by grind) (by grind)
have hi : (fun n : ℤ ↦ n • g).Injective := injective_zsmul_iff_not_isOfFinAddOrder.mpr
<| not_isOfFinAddOrder_of_isAddTorsionFree h_ne
exact ⟨.symm { Equiv.ofBijective _ ⟨hi, hs⟩ with
map_add' := add_zsmul g
map_le_map_iff' := zsmul_le_zsmul_iff_left hg' }⟩
/-- A linearly-ordered abelian group is cyclic iff it is isomorphic to `Multiplicative ℤ` as an
ordered monoid. -/
lemma LinearOrderedCommGroup.isCyclic_iff_nonempty_equiv_int {G : Type*}
[CommGroup G] [LinearOrder G] [IsOrderedMonoid G] [Nontrivial G] :
IsCyclic G ↔ Nonempty (G ≃*o Multiplicative ℤ) := by
rw [← isAddCyclic_additive_iff, LinearOrderedAddCommGroup.isAddCyclic_iff_nonempty_equiv_int,
OrderAddMonoidIso.toMultiplicativeRight.nonempty_congr]
end EquivInt
section Exponent
open Monoid
@[to_additive]
theorem IsCyclic.exponent_eq_card [Group α] [IsCyclic α] :
exponent α = Nat.card α := by
obtain ⟨g, hg⟩ := IsCyclic.exists_ofOrder_eq_natCard (α := α)
apply Nat.dvd_antisymm Group.exponent_dvd_nat_card
rw [← hg]
exact order_dvd_exponent _
@[to_additive]
theorem IsCyclic.of_exponent_eq_card [CommGroup α] [Finite α] (h : exponent α = Nat.card α) :
IsCyclic α :=
let ⟨_⟩ := nonempty_fintype α
let ⟨g, _, hg⟩ := Finset.mem_image.mp (Finset.max'_mem _ _)
isCyclic_of_orderOf_eq_card g <| hg.trans <| exponent_eq_max'_orderOf.symm.trans h
@[to_additive]
theorem IsCyclic.iff_exponent_eq_card [CommGroup α] [Finite α] :
IsCyclic α ↔ exponent α = Nat.card α :=
⟨fun _ => IsCyclic.exponent_eq_card, IsCyclic.of_exponent_eq_card⟩
@[to_additive]
theorem IsCyclic.exponent_eq_zero_of_infinite [Group α] [IsCyclic α] [Infinite α] :
exponent α = 0 :=
let ⟨_, hg⟩ := IsCyclic.exists_generator (α := α)
exponent_eq_zero_of_order_zero <| Infinite.orderOf_eq_zero_of_forall_mem_zpowers hg
@[simp]
protected theorem ZMod.exponent (n : ℕ) : AddMonoid.exponent (ZMod n) = n := by
rw [IsAddCyclic.exponent_eq_card, Nat.card_zmod]
/-- A group of order `p ^ 2` is not cyclic if and only if its exponent is `p`. -/
@[to_additive]
lemma not_isCyclic_iff_exponent_eq_prime [Group α] {p : ℕ} (hp : p.Prime)
(hα : Nat.card α = p ^ 2) : ¬ IsCyclic α ↔ Monoid.exponent α = p := by
-- G is a nontrivial fintype of cardinality `p ^ 2`
have : Finite α := Nat.finite_of_card_ne_zero (hα ▸ pow_ne_zero 2 hp.ne_zero)
have : Nontrivial α := Finite.one_lt_card_iff_nontrivial.mp
(hα ▸ one_lt_pow₀ hp.one_lt two_ne_zero)
/- in the forward direction, we apply `exponent_eq_prime_iff`, and the reverse direction follows
immediately because if `α` has exponent `p`, it has no element of order `p ^ 2`. -/
refine ⟨fun h_cyc ↦ (Monoid.exponent_eq_prime_iff hp).mpr fun g hg ↦ ?_, fun h_exp h_cyc ↦ by
obtain (rfl | rfl) := eq_zero_or_one_of_sq_eq_self <| hα ▸ h_exp ▸ (h_cyc.exponent_eq_card).symm
· exact Nat.not_prime_zero hp
· exact Nat.not_prime_one hp⟩
/- we must show every non-identity element has order `p`. By Lagrange's theorem, the only possible
orders of `g` are `1`, `p`, or `p ^ 2`. It can't be the former because `g ≠ 1`, and it can't
the latter because the group isn't cyclic. -/
have := (Nat.mem_divisors (m := p ^ 2)).mpr ⟨hα ▸ orderOf_dvd_natCard (x := g), by aesop⟩
have : ∃ a < 3, p ^ a = orderOf g := by
simpa [Nat.divisors_prime_pow hp 2] using this
obtain ⟨a, ha, ha'⟩ := by simpa using this
interval_cases a
· exact False.elim <| hg <| orderOf_eq_one_iff.mp <| by simp_all
· simp_all
· exact False.elim <| h_cyc <| isCyclic_of_orderOf_eq_card g <| by cutsat
end Exponent
section ZMod
open Subgroup AddSubgroup
/-- The kernel of `zmultiplesHom G g` is equal to the additive subgroup generated by
`addOrderOf g`. -/
theorem zmultiplesHom_ker_eq [AddGroup G] (g : G) :
(zmultiplesHom G g).ker = zmultiples ↑(addOrderOf g) := by
ext
simp_rw [AddMonoidHom.mem_ker, mem_zmultiples_iff, zmultiplesHom_apply,
← addOrderOf_dvd_iff_zsmul_eq_zero, zsmul_eq_mul', Int.cast_id, dvd_def, eq_comm]
/-- The kernel of `zpowersHom G g` is equal to the subgroup generated by `orderOf g`. -/
theorem zpowersHom_ker_eq [Group G] (g : G) :
(zpowersHom G g).ker = zpowers (Multiplicative.ofAdd ↑(orderOf g)) :=
congr_arg AddSubgroup.toSubgroup <| zmultiplesHom_ker_eq (Additive.ofMul g)
/-- The isomorphism from `ZMod n` to any cyclic additive group of `Nat.card` equal to `n`. -/
noncomputable def zmodAddCyclicAddEquiv [AddGroup G] (h : IsAddCyclic G) :
ZMod (Nat.card G) ≃+ G := by
let n := Nat.card G
let ⟨g, surj⟩ := Classical.indefiniteDescription _ h.exists_generator
have kereq : ((zmultiplesHom G) g).ker = zmultiples ↑(Nat.card G) := by
rw [zmultiplesHom_ker_eq]
congr
rw [← Nat.card_zmultiples]
exact Nat.card_congr (Equiv.subtypeUnivEquiv surj)
exact Int.quotientZMultiplesNatEquivZMod n
|>.symm.trans <| QuotientAddGroup.quotientAddEquivOfEq kereq
|>.symm.trans <| QuotientAddGroup.quotientKerEquivOfSurjective (zmultiplesHom G g) surj
/-- The isomorphism from `Multiplicative (ZMod n)` to any cyclic group of `Nat.card` equal to `n`.
-/
noncomputable def zmodCyclicMulEquiv [Group G] (h : IsCyclic G) :
Multiplicative (ZMod (Nat.card G)) ≃* G :=
AddEquiv.toMultiplicative <| zmodAddCyclicAddEquiv <| isAddCyclic_additive_iff.2 h
/-- Two cyclic additive groups of the same cardinality are isomorphic. -/
noncomputable def addEquivOfAddCyclicCardEq [AddGroup G] [AddGroup G'] [hG : IsAddCyclic G]
[hH : IsAddCyclic G'] (hcard : Nat.card G = Nat.card G') : G ≃+ G' := hcard ▸
zmodAddCyclicAddEquiv hG |>.symm.trans (zmodAddCyclicAddEquiv hH)
/-- Two cyclic groups of the same cardinality are isomorphic. -/
@[to_additive existing]
noncomputable def mulEquivOfCyclicCardEq [Group G] [Group G'] [hG : IsCyclic G]
[hH : IsCyclic G'] (hcard : Nat.card G = Nat.card G') : G ≃* G' := hcard ▸
zmodCyclicMulEquiv hG |>.symm.trans (zmodCyclicMulEquiv hH)
/-- Two groups of the same prime cardinality are isomorphic. -/
@[to_additive /-- Two additive groups of the same prime cardinality are isomorphic. -/]
noncomputable def mulEquivOfPrimeCardEq {p : ℕ} [Group G] [Group G']
[Fact p.Prime] (hG : Nat.card G = p) (hH : Nat.card G' = p) : G ≃* G' := by
have hGcyc := isCyclic_of_prime_card hG
have hHcyc := isCyclic_of_prime_card hH
apply mulEquivOfCyclicCardEq
exact hG.trans hH.symm
variable (G) in
/-- The automorphism group of a cyclic group is isomorphic to the multiplicative group of ZMod. -/
@[simps!]
noncomputable def IsCyclic.mulAutMulEquiv [Group G] [h : IsCyclic G] :
MulAut G ≃* (ZMod (Nat.card G))ˣ :=
((MulAut.congr (zmodCyclicMulEquiv h)).symm.trans
(MulAutMultiplicative (ZMod (Nat.card G)))).trans (ZMod.AddAutEquivUnits (Nat.card G))
variable (G) in
theorem IsCyclic.card_mulAut [Group G] [Finite G] [h : IsCyclic G] :
Nat.card (MulAut G) = Nat.totient (Nat.card G) := by
have : NeZero (Nat.card G) := ⟨Nat.card_pos.ne'⟩
rw [← ZMod.card_units_eq_totient, ← Nat.card_eq_fintype_card]
exact Nat.card_congr (mulAutMulEquiv G)
end ZMod
section powMonoidHom
variable (G)
-- Note. Even though cyclic groups only require `[Group G]`, we need `[CommGroup G]` for
-- `powMonoidHom` to be defined.
@[to_additive]
theorem IsCyclic.card_powMonoidHom_range [CommGroup G] [hG : IsCyclic G] [Finite G] (d : ℕ) :
Nat.card (powMonoidHom d : G →* G).range = Nat.card G / (Nat.card G).gcd d := by
obtain ⟨g, h⟩ := isCyclic_iff_exists_zpowers_eq_top.mp hG
rw [MonoidHom.range_eq_map, ← h, MonoidHom.map_zpowers, Nat.card_zpowers, powMonoidHom_apply,
orderOf_pow, orderOf_eq_card_of_zpowers_eq_top h]
@[to_additive]
theorem IsCyclic.index_powMonoidHom_ker [CommGroup G] [IsCyclic G] [Finite G] (d : ℕ) :
(powMonoidHom d : G →* G).ker.index = Nat.card G / (Nat.card G).gcd d := by
rw [Subgroup.index_ker, card_powMonoidHom_range]
@[to_additive]
theorem IsCyclic.card_powMonoidHom_ker [CommGroup G] [IsCyclic G] [Finite G] (d : ℕ) :
Nat.card (powMonoidHom d : G →* G).ker = (Nat.card G).gcd d := by
have h : (powMonoidHom d : G →* G).ker.index ≠ 0 := Subgroup.index_ne_zero_of_finite
rw [← mul_left_inj' h, Subgroup.card_mul_index, index_powMonoidHom_ker, Nat.mul_div_cancel']
exact Nat.gcd_dvd_left (Nat.card G) d
@[to_additive]
theorem IsCyclic.index_powMonoidHom_range [CommGroup G] [IsCyclic G] [Finite G] (d : ℕ) :
(powMonoidHom d : G →* G).range.index = (Nat.card G).gcd d := by
rw [Subgroup.index_range, card_powMonoidHom_ker]
end powMonoidHom
section generator
/-!
### Groups with a given generator
We state some results in terms of an explicitly given generator.
The generating property is given as in `IsCyclic.exists_generator`.
The main statements are about the existence and uniqueness of homomorphisms and isomorphisms
specified by the image of the given generator.
-/
open Subgroup
variable [Group G] [Group G'] {g : G} (hg : ∀ x, x ∈ zpowers g) {g' : G'}
section monoidHom
variable (hg' : orderOf g' ∣ orderOf (g : G))
/-- If `g` generates the group `G` and `g'` is an element of another group `G'` whose order
divides that of `g`, then there is a homomorphism `G →* G'` mapping `g` to `g'`. -/
@[to_additive
/-- If `g` generates the additive group `G` and `g'` is an element of another additive group `G'`
whose order divides that of `g`, then there is a homomorphism `G →+ G'` mapping `g` to `g'`. -/]
noncomputable
def monoidHomOfForallMemZpowers : G →* G' where
toFun x := g' ^ (Classical.choose <| mem_zpowers_iff.mp <| hg x)
map_one' := orderOf_dvd_iff_zpow_eq_one.mp <|
(Int.natCast_dvd_natCast.mpr hg').trans <| orderOf_dvd_iff_zpow_eq_one.mpr <|
Classical.choose_spec <| mem_zpowers_iff.mp <| hg 1
map_mul' x y := by
simp only [← zpow_add, zpow_eq_zpow_iff_modEq]
apply Int.ModEq.of_dvd (Int.natCast_dvd_natCast.mpr hg')
rw [← zpow_eq_zpow_iff_modEq, zpow_add]
simp only [fun x ↦ Classical.choose_spec <| mem_zpowers_iff.mp <| hg x]
@[to_additive (attr := simp)]
lemma monoidHomOfForallMemZpowers_apply_gen :
monoidHomOfForallMemZpowers hg hg' g = g' := by
simp only [monoidHomOfForallMemZpowers, MonoidHom.coe_mk, OneHom.coe_mk]
nth_rw 2 [← zpow_one g']
rw [zpow_eq_zpow_iff_modEq]
apply Int.ModEq.of_dvd (Int.natCast_dvd_natCast.mpr hg')
rw [← zpow_eq_zpow_iff_modEq, zpow_one]
exact Classical.choose_spec <| mem_zpowers_iff.mp <| hg g
end monoidHom
include hg
/-- Two group homomorphisms `G →* G'` are equal if and only if they agree on a generator of `G`. -/
@[to_additive
/-- Two homomorphisms `G →+ G'` of additive groups are equal if and only if they agree
on a generator of `G`. -/]
lemma MonoidHom.eq_iff_eq_on_generator (f₁ f₂ : G →* G') : f₁ = f₂ ↔ f₁ g = f₂ g := by
rw [DFunLike.ext_iff]
refine ⟨fun H ↦ H g, fun H x ↦ ?_⟩
obtain ⟨n, hn⟩ := mem_zpowers_iff.mp <| hg x
rw [← hn, map_zpow, map_zpow, H]
/-- Two group isomorphisms `G ≃* G'` are equal if and only if they agree on a generator of `G`. -/
@[to_additive
/-- Two isomorphisms `G ≃+ G'` of additive groups are equal if and only if they agree
on a generator of `G`. -/]
lemma MulEquiv.eq_iff_eq_on_generator (f₁ f₂ : G ≃* G') : f₁ = f₂ ↔ f₁ g = f₂ g :=
(Function.Injective.eq_iff toMonoidHom_injective).symm.trans <|
MonoidHom.eq_iff_eq_on_generator hg ..
section mulEquiv
variable (hg' : ∀ x, x ∈ zpowers g') (h : orderOf g = orderOf g')
/-- Given two groups that are generated by elements `g` and `g'` of the same order,
we obtain an isomorphism sending `g` to `g'`. -/
@[to_additive
/-- Given two additive groups that are generated by elements `g` and `g'` of the same order,
we obtain an isomorphism sending `g` to `g'`. -/]
noncomputable
def mulEquivOfOrderOfEq : G ≃* G' := by
refine MonoidHom.toMulEquiv (monoidHomOfForallMemZpowers hg h.symm.dvd)
(monoidHomOfForallMemZpowers hg' h.dvd) ?_ ?_ <;>
refine (MonoidHom.eq_iff_eq_on_generator (by assumption) _ _).mpr ?_ <;>
simp only [MonoidHom.coe_comp, Function.comp_apply, monoidHomOfForallMemZpowers_apply_gen,
MonoidHom.id_apply]
@[to_additive (attr := simp)]
lemma mulEquivOfOrderOfEq_apply_gen : mulEquivOfOrderOfEq hg hg' h g = g' :=
monoidHomOfForallMemZpowers_apply_gen hg h.symm.dvd
@[to_additive (attr := simp)]
lemma mulEquivOfOrderOfEq_symm :
(mulEquivOfOrderOfEq hg hg' h).symm = mulEquivOfOrderOfEq hg' hg h.symm := rfl
@[to_additive] -- `simp` can prove this by a combination of the two preceding lemmas
lemma mulEquivOfOrderOfEq_symm_apply_gen : (mulEquivOfOrderOfEq hg hg' h).symm g' = g :=
monoidHomOfForallMemZpowers_apply_gen hg' h.dvd
end mulEquiv
end generator
section prod
@[to_additive] theorem Group.isCyclic_of_coprime_card_range_card_ker {M N : Type*}
[CommGroup M] [Group N] (f : M →* N) (h : (Nat.card f.ker).Coprime (Nat.card f.range))
[IsCyclic f.ker] [IsCyclic f.range] : IsCyclic M := by
cases (finite_or_infinite f.ker).symm
· rw [Nat.card_eq_zero_of_infinite, Nat.coprime_zero_left] at h
rw [← f.range.eq_bot_iff_card, f.range_eq_bot_iff, ← f.ker_eq_top_iff] at h
rwa [← Subgroup.topEquiv.isCyclic, ← h]
cases (finite_or_infinite f.range).symm
· rw [Nat.card_eq_zero_of_infinite (α := f.range), Nat.coprime_zero_right] at h
rwa [(f.ofInjective (f.ker_eq_bot_iff.mp (f.ker.eq_bot_of_card_eq h))).isCyclic]
have := f.finite_iff_finite_ker_range.mpr ⟨‹_›, ‹_›⟩
rw [IsCyclic.iff_exponent_eq_card]
apply dvd_antisymm Group.exponent_dvd_nat_card
rw [← f.ker.card_mul_index, Subgroup.index_ker]
apply h.mul_dvd_of_dvd_of_dvd <;> rw [← IsCyclic.exponent_eq_card]
· exact Monoid.exponent_dvd_of_monoidHom _ f.ker.subtype_injective
· exact MonoidHom.exponent_dvd f.rangeRestrict_surjective
@[to_additive] theorem Group.isCyclic_of_coprime_card_ker {M N : Type*}
[CommGroup M] [Group N] (f : M →* N) (h : (Nat.card f.ker).Coprime (Nat.card N))
[IsCyclic f.ker] [hN : IsCyclic N] (hf : Function.Surjective f) : IsCyclic M := by
rw [← Subgroup.topEquiv.isCyclic, ← f.range_eq_top.mpr hf] at hN
rw [← Subgroup.card_top (G := N), ← f.range_eq_top.mpr hf] at h
exact isCyclic_of_coprime_card_range_card_ker f h
section
variable (M N : Type*) [Group M] [Group N] [cyc : IsCyclic (M × N)]
include M N
@[to_additive isAddCyclic_left_of_prod] theorem isCyclic_left_of_prod : IsCyclic M :=
isCyclic_of_surjective (MonoidHom.fst M N) Prod.fst_surjective
@[to_additive isAddCyclic_right_of_prod] theorem isCyclic_right_of_prod : IsCyclic N :=
isCyclic_of_surjective (MonoidHom.snd M N) Prod.snd_surjective
@[to_additive coprime_card_of_isAddCyclic_prod] theorem coprime_card_of_isCyclic_prod
[Finite M] [Finite N] : (Nat.card M).Coprime (Nat.card N) := by
have hM := isCyclic_left_of_prod M N
have hN := isCyclic_right_of_prod M N
let _ := cyc.commGroup; let _ := hM.commGroup; let _ := hN.commGroup
rw [IsCyclic.iff_exponent_eq_card, Monoid.exponent_prod, Nat.card_prod, lcm_eq_nat_lcm] at *
simpa only [hM, hN, Nat.lcm_eq_mul_iff, Nat.card_pos.ne', false_or] using cyc
end
theorem not_isAddCyclic_prod_of_infinite_nontrivial (M N : Type*) [AddGroup M] [AddGroup N]
[Infinite M] [Nontrivial N] : ¬ IsAddCyclic (M × N) := fun hMN ↦ by
rw [← ((zmodAddCyclicAddEquiv <| isAddCyclic_left_of_prod M N).prodCongr (zmodAddCyclicAddEquiv <|
isAddCyclic_right_of_prod M N)).isAddCyclic, Nat.card_eq_zero_of_infinite] at hMN
cases (finite_or_infinite N).symm
· rw [Nat.card_eq_zero_of_infinite] at hMN
let f := (ZMod.castHom (dvd_zero _) (ZMod 2)).toAddMonoidHom
have hf := ZMod.castHom_surjective (dvd_zero 2)
have := isAddCyclic_of_surjective (f.prodMap f) (Prod.map_surjective.mpr ⟨hf, hf⟩)
simpa using coprime_card_of_isAddCyclic_prod (ZMod 2) (ZMod 2)
let ZN := ZMod (Nat.card N)
have : NeZero (Nat.card N) := ⟨Nat.card_pos.ne'⟩
have := isAddCyclic_of_surjective ((ZMod.castHom (dvd_zero _) ZN).toAddMonoidHom.prodMap (.id ZN))
(Prod.map_surjective.mpr ⟨ZMod.castHom_surjective (dvd_zero _), Function.surjective_id⟩)
exact Finite.one_lt_card (α := N).ne' (by simpa [ZN] using coprime_card_of_isAddCyclic_prod ZN ZN)
@[to_additive existing not_isAddCyclic_prod_of_infinite_nontrivial]
theorem not_isCyclic_prod_of_infinite_nontrivial (M N : Type*) [Group M] [Group N]
[Infinite M] [Nontrivial N] : ¬ IsCyclic (M × N) := by
rw [← isAddCyclic_additive_iff, (AddEquiv.prodAdditive ..).isAddCyclic]
apply not_isAddCyclic_prod_of_infinite_nontrivial
/-- The product of two finite groups is cyclic iff
both of them are cyclic and their orders are coprime. -/
@[to_additive AddGroup.isAddCyclic_prod_iff /-- The product of two finite additive groups is cyclic
iff both of them are cyclic and their orders are coprime. -/]
theorem Group.isCyclic_prod_iff {M N : Type*} [Group M] [Group N] :
IsCyclic (M × N) ↔ IsCyclic M ∧ IsCyclic N ∧ (Nat.card M).Coprime (Nat.card N) := by
refine ⟨fun h ↦ ⟨isCyclic_left_of_prod M N, isCyclic_right_of_prod M N, ?_⟩, fun ⟨hM, hN, h⟩ ↦ ?_⟩
· cases (finite_or_infinite M).symm
· cases subsingleton_or_nontrivial N; · simp
exact (not_isCyclic_prod_of_infinite_nontrivial M N h).elim
cases (finite_or_infinite N).symm
· cases subsingleton_or_nontrivial M; · simp
rw [(MulEquiv.prodComm ..).isCyclic] at h
exact (not_isCyclic_prod_of_infinite_nontrivial N M h).elim
apply coprime_card_of_isCyclic_prod
· let f := MonoidHom.snd M N
let e : f.ker ≃* M := by
rw [MonoidHom.ker_snd]
exact ((Subgroup.prodEquiv ..).trans .prodUnique).trans Subgroup.topEquiv
let _ := hM.commGroup; let _ := hN.commGroup
rw [← e.isCyclic] at hM
rw [← Nat.card_congr e.toEquiv] at h
exact isCyclic_of_coprime_card_ker f h Prod.snd_surjective
end prod
section WithZero
instance (G : Type*) [Group G] [IsCyclic G] : IsCyclic (WithZero G)ˣ := by
apply isCyclic_of_injective (G := (WithZero G)ˣ) (WithZero.unitsWithZeroEquiv).toMonoidHom
apply Equiv.injective
end WithZero |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/ZGroup.lean | import Mathlib.FieldTheory.Finite.Basic
import Mathlib.GroupTheory.Abelianization.Finite
import Mathlib.GroupTheory.Nilpotent
import Mathlib.GroupTheory.SchurZassenhaus
import Mathlib.GroupTheory.SemidirectProduct
/-!
# Z-Groups
A Z-group is a group whose Sylow subgroups are all cyclic.
## Main definitions
* `IsZGroup G`: a predicate stating that all Sylow subgroups of `G` are cyclic.
## Main results
* `IsZGroup.isCyclic_abelianization`: a finite Z-group has cyclic abelianization.
* `IsZGroup.isCyclic_commutator`: a finite Z-group has cyclic commutator subgroup.
* `IsZGroup.coprime_commutator_index`: the commutator subgroup of a finite Z-group is a
Hall-subgroup (the commutator subgroup has cardinality coprime to its index).
* `isZGroup_iff_exists_mulEquiv`: a finite group `G` is a Z-group if and only if `G` is isomorphic
to a semidirect product of two cyclic subgroups of coprime order.
-/
variable (G G' G'' : Type*) [Group G] [Group G'] [Group G''] (f : G →* G') (f' : G' →* G'')
/-- A Z-group is a group whose Sylow subgroups are all cyclic. -/
@[mk_iff] class IsZGroup : Prop where
isZGroup : ∀ p : ℕ, p.Prime → ∀ P : Sylow p G, IsCyclic P
variable {G G' G'' f f'}
namespace IsZGroup
instance [IsCyclic G] : IsZGroup G :=
⟨inferInstance⟩
instance [IsZGroup G] {p : ℕ} [Fact p.Prime] (P : Sylow p G) : IsCyclic P :=
isZGroup p Fact.out P
theorem _root_.IsPGroup.isCyclic_of_isZGroup [IsZGroup G] {p : ℕ} [Fact p.Prime]
{P : Subgroup G} (hP : IsPGroup p P) : IsCyclic P := by
obtain ⟨Q, hQ⟩ := hP.exists_le_sylow
exact Subgroup.isCyclic_of_le hQ
theorem of_squarefree (hG : Squarefree (Nat.card G)) : IsZGroup G := by
have : Finite G := Nat.finite_of_card_ne_zero hG.ne_zero
refine ⟨fun p hp P ↦ ?_⟩
have := Fact.mk hp
obtain ⟨k, hk⟩ := P.2.exists_card_eq
exact isCyclic_of_card_dvd_prime ((hk ▸ hG.pow_dvd_of_pow_dvd) P.card_subgroup_dvd_card)
theorem of_injective [hG' : IsZGroup G'] (hf : Function.Injective f) : IsZGroup G := by
rw [isZGroup_iff] at hG' ⊢
intro p hp P
obtain ⟨Q, hQ⟩ := P.exists_comap_eq_of_injective hf
specialize hG' p hp Q
have h : Subgroup.map f P ≤ Q := hQ ▸ Subgroup.map_comap_le f ↑Q
have := isCyclic_of_surjective _ (Subgroup.subgroupOfEquivOfLe h).surjective
exact isCyclic_of_surjective _ (Subgroup.equivMapOfInjective P f hf).symm.surjective
instance [IsZGroup G] (H : Subgroup G) : IsZGroup H := of_injective H.subtype_injective
theorem of_surjective [Finite G] [hG : IsZGroup G] (hf : Function.Surjective f) : IsZGroup G' := by
rw [isZGroup_iff] at hG ⊢
intro p hp P
have := Fact.mk hp
obtain ⟨Q, rfl⟩ := Sylow.mapSurjective_surjective hf p P
specialize hG p hp Q
exact isCyclic_of_surjective _ (f.subgroupMap_surjective Q)
instance [Finite G] [IsZGroup G] (H : Subgroup G) [H.Normal] : IsZGroup (G ⧸ H) :=
of_surjective (QuotientGroup.mk'_surjective H)
section Solvable
variable (G) in
theorem commutator_lt [Finite G] [IsZGroup G] [Nontrivial G] : commutator G < ⊤ := by
let p := (Nat.card G).minFac
have hp : p.Prime := Nat.minFac_prime Finite.one_lt_card.ne'
have := Fact.mk hp
let P : Sylow p G := default
have hP := isZGroup p hp P
let f := MonoidHom.transferSylow P (hP.normalizer_le_centralizer rfl)
refine lt_of_le_of_lt (Abelianization.commutator_subset_ker f) ?_
have h := P.ne_bot_of_dvd_card (Nat.card G).minFac_dvd
contrapose! h
rw [← Subgroup.isComplement'_top_left, ← (not_lt_top_iff.mp h)]
exact hP.isComplement' rfl
instance [Finite G] [IsZGroup G] : IsSolvable G := by
rw [isSolvable_iff_commutator_lt]
intro H h
rw [← H.nontrivial_iff_ne_bot] at h
rw [← H.range_subtype, MonoidHom.range_eq_map, ← Subgroup.map_commutator,
Subgroup.map_subtype_lt_map_subtype]
exact commutator_lt H
end Solvable
section Nilpotent
variable (G) in
theorem exponent_eq_card [Finite G] [IsZGroup G] : Monoid.exponent G = Nat.card G := by
refine dvd_antisymm Group.exponent_dvd_nat_card ?_
rw [← Nat.factorization_prime_le_iff_dvd Nat.card_pos.ne' Monoid.exponent_ne_zero_of_finite]
intro p hp
have := Fact.mk hp
let P : Sylow p G := default
rw [← hp.pow_dvd_iff_le_factorization Monoid.exponent_ne_zero_of_finite,
← P.card_eq_multiplicity, ← (isZGroup p hp P).exponent_eq_card]
exact Monoid.exponent_dvd_of_monoidHom P.1.subtype P.1.subtype_injective
instance [Finite G] [IsZGroup G] [hG : Group.IsNilpotent G] : IsCyclic G := by
have (p : { x // x ∈ (Nat.card G).primeFactors }) : Fact p.1.Prime :=
⟨Nat.prime_of_mem_primeFactors p.2⟩
obtain ⟨ϕ⟩ := ((isNilpotent_of_finite_tfae (G := G)).out 0 4).mp hG
let _ : CommGroup G :=
⟨fun g h ↦ by rw [← ϕ.symm.injective.eq_iff, map_mul, mul_comm, ← map_mul]⟩
exact IsCyclic.of_exponent_eq_card (exponent_eq_card G)
/-- A finite Z-group has cyclic abelianization. -/
instance isCyclic_abelianization [Finite G] [IsZGroup G] : IsCyclic (Abelianization G) :=
let _ : IsZGroup (Abelianization G) := inferInstanceAs (IsZGroup (G ⧸ commutator G))
inferInstance
end Nilpotent
section Commutator
variable (G) in
/-- A finite Z-group has cyclic commutator subgroup. -/
theorem isCyclic_commutator [Finite G] [IsZGroup G] : IsCyclic (commutator G) := by
refine WellFoundedLT.induction (C := fun H ↦ IsCyclic (⁅H, H⁆ : Subgroup G)) (⊤ : Subgroup G) ?_
intro H hH
rcases eq_or_ne H ⊥ with rfl | h
· rw [Subgroup.commutator_bot_left]
infer_instance
· specialize hH ⁅H, H⁆ (IsSolvable.commutator_lt_of_ne_bot h)
replace hH : IsCyclic (⁅commutator H, commutator H⁆ : Subgroup H) := by
let f := Subgroup.equivMapOfInjective ⁅commutator H, commutator H⁆ _ H.subtype_injective
rw [Subgroup.map_commutator, Subgroup.map_subtype_commutator] at f
exact isCyclic_of_surjective f.symm f.symm.surjective
suffices IsCyclic (commutator H) by
let f := Subgroup.equivMapOfInjective (commutator H) _ H.subtype_injective
rw [Subgroup.map_subtype_commutator] at f
exact isCyclic_of_surjective f f.surjective
suffices h : commutator (commutator H) ≤ Subgroup.center (commutator H) by
rw [← Abelianization.ker_of (commutator H)] at h
let _ := commGroupOfCyclicCenterQuotient Abelianization.of h
infer_instance
suffices h : (commutator (commutator H)).map (commutator H).subtype ≤
Subgroup.centralizer (commutator H) by
simpa [SetLike.le_def, Subgroup.mem_center_iff, Subgroup.mem_centralizer_iff] using h
rw [Subgroup.map_subtype_commutator, Subgroup.le_centralizer_iff]
let _ := (hH.mulAutMulEquiv _).toMonoidHom.commGroupOfInjective (hH.mulAutMulEquiv _).injective
have h := Abelianization.commutator_subset_ker ⁅commutator H, commutator H⁆.normalizerMonoidHom
rwa [Subgroup.normalizerMonoidHom_ker, Subgroup.normalizer_eq_top,
← Subgroup.map_subtype_le_map_subtype, Subgroup.map_subtype_commutator,
Subgroup.map_subgroupOf_eq_of_le le_top] at h
end Commutator
end IsZGroup
section Hall
variable {p : ℕ} [Fact p.Prime]
namespace IsPGroup
/-- If a group `K` acts on a cyclic `p`-group `G` of coprime order, then the map `K × G → G`
defined by `(k, g) ↦ k • g * g⁻¹` is either trivial or surjective. -/
theorem smul_mul_inv_trivial_or_surjective [IsCyclic G] (hG : IsPGroup p G)
{K : Type*} [Group K] [MulDistribMulAction K G] (hGK : (Nat.card G).Coprime (Nat.card K)) :
(∀ g : G, ∀ k : K, k • g * g⁻¹ = 1) ∨ (∀ g : G, ∃ k : K, ∃ q : G, k • q * q⁻¹ = g) := by
by_cases hc : Nat.card G = 0
· rw [hc, Nat.coprime_zero_left, Nat.card_eq_one_iff_unique] at hGK
simp [← hGK.1.elim 1]
have := Nat.finite_of_card_ne_zero hc
let ϕ := MulDistribMulAction.toMonoidHomZModOfIsCyclic G K rfl
have h (g : G) (k : K) (n : ℤ) (h : ϕ k - 1 = n) : k • g * g⁻¹ = g ^ n := by
rw [sub_eq_iff_eq_add, ← Int.cast_one, ← Int.cast_add] at h
rw [MulDistribMulAction.toMonoidHomZModOfIsCyclic_apply rfl k g (n + 1) h,
zpow_add_one, mul_inv_cancel_right]
replace hG k : ϕ k = 1 ∨ IsUnit (ϕ k - 1) := by
obtain ⟨n, hn⟩ := hG.exists_card_eq
exact ZMod.eq_one_or_isUnit_sub_one hn (ϕ k)
(hGK.symm.coprime_dvd_left ((orderOf_map_dvd ϕ k).trans (orderOf_dvd_natCard k)))
rcases forall_or_exists_not (fun k : K ↦ ϕ k = 1) with hϕ | ⟨k, hk⟩
· exact Or.inl fun p k ↦ by rw [h p k 0 (by rw [hϕ, sub_self, Int.cast_zero]), zpow_zero]
· obtain ⟨⟨u, v, -, hvu⟩, hu : u = ϕ k - 1⟩ := (hG k).resolve_left hk
rw [← u.intCast_zmod_cast] at hu hvu
rw [← v.intCast_zmod_cast, ← Int.cast_mul, ← Int.cast_one, ZMod.intCast_eq_intCast_iff] at hvu
refine Or.inr fun p ↦ zpow_one p ▸ ⟨k, p ^ (v.cast : ℤ), ?_⟩
rw [h (p ^ v.cast) k u.cast hu.symm, ← zpow_mul, zpow_eq_zpow_iff_modEq]
exact hvu.of_dvd (Int.natCast_dvd_natCast.mpr (orderOf_dvd_natCard p))
/-- If a cyclic `p`-subgroup `P` acts by conjugation on a subgroup `K` of coprime order, then
either `⁅K, P⁆ = ⊥` or `⁅K, P⁆ = P`. -/
theorem commutator_eq_bot_or_commutator_eq_self {P K : Subgroup G} [IsCyclic P]
(hP : IsPGroup p P) (hKP : K ≤ P.normalizer) (hPK : (Nat.card P).Coprime (Nat.card K)) :
⁅K, P⁆ = ⊥ ∨ ⁅K, P⁆ = P := by
let _ := MulDistribMulAction.compHom P (P.normalizerMonoidHom.comp (Subgroup.inclusion hKP))
refine (smul_mul_inv_trivial_or_surjective hP hPK).imp (fun h ↦ ?_) fun h ↦ ?_
· rw [eq_bot_iff, Subgroup.commutator_le]
exact fun k hk g hg ↦ Subtype.ext_iff.mp (h ⟨g, hg⟩ ⟨k, hk⟩)
· rw [le_antisymm_iff, Subgroup.commutator_le]
refine ⟨fun k hk g hg ↦ P.mul_mem ((hKP hk g).mp hg) (P.inv_mem hg), fun g hg ↦ ?_⟩
obtain ⟨k, q, hkq⟩ := h ⟨g, hg⟩
rw [← Subtype.coe_mk g hg, ← hkq]
exact Subgroup.commutator_mem_commutator k.2 q.2
end IsPGroup
namespace Sylow
variable [Finite G] (P : Sylow p G) [IsCyclic P]
/-- If a normal cyclic Sylow `p`-subgroup `P` has a complement `K`, then either `⁅K, P⁆ = ⊥` or
`⁅K, P⁆ = P`. -/
theorem commutator_eq_bot_or_commutator_eq_self [P.Normal] {K : Subgroup G}
(h : K.IsComplement' P) : ⁅K, P.1⁆ = ⊥ ∨ ⁅K, P.1⁆ = P :=
P.2.commutator_eq_bot_or_commutator_eq_self (P.normalizer_eq_top ▸ le_top)
(h.index_eq_card ▸ P.card_coprime_index)
/-- A normal cyclic Sylow subgroup is either central or contained in the commutator subgroup. -/
theorem le_center_or_le_commutator [P.Normal] : P ≤ Subgroup.center G ∨ P ≤ commutator G := by
obtain ⟨K, hK⟩ := Subgroup.exists_left_complement'_of_coprime P.card_coprime_index
refine (commutator_eq_bot_or_commutator_eq_self P hK).imp (fun h ↦ ?_) (fun h ↦ ?_)
· replace h := sup_le (Subgroup.commutator_eq_bot_iff_le_centralizer.mp h) P.le_centralizer
rwa [hK.sup_eq_top, top_le_iff, Subgroup.centralizer_eq_top_iff_subset] at h
· rw [← h, commutator_def]
exact Subgroup.commutator_mono le_top le_top
/-- A cyclic Sylow subgroup is either central in its normalizer or contained in the commutator
subgroup. -/
theorem normalizer_le_centralizer_or_le_commutator :
P.normalizer ≤ Subgroup.centralizer P ∨ P ≤ commutator G := by
let Q : Sylow p P.normalizer := P.subtype P.le_normalizer
have : Q.Normal := P.normal_in_normalizer
have : IsCyclic Q :=
isCyclic_of_surjective _ (Subgroup.subgroupOfEquivOfLe P.le_normalizer).symm.surjective
refine (le_center_or_le_commutator Q).imp (fun h ↦ ?_) (fun h ↦ ?_)
· rw [← SetLike.coe_subset_coe, ← Subgroup.centralizer_eq_top_iff_subset, eq_top_iff,
← Subgroup.map_subtype_le_map_subtype, ← MonoidHom.range_eq_map,
P.normalizer.range_subtype] at h
replace h := h.trans (Subgroup.map_centralizer_le_centralizer_image _ _)
rwa [← Subgroup.coe_map, P.coe_subtype, Subgroup.map_subgroupOf_eq_of_le P.le_normalizer] at h
· rw [P.coe_subtype, ← Subgroup.map_subtype_le_map_subtype,
Subgroup.map_subgroupOf_eq_of_le P.le_normalizer, Subgroup.map_subtype_commutator] at h
exact h.trans (Subgroup.commutator_mono le_top le_top)
include P in
/-- If `G` has a cyclic Sylow `p`-subgroup, then the cardinality and index of the commutator
subgroup of `G` cannot both be divisible by `p`. -/
theorem not_dvd_card_commutator_or_not_dvd_index_commutator :
¬ p ∣ Nat.card (commutator G) ∨ ¬ p ∣ (commutator G).index := by
refine (normalizer_le_centralizer_or_le_commutator P).imp ?_ ?_ <;>
refine fun hP h ↦ P.not_dvd_index (h.trans ?_)
· rw [(MonoidHom.ker_transferSylow_isComplement' P hP).index_eq_card]
exact Subgroup.card_dvd_of_le (Abelianization.commutator_subset_ker _)
· exact Subgroup.index_dvd_of_le hP
end Sylow
variable (G) in
/-- If `G` is a finite Z-group, then `commutator G` is a Hall subgroup of `G`. -/
theorem IsZGroup.coprime_commutator_index [Finite G] [IsZGroup G] :
(Nat.card (commutator G)).Coprime (commutator G).index := by
suffices h : ∀ p, p.Prime → (¬ p ∣ Nat.card (commutator G) ∨ ¬ p ∣ (commutator G).index) by
contrapose! h
exact Nat.Prime.not_coprime_iff_dvd.mp h
intro p hp
have := Fact.mk hp
exact Sylow.not_dvd_card_commutator_or_not_dvd_index_commutator default
end Hall
section Classification
/-- An extension of coprime Z-groups is a Z-group. -/
theorem isZGroup_of_coprime [Finite G] [IsZGroup G] [IsZGroup G'']
(h_le : f'.ker ≤ f.range) (h_cop : (Nat.card G).Coprime (Nat.card G'')) :
IsZGroup G' := by
refine ⟨fun p hp P ↦ ?_⟩
have := Fact.mk hp
replace h_cop := (h_cop.of_dvd ((Subgroup.card_dvd_of_le h_le).trans
(Subgroup.card_range_dvd f)) (Subgroup.index_ker f' ▸ f'.range.card_subgroup_dvd_card))
rcases P.2.le_or_disjoint_of_coprime h_cop with h | h
· replace h_le : P ≤ f.range := h.trans h_le
suffices IsCyclic (P.subgroupOf f.range) by
have key := Subgroup.subgroupOfEquivOfLe h_le
exact isCyclic_of_surjective key key.surjective
obtain ⟨Q, hQ⟩ := Sylow.mapSurjective_surjective f.rangeRestrict_surjective p (P.subtype h_le)
rw [Sylow.ext_iff, Sylow.coe_mapSurjective, Sylow.coe_subtype] at hQ
exact hQ ▸ isCyclic_of_surjective _ (f.rangeRestrict.subgroupMap_surjective Q)
· have := (P.2.map f').isCyclic_of_isZGroup
apply isCyclic_of_injective (f'.subgroupMap P)
rwa [← MonoidHom.ker_eq_bot_iff, P.ker_subgroupMap f', Subgroup.subgroupOf_eq_bot]
/-- A finite group `G` is a Z-group if and only if `G` is isomorphic to a semidirect product of two
cyclic subgroups of coprime order. -/
theorem isZGroup_iff_exists_mulEquiv [Finite G] :
IsZGroup G ↔ ∃ (N H : Subgroup G) (φ : H →* MulAut N) (_ : G ≃* N ⋊[φ] H),
IsCyclic H ∧ IsCyclic N ∧ (Nat.card N).Coprime (Nat.card H) := by
refine ⟨fun hG ↦ ?_, ?_⟩
· obtain ⟨H, hH⟩ := Subgroup.exists_right_complement'_of_coprime hG.coprime_commutator_index
have h1 : Abelianization G ≃* H := hH.symm.QuotientMulEquiv
refine ⟨commutator G, H, _, (SemidirectProduct.mulEquivSubgroup hH).symm,
isCyclic_of_surjective _ h1.surjective, hG.isCyclic_commutator, ?_⟩
exact Nat.card_congr h1.toEquiv ▸ hG.coprime_commutator_index
· rintro ⟨N, H, φ, e, hH, hN, hHN⟩
have : IsZGroup (N ⋊[φ] H) :=
isZGroup_of_coprime SemidirectProduct.range_inl_eq_ker_rightHom.ge hHN
exact IsZGroup.of_injective (f := e.toMonoidHom) e.injective
end Classification |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean | import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.GroupTheory.SpecificGroups.Dihedral
/-!
# Quaternion Groups
We define the (generalised) quaternion groups `QuaternionGroup n` of order `4n`, also known as
dicyclic groups, with elements `a i` and `xa i` for `i : ZMod n`. The (generalised) quaternion
groups can be defined by the presentation
$\langle a, x | a^{2n} = 1, x^2 = a^n, x^{-1}ax=a^{-1}\rangle$. We write `a i` for
$a^i$ and `xa i` for $x * a^i$. For `n=2` the quaternion group `QuaternionGroup 2` is isomorphic to
the unit integral quaternions `(Quaternion ℤ)ˣ`.
## Main definition
`QuaternionGroup n`: The (generalised) quaternion group of order `4n`.
## Implementation notes
This file is heavily based on `DihedralGroup` by Shing Tak Lam.
In mathematics, the name "quaternion group" is reserved for the cases `n ≥ 2`. Since it would be
inconvenient to carry around this condition we define `QuaternionGroup` also for `n = 0` and
`n = 1`. `QuaternionGroup 0` is isomorphic to the infinite dihedral group, while
`QuaternionGroup 1` is isomorphic to a cyclic group of order `4`.
## References
* https://en.wikipedia.org/wiki/Dicyclic_group
* https://en.wikipedia.org/wiki/Quaternion_group
## TODO
Show that `QuaternionGroup 2 ≃* (Quaternion ℤ)ˣ`.
-/
/-- The (generalised) quaternion group `QuaternionGroup n` of order `4n`. It can be defined by the
presentation $\langle a, x | a^{2n} = 1, x^2 = a^n, x^{-1}ax=a^{-1}\rangle$. We write `a i` for
$a^i$ and `xa i` for $x * a^i$.
-/
inductive QuaternionGroup (n : ℕ) : Type
| a : ZMod (2 * n) → QuaternionGroup n
| xa : ZMod (2 * n) → QuaternionGroup n
deriving DecidableEq
namespace QuaternionGroup
variable {n : ℕ}
/-- Multiplication of the dihedral group.
-/
private def mul : QuaternionGroup n → QuaternionGroup n → QuaternionGroup n
| a i, a j => a (i + j)
| a i, xa j => xa (j - i)
| xa i, a j => xa (i + j)
| xa i, xa j => a (n + j - i)
/-- The identity `1` is given by `aⁱ`.
-/
private def one : QuaternionGroup n :=
a 0
instance : Inhabited (QuaternionGroup n) :=
⟨one⟩
/-- The inverse of an element of the quaternion group.
-/
private def inv : QuaternionGroup n → QuaternionGroup n
| a i => a (-i)
| xa i => xa (n + i)
/-- The group structure on `QuaternionGroup n`.
-/
instance : Group (QuaternionGroup n) where
mul := mul
mul_assoc := by
rintro (i | i) (j | j) (k | k) <;> simp only [(· * ·), mul] <;> ring_nf
congr
calc
-(n : ZMod (2 * n)) = 0 - n := by rw [zero_sub]
_ = 2 * n - n := by norm_cast; simp
_ = n := by ring
one := one
one_mul := by
rintro (i | i)
· exact congr_arg a (zero_add i)
· exact congr_arg xa (sub_zero i)
mul_one := by
rintro (i | i)
· exact congr_arg a (add_zero i)
· exact congr_arg xa (add_zero i)
inv := inv
inv_mul_cancel := by
rintro (i | i)
· exact congr_arg a (neg_add_cancel i)
· exact congr_arg a (sub_self (n + i))
@[simp]
theorem a_mul_a (i j : ZMod (2 * n)) : a i * a j = a (i + j) :=
rfl
@[simp]
theorem a_mul_xa (i j : ZMod (2 * n)) : a i * xa j = xa (j - i) :=
rfl
@[simp]
theorem xa_mul_a (i j : ZMod (2 * n)) : xa i * a j = xa (i + j) :=
rfl
@[simp]
theorem xa_mul_xa (i j : ZMod (2 * n)) : xa i * xa j = a ((n : ZMod (2 * n)) + j - i) :=
rfl
@[simp]
theorem a_zero : a 0 = (1 : QuaternionGroup n) := by
rfl
theorem one_def : (1 : QuaternionGroup n) = a 0 :=
rfl
private def fintypeHelper : ZMod (2 * n) ⊕ ZMod (2 * n) ≃ QuaternionGroup n where
invFun i :=
match i with
| a j => Sum.inl j
| xa j => Sum.inr j
toFun i :=
match i with
| Sum.inl j => a j
| Sum.inr j => xa j
left_inv := by rintro (x | x) <;> rfl
right_inv := by rintro (x | x) <;> rfl
/-- The special case that more or less by definition `QuaternionGroup 0` is isomorphic to the
infinite dihedral group. -/
def quaternionGroupZeroEquivDihedralGroupZero : QuaternionGroup 0 ≃* DihedralGroup 0 where
toFun
| a j => DihedralGroup.r j
| xa j => DihedralGroup.sr j
invFun
| DihedralGroup.r j => a j
| DihedralGroup.sr j => xa j
left_inv := by rintro (k | k) <;> rfl
right_inv := by rintro (k | k) <;> rfl
map_mul' := by rintro (k | k) (l | l) <;> simp
/-- If `0 < n`, then `QuaternionGroup n` is a finite group.
-/
instance [NeZero n] : Fintype (QuaternionGroup n) :=
Fintype.ofEquiv _ fintypeHelper
instance : Nontrivial (QuaternionGroup n) :=
⟨⟨a 0, xa 0, by simp [- a_zero]⟩⟩
/-- If `0 < n`, then `QuaternionGroup n` has `4n` elements.
-/
theorem card [NeZero n] : Fintype.card (QuaternionGroup n) = 4 * n := by
rw [← Fintype.card_eq.mpr ⟨fintypeHelper⟩, Fintype.card_sum, ZMod.card, two_mul]
ring
@[simp]
theorem a_one_pow (k : ℕ) : (a 1 : QuaternionGroup n) ^ k = a k := by
induction k with
| zero => rw [Nat.cast_zero]; rfl
| succ k IH =>
rw [pow_succ, IH, a_mul_a]
congr 1
norm_cast
theorem a_one_pow_n : (a 1 : QuaternionGroup n) ^ (2 * n) = 1 := by
simp
@[simp]
theorem xa_sq (i : ZMod (2 * n)) : xa i ^ 2 = a n := by simp [sq]
@[simp]
theorem xa_pow_four (i : ZMod (2 * n)) : xa i ^ 4 = 1 := by
calc xa i ^ 4
= a (n + n) := by simp [pow_succ, add_sub_assoc, sub_sub_cancel]
_ = a ↑(2 * n) := by simp [Nat.cast_add, two_mul]
_ = 1 := by simp
/-- If `0 < n`, then `xa i` has order 4.
-/
@[simp]
theorem orderOf_xa [NeZero n] (i : ZMod (2 * n)) : orderOf (xa i) = 4 := by
change _ = 2 ^ 2
haveI : Fact (Nat.Prime 2) := Fact.mk Nat.prime_two
apply orderOf_eq_prime_pow
· intro h
simp only [pow_one, xa_sq] at h
injection h with h'
apply_fun ZMod.val at h'
apply_fun (· / n) at h'
simp only [ZMod.val_natCast, ZMod.val_zero, Nat.zero_div, Nat.mod_mul_left_div_self,
Nat.div_self (NeZero.pos n), reduceCtorEq] at h'
· simp
/-- In the special case `n = 1`, `Quaternion 1` is a cyclic group (of order `4`). -/
theorem quaternionGroup_one_isCyclic : IsCyclic (QuaternionGroup 1) := by
apply isCyclic_of_orderOf_eq_card
· rw [Nat.card_eq_fintype_card, card, mul_one]
exact orderOf_xa 0
/-- If `0 < n`, then `a 1` has order `2 * n`.
-/
@[simp]
theorem orderOf_a_one : orderOf (a 1 : QuaternionGroup n) = 2 * n := by
rcases eq_zero_or_neZero n with hn | hn
· subst hn
simp_rw [mul_zero, orderOf_eq_zero_iff']
intro n h
rw [one_def, a_one_pow]
apply mt a.inj
haveI : CharZero (ZMod (2 * 0)) := ZMod.charZero
simpa using h.ne'
apply (Nat.le_of_dvd
(NeZero.pos _) (orderOf_dvd_of_pow_eq_one (@a_one_pow_n n))).lt_or_eq.resolve_left
intro h
have h1 : (a 1 : QuaternionGroup n) ^ orderOf (a 1) = 1 := pow_orderOf_eq_one _
rw [a_one_pow] at h1
injection h1 with h2
rw [← ZMod.val_eq_zero, ZMod.val_natCast, Nat.mod_eq_of_lt h] at h2
exact absurd h2.symm (orderOf_pos _).ne
/-- If `0 < n`, then `a i` has order `(2 * n) / gcd (2 * n) i`.
-/
theorem orderOf_a [NeZero n] (i : ZMod (2 * n)) :
orderOf (a i) = 2 * n / Nat.gcd (2 * n) i.val := by
conv_lhs => rw [← ZMod.natCast_zmod_val i]
rw [← a_one_pow, orderOf_pow, orderOf_a_one]
theorem exponent : Monoid.exponent (QuaternionGroup n) = 2 * lcm n 2 := by
rw [← normalize_eq 2, ← lcm_mul_left, normalize_eq]
norm_num
rcases eq_zero_or_neZero n with hn | hn
· subst hn
simp only [lcm_zero_left, mul_zero]
exact Monoid.exponent_eq_zero_of_order_zero orderOf_a_one
apply Nat.dvd_antisymm
· apply Monoid.exponent_dvd_of_forall_pow_eq_one
rintro (m | m)
· rw [← orderOf_dvd_iff_pow_eq_one, orderOf_a]
refine Nat.dvd_trans ⟨gcd (2 * n) m.val, ?_⟩ (dvd_lcm_left (2 * n) 4)
exact (Nat.div_mul_cancel (Nat.gcd_dvd_left (2 * n) m.val)).symm
· rw [← orderOf_dvd_iff_pow_eq_one, orderOf_xa]
exact dvd_lcm_right (2 * n) 4
· apply lcm_dvd
· convert Monoid.order_dvd_exponent (a 1)
exact orderOf_a_one.symm
· convert Monoid.order_dvd_exponent (xa (0 : ZMod (2 * n)))
exact (orderOf_xa 0).symm
end QuaternionGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/KleinFour.lean | import Mathlib.GroupTheory.SpecificGroups.Cyclic
/-!
# Klein Four Group
The Klein (Vierergruppe) four-group is a non-cyclic abelian group with four elements, in which
each element is self-inverse and in which composing any two of the three non-identity elements
produces the third one.
## Main definitions
* `IsKleinFour` : A mixin class which states that the group has order four and exponent two.
* `mulEquiv'` : An equivalence between a Klein four-group and a group of exponent two which
preserves the identity is in fact an isomorphism.
* `mulEquiv`: Any two Klein four-groups are isomorphic via any identity-preserving equivalence.
## References
* https://en.wikipedia.org/wiki/Klein_four-group
* https://en.wikipedia.org/wiki/Alternating_group
## TODO
* Prove an `IsKleinFour` group is isomorphic to the normal subgroup of `alternatingGroup (Fin 4)`
with the permutation cycles `V = {(), (1 2)(3 4), (1 3)(2 4), (1 4)(2 3)}`. This is the kernel
of the surjection of `alternatingGroup (Fin 4)` onto `alternatingGroup (Fin 3) ≃ (ZMod 3)`.
In other words, we have the exact sequence `V → A₄ → A₃`.
* The outer automorphism group of `A₆` is the Klein four-group `V = (ZMod 2) × (ZMod 2)`,
and is related to the outer automorphism of `S₆`. The extra outer automorphism in `A₆`
swaps the 3-cycles (like `(1 2 3)`) with elements of shape `3²` (like `(1 2 3)(4 5 6)`).
## Tags
non-cyclic abelian group
-/
/-! ### Klein four-groups as a mixin class -/
/-- An (additive) Klein four-group is an (additive) group of cardinality four and exponent two. -/
class IsAddKleinFour (G : Type*) [AddGroup G] : Prop where
card_four : Nat.card G = 4
exponent_two : AddMonoid.exponent G = 2
/-- A Klein four-group is a group of cardinality four and exponent two. -/
@[to_additive existing IsAddKleinFour]
class IsKleinFour (G : Type*) [Group G] : Prop where
card_four : Nat.card G = 4
exponent_two : Monoid.exponent G = 2
attribute [simp] IsKleinFour.card_four IsKleinFour.exponent_two
IsAddKleinFour.card_four IsAddKleinFour.exponent_two
instance : IsAddKleinFour (ZMod 2 × ZMod 2) where
card_four := by simp
exponent_two := by simp [AddMonoid.exponent_prod]
instance {G : Type*} [Group G] [IsKleinFour G] : IsAddKleinFour (Additive G) where
card_four := by rw [← IsKleinFour.card_four (G := G)]; congr!
exponent_two := by simp
instance {G : Type*} [AddGroup G] [IsAddKleinFour G] : IsKleinFour (Multiplicative G) where
card_four := by rw [← IsAddKleinFour.card_four (G := G)]; congr!
exponent_two := by simp
namespace IsKleinFour
/-- This instance is scoped, because it always applies (which makes linting and typeclass inference
potentially *a lot* slower). -/
@[to_additive]
scoped instance instFinite {G : Type*} [Group G] [IsKleinFour G] : Finite G :=
Nat.finite_of_card_ne_zero <| by simp [IsKleinFour.card_four]
@[to_additive (attr := simp)]
lemma card_four' {G : Type*} [Group G] [Fintype G] [IsKleinFour G] :
Fintype.card G = 4 :=
Nat.card_eq_fintype_card (α := G).symm ▸ IsKleinFour.card_four
open Finset
variable {G : Type*} [Group G] [IsKleinFour G]
@[to_additive]
lemma not_isCyclic : ¬IsCyclic G :=
fun h ↦ by simpa using h.exponent_eq_card
@[to_additive]
lemma inv_eq_self (x : G) : x⁻¹ = x := inv_eq_self_of_exponent_two (by simp) x
/- this is not an appropriate global `simp` lemma for a `Prop`-mixin class. Indeed, if it were
then every time Lean sees `·⁻¹` it would try to apply `inv_eq_self` which would trigger
type class inference to try and synthesize an `IsKleinFour` instance. -/
scoped[IsKleinFour] attribute [simp] inv_eq_self
scoped[IsAddKleinFour] attribute [simp] neg_eq_self
@[to_additive]
lemma mul_self (x : G) : x * x = 1 := by
rw [mul_eq_one_iff_eq_inv, inv_eq_self]
@[to_additive]
lemma eq_finset_univ [Fintype G] [DecidableEq G]
{x y : G} (hx : x ≠ 1) (hy : y ≠ 1) (hxy : x ≠ y) : {x * y, x, y, (1 : G)} = Finset.univ := by
apply Finset.eq_univ_of_card
rw [card_four']
repeat rw [card_insert_of_notMem]
on_goal 4 => simpa using mul_notMem_of_exponent_two (by simp) hx hy hxy
all_goals simp_all
@[to_additive]
lemma eq_mul_of_ne_all {x y z : G} (hx : x ≠ 1)
(hy : y ≠ 1) (hxy : x ≠ y) (hz : z ≠ 1) (hzx : z ≠ x) (hzy : z ≠ y) : z = x * y := by
classical
let _ := Fintype.ofFinite G
apply eq_of_mem_insert_of_notMem <| (eq_finset_univ hx hy hxy).symm ▸ mem_univ _
simpa only [mem_singleton, mem_insert, not_or] using ⟨hzx, hzy, hz⟩
variable {G₁ G₂ : Type*} [Group G₁] [Group G₂] [IsKleinFour G₁]
/-- An equivalence between an `IsKleinFour` group `G₁` and a group `G₂` of exponent two which sends
`1 : G₁` to `1 : G₂` is in fact an isomorphism. -/
@[to_additive /-- An equivalence between an `IsAddKleinFour` group `G₁` and a group `G₂` of exponent
two which sends `0 : G₁` to `0 : G₂` is in fact an isomorphism. -/]
def mulEquiv' (e : G₁ ≃ G₂) (he : e 1 = 1) (h : Monoid.exponent G₂ = 2) : G₁ ≃* G₂ where
toEquiv := e
map_mul' := by
let _inst₁ := Fintype.ofFinite G₁
let _inst₂ := Fintype.ofEquiv G₁ e
intro x y
by_cases hx : x = 1 <;> by_cases hy : y = 1
all_goals try simp only [hx, hy, mul_one, one_mul, Equiv.toFun_as_coe, he]
by_cases hxy : x = y
· simp [hxy, mul_self, ← pow_two (e y), h ▸ Monoid.pow_exponent_eq_one (e y), he]
· classical
have univ₂ : {e (x * y), e x, e y, (1 : G₂)} = Finset.univ := by
simpa [map_univ_equiv e, map_insert, he]
using congr(Finset.map e.toEmbedding $(eq_finset_univ hx hy hxy))
rw [← Ne, ← e.injective.ne_iff] at hx hy hxy
rw [he] at hx hy
symm
apply eq_of_mem_insert_of_notMem <| univ₂.symm ▸ mem_univ _
simpa using mul_notMem_of_exponent_two h hx hy hxy
/-- Any two `IsKleinFour` groups are isomorphic via any equivalence which sends the identity of one
group to the identity of the other. -/
@[to_additive /-- Any two `IsAddKleinFour` groups are isomorphic via any
equivalence which sends the identity of one group to the identity of the other. -/]
abbrev mulEquiv [IsKleinFour G₂] (e : G₁ ≃ G₂) (he : e 1 = 1) : G₁ ≃* G₂ :=
mulEquiv' e he exponent_two
/-- Any two `IsKleinFour` groups are isomorphic. -/
@[to_additive /-- Any two `IsAddKleinFour` groups are isomorphic. -/]
lemma nonempty_mulEquiv [IsKleinFour G₂] : Nonempty (G₁ ≃* G₂) := by
classical
let _inst₁ := Fintype.ofFinite G₁
let _inst₁ := Fintype.ofFinite G₂
exact ⟨mulEquiv ((Fintype.equivOfCardEq <| by simp).setValue 1 1) <| by simp⟩
end IsKleinFour |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/Alternating/KleinFour.lean | import Mathlib.GroupTheory.SpecificGroups.Alternating.Centralizer
import Mathlib.GroupTheory.SpecificGroups.KleinFour
import Mathlib.GroupTheory.Sylow
/-! # The Klein Four subgroup of an alternating group on 4 letters
Let `α` be a finite type such that `Nat.card α = 4`.
* `alternatingGroup.kleinFour` : the subgroup of `alternatingGroup α` generated by permutations of
cycle type (2, 2).
## Main results
* `alternatingGroup.kleinFour_isKleinFour`: `alternatingGroup.kleinFour α` satisfies `IsKleinFour`.
(When `4 < Nat.card α`, it is equal to `⊤`, when `Nat.card α < 4`, it is trivial.)
* `alternatingGroup.two_sylow_eq_kleinFour_of_card_eq_four`:
All `2`-sylow subgroups of `alternatingGroup α` are equal to `kleinFour α`.
* `alternatingGroup.characteristic_kleinFour`:
the subgroup `alternatingGroup.kleinFour α` is characteristic.
* `alternatingGroup.kleinFour_eq_commutator`:
the subgroup `alternatingGroup.kleinFour α` is the commutator subgroup of `alternatingGroup α`.
(When `4 < Nat.card α`, the commutator subgroup of `alternatingGroup α` is equal to `⊤`;
when `Nat.card α < 3`, it is trivial.)
## Remark on implementation
We start from `alternatingGroup.kleinFour α` as given by its definition.
We first prove that it is equal to any 2-sylow subgroup:
the elements of such a sylow subgroup `S` have order a power of 2,
and this implies that their cycle type is () or (2,2).
Since there are exactly 4 elements of that cycle type,
we conclude that `alternatingGroup.kleinFour α = S`.
Since all 2-sylow subgroups are conjugate, we conclude
that there is only one 2-sylow subgroup and that it is normal,
and then characteristic.
## TODO :
Prove `alternatingGroup.kleinFour α = commutator (alternatingGroup α)`
without any assumption on `Nat.card α`.
-/
namespace alternatingGroup
open Equiv.Perm Equiv
variable {α : Type*} [DecidableEq α] [Fintype α]
variable (α) in
/-- The subgroup of `alternatingGroup α` generated by permutations of cycle type (2, 2).
When `Nat.card α = 4`, it will effectively be of Klein Four type. -/
def kleinFour : Subgroup (alternatingGroup α) :=
Subgroup.closure {g : alternatingGroup α | (g : Equiv.Perm α).cycleType = {2, 2}}
theorem mem_kleinFour_of_order_two_pow (hα4 : Nat.card α = 4) {g : Perm α}
(hg0 : g ∈ alternatingGroup α) {n : ℕ} (hg : orderOf g ∣ 2 ^ n) :
g.cycleType = { } ∨ g.cycleType = {2, 2} := by
rw [mem_alternatingGroup, sign_of_cycleType] at hg0
have h1 : g.cycleType.sum ≤ 4 := by
rw [sum_cycleType, ← hα4, Nat.card_eq_fintype_card]
exact g.support.card_le_univ
have h2 : ∀ k ∈ g.cycleType, k = 2 := by
intro k hk
have hk4 := (Multiset.le_sum_of_mem hk).trans h1
have hk1 := one_lt_of_mem_cycleType hk
interval_cases k
· rfl
· rw [← lcm_cycleType, Multiset.lcm_dvd] at hg
exact Nat.prime_eq_prime_of_dvd_pow Nat.prime_three Nat.prime_two (hg 3 hk)
· contrapose! hg0
obtain ⟨t, ht⟩ := Multiset.exists_cons_of_mem hk
rw [ht, Multiset.sum_cons, add_le_iff_nonpos_right, le_zero_iff,
Multiset.sum_eq_zero_iff, ← Multiset.eq_replicate_card] at h1
have h : 0 ∉ g.cycleType := Nat.not_succ_lt_self ∘ one_lt_of_mem_cycleType
replace h : t = 0 := by simpa [h1 ▸ ht, Multiset.mem_replicate] using h
simp [ht, h, Units.ext_iff]
rw [← Multiset.eq_replicate_card] at h2
rw [h2, Multiset.sum_replicate, smul_eq_mul, ← Nat.le_div_iff_mul_le two_pos] at h1
interval_cases g.cycleType.card <;> simp [h2, Units.ext_iff] at hg0 ⊢
theorem card_of_card_eq_four (hα4 : Nat.card α = 4) :
Nat.card (alternatingGroup α) = 12 := by
have : Nontrivial α := by
rw [← Finite.one_lt_card_iff_nontrivial, hα4]
simp
rw [nat_card_alternatingGroup, hα4]
decide
theorem card_two_sylow_of_card_eq_four (hα4 : Nat.card α = 4) (S : Sylow 2 (alternatingGroup α)) :
Nat.card S = 4 := by
rw [Sylow.card_eq_multiplicity, card_of_card_eq_four hα4]
have : 12 = 2 ^ 2 * 3 := by simp
rw [this, Nat.factorization_mul_apply_of_coprime (by decide), Nat.factorization_pow,
Finsupp.coe_smul, Pi.smul_apply, smul_eq_mul, Nat.prime_two.factorization_self,
Nat.factorization_eq_zero_of_not_dvd (by decide)]
simp
theorem coe_two_sylow_of_card_eq_four
(hα4 : Nat.card α = 4) (S : Sylow 2 (alternatingGroup α)) :
(S : Set (alternatingGroup α)) =
{1} ∪ {g : alternatingGroup α | (g : Perm α).cycleType = {2, 2}} := by
classical
refine Set.eq_of_subset_of_card_le (fun k hk ↦ ?_) ?_
· -- inclusion S ⊆ {1} ∪ {g | cycleType g = { 2, 2 }}
obtain ⟨n, hn⟩ := (IsPGroup.iff_orderOf.mp S.isPGroup') ⟨k, hk⟩
replace hn : (orderOf (k : Perm α)) = 2 ^ n := by simpa using hn
convert mem_kleinFour_of_order_two_pow hα4 k.2 hn.dvd
simp
· -- card (kleinFour α) ≤ card S
simp_rw [← Nat.card_eq_fintype_card]
refine (card_two_sylow_of_card_eq_four hα4 S).symm.trans_ge ?_
rw [Nat.card_eq_card_toFinset, Set.toFinset_union, Set.toFinset_singleton, Set.toFinset_setOf]
apply (Finset.card_union_le _ _).trans
rw [Finset.card_singleton, AlternatingGroup.card_of_cycleType, ← Nat.card_eq_fintype_card, hα4]
decide
theorem two_sylow_eq_kleinFour_of_card_eq_four
(hα4 : Nat.card α = 4) (S : Sylow 2 (alternatingGroup α)) :
S = kleinFour α := by
rw [kleinFour, ← Subgroup.closure_insert_one,
← Set.singleton_union, ← coe_two_sylow_of_card_eq_four hα4]
exact S.closure_eq.symm
theorem subsingleton_two_sylow (hα4 : Nat.card α = 4) :
Subsingleton (Sylow 2 (alternatingGroup α)) where
allEq S T := by
rw [Sylow.ext_iff]
simp [two_sylow_eq_kleinFour_of_card_eq_four hα4]
theorem characteristic_kleinFour (hα4 : Nat.card α = 4) :
(kleinFour α).Characteristic := by
obtain ⟨S : Sylow 2 (alternatingGroup α)⟩ := Sylow.nonempty (G := alternatingGroup α)
have _ := subsingleton_two_sylow hα4
rw [← two_sylow_eq_kleinFour_of_card_eq_four hα4 S]
exact Sylow.characteristic_of_subsingleton _
theorem normal_kleinFour (hα4 : Nat.card α = 4) :
(kleinFour α).Normal := by
have _ := characteristic_kleinFour hα4
apply Subgroup.normal_of_characteristic
theorem kleinFour_card_of_card_eq_four (hα4 : Nat.card α = 4) :
Nat.card (kleinFour α) = 4 := by
obtain ⟨S : Sylow 2 (alternatingGroup α)⟩ := Sylow.nonempty (G := alternatingGroup α)
rw [← two_sylow_eq_kleinFour_of_card_eq_four hα4 S, card_two_sylow_of_card_eq_four hα4 S]
theorem coe_kleinFour_of_card_eq_four (hα4 : Nat.card α = 4) :
(kleinFour α : Set (alternatingGroup α)) =
{1} ∪ {g : alternatingGroup α | (g : Equiv.Perm α).cycleType = {2, 2}} := by
obtain ⟨S : Sylow 2 (alternatingGroup α)⟩ := Sylow.nonempty (G := alternatingGroup α)
rw [← two_sylow_eq_kleinFour_of_card_eq_four hα4 S]
exact coe_two_sylow_of_card_eq_four hα4 S
theorem exponent_kleinFour_of_card_eq_four (hα4 : Nat.card α = 4) :
Monoid.exponent (kleinFour α) = 2 := by
have : Monoid.exponent (kleinFour α) ∣ 2 := by
rw [Monoid.exponent_dvd]
rintro ⟨⟨g, hg⟩, hg'⟩
simp only [Subgroup.orderOf_mk, orderOf_dvd_iff_pow_eq_one]
rw [← SetLike.mem_coe, coe_kleinFour_of_card_eq_four hα4] at hg'
rcases hg' with hg' | hg'
· convert one_pow _
simpa only [Set.mem_singleton_iff, Subgroup.mk_eq_one] using hg'
· convert pow_orderOf_eq_one g
rw [← Equiv.Perm.lcm_cycleType, hg']
simp
rw [Nat.dvd_prime Nat.prime_two] at this
apply Or.resolve_left this
rw [Monoid.exp_eq_one_iff, ← Finite.card_le_one_iff_subsingleton,
kleinFour_card_of_card_eq_four hα4]
decide
theorem kleinFour_isKleinFour (hα4 : Nat.card α = 4) :
IsKleinFour (kleinFour α) where
card_four := kleinFour_card_of_card_eq_four hα4
exponent_two := exponent_kleinFour_of_card_eq_four hα4
theorem kleinFour_eq_commutator (hα4 : Nat.card α = 4) :
kleinFour α = commutator (alternatingGroup α) := by
have _ : (kleinFour α).Normal := normal_kleinFour hα4
have : Nat.card (alternatingGroup α ⧸ kleinFour α) = 3 := by
rw [← Nat.mul_left_inj (a := Nat.card (kleinFour α))]
· rw [← Subgroup.card_eq_card_quotient_mul_card_subgroup]
rw [card_of_card_eq_four hα4, kleinFour_card_of_card_eq_four hα4]
rw [kleinFour_card_of_card_eq_four hα4]; simp
have comm_le : commutator (alternatingGroup α) ≤ kleinFour α := by
rw [← Subgroup.Normal.quotient_commutative_iff_commutator_le]
exact (isCyclic_of_prime_card this).commutative
have comm_ne_bot : commutator (alternatingGroup α) ≠ ⊥ := by
rw [ne_eq, commutator_eq_bot_iff_center_eq_top,
center_eq_bot (le_of_eq hα4.symm)]
apply @bot_ne_top _ _ _ ?_
rw [Subgroup.nontrivial_iff, ← Finite.one_lt_card_iff_nontrivial,
card_of_card_eq_four hα4]
simp
obtain ⟨k, hk, hk'⟩ := Or.resolve_left (Subgroup.bot_or_exists_ne_one _) comm_ne_bot
suffices hk22 : (k : Equiv.Perm α).cycleType = {2, 2} by
refine le_antisymm ?_ comm_le
intro g hg
rw [← SetLike.mem_coe, coe_kleinFour_of_card_eq_four hα4,
Set.mem_union, Set.mem_singleton_iff, Set.mem_setOf_eq] at hg
rcases hg with ⟨rfl⟩ | hg
· exact Subgroup.one_mem _
· rw [← hg, ← Equiv.Perm.isConj_iff_cycleType_eq, isConj_iff] at hk22
obtain ⟨c, hc⟩ := hk22
rw [← MulAut.conjNormal_apply, Subtype.coe_inj] at hc
simp only [commutator, ← hc]
let fc : MulAut (alternatingGroup α) := MulAut.conjNormal c
suffices (⊤ : Subgroup (alternatingGroup α)) =
Subgroup.map fc.toMonoidHom (⊤ : Subgroup (alternatingGroup α)) by
rw [this, ← Subgroup.map_commutator]
refine Subgroup.mem_map_of_mem _ hk
apply symm
rw [← MonoidHom.range_eq_map]
rw [MonoidHom.range_eq_top]
exact MulEquiv.surjective _
have hk2 := comm_le hk
rw [← SetLike.mem_coe, coe_kleinFour_of_card_eq_four hα4,
Set.mem_union, Set.mem_singleton_iff, Set.mem_setOf_eq] at hk2
exact hk2.resolve_left hk'
end alternatingGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/SpecificGroups/Alternating/Centralizer.lean | import Mathlib.GroupTheory.Perm.Centralizer
import Mathlib.GroupTheory.SpecificGroups.Alternating
/-! # Centralizer of an element in the alternating group
Given a finite type `α`, our goal is to compute the cardinality of conjugacy classes
in `alternatingGroup α`.
* `AlternatingGroup.card_of_cycleType_mul_eq m` and `AlternatingGroup.card_of_cycleType m`
compute the number of even permutations of given cycle type.
* `Equiv.Perm.OnCycleFactors.odd_of_centralizer_le_alternatingGroup` :
if `Subgroup.centralizer {g} ≤ alternatingGroup α`, then all members of the `g.cycleType` are odd.
* `Equiv.Perm.card_le_of_centralizer_le_alternating` :
if `Subgroup.centralizer {g} ≤ alternatingGroup α`, then the cardinality of α
is at most `g.cycleType.sum` plus one.
* `Equiv.Perm.count_le_one_of_centralizer_le_alternating` :
if `Subgroup.centralizer {g} ≤ alternatingGroup α`, then `g.cycleType` has no repetitions.
* `Equiv.Perm.centralizer_le_alternating_iff` :
the previous three conditions are necessary and sufficient
for having `Subgroup.centralizer {g} ≤ alternatingGroup α`.
TODO :
Deduce the formula for the cardinality of the centralizers
and conjugacy classes in `alternatingGroup α`.
-/
open Equiv Finset Function MulAction
variable {α : Type*} [Fintype α] [DecidableEq α] {g : Perm α}
namespace Equiv.Perm.OnCycleFactors
theorem odd_of_centralizer_le_alternatingGroup (h : Subgroup.centralizer {g} ≤ alternatingGroup α)
(i : ℕ) (hi : i ∈ g.cycleType) :
Odd i := by
rw [cycleType_def g, Multiset.mem_map] at hi
obtain ⟨c, hc, rfl⟩ := hi
rw [← Finset.mem_def] at hc
suffices sign c = 1 by
rw [IsCycle.sign _, neg_eq_iff_eq_neg, ← Int.units_ne_iff_eq_neg] at this
· rw [← Nat.not_even_iff_odd, comp_apply]
exact fun h ↦ this h.neg_one_pow
· rw [mem_cycleFactorsFinset_iff] at hc
exact hc.left
apply h
rw [Subgroup.mem_centralizer_singleton_iff]
exact Equiv.Perm.self_mem_cycle_factors_commute hc
end Equiv.Perm.OnCycleFactors
namespace AlternatingGroup
open Nat Equiv.Perm.OnCycleFactors Equiv.Perm
theorem map_subtype_of_cycleType (m : Multiset ℕ) :
({g | (g : Perm α).cycleType = m} : Finset (alternatingGroup α)).map (Embedding.subtype _) =
if Even (m.sum + m.card) then ({g | g.cycleType = m} : Finset (Perm α)) else ∅ := by
split_ifs with hm
· ext g
simp_rw [Finset.mem_map, Finset.mem_filter_univ, Embedding.coe_subtype, Subtype.exists,
mem_alternatingGroup, exists_and_left, exists_prop, exists_eq_right_right,
and_iff_left_iff_imp]
intro hg
rw [sign_of_cycleType, hg, Even.neg_one_pow hm]
· rw [Finset.eq_empty_iff_forall_notMem]
intro g hg
simp_rw [Finset.mem_map, Finset.mem_filter_univ, Embedding.coe_subtype, Subtype.exists,
mem_alternatingGroup, exists_and_left, exists_prop, exists_eq_right_right] at hg
rcases hg with ⟨hg, hs⟩
rw [g.sign_of_cycleType, hg, neg_one_pow_eq_one_iff_even (by simp)] at hs
contradiction
variable (α) in
/-- The cardinality of even permutations of given `cycleType` -/
theorem card_of_cycleType_mul_eq (m : Multiset ℕ) :
#{g : alternatingGroup α | g.val.cycleType = m} *
((Fintype.card α - m.sum)! * m.prod * (∏ n ∈ m.toFinset, (m.count n)!)) =
if ((m.sum ≤ Fintype.card α ∧ ∀ a ∈ m, 2 ≤ a) ∧ Even (m.sum + Multiset.card m))
then (Fintype.card α)!
else 0 := by
rw [← Finset.card_map, map_subtype_of_cycleType, apply_ite Finset.card,
Finset.card_empty, ite_mul, zero_mul]
simp only [and_comm (b := Even _)]
rw [ite_and, Equiv.Perm.card_of_cycleType_mul_eq]
variable (α) in
/-- The cardinality of even permutations of given `cycleType` -/
theorem card_of_cycleType (m : Multiset ℕ) :
#{g : alternatingGroup α | (g : Equiv.Perm α).cycleType = m} =
if (m.sum ≤ Fintype.card α ∧ ∀ a ∈ m, 2 ≤ a) ∧ Even (m.sum + Multiset.card m) then
(Fintype.card α)! /
((Fintype.card α - m.sum)! *
(m.prod * (∏ n ∈ m.toFinset, (m.count n)!)))
else 0 := by
split_ifs with hm
· -- m is an even cycle_type
rw [← Finset.card_map, map_subtype_of_cycleType, if_pos hm.2,
Equiv.Perm.card_of_cycleType α m, if_pos hm.1, mul_assoc]
· -- m does not correspond to a permutation, or to an odd one,
rw [← Finset.card_map, map_subtype_of_cycleType]
rw [apply_ite Finset.card, Finset.card_empty]
split_ifs with hm'
· rw [Equiv.Perm.card_of_cycleType, if_neg]
obtain hm | hm := not_and_or.mp hm
· exact hm
· contradiction
· rfl
open Fintype in
/-- The number of cycles of given length -/
lemma card_of_cycleType_singleton {n : ℕ} (hn : 2 ≤ n) (hα : n ≤ card α) :
#{g : alternatingGroup α | g.val.cycleType = {n}} =
if Odd n then (n - 1)! * (choose (card α) n) else 0 := by
rw [← card_map, map_subtype_of_cycleType, apply_ite Finset.card]
simp only [Multiset.sum_singleton, Multiset.card_singleton, Finset.card_empty]
simp_rw [← Nat.not_odd_iff_even, Nat.odd_add_one, not_not,
Perm.card_of_cycleType_singleton hn hα]
end AlternatingGroup
namespace Equiv.Perm
open Basis OnCycleFactors
theorem card_le_of_centralizer_le_alternating (h : Subgroup.centralizer {g} ≤ alternatingGroup α) :
Fintype.card α ≤ g.cycleType.sum + 1 := by
by_contra! hm
replace hm : 2 + g.cycleType.sum ≤ Fintype.card α := by omega
suffices 1 < Fintype.card (Function.fixedPoints g) by
obtain ⟨a, b, hab⟩ := Fintype.exists_pair_of_one_lt_card this
suffices sign (kerParam g ⟨swap a b, 1⟩) ≠ 1 from
this (h (kerParam_range_le_centralizer (Set.mem_range_self _)))
simp [sign_kerParam_apply_apply, hab]
rwa [card_fixedPoints g, Nat.lt_iff_add_one_le, Nat.le_sub_iff_add_le]
rw [sum_cycleType]
exact Finset.card_le_univ _
theorem count_le_one_of_centralizer_le_alternating
(h : Subgroup.centralizer {g} ≤ alternatingGroup α) :
∀ i, g.cycleType.count i ≤ 1 := by
rw [← Multiset.nodup_iff_count_le_one, Equiv.Perm.cycleType_def]
rw [Multiset.nodup_map_iff_inj_on g.cycleFactorsFinset.nodup]
simp only [Function.comp_apply, ← Finset.mem_def]
by_contra! hm
obtain ⟨c, hc, d, hd, hm, hm'⟩ := hm
let τ : Equiv.Perm g.cycleFactorsFinset := Equiv.swap ⟨c, hc⟩ ⟨d, hd⟩
obtain ⟨a⟩ := Equiv.Perm.Basis.nonempty g
have hτ : τ ∈ range_toPermHom' g := fun x ↦ by
by_cases hx : x = ⟨c, hc⟩
· rw [hx, Equiv.swap_apply_left]; exact hm.symm
by_cases hx' : x = ⟨d, hd⟩
· rw [hx', Equiv.swap_apply_right]; exact hm
· rw [Equiv.swap_apply_of_ne_of_ne hx hx']
set k := toCentralizer a ⟨τ, hτ⟩ with hk
suffices hsign_k : k.val.sign = -1 by
apply units_ne_neg_self (1 : ℤˣ)
rw [← hsign_k, h (toCentralizer a ⟨τ, hτ⟩).prop]
/- to prove that `hsign_k : sign k = -1` below,
we could prove that it is the product of the transpositions with disjoint supports
[(g ^ n) (a c), (g ^ n) (a d)], for 0 ≤ n < c.support.card,
which are in odd number by `odd_of_centralizer_le_alternatingGroup`,
but it will be sufficient to observe that `k ^ 2 = 1`
(which implies that `k.cycleType` is of the form (2,2,…))
and to control its support. -/
have hk_cT : k.val.cycleType = Multiset.replicate k.val.cycleType.card 2 := by
rw [Multiset.eq_replicate_card, ← pow_prime_eq_one_iff, ← Subgroup.coe_pow,
← Subgroup.coe_one, Subtype.coe_inj, hk, ← map_pow]
convert MonoidHom.map_one _
rw [← Subtype.coe_inj]
apply Equiv.swap_mul_self
rw [sign_of_cycleType, hk_cT]
simp only [Multiset.sum_replicate, smul_eq_mul, Multiset.card_replicate, pow_add,
even_two, Even.mul_left, Even.neg_pow, one_pow, one_mul]
apply Odd.neg_one_pow
apply odd_of_centralizer_le_alternatingGroup h
have this : (k : Perm α).cycleType.card * 2 = (k : Perm α).support.card := by
rw [← sum_cycleType, hk_cT]
simp
have that : Multiset.card (k : Perm α).cycleType = (c : Perm α).support.card := by
rw [← Nat.mul_left_inj (a := 2) (by simp), this]
simp only [hk, toCentralizer, MonoidHom.coe_mk, OneHom.coe_mk, card_ofPermHom_support]
have H : (⟨c, hc⟩ : g.cycleFactorsFinset) ≠ ⟨d, hd⟩ := Subtype.coe_ne_coe.mp hm'
simp only [τ, support_swap H]
rw [Finset.sum_insert (by simp only [mem_singleton, H, not_false_eq_true]),
Finset.sum_singleton, hm, mul_two]
rw [that]
simp only [cycleType_def, Multiset.mem_map]
exact ⟨c, hc, by simp only [Function.comp_apply]⟩
theorem OnCycleFactors.kerParam_range_eq_centralizer_of_count_le_one
(h_count : ∀ i, g.cycleType.count i ≤ 1) :
(kerParam g).range = Subgroup.centralizer {g} := by
ext x
refine ⟨fun hx ↦ kerParam_range_le_centralizer hx, fun hx ↦ ?_⟩
simp_rw [kerParam_range_eq, Subgroup.mem_map, MonoidHom.mem_ker, Subgroup.coe_subtype,
Subtype.exists, exists_and_right, exists_eq_right]
use hx
ext c : 2
rw [← Multiset.nodup_iff_count_le_one, cycleType_def,
Multiset.nodup_map_iff_inj_on (cycleFactorsFinset g).nodup] at h_count
exact h_count _ (by simp) _ c.prop ((mem_range_toPermHom_iff).mp (by simp) c)
/-- The centralizer of a permutation is contained in the alternating group if and only if
its cycles have odd length, with at most one of each, and there is at most one fixed point. -/
theorem centralizer_le_alternating_iff :
Subgroup.centralizer {g} ≤ alternatingGroup α ↔
(∀ c ∈ g.cycleType, Odd c) ∧ Fintype.card α ≤ g.cycleType.sum + 1 ∧
∀ i, g.cycleType.count i ≤ 1 := by
rw [SetLike.le_def]
constructor
· intro h
exact ⟨odd_of_centralizer_le_alternatingGroup h,
card_le_of_centralizer_le_alternating h,
count_le_one_of_centralizer_le_alternating h⟩
· rintro ⟨h_odd, h_fixed, h_count⟩ x hx
rw [← kerParam_range_eq_centralizer_of_count_le_one h_count] at hx
obtain ⟨⟨y, uv⟩, rfl⟩ := MonoidHom.mem_range.mp hx
rw [mem_alternatingGroup, sign_kerParam_apply_apply (g := g) y uv]
convert mul_one _
· apply Finset.prod_eq_one
rintro ⟨c, hc⟩ _
obtain ⟨k, hk⟩ := (uv _).prop
rw [← hk, map_zpow]
convert one_zpow k
rw [IsCycle.sign, Odd.neg_one_pow, neg_neg]
· apply h_odd
rw [cycleType_def, Multiset.mem_map]
exact ⟨c, hc, rfl⟩
· rw [mem_cycleFactorsFinset_iff] at hc
exact hc.left
· suffices y = 1 by simp [this]
have := card_fixedPoints g
exact card_support_le_one.mp <| le_trans (Finset.card_le_univ _) (by cutsat)
namespace IsThreeCycle
variable (h5 : 5 ≤ Fintype.card α) {g : alternatingGroup α} (hg : IsThreeCycle (g : Perm α))
include h5 hg
theorem mem_commutatorSet_alternatingGroup : g ∈ commutatorSet (alternatingGroup α) := by
apply mem_commutatorSet_of_isConj_sq
apply alternatingGroup.isThreeCycle_isConj h5 hg
simpa [sq] using hg.isThreeCycle_sq
theorem mem_commutator_alternatingGroup : g ∈ commutator (alternatingGroup α) := by
rw [commutator_eq_closure]
apply Subgroup.subset_closure
exact hg.mem_commutatorSet_alternatingGroup h5
end IsThreeCycle
end Equiv.Perm
section Perfect
open Subgroup Equiv.Perm
theorem alternatingGroup.commutator_perm_le :
commutator (Perm α) ≤ alternatingGroup α := by
simp only [commutator_eq_closure, closure_le, Set.subset_def, mem_commutatorSet_iff,
SetLike.mem_coe, mem_alternatingGroup, forall_exists_index]
rintro _ p q rfl
simp [map_commutatorElement, commutatorElement_eq_one_iff_commute, Commute.all]
/-- If `n ≥ 5`, then the alternating group on `n` letters is perfect -/
theorem commutator_alternatingGroup_eq_top (h5 : 5 ≤ Fintype.card α) :
commutator (alternatingGroup α) = ⊤ := by
suffices closure {b : alternatingGroup α | (b : Perm α).IsThreeCycle} = ⊤ by
rw [eq_top_iff, ← this, Subgroup.closure_le]
intro b hb
exact hb.mem_commutator_alternatingGroup h5
rw [← closure_three_cycles_eq_alternating]
exact Subgroup.closure_closure_coe_preimage
/-- If `n ≥ 5`, then the alternating group on `n` letters is perfect (subgroup version) -/
theorem commutator_alternatingGroup_eq_self (h5 : 5 ≤ Fintype.card α) :
⁅alternatingGroup α, alternatingGroup α⁆ = alternatingGroup α := by
rw [← Subgroup.map_subtype_commutator, commutator_alternatingGroup_eq_top h5,
← MonoidHom.range_eq_map, Subgroup.range_subtype]
/-- The commutator subgroup of the permutation group is the alternating group -/
theorem alternatingGroup.commutator_perm_eq (h5 : 5 ≤ Fintype.card α) :
commutator (Perm α) = alternatingGroup α := by
apply le_antisymm alternatingGroup.commutator_perm_le
rw [← commutator_alternatingGroup_eq_self h5]
exact commutator_mono le_top le_top
end Perfect |
.lake/packages/mathlib/Mathlib/GroupTheory/OreLocalization/OreSet.lean | import Mathlib.Algebra.Group.Submonoid.Defs
/-!
# (Left) Ore sets
This defines left Ore sets on arbitrary monoids.
## References
* https://ncatlab.org/nlab/show/Ore+set
-/
assert_not_exists RelIso
namespace AddOreLocalization
/-- A submonoid `S` of an additive monoid `R` is (left) Ore if common summands on the right can be
turned into common summands on the left, and if each pair of `r : R` and `s : S` admits an Ore
minuend `v : R` and an Ore subtrahend `u : S` such that `u + r = v + s`. -/
class AddOreSet {R : Type*} [AddMonoid R] (S : AddSubmonoid R) where
/-- Common summands on the right can be turned into common summands on the left, a weak form of
cancellability. -/
ore_right_cancel : ∀ (r₁ r₂ : R) (s : S), r₁ + s = r₂ + s → ∃ s' : S, s' + r₁ = s' + r₂
/-- The Ore minuend of a difference. -/
oreMin : R → S → R
/-- The Ore subtrahend of a difference. -/
oreSubtra : R → S → S
/-- The Ore condition of a difference, expressed in terms of `oreMin` and `oreSubtra`. -/
ore_eq : ∀ (r : R) (s : S), oreSubtra r s + r = oreMin r s + s
end AddOreLocalization
namespace OreLocalization
section Monoid
/-- A submonoid `S` of a monoid `R` is (left) Ore if common factors on the right can be turned
into common factors on the left, and if each pair of `r : R` and `s : S` admits an Ore numerator
`v : R` and an Ore denominator `u : S` such that `u * r = v * s`. -/
@[to_additive AddOreLocalization.AddOreSet]
class OreSet {R : Type*} [Monoid R] (S : Submonoid R) where
/-- Common factors on the right can be turned into common factors on the left, a weak form of
cancellability. -/
ore_right_cancel : ∀ (r₁ r₂ : R) (s : S), r₁ * s = r₂ * s → ∃ s' : S, s' * r₁ = s' * r₂
/-- The Ore numerator of a fraction. -/
oreNum : R → S → R
/-- The Ore denominator of a fraction. -/
oreDenom : R → S → S
/-- The Ore condition of a fraction, expressed in terms of `oreNum` and `oreDenom`. -/
ore_eq : ∀ (r : R) (s : S), oreDenom r s * r = oreNum r s * s
-- TODO: use this once it's available.
-- run_cmd to_additive.map_namespace `OreLocalization `AddOreLocalization
variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S]
/-- Common factors on the right can be turned into common factors on the left, a weak form of
cancellability. -/
@[to_additive AddOreLocalization.ore_right_cancel]
theorem ore_right_cancel (r₁ r₂ : R) (s : S) (h : r₁ * s = r₂ * s) : ∃ s' : S, s' * r₁ = s' * r₂ :=
OreSet.ore_right_cancel r₁ r₂ s h
/-- The Ore numerator of a fraction. -/
@[to_additive AddOreLocalization.oreMin /-- The Ore minuend of a difference. -/]
def oreNum (r : R) (s : S) : R :=
OreSet.oreNum r s
/-- The Ore denominator of a fraction. -/
@[to_additive AddOreLocalization.oreSubtra /-- The Ore subtrahend of a difference. -/]
def oreDenom (r : R) (s : S) : S :=
OreSet.oreDenom r s
/-- The Ore condition of a fraction, expressed in terms of `oreNum` and `oreDenom`. -/
@[to_additive AddOreLocalization.add_ore_eq
/-- The Ore condition of a difference, expressed in terms of `oreMin` and `oreSubtra`. -/]
theorem ore_eq (r : R) (s : S) : oreDenom r s * r = oreNum r s * s :=
OreSet.ore_eq r s
/-- The Ore condition bundled in a sigma type. This is useful in situations where we want to obtain
both witnesses and the condition for a given fraction. -/
@[to_additive AddOreLocalization.addOreCondition
/-- The Ore condition bundled in a sigma type. This is useful in situations where we want to obtain
both witnesses and the condition for a given difference. -/]
def oreCondition (r : R) (s : S) : Σ' r' : R, Σ' s' : S, s' * r = r' * s :=
⟨oreNum r s, oreDenom r s, ore_eq r s⟩
/-- The trivial submonoid is an Ore set. -/
@[to_additive AddOreLocalization.addOreSetBot]
instance oreSetBot : OreSet (⊥ : Submonoid R) where
ore_right_cancel _ _ s h :=
⟨s, by
rcases s with ⟨s, hs⟩
rw [Submonoid.mem_bot] at hs
subst hs
rw [mul_one, mul_one] at h
subst h
rfl⟩
oreNum r _ := r
oreDenom _ s := s
ore_eq _ s := by
rcases s with ⟨s, hs⟩
rw [Submonoid.mem_bot] at hs
simp [hs]
/-- Every submonoid of a commutative monoid is an Ore set. -/
@[to_additive AddOreLocalization.addOreSetComm]
instance (priority := 100) oreSetComm {R} [CommMonoid R] (S : Submonoid R) : OreSet S where
ore_right_cancel m n s h := ⟨s, by rw [mul_comm (s : R) n, mul_comm (s : R) m, h]⟩
oreNum r _ := r
oreDenom _ s := s
ore_eq r s := by rw [mul_comm]
end Monoid
end OreLocalization |
.lake/packages/mathlib/Mathlib/GroupTheory/OreLocalization/Basic.lean | import Mathlib.GroupTheory.OreLocalization.OreSet
import Mathlib.Tactic.Common
import Mathlib.Algebra.Group.Submonoid.MulAction
import Mathlib.Algebra.Group.Units.Defs
import Mathlib.Algebra.Group.Basic
/-!
# Localization over left Ore sets.
This file defines the localization of a monoid over a left Ore set and proves its universal
mapping property.
## Notation
Introduces the notation `R[S⁻¹]` for the Ore localization of a monoid `R` at a right Ore
subset `S`. Also defines a new heterogeneous division notation `r /ₒ s` for a numerator `r : R` and
a denominator `s : S`.
## References
* <https://ncatlab.org/nlab/show/Ore+localization>
* [Zoran Škoda, *Noncommutative localization in noncommutative geometry*][skoda2006]
## Tags
localization, Ore, non-commutative
-/
assert_not_exists RelIso MonoidWithZero
universe u
open OreLocalization
namespace OreLocalization
variable {R : Type*} [Monoid R] (S : Submonoid R) [OreSet S] (X) [MulAction R X]
/-- The setoid on `R × S` used for the Ore localization. -/
@[to_additive AddOreLocalization.oreEqv /-- The setoid on `R × S` used for the Ore localization. -/]
def oreEqv : Setoid (X × S) where
r rs rs' := ∃ (u : S) (v : R), u • rs'.1 = v • rs.1 ∧ u * rs'.2 = v * rs.2
iseqv := by
refine ⟨fun _ => ⟨1, 1, by simp⟩, ?_, ?_⟩
· rintro ⟨r, s⟩ ⟨r', s'⟩ ⟨u, v, hru, hsu⟩; dsimp only at *
rcases oreCondition (s : R) s' with ⟨r₂, s₂, h₁⟩
rcases oreCondition r₂ u with ⟨r₃, s₃, h₂⟩
have : r₃ * v * s = s₃ * s₂ * s := by
-- Porting note: the proof used `assoc_rw`
rw [mul_assoc _ (s₂ : R), h₁, ← mul_assoc, h₂, mul_assoc, ← hsu, ← mul_assoc]
rcases ore_right_cancel (r₃ * v) (s₃ * s₂) s this with ⟨w, hw⟩
refine ⟨w * (s₃ * s₂), w * (r₃ * u), ?_, ?_⟩ <;>
simp only [Submonoid.coe_mul, Submonoid.smul_def, ← hw]
· simp only [mul_smul, hru, ← Submonoid.smul_def]
· simp only [mul_assoc, hsu]
· rintro ⟨r₁, s₁⟩ ⟨r₂, s₂⟩ ⟨r₃, s₃⟩ ⟨u, v, hur₁, hs₁u⟩ ⟨u', v', hur₂, hs₂u⟩
rcases oreCondition v' u with ⟨r', s', h⟩; dsimp only at *
refine ⟨s' * u', r' * v, ?_, ?_⟩ <;>
simp only [Submonoid.smul_def, Submonoid.coe_mul, mul_smul, mul_assoc] at *
· rw [hur₂, smul_smul, h, mul_smul, hur₁]
· rw [hs₂u, ← mul_assoc, h, mul_assoc, hs₁u]
end OreLocalization
/-- The Ore localization of a monoid and a submonoid fulfilling the Ore condition. -/
@[to_additive AddOreLocalization /-- The Ore localization of an additive monoid and a submonoid
fulfilling the Ore condition. -/]
def OreLocalization {R : Type*} [Monoid R] (S : Submonoid R) [OreSet S]
(X : Type*) [MulAction R X] :=
Quotient (OreLocalization.oreEqv S X)
namespace OreLocalization
section Monoid
variable (R : Type*) [Monoid R] (S : Submonoid R) [OreSet S]
@[inherit_doc OreLocalization]
scoped syntax:1075 term noWs atomic("[" term "⁻¹" noWs "]") : term
macro_rules | `($R[$S⁻¹]) => ``(OreLocalization $S $R)
attribute [local instance] oreEqv
variable {R S}
variable {X} [MulAction R X]
/-- The division in the Ore localization `X[S⁻¹]`, as a fraction of an element of `X` and `S`. -/
@[to_additive /-- The subtraction in the Ore localization,
as a difference of an element of `X` and `S`. -/]
def oreDiv (r : X) (s : S) : X[S⁻¹] :=
Quotient.mk' (r, s)
@[inherit_doc]
infixl:70 " /ₒ " => oreDiv
@[inherit_doc]
infixl:65 " -ₒ " => _root_.AddOreLocalization.oreSub
@[to_additive (attr := elab_as_elim, cases_eliminator, induction_eliminator)]
protected theorem ind {β : X[S⁻¹] → Prop}
(c : ∀ (r : X) (s : S), β (r /ₒ s)) : ∀ q, β q := by
apply Quotient.ind
rintro ⟨r, s⟩
exact c r s
@[to_additive]
theorem oreDiv_eq_iff {r₁ r₂ : X} {s₁ s₂ : S} :
r₁ /ₒ s₁ = r₂ /ₒ s₂ ↔ ∃ (u : S) (v : R), u • r₂ = v • r₁ ∧ u * s₂ = v * s₁ :=
Quotient.eq''
/-- A fraction `r /ₒ s` is equal to its expansion by an arbitrary factor `t` if `t * s ∈ S`. -/
@[to_additive /-- A difference `r -ₒ s` is equal to its expansion by an
arbitrary translation `t` if `t + s ∈ S`. -/]
protected theorem expand (r : X) (s : S) (t : R) (hst : t * (s : R) ∈ S) :
r /ₒ s = t • r /ₒ ⟨t * s, hst⟩ := by
apply Quotient.sound
exact ⟨s, s * t, by rw [mul_smul, Submonoid.smul_def], by rw [← mul_assoc]⟩
/-- A fraction is equal to its expansion by a factor from `S`. -/
@[to_additive /-- A difference is equal to its expansion by a summand from `S`. -/]
protected theorem expand' (r : X) (s s' : S) : r /ₒ s = s' • r /ₒ (s' * s) :=
OreLocalization.expand r s s' (by norm_cast; apply SetLike.coe_mem)
/-- Fractions which differ by a factor of the numerator can be proven equal if
those factors expand to equal elements of `R`. -/
@[to_additive /-- Differences whose minuends differ by a common summand can be proven equal if
those summands expand to equal elements of `R`. -/]
protected theorem eq_of_num_factor_eq {r r' r₁ r₂ : R} {s t : S} (h : t * r = t * r') :
r₁ * r * r₂ /ₒ s = r₁ * r' * r₂ /ₒ s := by
rcases oreCondition r₁ t with ⟨r₁', t', hr₁⟩
rw [OreLocalization.expand' _ s t', OreLocalization.expand' _ s t']
congr 1
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: use `assoc_rw`?
calc (t' : R) * (r₁ * r * r₂)
= t' * r₁ * r * r₂ := by simp [← mul_assoc]
_ = r₁' * t * r * r₂ := by rw [hr₁]
_ = r₁' * (t * r) * r₂ := by simp [← mul_assoc]
_ = r₁' * (t * r') * r₂ := by rw [h]
_ = r₁' * t * r' * r₂ := by simp [← mul_assoc]
_ = t' * r₁ * r' * r₂ := by rw [hr₁]
_ = t' * (r₁ * r' * r₂) := by simp [← mul_assoc]
/-- A function or predicate over `X` and `S` can be lifted to `X[S⁻¹]` if it is invariant
under expansion on the left. -/
@[to_additive /-- A function or predicate over `X` and `S` can be lifted to the localization if it
is invariant under expansion on the left. -/]
def liftExpand {C : Sort*} (P : X → S → C)
(hP : ∀ (r : X) (t : R) (s : S) (ht : t * s ∈ S), P r s = P (t • r) ⟨t * s, ht⟩) :
X[S⁻¹] → C :=
Quotient.lift (fun p : X × S => P p.1 p.2) fun (r₁, s₁) (r₂, s₂) ⟨u, v, hr₂, hs₂⟩ => by
dsimp at *
have s₁vS : v * s₁ ∈ S := by
rw [← hs₂, ← S.coe_mul]
exact SetLike.coe_mem (u * s₂)
replace hs₂ : u * s₂ = ⟨_, s₁vS⟩ := by ext; simp [hs₂]
rw [hP r₁ v s₁ s₁vS, hP r₂ u s₂ (by norm_cast; rwa [hs₂]), ← hr₂]
simp only [← hs₂]; rfl
@[to_additive (attr := simp)]
theorem liftExpand_of {C : Sort*} {P : X → S → C}
{hP : ∀ (r : X) (t : R) (s : S) (ht : t * s ∈ S), P r s = P (t • r) ⟨t * s, ht⟩} (r : X)
(s : S) : liftExpand P hP (r /ₒ s) = P r s :=
rfl
/-- A version of `liftExpand` used to simultaneously lift functions with two arguments
in `X[S⁻¹]`. -/
@[to_additive
/-- A version of `liftExpand` used to simultaneously lift functions with two arguments. -/]
def lift₂Expand {C : Sort*} (P : X → S → X → S → C)
(hP :
∀ (r₁ : X) (t₁ : R) (s₁ : S) (ht₁ : t₁ * s₁ ∈ S) (r₂ : X) (t₂ : R) (s₂ : S)
(ht₂ : t₂ * s₂ ∈ S),
P r₁ s₁ r₂ s₂ = P (t₁ • r₁) ⟨t₁ * s₁, ht₁⟩ (t₂ • r₂) ⟨t₂ * s₂, ht₂⟩) :
X[S⁻¹] → X[S⁻¹] → C :=
liftExpand
(fun r₁ s₁ => liftExpand (P r₁ s₁) fun r₂ t₂ s₂ ht₂ => by
have := hP r₁ 1 s₁ (by simp) r₂ t₂ s₂ ht₂
simp [this])
fun r₁ t₁ s₁ ht₁ => by
ext x; cases x with | _ r₂ s₂
dsimp only
rw [liftExpand_of, liftExpand_of, hP r₁ t₁ s₁ ht₁ r₂ 1 s₂ (by simp)]; simp
@[to_additive (attr := simp)]
theorem lift₂Expand_of {C : Sort*} {P : X → S → X → S → C}
{hP :
∀ (r₁ : X) (t₁ : R) (s₁ : S) (ht₁ : t₁ * s₁ ∈ S) (r₂ : X) (t₂ : R) (s₂ : S)
(ht₂ : t₂ * s₂ ∈ S),
P r₁ s₁ r₂ s₂ = P (t₁ • r₁) ⟨t₁ * s₁, ht₁⟩ (t₂ • r₂) ⟨t₂ * s₂, ht₂⟩}
(r₁ : X) (s₁ : S) (r₂ : X) (s₂ : S) : lift₂Expand P hP (r₁ /ₒ s₁) (r₂ /ₒ s₂) = P r₁ s₁ r₂ s₂ :=
rfl
@[to_additive]
private def smul' (r₁ : R) (s₁ : S) (r₂ : X) (s₂ : S) : X[S⁻¹] :=
oreNum r₁ s₂ • r₂ /ₒ (oreDenom r₁ s₂ * s₁)
@[to_additive]
private theorem smul'_char (r₁ : R) (r₂ : X) (s₁ s₂ : S) (u : S) (v : R) (huv : u * r₁ = v * s₂) :
OreLocalization.smul' r₁ s₁ r₂ s₂ = v • r₂ /ₒ (u * s₁) := by
-- Porting note: `assoc_rw` was not ported yet
simp only [smul']
have h₀ := ore_eq r₁ s₂; set v₀ := oreNum r₁ s₂; set u₀ := oreDenom r₁ s₂
rcases oreCondition (u₀ : R) u with ⟨r₃, s₃, h₃⟩
have :=
calc
r₃ * v * s₂ = r₃ * (u * r₁) := by rw [mul_assoc, ← huv]
_ = s₃ * (u₀ * r₁) := by rw [← mul_assoc, ← mul_assoc, h₃]
_ = s₃ * v₀ * s₂ := by rw [mul_assoc, h₀]
rcases ore_right_cancel _ _ _ this with ⟨s₄, hs₄⟩
symm; rw [oreDiv_eq_iff]
use s₄ * s₃
use s₄ * r₃
simp only [Submonoid.coe_mul, Submonoid.smul_def]
constructor
· rw [smul_smul, mul_assoc (c := v₀), ← hs₄]
simp only [smul_smul, mul_assoc]
· rw [← mul_assoc (b := (u₀ : R)), mul_assoc (c := (u₀ : R)), h₃]
simp only [mul_assoc]
/-- The multiplication on the Ore localization of monoids. -/
@[to_additive]
private def smul'' (r : R) (s : S) : X[S⁻¹] → X[S⁻¹] :=
liftExpand (smul' r s) fun r₁ r₂ s' hs => by
rcases oreCondition r s' with ⟨r₁', s₁', h₁⟩
rw [smul'_char _ _ _ _ _ _ h₁]
rcases oreCondition r ⟨_, hs⟩ with ⟨r₂', s₂', h₂⟩
rw [smul'_char _ _ _ _ _ _ h₂]
rcases oreCondition (s₁' : R) (s₂') with ⟨r₃', s₃', h₃⟩
have : s₃' * r₁' * s' = (r₃' * r₂' * r₂) * s' := by
rw [mul_assoc, ← h₁, ← mul_assoc, h₃, mul_assoc, h₂]
simp [mul_assoc]
rcases ore_right_cancel _ _ _ this with ⟨s₄', h₄⟩
have : (s₄' * r₃') * (s₂' * s) ∈ S := by
rw [mul_assoc, ← mul_assoc r₃', ← h₃]
exact (s₄' * (s₃' * s₁' * s)).2
rw [OreLocalization.expand' _ _ (s₄' * s₃'), OreLocalization.expand _ (s₂' * s) _ this]
simp only [Submonoid.smul_def, Submonoid.coe_mul, smul_smul, mul_assoc, h₄]
congr 1
ext; simp only [Submonoid.coe_mul, ← mul_assoc]
rw [mul_assoc (s₄' : R), h₃, ← mul_assoc]
/-- The scalar multiplication on the Ore localization of monoids. -/
@[to_additive (attr := irreducible)
/-- the vector addition on the Ore localization of additive monoids. -/]
protected def smul : R[S⁻¹] → X[S⁻¹] → X[S⁻¹] :=
liftExpand smul'' fun r₁ r₂ s hs => by
ext x
cases x with | _ x s₂
change OreLocalization.smul' r₁ s x s₂ = OreLocalization.smul' (r₂ * r₁) ⟨_, hs⟩ x s₂
rcases oreCondition r₁ s₂ with ⟨r₁', s₁', h₁⟩
rw [smul'_char _ _ _ _ _ _ h₁]
rcases oreCondition (r₂ * r₁) s₂ with ⟨r₂', s₂', h₂⟩
rw [smul'_char _ _ _ _ _ _ h₂]
rcases oreCondition (s₂' * r₂) (s₁') with ⟨r₃', s₃', h₃⟩
have : s₃' * r₂' * s₂ = r₃' * r₁' * s₂ := by
rw [mul_assoc, ← h₂, ← mul_assoc _ r₂, ← mul_assoc, h₃, mul_assoc, h₁, mul_assoc]
rcases ore_right_cancel _ _ _ this with ⟨s₄', h₄⟩
have : (s₄' * r₃') * (s₁' * s) ∈ S := by
rw [← mul_assoc, mul_assoc _ r₃', ← h₃, ← mul_assoc, ← mul_assoc, mul_assoc]
exact mul_mem (s₄' * s₃' * s₂').2 hs
rw [OreLocalization.expand' (r₂' • x) _ (s₄' * s₃'), OreLocalization.expand _ _ _ this]
simp only [Submonoid.smul_def, Submonoid.coe_mul, smul_smul, mul_assoc, h₄]
congr 1
ext; simp only [Submonoid.coe_mul, ← mul_assoc]
rw [mul_assoc _ r₃', ← h₃, ← mul_assoc, ← mul_assoc]
@[to_additive]
instance : SMul R[S⁻¹] X[S⁻¹] :=
⟨OreLocalization.smul⟩
@[to_additive]
instance : Mul R[S⁻¹] :=
⟨OreLocalization.smul⟩
@[to_additive]
theorem oreDiv_smul_oreDiv {r₁ : R} {r₂ : X} {s₁ s₂ : S} :
(r₁ /ₒ s₁) • (r₂ /ₒ s₂) = oreNum r₁ s₂ • r₂ /ₒ (oreDenom r₁ s₂ * s₁) := by
with_unfolding_all rfl
@[to_additive]
theorem oreDiv_mul_oreDiv {r₁ : R} {r₂ : R} {s₁ s₂ : S} :
(r₁ /ₒ s₁) * (r₂ /ₒ s₂) = oreNum r₁ s₂ * r₂ /ₒ (oreDenom r₁ s₂ * s₁) := by
with_unfolding_all rfl
/-- A characterization lemma for the scalar multiplication on the Ore localization,
allowing for a choice of Ore numerator and Ore denominator. -/
@[to_additive /-- A characterization lemma for the vector addition on the Ore localization,
allowing for a choice of Ore minuend and Ore subtrahend. -/]
theorem oreDiv_smul_char (r₁ : R) (r₂ : X) (s₁ s₂ : S) (r' : R) (s' : S) (huv : s' * r₁ = r' * s₂) :
(r₁ /ₒ s₁) • (r₂ /ₒ s₂) = r' • r₂ /ₒ (s' * s₁) := by
with_unfolding_all exact smul'_char r₁ r₂ s₁ s₂ s' r' huv
/-- A characterization lemma for the multiplication on the Ore localization, allowing for a choice
of Ore numerator and Ore denominator. -/
@[to_additive /-- A characterization lemma for the addition on the Ore localization,
allowing for a choice of Ore minuend and Ore subtrahend. -/]
theorem oreDiv_mul_char (r₁ r₂ : R) (s₁ s₂ : S) (r' : R) (s' : S) (huv : s' * r₁ = r' * s₂) :
r₁ /ₒ s₁ * (r₂ /ₒ s₂) = r' * r₂ /ₒ (s' * s₁) := by
with_unfolding_all exact smul'_char r₁ r₂ s₁ s₂ s' r' huv
/-- Another characterization lemma for the scalar multiplication on the Ore localization delivering
Ore witnesses and conditions bundled in a sigma type. -/
@[to_additive /-- Another characterization lemma for the vector addition on the
Ore localization delivering Ore witnesses and conditions bundled in a sigma type. -/]
def oreDivSMulChar' (r₁ : R) (r₂ : X) (s₁ s₂ : S) :
Σ' r' : R, Σ' s' : S, s' * r₁ = r' * s₂ ∧ (r₁ /ₒ s₁) • (r₂ /ₒ s₂) = r' • r₂ /ₒ (s' * s₁) :=
⟨oreNum r₁ s₂, oreDenom r₁ s₂, ore_eq r₁ s₂, oreDiv_smul_oreDiv⟩
/-- Another characterization lemma for the multiplication on the Ore localization delivering
Ore witnesses and conditions bundled in a sigma type. -/
@[to_additive /-- Another characterization lemma for the addition on the Ore localization delivering
Ore witnesses and conditions bundled in a sigma type. -/]
def oreDivMulChar' (r₁ r₂ : R) (s₁ s₂ : S) :
Σ' r' : R, Σ' s' : S, s' * r₁ = r' * s₂ ∧ r₁ /ₒ s₁ * (r₂ /ₒ s₂) = r' * r₂ /ₒ (s' * s₁) :=
⟨oreNum r₁ s₂, oreDenom r₁ s₂, ore_eq r₁ s₂, oreDiv_mul_oreDiv⟩
/-- `1` in the localization, defined as `1 /ₒ 1`. -/
@[to_additive (attr := irreducible) /-- `0` in the additive localization, defined as `0 -ₒ 0`. -/]
protected def one : R[S⁻¹] := 1 /ₒ 1
@[to_additive]
instance : One R[S⁻¹] :=
⟨OreLocalization.one⟩
@[to_additive]
protected theorem one_def : (1 : R[S⁻¹]) = 1 /ₒ 1 := by
with_unfolding_all rfl
@[to_additive]
instance : Inhabited R[S⁻¹] :=
⟨1⟩
@[to_additive (attr := simp)]
protected theorem div_eq_one' {r : R} (hr : r ∈ S) : r /ₒ ⟨r, hr⟩ = 1 := by
rw [OreLocalization.one_def, oreDiv_eq_iff]
exact ⟨⟨r, hr⟩, 1, by simp, by simp⟩
@[to_additive (attr := simp)]
protected theorem div_eq_one {s : S} : (s : R) /ₒ s = 1 :=
OreLocalization.div_eq_one' _
@[to_additive]
protected theorem one_smul (x : X[S⁻¹]) : (1 : R[S⁻¹]) • x = x := by
cases x with | _ r s
simp [OreLocalization.one_def, oreDiv_smul_char 1 r 1 s 1 s (by simp)]
@[to_additive]
protected theorem one_mul (x : R[S⁻¹]) : 1 * x = x :=
OreLocalization.one_smul x
@[to_additive]
protected theorem mul_one (x : R[S⁻¹]) : x * 1 = x := by
cases x with | _ r s
simp [OreLocalization.one_def, oreDiv_mul_char r (1 : R) s (1 : S) r 1 (by simp)]
@[to_additive]
protected theorem mul_smul (x y : R[S⁻¹]) (z : X[S⁻¹]) : (x * y) • z = x • y • z := by
-- Porting note: `assoc_rw` was not ported yet
cases x with | _ r₁ s₁
cases y with | _ r₂ s₂
cases z with | _ r₃ s₃
rcases oreDivMulChar' r₁ r₂ s₁ s₂ with ⟨ra, sa, ha, ha'⟩; rw [ha']; clear ha'
rcases oreDivSMulChar' r₂ r₃ s₂ s₃ with ⟨rb, sb, hb, hb'⟩; rw [hb']; clear hb'
rcases oreCondition ra sb with ⟨rc, sc, hc⟩
rw [oreDiv_smul_char (ra * r₂) r₃ (sa * s₁) s₃ (rc * rb) sc]; swap
· rw [← mul_assoc _ ra, hc, mul_assoc, hb, ← mul_assoc]
rw [← mul_assoc, mul_smul]
symm; apply oreDiv_smul_char
rw [Submonoid.coe_mul, Submonoid.coe_mul, ← mul_assoc, ← hc, mul_assoc _ ra, ← ha, mul_assoc]
@[to_additive]
protected theorem mul_assoc (x y z : R[S⁻¹]) : x * y * z = x * (y * z) :=
OreLocalization.mul_smul x y z
/-- `npow` of `OreLocalization` -/
@[to_additive (attr := irreducible) /-- `nsmul` of `AddOreLocalization` -/]
protected def npow : ℕ → R[S⁻¹] → R[S⁻¹] := npowRec
unseal OreLocalization.npow in
@[to_additive]
instance : Monoid R[S⁻¹] where
one_mul := OreLocalization.one_mul
mul_one := OreLocalization.mul_one
mul_assoc := OreLocalization.mul_assoc
npow := OreLocalization.npow
@[to_additive]
instance instMulActionOreLocalization : MulAction R[S⁻¹] X[S⁻¹] where
one_smul := OreLocalization.one_smul
mul_smul := OreLocalization.mul_smul
@[to_additive]
protected theorem mul_inv (s s' : S) : ((s : R) /ₒ s') * ((s' : R) /ₒ s) = 1 := by
simp [oreDiv_mul_char (s : R) s' s' s 1 1 (by simp)]
@[to_additive (attr := simp)]
protected theorem one_div_smul {r : X} {s t : S} : ((1 : R) /ₒ t) • (r /ₒ s) = r /ₒ (s * t) := by
simp [oreDiv_smul_char 1 r t s 1 s (by simp)]
@[to_additive (attr := simp)]
protected theorem one_div_mul {r : R} {s t : S} : (1 /ₒ t) * (r /ₒ s) = r /ₒ (s * t) := by
simp [oreDiv_mul_char 1 r t s 1 s (by simp)]
@[to_additive (attr := simp)]
protected theorem smul_cancel {r : X} {s t : S} : ((s : R) /ₒ t) • (r /ₒ s) = r /ₒ t := by
simp [oreDiv_smul_char s.1 r t s 1 1 (by simp)]
@[to_additive (attr := simp)]
protected theorem mul_cancel {r : R} {s t : S} : ((s : R) /ₒ t) * (r /ₒ s) = r /ₒ t := by
simp [oreDiv_mul_char s.1 r t s 1 1 (by simp)]
@[to_additive (attr := simp)]
protected theorem smul_cancel' {r₁ : R} {r₂ : X} {s t : S} :
((r₁ * s) /ₒ t) • (r₂ /ₒ s) = (r₁ • r₂) /ₒ t := by
simp [oreDiv_smul_char (r₁ * s) r₂ t s r₁ 1 (by simp)]
@[to_additive (attr := simp)]
protected theorem mul_cancel' {r₁ r₂ : R} {s t : S} :
((r₁ * s) /ₒ t) * (r₂ /ₒ s) = (r₁ * r₂) /ₒ t := by
simp [oreDiv_mul_char (r₁ * s) r₂ t s r₁ 1 (by simp)]
@[to_additive (attr := simp)]
theorem smul_div_one {p : R} {r : X} {s : S} : (p /ₒ s) • (r /ₒ 1) = (p • r) /ₒ s := by
simp [oreDiv_smul_char p r s 1 p 1 (by simp)]
@[to_additive (attr := simp)]
theorem mul_div_one {p r : R} {s : S} : (p /ₒ s) * (r /ₒ 1) = (p * r) /ₒ s := by
--TODO use coercion r ↦ r /ₒ 1
simp [oreDiv_mul_char p r s 1 p 1 (by simp)]
/-- The fraction `s /ₒ 1` as a unit in `R[S⁻¹]`, where `s : S`. -/
@[to_additive /-- The difference `s -ₒ 0` as a an additive unit. -/]
def numeratorUnit (s : S) : Units R[S⁻¹] where
val := (s : R) /ₒ 1
inv := (1 : R) /ₒ s
val_inv := OreLocalization.mul_inv s 1
inv_val := OreLocalization.mul_inv 1 s
/-- The multiplicative homomorphism from `R` to `R[S⁻¹]`, mapping `r : R` to the
fraction `r /ₒ 1`. -/
@[to_additive /-- The additive homomorphism from `R` to `AddOreLocalization R S`,
mapping `r : R` to the difference `r -ₒ 0`. -/]
def numeratorHom : R →* R[S⁻¹] where
toFun r := r /ₒ 1
map_one' := by with_unfolding_all rfl
map_mul' _ _ := mul_div_one.symm
@[to_additive]
theorem numeratorHom_apply {r : R} : numeratorHom r = r /ₒ (1 : S) :=
rfl
@[to_additive]
theorem numerator_isUnit (s : S) : IsUnit (numeratorHom (s : R) : R[S⁻¹]) :=
⟨numeratorUnit s, rfl⟩
section UMP
variable {T : Type*} [Monoid T]
variable (f : R →* T) (fS : S →* Units T)
/-- The universal lift from a morphism `R →* T`, which maps elements of `S` to units of `T`,
to a morphism `R[S⁻¹] →* T`. -/
@[to_additive /-- The universal lift from a morphism `R →+ T`, which maps elements of `S` to
additive-units of `T`, to a morphism `AddOreLocalization R S →+ T`. -/]
def universalMulHom (hf : ∀ s : S, f s = fS s) : R[S⁻¹] →* T where
toFun x :=
x.liftExpand (fun r s => ((fS s)⁻¹ : Units T) * f r) fun r t s ht => by
simp only [smul_eq_mul]
have : (fS ⟨t * s, ht⟩ : T) = f t * fS s := by
simp only [← hf, MonoidHom.map_mul]
conv_rhs =>
rw [MonoidHom.map_mul, ← one_mul (f r), ← Units.val_one, ← mul_inv_cancel (fS s)]
rw [Units.val_mul, mul_assoc, ← mul_assoc _ (fS s : T), ← this, ← mul_assoc]
simp only [one_mul, Units.inv_mul]
map_one' := by beta_reduce; rw [OreLocalization.one_def, liftExpand_of]; simp
map_mul' x y := by
cases x with | _ r₁ s₁
cases y with | _ r₂ s₂
rcases oreDivMulChar' r₁ r₂ s₁ s₂ with ⟨ra, sa, ha, ha'⟩; rw [ha']; clear ha'
rw [liftExpand_of, liftExpand_of, liftExpand_of, Units.inv_mul_eq_iff_eq_mul, map_mul, map_mul,
Units.val_mul, mul_assoc, ← mul_assoc (fS s₁ : T), ← mul_assoc (fS s₁ : T), Units.mul_inv,
one_mul, ← hf, ← mul_assoc, ← map_mul _ _ r₁, ha, map_mul, hf s₂, mul_assoc,
← mul_assoc (fS s₂ : T), (fS s₂).mul_inv, one_mul]
variable (hf : ∀ s : S, f s = fS s)
@[to_additive]
theorem universalMulHom_apply {r : R} {s : S} :
universalMulHom f fS hf (r /ₒ s) = ((fS s)⁻¹ : Units T) * f r :=
rfl
@[to_additive]
theorem universalMulHom_commutes {r : R} : universalMulHom f fS hf (numeratorHom r) = f r := by
simp [numeratorHom_apply, universalMulHom_apply]
/-- The universal morphism `universalMulHom` is unique. -/
@[to_additive /-- The universal morphism `universalAddHom` is unique. -/]
theorem universalMulHom_unique (φ : R[S⁻¹] →* T) (huniv : ∀ r : R, φ (numeratorHom r) = f r) :
φ = universalMulHom f fS hf := by
ext x; cases x with | _ r s
rw [universalMulHom_apply, ← huniv r, numeratorHom_apply, ← one_mul (φ (r /ₒ s)), ←
Units.val_one, ← inv_mul_cancel (fS s), Units.val_mul, mul_assoc, ← hf, ← huniv, ← φ.map_mul,
numeratorHom_apply, OreLocalization.mul_cancel]
end UMP
end Monoid
section SMul
variable {R R' M X : Type*} [Monoid M] {S : Submonoid M} [OreSet S] [MulAction M X]
variable [SMul R X] [SMul R M] [IsScalarTower R M M] [IsScalarTower R M X]
variable [SMul R' X] [SMul R' M] [IsScalarTower R' M M] [IsScalarTower R' M X]
variable [SMul R R'] [IsScalarTower R R' M]
/-- Scalar multiplication in a monoid localization. -/
@[to_additive (attr := irreducible) /-- Vector addition in an additive monoid localization. -/]
protected def hsmul (c : R) :
X[S⁻¹] → X[S⁻¹] :=
liftExpand (fun m s ↦ oreNum (c • 1) s • m /ₒ oreDenom (c • 1) s) (fun r t s ht ↦ by
dsimp only
rw [← mul_one (oreDenom (c • 1) s), ← oreDiv_smul_oreDiv, ← mul_one (oreDenom (c • 1) _),
← oreDiv_smul_oreDiv, ← OreLocalization.expand])
/- Warning: This gives an diamond on `SMul R[S⁻¹] M[S⁻¹][S⁻¹]`, but we will almost never localize
at the same monoid twice. -/
/- Although the definition does not require `IsScalarTower R M X`,
it does not make sense without it. -/
@[to_additive (attr := nolint unusedArguments)]
instance [SMul R X] [SMul R M] [IsScalarTower R M X] [IsScalarTower R M M] : SMul R (X[S⁻¹]) where
smul := OreLocalization.hsmul
@[to_additive]
theorem smul_oreDiv (r : R) (x : X) (s : S) :
r • (x /ₒ s) = oreNum (r • 1) s • x /ₒ oreDenom (r • 1) s := by with_unfolding_all rfl
@[to_additive (attr := simp)]
theorem oreDiv_one_smul (r : M) (x : X[S⁻¹]) : (r /ₒ (1 : S)) • x = r • x := by
cases x
rw [smul_oreDiv, oreDiv_smul_oreDiv, mul_one, smul_eq_mul, mul_one]
@[to_additive]
theorem smul_one_smul (r : R) (x : X[S⁻¹]) : (r • 1 : M) • x = r • x := by
cases x
simp only [smul_oreDiv, smul_eq_mul, mul_one]
@[to_additive]
theorem smul_one_oreDiv_one_smul (r : R) (x : X[S⁻¹]) :
((r • 1 : M) /ₒ (1 : S)) • x = r • x := by
rw [oreDiv_one_smul, smul_one_smul]
@[to_additive]
instance : IsScalarTower R R' X[S⁻¹] where
smul_assoc r m x := by
rw [← smul_one_oreDiv_one_smul, ← smul_one_oreDiv_one_smul, ← smul_one_oreDiv_one_smul,
← mul_smul, mul_div_one]
simp only [smul_mul_assoc, smul_assoc, one_mul]
@[to_additive]
instance [SMulCommClass R R' M] : SMulCommClass R R' X[S⁻¹] where
smul_comm r m x := by
rw [← smul_one_smul m, ← smul_assoc, smul_comm, smul_assoc, smul_one_smul]
@[to_additive]
instance : IsScalarTower R M[S⁻¹] X[S⁻¹] where
smul_assoc r m x := by
rw [← smul_one_oreDiv_one_smul, ← smul_one_oreDiv_one_smul, ← mul_smul, smul_eq_mul]
@[to_additive]
instance [SMulCommClass R M M] : SMulCommClass R M[S⁻¹] X[S⁻¹] where
smul_comm r x y := by
cases x with | _ r₁ s₁
cases y with | _ r₂ s₂
rw [← smul_one_oreDiv_one_smul, ← smul_one_oreDiv_one_smul, smul_smul, smul_smul,
mul_div_one, oreDiv_mul_char _ _ _ _ (r • 1) s₁ (by simp), mul_one]
simp
@[to_additive]
instance [SMul Rᵐᵒᵖ M] [SMul Rᵐᵒᵖ X] [IsScalarTower Rᵐᵒᵖ M M] [IsScalarTower Rᵐᵒᵖ M X]
[IsCentralScalar R M] : IsCentralScalar R X[S⁻¹] where
op_smul_eq_smul r x := by
rw [← smul_one_oreDiv_one_smul, ← smul_one_oreDiv_one_smul, op_smul_eq_smul]
@[to_additive]
instance {R} [Monoid R] [MulAction R M] [IsScalarTower R M M]
[MulAction R X] [IsScalarTower R M X] : MulAction R X[S⁻¹] where
one_smul := OreLocalization.ind fun x s ↦ by
rw [← smul_one_oreDiv_one_smul, one_smul, ← OreLocalization.one_def, one_smul]
mul_smul s₁ s₂ x := by rw [← smul_eq_mul, smul_assoc]
@[to_additive]
theorem smul_oreDiv_one (r : R) (x : X) : r • (x /ₒ (1 : S)) = (r • x) /ₒ (1 : S) := by
rw [← smul_one_oreDiv_one_smul, smul_div_one, smul_assoc, one_smul]
end SMul
section CommMonoid
variable {R : Type*} [CommMonoid R] {S : Submonoid R} [OreSet S]
@[to_additive]
theorem oreDiv_mul_oreDiv_comm {r₁ r₂ : R} {s₁ s₂ : S} :
r₁ /ₒ s₁ * (r₂ /ₒ s₂) = r₁ * r₂ /ₒ (s₁ * s₂) := by
rw [oreDiv_mul_char r₁ r₂ s₁ s₂ r₁ s₂ (by simp [mul_comm]), mul_comm s₂]
@[to_additive]
instance : CommMonoid R[S⁻¹] where
mul_comm := fun x y => by
cases x with | _ r₁ s₁
cases y with | _ r₂ s₂
rw [oreDiv_mul_oreDiv_comm, oreDiv_mul_oreDiv_comm, mul_comm r₁, mul_comm s₁]
end CommMonoid
section Zero
variable {R : Type*} [Monoid R] {S : Submonoid R} [OreSet S] {X : Type*} [Zero X]
variable [MulAction R X]
/-- `0` in the localization, defined as `0 /ₒ 1`. -/
@[irreducible]
protected def zero : X[S⁻¹] := 0 /ₒ 1
instance : Zero X[S⁻¹] :=
⟨OreLocalization.zero⟩
protected theorem zero_def : (0 : X[S⁻¹]) = 0 /ₒ 1 := by
with_unfolding_all rfl
end Zero
end OreLocalization |
.lake/packages/mathlib/Mathlib/GroupTheory/OreLocalization/Cardinality.lean | import Mathlib.Data.Fintype.Pigeonhole
import Mathlib.GroupTheory.OreLocalization.Basic
import Mathlib.SetTheory.Cardinal.Arithmetic
/-!
# Cardinality of Ore localizations
This file contains some results on cardinality of Ore localizations.
## TODO
- Prove or disprove `OreLocalization.cardinalMk_le_lift_cardinalMk_of_commute`
with `Commute` assumption removed.
-/
universe u v
open Cardinal Function
namespace OreLocalization
variable {R : Type u} [Monoid R] (S : Submonoid R) [OreLocalization.OreSet S]
(X : Type v) [MulAction R X]
@[to_additive]
theorem oreDiv_one_surjective_of_finite_left [Finite S] :
Surjective (fun x ↦ x /ₒ (1 : ↥S) : X → OreLocalization S X) := by
refine OreLocalization.ind fun x s ↦ ?_
obtain ⟨i, j, hne, heq⟩ := Finite.exists_ne_map_eq_of_infinite (α := ℕ) (s ^ ·)
wlog hlt : j < i generalizing i j
· exact this j i hne.symm heq.symm (hne.lt_of_le (not_lt.1 hlt))
use s ^ (i - (j + 1)) • x
rw [oreDiv_eq_iff]
refine ⟨s ^ j, (s ^ (j + 1)).1, ?_, ?_⟩
· change s ^ j • x = s ^ (j + 1) • s ^ (i - (j + 1)) • x
rw [← mul_smul, ← pow_add, Nat.add_sub_cancel' hlt, heq]
· simp_rw [SubmonoidClass.coe_pow, OneMemClass.coe_one, mul_one, pow_succ]
@[to_additive]
theorem oreDiv_one_surjective_of_finite_right [Finite X] :
Surjective (fun x ↦ x /ₒ (1 : ↥S) : X → OreLocalization S X) := by
refine OreLocalization.ind fun x s ↦ ?_
obtain ⟨i, j, hne, heq⟩ := Finite.exists_ne_map_eq_of_infinite (α := ℕ) (s ^ · • x)
wlog hlt : j < i generalizing i j
· exact this j i hne.symm heq.symm (hne.lt_of_le (not_lt.1 hlt))
use s ^ (i - (j + 1)) • x
rw [oreDiv_eq_iff]
refine ⟨s ^ j, (s ^ (j + 1)).1, ?_, ?_⟩
· change s ^ j • x = s ^ (j + 1) • s ^ (i - (j + 1)) • x
rw [← mul_smul, ← pow_add, Nat.add_sub_cancel' hlt, heq]
· simp_rw [SubmonoidClass.coe_pow, OneMemClass.coe_one, mul_one, pow_succ]
@[to_additive]
theorem numeratorHom_surjective_of_finite [Finite S] : Surjective (numeratorHom (S := S)) :=
oreDiv_one_surjective_of_finite_left S R
@[to_additive]
theorem cardinalMk_le_max : #(OreLocalization S X) ≤ max (lift.{v} #S) (lift.{u} #X) := by
rcases finite_or_infinite X with _ | _
· have := lift_mk_le_lift_mk_of_surjective (oreDiv_one_surjective_of_finite_right S X)
rw [lift_umax.{v, u}, lift_id'] at this
exact le_max_of_le_right this
rcases finite_or_infinite S with _ | _
· have := lift_mk_le_lift_mk_of_surjective (oreDiv_one_surjective_of_finite_left S X)
rw [lift_umax.{v, u}, lift_id'] at this
exact le_max_of_le_right this
convert ← mk_le_of_surjective (show Surjective fun x : X × S ↦ x.1 /ₒ x.2 from
Quotient.mk''_surjective)
rw [mk_prod, mul_comm]
refine mul_eq_max ?_ ?_ <;> simp
@[to_additive]
theorem cardinalMk_le : #(OreLocalization S R) ≤ #R := by
convert ← cardinalMk_le_max S R
simp_rw [lift_id, max_eq_right_iff, mk_subtype_le]
-- TODO: remove the `Commute` assumption
@[to_additive]
theorem cardinalMk_le_lift_cardinalMk_of_commute (hc : ∀ s s' : S, Commute s s') :
#(OreLocalization S X) ≤ lift.{u} #X := by
rcases finite_or_infinite X with _ | _
· have := lift_mk_le_lift_mk_of_surjective (oreDiv_one_surjective_of_finite_right S X)
rwa [lift_umax.{v, u}, lift_id'] at this
have key (x : X) (s s' : S) (h : s • x = s' • x) (hc : Commute s s') : x /ₒ s = x /ₒ s' := by
rw [oreDiv_eq_iff]
refine ⟨s, s'.1, h, ?_⟩
· exact_mod_cast hc
let i (x : X × S) := x.1 /ₒ x.2
have hsurj : Surjective i := Quotient.mk''_surjective
have hi := rightInverse_surjInv hsurj
let j := (fun x : X × S ↦ (x.1, x.2 • x.1)) ∘ surjInv hsurj
suffices Injective j by
have := lift_mk_le_lift_mk_of_injective this
rwa [lift_umax.{v, u}, lift_id', mk_prod, lift_id, lift_mul, mul_eq_self (by simp)] at this
intro
grind
end OreLocalization |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/Finite.lean | import Mathlib.GroupTheory.Finiteness
import Mathlib.GroupTheory.MonoidLocalization.GrothendieckGroup
/-!
# Localization of a finitely generated submonoid
## TODO
If `Mathlib/GroupTheory/Finiteness.lean` wasn't so heavy, this could move earlier.
-/
open Localization
variable {M : Type*} [CommMonoid M] {S : Submonoid M}
namespace Localization
/-- The localization of a finitely generated monoid at a finitely generated submonoid is
finitely generated. -/
@[to_additive /-- The localization of a finitely generated monoid at a finitely generated submonoid
is finitely generated. -/]
lemma fg [Monoid.FG M] (hS : S.FG) : Monoid.FG <| Localization S := by
rw [← Monoid.fg_iff_submonoid_fg] at hS; exact Monoid.fg_of_surjective mkHom mkHom_surjective
end Localization
namespace Algebra.GrothendieckGroup
/-- The Grothendieck group of a finitely generated monoid is finitely generated. -/
@[to_additive /-- The Grothendieck group of a finitely generated monoid is finitely generated. -/]
instance instFG [Monoid.FG M] : Monoid.FG <| GrothendieckGroup M := fg Monoid.FG.fg_top
end Algebra.GrothendieckGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/Away.lean | import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.GroupTheory.MonoidLocalization.Basic
/-!
# Localizing commutative monoids away from an element
We treat the special case of localizing away from an element in the sections
`AwayMap` and `Away`.
## Tags
localization, monoid localization, quotient monoid, congruence relation, characteristic predicate,
commutative monoid, grothendieck group
-/
assert_not_exists MonoidWithZero
open Function
section CommMonoid
variable {M : Type*} [CommMonoid M] {S : Submonoid M} {N : Type*} [CommMonoid N] {P : Type*}
[CommMonoid P]
namespace Submonoid
namespace LocalizationMap
section AwayMap
variable {g : M →* P} (hg : ∀ y : S, IsUnit (g y))
variable (x : M)
/-- Given `x : M`, the type of `CommMonoid` homomorphisms `f : M →* N` such that `N`
is isomorphic to the Localization of `M` at the Submonoid generated by `x`. -/
@[to_additive
/-- Given `x : M`, the type of `AddCommMonoid` homomorphisms `f : M →+ N` such that `N` is
isomorphic to the localization of `M` at the AddSubmonoid generated by `x`. -/]
abbrev AwayMap (N' : Type*) [CommMonoid N'] := LocalizationMap (powers x) N'
variable (F : AwayMap x N)
/-- Given `x : M` and a Localization map `F : M →* N` away from `x`, `invSelf` is `(F x)⁻¹`. -/
noncomputable def AwayMap.invSelf : N := F.mk' 1 ⟨x, mem_powers _⟩
/-- Given `x : M`, a Localization map `F : M →* N` away from `x`, and a map of `CommMonoid`s
`g : M →* P` such that `g x` is invertible, the homomorphism induced from `N` to `P` sending
`z : N` to `g y * (g x)⁻ⁿ`, where `y : M, n : ℕ` are such that `z = F y * (F x)⁻ⁿ`. -/
noncomputable def AwayMap.lift (hg : IsUnit (g x)) : N →* P :=
Submonoid.LocalizationMap.lift F fun y ↦
show IsUnit (g y.1) by
obtain ⟨n, hn⟩ := y.2
rw [← hn, g.map_pow]
exact IsUnit.pow n hg
@[simp]
theorem AwayMap.lift_eq (hg : IsUnit (g x)) (a : M) : F.lift x hg (F a) = g a :=
Submonoid.LocalizationMap.lift_eq _ _ _
@[simp]
theorem AwayMap.lift_comp (hg : IsUnit (g x)) : (F.lift x hg).comp F = g :=
Submonoid.LocalizationMap.lift_comp _ _
/-- Given `x y : M` and Localization maps `F : M →* N, G : M →* P` away from `x` and `x * y`
respectively, the homomorphism induced from `N` to `P`. -/
noncomputable def awayToAwayRight (y : M) (G : AwayMap (x * y) P) : N →* P :=
F.lift x <|
show IsUnit (G x) from
.of_mul_eq_one (G.mk' y ⟨x * y, mem_powers _⟩) <| by
rw [mul_mk'_eq_mk'_of_mul, mk'_self]
end AwayMap
end LocalizationMap
end Submonoid
namespace AddSubmonoid
namespace LocalizationMap
section AwayMap
variable {A : Type*} [AddCommMonoid A] (x : A) {B : Type*} [AddCommMonoid B] (F : AwayMap x B)
{C : Type*} [AddCommMonoid C] {g : A →+ C}
/-- Given `x : A` and a Localization map `F : A →+ B` away from `x`, `neg_self` is `- (F x)`. -/
noncomputable def AwayMap.negSelf : B :=
F.mk' 0 ⟨x, mem_multiples _⟩
/-- Given `x : A`, a localization map `F : A →+ B` away from `x`, and a map of `AddCommMonoid`s
`g : A →+ C` such that `g x` is invertible, the homomorphism induced from `B` to `C` sending
`z : B` to `g y - n • g x`, where `y : A, n : ℕ` are such that `z = F y - n • F x`. -/
noncomputable def AwayMap.lift (hg : IsAddUnit (g x)) : B →+ C :=
AddSubmonoid.LocalizationMap.lift F fun y ↦
show IsAddUnit (g y.1) by
obtain ⟨n, hn⟩ := y.2
rw [← hn]
dsimp
rw [g.map_nsmul]
exact IsAddUnit.map (nsmulAddMonoidHom n : C →+ C) hg
@[simp]
theorem AwayMap.lift_eq (hg : IsAddUnit (g x)) (a : A) : F.lift x hg (F a) = g a :=
AddSubmonoid.LocalizationMap.lift_eq _ _ _
@[simp]
theorem AwayMap.lift_comp (hg : IsAddUnit (g x)) : (F.lift x hg).comp F = g :=
AddSubmonoid.LocalizationMap.lift_comp _ _
/-- Given `x y : A` and Localization maps `F : A →+ B, G : A →+ C` away from `x` and `x + y`
respectively, the homomorphism induced from `B` to `C`. -/
noncomputable def awayToAwayRight (y : A) (G : AwayMap (x + y) C) : B →+ C :=
F.lift x <|
show IsAddUnit (G x) from
.of_add_eq_zero (G.mk' y ⟨x + y, mem_multiples _⟩) <| by
rw [add_mk'_eq_mk'_of_add, mk'_self]
end AwayMap
end LocalizationMap
end AddSubmonoid
namespace Localization
section Away
variable (x : M)
/-- Given `x : M`, the Localization of `M` at the Submonoid generated by `x`, as a quotient. -/
@[to_additive
/-- Given `x : M`, the Localization of `M` at the Submonoid generated by `x`, as a quotient. -/]
abbrev Away :=
Localization (Submonoid.powers x)
/-- Given `x : M`, `invSelf` is `x⁻¹` in the Localization (as a quotient type) of `M` at the
Submonoid generated by `x`. -/
@[to_additive
/-- Given `x : M`, `negSelf` is `-x` in the Localization (as a quotient type) of `M` at the
Submonoid generated by `x`. -/]
def Away.invSelf : Away x :=
mk 1 ⟨x, Submonoid.mem_powers _⟩
/-- Given `x : M`, the natural hom sending `y : M`, `M` a `CommMonoid`, to the equivalence class
of `(y, 1)` in the Localization of `M` at the Submonoid generated by `x`. -/
@[to_additive
/-- Given `x : M`, the natural hom sending `y : M`, `M` an `AddCommMonoid`, to the equivalence
class of `(y, 0)` in the Localization of `M` at the Submonoid generated by `x`. -/]
abbrev Away.monoidOf : Submonoid.LocalizationMap.AwayMap x (Away x) :=
Localization.monoidOf (Submonoid.powers x)
@[to_additive]
theorem Away.mk_eq_monoidOf_mk' : mk = (Away.monoidOf x).mk' := by
simp [Localization.mk_eq_monoidOf_mk']
/-- Given `x : M` and a Localization map `f : M →* N` away from `x`, we get an isomorphism between
the Localization of `M` at the Submonoid generated by `x` as a quotient type and `N`. -/
@[to_additive
/-- Given `x : M` and a Localization map `f : M →+ N` away from `x`, we get an isomorphism between
the Localization of `M` at the Submonoid generated by `x` as a quotient type and `N`. -/]
noncomputable def Away.mulEquivOfQuotient (f : Submonoid.LocalizationMap.AwayMap x N) :
Away x ≃* N :=
Localization.mulEquivOfQuotient f
end Away
end Localization
end CommMonoid |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/GrothendieckGroup.lean | import Mathlib.GroupTheory.MonoidLocalization.Basic
/-!
# Grothendieck group
The Grothendieck group of a commutative monoid `M` is the "smallest" commutative group `G`
containing `M`, in the sense that monoid homs `M → H` are in bijection with monoid homs `G → H` for
any commutative group `H`.
Note that "Grothendieck group" also refers to the analogous construction in an abelian category
obtained by formally making the last term of each short exact sequence invertible.
### References
* [*Grothendieck group*, Wikipedia](https://en.wikipedia.org/wiki/Grothendieck_group#Grothendieck_group_of_a_commutative_monoid)
-/
open Function Localization
namespace Algebra
variable {M G : Type*} [CommMonoid M] [CommGroup G]
variable (M) in
/-- The Grothendieck group of a monoid `M` is the localization at its top submonoid. -/
@[to_additive
/-- The Grothendieck group of an additive monoid `M` is the localization at its top submonoid. -/]
abbrev GrothendieckGroup : Type _ := Localization (⊤ : Submonoid M)
namespace GrothendieckGroup
/-- The inclusion from a commutative monoid `M` to its Grothendieck group.
Note that this is only injective if `M` is cancellative. -/
@[to_additive
/-- The inclusion from an additive commutative monoid `M` to its Grothendieck group.
Note that this is only injective if `M` is cancellative. -/]
abbrev of : M →* GrothendieckGroup M := (monoidOf ⊤).toMonoidHom
@[to_additive]
lemma of_injective [IsCancelMul M] : Injective (of (M := M)) :=
fun m₁ m₂ ↦ by simp [of, ← mk_one_eq_monoidOf_mk, mk_eq_mk_iff']
@[to_additive]
instance : Inv (GrothendieckGroup M) where
inv := rec (fun m s ↦ (.mk s ⟨m, Submonoid.mem_top m⟩ : GrothendieckGroup M))
fun {m₁ m₂ s₁ s₂} h ↦ by simpa [r_iff_exists, mk_eq_mk_iff, eq_comm, mul_comm] using h
@[to_additive (attr := simp)]
lemma inv_mk (m : M) (s : (⊤ : Submonoid M)) : (mk m s)⁻¹ = .mk s ⟨m, Submonoid.mem_top _⟩ := rfl
/-- The Grothendieck group is a group. -/
@[to_additive /-- The Grothendieck group is a group. -/]
instance instCommGroup : CommGroup (GrothendieckGroup M) where
__ : CommMonoid (GrothendieckGroup M) := inferInstance
inv_mul_cancel a := by
cases a using ind
rw [inv_mk, mk_eq_monoidOf_mk', ←Submonoid.LocalizationMap.mk'_mul]
convert Submonoid.LocalizationMap.mk'_self' _ _
rw [mul_comm, Submonoid.coe_mul]
@[to_additive (attr := simp)]
lemma mk_div_mk (m₁ m₂ : M) (s₁ s₂ : (⊤ : Submonoid M)) :
mk m₁ s₁ / mk m₂ s₂ = .mk (m₁ * s₂) ⟨s₁ * m₂, Submonoid.mem_top _⟩ := by
simp [div_eq_mul_inv, mk_mul]; rfl
/-- A monoid homomorphism from a monoid `M` to a group `G` lifts to a group homomorphism from the
Grothendieck group of `M` to `G`. -/
@[to_additive (attr := simps symm_apply)
/-- A monoid homomorphism from a monoid `M` to a group `G` lifts to a group homomorphism from the
Grothendieck group of `M` to `G`. -/]
noncomputable def lift : (M →* G) ≃ (GrothendieckGroup M →* G) where
toFun f := (monoidOf ⊤).lift (g := f) fun _ ↦ Group.isUnit _
invFun f := f.comp of
left_inv f := by ext; simp
right_inv f := by ext; simp
@[to_additive]
lemma lift_apply (f : M →* G) (x : GrothendieckGroup M) :
lift f x = f ((monoidOf ⊤).sec x).1 / f ((monoidOf ⊤).sec x).2 := by
simp [lift, (monoidOf ⊤).lift_apply, div_eq_mul_inv]; congr
end Algebra.GrothendieckGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/Order.lean | import Mathlib.Algebra.Order.Monoid.Defs
import Mathlib.GroupTheory.MonoidLocalization.Basic
/-!
# Ordered structures on localizations of commutative monoids
-/
open Function
namespace Localization
variable {α : Type*}
section OrderedCancelCommMonoid
variable [CommMonoid α] [PartialOrder α] [IsOrderedCancelMonoid α] {s : Submonoid α}
{a₁ b₁ : α} {a₂ b₂ : s}
@[to_additive]
instance le : LE (Localization s) :=
⟨fun a b =>
Localization.liftOn₂ a b (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ ≤ a₂ * b₁)
fun {a₁ b₁ a₂ b₂ c₁ d₁ c₂ d₂} hab hcd => propext <| by
obtain ⟨e, he⟩ := r_iff_exists.1 hab
obtain ⟨f, hf⟩ := r_iff_exists.1 hcd
simp only [mul_right_inj] at he hf
dsimp
rw [← mul_le_mul_iff_right, mul_right_comm, ← hf, mul_right_comm, mul_right_comm (a₂ : α),
mul_le_mul_iff_right, ← mul_le_mul_iff_left, mul_left_comm, he, mul_left_comm,
mul_left_comm (b₂ : α), mul_le_mul_iff_left]⟩
@[to_additive]
instance lt : LT (Localization s) :=
⟨fun a b =>
Localization.liftOn₂ a b (fun a₁ a₂ b₁ b₂ => ↑b₂ * a₁ < a₂ * b₁)
fun {a₁ b₁ a₂ b₂ c₁ d₁ c₂ d₂} hab hcd => propext <| by
obtain ⟨e, he⟩ := r_iff_exists.1 hab
obtain ⟨f, hf⟩ := r_iff_exists.1 hcd
simp only [mul_right_inj] at he hf
dsimp
rw [← mul_lt_mul_iff_right, mul_right_comm, ← hf, mul_right_comm, mul_right_comm (a₂ : α),
mul_lt_mul_iff_right, ← mul_lt_mul_iff_left, mul_left_comm, he, mul_left_comm,
mul_left_comm (b₂ : α), mul_lt_mul_iff_left]⟩
@[to_additive]
theorem mk_le_mk : mk a₁ a₂ ≤ mk b₁ b₂ ↔ ↑b₂ * a₁ ≤ a₂ * b₁ :=
Iff.rfl
@[to_additive]
theorem mk_lt_mk : mk a₁ a₂ < mk b₁ b₂ ↔ ↑b₂ * a₁ < a₂ * b₁ :=
Iff.rfl
-- declaring this separately to the instance below makes things faster
@[to_additive]
instance partialOrder : PartialOrder (Localization s) where
le_refl a := Localization.induction_on a fun _ => le_rfl
le_trans a b c :=
Localization.induction_on₃ a b c fun a b c hab hbc => by
simp only [mk_le_mk] at hab hbc ⊢
apply le_of_mul_le_mul_left' _
· exact ↑b.2
grw [mul_left_comm, hab]
rwa [mul_left_comm, mul_left_comm (b.2 : α), mul_le_mul_iff_left]
le_antisymm a b := by
induction a using Localization.rec
on_goal 1 =>
induction b using Localization.rec
· simp_rw [mk_le_mk, mk_eq_mk_iff, r_iff_exists]
exact fun hab hba => ⟨1, by rw [hab.antisymm hba]⟩
all_goals rfl
lt_iff_le_not_ge a b := Localization.induction_on₂ a b fun _ _ => lt_iff_le_not_ge
@[to_additive]
instance isOrderedCancelMonoid : IsOrderedCancelMonoid (Localization s) where
mul_le_mul_left := fun a b =>
Localization.induction_on₂ a b fun a b hab c =>
Localization.induction_on c fun c => by
simp only [mk_mul, mk_le_mk, Submonoid.coe_mul, mul_mul_mul_comm _ _ c.1] at hab ⊢
exact mul_le_mul_left' hab _
le_of_mul_le_mul_left := fun a b c =>
Localization.induction_on₃ a b c fun a b c hab => by
simp only [mk_mul, mk_le_mk, Submonoid.coe_mul, mul_mul_mul_comm _ _ a.1] at hab ⊢
exact le_of_mul_le_mul_left' hab
@[to_additive]
instance decidableLE [DecidableLE α] : DecidableLE (Localization s) := fun a b =>
Localization.recOnSubsingleton₂ a b fun _ _ _ _ => decidable_of_iff' _ mk_le_mk
@[to_additive]
instance decidableLT [DecidableLT α] : DecidableLT (Localization s) := fun a b =>
Localization.recOnSubsingleton₂ a b fun _ _ _ _ => decidable_of_iff' _ mk_lt_mk
/-- An ordered cancellative monoid injects into its localization by sending `a` to `a / b`. -/
@[to_additive (attr := simps!) /-- An ordered cancellative monoid injects into its localization by
sending `a` to `a - b`. -/]
def mkOrderEmbedding (b : s) : α ↪o Localization s where
toFun a := mk a b
inj' := mk_left_injective _
map_rel_iff' {a b} := by simp [mk_le_mk]
end OrderedCancelCommMonoid
@[to_additive]
instance [CommMonoid α] [LinearOrder α] [IsOrderedCancelMonoid α] {s : Submonoid α} :
LinearOrder (Localization s) :=
{ le_total := fun a b =>
Localization.induction_on₂ a b fun _ _ => by
simp_rw [mk_le_mk]
exact le_total _ _
toDecidableLE := Localization.decidableLE
toDecidableLT := Localization.decidableLT
toDecidableEq := Localization.decidableEq }
end Localization |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/MonoidWithZero.lean | import Mathlib.Algebra.GroupWithZero.Hom
import Mathlib.GroupTheory.MonoidLocalization.Basic
import Mathlib.RingTheory.OreLocalization.Basic
import Mathlib.Algebra.GroupWithZero.Units.Basic
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
/-!
# Localizations of commutative monoids with zeroes
-/
open Function
section CommMonoidWithZero
variable {M : Type*} [CommMonoidWithZero M] (S : Submonoid M) (N : Type*) [CommMonoidWithZero N]
{P : Type*} [CommMonoidWithZero P]
namespace Submonoid
variable {S N}
/-- If `S` contains `0` then the localization at `S` is trivial. -/
theorem LocalizationMap.subsingleton (f : LocalizationMap S N) (h : 0 ∈ S) :
Subsingleton N := by
refine ⟨fun a b ↦ ?_⟩
rw [← LocalizationMap.mk'_sec f a, ← LocalizationMap.mk'_sec f b, LocalizationMap.eq]
exact ⟨⟨0, h⟩, by simp only [zero_mul]⟩
theorem LocalizationMap.subsingleton_iff (f : LocalizationMap S N) : Subsingleton N ↔ 0 ∈ S :=
⟨fun _ ↦ have ⟨c, eq⟩ := f.exists_of_eq 0 1 (Subsingleton.elim ..)
by rw [mul_zero, mul_one] at eq; exact eq ▸ c.2, f.subsingleton⟩
theorem LocalizationMap.nontrivial (f : LocalizationMap S N) (h : 0 ∉ S) : Nontrivial N := by
rwa [← not_subsingleton_iff_nontrivial, f.subsingleton_iff]
protected theorem LocalizationMap.map_zero (f : LocalizationMap S N) : f 0 = 0 := by
have ⟨ms, eq⟩ := f.surj 0
rw [← zero_mul, map_mul, ← eq, zero_mul, mul_zero]
/-- The monoid with zero hom underlying a `LocalizationMap`. -/
def LocalizationMap.toMonoidWithZeroHom (f : LocalizationMap S N) : M →*₀ N :=
{ f with map_zero' := f.map_zero }
@[deprecated (since := "2025-08-01")] alias LocalizationWithZeroMap := LocalizationMap
@[deprecated (since := "2025-08-01")]
alias LocalizationWithZeroMap.toMonoidWithZeroHom := LocalizationMap.toMonoidWithZeroHom
end Submonoid
namespace Localization
variable {S}
theorem mk_zero (x : S) : mk 0 (x : S) = 0 := OreLocalization.zero_oreDiv' _
instance : CommMonoidWithZero (Localization S) where
zero_mul := fun x ↦ Localization.induction_on x fun y => by
simp only [← Localization.mk_zero y.2, mk_mul, mk_eq_mk_iff, mul_zero, zero_mul, r_of_eq]
mul_zero := fun x ↦ Localization.induction_on x fun y => by
simp only [← Localization.mk_zero y.2, mk_mul, mk_eq_mk_iff, mul_zero, r_of_eq]
theorem liftOn_zero {p : Type*} (f : M → S → p) (H) : liftOn 0 f H = f 0 1 := by
rw [← mk_zero 1, liftOn_mk]
end Localization
variable {S N}
namespace Submonoid
@[simp]
theorem LocalizationMap.sec_zero_fst {f : LocalizationMap S N} : f (f.sec 0).fst = 0 := by
rw [LocalizationMap.sec_spec', mul_zero]
namespace LocalizationMap
/-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M` and a map of
`CommMonoidWithZero`s `g : M →*₀ P` such that `g y` is invertible for all `y : S`, the
homomorphism induced from `N` to `P` sending `z : N` to `g x * (g y)⁻¹`, where `(x, y) : M × S`
are such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift₀ (f : LocalizationMap S N) (g : M →*₀ P)
(hg : ∀ y : S, IsUnit (g y)) : N →*₀ P :=
{ @LocalizationMap.lift _ _ _ _ _ _ _ f g.toMonoidHom hg with
map_zero' := by
dsimp only [OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe]
rw [LocalizationMap.lift_spec f hg 0 0, mul_zero, ← map_zero g, ← g.toMonoidHom_coe]
refine f.eq_of_eq hg ?_
rw [LocalizationMap.sec_zero_fst]
exact f.toMonoidWithZeroHom.map_zero.symm }
lemma lift₀_def (f : LocalizationMap S N) (g : M →*₀ P) (hg : ∀ y : S, IsUnit (g y)) :
⇑(f.lift₀ g hg) = f.lift (g := g) hg := rfl
lemma lift₀_apply (f : LocalizationMap S N) (g : M →*₀ P) (hg : ∀ y : S, IsUnit (g y)) (x) :
f.lift₀ g hg x = g (f.sec x).1 * (IsUnit.liftRight (g.restrict S) hg (f.sec x).2)⁻¹ := rfl
/-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M`,
if `M` is a cancellative monoid with zero, and all elements of `S` are
regular, then N is a cancellative monoid with zero. -/
theorem isCancelMulZero (f : LocalizationMap S N) [IsCancelMulZero M] : IsCancelMulZero N := by
simp_rw [isCancelMulZero_iff_forall_isRegular, Commute.isRegular_iff (Commute.all _),
← Commute.isRightRegular_iff (Commute.all _)]
intro n hn
have ⟨ms, eq⟩ := f.surj n
refine (eq ▸ f.map_isRegular (isCancelMulZero_iff_forall_isRegular.mp ‹_› ?_)).2.of_mul
refine fun h ↦ hn ?_
rwa [h, f.map_zero, (f.map_units _).mul_left_eq_zero] at eq
theorem map_eq_zero_iff (f : LocalizationMap S N) {m : M} : f m = 0 ↔ ∃ s : S, s * m = 0 := by
simp_rw [← f.map_zero, eq_iff_exists, mul_zero]
theorem mk'_eq_zero_iff (f : LocalizationMap S N) (m : M) (s : S) :
f.mk' m s = 0 ↔ ∃ s : S, s * m = 0 := by
rw [← (f.map_units s).mul_left_inj, mk'_spec, zero_mul, map_eq_zero_iff]
@[simp] theorem mk'_zero (f : LocalizationMap S N) (s : S) : f.mk' 0 s = 0 := by
rw [eq_comm, eq_mk'_iff_mul_eq, zero_mul, f.map_zero]
theorem nonZeroDivisors_le_comap (f : LocalizationMap S N) :
nonZeroDivisors M ≤ (nonZeroDivisors N).comap f := by
refine fun m hm ↦ nonZeroDivisorsRight_eq_nonZeroDivisors (M₀ := N) ▸ fun n h0 ↦ ?_
have ⟨ms, eq⟩ := f.surj n
rw [← (f.map_units ms.2).mul_left_eq_zero, mul_right_comm, eq, ← map_mul, map_eq_zero_iff] at h0
simp_rw [← mul_assoc, mul_right_mem_nonZeroDivisorsRight_eq_zero_iff hm.2] at h0
rwa [← (f.map_units ms.2).mul_left_eq_zero, eq, map_eq_zero_iff]
theorem map_nonZeroDivisors_le (f : LocalizationMap S N) :
(nonZeroDivisors M).map f ≤ nonZeroDivisors N :=
map_le_iff_le_comap.mpr f.nonZeroDivisors_le_comap
theorem noZeroDivisors (f : LocalizationMap S N) [NoZeroDivisors M] : NoZeroDivisors N := by
refine noZeroDivisors_iff_forall_mem_nonZeroDivisors.mpr fun n hn ↦ ?_
have ⟨ms, eq⟩ := f.surj n
have hs : ms.1 ≠ 0 := fun h ↦ hn (by rwa [h, f.map_zero, (f.map_units _).mul_left_eq_zero] at eq)
exact And.left <| mul_mem_nonZeroDivisors.mp
(eq ▸ f.map_nonZeroDivisors_le ⟨_, mem_nonZeroDivisors_of_ne_zero hs, rfl⟩)
end LocalizationMap
namespace LocalizationWithZeroMap
@[deprecated (since := "2025-08-01")]
alias isLeftRegular_of_le_isCancelMulZero := LocalizationMap.isCancelMulZero
@[deprecated (since := "2025-08-01")]
alias leftCancelMulZero_of_le_isLeftRegular := LocalizationMap.isCancelMulZero
@[deprecated (since := "2025-08-01")] alias lift := LocalizationMap.lift₀
@[deprecated (since := "2025-08-01")] alias lift_def := LocalizationMap.lift₀_def
@[deprecated (since := "2025-08-01")] alias lift_apply := LocalizationMap.lift₀_apply
end LocalizationWithZeroMap
end Submonoid
end CommMonoidWithZero |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/Basic.lean | import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.Algebra.Regular.Basic
import Mathlib.GroupTheory.Congruence.Hom
import Mathlib.GroupTheory.OreLocalization.Basic
/-!
# Localizations of commutative monoids
Localizing a commutative ring at one of its submonoids does not rely on the ring's addition, so
we can generalize localizations to commutative monoids.
We characterize the localization of a commutative monoid `M` at a submonoid `S` up to
isomorphism; that is, a commutative monoid `N` is the localization of `M` at `S` iff we can find a
monoid homomorphism `f : M →* N` satisfying 3 properties:
1. For all `y ∈ S`, `f y` is a unit;
2. For all `z : N`, there exists `(x, y) : M × S` such that `z * f y = f x`;
3. For all `x, y : M` such that `f x = f y`, there exists `c ∈ S` such that `x * c = y * c`.
(The converse is a consequence of 1.)
Given such a localization map `f : M →* N`, we can define the surjection
`Submonoid.LocalizationMap.mk'` sending `(x, y) : M × S` to `f x * (f y)⁻¹`, and
`Submonoid.LocalizationMap.lift`, the homomorphism from `N` induced by a homomorphism from `M` which
maps elements of `S` to invertible elements of the codomain. Similarly, given commutative monoids
`P, Q`, a submonoid `T` of `P` and a localization map for `T` from `P` to `Q`, then a homomorphism
`g : M →* P` such that `g(S) ⊆ T` induces a homomorphism of localizations, `LocalizationMap.map`,
from `N` to `Q`.
We also define the quotient of `M × S` by the unique congruence relation (equivalence relation
preserving a binary operation) `r` such that for any other congruence relation `s` on `M × S`
satisfying '`∀ y ∈ S`, `(1, 1) ∼ (y, y)` under `s`', we have that `(x₁, y₁) ∼ (x₂, y₂)` by `s`
whenever `(x₁, y₁) ∼ (x₂, y₂)` by `r`. We show this relation is equivalent to the standard
localization relation.
This defines the localization as a quotient type, `Localization`, but the majority of
subsequent lemmas in the file are given in terms of localizations up to isomorphism, using maps
which satisfy the characteristic predicate.
The Grothendieck group construction corresponds to localizing at the top submonoid, namely making
every element invertible.
## Implementation notes
In maths it is natural to reason up to isomorphism, but in Lean we cannot naturally `rewrite` one
structure with an isomorphic one; one way around this is to isolate a predicate characterizing
a structure up to isomorphism, and reason about things that satisfy the predicate.
The infimum form of the localization congruence relation is chosen as 'canonical' here, since it
shortens some proofs.
To reason about the localization as a quotient type, use `mk_eq_monoidOf_mk'` and associated
lemmas. These show the quotient map `mk : M → S → Localization S` equals the
surjection `LocalizationMap.mk'` induced by the map
`Localization.monoidOf : Submonoid.LocalizationMap S (Localization S)` (where `of` establishes the
localization as a quotient type satisfies the characteristic predicate). The lemma
`mk_eq_monoidOf_mk'` hence gives you access to the results in the rest of the file, which are about
the `LocalizationMap.mk'` induced by any localization map.
## TODO
* Show that the localization at the top monoid is a group.
* Generalise to (nonempty) subsemigroups.
* If we acquire more bundlings, we can make `Localization.mkOrderEmbedding` be an ordered monoid
embedding.
## Tags
localization, monoid localization, quotient monoid, congruence relation, characteristic predicate,
commutative monoid, grothendieck group
-/
assert_not_exists MonoidWithZero Ring
open Function
namespace AddSubmonoid
variable {M : Type*} [AddCommMonoid M] (S : AddSubmonoid M) (N : Type*) [AddCommMonoid N]
/-- The type of AddMonoid homomorphisms satisfying the characteristic predicate: if `f : M →+ N`
satisfies this predicate, then `N` is isomorphic to the localization of `M` at `S`. -/
structure LocalizationMap extends AddMonoidHom M N where
map_add_units' : ∀ y : S, IsAddUnit (toFun y)
surj' : ∀ z : N, ∃ x : M × S, z + toFun x.2 = toFun x.1
exists_of_eq : ∀ x y, toFun x = toFun y → ∃ c : S, ↑c + x = ↑c + y
/-- The AddMonoidHom underlying a `LocalizationMap` of `AddCommMonoid`s. -/
add_decl_doc LocalizationMap.toAddMonoidHom
end AddSubmonoid
section CommMonoid
variable {M : Type*} [CommMonoid M] (S : Submonoid M) (N : Type*) [CommMonoid N] {P : Type*}
[CommMonoid P]
namespace Submonoid
/-- The type of monoid homomorphisms satisfying the characteristic predicate: if `f : M →* N`
satisfies this predicate, then `N` is isomorphic to the localization of `M` at `S`. -/
structure LocalizationMap extends MonoidHom M N where
map_units' : ∀ y : S, IsUnit (toFun y)
surj' : ∀ z : N, ∃ x : M × S, z * toFun x.2 = toFun x.1
exists_of_eq : ∀ x y, toFun x = toFun y → ∃ c : S, ↑c * x = c * y
attribute [to_additive] Submonoid.LocalizationMap
/-- The monoid hom underlying a `LocalizationMap`. -/
add_decl_doc LocalizationMap.toMonoidHom
end Submonoid
namespace Localization
/- Ensure that `@[to_additive]` uses the right namespace before the definition of `Localization`. -/
insert_to_additive_translation Localization AddLocalization
/-- The congruence relation on `M × S`, `M` a `CommMonoid` and `S` a submonoid of `M`, whose
quotient is the localization of `M` at `S`, defined as the unique congruence relation on
`M × S` such that for any other congruence relation `s` on `M × S` where for all `y ∈ S`,
`(1, 1) ∼ (y, y)` under `s`, we have that `(x₁, y₁) ∼ (x₂, y₂)` by `r` implies
`(x₁, y₁) ∼ (x₂, y₂)` by `s`. -/
@[to_additive
/-- The congruence relation on `M × S`, `M` an `AddCommMonoid` and `S` an `AddSubmonoid` of `M`,
whose quotient is the localization of `M` at `S`, defined as the unique congruence relation on
`M × S` such that for any other congruence relation `s` on `M × S` where for all `y ∈ S`,
`(0, 0) ∼ (y, y)` under `s`, we have that `(x₁, y₁) ∼ (x₂, y₂)` by `r` implies
`(x₁, y₁) ∼ (x₂, y₂)` by `s`. -/]
def r (S : Submonoid M) : Con (M × S) :=
sInf { c | ∀ y : S, c 1 (y, y) }
/-- An alternate form of the congruence relation on `M × S`, `M` a `CommMonoid` and `S` a
submonoid of `M`, whose quotient is the localization of `M` at `S`. -/
@[to_additive
/-- An alternate form of the congruence relation on `M × S`, `M` a `CommMonoid` and `S` a
submonoid of `M`, whose quotient is the localization of `M` at `S`. -/]
def r' : Con (M × S) := by
-- note we multiply by `c` on the left so that we can later generalize to `•`
refine
{ r := fun a b : M × S ↦ ∃ c : S, ↑c * (↑b.2 * a.1) = c * (a.2 * b.1)
iseqv := ⟨fun a ↦ ⟨1, rfl⟩, fun ⟨c, hc⟩ ↦ ⟨c, hc.symm⟩, ?_⟩
mul' := ?_ }
· rintro a b c ⟨t₁, ht₁⟩ ⟨t₂, ht₂⟩
use t₂ * t₁ * b.2
simp only [Submonoid.coe_mul]
calc
(t₂ * t₁ * b.2 : M) * (c.2 * a.1) = t₂ * c.2 * (t₁ * (b.2 * a.1)) := by ac_rfl
_ = t₁ * a.2 * (t₂ * (c.2 * b.1)) := by rw [ht₁]; ac_rfl
_ = t₂ * t₁ * b.2 * (a.2 * c.1) := by rw [ht₂]; ac_rfl
· rintro a b c d ⟨t₁, ht₁⟩ ⟨t₂, ht₂⟩
use t₂ * t₁
calc
(t₂ * t₁ : M) * (b.2 * d.2 * (a.1 * c.1)) = t₂ * (d.2 * c.1) * (t₁ * (b.2 * a.1)) := by ac_rfl
_ = (t₂ * t₁ : M) * (a.2 * c.2 * (b.1 * d.1)) := by rw [ht₁, ht₂]; ac_rfl
/-- The congruence relation used to localize a `CommMonoid` at a submonoid can be expressed
equivalently as an infimum (see `Localization.r`) or explicitly
(see `Localization.r'`). -/
@[to_additive
/-- The additive congruence relation used to localize an `AddCommMonoid` at a submonoid can be
expressed equivalently as an infimum (see `AddLocalization.r`) or explicitly
(see `AddLocalization.r'`). -/]
theorem r_eq_r' : r S = r' S :=
le_antisymm (sInf_le fun _ ↦ ⟨1, by simp⟩) <|
le_sInf fun b H ⟨p, q⟩ ⟨x, y⟩ ⟨t, ht⟩ ↦ by
rw [← one_mul (p, q), ← one_mul (x, y)]
refine b.trans (b.mul (H (t * y)) (b.refl _)) ?_
convert b.symm (b.mul (H (t * q)) (b.refl (x, y))) using 1
dsimp only [Prod.mk_mul_mk, Submonoid.coe_mul] at ht ⊢
simp_rw [mul_assoc, ht, mul_comm y q]
variable {S}
@[to_additive]
theorem r_iff_exists {x y : M × S} : r S x y ↔ ∃ c : S, ↑c * (↑y.2 * x.1) = c * (x.2 * y.1) := by
simp only [r_eq_r' S, r', Con.rel_mk]
@[to_additive]
theorem r_iff_oreEqv_r {x y : M × S} : r S x y ↔ (OreLocalization.oreEqv S M).r x y := by
simp only [r_iff_exists, Subtype.exists, exists_prop, OreLocalization.oreEqv, smul_eq_mul,
Submonoid.mk_smul]
constructor
· rintro ⟨u, hu, e⟩
exact ⟨_, mul_mem hu x.2.2, u * y.2, by rw [mul_assoc, mul_assoc, ← e], mul_right_comm _ _ _⟩
· rintro ⟨u, hu, v, e₁, e₂⟩
exact ⟨u, hu, by rw [← mul_assoc, e₂, mul_right_comm, ← e₁, mul_assoc, mul_comm y.1]⟩
end Localization
/-- The localization of a `CommMonoid` at one of its submonoids (as a quotient type). -/
@[to_additive AddLocalization
/-- The localization of an `AddCommMonoid` at one of its submonoids (as a quotient type). -/]
abbrev Localization := OreLocalization S M
namespace Localization
variable {S}
/-- Given a `CommMonoid` `M` and submonoid `S`, `mk` sends `x : M`, `y ∈ S` to the equivalence
class of `(x, y)` in the localization of `M` at `S`. -/
@[to_additive
/-- Given an `AddCommMonoid` `M` and submonoid `S`, `mk` sends `x : M`, `y ∈ S` to
the equivalence class of `(x, y)` in the localization of `M` at `S`. -/]
def mk (x : M) (y : S) : Localization S := x /ₒ y
@[to_additive]
theorem mk_eq_mk_iff {a c : M} {b d : S} : mk a b = mk c d ↔ r S ⟨a, b⟩ ⟨c, d⟩ := by
simp only [mk, OreLocalization.oreDiv_eq_iff, r_iff_oreEqv_r, OreLocalization.oreEqv]
universe u
/-- Dependent recursion principle for `Localizations`: given elements `f a b : p (mk a b)`
for all `a b`, such that `r S (a, b) (c, d)` implies `f a b = f c d` (with the correct coercions),
then `f` is defined on the whole `Localization S`. -/
@[to_additive (attr := elab_as_elim)
/-- Dependent recursion principle for `AddLocalizations`: given elements `f a b : p (mk a b)`
for all `a b`, such that `r S (a, b) (c, d)` implies `f a b = f c d` (with the correct coercions),
then `f` is defined on the whole `AddLocalization S`. -/]
def rec {p : Localization S → Sort u} (f : ∀ (a : M) (b : S), p (mk a b))
(H : ∀ {a c : M} {b d : S} (h : r S (a, b) (c, d)),
(Eq.ndrec (f a b) (mk_eq_mk_iff.mpr h) : p (mk c d)) = f c d) (x) : p x :=
Quot.rec (fun y ↦ Eq.ndrec (f y.1 y.2) (by rfl))
(fun y z h ↦ by cases y; cases z; exact H (r_iff_oreEqv_r.mpr h)) x
/-- Copy of `Quotient.recOnSubsingleton₂` for `Localization` -/
@[to_additive (attr := elab_as_elim)
/-- Copy of `Quotient.recOnSubsingleton₂` for `AddLocalization` -/]
def recOnSubsingleton₂ {r : Localization S → Localization S → Sort u}
[h : ∀ (a c : M) (b d : S), Subsingleton (r (mk a b) (mk c d))] (x y : Localization S)
(f : ∀ (a c : M) (b d : S), r (mk a b) (mk c d)) : r x y :=
@Quotient.recOnSubsingleton₂' _ _ _ _ r (Prod.rec fun _ _ => Prod.rec fun _ _ => h _ _ _ _) x y
(Prod.rec fun _ _ => Prod.rec fun _ _ => f _ _ _ _)
@[to_additive]
theorem mk_mul (a c : M) (b d : S) : mk a b * mk c d = mk (a * c) (b * d) :=
mul_comm b d ▸ OreLocalization.oreDiv_mul_oreDiv
unseal OreLocalization.one in
@[to_additive]
theorem mk_one : mk 1 (1 : S) = 1 := OreLocalization.one_def
@[to_additive]
theorem mk_pow (n : ℕ) (a : M) (b : S) : mk a b ^ n = mk (a ^ n) (b ^ n) := by
induction n <;> simp [pow_succ, *, ← mk_mul, ← mk_one]
@[to_additive]
theorem mk_prod {ι} (t : Finset ι) (f : ι → M) (s : ι → S) :
∏ i ∈ t, mk (f i) (s i) = mk (∏ i ∈ t, f i) (∏ i ∈ t, s i) := by
classical
induction t using Finset.induction_on <;> simp [mk_one, Finset.prod_insert, *, mk_mul]
@[to_additive (attr := simp)]
theorem ndrec_mk {p : Localization S → Sort u} (f : ∀ (a : M) (b : S), p (mk a b)) (H) (a : M)
(b : S) : (rec f H (mk a b) : p (mk a b)) = f a b := rfl
/-- Non-dependent recursion principle for localizations: given elements `f a b : p`
for all `a b`, such that `r S (a, b) (c, d)` implies `f a b = f c d`,
then `f` is defined on the whole `Localization S`. -/
@[to_additive
/-- Non-dependent recursion principle for `AddLocalization`s: given elements `f a b : p`
for all `a b`, such that `r S (a, b) (c, d)` implies `f a b = f c d`,
then `f` is defined on the whole `Localization S`. -/]
def liftOn {p : Sort u} (x : Localization S) (f : M → S → p)
(H : ∀ {a c : M} {b d : S}, r S (a, b) (c, d) → f a b = f c d) : p :=
rec f (fun h ↦ (by simpa only [eq_rec_constant] using H h)) x
@[to_additive]
theorem liftOn_mk {p : Sort u} (f : M → S → p) (H) (a : M) (b : S) :
liftOn (mk a b) f H = f a b := rfl
@[to_additive (attr := elab_as_elim, induction_eliminator, cases_eliminator)]
theorem ind {p : Localization S → Prop} (H : ∀ y : M × S, p (mk y.1 y.2)) (x) : p x :=
rec (fun a b ↦ H (a, b)) (fun _ ↦ rfl) x
@[to_additive (attr := elab_as_elim)]
theorem induction_on {p : Localization S → Prop} (x) (H : ∀ y : M × S, p (mk y.1 y.2)) : p x :=
ind H x
/-- Non-dependent recursion principle for localizations: given elements `f x y : p`
for all `x` and `y`, such that `r S x x'` and `r S y y'` implies `f x y = f x' y'`,
then `f` is defined on the whole `Localization S`. -/
@[to_additive
/-- Non-dependent recursion principle for localizations: given elements `f x y : p`
for all `x` and `y`, such that `r S x x'` and `r S y y'` implies `f x y = f x' y'`,
then `f` is defined on the whole `Localization S`. -/]
def liftOn₂ {p : Sort u} (x y : Localization S) (f : M → S → M → S → p)
(H : ∀ {a a' b b' c c' d d'}, r S (a, b) (a', b') → r S (c, d) (c', d') →
f a b c d = f a' b' c' d') : p :=
liftOn x (fun a b ↦ liftOn y (f a b) fun hy ↦ H ((r S).refl _) hy) fun hx ↦
induction_on y fun ⟨_, _⟩ ↦ H hx ((r S).refl _)
@[to_additive]
theorem liftOn₂_mk {p : Sort*} (f : M → S → M → S → p) (H) (a c : M) (b d : S) :
liftOn₂ (mk a b) (mk c d) f H = f a b c d := rfl
@[to_additive (attr := elab_as_elim)]
theorem induction_on₂ {p : Localization S → Localization S → Prop} (x y)
(H : ∀ x y : M × S, p (mk x.1 x.2) (mk y.1 y.2)) : p x y :=
induction_on x fun x ↦ induction_on y <| H x
@[to_additive (attr := elab_as_elim)]
theorem induction_on₃ {p : Localization S → Localization S → Localization S → Prop} (x y z)
(H : ∀ x y z : M × S, p (mk x.1 x.2) (mk y.1 y.2) (mk z.1 z.2)) : p x y z :=
induction_on₂ x y fun x y ↦ induction_on z <| H x y
@[to_additive]
theorem one_rel (y : S) : r S 1 (y, y) := fun _ hb ↦ hb y
@[to_additive]
theorem r_of_eq {x y : M × S} (h : ↑y.2 * x.1 = ↑x.2 * y.1) : r S x y :=
r_iff_exists.2 ⟨1, by rw [h]⟩
@[to_additive]
theorem mk_self (a : S) : mk (a : M) a = 1 := by
symm
rw [← mk_one, mk_eq_mk_iff]
exact one_rel a
@[to_additive (attr := simp)]
lemma mk_self_mk (a : M) (haS : a ∈ S) : mk a ⟨a, haS⟩ = 1 :=
mk_self ⟨a, haS⟩
/-- `Localization.mk` as a monoid hom. -/
@[to_additive (attr := simps) /-- `Localization.mk` as a monoid hom. -/]
def mkHom : M × S →* Localization S where
toFun x := mk x.1 x.2
map_one' := mk_one
map_mul' _ _ := (mk_mul ..).symm
@[to_additive]
lemma mkHom_surjective : Surjective (mkHom (S := S)) := by rintro ⟨x, y⟩; exact ⟨⟨x, y⟩, rfl⟩
section Scalar
variable {R R₁ R₂ : Type*}
theorem smul_mk [SMul R M] [IsScalarTower R M M] (c : R) (a b) :
c • (mk a b : Localization S) = mk (c • a) b := by
rw [mk, mk, ← OreLocalization.smul_one_oreDiv_one_smul, OreLocalization.oreDiv_smul_oreDiv]
change (c • 1) • a /ₒ (b * 1) = _
rw [smul_assoc, one_smul, mul_one]
-- move me
instance {R M : Type*} [CommMonoid M] [SMul R M] [IsScalarTower R M M] : SMulCommClass R M M where
smul_comm r s x := by
rw [← one_smul M (s • x), ← smul_assoc, smul_comm, smul_assoc, one_smul]
-- Note: Previously there was a `MulDistribMulAction R (Localization S)`.
-- It was removed as it is not the correct action.
end Scalar
end Localization
variable {S N}
namespace MonoidHom
/-- Makes a localization map from a `CommMonoid` hom satisfying the characteristic predicate. -/
@[to_additive /-- Makes a localization map from an `AddCommMonoid` hom satisfying the
characteristic predicate. -/]
def toLocalizationMap (f : M →* N) (H1 : ∀ y : S, IsUnit (f y))
(H2 : ∀ z, ∃ x : M × S, z * f x.2 = f x.1) (H3 : ∀ x y, f x = f y → ∃ c : S, ↑c * x = ↑c * y) :
Submonoid.LocalizationMap S N :=
{ f with
map_units' := H1
surj' := H2
exists_of_eq := H3 }
end MonoidHom
namespace Submonoid
namespace LocalizationMap
/-- Short for `toMonoidHom`; used to apply a localization map as a function. -/
@[to_additive /-- Short for `toAddMonoidHom`; used to apply a localization map as a function. -/]
abbrev toMap (f : LocalizationMap S N) := f.toMonoidHom
attribute [deprecated toMonoidHom (since := "2025-08-13")] toMap
attribute [deprecated AddSubmonoid.LocalizationMap.toAddMonoidHom (since := "2025-08-13")]
AddSubmonoid.LocalizationMap.toMap
@[to_additive]
theorem toMonoidHom_injective : Injective (toMonoidHom : LocalizationMap S N → M →* N) :=
fun f g ↦ by cases f; congr!
@[deprecated (since := "2025-08-13")] alias toMap_injective := toMonoidHom_injective
@[to_additive] instance : FunLike (LocalizationMap S N) M N where
coe f := f.toMonoidHom
coe_injective' := DFunLike.coe_injective.comp toMonoidHom_injective
@[to_additive] instance : MonoidHomClass (LocalizationMap S N) M N where
map_one f := f.toMonoidHom.map_one
map_mul f := f.toMonoidHom.map_mul
@[to_additive (attr := simp)] lemma toMonoidHom_apply (f : LocalizationMap S N) (x : M) :
f.toMonoidHom x = f x := rfl
@[to_additive (attr := ext)]
theorem ext {f g : LocalizationMap S N} (h : ∀ x, f x = g x) : f = g := DFunLike.ext _ _ h
@[to_additive]
theorem map_units (f : LocalizationMap S N) (y : S) : IsUnit (f y) :=
f.2 y
@[to_additive]
theorem surj (f : LocalizationMap S N) (z : N) : ∃ x : M × S, z * f x.2 = f x.1 :=
f.3 z
/-- Given a localization map `f : M →* N`, and `z w : N`, there exist `z' w' : M` and `d : S`
such that `f z' / f d = z` and `f w' / f d = w`. -/
@[to_additive
/-- Given a localization map `f : M →+ N`, and `z w : N`, there exist `z' w' : M` and `d : S`
such that `f z' - f d = z` and `f w' - f d = w`. -/]
theorem surj₂ (f : LocalizationMap S N) (z w : N) : ∃ z' w' : M, ∃ d : S,
(z * f d = f z') ∧ (w * f d = f w') := by
let ⟨a, ha⟩ := surj f z
let ⟨b, hb⟩ := surj f w
refine ⟨a.1 * b.2, a.2 * b.1, a.2 * b.2, ?_, ?_⟩
· simp_rw [mul_def, map_mul, ← ha]
exact (mul_assoc z _ _).symm
· simp_rw [mul_def, map_mul, ← hb]
exact mul_left_comm w _ _
@[to_additive]
theorem eq_iff_exists (f : LocalizationMap S N) {x y} :
f x = f y ↔ ∃ c : S, ↑c * x = c * y := Iff.intro (f.4 x y)
fun ⟨c, h⟩ ↦ by
replace h := congr_arg f h
rw [map_mul, map_mul] at h
exact (f.map_units c).mul_right_inj.mp h
/-- Given a localization map `f : M →* N`, a section function sending `z : N` to some
`(x, y) : M × S` such that `f x * (f y)⁻¹ = z`. -/
@[to_additive
/-- Given a localization map `f : M →+ N`, a section function sending `z : N`
to some `(x, y) : M × S` such that `f x - f y = z`. -/]
noncomputable def sec (f : LocalizationMap S N) (z : N) : M × S := Classical.choose <| f.surj z
@[to_additive]
theorem sec_spec {f : LocalizationMap S N} (z : N) :
z * f (f.sec z).2 = f (f.sec z).1 := Classical.choose_spec <| f.surj z
@[to_additive]
theorem sec_spec' {f : LocalizationMap S N} (z : N) :
f (f.sec z).1 = f (f.sec z).2 * z := by rw [mul_comm, sec_spec]
/-- Given a MonoidHom `f : M →* N` and Submonoid `S ⊆ M` such that `f(S) ⊆ Nˣ`, for all
`w, z : N` and `y ∈ S`, we have `w * (f y)⁻¹ = z ↔ w = f y * z`. -/
@[to_additive
/-- Given an AddMonoidHom `f : M →+ N` and Submonoid `S ⊆ M` such that `f(S) ⊆ AddUnits N`, for all
`w, z : N` and `y ∈ S`, we have `w - f y = z ↔ w = f y + z`. -/]
theorem mul_inv_left {f : M →* N} (h : ∀ y : S, IsUnit (f y)) (y : S) (w z : N) :
w * (IsUnit.liftRight (f.restrict S) h y)⁻¹ = z ↔ w = f y * z := by
rw [mul_comm]
exact Units.inv_mul_eq_iff_eq_mul (IsUnit.liftRight (f.restrict S) h y)
/-- Given a MonoidHom `f : M →* N` and Submonoid `S ⊆ M` such that `f(S) ⊆ Nˣ`, for all
`w, z : N` and `y ∈ S`, we have `z = w * (f y)⁻¹ ↔ z * f y = w`. -/
@[to_additive
/-- Given an AddMonoidHom `f : M →+ N` and Submonoid `S ⊆ M` such that `f(S) ⊆ AddUnits N`, for all
`w, z : N` and `y ∈ S`, we have `z = w - f y ↔ z + f y = w`. -/]
theorem mul_inv_right {f : M →* N} (h : ∀ y : S, IsUnit (f y)) (y : S) (w z : N) :
z = w * (IsUnit.liftRight (f.restrict S) h y)⁻¹ ↔ z * f y = w := by
rw [eq_comm, mul_inv_left h, mul_comm, eq_comm]
/-- Given a MonoidHom `f : M →* N` and Submonoid `S ⊆ M` such that
`f(S) ⊆ Nˣ`, for all `x₁ x₂ : M` and `y₁, y₂ ∈ S`, we have
`f x₁ * (f y₁)⁻¹ = f x₂ * (f y₂)⁻¹ ↔ f (x₁ * y₂) = f (x₂ * y₁)`. -/
@[to_additive (attr := simp)
/-- Given an AddMonoidHom `f : M →+ N` and Submonoid `S ⊆ M` such that
`f(S) ⊆ AddUnits N`, for all `x₁ x₂ : M` and `y₁, y₂ ∈ S`, we have
`f x₁ - f y₁ = f x₂ - f y₂ ↔ f (x₁ + y₂) = f (x₂ + y₁)`. -/]
theorem mul_inv {f : M →* N} (h : ∀ y : S, IsUnit (f y)) {x₁ x₂} {y₁ y₂ : S} :
f x₁ * (IsUnit.liftRight (f.restrict S) h y₁)⁻¹ =
f x₂ * (IsUnit.liftRight (f.restrict S) h y₂)⁻¹ ↔
f (x₁ * y₂) = f (x₂ * y₁) := by
rw [mul_inv_right h, mul_assoc, mul_comm _ (f y₂), ← mul_assoc, mul_inv_left h, mul_comm x₂,
f.map_mul, f.map_mul]
/-- Given a MonoidHom `f : M →* N` and Submonoid `S ⊆ M` such that `f(S) ⊆ Nˣ`, for all
`y, z ∈ S`, we have `(f y)⁻¹ = (f z)⁻¹ → f y = f z`. -/
@[to_additive
/-- Given an AddMonoidHom `f : M →+ N` and Submonoid `S ⊆ M` such that
`f(S) ⊆ AddUnits N`, for all `y, z ∈ S`, we have `- (f y) = - (f z) → f y = f z`. -/]
theorem inv_inj {f : M →* N} (hf : ∀ y : S, IsUnit (f y)) {y z : S}
(h : (IsUnit.liftRight (f.restrict S) hf y)⁻¹ = (IsUnit.liftRight (f.restrict S) hf z)⁻¹) :
f y = f z := by
rw [← mul_one (f y), eq_comm, ← mul_inv_left hf y (f z) 1, h]
exact Units.inv_mul (IsUnit.liftRight (f.restrict S) hf z)⁻¹
/-- Given a MonoidHom `f : M →* N` and Submonoid `S ⊆ M` such that `f(S) ⊆ Nˣ`, for all
`y ∈ S`, `(f y)⁻¹` is unique. -/
@[to_additive
/-- Given an AddMonoidHom `f : M →+ N` and Submonoid `S ⊆ M` such that
`f(S) ⊆ AddUnits N`, for all `y ∈ S`, `- (f y)` is unique. -/]
theorem inv_unique {f : M →* N} (h : ∀ y : S, IsUnit (f y)) {y : S} {z : N} (H : f y * z = 1) :
(IsUnit.liftRight (f.restrict S) h y)⁻¹ = z := by
rw [← one_mul _⁻¹, Units.val_mul, mul_inv_left]
exact H.symm
variable (f : LocalizationMap S N)
@[to_additive]
theorem map_right_cancel {x y} {c : S} (h : f (c * x) = f (c * y)) :
f x = f y := by
rw [map_mul, map_mul] at h
let ⟨u, hu⟩ := f.map_units c
rw [← hu] at h
exact (Units.mul_right_inj u).1 h
@[to_additive]
theorem map_left_cancel {x y} {c : S} (h : f (x * c) = f (y * c)) :
f x = f y :=
f.map_right_cancel (c := c) <| by rw [mul_comm _ x, mul_comm _ y, h]
/-- Given a localization map `f : M →* N`, the surjection sending `(x, y) : M × S` to
`f x * (f y)⁻¹`. -/
@[to_additive
/-- Given a localization map `f : M →+ N`, the surjection sending `(x, y) : M × S` to
`f x - f y`. -/]
noncomputable def mk' (f : LocalizationMap S N) (x : M) (y : S) : N :=
f x * ↑(IsUnit.liftRight (f.restrict S) f.map_units y)⁻¹
@[to_additive]
lemma mk'_mul (x₁ x₂ : M) (y₁ y₂ : S) : f.mk' (x₁ * x₂) (y₁ * y₂) = f.mk' x₁ y₁ * f.mk' x₂ y₂ := by
refine (mul_inv_left f.map_units _ _ _).2 ?_
simp only [map_mul, coe_mul, toMonoidHom_apply, mk', IsUnit.liftRight, Units.liftRight,
MonoidHom.restrict_apply, MonoidHom.coe_mk, OneHom.coe_mk]
rw [mul_mul_mul_comm (f x₁), mul_left_comm, mul_mul_mul_comm (f y₁)]
simp
@[to_additive]
theorem mk'_one (x) : f.mk' x (1 : S) = f x := by
rw [mk', MonoidHom.map_one]
exact mul_one _
/-- Given a localization map `f : M →* N` for a submonoid `S ⊆ M`, for all `z : N` we have that if
`x : M, y ∈ S` are such that `z * f y = f x`, then `f x * (f y)⁻¹ = z`. -/
@[to_additive (attr := simp)
/-- Given a localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M`, for all `z : N`
we have that if `x : M, y ∈ S` are such that `z + f y = f x`, then `f x - f y = z`. -/]
theorem mk'_sec (z : N) : f.mk' (f.sec z).1 (f.sec z).2 = z :=
show _ * _ = _ by rw [← sec_spec, mul_inv_left, mul_comm]; dsimp
@[to_additive]
theorem mk'_surjective (z : N) : ∃ (x : _) (y : S), f.mk' x y = z :=
⟨(f.sec z).1, (f.sec z).2, f.mk'_sec z⟩
@[to_additive]
theorem mk'_spec (x) (y : S) : f.mk' x y * f y = f x :=
show _ * _ * _ = _ by rw [mul_assoc, mul_comm _ (f y), ← mul_assoc, mul_inv_left, mul_comm]; dsimp
@[to_additive]
theorem mk'_spec' (x) (y : S) : f y * f.mk' x y = f x := by rw [mul_comm, mk'_spec]
@[to_additive]
theorem eq_mk'_iff_mul_eq {x} {y : S} {z} : z = f.mk' x y ↔ z * f y = f x :=
⟨fun H ↦ by rw [H, mk'_spec], fun H ↦ by rwa [mk', mul_inv_right]⟩
@[to_additive]
theorem mk'_eq_iff_eq_mul {x} {y : S} {z} : f.mk' x y = z ↔ f x = z * f y := by
rw [eq_comm, eq_mk'_iff_mul_eq, eq_comm]
@[to_additive]
theorem mk'_eq_iff_eq {x₁ x₂} {y₁ y₂ : S} :
f.mk' x₁ y₁ = f.mk' x₂ y₂ ↔ f (y₂ * x₁) = f (y₁ * x₂) where
mp H := by
rw [map_mul f, map_mul f, f.mk'_eq_iff_eq_mul.1 H,← mul_assoc, mk'_spec', mul_comm (f x₂)]
mpr H := by
rw [mk'_eq_iff_eq_mul, mk', mul_assoc, mul_comm _ (f y₁), ← mul_assoc, ← map_mul f, mul_comm x₂,
← H, ← mul_comm x₁, map_mul f, mul_inv_right f.map_units, toMonoidHom_apply]
@[to_additive]
theorem mk'_eq_iff_eq' {x₁ x₂} {y₁ y₂ : S} :
f.mk' x₁ y₁ = f.mk' x₂ y₂ ↔ f (x₁ * y₂) = f (x₂ * y₁) := by
simp only [f.mk'_eq_iff_eq, mul_comm]
@[to_additive]
protected theorem eq {a₁ b₁} {a₂ b₂ : S} :
f.mk' a₁ a₂ = f.mk' b₁ b₂ ↔ ∃ c : S, ↑c * (↑b₂ * a₁) = c * (a₂ * b₁) :=
f.mk'_eq_iff_eq.trans <| f.eq_iff_exists
@[to_additive]
protected theorem eq' {a₁ b₁} {a₂ b₂ : S} :
f.mk' a₁ a₂ = f.mk' b₁ b₂ ↔ Localization.r S (a₁, a₂) (b₁, b₂) := by
rw [f.eq, Localization.r_iff_exists]
@[to_additive]
theorem eq_iff_eq (g : LocalizationMap S P) {x y} : f x = f y ↔ g x = g y :=
f.eq_iff_exists.trans g.eq_iff_exists.symm
@[to_additive]
theorem mk'_eq_iff_mk'_eq (g : LocalizationMap S P) {x₁ x₂} {y₁ y₂ : S} :
f.mk' x₁ y₁ = f.mk' x₂ y₂ ↔ g.mk' x₁ y₁ = g.mk' x₂ y₂ :=
f.eq'.trans g.eq'.symm
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M`, for all `x₁ : M` and `y₁ ∈ S`,
if `x₂ : M, y₂ ∈ S` are such that `f x₁ * (f y₁)⁻¹ * f y₂ = f x₂`, then there exists `c ∈ S`
such that `x₁ * y₂ * c = x₂ * y₁ * c`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for a Submonoid `S ⊆ M`, for all `x₁ : M`
and `y₁ ∈ S`, if `x₂ : M, y₂ ∈ S` are such that `(f x₁ - f y₁) + f y₂ = f x₂`, then there exists
`c ∈ S` such that `x₁ + y₂ + c = x₂ + y₁ + c`. -/]
theorem exists_of_sec_mk' (x) (y : S) :
∃ c : S, ↑c * (↑(f.sec <| f.mk' x y).2 * x) = c * (y * (f.sec <| f.mk' x y).1) :=
f.eq_iff_exists.1 <| f.mk'_eq_iff_eq.1 <| (mk'_sec _ _).symm
@[to_additive]
theorem mk'_eq_of_eq {a₁ b₁ : M} {a₂ b₂ : S} (H : ↑a₂ * b₁ = ↑b₂ * a₁) :
f.mk' a₁ a₂ = f.mk' b₁ b₂ :=
f.mk'_eq_iff_eq.2 <| H ▸ rfl
@[to_additive]
theorem mk'_eq_of_eq' {a₁ b₁ : M} {a₂ b₂ : S} (H : b₁ * ↑a₂ = a₁ * ↑b₂) :
f.mk' a₁ a₂ = f.mk' b₁ b₂ :=
f.mk'_eq_of_eq <| by simpa only [mul_comm] using H
@[to_additive]
theorem mk'_cancel (a : M) (b c : S) :
f.mk' (a * c) (b * c) = f.mk' a b :=
mk'_eq_of_eq' f (by rw [Submonoid.coe_mul, mul_comm (b : M), mul_assoc])
@[to_additive]
theorem mk'_eq_of_same {a b} {d : S} :
f.mk' a d = f.mk' b d ↔ ∃ c : S, c * a = c * b := by
rw [mk'_eq_iff_eq', map_mul, map_mul, ← eq_iff_exists f]
exact (map_units f d).mul_left_inj
@[to_additive (attr := simp)]
theorem mk'_self' (y : S) : f.mk' (y : M) y = 1 :=
show _ * _ = _ by rw [mul_inv_left, mul_one]; dsimp
@[to_additive (attr := simp)]
theorem mk'_self (x) (H : x ∈ S) : f.mk' x ⟨x, H⟩ = 1 := mk'_self' f ⟨x, H⟩
@[to_additive]
theorem mul_mk'_eq_mk'_of_mul (x₁ x₂) (y : S) : f x₁ * f.mk' x₂ y = f.mk' (x₁ * x₂) y := by
rw [← mk'_one, ← mk'_mul, one_mul]
@[to_additive]
theorem mk'_mul_eq_mk'_of_mul (x₁ x₂) (y : S) : f.mk' x₂ y * f x₁ = f.mk' (x₁ * x₂) y := by
rw [mul_comm, mul_mk'_eq_mk'_of_mul]
@[to_additive]
theorem mul_mk'_one_eq_mk' (x) (y : S) : f x * f.mk' 1 y = f.mk' x y := by
rw [mul_mk'_eq_mk'_of_mul, mul_one]
@[to_additive (attr := simp)]
theorem mk'_mul_cancel_right (x : M) (y : S) : f.mk' (x * y) y = f x := by
rw [← mul_mk'_one_eq_mk', map_mul, mul_assoc, mul_mk'_one_eq_mk', mk'_self', mul_one]
@[to_additive]
theorem mk'_mul_cancel_left (x) (y : S) : f.mk' ((y : M) * x) y = f x := by
rw [mul_comm, mk'_mul_cancel_right]
@[to_additive]
theorem isUnit_comp (j : N →* P) (y : S) : IsUnit (j.comp f.toMonoidHom y) :=
⟨Units.map j <| IsUnit.liftRight (f.restrict S) f.map_units y,
show j _ = j _ from congr_arg j <| IsUnit.coe_liftRight (f.restrict S) f.map_units _⟩
variable {g : M →* P}
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M` and a map of `CommMonoid`s
`g : M →* P` such that `g(S) ⊆ Units P`, `f x = f y → g x = g y` for all `x y : M`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M` and a map of
`AddCommMonoid`s `g : M →+ P` such that `g(S) ⊆ AddUnits P`, `f x = f y → g x = g y`
for all `x y : M`. -/]
theorem eq_of_eq (hg : ∀ y : S, IsUnit (g y)) {x y} (h : f x = f y) : g x = g y := by
obtain ⟨c, hc⟩ := f.eq_iff_exists.1 h
rw [← one_mul (g x), ← IsUnit.liftRight_inv_mul (g.restrict S) hg c]
change _ * g c * _ = _
rw [mul_assoc, ← g.map_mul, hc, mul_comm, mul_inv_left hg, g.map_mul]
/-- Given `CommMonoid`s `M, P`, Localization maps `f : M →* N, k : P →* Q` for Submonoids
`S, T` respectively, and `g : M →* P` such that `g(S) ⊆ T`, `f x = f y` implies
`k (g x) = k (g y)`. -/
@[to_additive
/-- Given `AddCommMonoid`s `M, P`, Localization maps `f : M →+ N, k : P →+ Q` for AddSubmonoids
`S, T` respectively, and `g : M →+ P` such that `g(S) ⊆ T`, `f x = f y`
implies `k (g x) = k (g y)`. -/]
theorem comp_eq_of_eq {T : Submonoid P} {Q : Type*} [CommMonoid Q] (hg : ∀ y : S, g y ∈ T)
(k : LocalizationMap T Q) {x y} (h : f x = f y) : k (g x) = k (g y) :=
f.eq_of_eq (fun y : S ↦ show IsUnit (k.comp g y) from k.map_units ⟨g y, hg y⟩) h
variable (hg : ∀ y : S, IsUnit (g y))
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M` and a map of `CommMonoid`s
`g : M →* P` such that `g y` is invertible for all `y : S`, the homomorphism induced from
`N` to `P` sending `z : N` to `g x * (g y)⁻¹`, where `(x, y) : M × S` are such that
`z = f x * (f y)⁻¹`. -/
@[to_additive
/-- Given a localization map `f : M →+ N` for a submonoid `S ⊆ M` and a map of
`AddCommMonoid`s `g : M →+ P` such that `g y` is invertible for all `y : S`, the homomorphism
induced from `N` to `P` sending `z : N` to `g x - g y`, where `(x, y) : M × S` are such that
`z = f x - f y`. -/]
noncomputable def lift : N →* P where
toFun z := g (f.sec z).1 * (IsUnit.liftRight (g.restrict S) hg (f.sec z).2)⁻¹
map_one' := by rw [mul_inv_left, mul_one]; exact f.eq_of_eq hg (by rw [← sec_spec, one_mul])
map_mul' x y := by
rw [mul_inv_left hg, ← mul_assoc, ← mul_assoc, mul_inv_right hg, mul_comm _ (g (f.sec y).1), ←
mul_assoc, ← mul_assoc, mul_inv_right hg]
repeat rw [← g.map_mul]
refine f.eq_of_eq hg ?_
simp_rw [map_mul, sec_spec', ← toMonoidHom_apply]
ac_rfl
@[to_additive]
lemma lift_apply (z) :
f.lift hg z = g (f.sec z).1 * (IsUnit.liftRight (g.restrict S) hg (f.sec z).2)⁻¹ :=
rfl
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M` and a map of `CommMonoid`s
`g : M →* P` such that `g y` is invertible for all `y : S`, the homomorphism induced from
`N` to `P` maps `f x * (f y)⁻¹` to `g x * (g y)⁻¹` for all `x : M, y ∈ S`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M` and a map of
`AddCommMonoid`s `g : M →+ P` such that `g y` is invertible for all `y : S`, the homomorphism
induced from `N` to `P` maps `f x - f y` to `g x - g y` for all `x : M, y ∈ S`. -/]
theorem lift_mk' (x y) : f.lift hg (f.mk' x y) = g x * (IsUnit.liftRight (g.restrict S) hg y)⁻¹ :=
(mul_inv hg).2 <|
f.eq_of_eq hg <| by
simp_rw [map_mul, sec_spec', mul_assoc, f.mk'_spec, mul_comm]
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M` and a localization map
`g : M →* P` for the same submonoid, the homomorphism induced from
`N` to `P` maps `f x * (f y)⁻¹` to `g x * (g y)⁻¹` for all `x : M, y ∈ S`. -/
@[to_additive (attr := simp)
/-- Given a Localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M` and a localization map
`g : M →+ P` for the same submonoid, the homomorphism
induced from `N` to `P` maps `f x - f y` to `g x - g y` for all `x : M, y ∈ S`. -/]
theorem lift_localizationMap_mk' (g : S.LocalizationMap P) (x y) :
f.lift g.map_units (f.mk' x y) = g.mk' x y :=
f.lift_mk' _ _ _
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M`, if a `CommMonoid` map
`g : M →* P` induces a map `f.lift hg : N →* P` then for all `z : N, v : P`, we have
`f.lift hg z = v ↔ g x = g y * v`, where `x : M, y ∈ S` are such that `z * f y = f x`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M`, if an
`AddCommMonoid` map `g : M →+ P` induces a map `f.lift hg : N →+ P` then for all
`z : N, v : P`, we have `f.lift hg z = v ↔ g x = g y + v`, where `x : M, y ∈ S` are such that
`z + f y = f x`. -/]
theorem lift_spec (z v) : f.lift hg z = v ↔ g (f.sec z).1 = g (f.sec z).2 * v :=
mul_inv_left hg _ _ v
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M`, if a `CommMonoid` map
`g : M →* P` induces a map `f.lift hg : N →* P` then for all `z : N, v w : P`, we have
`f.lift hg z * w = v ↔ g x * w = g y * v`, where `x : M, y ∈ S` are such that
`z * f y = f x`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M`, if an `AddCommMonoid` map
`g : M →+ P` induces a map `f.lift hg : N →+ P` then for all
`z : N, v w : P`, we have `f.lift hg z + w = v ↔ g x + w = g y + v`, where `x : M, y ∈ S` are such
that `z + f y = f x`. -/]
theorem lift_spec_mul (z w v) : f.lift hg z * w = v ↔ g (f.sec z).1 * w = g (f.sec z).2 * v := by
rw [mul_comm, lift_apply, ← mul_assoc, mul_inv_left hg, mul_comm]
@[to_additive]
theorem lift_mk'_spec (x v) (y : S) : f.lift hg (f.mk' x y) = v ↔ g x = g y * v := by
rw [f.lift_mk' hg]; exact mul_inv_left hg _ _ _
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M`, if a `CommMonoid` map
`g : M →* P` induces a map `f.lift hg : N →* P` then for all `z : N`, we have
`f.lift hg z * g y = g x`, where `x : M, y ∈ S` are such that `z * f y = f x`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M`, if an `AddCommMonoid`
map `g : M →+ P` induces a map `f.lift hg : N →+ P` then for all `z : N`, we have
`f.lift hg z + g y = g x`, where `x : M, y ∈ S` are such that `z + f y = f x`. -/]
theorem lift_mul_right (z) : f.lift hg z * g (f.sec z).2 = g (f.sec z).1 := by
rw [lift_apply, mul_assoc, ← g.restrict_apply, IsUnit.liftRight_inv_mul, mul_one]
/-- Given a Localization map `f : M →* N` for a Submonoid `S ⊆ M`, if a `CommMonoid` map
`g : M →* P` induces a map `f.lift hg : N →* P` then for all `z : N`, we have
`g y * f.lift hg z = g x`, where `x : M, y ∈ S` are such that `z * f y = f x`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for an AddSubmonoid `S ⊆ M`, if an `AddCommMonoid` map
`g : M →+ P` induces a map `f.lift hg : N →+ P` then for all `z : N`, we have
`g y + f.lift hg z = g x`, where `x : M, y ∈ S` are such that `z + f y = f x`. -/]
theorem lift_mul_left (z) : g (f.sec z).2 * f.lift hg z = g (f.sec z).1 := by
rw [mul_comm, lift_mul_right]
@[to_additive (attr := simp)]
theorem lift_eq (x : M) : f.lift hg (f x) = g x := by
rw [lift_spec, ← g.map_mul]; exact f.eq_of_eq hg (by rw [sec_spec', map_mul])
@[to_additive]
theorem lift_eq_iff {x y : M × S} :
f.lift hg (f.mk' x.1 x.2) = f.lift hg (f.mk' y.1 y.2) ↔ g (x.1 * y.2) = g (y.1 * x.2) := by
rw [lift_mk', lift_mk', mul_inv hg]
@[to_additive (attr := simp)]
theorem lift_comp : (f.lift hg).comp f.toMonoidHom = g := by ext; exact f.lift_eq hg _
@[to_additive (attr := simp)]
theorem lift_of_comp (j : N →* P) : f.lift (f.isUnit_comp j) = j := by
ext; simp_rw [lift_spec, j.comp_apply, ← map_mul, toMonoidHom_apply, sec_spec']
@[to_additive]
theorem epic_of_localizationMap {P : Type*} [Monoid P] {j k : N →* P}
(h : j.comp f.toMonoidHom = k.comp f.toMonoidHom) : j = k := by
ext n
obtain ⟨⟨m, s⟩, hn : n * f s = f m⟩ := f.surj n
replace h (a) : j (f a) = k (f a) := congr($h a)
exact ((f.map_units s).map j).mul_left_inj.mp <| by rw [← j.map_mul, h, ← k.map_mul, hn, h m]
@[to_additive]
theorem lift_unique {j : N →* P} (hj : ∀ x, j (f x) = g x) : f.lift hg = j := by
ext
rw [lift_spec, ← hj, ← hj, ← j.map_mul]
apply congr_arg
rw [← sec_spec']
@[to_additive (attr := simp)]
theorem lift_id (x) : f.lift f.map_units x = x :=
DFunLike.ext_iff.1 (f.lift_of_comp <| MonoidHom.id N) x
/-- Given Localization maps `f : M →* N` for a Submonoid `S ⊆ M` and
`k : M →* Q` for a Submonoid `T ⊆ M`, such that `S ≤ T`, and we have
`l : M →* A`, the composition of the induced map `f.lift` for `k` with
the induced map `k.lift` for `l` is equal to the induced map `f.lift` for `l`. -/
@[to_additive
/-- Given Localization maps `f : M →+ N` for a Submonoid `S ⊆ M` and
`k : M →+ Q` for a Submonoid `T ⊆ M`, such that `S ≤ T`, and we have
`l : M →+ A`, the composition of the induced map `f.lift` for `k` with
the induced map `k.lift` for `l` is equal to the induced map `f.lift` for `l` -/]
theorem lift_comp_lift {T : Submonoid M} (hST : S ≤ T) {Q : Type*} [CommMonoid Q]
(k : LocalizationMap T Q) {A : Type*} [CommMonoid A] {l : M →* A}
(hl : ∀ w : T, IsUnit (l w)) :
(k.lift hl).comp (f.lift (map_units k ⟨_, hST ·.2⟩)) =
f.lift (hl ⟨_, hST ·.2⟩) := .symm <|
lift_unique _ _ fun x ↦ by rw [← toMonoidHom_apply, ← MonoidHom.comp_apply,
MonoidHom.comp_assoc, lift_comp, lift_comp]
@[to_additive]
theorem lift_comp_lift_eq {Q : Type*} [CommMonoid Q] (k : LocalizationMap S Q)
{A : Type*} [CommMonoid A] {l : M →* A} (hl : ∀ w : S, IsUnit (l w)) :
(k.lift hl).comp (f.lift k.map_units) = f.lift hl :=
lift_comp_lift f le_rfl k hl
/-- Given two Localization maps `f : M →* N, k : M →* P` for a Submonoid `S ⊆ M`, the hom
from `P` to `N` induced by `f` is left inverse to the hom from `N` to `P` induced by `k`. -/
@[to_additive (attr := simp)
/-- Given two Localization maps `f : M →+ N, k : M →+ P` for a Submonoid `S ⊆ M`, the hom
from `P` to `N` induced by `f` is left inverse to the hom from `N` to `P` induced by `k`. -/]
theorem lift_left_inverse {k : LocalizationMap S P} (z : N) :
k.lift f.map_units (f.lift k.map_units z) = z :=
(DFunLike.congr_fun (lift_comp_lift_eq f k f.map_units) z).trans (lift_id f z)
@[to_additive]
theorem lift_surjective_iff :
Function.Surjective (f.lift hg) ↔ ∀ v : P, ∃ x : M × S, v * g x.2 = g x.1 := by
constructor
· intro H v
obtain ⟨z, hz⟩ := H v
obtain ⟨x, hx⟩ := f.surj z
use x
rw [← hz, f.eq_mk'_iff_mul_eq.2 hx, lift_mk', mul_assoc, mul_comm _ (g ↑x.2),
← MonoidHom.restrict_apply, IsUnit.mul_liftRight_inv (g.restrict S) hg, mul_one]
· intro H v
obtain ⟨x, hx⟩ := H v
use f.mk' x.1 x.2
rw [lift_mk', mul_inv_left hg, mul_comm, ← hx]
@[to_additive]
theorem lift_injective_iff :
Function.Injective (f.lift hg) ↔ ∀ x y, f x = f y ↔ g x = g y := by
constructor
· intro H x y
constructor
· exact f.eq_of_eq hg
· intro h
rw [← f.lift_eq hg, ← f.lift_eq hg] at h
exact H h
· intro H z w h
obtain ⟨_, _⟩ := f.surj z
obtain ⟨_, _⟩ := f.surj w
rw [← f.mk'_sec z, ← f.mk'_sec w]
exact (mul_inv f.map_units).2 ((H _ _).2 <| (mul_inv hg).1 h)
variable {T : Submonoid P} (hy : ∀ y : S, g y ∈ T) {Q : Type*} [CommMonoid Q]
(k : LocalizationMap T Q)
/-- Given a `CommMonoid` homomorphism `g : M →* P` where for Submonoids `S ⊆ M, T ⊆ P` we have
`g(S) ⊆ T`, the induced Monoid homomorphism from the Localization of `M` at `S` to the
Localization of `P` at `T`: if `f : M →* N` and `k : P →* Q` are Localization maps for `S` and
`T` respectively, we send `z : N` to `k (g x) * (k (g y))⁻¹`, where `(x, y) : M × S` are such
that `z = f x * (f y)⁻¹`. -/
@[to_additive
/-- Given an `AddCommMonoid` homomorphism `g : M →+ P` where for AddSubmonoids `S ⊆ M, T ⊆ P` we
have `g(S) ⊆ T`, the induced AddMonoid homomorphism from the Localization of `M` at `S` to the
Localization of `P` at `T`: if `f : M →+ N` and `k : P →+ Q` are Localization maps for `S` and
`T` respectively, we send `z : N` to `k (g x) - k (g y)`, where `(x, y) : M × S` are such
that `z = f x - f y`. -/]
noncomputable def map : N →* Q :=
@lift _ _ _ _ _ _ _ f (k.toMonoidHom.comp g) fun y ↦ k.map_units ⟨g y, hy y⟩
variable {k}
@[to_additive (attr := simp)]
theorem map_eq (x) : f.map hy k (f x) = k (g x) :=
f.lift_eq (fun y ↦ k.map_units ⟨g y, hy y⟩) x
@[to_additive (attr := simp)]
theorem map_comp : (f.map hy k).comp f.toMonoidHom = k.toMonoidHom.comp g :=
f.lift_comp fun y ↦ k.map_units ⟨g y, hy y⟩
@[to_additive (attr := simp)]
theorem map_mk' (x) (y : S) : f.map hy k (f.mk' x y) = k.mk' (g x) ⟨g y, hy y⟩ := by
rw [map, lift_mk', mul_inv_left]
change k (g x) = k (g y) * _
rw [mul_mk'_eq_mk'_of_mul]
exact (k.mk'_mul_cancel_left (g x) ⟨g y, hy y⟩).symm
/-- Given Localization maps `f : M →* N, k : P →* Q` for Submonoids `S, T` respectively, if a
`CommMonoid` homomorphism `g : M →* P` induces a `f.map hy k : N →* Q`, then for all `z : N`,
`u : Q`, we have `f.map hy k z = u ↔ k (g x) = k (g y) * u` where `x : M, y ∈ S` are such that
`z * f y = f x`. -/
@[to_additive
/-- Given Localization maps `f : M →+ N, k : P →+ Q` for AddSubmonoids `S, T` respectively, if an
`AddCommMonoid` homomorphism `g : M →+ P` induces a `f.map hy k : N →+ Q`, then for all `z : N`,
`u : Q`, we have `f.map hy k z = u ↔ k (g x) = k (g y) + u` where `x : M, y ∈ S` are such that
`z + f y = f x`. -/]
theorem map_spec (z u) : f.map hy k z = u ↔ k (g (f.sec z).1) = k (g (f.sec z).2) * u :=
f.lift_spec (fun y ↦ k.map_units ⟨g y, hy y⟩) _ _
/-- Given Localization maps `f : M →* N, k : P →* Q` for Submonoids `S, T` respectively, if a
`CommMonoid` homomorphism `g : M →* P` induces a `f.map hy k : N →* Q`, then for all `z : N`,
we have `f.map hy k z * k (g y) = k (g x)` where `x : M, y ∈ S` are such that
`z * f y = f x`. -/
@[to_additive
/-- Given Localization maps `f : M →+ N, k : P →+ Q` for AddSubmonoids `S, T` respectively, if an
`AddCommMonoid` homomorphism `g : M →+ P` induces a `f.map hy k : N →+ Q`, then for all `z : N`,
we have `f.map hy k z + k (g y) = k (g x)` where `x : M, y ∈ S` are such that
`z + f y = f x`. -/]
theorem map_mul_right (z) : f.map hy k z * k (g (f.sec z).2) = k (g (f.sec z).1) :=
f.lift_mul_right (fun y ↦ k.map_units ⟨g y, hy y⟩) _
/-- Given Localization maps `f : M →* N, k : P →* Q` for Submonoids `S, T` respectively, if a
`CommMonoid` homomorphism `g : M →* P` induces a `f.map hy k : N →* Q`, then for all `z : N`,
we have `k (g y) * f.map hy k z = k (g x)` where `x : M, y ∈ S` are such that
`z * f y = f x`. -/
@[to_additive
/-- Given Localization maps `f : M →+ N, k : P →+ Q` for AddSubmonoids `S, T` respectively if an
`AddCommMonoid` homomorphism `g : M →+ P` induces a `f.map hy k : N →+ Q`, then for all `z : N`,
we have `k (g y) + f.map hy k z = k (g x)` where `x : M, y ∈ S` are such that
`z + f y = f x`. -/]
theorem map_mul_left (z) : k (g (f.sec z).2) * f.map hy k z = k (g (f.sec z).1) := by
rw [mul_comm, f.map_mul_right]
@[to_additive (attr := simp)]
theorem map_id (z : N) : f.map (fun y ↦ show MonoidHom.id M y ∈ S from y.2) f z = z :=
f.lift_id z
/-- If `CommMonoid` homs `g : M →* P, l : P →* A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/
@[to_additive
/-- If `AddCommMonoid` homs `g : M →+ P, l : P →+ A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/]
theorem map_comp_map {A : Type*} [CommMonoid A] {U : Submonoid A} {R} [CommMonoid R]
(j : LocalizationMap U R) {l : P →* A} (hl : ∀ w : T, l w ∈ U) :
(k.map hl j).comp (f.map hy k) =
f.map (fun x ↦ show l.comp g x ∈ U from hl ⟨g x, hy x⟩) j := by
ext z
change j _ * _ = j (l _) * _
rw [mul_inv_left, ← mul_assoc, mul_inv_right]
change j _ * j (l (g _)) = j (l _) * _
rw [← map_mul j, ← map_mul j, ← l.map_mul, ← l.map_mul]
refine k.comp_eq_of_eq hl j ?_
rw [map_mul k, map_mul k, sec_spec', mul_assoc, map_mul_right]
/-- If `CommMonoid` homs `g : M →* P, l : P →* A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/
@[to_additive
/-- If `AddCommMonoid` homs `g : M →+ P, l : P →+ A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/]
theorem map_map {A : Type*} [CommMonoid A] {U : Submonoid A} {R} [CommMonoid R]
(j : LocalizationMap U R) {l : P →* A} (hl : ∀ w : T, l w ∈ U) (x) :
k.map hl j (f.map hy k x) = f.map (fun x ↦ show l.comp g x ∈ U from hl ⟨g x, hy x⟩) j x := by
-- Porting note: need to specify `k` explicitly
rw [← f.map_comp_map (k := k) hy j hl]
simp only [MonoidHom.coe_comp, comp_apply]
/-- Given an injective `CommMonoid` homomorphism `g : M →* P`, and a submonoid `S ⊆ M`,
the induced monoid homomorphism from the localization of `M` at `S` to the
localization of `P` at `g S`, is injective.
-/
@[to_additive /-- Given an injective `AddCommMonoid` homomorphism `g : M →+ P`, and a
submonoid `S ⊆ M`, the induced monoid homomorphism from the localization of `M` at `S`
to the localization of `P` at `g S`, is injective. -/]
theorem map_injective_of_injective (hg : Injective g) (k : LocalizationMap (S.map g) Q) :
Injective (map f (apply_coe_mem_map g S) k) := fun z w hizw ↦ by
set i := map f (apply_coe_mem_map g S) k
have ifkg (a : M) : i (f a) = k (g a) := map_eq f (apply_coe_mem_map g S) a
let ⟨z', w', x, hxz, hxw⟩ := surj₂ f z w
have : k (g z') = k (g w') := by
rw [← ifkg, ← ifkg, ← hxz, ← hxw, map_mul, map_mul, hizw]
obtain ⟨⟨_, c, hc, rfl⟩, eq⟩ := k.exists_of_eq _ _ this
simp_rw [← map_mul, hg.eq_iff] at eq
rw [← (f.map_units x).mul_left_inj, hxz, hxw, f.eq_iff_exists]
exact ⟨⟨c, hc⟩, eq⟩
/-- Given a surjective `CommMonoid` homomorphism `g : M →* P`, and a submonoid `S ⊆ M`,
the induced monoid homomorphism from the localization of `M` at `S` to the
localization of `P` at `g S`, is surjective.
-/
@[to_additive /-- Given a surjective `AddCommMonoid` homomorphism `g : M →+ P`, and a
submonoid `S ⊆ M`, the induced monoid homomorphism from the localization of `M` at `S`
to the localization of `P` at `g S`, is surjective. -/]
theorem map_surjective_of_surjective (hg : Surjective g) (k : LocalizationMap (S.map g) Q) :
Surjective (map f (apply_coe_mem_map g S) k) := fun z ↦ by
obtain ⟨y, ⟨y', s, hs, rfl⟩, rfl⟩ := k.mk'_surjective z
obtain ⟨x, rfl⟩ := hg y
use f.mk' x ⟨s, hs⟩
rw [map_mk']
end LocalizationMap
end Submonoid
namespace Submonoid
namespace LocalizationMap
variable (f : S.LocalizationMap N) {g : M →* P} (hg : ∀ y : S, IsUnit (g y)) {T : Submonoid P}
{Q : Type*} [CommMonoid Q]
/-- If `f : M →* N` and `k : M →* P` are Localization maps for a Submonoid `S`, we get an
isomorphism of `N` and `P`. -/
@[to_additive
/-- If `f : M →+ N` and `k : M →+ R` are Localization maps for an AddSubmonoid `S`, we get an
isomorphism of `N` and `R`. -/]
noncomputable def mulEquivOfLocalizations (k : LocalizationMap S P) : N ≃* P :=
{ toFun := f.lift k.map_units
invFun := k.lift f.map_units
left_inv := f.lift_left_inverse
right_inv := k.lift_left_inverse
map_mul' := MonoidHom.map_mul _ }
@[to_additive (attr := simp)]
theorem mulEquivOfLocalizations_apply {k : LocalizationMap S P} {x} :
f.mulEquivOfLocalizations k x = f.lift k.map_units x := rfl
@[to_additive (attr := simp)]
theorem mulEquivOfLocalizations_symm_apply {k : LocalizationMap S P} {x} :
(f.mulEquivOfLocalizations k).symm x = k.lift f.map_units x := rfl
@[to_additive]
theorem mulEquivOfLocalizations_symm_eq_mulEquivOfLocalizations {k : LocalizationMap S P} :
(k.mulEquivOfLocalizations f).symm = f.mulEquivOfLocalizations k := rfl
/-- If `f : M →* N` is a Localization map for a Submonoid `S` and `k : N ≃* P` is an isomorphism
of `CommMonoid`s, `k ∘ f` is a Localization map for `M` at `S`. -/
@[to_additive
/-- If `f : M →+ N` is a Localization map for a Submonoid `S` and `k : N ≃+ P` is an isomorphism
of `AddCommMonoid`s, `k ∘ f` is a Localization map for `M` at `S`. -/]
def ofMulEquivOfLocalizations (k : N ≃* P) : LocalizationMap S P :=
(k.toMonoidHom.comp f.toMonoidHom).toLocalizationMap (fun y ↦ isUnit_comp f k.toMonoidHom y)
(fun v ↦
let ⟨z, hz⟩ := k.surjective v
let ⟨x, hx⟩ := f.surj z
⟨x, show v * k (f _) = k (f _) by rw [← hx, map_mul, ← hz]⟩)
fun x y ↦ (k.apply_eq_iff_eq.trans f.eq_iff_exists).1
@[to_additive (attr := simp)]
theorem ofMulEquivOfLocalizations_apply {k : N ≃* P} (x) :
f.ofMulEquivOfLocalizations k x = k (f x) := rfl
@[to_additive]
theorem ofMulEquivOfLocalizations_eq {k : N ≃* P} :
(f.ofMulEquivOfLocalizations k).toMonoidHom = k.toMonoidHom.comp f.toMonoidHom := rfl
@[to_additive]
theorem symm_comp_ofMulEquivOfLocalizations_apply {k : N ≃* P} (x) :
k.symm (f.ofMulEquivOfLocalizations k x) = f x := k.symm_apply_apply (f x)
@[to_additive]
theorem symm_comp_ofMulEquivOfLocalizations_apply' {k : P ≃* N} (x) :
k (f.ofMulEquivOfLocalizations k.symm x) = f x := k.apply_symm_apply (f x)
@[to_additive]
theorem ofMulEquivOfLocalizations_eq_iff_eq {k : N ≃* P} {x y} :
f.ofMulEquivOfLocalizations k x = y ↔ f x = k.symm y :=
k.toEquiv.eq_symm_apply.symm
@[to_additive addEquivOfLocalizations_right_inv]
theorem mulEquivOfLocalizations_right_inv (k : LocalizationMap S P) :
f.ofMulEquivOfLocalizations (f.mulEquivOfLocalizations k) = k :=
toMonoidHom_injective <| f.lift_comp k.map_units
@[to_additive addEquivOfLocalizations_right_inv_apply]
theorem mulEquivOfLocalizations_right_inv_apply {k : LocalizationMap S P} {x} :
f.ofMulEquivOfLocalizations (f.mulEquivOfLocalizations k) x = k x := by simp
@[to_additive]
theorem mulEquivOfLocalizations_left_inv (k : N ≃* P) :
f.mulEquivOfLocalizations (f.ofMulEquivOfLocalizations k) = k :=
DFunLike.ext _ _ fun x ↦ DFunLike.ext_iff.1 (f.lift_of_comp k.toMonoidHom) x
@[to_additive]
theorem mulEquivOfLocalizations_left_inv_apply {k : N ≃* P} (x) :
f.mulEquivOfLocalizations (f.ofMulEquivOfLocalizations k) x = k x := by simp
@[to_additive (attr := simp)]
theorem ofMulEquivOfLocalizations_id : f.ofMulEquivOfLocalizations (MulEquiv.refl N) = f := by
ext; rfl
@[to_additive]
theorem ofMulEquivOfLocalizations_comp {k : N ≃* P} {j : P ≃* Q} :
(f.ofMulEquivOfLocalizations (k.trans j)).toMonoidHom =
j.toMonoidHom.comp (f.ofMulEquivOfLocalizations k).toMonoidHom := by
ext; rfl
/-- Given `CommMonoid`s `M, P` and Submonoids `S ⊆ M, T ⊆ P`, if `f : M →* N` is a Localization
map for `S` and `k : P ≃* M` is an isomorphism of `CommMonoid`s such that `k(T) = S`, `f ∘ k`
is a Localization map for `T`. -/
@[to_additive
/-- Given `AddCommMonoid`s `M, P` and `AddSubmonoid`s `S ⊆ M, T ⊆ P`, if `f : M →* N` is a
Localization map for `S` and `k : P ≃+ M` is an isomorphism of `AddCommMonoid`s such that
`k(T) = S`, `f ∘ k` is a Localization map for `T`. -/]
def ofMulEquivOfDom {k : P ≃* M} (H : T.map k.toMonoidHom = S) : LocalizationMap T N :=
have H' : S.comap k.toMonoidHom = T :=
H ▸ (SetLike.coe_injective <| T.1.1.preimage_image_eq k.toEquiv.injective)
(f.toMonoidHom.comp k.toMonoidHom).toLocalizationMap
(fun y ↦
let ⟨z, hz⟩ := f.map_units ⟨k y, H ▸ Set.mem_image_of_mem k y.2⟩
⟨z, hz⟩)
(fun z ↦
let ⟨x, hx⟩ := f.surj z
let ⟨v, hv⟩ := k.surjective x.1
let ⟨w, hw⟩ := k.surjective x.2
⟨(v, ⟨w, H' ▸ show k w ∈ S from hw.symm ▸ x.2.2⟩), by
simp_rw [MonoidHom.comp_apply, MulEquiv.toMonoidHom_eq_coe, MonoidHom.coe_coe, hv, hw]
dsimp
rw [hx]⟩)
fun x y ↦ by
rw [MonoidHom.comp_apply, MonoidHom.comp_apply, MulEquiv.toMonoidHom_eq_coe,
MonoidHom.coe_coe, toMonoidHom_apply, toMonoidHom_apply, f.eq_iff_exists]
rintro ⟨c, hc⟩
let ⟨d, hd⟩ := k.surjective c
refine ⟨⟨d, H' ▸ show k d ∈ S from hd.symm ▸ c.2⟩, ?_⟩
rw [← hd, ← map_mul k, ← map_mul k] at hc; exact k.injective hc
@[to_additive (attr := simp)]
theorem ofMulEquivOfDom_apply {k : P ≃* M} (H : T.map k.toMonoidHom = S) (x) :
f.ofMulEquivOfDom H x = f (k x) := rfl
@[to_additive]
theorem ofMulEquivOfDom_eq {k : P ≃* M} (H : T.map k.toMonoidHom = S) :
(f.ofMulEquivOfDom H).toMonoidHom = f.toMonoidHom.comp k.toMonoidHom := rfl
@[to_additive]
theorem ofMulEquivOfDom_comp_symm {k : P ≃* M} (H : T.map k.toMonoidHom = S) (x) :
f.ofMulEquivOfDom H (k.symm x) = f x :=
congr_arg f <| k.apply_symm_apply x
@[to_additive]
theorem ofMulEquivOfDom_comp {k : M ≃* P} (H : T.map k.symm.toMonoidHom = S) (x) :
f.ofMulEquivOfDom H (k x) = f x := congr_arg f <| k.symm_apply_apply x
/-- A special case of `f ∘ id = f`, `f` a Localization map. -/
@[to_additive (attr := simp) /-- A special case of `f ∘ id = f`, `f` a Localization map. -/]
theorem ofMulEquivOfDom_id :
f.ofMulEquivOfDom
(show S.map (MulEquiv.refl M).toMonoidHom = S from
Submonoid.ext fun x ↦ ⟨fun ⟨_, hy, h⟩ ↦ h ▸ hy, fun h ↦ ⟨x, h, rfl⟩⟩) = f := by
ext; rfl
/-- Given Localization maps `f : M →* N, k : P →* U` for Submonoids `S, T` respectively, an
isomorphism `j : M ≃* P` such that `j(S) = T` induces an isomorphism of localizations `N ≃* U`. -/
@[to_additive
/-- Given Localization maps `f : M →+ N, k : P →+ U` for Submonoids `S, T` respectively, an
isomorphism `j : M ≃+ P` such that `j(S) = T` induces an isomorphism of localizations `N ≃+ U`. -/]
noncomputable def mulEquivOfMulEquiv (k : LocalizationMap T Q) {j : M ≃* P}
(H : S.map j.toMonoidHom = T) : N ≃* Q :=
f.mulEquivOfLocalizations <| k.ofMulEquivOfDom H
@[to_additive (attr := simp)]
theorem mulEquivOfMulEquiv_eq_map_apply {k : LocalizationMap T Q} {j : M ≃* P}
(H : S.map j.toMonoidHom = T) (x) :
f.mulEquivOfMulEquiv k H x =
f.map (fun y : S ↦ show j.toMonoidHom y ∈ T from H ▸ Set.mem_image_of_mem j y.2) k x := rfl
@[to_additive]
theorem mulEquivOfMulEquiv_eq_map {k : LocalizationMap T Q} {j : M ≃* P}
(H : S.map j.toMonoidHom = T) :
(f.mulEquivOfMulEquiv k H).toMonoidHom =
f.map (fun y : S ↦ show j.toMonoidHom y ∈ T from H ▸ Set.mem_image_of_mem j y.2) k := rfl
@[to_additive]
theorem mulEquivOfMulEquiv_eq {k : LocalizationMap T Q} {j : M ≃* P} (H : S.map j.toMonoidHom = T)
(x) :
f.mulEquivOfMulEquiv k H (f x) = k (j x) :=
f.map_eq (fun y : S ↦ H ▸ Set.mem_image_of_mem j y.2) _
@[to_additive]
theorem mulEquivOfMulEquiv_mk' {k : LocalizationMap T Q} {j : M ≃* P} (H : S.map j.toMonoidHom = T)
(x y) :
f.mulEquivOfMulEquiv k H (f.mk' x y) = k.mk' (j x) ⟨j y, H ▸ Set.mem_image_of_mem j y.2⟩ :=
f.map_mk' (fun y : S ↦ H ▸ Set.mem_image_of_mem j y.2) _ _
@[to_additive]
theorem of_mulEquivOfMulEquiv_apply {k : LocalizationMap T Q} {j : M ≃* P}
(H : S.map j.toMonoidHom = T) (x) :
f.ofMulEquivOfLocalizations (f.mulEquivOfMulEquiv k H) x = k (j x) :=
Submonoid.LocalizationMap.ext_iff.1 (f.mulEquivOfLocalizations_right_inv (k.ofMulEquivOfDom H)) x
@[to_additive]
theorem of_mulEquivOfMulEquiv {k : LocalizationMap T Q} {j : M ≃* P} (H : S.map j.toMonoidHom = T) :
(f.ofMulEquivOfLocalizations (f.mulEquivOfMulEquiv k H)).toMonoidHom =
k.toMonoidHom.comp j.toMonoidHom :=
MonoidHom.ext <| f.of_mulEquivOfMulEquiv_apply H
end LocalizationMap
end Submonoid
namespace Localization
variable (S) in
/-- Natural homomorphism sending `x : M`, `M` a `CommMonoid`, to the equivalence class of
`(x, 1)` in the Localization of `M` at a Submonoid. -/
@[to_additive
/-- Natural homomorphism sending `x : M`, `M` an `AddCommMonoid`, to the equivalence class of
`(x, 0)` in the Localization of `M` at a Submonoid. -/]
def monoidOf : Submonoid.LocalizationMap S (Localization S) :=
{ (r S).mk'.comp <| MonoidHom.inl M S with
toFun := fun x ↦ mk x 1
map_one' := mk_one
map_mul' := fun x y ↦ by rw [mk_mul, mul_one]
map_units' := fun y ↦
isUnit_iff_exists_inv.2 ⟨mk 1 y, by rw [mk_mul, mul_one, one_mul, mk_self]⟩
surj' := fun z ↦ induction_on z fun x ↦
⟨x, by rw [mk_mul, mul_comm x.fst, ← mk_mul, mk_self, one_mul]⟩
exists_of_eq := fun x y ↦ Iff.mp <| mk_eq_mk_iff.trans <| r_iff_exists.trans <| by simp }
@[to_additive]
theorem mk_one_eq_monoidOf_mk (x) : mk x 1 = monoidOf S x := rfl
@[to_additive]
theorem mk_eq_monoidOf_mk'_apply (x y) : mk x y = (monoidOf S).mk' x y :=
show _ = _ * _ from
(Submonoid.LocalizationMap.mul_inv_right (monoidOf S).map_units _ _ _).2 <| by
dsimp
rw [← mk_one_eq_monoidOf_mk, ← mk_one_eq_monoidOf_mk, mk_mul x y y 1, mul_comm y 1]
conv => rhs; rw [← mul_one 1]; rw [← mul_one x]
exact mk_eq_mk_iff.2 (Con.symm _ <| (Localization.r S).mul (Con.refl _ (x, 1)) <| one_rel _)
@[to_additive]
theorem mk_eq_monoidOf_mk' : mk = (monoidOf S).mk' :=
funext fun _ ↦ funext fun _ ↦ mk_eq_monoidOf_mk'_apply _ _
universe u
@[to_additive (attr := simp)]
theorem liftOn_mk' {p : Sort u} (f : M → S → p) (H) (a : M) (b : S) :
liftOn ((monoidOf S).mk' a b) f H = f a b := by rw [← mk_eq_monoidOf_mk', liftOn_mk]
@[to_additive (attr := simp)]
theorem liftOn₂_mk' {p : Sort*} (f : M → S → M → S → p) (H) (a c : M) (b d : S) :
liftOn₂ ((monoidOf S).mk' a b) ((monoidOf S).mk' c d) f H = f a b c d := by
rw [← mk_eq_monoidOf_mk', liftOn₂_mk]
variable (f : Submonoid.LocalizationMap S N)
/-- Given a Localization map `f : M →* N` for a Submonoid `S`, we get an isomorphism between
the Localization of `M` at `S` as a quotient type and `N`. -/
@[to_additive
/-- Given a Localization map `f : M →+ N` for a Submonoid `S`, we get an isomorphism between
the Localization of `M` at `S` as a quotient type and `N`. -/]
noncomputable def mulEquivOfQuotient (f : Submonoid.LocalizationMap S N) : Localization S ≃* N :=
(monoidOf S).mulEquivOfLocalizations f
variable {f}
@[to_additive (attr := simp)]
theorem mulEquivOfQuotient_apply (x) : mulEquivOfQuotient f x = (monoidOf S).lift f.map_units x :=
rfl
@[to_additive]
theorem mulEquivOfQuotient_mk' (x y) : mulEquivOfQuotient f ((monoidOf S).mk' x y) = f.mk' x y :=
(monoidOf S).lift_mk' _ _ _
@[to_additive]
theorem mulEquivOfQuotient_mk (x y) : mulEquivOfQuotient f (mk x y) = f.mk' x y := by
rw [mk_eq_monoidOf_mk'_apply]; exact mulEquivOfQuotient_mk' _ _
@[to_additive]
theorem mulEquivOfQuotient_monoidOf (x) : mulEquivOfQuotient f (monoidOf S x) = f x := by simp
@[to_additive (attr := simp)]
theorem mulEquivOfQuotient_symm_mk' (x y) :
(mulEquivOfQuotient f).symm (f.mk' x y) = (monoidOf S).mk' x y :=
f.lift_mk' (monoidOf S).map_units _ _
@[to_additive]
theorem mulEquivOfQuotient_symm_mk (x y) : (mulEquivOfQuotient f).symm (f.mk' x y) = mk x y := by
rw [mk_eq_monoidOf_mk'_apply]; exact mulEquivOfQuotient_symm_mk' _ _
@[to_additive (attr := simp)]
theorem mulEquivOfQuotient_symm_monoidOf (x) : (mulEquivOfQuotient f).symm (f x) = monoidOf S x :=
f.lift_eq (monoidOf S).map_units _
/-- The localization of a torsion-free monoid is torsion-free. -/
@[to_additive /-- The localization of a torsion-free monoid is torsion-free. -/]
instance instIsMulTorsionFree [IsMulTorsionFree M] : IsMulTorsionFree <| Localization S where
pow_left_injective n hn := by
rintro ⟨a⟩ ⟨b⟩ (hab : mk a.1 a.2 ^ n = mk b.1 b.2 ^ n)
change mk a.1 a.2 = mk b.1 b.2
simp only [mk_pow, mk_eq_mk_iff, r_iff_exists, SubmonoidClass.coe_pow, Subtype.exists,
exists_prop] at hab ⊢
obtain ⟨c, hc, hab⟩ := hab
refine ⟨c, hc, pow_left_injective hn ?_⟩
obtain _ | n := n
· simp
· simp [mul_pow, pow_succ c, mul_assoc, hab]
end Localization
end CommMonoid
namespace Localization
variable {α : Type*} [CommMonoid α] [IsCancelMul α] {s : Submonoid α} {a₁ b₁ : α} {a₂ b₂ : s}
@[to_additive]
theorem mk_left_injective (b : s) : Injective fun a => mk a b := fun c d h => by
simpa [mk_eq_mk_iff, r_iff_exists] using h
@[to_additive]
theorem mk_eq_mk_iff' : mk a₁ a₂ = mk b₁ b₂ ↔ ↑b₂ * a₁ = a₂ * b₁ := by
simp_rw [mk_eq_mk_iff, r_iff_exists, mul_left_cancel_iff, exists_const]
@[to_additive]
instance decidableEq [DecidableEq α] : DecidableEq (Localization s) := fun a b =>
Localization.recOnSubsingleton₂ a b fun _ _ _ _ => decidable_of_iff' _ mk_eq_mk_iff'
end Localization
namespace OreLocalization
variable (R) [CommMonoid R] (S : Submonoid R)
/-- The morphism `numeratorHom` is a monoid localization map in the case of commutative `R`. -/
protected def localizationMap : S.LocalizationMap R[S⁻¹] := Localization.monoidOf S
/-- If `R` is commutative, Ore localization and monoid localization are isomorphic. -/
protected noncomputable def equivMonoidLocalization : Localization S ≃* R[S⁻¹] := MulEquiv.refl _
end OreLocalization
namespace Submonoid.LocalizationMap
variable {M N : Type*} [CommMonoid M] {S : Submonoid M} [CommMonoid N]
@[to_additive] theorem injective_iff (f : LocalizationMap S N) :
Injective f ↔ ∀ ⦃x⦄, x ∈ S → IsRegular x := by
simp_rw [Commute.isRegular_iff (Commute.all _), IsLeftRegular,
Injective, LocalizationMap.eq_iff_exists, exists_imp, Subtype.forall]
exact forall₂_swap
@[to_additive] theorem top_injective_iff (f : (⊤ : Submonoid M).LocalizationMap N) :
Injective f ↔ IsCancelMul M := by
simp [injective_iff, isCancelMul_iff_forall_isRegular]
@[to_additive] theorem map_isRegular (f : LocalizationMap S N) {m : M}
(hm : IsRegular m) : IsRegular (f m) := by
refine (Commute.isRegular_iff (Commute.all _)).mpr fun n₁ n₂ eq ↦ ?_
have ⟨ms₁, eq₁⟩ := f.surj n₁
have ⟨ms₂, eq₂⟩ := f.surj n₂
rw [← (f.map_units (ms₁.2 * ms₂.2)).mul_left_inj, Submonoid.coe_mul]
replace eq := congr($eq * f (ms₁.2 * ms₂.2))
simp_rw [mul_assoc] at eq
rw [map_mul, ← mul_assoc n₁, eq₁, ← mul_assoc n₂, mul_right_comm n₂, eq₂] at eq ⊢
simp_rw [← map_mul, eq_iff_exists] at eq ⊢
simp_rw [mul_left_comm _ m] at eq
exact eq.imp fun _ ↦ (hm.1 ·)
@[to_additive] theorem isCancelMul (f : LocalizationMap S N) [IsCancelMul M] : IsCancelMul N := by
simp_rw [isCancelMul_iff_forall_isRegular, Commute.isRegular_iff (Commute.all _),
← Commute.isRightRegular_iff (Commute.all _)]
intro n
have ⟨ms, eq⟩ := f.surj n
exact (eq ▸ f.map_isRegular (isCancelMul_iff_forall_isRegular.mp ‹_› ms.1)).2.of_mul
end Submonoid.LocalizationMap |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/Cardinality.lean | import Mathlib.GroupTheory.MonoidLocalization.Basic
import Mathlib.GroupTheory.OreLocalization.Cardinality
/-!
# Cardinality of localizations of commutative monoids
This file contains some results on cardinality of localizations.
-/
universe u
open Cardinal
namespace Localization
variable {M : Type u} [CommMonoid M] (S : Submonoid M)
@[to_additive]
theorem cardinalMk_le : #(Localization S) ≤ #M :=
OreLocalization.cardinalMk_le S
end Localization |
.lake/packages/mathlib/Mathlib/GroupTheory/MonoidLocalization/DivPairs.lean | import Mathlib.GroupTheory.MonoidLocalization.Basic
/-!
# Submonoid of pairs with quotient in a submonoid
This file defines the submonoid of pairs whose quotient lies in a submonoid of the localization.
-/
variable {M G H : Type*} [CommMonoid M] [CommGroup G] [CommGroup H]
{f : (⊤ : Submonoid M).LocalizationMap G} {g : (⊤ : Submonoid M).LocalizationMap H}
{s : Submonoid G} {x : M × M}
namespace Submonoid
variable (f s) in
/-- Given a commutative monoid `M`, a localization map `f` to its Grothendieck group `G` and
a submonoid `s` of `G`, `s.divPairs f` is the submonoid of pairs `(a, b)`
such that `f a / f b ∈ s`. -/
@[to_additive
/-- Given an additive commutative monoid `M`, a localization map `f` to its Grothendieck group `G`
and a submonoid `s` of `G`, `s.subPairs f` is the submonoid of pairs `(a, b)`
such that `f a - f b ∈ s`. -/]
def divPairs : Submonoid (M × M) := s.comap <| divMonoidHom.comp <| .prodMap f f
@[to_additive (attr := simp)] lemma mem_divPairs : x ∈ divPairs f s ↔ f x.1 / f x.2 ∈ s := .rfl
--TODO(Yaël): make simp once `LocalizationMap.toMonoidHom` is simp nf
variable (f g s) in
@[to_additive]
lemma divPairs_comap :
divPairs g (.comap (g.mulEquivOfLocalizations f).toMonoidHom s) = divPairs f s := by
ext; simp
end Submonoid |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupExtension/Basic.lean | import Mathlib.GroupTheory.GroupExtension.Defs
import Mathlib.GroupTheory.SemidirectProduct
import Mathlib.GroupTheory.QuotientGroup.Basic
import Mathlib.Tactic.Group
/-!
# Basic lemmas about group extensions
This file gives basic lemmas about group extensions.
For the main definitions, see `Mathlib/GroupTheory/GroupExtension/Defs.lean`.
-/
variable {N G : Type*} [Group N] [Group G]
namespace GroupExtension
variable {E : Type*} [Group E] (S : GroupExtension N E G)
/-- The isomorphism `E ⧸ S.rightHom.ker ≃* G` induced by `S.rightHom` -/
@[to_additive /-- The isomorphism `E ⧸ S.rightHom.ker ≃+ G` induced by `S.rightHom` -/]
noncomputable def quotientKerRightHomEquivRight : E ⧸ S.rightHom.ker ≃* G :=
QuotientGroup.quotientKerEquivOfSurjective S.rightHom S.rightHom_surjective
/-- The isomorphism `E ⧸ S.inl.range ≃* G` induced by `S.rightHom` -/
@[to_additive /-- The isomorphism `E ⧸ S.inl.range ≃+ G` induced by `S.rightHom` -/]
noncomputable def quotientRangeInlEquivRight : E ⧸ S.inl.range ≃* G :=
(QuotientGroup.quotientMulEquivOfEq S.range_inl_eq_ker_rightHom).trans
S.quotientKerRightHomEquivRight
/-- An arbitrarily chosen section -/
@[to_additive surjInvRightHom /-- An arbitrarily chosen section -/]
noncomputable def surjInvRightHom : S.Section where
toFun := Function.surjInv S.rightHom_surjective
rightInverse_rightHom := Function.surjInv_eq S.rightHom_surjective
namespace Section
variable {S}
variable {E' : Type*} [Group E'] {S' : GroupExtension N E' G} (σ σ' : S.Section) (g g₁ g₂ : G)
(equiv : S.Equiv S')
@[to_additive]
theorem mul_inv_mem_range_inl : σ g * (σ' g)⁻¹ ∈ S.inl.range := by
simp only [S.range_inl_eq_ker_rightHom, MonoidHom.mem_ker, map_mul, map_inv, rightHom_section,
mul_inv_cancel]
@[to_additive]
theorem inv_mul_mem_range_inl : (σ g)⁻¹ * σ' g ∈ S.inl.range := by
simp only [S.range_inl_eq_ker_rightHom, MonoidHom.mem_ker, map_mul, map_inv, rightHom_section,
inv_mul_cancel]
@[to_additive]
theorem exists_eq_inl_mul : ∃ n : N, σ g = S.inl n * σ' g := by
obtain ⟨n, hn⟩ := mul_inv_mem_range_inl σ σ' g
exact ⟨n, by rw [hn, inv_mul_cancel_right]⟩
@[to_additive]
theorem exists_eq_mul_inl : ∃ n : N, σ g = σ' g * S.inl n := by
obtain ⟨n, hn⟩ := inv_mul_mem_range_inl σ' σ g
exact ⟨n, by rw [hn, mul_inv_cancel_left]⟩
@[to_additive]
theorem mul_mul_mul_inv_mem_range_inl : σ g₁ * σ g₂ * (σ (g₁ * g₂))⁻¹ ∈ S.inl.range := by
simp only [S.range_inl_eq_ker_rightHom, MonoidHom.mem_ker, map_mul, map_inv, rightHom_section,
mul_inv_cancel]
@[to_additive]
theorem mul_inv_mul_mul_mem_range_inl : (σ (g₁ * g₂))⁻¹ * σ g₁ * σ g₂ ∈ S.inl.range := by
simp only [S.range_inl_eq_ker_rightHom, MonoidHom.mem_ker, map_mul, map_inv, rightHom_section,
mul_assoc, inv_mul_cancel]
@[to_additive]
theorem exists_mul_eq_inl_mul_mul : ∃ n : N, σ (g₁ * g₂) = S.inl n * σ g₁ * σ g₂ := by
obtain ⟨n, hn⟩ := mul_mul_mul_inv_mem_range_inl σ g₁ g₂
use n⁻¹
rw [mul_assoc, map_inv, eq_inv_mul_iff_mul_eq, ← eq_mul_inv_iff_mul_eq, hn]
@[to_additive]
theorem exists_mul_eq_mul_mul_inl : ∃ n : N, σ (g₁ * g₂) = σ g₁ * σ g₂ * S.inl n := by
obtain ⟨n, hn⟩ := mul_inv_mul_mul_mem_range_inl σ g₁ g₂
use n⁻¹
rw [map_inv, eq_mul_inv_iff_mul_eq, ← eq_inv_mul_iff_mul_eq, ← mul_assoc, hn]
initialize_simps_projections AddGroupExtension.Section (toFun → apply)
initialize_simps_projections Section (toFun → apply)
/-- The composition of an isomorphism between equivalent group extensions and a section -/
@[to_additive (attr := simps!)
/-- The composition of an isomorphism between equivalent additive group extensions and a section -/]
def equivComp : S'.Section where
toFun := equiv ∘ σ
rightInverse_rightHom g := by
rw [Function.comp_apply, equiv.rightHom_map, rightHom_section]
end Section
namespace Equiv
variable {S}
variable {E' : Type*} [Group E'] {S' : GroupExtension N E' G}
/-- An equivalence of group extensions from a homomorphism making a commuting diagram. Such a
homomorphism is necessarily an isomorphism. -/
@[to_additive
/-- An equivalence of additive group extensions from a homomorphism making a commuting diagram.
Such a homomorphism is necessarily an isomorphism. -/]
noncomputable def ofMonoidHom (f : E →* E') (comp_inl : f.comp S.inl = S'.inl)
(rightHom_comp : S'.rightHom.comp f = S.rightHom) : S.Equiv S' where
__ := f
invFun e' :=
let e := Function.surjInv S.rightHom_surjective (S'.rightHom e')
e * S.inl (Function.invFun S'.inl ((f e)⁻¹ * e'))
left_inv e := by
simp only [OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, ← map_inv, ← map_mul]
obtain ⟨n, hn⟩ :
(Function.surjInv S.rightHom_surjective (S'.rightHom (f e)))⁻¹ * e ∈ S.inl.range := by
rw [S.range_inl_eq_ker_rightHom, MonoidHom.mem_ker, map_mul, map_inv, ← MonoidHom.comp_apply,
rightHom_comp]
simpa only [Function.surjInv_eq] using inv_mul_cancel (S.rightHom e)
rw [← eq_inv_mul_iff_mul_eq, ← hn, ← MonoidHom.comp_apply, comp_inl,
Function.leftInverse_invFun S'.inl_injective]
right_inv e' := by
simp only [OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, map_mul]
rw [← eq_inv_mul_iff_mul_eq, ← MonoidHom.comp_apply, comp_inl]
apply Function.invFun_eq
rw [← MonoidHom.mem_range, S'.range_inl_eq_ker_rightHom, MonoidHom.mem_ker, map_mul, map_inv,
← MonoidHom.comp_apply, rightHom_comp]
simpa only [Function.surjInv_eq] using inv_mul_cancel (S'.rightHom e')
inl_comm := congrArg DFunLike.coe comp_inl
rightHom_comm := congrArg DFunLike.coe rightHom_comp
end Equiv
namespace Splitting
variable {S}
variable (s : S.Splitting)
/-- `G` acts on `N` by conjugation. -/
noncomputable def conjAct : G →* MulAut N := S.conjAct.comp s
/-- A split group extension is equivalent to the extension associated to a semidirect product. -/
noncomputable def semidirectProductToGroupExtensionEquiv :
(SemidirectProduct.toGroupExtension s.conjAct).Equiv S where
toFun := fun ⟨n, g⟩ ↦ S.inl n * s g
invFun := fun e ↦ ⟨Function.invFun S.inl (e * (s (S.rightHom e))⁻¹), S.rightHom e⟩
left_inv := fun ⟨n, g⟩ ↦ by
simp only [map_mul, rightHom_inl, rightHom_splitting, one_mul, mul_inv_cancel_right,
Function.leftInverse_invFun S.inl_injective n]
right_inv := fun e ↦ by
simp only [← eq_mul_inv_iff_mul_eq]
apply Function.invFun_eq
rw [← MonoidHom.mem_range, S.range_inl_eq_ker_rightHom, MonoidHom.mem_ker, map_mul, map_inv,
rightHom_splitting, mul_inv_cancel]
map_mul' := fun ⟨n₁, g₁⟩ ⟨n₂, g₂⟩ ↦ by
simp only [conjAct, MonoidHom.comp_apply, map_mul, inl_conjAct_comm, MonoidHom.coe_coe]
group
inl_comm := by
ext n
simp only [SemidirectProduct.toGroupExtension, Function.comp_apply, MulEquiv.coe_mk,
Equiv.coe_fn_mk, SemidirectProduct.left_inl, SemidirectProduct.right_inl, map_one, mul_one]
rightHom_comm := by
ext ⟨n, g⟩
simp only [SemidirectProduct.toGroupExtension, Function.comp_apply, MulEquiv.coe_mk,
Equiv.coe_fn_mk, map_mul, rightHom_inl, one_mul, rightHom_splitting,
SemidirectProduct.rightHom_eq_right]
/-- The group associated to a split extension is isomorphic to a semidirect product. -/
noncomputable def semidirectProductMulEquiv : N ⋊[s.conjAct] G ≃* E :=
s.semidirectProductToGroupExtensionEquiv.toMulEquiv
end Splitting
namespace IsConj
/-- `N`-conjugacy is reflexive. -/
@[to_additive /-- `N`-conjugacy is reflexive. -/]
theorem refl (s : S.Splitting) : S.IsConj s s :=
⟨1, by simp only [map_one, inv_one, one_mul, mul_one]⟩
/-- `N`-conjugacy is symmetric. -/
@[to_additive /-- `N`-conjugacy is symmetric. -/]
theorem symm {s₁ s₂ : S.Splitting} (h : S.IsConj s₁ s₂) : S.IsConj s₂ s₁ := by
obtain ⟨n, hn⟩ := h
exact ⟨n⁻¹, by simp only [hn, map_inv]; group⟩
/-- `N`-conjugacy is transitive. -/
@[to_additive /-- `N`-conjugacy is transitive. -/]
theorem trans {s₁ s₂ s₃ : S.Splitting} (h₁ : S.IsConj s₁ s₂) (h₂ : S.IsConj s₂ s₃) :
S.IsConj s₁ s₃ := by
obtain ⟨n₁, hn₁⟩ := h₁
obtain ⟨n₂, hn₂⟩ := h₂
exact ⟨n₁ * n₂, by simp only [hn₁, hn₂, map_mul]; group⟩
/-- The setoid of splittings with `N`-conjugacy -/
@[to_additive /-- The setoid of splittings with `N`-conjugacy -/]
def setoid : Setoid S.Splitting where
r := S.IsConj
iseqv :=
{ refl := refl S
symm := symm S
trans := trans S }
end IsConj
/-- The `N`-conjugacy classes of splittings -/
@[to_additive /-- The `N`-conjugacy classes of splittings -/]
def ConjClasses := Quotient <| IsConj.setoid S
end GroupExtension
namespace SemidirectProduct
variable {φ : G →* MulAut N} (s : (toGroupExtension φ).Splitting)
theorem right_splitting (g : G) : (s g).right = g := by
rw [← rightHom_eq_right, ← toGroupExtension_rightHom, s.rightHom_splitting]
end SemidirectProduct |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupExtension/Defs.lean | import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.GroupTheory.SemidirectProduct
/-!
# Group Extensions
This file defines extensions of multiplicative and additive groups and their associated structures
such as splittings and equivalences.
## Main definitions
- `(Add?)GroupExtension N E G`: structure for extensions of `G` by `N` as short exact sequences
`1 → N → E → G → 1` (`0 → N → E → G → 0` for additive groups)
- `(Add?)GroupExtension.Equiv S S'`: structure for equivalences of two group extensions `S` and `S'`
as specific homomorphisms `E → E'` such that each diagram below is commutative
```text
For multiplicative groups:
↗︎ E ↘
1 → N ↓ G → 1
↘︎ E' ↗︎️
For additive groups:
↗︎ E ↘
0 → N ↓ G → 0
↘︎ E' ↗︎️
```
- `(Add?)GroupExtension.Section S`: structure for right inverses to `rightHom` of a group extension
`S` of `G` by `N`
- `(Add?)GroupExtension.Splitting S`: structure for section homomorphisms of a group extension `S`
of `G` by `N`
- `SemidirectProduct.toGroupExtension φ`: the multiplicative group extension associated to the
semidirect product coming from `φ : G →* MulAut N`, `1 → N → N ⋊[φ] G → G → 1`
## TODO
If `N` is abelian,
- there is a bijection between `N`-conjugacy classes of
`(SemidirectProduct.toGroupExtension φ).Splitting` and `groupCohomology.H1`
(which will be available in `GroupTheory/GroupExtension/Abelian.lean` to be added in a later PR).
- there is a bijection between equivalence classes of group extensions and `groupCohomology.H2`
(which is also stated as a TODO in `RepresentationTheory/GroupCohomology/LowDegree.lean`).
-/
variable (N E G : Type*)
/-- `AddGroupExtension N E G` is a short exact sequence of additive groups `0 → N → E → G → 0`. -/
structure AddGroupExtension [AddGroup N] [AddGroup E] [AddGroup G] where
/-- The inclusion homomorphism `N →+ E` -/
inl : N →+ E
/-- The projection homomorphism `E →+ G` -/
rightHom : E →+ G
/-- The inclusion map is injective. -/
inl_injective : Function.Injective inl
/-- The range of the inclusion map is equal to the kernel of the projection map. -/
range_inl_eq_ker_rightHom : inl.range = rightHom.ker
/-- The projection map is surjective. -/
rightHom_surjective : Function.Surjective rightHom
/-- `GroupExtension N E G` is a short exact sequence of groups `1 → N → E → G → 1`. -/
@[to_additive]
structure GroupExtension [Group N] [Group E] [Group G] where
/-- The inclusion homomorphism `N →* E` -/
inl : N →* E
/-- The projection homomorphism `E →* G` -/
rightHom : E →* G
/-- The inclusion map is injective. -/
inl_injective : Function.Injective inl
/-- The range of the inclusion map is equal to the kernel of the projection map. -/
range_inl_eq_ker_rightHom : inl.range = rightHom.ker
/-- The projection map is surjective. -/
rightHom_surjective : Function.Surjective rightHom
variable {N E G}
namespace AddGroupExtension
variable [AddGroup N] [AddGroup E] [AddGroup G] (S : AddGroupExtension N E G)
/-- `AddGroupExtension`s are equivalent iff there is an isomorphism making a commuting diagram.
Use `AddGroupExtension.Equiv.ofMonoidHom` in `Mathlib/GroupTheory/GroupExtension/Basic.lean` to
construct an equivalence without providing the inverse map. -/
structure Equiv {E' : Type*} [AddGroup E'] (S' : AddGroupExtension N E' G) extends E ≃+ E' where
/-- The left-hand side of the diagram commutes. -/
inl_comm : toAddEquiv ∘ S.inl = S'.inl
/-- The right-hand side of the diagram commutes. -/
rightHom_comm : S'.rightHom ∘ toAddEquiv = S.rightHom
/-- `Section` of an additive group extension is a right inverse to `S.rightHom`. -/
structure Section where
/-- The underlying function -/
toFun : G → E
/-- `Section` is a right inverse to `S.rightHom` -/
rightInverse_rightHom : Function.RightInverse toFun S.rightHom
/-- `Splitting` of an additive group extension is a section homomorphism. -/
structure Splitting extends G →+ E, S.Section
/-- A splitting of an additive group extension as a (set-theoretic) section. -/
add_decl_doc Splitting.toSection
end AddGroupExtension
namespace GroupExtension
variable [Group N] [Group E] [Group G] (S : GroupExtension N E G)
/-- The range of the inclusion map is a normal subgroup. -/
@[to_additive /-- The range of the inclusion map is a normal additive subgroup. -/]
instance normal_inl_range : S.inl.range.Normal :=
S.range_inl_eq_ker_rightHom ▸ S.rightHom.normal_ker
@[to_additive (attr := simp)]
theorem rightHom_inl (n : N) : S.rightHom (S.inl n) = 1 := by
rw [← MonoidHom.mem_ker, ← S.range_inl_eq_ker_rightHom, MonoidHom.mem_range]
exact exists_apply_eq_apply S.inl n
@[to_additive (attr := simp)]
theorem rightHom_comp_inl : S.rightHom.comp S.inl = 1 := by
ext n
rw [MonoidHom.one_apply, MonoidHom.comp_apply]
exact S.rightHom_inl n
/-- `E` acts on `N` by conjugation. -/
noncomputable def conjAct : E →* MulAut N where
toFun e := (MonoidHom.ofInjective S.inl_injective).trans <|
(MulAut.conjNormal e).trans (MonoidHom.ofInjective S.inl_injective).symm
map_one' := by
ext _
simp only [map_one, MulEquiv.trans_apply, MulAut.one_apply, MulEquiv.symm_apply_apply]
map_mul' _ _ := by
ext _
simp only [map_mul, MulEquiv.trans_apply, MulAut.mul_apply, MulEquiv.apply_symm_apply]
/-- The inclusion and a conjugation commute. -/
theorem inl_conjAct_comm {e : E} {n : N} : S.inl (S.conjAct e n) = e * S.inl n * e⁻¹ := by
simp only [conjAct, MonoidHom.coe_mk, OneHom.coe_mk, MulEquiv.trans_apply,
MonoidHom.apply_ofInjective_symm, MulAut.conjNormal_apply, MonoidHom.ofInjective_apply]
/-- `GroupExtension`s are equivalent iff there is an isomorphism making a commuting diagram.
Use `GroupExtension.Equiv.ofMonoidHom` in `Mathlib/GroupTheory/GroupExtension/Basic.lean` to
construct an equivalence without providing the inverse map. -/
@[to_additive]
structure Equiv {E' : Type*} [Group E'] (S' : GroupExtension N E' G) extends E ≃* E' where
/-- The left-hand side of the diagram commutes. -/
inl_comm : toMulEquiv ∘ S.inl = S'.inl
/-- The right-hand side of the diagram commutes. -/
rightHom_comm : S'.rightHom ∘ toMulEquiv = S.rightHom
namespace Equiv
variable {S}
variable {E' : Type*} [Group E'] {S' : GroupExtension N E' G}
@[to_additive]
instance : EquivLike (S.Equiv S') E E' where
coe equiv := equiv.toMulEquiv
inv equiv := equiv.toMulEquiv.symm
left_inv equiv := equiv.left_inv
right_inv equiv := equiv.right_inv
coe_injective' := fun ⟨_, _, _⟩ ⟨_, _, _⟩ h _ ↦ by
congr
rw [MulEquiv.ext_iff]
exact congrFun h
@[to_additive]
instance : MulEquivClass (S.Equiv S') E E' where
map_mul equiv := equiv.map_mul'
variable (equiv : S.Equiv S')
@[to_additive (attr := simp)]
theorem toMulEquiv_eq_coe : equiv.toMulEquiv = equiv := rfl
@[to_additive (attr := simp)]
theorem coe_toMulEquiv : ⇑(equiv : E ≃* E') = equiv := rfl
@[to_additive (attr := simp)]
theorem map_inl (n : N) : equiv (S.inl n) = S'.inl n := congrFun equiv.inl_comm n
@[to_additive (attr := simp)]
theorem rightHom_map (e : E) : S'.rightHom (equiv e) = S.rightHom e :=
congrFun equiv.rightHom_comm e
/-- The inverse of an equivalence of group extensions is an equivalence. -/
@[to_additive /-- The inverse of an equivalence of additive group extensions is an equivalence. -/]
def symm : S'.Equiv S where
__ := equiv.toMulEquiv.symm
inl_comm := by rw [MulEquiv.symm_comp_eq, ← equiv.inl_comm]
rightHom_comm := by rw [MulEquiv.comp_symm_eq, ← equiv.rightHom_comm]
/-- See Note [custom simps projection]. -/
@[to_additive /-- See Note [custom simps projection]. -/]
def Simps.symm_apply : E' → E := equiv.symm
@[to_additive (attr := simp)]
theorem coe_symm : (equiv : E ≃* E').symm = equiv.symm := rfl
initialize_simps_projections AddGroupExtension.Equiv (toFun → apply, invFun → symm_apply)
initialize_simps_projections Equiv (toFun → apply, invFun → symm_apply)
attribute [simps! symm_apply] AddGroupExtension.Equiv.symm
attribute [simps! symm_apply] symm
/-- The composition of monoid isomorphisms associated to equivalences of group extensions gives
another equivalence. -/
@[to_additive (attr := simps!)
/-- The composition of monoid isomorphisms associated to equivalences of additive group
extensions gives another equivalence. -/]
def trans {E'' : Type*} [Group E''] {S'' : GroupExtension N E'' G} (equiv' : S'.Equiv S'') :
S.Equiv S'' where
__ := equiv.toMulEquiv.trans equiv'.toMulEquiv
inl_comm := by rw [MulEquiv.coe_trans, Function.comp_assoc, equiv.inl_comm, equiv'.inl_comm]
rightHom_comm := by
rw [MulEquiv.coe_trans, ← Function.comp_assoc, equiv'.rightHom_comm, equiv.rightHom_comm]
variable (S)
/-- A group extension is equivalent to itself. -/
@[to_additive (attr := simps!) /-- An additive group extension is equivalent to itself. -/]
def refl : S.Equiv S where
__ := MulEquiv.refl E
inl_comm := rfl
rightHom_comm := rfl
end Equiv
/-- `Section` of a group extension is a right inverse to `S.rightHom`. -/
@[to_additive]
structure Section where
/-- The underlying function -/
toFun : G → E
/-- `Section` is a right inverse to `S.rightHom` -/
rightInverse_rightHom : Function.RightInverse toFun S.rightHom
namespace Section
@[to_additive]
instance : FunLike S.Section G E where
coe := toFun
coe_injective' := fun ⟨_, _⟩ ⟨_, _⟩ _ ↦ by congr
variable {S}
@[to_additive (attr := simp)]
theorem coe_mk (σ : G → E) (hσ : Function.RightInverse σ S.rightHom) : (mk σ hσ : G → E) = σ := rfl
variable (σ : S.Section)
@[to_additive (attr := simp)]
theorem rightHom_section (g : G) : S.rightHom (σ g) = g := σ.rightInverse_rightHom g
@[to_additive (attr := simp)]
theorem rightHom_comp_section : S.rightHom ∘ σ = id := σ.rightInverse_rightHom.comp_eq_id
end Section
/-- `Splitting` of a group extension is a section homomorphism. -/
@[to_additive]
structure Splitting extends G →* E, S.Section
/-- A splitting of a group extension as a (set-theoretic) section. -/
add_decl_doc Splitting.toSection
namespace Splitting
@[to_additive]
instance : FunLike S.Splitting G E where
coe s := s.toFun
coe_injective' := by
intro ⟨_, _⟩ ⟨_, _⟩ h
congr
exact DFunLike.coe_injective h
@[to_additive]
instance : MonoidHomClass S.Splitting G E where
map_mul s := s.map_mul'
map_one s := s.map_one'
variable {S}
@[to_additive (attr := simp)]
theorem coe_mk (s : G →* E) (hs : Function.RightInverse s S.rightHom) : (mk s hs : G → E) = s := rfl
@[to_additive (attr := simp)]
theorem coe_monoidHom_mk (s : G →* E) (hs : Function.RightInverse s S.rightHom) :
(mk s hs : G →* E) = s := rfl
variable (s : S.Splitting)
@[to_additive (attr := simp)]
theorem rightHom_splitting (g : G) : S.rightHom (s g) = g := s.rightInverse_rightHom g
@[to_additive (attr := simp)]
theorem rightHom_comp_splitting : S.rightHom.comp s = MonoidHom.id G := by
ext g
simp only [MonoidHom.comp_apply, MonoidHom.id_apply, MonoidHom.coe_coe, rightHom_splitting]
end Splitting
/-- A splitting of an extension `S` is `N`-conjugate to another iff there exists `n : N` such that
the section homomorphism is a conjugate of the other section homomorphism by `S.inl n`. -/
@[to_additive
/-- A splitting of an extension `S` is `N`-conjugate to another iff there exists `n : N` such
that the section homomorphism is a conjugate of the other section homomorphism by `S.inl n`. -/]
def IsConj (s s' : S.Splitting) : Prop := ∃ n : N, s = fun g ↦ S.inl n * s' g * (S.inl n)⁻¹
end GroupExtension
namespace SemidirectProduct
variable [Group G] [Group N] (φ : G →* MulAut N)
/-- The group extension associated to the semidirect product -/
def toGroupExtension : GroupExtension N (N ⋊[φ] G) G where
inl := inl
inl_injective := inl_injective
range_inl_eq_ker_rightHom := range_inl_eq_ker_rightHom
rightHom := rightHom
rightHom_surjective := rightHom_surjective
theorem toGroupExtension_inl : (toGroupExtension φ).inl = SemidirectProduct.inl := rfl
theorem toGroupExtension_rightHom : (toGroupExtension φ).rightHom = SemidirectProduct.rightHom :=
rfl
/-- A canonical splitting of the group extension associated to the semidirect product -/
def inr_splitting : (toGroupExtension φ).Splitting where
__ := inr
rightInverse_rightHom := rightHom_inr
end SemidirectProduct |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeGroup/IsFreeGroup.lean | import Mathlib.GroupTheory.FreeGroup.Basic
/-!
# Free groups structures on arbitrary types
This file defines the notion of free basis of a group, which induces an isomorphism between the
group and the free group generated by the basis.
It also introduced a type class for groups which are free groups, i.e., for which some free basis
exists.
For the explicit construction of free groups, see `GroupTheory/FreeGroup`.
## Main definitions
* `FreeGroupBasis ι G` : a function from `ι` to `G` such that `G` is free over its image.
Equivalently, an isomorphism between `G` and `FreeGroup ι`.
* `IsFreeGroup G` : a typeclass to indicate that `G` is free over some generators
* `Generators G` : given a group satisfying `IsFreeGroup G`, some indexing type over
which `G` is free.
* `IsFreeGroup.of` : the canonical injection of `G`'s generators into `G`
* `IsFreeGroup.lift` : the universal property of the free group
## Main results
* `FreeGroupBasis.isFreeGroup`: a group admitting a free group basis is free.
* `IsFreeGroup.toFreeGroup`: any free group with generators `A` is equivalent to `FreeGroup A`.
* `IsFreeGroup.unique_lift`: the universal property of a free group.
* `FreeGroupBasis.ofUniqueLift`: a group satisfying the universal property of a free group admits
a free group basis.
-/
universe u
open Function Set
noncomputable section
/-- A free group basis `FreeGroupBasis ι G` is a structure recording the isomorphism between a
group `G` and the free group over `ι`. One may think of such a basis as a function from `ι` to `G`
(which is registered through a `FunLike` instance) together with the fact that the morphism induced
by this function from `FreeGroup ι` to `G` is an isomorphism. -/
structure FreeGroupBasis (ι : Type*) (G : Type*) [Group G] where
/-- `FreeGroupBasis.ofRepr` constructs a basis given an equivalence with a free group. -/
ofRepr ::
/-- `repr` is the isomorphism between the group `G` and the free group generated by `ι`. -/
repr : G ≃* FreeGroup ι
/-- A group is free if it admits a free group basis. In the definition, we require the basis to
be in the same universe as `G`, although this property follows from the existence of a basis in
any universe, see `FreeGroupBasis.isFreeGroup`. -/
class IsFreeGroup (G : Type u) [Group G] : Prop where
nonempty_basis : ∃ (ι : Type u), Nonempty (FreeGroupBasis ι G)
namespace FreeGroupBasis
variable {ι ι' G H : Type*} [Group G] [Group H]
/-- A free group basis for `G` over `ι` is associated to a map `ι → G` recording the images of
the generators. -/
instance instFunLike : FunLike (FreeGroupBasis ι G) ι G where
coe b := fun i ↦ b.repr.symm (FreeGroup.of i)
coe_injective' := by
rintro ⟨b⟩ ⟨b'⟩ hbb'
have H : (b.symm : FreeGroup ι →* G) = (b'.symm : FreeGroup ι →* G) := by
ext i; exact congr_fun hbb' i
have : b.symm = b'.symm := by ext x; exact DFunLike.congr_fun H x
rw [ofRepr.injEq, ← MulEquiv.symm_symm b, ← MulEquiv.symm_symm b', this]
@[simp] lemma repr_apply_coe (b : FreeGroupBasis ι G) (i : ι) : b.repr (b i) = FreeGroup.of i := by
change b.repr (b.repr.symm (FreeGroup.of i)) = FreeGroup.of i
simp
/-- The canonical basis of the free group over `X`. -/
def ofFreeGroup (X : Type*) : FreeGroupBasis X (FreeGroup X) := ofRepr (MulEquiv.refl _)
@[simp] lemma ofFreeGroup_apply {X : Type*} (x : X) :
FreeGroupBasis.ofFreeGroup X x = FreeGroup.of x :=
rfl
/-- Reindex a free group basis through a bijection of the indexing sets. -/
protected def reindex (b : FreeGroupBasis ι G) (e : ι ≃ ι') : FreeGroupBasis ι' G :=
ofRepr (b.repr.trans (FreeGroup.freeGroupCongr e))
@[simp] lemma reindex_apply (b : FreeGroupBasis ι G) (e : ι ≃ ι') (x : ι') :
b.reindex e x = b (e.symm x) := rfl
/-- Pushing a free group basis through a group isomorphism. -/
protected def map (b : FreeGroupBasis ι G) (e : G ≃* H) : FreeGroupBasis ι H :=
ofRepr (e.symm.trans b.repr)
@[simp] lemma map_apply (b : FreeGroupBasis ι G) (e : G ≃* H) (x : ι) :
b.map e x = e (b x) := rfl
protected lemma injective (b : FreeGroupBasis ι G) : Injective b :=
b.repr.symm.injective.comp FreeGroup.of_injective
/-- A group admitting a free group basis is a free group. -/
lemma isFreeGroup (b : FreeGroupBasis ι G) : IsFreeGroup G :=
⟨range b, ⟨b.reindex (Equiv.ofInjective (↑b) b.injective)⟩⟩
instance (X : Type*) : IsFreeGroup (FreeGroup X) :=
(ofFreeGroup X).isFreeGroup
/-- Given a free group basis of `G` over `ι`, there is a canonical bijection between maps from `ι`
to a group `H` and morphisms from `G` to `H`. -/
@[simps!]
def lift (b : FreeGroupBasis ι G) : (ι → H) ≃ (G →* H) :=
FreeGroup.lift.trans
{ toFun := fun f => f.comp b.repr.toMonoidHom
invFun := fun f => f.comp b.repr.symm.toMonoidHom
left_inv := fun f => by
ext
simp
right_inv := fun f => by
ext
simp }
/-- If two morphisms on `G` coincide on the elements of a basis, then they coincide. -/
lemma ext_hom (b : FreeGroupBasis ι G) (f g : G →* H) (h : ∀ i, f (b i) = g (b i)) : f = g :=
b.lift.symm.injective <| funext h
/-- If a group satisfies the universal property of a free group with respect to a given type, then
it admits a free group basis based on this type. Here, the universal property is expressed as
in `IsFreeGroup.lift` and its properties. -/
def ofLift {G : Type u} [Group G] (X : Type u) (of : X → G)
(lift : ∀ {H : Type u} [Group H], (X → H) ≃ (G →* H))
(lift_of : ∀ {H : Type u} [Group H], ∀ (f : X → H) (a), lift f (of a) = f a) :
FreeGroupBasis X G where
repr := MulEquiv.symm <| MonoidHom.toMulEquiv (FreeGroup.lift of) (lift FreeGroup.of)
(by
apply FreeGroup.ext_hom; intro x
simp only [MonoidHom.coe_comp, Function.comp_apply, MonoidHom.id_apply,
FreeGroup.lift_apply_of, lift_of])
(by
let lift_symm_of : ∀ {H : Type u} [Group H], ∀ (f : G →* H) (a), lift.symm f a = f (of a) :=
by intro H _ f a; simp [← lift_of (lift.symm f)]
apply lift.symm.injective; ext x
simp only [MonoidHom.coe_comp, Function.comp_apply, MonoidHom.id_apply,
FreeGroup.lift_apply_of, lift_of, lift_symm_of])
/-- If a group satisfies the universal property of a free group with respect to a given type, then
it admits a free group basis based on this type. Here
the universal property is expressed as in `IsFreeGroup.unique_lift`. -/
def ofUniqueLift {G : Type u} [Group G] (X : Type u) (of : X → G)
(h : ∀ {H : Type u} [Group H] (f : X → H), ∃! F : G →* H, ∀ a, F (of a) = f a) :
FreeGroupBasis X G :=
let lift {H : Type u} [Group H] : (X → H) ≃ (G →* H) :=
{ toFun := fun f => Classical.choose (h f)
invFun := fun F => F ∘ of
left_inv := fun f => funext (Classical.choose_spec (h f)).left
right_inv := fun F => ((Classical.choose_spec (h (F ∘ of))).right F fun _ => rfl).symm }
let lift_of {H : Type u} [Group H] (f : X → H) (a : X) : lift f (of a) = f a :=
congr_fun (lift.symm_apply_apply f) a
ofLift X of @lift @lift_of
end FreeGroupBasis
namespace IsFreeGroup
variable (G : Type*) [Group G] [IsFreeGroup G]
/-- A set of generators of a free group, chosen arbitrarily -/
def Generators : Type _ := (IsFreeGroup.nonempty_basis (G := G)).choose
/-- Any free group is isomorphic to "the" free group. -/
irreducible_def mulEquiv : FreeGroup (Generators G) ≃* G :=
(IsFreeGroup.nonempty_basis (G := G)).choose_spec.some.repr.symm
/-- A free group basis of a free group `G`, over the set `Generators G`. -/
def basis : FreeGroupBasis (Generators G) G := FreeGroupBasis.ofRepr (mulEquiv G).symm
/-- Any free group is isomorphic to "the" free group. -/
@[simps!]
def toFreeGroup : G ≃* FreeGroup (Generators G) :=
(mulEquiv G).symm
variable {G}
/-- The canonical injection of G's generators into G -/
def of : Generators G → G :=
(mulEquiv G).toFun ∘ FreeGroup.of
variable {H : Type*} [Group H]
/-- The equivalence between functions on the generators and group homomorphisms from a free group
given by those generators. -/
def lift : (Generators G → H) ≃ (G →* H) :=
(basis G).lift
@[simp]
theorem lift_of (f : Generators G → H) (a : Generators G) : lift f (of a) = f a :=
congr_fun (lift.symm_apply_apply f) a
@[simp]
theorem lift_symm_apply (f : G →* H) (a : Generators G) : (lift.symm f) a = f (of a) :=
rfl
/- Do not register this as an ext lemma, as `Generators G` is not canonical. -/
theorem ext_hom ⦃f g : G →* H⦄ (h : ∀ a : Generators G, f (of a) = g (of a)) : f = g :=
lift.symm.injective (funext h)
/-- The universal property of a free group: A function from the generators of `G` to another
group extends in a unique way to a homomorphism from `G`.
Note that since `IsFreeGroup.lift` is expressed as a bijection, it already
expresses the universal property. -/
theorem unique_lift (f : Generators G → H) : ∃! F : G →* H, ∀ a, F (of a) = f a := by
simpa only [funext_iff] using lift.symm.bijective.existsUnique f
/-- If a group satisfies the universal property of a free group with respect to a given type, then
it is free. Here, the universal property is expressed as in `IsFreeGroup.lift` and its
properties. -/
lemma ofLift {G : Type u} [Group G] (X : Type u) (of : X → G)
(lift : ∀ {H : Type u} [Group H], (X → H) ≃ (G →* H))
(lift_of : ∀ {H : Type u} [Group H], ∀ (f : X → H) (a), lift f (of a) = f a) :
IsFreeGroup G :=
(FreeGroupBasis.ofLift X of lift lift_of).isFreeGroup
/-- If a group satisfies the universal property of a free group with respect to a given type, then
it is free. Here the universal property is expressed as in `IsFreeGroup.unique_lift`. -/
lemma ofUniqueLift {G : Type u} [Group G] (X : Type u) (of : X → G)
(h : ∀ {H : Type u} [Group H] (f : X → H), ∃! F : G →* H, ∀ a, F (of a) = f a) :
IsFreeGroup G :=
(FreeGroupBasis.ofUniqueLift X of h).isFreeGroup
lemma ofMulEquiv (e : G ≃* H) : IsFreeGroup H :=
((basis G).map e).isFreeGroup
end IsFreeGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeGroup/Basic.lean | import Mathlib.Algebra.Group.Pi.Basic
import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.Data.List.Chain
import Mathlib.Algebra.Group.Int.Defs
import Mathlib.Algebra.BigOperators.Group.List.Basic
/-!
# Free groups
This file defines free groups over a type. Furthermore, it is shown that the free group construction
is an instance of a monad. For the result that `FreeGroup` is the left adjoint to the forgetful
functor from groups to types, see `Mathlib/Algebra/Category/GrpCat/Adjunctions.lean`.
## Main definitions
* `FreeGroup`/`FreeAddGroup`: the free group (resp. free additive group) associated to a type
`α` defined as the words over `a : α × Bool` modulo the relation `a * x * x⁻¹ * b = a * b`.
* `FreeGroup.mk`/`FreeAddGroup.mk`: the canonical quotient map `List (α × Bool) → FreeGroup α`.
* `FreeGroup.of`/`FreeAddGroup.of`: the canonical injection `α → FreeGroup α`.
* `FreeGroup.lift f`/`FreeAddGroup.lift`: the canonical group homomorphism `FreeGroup α →* G`
given a group `G` and a function `f : α → G`.
## Main statements
* `FreeGroup.Red.church_rosser`/`FreeAddGroup.Red.church_rosser`: The Church-Rosser theorem for word
reduction (also known as Newman's diamond lemma).
* `FreeGroup.freeGroupUnitEquivInt`: The free group over the one-point type
is isomorphic to the integers.
* The free group construction is an instance of a monad.
## Implementation details
First we introduce the one step reduction relation `FreeGroup.Red.Step`:
`w * x * x⁻¹ * v ~> w * v`, its reflexive transitive closure `FreeGroup.Red.trans`
and prove that its join is an equivalence relation. Then we introduce `FreeGroup α` as a quotient
over `FreeGroup.Red.Step`.
For the additive version we introduce the same relation under a different name so that we can
distinguish the quotient types more easily.
## Tags
free group, Newman's diamond lemma, Church-Rosser theorem
-/
open Relation
open scoped List
universe u v w
variable {α : Type u}
attribute [local simp] List.append_eq_has_append
/- Ensure that `@[to_additive]` uses the right namespace before the definition of `FreeGroup`. -/
insert_to_additive_translation FreeGroup FreeAddGroup
/-- Reduction step for the additive free group relation: `w + x + (-x) + v ~> w + v` -/
inductive FreeAddGroup.Red.Step : List (α × Bool) → List (α × Bool) → Prop
| not {L₁ L₂ x b} : FreeAddGroup.Red.Step (L₁ ++ (x, b) :: (x, not b) :: L₂) (L₁ ++ L₂)
attribute [simp] FreeAddGroup.Red.Step.not
/-- Reduction step for the multiplicative free group relation: `w * x * x⁻¹ * v ~> w * v` -/
@[to_additive]
inductive FreeGroup.Red.Step : List (α × Bool) → List (α × Bool) → Prop
| not {L₁ L₂ x b} : FreeGroup.Red.Step (L₁ ++ (x, b) :: (x, not b) :: L₂) (L₁ ++ L₂)
attribute [simp] FreeGroup.Red.Step.not
namespace FreeGroup
variable {L L₁ L₂ L₃ L₄ : List (α × Bool)}
/-- Reflexive-transitive closure of `Red.Step` -/
@[to_additive /-- Reflexive-transitive closure of `Red.Step` -/]
def Red : List (α × Bool) → List (α × Bool) → Prop :=
ReflTransGen Red.Step
@[to_additive (attr := refl)]
theorem Red.refl : Red L L :=
ReflTransGen.refl
@[to_additive (attr := trans)]
theorem Red.trans : Red L₁ L₂ → Red L₂ L₃ → Red L₁ L₃ :=
ReflTransGen.trans
namespace Red
/-- Predicate asserting that the word `w₁` can be reduced to `w₂` in one step, i.e. there are words
`w₃ w₄` and letter `x` such that `w₁ = w₃xx⁻¹w₄` and `w₂ = w₃w₄` -/
@[to_additive /-- Predicate asserting that the word `w₁` can be reduced to `w₂` in one step, i.e.
there are words `w₃ w₄` and letter `x` such that `w₁ = w₃ + x + (-x) + w₄` and `w₂ = w₃w₄` -/]
theorem Step.length : ∀ {L₁ L₂ : List (α × Bool)}, Step L₁ L₂ → L₂.length + 2 = L₁.length
| _, _, @Red.Step.not _ L1 L2 x b => by rw [List.length_append, List.length_append]; rfl
@[to_additive (attr := simp)]
theorem Step.not_rev {x b} : Step (L₁ ++ (x, !b) :: (x, b) :: L₂) (L₁ ++ L₂) := by
cases b <;> exact Step.not
@[to_additive (attr := simp)]
theorem Step.cons_not {x b} : Red.Step ((x, b) :: (x, !b) :: L) L :=
@Step.not _ [] _ _ _
@[to_additive (attr := simp)]
theorem Step.cons_not_rev {x b} : Red.Step ((x, !b) :: (x, b) :: L) L :=
@Red.Step.not_rev _ [] _ _ _
@[to_additive]
theorem Step.append_left : ∀ {L₁ L₂ L₃ : List (α × Bool)}, Step L₂ L₃ → Step (L₁ ++ L₂) (L₁ ++ L₃)
| _, _, _, Red.Step.not => by rw [← List.append_assoc, ← List.append_assoc]; constructor
@[to_additive]
theorem Step.cons {x} (H : Red.Step L₁ L₂) : Red.Step (x :: L₁) (x :: L₂) :=
@Step.append_left _ [x] _ _ H
@[to_additive]
theorem Step.append_right : ∀ {L₁ L₂ L₃ : List (α × Bool)}, Step L₁ L₂ → Step (L₁ ++ L₃) (L₂ ++ L₃)
| _, _, _, Red.Step.not => by simp
@[to_additive]
theorem not_step_nil : ¬Step [] L := by
generalize h' : [] = L'
intro h
rcases h with - | ⟨L₁, L₂⟩
simp at h'
@[to_additive]
theorem Step.cons_left_iff {a : α} {b : Bool} :
Step ((a, b) :: L₁) L₂ ↔ (∃ L, Step L₁ L ∧ L₂ = (a, b) :: L) ∨ L₁ = (a, ! b) :: L₂ := by
constructor
· generalize hL : ((a, b) :: L₁ : List _) = L
rintro @⟨_ | ⟨p, s'⟩, e, a', b'⟩ <;> simp_all
· rintro (⟨L, h, rfl⟩ | rfl)
· exact Step.cons h
· exact Step.cons_not
@[to_additive]
theorem not_step_singleton : ∀ {p : α × Bool}, ¬Step [p] L
| (a, b) => by simp [Step.cons_left_iff, not_step_nil]
@[to_additive]
theorem Step.cons_cons_iff : ∀ {p : α × Bool}, Step (p :: L₁) (p :: L₂) ↔ Step L₁ L₂ := by
simp +contextual [Step.cons_left_iff, iff_def, or_imp]
@[to_additive]
theorem Step.append_left_iff : ∀ L, Step (L ++ L₁) (L ++ L₂) ↔ Step L₁ L₂
| [] => by simp
| p :: l => by simp [Step.append_left_iff l, Step.cons_cons_iff]
@[to_additive]
theorem Step.diamond_aux :
∀ {L₁ L₂ L₃ L₄ : List (α × Bool)} {x1 b1 x2 b2},
L₁ ++ (x1, b1) :: (x1, !b1) :: L₂ = L₃ ++ (x2, b2) :: (x2, !b2) :: L₄ →
L₁ ++ L₂ = L₃ ++ L₄ ∨ ∃ L₅, Red.Step (L₁ ++ L₂) L₅ ∧ Red.Step (L₃ ++ L₄) L₅
| [], _, [], _, _, _, _, _, H => by injections; subst_vars; simp
| [], _, [(x3, b3)], _, _, _, _, _, H => by injections; subst_vars; simp
| [(x3, b3)], _, [], _, _, _, _, _, H => by injections; subst_vars; simp
| [], _, (x3, b3) :: (x4, b4) :: tl, _, _, _, _, _, H => by
injections; subst_vars; right; exact ⟨_, Red.Step.not, Red.Step.cons_not⟩
| (x3, b3) :: (x4, b4) :: tl, _, [], _, _, _, _, _, H => by
injections; subst_vars; right; simpa using ⟨_, Red.Step.cons_not, Red.Step.not⟩
| (x3, b3) :: tl, _, (x4, b4) :: tl2, _, _, _, _, _, H =>
let ⟨H1, H2⟩ := List.cons.inj H
match Step.diamond_aux H2 with
| Or.inl H3 => Or.inl <| by simp [H1, H3]
| Or.inr ⟨L₅, H3, H4⟩ => Or.inr ⟨_, Step.cons H3, by simpa [H1] using Step.cons H4⟩
@[to_additive]
theorem Step.diamond :
∀ {L₁ L₂ L₃ L₄ : List (α × Bool)},
Red.Step L₁ L₃ → Red.Step L₂ L₄ → L₁ = L₂ → L₃ = L₄ ∨ ∃ L₅, Red.Step L₃ L₅ ∧ Red.Step L₄ L₅
| _, _, _, _, Red.Step.not, Red.Step.not, H => Step.diamond_aux H
@[to_additive]
theorem Step.to_red : Step L₁ L₂ → Red L₁ L₂ :=
ReflTransGen.single
/-- **Church-Rosser theorem** for word reduction: If `w1 w2 w3` are words such that `w1` reduces
to `w2` and `w3` respectively, then there is a word `w4` such that `w2` and `w3` reduce to `w4`
respectively. This is also known as Newman's diamond lemma. -/
@[to_additive
/-- **Church-Rosser theorem** for word reduction: If `w1 w2 w3` are words such that `w1` reduces
to `w2` and `w3` respectively, then there is a word `w4` such that `w2` and `w3` reduce to `w4`
respectively. This is also known as Newman's diamond lemma. -/]
theorem church_rosser : Red L₁ L₂ → Red L₁ L₃ → Join Red L₂ L₃ :=
Relation.church_rosser fun _ b c hab hac =>
match b, c, Red.Step.diamond hab hac rfl with
| b, _, Or.inl rfl => ⟨b, by rfl, by rfl⟩
| _, _, Or.inr ⟨d, hbd, hcd⟩ => ⟨d, ReflGen.single hbd, hcd.to_red⟩
@[to_additive]
theorem cons_cons {p} : Red L₁ L₂ → Red (p :: L₁) (p :: L₂) :=
ReflTransGen.lift (List.cons p) fun _ _ => Step.cons
@[to_additive]
theorem cons_cons_iff (p) : Red (p :: L₁) (p :: L₂) ↔ Red L₁ L₂ :=
Iff.intro
(by
generalize eq₁ : (p :: L₁ : List _) = LL₁
generalize eq₂ : (p :: L₂ : List _) = LL₂
intro h
induction h using Relation.ReflTransGen.head_induction_on generalizing L₁ L₂ with
| refl =>
subst_vars
cases eq₂
constructor
| head h₁₂ h ih =>
subst_vars
obtain ⟨a, b⟩ := p
rw [Step.cons_left_iff] at h₁₂
rcases h₁₂ with (⟨L, h₁₂, rfl⟩ | rfl)
· exact (ih rfl rfl).head h₁₂
· exact (cons_cons h).tail Step.cons_not_rev)
cons_cons
@[to_additive]
theorem append_append_left_iff : ∀ L, Red (L ++ L₁) (L ++ L₂) ↔ Red L₁ L₂
| [] => Iff.rfl
| p :: L => by simp [append_append_left_iff L, cons_cons_iff]
@[to_additive]
theorem append_append (h₁ : Red L₁ L₃) (h₂ : Red L₂ L₄) : Red (L₁ ++ L₂) (L₃ ++ L₄) :=
(h₁.lift (fun L => L ++ L₂) fun _ _ => Step.append_right).trans ((append_append_left_iff _).2 h₂)
@[to_additive]
theorem to_append_iff : Red L (L₁ ++ L₂) ↔ ∃ L₃ L₄, L = L₃ ++ L₄ ∧ Red L₃ L₁ ∧ Red L₄ L₂ :=
Iff.intro
(by
generalize eq : L₁ ++ L₂ = L₁₂
intro h
induction h generalizing L₁ L₂ with
| refl => exact ⟨_, _, eq.symm, by rfl, by rfl⟩
| tail hLL' h ih =>
obtain @⟨s, e, a, b⟩ := h
rcases List.append_eq_append_iff.1 eq with (⟨s', rfl, rfl⟩ | ⟨e', rfl, rfl⟩)
· have : L₁ ++ (s' ++ (a, b) :: (a, not b) :: e) = L₁ ++ s' ++ (a, b) :: (a, not b) :: e :=
by simp
rcases ih this with ⟨w₁, w₂, rfl, h₁, h₂⟩
exact ⟨w₁, w₂, rfl, h₁, h₂.tail Step.not⟩
· have : s ++ (a, b) :: (a, not b) :: e' ++ L₂ = s ++ (a, b) :: (a, not b) :: (e' ++ L₂) :=
by simp
rcases ih this with ⟨w₁, w₂, rfl, h₁, h₂⟩
exact ⟨w₁, w₂, rfl, h₁.tail Step.not, h₂⟩)
fun ⟨_, _, Eq, h₃, h₄⟩ => Eq.symm ▸ append_append h₃ h₄
/-- The empty word `[]` only reduces to itself. -/
@[to_additive /-- The empty word `[]` only reduces to itself. -/]
theorem nil_iff : Red [] L ↔ L = [] :=
reflTransGen_iff_eq fun _ => Red.not_step_nil
/-- A letter only reduces to itself. -/
@[to_additive /-- A letter only reduces to itself. -/]
theorem singleton_iff {x} : Red [x] L₁ ↔ L₁ = [x] :=
reflTransGen_iff_eq fun _ => not_step_singleton
/-- If `x` is a letter and `w` is a word such that `xw` reduces to the empty word, then `w` reduces
to `x⁻¹` -/
@[to_additive
/-- If `x` is a letter and `w` is a word such that `x + w` reduces to the empty word, then `w`
reduces to `-x`. -/]
theorem cons_nil_iff_singleton {x b} : Red ((x, b) :: L) [] ↔ Red L [(x, not b)] :=
Iff.intro
(fun h => by
have h₁ : Red ((x, not b) :: (x, b) :: L) [(x, not b)] := cons_cons h
have h₂ : Red ((x, not b) :: (x, b) :: L) L := ReflTransGen.single Step.cons_not_rev
let ⟨L', h₁, h₂⟩ := church_rosser h₁ h₂
rw [singleton_iff] at h₁
subst L'
assumption)
fun h => (cons_cons h).tail Step.cons_not
@[to_additive]
theorem red_iff_irreducible {x1 b1 x2 b2} (h : (x1, b1) ≠ (x2, b2)) :
Red [(x1, !b1), (x2, b2)] L ↔ L = [(x1, !b1), (x2, b2)] := by
apply reflTransGen_iff_eq
generalize eq : [(x1, not b1), (x2, b2)] = L'
intro L h'
cases h'
simp only [List.cons_eq_append_iff, List.cons.injEq, Prod.mk.injEq, and_false,
List.nil_eq_append_iff, exists_const, or_self, or_false, List.cons_ne_nil] at eq
rcases eq with ⟨rfl, ⟨rfl, rfl⟩, ⟨rfl, rfl⟩, rfl⟩
simp at h
/-- If `x` and `y` are distinct letters and `w₁ w₂` are words such that `xw₁` reduces to `yw₂`, then
`w₁` reduces to `x⁻¹yw₂`. -/
@[to_additive /-- If `x` and `y` are distinct letters and `w₁ w₂` are words such that `x + w₁`
reduces to `y + w₂`, then `w₁` reduces to `-x + y + w₂`. -/]
theorem inv_of_red_of_ne {x1 b1 x2 b2} (H1 : (x1, b1) ≠ (x2, b2))
(H2 : Red ((x1, b1) :: L₁) ((x2, b2) :: L₂)) : Red L₁ ((x1, not b1) :: (x2, b2) :: L₂) := by
have : Red ((x1, b1) :: L₁) ([(x2, b2)] ++ L₂) := H2
rcases to_append_iff.1 this with ⟨_ | ⟨p, L₃⟩, L₄, eq, h₁, h₂⟩
· simp [nil_iff] at h₁
· cases eq
change Red (L₃ ++ L₄) ([(x1, not b1), (x2, b2)] ++ L₂)
apply append_append _ h₂
have h₁ : Red ((x1, not b1) :: (x1, b1) :: L₃) [(x1, not b1), (x2, b2)] := cons_cons h₁
have h₂ : Red ((x1, not b1) :: (x1, b1) :: L₃) L₃ := Step.cons_not_rev.to_red
rcases church_rosser h₁ h₂ with ⟨L', h₁, h₂⟩
rw [red_iff_irreducible H1] at h₁
rwa [h₁] at h₂
open List -- for <+ notation
@[to_additive]
theorem Step.sublist (H : Red.Step L₁ L₂) : L₂ <+ L₁ := by
cases H; simp
/-- If `w₁ w₂` are words such that `w₁` reduces to `w₂`, then `w₂` is a sublist of `w₁`. -/
@[to_additive
/-- If `w₁ w₂` are words such that `w₁` reduces to `w₂`, then `w₂` is a sublist of `w₁`. -/]
protected theorem sublist : Red L₁ L₂ → L₂ <+ L₁ :=
@reflTransGen_of_transitive_reflexive
_ (fun a b => b <+ a) _ _ _
(fun l => List.Sublist.refl l)
(fun _a _b _c hab hbc => List.Sublist.trans hbc hab)
(fun _ _ => Red.Step.sublist)
@[to_additive]
theorem length_le (h : Red L₁ L₂) : L₂.length ≤ L₁.length :=
h.sublist.length_le
@[to_additive]
theorem sizeof_of_step : ∀ {L₁ L₂ : List (α × Bool)},
Step L₁ L₂ → sizeOf L₂ < sizeOf L₁
| _, _, @Step.not _ L1 L2 x b => by
induction L1 with
| nil =>
dsimp
cutsat
| cons hd tl ih =>
dsimp
exact Nat.add_lt_add_left ih _
@[to_additive]
theorem length (h : Red L₁ L₂) : ∃ n, L₁.length = L₂.length + 2 * n := by
induction h with
| refl => exact ⟨0, rfl⟩
| tail _h₁₂ h₂₃ ih =>
rcases ih with ⟨n, eq⟩
exists 1 + n
simp [Nat.mul_add, eq, (Step.length h₂₃).symm, add_assoc]
@[to_additive]
theorem antisymm (h₁₂ : Red L₁ L₂) (h₂₁ : Red L₂ L₁) : L₁ = L₂ :=
h₂₁.sublist.antisymm h₁₂.sublist
end Red
@[to_additive]
theorem equivalence_join_red : Equivalence (Join (@Red α)) :=
equivalence_join_reflTransGen fun _ b c hab hac =>
match b, c, Red.Step.diamond hab hac rfl with
| b, _, Or.inl rfl => ⟨b, by rfl, by rfl⟩
| _, _, Or.inr ⟨d, hbd, hcd⟩ => ⟨d, ReflGen.single hbd, ReflTransGen.single hcd⟩
@[to_additive]
theorem join_red_of_step (h : Red.Step L₁ L₂) : Join Red L₁ L₂ :=
join_of_single reflexive_reflTransGen h.to_red
@[to_additive]
theorem eqvGen_step_iff_join_red : EqvGen Red.Step L₁ L₂ ↔ Join Red L₁ L₂ :=
Iff.intro
(fun h =>
have : EqvGen (Join Red) L₁ L₂ := h.mono fun _ _ => join_red_of_step
equivalence_join_red.eqvGen_iff.1 this)
(join_of_equivalence (Relation.EqvGen.is_equivalence _) fun _ _ =>
reflTransGen_of_equivalence (Relation.EqvGen.is_equivalence _) EqvGen.rel)
/-! ### Reduced words -/
/-- Predicate asserting that the word `L` admits no reduction steps, i.e., no two neighboring
elements of the word cancel. -/
@[to_additive /-- Predicate asserting the word `L` admits no reduction steps,
i.e., no two neighboring elements of the word cancel. -/]
def IsReduced (L : List (α × Bool)) : Prop := L.IsChain fun a b ↦ a.1 = b.1 → a.2 = b.2
section IsReduced
open List
@[to_additive (attr := simp)]
theorem IsReduced.nil : IsReduced ([] : List (α × Bool)) := isChain_nil
@[to_additive (attr := simp)]
theorem IsReduced.singleton {a : α × Bool} : IsReduced [a] := isChain_singleton a
@[to_additive (attr := simp)]
theorem isReduced_cons_cons {a b : (α × Bool)} :
IsReduced (a :: b :: L) ↔ (a.1 = b.1 → a.2 = b.2) ∧ IsReduced (b :: L) := isChain_cons_cons
@[to_additive]
theorem IsReduced.not_step (h : IsReduced L₁) : ¬ Red.Step L₁ L₂ := fun step ↦ by
induction step
simp [IsReduced] at h
@[to_additive]
lemma IsReduced.of_forall_not_step :
∀ {L₁ : List (α × Bool)}, (∀ L₂, ¬ Red.Step L₁ L₂) → IsReduced L₁
| [], _ => .nil
| [a], _ => .singleton
| (a₁, b₁) :: (a₂, b₂) :: L₁, hL₁ => by
rw [isReduced_cons_cons]
refine ⟨?_, .of_forall_not_step fun L₂ step ↦ hL₁ _ step.cons⟩
rintro rfl
symm
rw [← Bool.ne_not]
rintro rfl
exact hL₁ L₁ <| .not (L₁ := [])
@[to_additive]
theorem isReduced_iff_not_step : IsReduced L₁ ↔ ∀ L₂, ¬ Red.Step L₁ L₂ where
mp h _ := h.not_step
mpr := .of_forall_not_step
@[to_additive]
theorem IsReduced.red_iff_eq (h : IsReduced L₁) : Red L₁ L₂ ↔ L₂ = L₁ :=
Relation.reflTransGen_iff_eq fun _ => h.not_step
@[to_additive]
theorem IsReduced.append_overlap {L₁ L₂ L₃ : List (α × Bool)} (h₁ : IsReduced (L₁ ++ L₂))
(h₂ : IsReduced (L₂ ++ L₃)) (hn : L₂ ≠ []) : IsReduced (L₁ ++ L₂ ++ L₃) :=
IsChain.append_overlap h₁ h₂ hn
@[to_additive]
theorem IsReduced.infix (h : IsReduced L₂) (h' : L₁ <:+: L₂) : IsReduced L₁ := IsChain.infix h h'
end IsReduced
end FreeGroup
/--
If `α` is a type, then `FreeGroup α` is the free group generated by `α`.
This is a group equipped with a function `FreeGroup.of : α → FreeGroup α` which has
the following universal property: if `G` is any group, and `f : α → G` is any function,
then this function is the composite of `FreeGroup.of` and a unique group homomorphism
`FreeGroup.lift f : FreeGroup α →* G`.
A typical element of `FreeGroup α` is a formal product of
elements of `α` and their formal inverses, quotient by reduction.
For example if `x` and `y` are terms of type `α` then `x⁻¹ * y * y * x * y⁻¹` is a
"typical" element of `FreeGroup α`. In particular if `α` is empty
then `FreeGroup α` is isomorphic to the trivial group, and if `α` has one term
then `FreeGroup α` is isomorphic to `Multiplicative ℤ`.
If `α` has two or more terms then `FreeGroup α` is not commutative.
-/
@[to_additive
/-- If `α` is a type, then `FreeAddGroup α` is the free additive group generated by `α`.
This is a group equipped with a function `FreeAddGroup.of : α → FreeAddGroup α` which has
the following universal property: if `G` is any group, and `f : α → G` is any function,
then this function is the composite of `FreeAddGroup.of` and a unique group homomorphism
`FreeAddGroup.lift f : FreeAddGroup α →+ G`.
A typical element of `FreeAddGroup α` is a formal sum of
elements of `α` and their formal inverses, quotient by reduction.
For example if `x` and `y` are terms of type `α` then `-x + y + y + x + -y` is a
"typical" element of `FreeAddGroup α`. In particular if `α` is empty
then `FreeAddGroup α` is isomorphic to the trivial group, and if `α` has one term
then `FreeAddGroup α` is isomorphic to `ℤ`.
If `α` has two or more terms then `FreeAddGroup α` is not commutative. -/]
def FreeGroup (α : Type u) : Type u :=
Quot <| @FreeGroup.Red.Step α
namespace FreeGroup
variable {L L₁ L₂ L₃ L₄ : List (α × Bool)}
/-- The canonical map from `List (α × Bool)` to the free group on `α`. -/
@[to_additive /-- The canonical map from `List (α × Bool)` to the free additive group on `α`. -/]
def mk (L : List (α × Bool)) : FreeGroup α :=
Quot.mk Red.Step L
@[to_additive (attr := simp)]
theorem quot_mk_eq_mk : Quot.mk Red.Step L = mk L :=
rfl
@[to_additive (attr := simp)]
theorem quot_lift_mk (β : Type v) (f : List (α × Bool) → β)
(H : ∀ L₁ L₂, Red.Step L₁ L₂ → f L₁ = f L₂) : Quot.lift f H (mk L) = f L :=
rfl
@[to_additive (attr := simp)]
theorem quot_liftOn_mk (β : Type v) (f : List (α × Bool) → β)
(H : ∀ L₁ L₂, Red.Step L₁ L₂ → f L₁ = f L₂) : Quot.liftOn (mk L) f H = f L :=
rfl
open scoped Relator in
@[to_additive (attr := simp)]
theorem quot_map_mk (β : Type v) (f : List (α × Bool) → List (β × Bool))
(H : (Red.Step ⇒ Red.Step) f f) : Quot.map f H (mk L) = mk (f L) :=
rfl
@[to_additive]
instance : One (FreeGroup α) :=
⟨mk []⟩
@[to_additive]
theorem one_eq_mk : (1 : FreeGroup α) = mk [] :=
rfl
@[to_additive]
instance : Inhabited (FreeGroup α) :=
⟨1⟩
@[to_additive]
instance [IsEmpty α] : Unique (FreeGroup α) := by unfold FreeGroup; infer_instance
@[to_additive]
instance : Mul (FreeGroup α) :=
⟨fun x y =>
Quot.liftOn x
(fun L₁ =>
Quot.liftOn y (fun L₂ => mk <| L₁ ++ L₂) fun _L₂ _L₃ H =>
Quot.sound <| Red.Step.append_left H)
fun _L₁ _L₂ H => Quot.inductionOn y fun _L₃ => Quot.sound <| Red.Step.append_right H⟩
@[to_additive (attr := simp)]
theorem mul_mk : mk L₁ * mk L₂ = mk (L₁ ++ L₂) :=
rfl
/-- Transform a word representing a free group element into a word representing its inverse. -/
@[to_additive /-- Transform a word representing a free group element into a word representing its
negative. -/]
def invRev (w : List (α × Bool)) : List (α × Bool) :=
(List.map (fun g : α × Bool => (g.1, not g.2)) w).reverse
@[to_additive (attr := simp)]
theorem invRev_length : (invRev L₁).length = L₁.length := by simp [invRev]
@[to_additive (attr := simp)]
theorem invRev_invRev : invRev (invRev L₁) = L₁ := by
simp [invRev, List.map_reverse, Function.comp_def]
@[to_additive (attr := simp)]
theorem invRev_empty : invRev ([] : List (α × Bool)) = [] :=
rfl
@[to_additive (attr := simp)]
theorem invRev_append : invRev (L₁ ++ L₂) = invRev L₂ ++ invRev L₁ := by simp [invRev]
@[to_additive]
theorem invRev_cons {a : (α × Bool)} : invRev (a :: L) = invRev L ++ invRev [a] := by
simp [invRev]
@[to_additive]
theorem invRev_involutive : Function.Involutive (@invRev α) := fun _ => invRev_invRev
@[to_additive]
theorem invRev_injective : Function.Injective (@invRev α) :=
invRev_involutive.injective
@[to_additive]
theorem invRev_surjective : Function.Surjective (@invRev α) :=
invRev_involutive.surjective
@[to_additive]
theorem invRev_bijective : Function.Bijective (@invRev α) :=
invRev_involutive.bijective
@[to_additive]
instance : Inv (FreeGroup α) :=
⟨Quot.map invRev
(by
intro a b h
cases h
simp [invRev])⟩
@[to_additive (attr := simp)]
theorem inv_mk : (mk L)⁻¹ = mk (invRev L) :=
rfl
@[to_additive]
theorem Red.Step.invRev {L₁ L₂ : List (α × Bool)} (h : Red.Step L₁ L₂) :
Red.Step (FreeGroup.invRev L₁) (FreeGroup.invRev L₂) := by
obtain ⟨a, b, x, y⟩ := h
simp [FreeGroup.invRev]
@[to_additive]
theorem Red.invRev {L₁ L₂ : List (α × Bool)} (h : Red L₁ L₂) : Red (invRev L₁) (invRev L₂) :=
Relation.ReflTransGen.lift _ (fun _a _b => Red.Step.invRev) h
@[to_additive (attr := simp)]
theorem Red.step_invRev_iff :
Red.Step (FreeGroup.invRev L₁) (FreeGroup.invRev L₂) ↔ Red.Step L₁ L₂ :=
⟨fun h => by simpa only [invRev_invRev] using h.invRev, fun h => h.invRev⟩
@[to_additive (attr := simp)]
theorem red_invRev_iff : Red (invRev L₁) (invRev L₂) ↔ Red L₁ L₂ :=
⟨fun h => by simpa only [invRev_invRev] using h.invRev, fun h => h.invRev⟩
@[to_additive]
instance : Group (FreeGroup α) where
mul_assoc := by rintro ⟨L₁⟩ ⟨L₂⟩ ⟨L₃⟩; simp
one_mul := by rintro ⟨L⟩; rfl
mul_one := by rintro ⟨L⟩; simp [one_eq_mk]
inv_mul_cancel := by
rintro ⟨L⟩
exact
List.recOn L rfl fun ⟨x, b⟩ tl ih =>
Eq.trans (Quot.sound <| by simp [invRev]) ih
@[to_additive (attr := simp)]
theorem pow_mk (n : ℕ) : mk L ^ n = mk (List.flatten <| List.replicate n L) :=
match n with
| 0 => rfl
| n + 1 => by rw [pow_succ', pow_mk, mul_mk, List.replicate_succ, List.flatten_cons]
/-- `of` is the canonical injection from the type to the free group over that type by sending each
element to the equivalence class of the letter that is the element. -/
@[to_additive /-- `of` is the canonical injection from the type to the free group over that type
by sending each element to the equivalence class of the letter that is the element. -/]
def of (x : α) : FreeGroup α :=
mk [(x, true)]
@[to_additive (attr := elab_as_elim, induction_eliminator)]
protected lemma induction_on {C : FreeGroup α → Prop} (z : FreeGroup α) (C1 : C 1)
(of : ∀ x, C <| of x) (inv_of : ∀ x, C (.of x) → C (.of x)⁻¹)
(mul : ∀ x y, C x → C y → C (x * y)) : C z :=
Quot.inductionOn z fun L ↦ L.recOn C1 fun ⟨x, b⟩ _tl ih ↦
b.recOn (mul _ _ (inv_of _ <| of x) ih) (mul _ _ (of x) ih)
/-- Two homomorphisms out of a free group are equal if they are equal on generators.
See note [partially-applied ext lemmas]. -/
@[to_additive (attr := ext) /-- Two homomorphisms out of a free additive group are equal if they are
equal on generators. See note [partially-applied ext lemmas]. -/]
lemma ext_hom {M : Type*} [Monoid M] (f g : FreeGroup α →* M) (h : ∀ a, f (of a) = g (of a)) :
f = g := by
ext x
have this (x) : f (of x)⁻¹ = g (of x)⁻¹ := by
trans f (of x)⁻¹ * f (of x) * g (of x)⁻¹
· simp_rw [mul_assoc, h, ← _root_.map_mul, mul_inv_cancel, _root_.map_one, mul_one]
· simp_rw [← _root_.map_mul, inv_mul_cancel, _root_.map_one, one_mul]
induction x <;> simp [*]
@[to_additive]
theorem Red.exact : mk L₁ = mk L₂ ↔ Join Red L₁ L₂ :=
calc
mk L₁ = mk L₂ ↔ EqvGen Red.Step L₁ L₂ := Iff.intro Quot.eqvGen_exact Quot.eqvGen_sound
_ ↔ Join Red L₁ L₂ := eqvGen_step_iff_join_red
/-- The canonical map from the type to the free group is an injection. -/
@[to_additive /-- The canonical map from the type to the additive free group is an injection. -/]
theorem of_injective : Function.Injective (@of α) := fun _ _ H => by
let ⟨L₁, hx, hy⟩ := Red.exact.1 H
simp [Red.singleton_iff] at hx hy; simp_all
section lift
variable {β : Type v} [Group β] (f : α → β) {x y : FreeGroup α}
/-- Given `f : α → β` with `β` a group, the canonical map `List (α × Bool) → β` -/
@[to_additive /-- Given `f : α → β` with `β` an additive group, the canonical map
`List (α × Bool) → β` -/]
def Lift.aux : List (α × Bool) → β := fun L =>
List.prod <| L.map fun x => cond x.2 (f x.1) (f x.1)⁻¹
@[to_additive]
theorem Red.Step.lift {f : α → β} (H : Red.Step L₁ L₂) : Lift.aux f L₁ = Lift.aux f L₂ := by
obtain @⟨_, _, _, b⟩ := H; cases b <;> simp [Lift.aux, List.prod_append]
/-- If `β` is a group, then any function from `α` to `β` extends uniquely to a group homomorphism
from the free group over `α` to `β` -/
@[to_additive (attr := simps symm_apply)
/-- If `β` is an additive group, then any function from `α` to `β` extends uniquely to an
additive group homomorphism from the free additive group over `α` to `β` -/]
def lift : (α → β) ≃ (FreeGroup α →* β) where
toFun f :=
MonoidHom.mk' (Quot.lift (Lift.aux f) fun _ _ => Red.Step.lift) <| by
rintro ⟨L₁⟩ ⟨L₂⟩; simp [Lift.aux, List.prod_append]
invFun g := g ∘ of
left_inv f := by ext; simp [of, Lift.aux]
right_inv g := by ext; simp [of, Lift.aux]
variable {f}
@[to_additive (attr := simp)]
theorem lift_mk : lift f (mk L) = List.prod (L.map fun x => cond x.2 (f x.1) (f x.1)⁻¹) :=
rfl
@[to_additive (attr := simp)]
theorem lift_apply_of {x} : lift f (of x) = f x := by simp [of]
@[to_additive]
theorem lift_unique (g : FreeGroup α →* β) (hg : ∀ x, g (FreeGroup.of x) = f x) {x} :
g x = FreeGroup.lift f x :=
DFunLike.congr_fun (lift.symm_apply_eq.mp (funext hg : g ∘ FreeGroup.of = f)) x
@[to_additive]
theorem lift_of_eq_id (α) : lift of = MonoidHom.id (FreeGroup α) :=
lift.apply_symm_apply (MonoidHom.id _)
@[to_additive]
theorem lift_of_apply (x : FreeGroup α) : lift FreeGroup.of x = x :=
DFunLike.congr_fun (lift_of_eq_id α) x
@[to_additive]
theorem range_lift_le {s : Subgroup β} (H : Set.range f ⊆ s) : (lift f).range ≤ s := by
rintro _ ⟨⟨L⟩, rfl⟩
exact List.recOn L s.one_mem fun ⟨x, b⟩ tl ih ↦
Bool.recOn b (by simpa using s.mul_mem (s.inv_mem <| H ⟨x, rfl⟩) ih)
(by simpa using s.mul_mem (H ⟨x, rfl⟩) ih)
@[to_additive]
theorem range_lift_eq_closure : (lift f).range = Subgroup.closure (Set.range f) := by
apply le_antisymm (range_lift_le Subgroup.subset_closure)
rw [Subgroup.closure_le]
rintro _ ⟨a, rfl⟩
exact ⟨FreeGroup.of a, by simp only [lift_apply_of]⟩
@[to_additive]
theorem closure_eq_range (s : Set β) : Subgroup.closure s = (lift ((↑) : s → β)).range := by
rw [FreeGroup.range_lift_eq_closure, Subtype.range_coe]
/-- The generators of `FreeGroup α` generate `FreeGroup α`. That is, the subgroup closure of the
set of generators equals `⊤`. -/
@[to_additive (attr := simp)]
theorem closure_range_of (α) :
Subgroup.closure (Set.range (FreeGroup.of : α → FreeGroup α)) = ⊤ := by
rw [← range_lift_eq_closure, lift_of_eq_id]
exact MonoidHom.range_eq_top.2 Function.surjective_id
end lift
section Map
variable {β : Type v} (f : α → β) {x y : FreeGroup α}
/-- Any function from `α` to `β` extends uniquely to a group homomorphism from the free group over
`α` to the free group over `β`. -/
@[to_additive /-- Any function from `α` to `β` extends uniquely to an additive group homomorphism
from the additive free group over `α` to the additive free group over `β`. -/]
def map : FreeGroup α →* FreeGroup β :=
MonoidHom.mk'
(Quot.map (List.map fun x => (f x.1, x.2)) fun L₁ L₂ H => by cases H; simp)
(by rintro ⟨L₁⟩ ⟨L₂⟩; simp)
variable {f}
@[to_additive (attr := simp)]
theorem map.mk : map f (mk L) = mk (L.map fun x => (f x.1, x.2)) :=
rfl
@[to_additive (attr := simp)]
theorem map.id (x : FreeGroup α) : map id x = x := by rcases x with ⟨L⟩; simp [List.map_id']
@[to_additive (attr := simp)]
theorem map.id' (x : FreeGroup α) : map (fun z => z) x = x :=
map.id x
@[to_additive]
theorem map.comp {γ : Type w} (f : α → β) (g : β → γ) (x) :
map g (map f x) = map (g ∘ f) x := by
rcases x with ⟨L⟩; simp [Function.comp_def]
@[to_additive (attr := simp)]
theorem map.of {x} : map f (of x) = of (f x) :=
rfl
@[to_additive]
theorem map.unique (g : FreeGroup α →* FreeGroup β)
(hg : ∀ x, g (FreeGroup.of x) = FreeGroup.of (f x)) :
∀ {x}, g x = map f x := by
rintro ⟨L⟩
exact List.recOn L g.map_one fun ⟨x, b⟩ t (ih : g (FreeGroup.mk t) = map f (FreeGroup.mk t)) =>
Bool.recOn b
(show g ((FreeGroup.of x)⁻¹ * FreeGroup.mk t) =
FreeGroup.map f ((FreeGroup.of x)⁻¹ * FreeGroup.mk t) by
simp [g.map_mul, g.map_inv, hg, ih])
(show g (FreeGroup.of x * FreeGroup.mk t) =
FreeGroup.map f (FreeGroup.of x * FreeGroup.mk t) by simp [g.map_mul, hg, ih])
@[to_additive]
theorem map_eq_lift : map f x = lift (of ∘ f) x :=
Eq.symm <| map.unique _ fun x => by simp
/-- Equivalent types give rise to multiplicatively equivalent free groups.
The converse can be found in `Mathlib/GroupTheory/FreeGroup/GeneratorEquiv.lean`, as
`Equiv.ofFreeGroupEquiv`. -/
@[to_additive (attr := simps apply)
/-- Equivalent types give rise to additively equivalent additive free groups. -/]
def freeGroupCongr {α β} (e : α ≃ β) : FreeGroup α ≃* FreeGroup β where
toFun := map e
invFun := map e.symm
left_inv x := by simp [map.comp]
right_inv x := by simp [map.comp]
map_mul' := MonoidHom.map_mul _
@[to_additive (attr := simp)]
theorem freeGroupCongr_refl : freeGroupCongr (Equiv.refl α) = MulEquiv.refl _ :=
MulEquiv.ext map.id
@[to_additive (attr := simp)]
theorem freeGroupCongr_symm {α β} (e : α ≃ β) : (freeGroupCongr e).symm = freeGroupCongr e.symm :=
rfl
@[to_additive]
theorem freeGroupCongr_trans {α β γ} (e : α ≃ β) (f : β ≃ γ) :
(freeGroupCongr e).trans (freeGroupCongr f) = freeGroupCongr (e.trans f) :=
MulEquiv.ext <| map.comp _ _
end Map
section Prod
variable [Group α] (x y : FreeGroup α)
/-- If `α` is a group, then any function from `α` to `α` extends uniquely to a homomorphism from the
free group over `α` to `α`. This is the multiplicative version of `FreeGroup.sum`. -/
@[to_additive /-- If `α` is an additive group, then any function from `α` to `α` extends uniquely
to an additive homomorphism from the additive free group over `α` to `α`. -/]
def prod : FreeGroup α →* α :=
lift id
variable {x y}
@[to_additive (attr := simp)]
theorem prod_mk : prod (mk L) = List.prod (L.map fun x => cond x.2 x.1 x.1⁻¹) :=
rfl
@[to_additive (attr := simp)]
theorem prod.of {x : α} : prod (of x) = x :=
lift_apply_of
@[to_additive]
theorem prod.unique (g : FreeGroup α →* α) (hg : ∀ x, g (FreeGroup.of x) = x) {x} : g x = prod x :=
lift_unique g hg
end Prod
@[to_additive]
theorem lift_eq_prod_map {β : Type v} [Group β] {f : α → β} {x} : lift f x = prod (map f x) := by
rw [← lift_unique (prod.comp (map f)) (by simp), MonoidHom.coe_comp, Function.comp_apply]
section Sum
variable [AddGroup α] (x y : FreeGroup α)
/-- If `α` is a group, then any function from `α` to `α` extends uniquely to a homomorphism from the
free group over `α` to `α`. This is the additive version of `Prod`. -/
def sum : α :=
@prod (Multiplicative _) _ x
variable {x y}
@[simp]
theorem sum_mk : sum (mk L) = List.sum (L.map fun x => cond x.2 x.1 (-x.1)) :=
rfl
@[simp]
theorem sum.of {x : α} : sum (of x) = x :=
@prod.of _ (_) _
-- note: there are no bundled homs with different notation in the domain and codomain, so we copy
-- these manually
@[simp]
theorem sum.map_mul : sum (x * y) = sum x + sum y :=
(@prod (Multiplicative _) _).map_mul _ _
@[simp]
theorem sum.map_one : sum (1 : FreeGroup α) = 0 :=
(@prod (Multiplicative _) _).map_one
@[simp]
theorem sum.map_inv : sum x⁻¹ = -sum x :=
(prod : FreeGroup (Multiplicative α) →* Multiplicative α).map_inv _
end Sum
/-- The bijection between the free group on the empty type, and a type with one element. -/
@[to_additive /-- The bijection between the additive free group on the empty type, and a type with
one element. -/]
def freeGroupEmptyEquivUnit : FreeGroup Empty ≃ Unit where
toFun _ := ()
invFun _ := 1
left_inv := by rintro ⟨_ | ⟨⟨⟨⟩, _⟩, _⟩⟩; rfl
/-- The bijection between the free group on a singleton, and the integers. -/
def freeGroupUnitEquivInt : FreeGroup Unit ≃ ℤ where
toFun x := sum (by
revert x
exact ↑(map fun _ => (1 : ℤ)))
invFun x := of () ^ x
left_inv := by
rintro ⟨L⟩
simp only [quot_mk_eq_mk, map.mk, sum_mk, List.map_map]
exact List.recOn L
(by rfl)
(fun ⟨⟨⟩, b⟩ tl ih => by
cases b <;> simp [zpow_add] at ih ⊢ <;> rw [ih] <;> rfl)
right_inv x :=
Int.induction_on x (by simp)
(fun i ih => by
simp only [zpow_natCast, map_pow, map.of] at ih
simp [zpow_add, ih])
(fun i ih => by
simp only [zpow_neg, zpow_natCast, map_inv, map_pow, map.of, sum.map_inv, neg_inj] at ih
simp [zpow_add, ih, sub_eq_add_neg])
section Category
variable {β : Type u}
@[to_additive]
instance : Monad FreeGroup.{u} where
pure {_α} := of
map {_α _β f} := map f
bind {_α _β x f} := lift f x
@[to_additive]
theorem map_pure (f : α → β) (x : α) : f <$> (pure x : FreeGroup α) = pure (f x) :=
map.of
@[to_additive (attr := simp)]
theorem map_one (f : α → β) : f <$> (1 : FreeGroup α) = 1 :=
(map f).map_one
@[to_additive (attr := simp)]
theorem map_mul (f : α → β) (x y : FreeGroup α) : f <$> (x * y) = f <$> x * f <$> y :=
(map f).map_mul x y
@[to_additive (attr := simp)]
theorem map_inv (f : α → β) (x : FreeGroup α) : f <$> x⁻¹ = (f <$> x)⁻¹ :=
(map f).map_inv x
@[to_additive]
theorem pure_bind (f : α → FreeGroup β) (x) : pure x >>= f = f x :=
lift_apply_of
@[to_additive (attr := simp)]
theorem one_bind (f : α → FreeGroup β) : 1 >>= f = 1 :=
(lift f).map_one
@[to_additive (attr := simp)]
theorem mul_bind (f : α → FreeGroup β) (x y : FreeGroup α) : x * y >>= f = (x >>= f) * (y >>= f) :=
(lift f).map_mul _ _
@[to_additive (attr := simp)]
theorem inv_bind (f : α → FreeGroup β) (x : FreeGroup α) : x⁻¹ >>= f = (x >>= f)⁻¹ :=
(lift f).map_inv _
@[to_additive]
instance : LawfulMonad FreeGroup.{u} := LawfulMonad.mk'
(id_map := fun x =>
FreeGroup.induction_on x (map_one id) (fun x => map_pure id x) (fun x ih => by rw [map_inv, ih])
fun x y ihx ihy => by rw [map_mul, ihx, ihy])
(pure_bind := fun x f => pure_bind f x)
(bind_assoc := fun x => by
refine FreeGroup.induction_on x ?_ ?_ ?_ ?_ <;> simp +contextual [instMonad])
(bind_pure_comp := fun f x => by
refine FreeGroup.induction_on x ?_ ?_ ?_ ?_ <;> simp +contextual [instMonad])
end Category
end FreeGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeGroup/CyclicallyReduced.lean | import Mathlib.Data.List.Induction
import Mathlib.GroupTheory.FreeGroup.Basic
import Mathlib.GroupTheory.FreeGroup.Reduce
import Mathlib.Tactic.Group
/-!
This file defines some extra lemmas for free groups, in particular about cyclically reduced words.
We show that free groups are (strongly) torsion-free in the sense of `IsMulTorsionFree`, i.e.,
taking powers by every non-zero element `n : ℕ` is injective.
## Main declarations
* `FreeGroup.IsCyclicallyReduced`: the predicate for cyclically reduced words
-/
open List
universe u
variable {α : Type u}
namespace FreeGroup
variable {L L₁ L₂ L₃ : List (α × Bool)}
/-- Predicate asserting that the word `L` is cyclically reduced, i.e., it is reduced and furthermore
the first and the last letter of the word do not cancel. The empty word is by convention also
cyclically reduced. -/
@[to_additive /-- Predicate asserting that the word `L` is cyclically reduced, i.e., it is reduced
and furthermore the first and the last letter of the word do not cancel. The empty word is by
convention also cyclically reduced. -/]
def IsCyclicallyReduced (L : List (α × Bool)) : Prop :=
IsReduced L ∧ ∀ a ∈ L.getLast?, ∀ b ∈ L.head?, a.1 = b.1 → a.2 = b.2
@[to_additive]
theorem isCyclicallyReduced_iff :
IsCyclicallyReduced L ↔
IsReduced L ∧ ∀ a ∈ L.getLast?, ∀ b ∈ L.head?, a.1 = b.1 → a.2 = b.2 := Iff.rfl
@[to_additive]
theorem isCyclicallyReduced_cons_append_iff {a b : α × Bool} :
IsCyclicallyReduced (b :: L ++ [a]) ↔
IsReduced (b :: L ++ [a]) ∧ (a.1 = b.1 → a.2 = b.2) := by
rw [isCyclicallyReduced_iff, List.getLast?_concat]
simp
namespace IsCyclicallyReduced
@[to_additive (attr := simp)]
protected theorem nil : IsCyclicallyReduced ([] : List (α × Bool)) := by
simp [IsCyclicallyReduced]
@[to_additive (attr := simp)]
protected theorem singleton {x : (α × Bool)} : IsCyclicallyReduced [x] := by
simp [IsCyclicallyReduced]
@[to_additive]
theorem isReduced (h : IsCyclicallyReduced L) : IsReduced L := h.1
@[to_additive]
theorem flatten_replicate (h : IsCyclicallyReduced L) (n : ℕ) :
IsCyclicallyReduced (List.replicate n L).flatten := by match n, L with
| 0, _ => simp
| n + 1, [] => simp
| n + 1, (head :: tail) =>
rw [isCyclicallyReduced_iff, IsReduced, List.isChain_flatten (by simp)]
refine ⟨⟨by simpa [IsReduced] using h.isReduced, List.isChain_replicate_of_rel _ h.2⟩,
fun _ ha _ hb ↦ ?_⟩
rw [Option.mem_def, List.getLast?_flatten_replicate (h := by simp +arith)] at ha
rw [Option.mem_def, List.head?_flatten_replicate (h := by simp +arith)] at hb
exact h.2 _ ha _ hb
end IsCyclicallyReduced
@[to_additive]
theorem IsReduced.append_flatten_replicate_append (h₁ : IsCyclicallyReduced L₂)
(h₂ : IsReduced (L₁ ++ L₂ ++ L₃)) {n : ℕ} (hn : n ≠ 0) :
IsReduced (L₁ ++ (List.replicate n L₂).flatten ++ L₃) := by
match n with
| 0 => contradiction
| n + 1 =>
if h : L₂ = [] then simp_all else
have h' : (replicate (n + 1) L₂).flatten ≠ [] := by simp [h]
refine IsReduced.append_overlap ?_ ?_ (hn := h')
· rw [replicate_succ, flatten_cons, ← append_assoc]
refine IsReduced.append_overlap (h₂.infix ⟨[], L₃, by simp⟩) ?_ h
rw [← flatten_cons, ← replicate_succ]
exact (h₁.flatten_replicate _).isReduced
· rw [replicate_succ', flatten_concat]
refine IsReduced.append_overlap ?_ (h₂.infix ⟨L₁, [], by simp⟩) h
rw [← flatten_concat, ← replicate_succ']
exact (h₁.flatten_replicate _).isReduced
/-- This function produces a subword of a word `L` by cancelling the first and last letters of `L`
as long as possible. If `L` is reduced, the resulting word will be cyclically reduced. -/
@[to_additive /-- This function produces a subword of a word `L` by cancelling the first and last
letters of `L` as long as possible. If `L` is reduced, the resulting word will be cyclically
reduced. -/]
def reduceCyclically [DecidableEq α] : List (α × Bool) → List (α × Bool) :=
List.bidirectionalRec
(nil := [])
(singleton := fun x => [x])
(cons_append := fun a L b rC => if b.1 = a.1 ∧ (!b.2) = a.2 then rC else a :: L ++ [b])
namespace reduceCyclically
variable [DecidableEq α]
@[to_additive (attr := simp)]
protected theorem nil : reduceCyclically ([] : List (α × Bool)) = [] := by simp [reduceCyclically]
@[to_additive (attr := simp)]
protected theorem singleton {a : α × Bool} : reduceCyclically [a] = [a] := by
simp [reduceCyclically]
@[to_additive]
protected theorem cons_append {a b : α × Bool} (L : List (α × Bool)) :
reduceCyclically (a :: (L ++ [b])) =
if b.1 = a.1 ∧ (!b.2) = a.2 then reduceCyclically L else a :: L ++ [b] := by
simp [reduceCyclically]
@[to_additive]
theorem isCyclicallyReduced (h : IsReduced L) : IsCyclicallyReduced (reduceCyclically L) := by
induction L using List.bidirectionalRec
case nil => simp
case singleton => simp
case cons_append a l b ih =>
rw [reduceCyclically.cons_append]
split
case isTrue => exact ih (h.infix ⟨[a], [b], rfl⟩)
case isFalse h' =>
rw [isCyclicallyReduced_cons_append_iff]
exact ⟨h, by simpa using h'⟩
/-- Partner function to `reduceCyclically`.
See `reduceCyclically.conj_conjugator_reduceCyclically`. -/
@[to_additive /-- Partner function to `reduceCyclically`.
See `reduceCyclically.conj_conjugator_reduceCyclically`. -/]
def conjugator : List (α × Bool) → List (α × Bool) :=
List.bidirectionalRec
(nil := [])
(singleton := fun _ => [])
(cons_append := fun a _ b rCC => if b.1 = a.1 ∧ (!b.2) = a.2 then a :: rCC else [] )
@[to_additive (attr := simp)]
protected theorem conjugator.nil : conjugator ([] : List (α × Bool)) = [] := by simp [conjugator]
@[to_additive (attr := simp)]
protected theorem conjugator.singleton {a : α × Bool} : conjugator [a] = [] := by simp [conjugator]
@[to_additive]
protected theorem conjugator.cons_append {a b : α × Bool} (L : List (α × Bool)) :
conjugator (a :: (L ++ [b])) = if b.1 = a.1 ∧ (!b.2) = a.2 then a :: conjugator L else [] := by
simp [conjugator]
@[to_additive]
theorem conj_conjugator_reduceCyclically (L : List (α × Bool)) :
conjugator L ++ reduceCyclically L ++ invRev (conjugator L) = L := by
induction L using List.bidirectionalRec
case nil => simp
case singleton => simp
case cons_append a l b eq =>
rw [reduceCyclically.cons_append, conjugator.cons_append]
split
case isTrue h =>
nth_rw 4 [← eq]
simp [invRev, h.1.symm, h.2.symm]
case isFalse => simp
@[to_additive]
theorem reduce_flatten_replicate_succ (h : IsReduced L) (n : ℕ) :
reduce (List.replicate (n + 1) L).flatten = conjugator L ++
(List.replicate (n + 1) (reduceCyclically L)).flatten ++ invRev (conjugator L) := by
induction n
case zero =>
simpa [← append_assoc, conj_conjugator_reduceCyclically, ← isReduced_iff_reduce_eq]
case succ n ih =>
rw [replicate_succ, flatten_cons, ← reduce_append_reduce_reduce, ih, h.reduce_eq]
nth_rewrite 1 [← conj_conjugator_reduceCyclically L]
have {L₁ L₂ L₃ L₄ L₅ : List (α × Bool)} : reduce (L₁ ++ L₂ ++ invRev L₃ ++ (L₃ ++ L₄ ++ L₅)) =
reduce (L₁ ++ (L₂ ++ L₄) ++ L₅) := by
apply reduce.sound
repeat rw [← mul_mk]
rw [← inv_mk]
group
rw [this, ← flatten_cons, ← replicate_succ, ← isReduced_iff_reduce_eq]
apply IsReduced.append_flatten_replicate_append (hn := by simp)
· exact isCyclicallyReduced h
· rwa [conj_conjugator_reduceCyclically]
@[to_additive]
theorem reduce_flatten_replicate (h : IsReduced L) (n : ℕ) :
reduce (List.replicate n L).flatten = if n = 0 then [] else conjugator L ++
(List.replicate n (reduceCyclically L)).flatten ++ invRev (conjugator L) :=
match n with
| 0 => by simp
| n + 1 => reduce_flatten_replicate_succ h n
end reduceCyclically
section IsMulTorsionFree
open reduceCyclically
/-- Free groups are torsion-free, i.e., taking powers is injective. Our proof idea is as follows:
if `x ^ n = y ^ n`, then also `x ^ (2 * n) = y ^ (2 * n)`. We then compare the reduced words
representing the powers in terms of the cyclic reductions of `x.toWord` and `y.toWord` using
`reduce_flatten_replicate`. We conclude that the cyclic reductions of `x.toWord` and `y.toWord` must
have the same length, and in fact they have to agree. -/
@[to_additive /-- Free additive groups are torsion free, i.e., scalar multiplication by every
non-zero element `n : ℕ` is injective. See the instance for free groups for an overview over the
proof. -/]
instance : IsMulTorsionFree (FreeGroup α) where
pow_left_injective n hn x y heq := by
classical
let f (a : FreeGroup α) (n : ℕ) : ℕ :=
(conjugator a.toWord).length + (n * (reduceCyclically a.toWord).length +
(conjugator a.toWord).length)
let g (a : FreeGroup α) (k : ℕ) : List (α × Bool) :=
conjugator a.toWord ++ ((replicate k (reduceCyclically a.toWord)).flatten ++
invRev (conjugator a.toWord))
have heq₂ : x ^ (2 * n) = y ^ (2 * n) := by simp_rw [mul_comm, pow_mul, heq]
replace heq : g x n = g y n := by
simpa [toWord_pow, reduce_flatten_replicate, isReduced_toWord, hn] using congr_arg toWord heq
replace heq₂ : g x (2 * n) = g y (2 * n) := by
simpa [toWord_pow, reduce_flatten_replicate, isReduced_toWord, hn] using congr_arg toWord heq₂
have leq : f x n = f y n := by simpa [g] using congr_arg List.length heq
have leq₂ : f x (2 * n) = f y (2 * n) := by simpa [g] using congr_arg List.length heq₂
obtain ⟨hc, heq'⟩ := List.append_inj heq (by grind)
obtain ⟨n, rfl⟩ := Nat.exists_eq_add_one_of_ne_zero hn
have hm : reduceCyclically x.toWord = reduceCyclically y.toWord := by
simp only [replicate_succ, flatten_cons, append_assoc] at heq'
exact (List.append_inj heq' <| mul_left_cancel₀ hn <| by grind).1
have := congr_arg mk <| (conj_conjugator_reduceCyclically x.toWord).symm
rwa [hc, hm, conj_conjugator_reduceCyclically, mk_toWord, mk_toWord] at this
end IsMulTorsionFree
end FreeGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeGroup/Orbit.lean | import Mathlib.GroupTheory.FreeGroup.Reduce
import Mathlib.GroupTheory.GroupAction.Defs
/-!
For any `w : α × Bool`, `FreeGroup.startsWith w` is the set of all elemenents of `FreeGroup α` that
start with `w`.
The main theorem `Orbit.duplicate` proves that applying `w⁻¹` to the orbit of `x` under the action
of `FreeGroup.startsWith w` yields the orbit of `x` under the action of `FreeGroup.startsWith v`
for every `v ≠ w⁻¹` (and the point `x`).
-/
variable {α X : Type*} [DecidableEq α]
namespace FreeGroup
/--
All elements of the free Group that start with a certain letter.
-/
def startsWith (w : α × Bool) := {g : FreeGroup α | (FreeGroup.toWord g)[0]? = some w}
/--
The neutral element is not contained in one of the startsWith sets.
-/
theorem startsWith.ne_one {w : α × Bool} (g : FreeGroup α) (h : g ∈ FreeGroup.startsWith w) :
g ≠ 1 := fun h1 ↦ by simp [h1, startsWith, FreeGroup.toWord_one] at h
@[simp]
lemma startsWith.disjoint_iff_ne {w w' : α × Bool} :
Disjoint (startsWith w) (startsWith w') ↔ w ≠ w' := by
simp_all only [ne_eq, startsWith, Set.disjoint_iff_inter_eq_empty, Set.ext_iff, Set.mem_inter_iff,
Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false, not_and, Option.some.injEq]
exact Iff.intro (fun h ↦ h (mk [w]) (by simp)) (by grind)
lemma startsWith.Injective : @startsWith α _|>.Injective := fun a b h ↦ by
simp only [startsWith, Set.ext_iff, Set.mem_setOf_eq] at h
simpa using h (mk [a])
theorem startsWith_mk_mul {w : α × Bool} (g : FreeGroup α)
(h : ¬ g ∈ startsWith (w.1, !w.2)) : mk [w] * g ∈ startsWith w := by
by_cases hC : 0 < g.toWord.length
· simp only [startsWith, Set.mem_setOf_eq, getElem?_pos, Option.some.injEq,
Prod.eq_iff_fst_eq_snd_eq, not_and, Bool.not_eq_not, toWord_mul, toWord_mk, reduce.cons,
reduce_nil, List.cons_append, List.nil_append, reduce_toWord, hC] at *
rw [show g.toWord = g.toWord.head (by grind) :: g.toWord.tail by grind]
grind
· simp_all [startsWith]
variable [MulAction (FreeGroup α) X]
instance {w : α × Bool} : SMul (startsWith w) X where
smul g x := g.val • x
@[simp]
lemma startsWith.smul_def {w : α × Bool} {g : startsWith w} {x : X} : g • x = g.val • x := by
rfl
/--
Applying `w⁻¹` to the orbit generated by all elements of a free group that start with `w` yields
the orbit generated by all the words that start with every letter except `w⁻¹`
(and the original point).
-/
theorem Orbit.duplicate (x : X) (w : α × Bool) :
{(mk [w])⁻¹ • y | y ∈ MulAction.orbit (startsWith w) x} =
(⋃ v ∈ {z : α × Bool | z ≠ (w.1, !w.2)}, MulAction.orbit (startsWith v) x) ∪ {x} := by
ext i
constructor
· rintro ⟨-, ⟨⟨g, hg⟩, rfl⟩, rfl⟩
set l := g.toWord with hl
have h : (⟨g, hg⟩ : startsWith w) = ⟨mk g.toWord, by simp [g.mk_toWord, hg]⟩ := by
simp [g.mk_toWord]
match l with
| [] => simp [← hl, startsWith] at hg
| [a] =>
simp_rw [h, ← hl, show a = w by simpa [← hl, startsWith] using hg, startsWith.smul_def,
inv_smul_smul]
exact Or.inr rfl
| a :: b :: l =>
have ha : a = w := by simpa [← hl, startsWith] using hg
have h1 := isReduced_cons_cons.mp (hl ▸ isReduced_toWord)
refine Or.inl (Set.mem_biUnion (x := b) (by grind) ?_)
simp_rw [h, ← hl, ha, ← List.singleton_append (l := b :: l), ← mul_mk, startsWith.smul_def,
mul_smul, inv_smul_smul]
exact ⟨⟨mk (b :: l), by simp [startsWith, h1.2.reduce_eq]⟩, rfl⟩
· rintro (⟨-, ⟨w', rfl⟩, -, ⟨hw, rfl⟩, ⟨g, hg⟩, rfl⟩ | rfl)
· exact ⟨mk [w] • g • x, ⟨⟨mk [w] * g, startsWith_mk_mul g
((startsWith.disjoint_iff_ne.mpr hw).notMem_of_mem_left hg)⟩,
mul_smul (mk [w]) g x⟩, inv_smul_smul (mk [w]) (g • x)⟩
· exact ⟨mk [w] • i, ⟨⟨mk [w], rfl⟩, rfl⟩, inv_smul_smul (mk [w]) i⟩
end FreeGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeGroup/GeneratorEquiv.lean | import Mathlib.Algebra.FreeAbelianGroup.Finsupp
import Mathlib.GroupTheory.FreeGroup.IsFreeGroup
import Mathlib.LinearAlgebra.Dimension.StrongRankCondition
/-!
# Isomorphisms between free groups imply equivalences of their generators
-/
noncomputable section
variable {α β G H : Type*}
open IsFreeGroup Module
/-- `A` is a basis of the ℤ-module `FreeAbelianGroup A`. -/
noncomputable def FreeAbelianGroup.basis (α : Type*) : Basis α ℤ (FreeAbelianGroup α) :=
⟨(FreeAbelianGroup.equivFinsupp α).toIntLinearEquiv⟩
/-- Isomorphic free abelian groups (as modules) have equivalent bases. -/
def Equiv.ofFreeAbelianGroupLinearEquiv (e : FreeAbelianGroup α ≃ₗ[ℤ] FreeAbelianGroup β) : α ≃ β :=
let t : Basis α ℤ (FreeAbelianGroup β) := (FreeAbelianGroup.basis α).map e
t.indexEquiv <| FreeAbelianGroup.basis _
/-- Isomorphic free abelian groups (as additive groups) have equivalent bases. -/
def Equiv.ofFreeAbelianGroupEquiv (e : FreeAbelianGroup α ≃+ FreeAbelianGroup β) : α ≃ β :=
.ofFreeAbelianGroupLinearEquiv e.toIntLinearEquiv
/-- Isomorphic free groups have equivalent bases. -/
def Equiv.ofFreeGroupEquiv (e : FreeGroup α ≃* FreeGroup β) : α ≃ β :=
.ofFreeAbelianGroupEquiv (MulEquiv.toAdditive e.abelianizationCongr)
/-- Isomorphic free groups have equivalent bases (`IsFreeGroup` variant). -/
def Equiv.ofIsFreeGroupEquiv [Group G] [Group H] [IsFreeGroup G] [IsFreeGroup H] (e : G ≃* H) :
Generators G ≃ Generators H :=
.ofFreeGroupEquiv <| (toFreeGroup G).symm.trans <| e.trans <| toFreeGroup H |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeGroup/NielsenSchreier.lean | import Mathlib.CategoryTheory.Action
import Mathlib.Combinatorics.Quiver.Arborescence
import Mathlib.Combinatorics.Quiver.ConnectedComponent
import Mathlib.GroupTheory.FreeGroup.IsFreeGroup
/-!
# The Nielsen-Schreier theorem
This file proves that a subgroup of a free group is itself free.
## Main result
- `subgroupIsFreeOfIsFree H`: an instance saying that a subgroup of a free group is free.
## Proof overview
The proof is analogous to the proof using covering spaces and fundamental groups of graphs,
but we work directly with groupoids instead of topological spaces. Under this analogy,
- `IsFreeGroupoid G` corresponds to saying that a space is a graph.
- `endMulEquivSubgroup H` plays the role of replacing 'subgroup of fundamental group' with
'fundamental group of covering space'.
- `actionGroupoidIsFree G A` corresponds to the fact that a covering of a (single-vertex)
graph is a graph.
- `endIsFree T` corresponds to the fact that, given a spanning tree `T` of a
graph, its fundamental group is free (generated by loops from the complement of the tree).
## Implementation notes
Our definition of `IsFreeGroupoid` is nonstandard. Normally one would require that functors
`G ⥤ X` to any _groupoid_ `X` are given by graph homomorphisms from the generators, but we only
consider _groups_ `X`. This simplifies the argument since functor equality is complicated in
general, but simple for functors to single object categories.
## References
https://ncatlab.org/nlab/show/Nielsen-Schreier+theorem
## Tags
free group, free groupoid, Nielsen-Schreier
-/
noncomputable section
universe v u
open CategoryTheory CategoryTheory.ActionCategory CategoryTheory.SingleObj Quiver FreeGroup
/-- `IsFreeGroupoid.Generators G` is a type synonym for `G`. We think of this as
the vertices of the generating quiver of `G` when `G` is free. We can't use `G` directly,
since `G` already has a quiver instance from being a groupoid. -/
@[nolint unusedArguments]
def IsFreeGroupoid.Generators (G) [Groupoid G] :=
G
/--
A groupoid `G` is free when we have the following data:
- a quiver on `IsFreeGroupoid.Generators G` (a type synonym for `G`)
- a function `of` taking a generating arrow to a morphism in `G`
- such that a functor from `G` to any group `X` is uniquely determined
by assigning labels in `X` to the generating arrows.
This definition is nonstandard. Normally one would require that functors `G ⥤ X`
to any _groupoid_ `X` are given by graph homomorphisms from `generators`. -/
class IsFreeGroupoid (G) [Groupoid.{v} G] where
quiverGenerators : Quiver.{v + 1} (IsFreeGroupoid.Generators G)
of : ∀ {a b : IsFreeGroupoid.Generators G}, (a ⟶ b) → ((show G from a) ⟶ b)
unique_lift :
∀ {X : Type v} [Group X] (f : Labelling (IsFreeGroupoid.Generators G) X),
∃! F : G ⥤ CategoryTheory.SingleObj X, ∀ (a b) (g : a ⟶ b), F.map (of g) = f g
attribute [nolint docBlame] IsFreeGroupoid.of IsFreeGroupoid.unique_lift
namespace IsFreeGroupoid
attribute [instance] quiverGenerators
/-- Two functors from a free groupoid to a group are equal when they agree on the generating
quiver. -/
@[ext]
theorem ext_functor {G} [Groupoid.{v} G] [IsFreeGroupoid G] {X : Type v} [Group X]
(f g : G ⥤ CategoryTheory.SingleObj X) (h : ∀ (a b) (e : a ⟶ b), f.map (of e) = g.map (of e)) :
f = g :=
let ⟨_, _, u⟩ := @unique_lift G _ _ X _ fun (a b : Generators G) (e : a ⟶ b) => g.map (of e)
_root_.trans (u _ h) (u _ fun _ _ _ => rfl).symm
/-- An action groupoid over a free group is free. More generally, one could show that the groupoid
of elements over a free groupoid is free, but this version is easier to prove and suffices for our
purposes.
Analogous to the fact that a covering space of a graph is a graph. (A free groupoid is like a graph,
and a groupoid of elements is like a covering space.) -/
instance actionGroupoidIsFree {G A : Type u} [Group G] [IsFreeGroup G] [MulAction G A] :
IsFreeGroupoid (ActionCategory G A) where
quiverGenerators :=
⟨fun a b => { e : IsFreeGroup.Generators G // IsFreeGroup.of e • a.back = b.back }⟩
of := fun (e : Subtype _) => ⟨IsFreeGroup.of e, e.property⟩
unique_lift := by
intro X _ f
let f' : IsFreeGroup.Generators G → (A → X) ⋊[mulAutArrow] G := fun e =>
⟨fun b => @f ⟨(), _⟩ ⟨(), b⟩ ⟨e, smul_inv_smul _ b⟩, IsFreeGroup.of e⟩
rcases IsFreeGroup.unique_lift f' with ⟨F', hF', uF'⟩
refine ⟨uncurry F' ?_, ?_, ?_⟩
· suffices SemidirectProduct.rightHom.comp F' = MonoidHom.id _ by
exact DFunLike.ext_iff.mp this
apply IsFreeGroup.ext_hom (fun x ↦ ?_)
rw [MonoidHom.comp_apply, hF']
rfl
· rintro ⟨⟨⟩, a : A⟩ ⟨⟨⟩, b⟩ ⟨e, h : IsFreeGroup.of e • a = b⟩
change (F' (IsFreeGroup.of _)).left _ = _
rw [hF']
cases inv_smul_eq_iff.mpr h.symm
rfl
· intro E hE
have : curry E = F' := by
apply uF'
intro e
ext
· convert hE _ _ _
rfl
· rfl
apply Functor.hext
· intro
apply Unit.ext
· refine ActionCategory.cases ?_
intros
simp only [← this, uncurry_map, curry_apply_left, coe_back, homOfPair.val]
rfl
namespace SpanningTree
/- In this section, we suppose we have a free groupoid with a spanning tree for its generating
quiver. The goal is to prove that the vertex group at the root is free. A picture to have in mind
is that we are 'pulling' the endpoints of all the edges of the quiver along the spanning tree to
the root. -/
variable {G : Type u} [Groupoid.{u} G] [IsFreeGroupoid G]
(T : WideSubquiver (Symmetrify <| Generators G)) [Arborescence T]
/-- The root of `T`, except its type is `G` instead of the type synonym `T`. -/
private def root' : G :=
show T from root T
-- this has to be marked noncomputable, see issue https://github.com/leanprover-community/mathlib4/pull/451.
-- It might be nicer to define this in terms of `composePath`
/-- A path in the tree gives a hom, by composition. -/
def homOfPath : ∀ {a : G}, Path (root T) a → (root' T ⟶ a)
| _, Path.nil => 𝟙 _
| _, Path.cons p f => homOfPath p ≫ Sum.recOn f.val (fun e => of e) fun e => inv (of e)
/-- For every vertex `a`, there is a canonical hom from the root, given by the path in the tree. -/
def treeHom (a : G) : root' T ⟶ a :=
homOfPath T default
/-- Any path to `a` gives `treeHom T a`, since paths in the tree are unique. -/
theorem treeHom_eq {a : G} (p : Path (root T) a) : treeHom T a = homOfPath T p := by
rw [treeHom, Unique.default_eq]
@[simp]
theorem treeHom_root : treeHom T (root' T) = 𝟙 _ :=
-- this should just be `treeHom_eq T Path.nil`, but Lean treats `homOfPath` with suspicion.
_root_.trans
(treeHom_eq T Path.nil) rfl
/-- Any hom in `G` can be made into a loop, by conjugating with `treeHom`s. -/
def loopOfHom {a b : G} (p : a ⟶ b) : End (root' T) :=
treeHom T a ≫ p ≫ inv (treeHom T b)
/-- Turning an edge in the spanning tree into a loop gives the identity loop. -/
theorem loopOfHom_eq_id {a b : Generators G} (e) (H : e ∈ wideSubquiverSymmetrify T a b) :
loopOfHom T (of e) = 𝟙 (root' T) := by
rw [loopOfHom, ← Category.assoc, IsIso.comp_inv_eq, Category.id_comp]
rcases H with H | H
· rw [treeHom_eq T (Path.cons default ⟨Sum.inl e, H⟩), homOfPath]
rfl
· rw [treeHom_eq T (Path.cons default ⟨Sum.inr e, H⟩), homOfPath]
simp only [IsIso.inv_hom_id, Category.comp_id, Category.assoc, treeHom]
/-- Since a hom gives a loop, any homomorphism from the vertex group at the root
extends to a functor on the whole groupoid. -/
@[simps]
def functorOfMonoidHom {X} [Monoid X] (f : End (root' T) →* X) :
G ⥤ CategoryTheory.SingleObj X where
obj _ := ()
map p := f (loopOfHom T p)
map_id := by
intro a
dsimp only [loopOfHom]
rw [Category.id_comp, IsIso.hom_inv_id, ← End.one_def, f.map_one, id_as_one]
map_comp := by
intros
rw [comp_as_mul, ← f.map_mul]
simp only [IsIso.inv_hom_id_assoc, loopOfHom, End.mul_def, Category.assoc]
open scoped Classical in
/-- Given a free groupoid and an arborescence of its generating quiver, the vertex
group at the root is freely generated by loops coming from generating arrows
in the complement of the tree. -/
lemma endIsFree : IsFreeGroup (End (root' T)) :=
IsFreeGroup.ofUniqueLift ((wideSubquiverEquivSetTotal <| wideSubquiverSymmetrify T)ᶜ : Set _)
(fun e => loopOfHom T (of e.val.hom))
(by
intro X _ f
let f' : Labelling (Generators G) X := fun a b e =>
if h : e ∈ wideSubquiverSymmetrify T a b then 1 else f ⟨⟨a, b, e⟩, h⟩
rcases unique_lift f' with ⟨F', hF', uF'⟩
refine ⟨F'.mapEnd _, ?_, ?_⟩
· suffices ∀ {x y} (q : x ⟶ y), F'.map (loopOfHom T q) = (F'.map q : X) by
rintro ⟨⟨a, b, e⟩, h⟩
-- Work around the defeq `X = End (F'.obj (IsFreeGroupoid.SpanningTree.root' T))`
erw [Functor.mapEnd_apply]
rw [this, hF']
exact dif_neg h
intro x y q
suffices ∀ {a} (p : Path (root T) a), F'.map (homOfPath T p) = 1 by
simp only [this, treeHom, comp_as_mul, inv_as_inv, loopOfHom, inv_one, mul_one,
one_mul, Functor.map_inv, Functor.map_comp]
intro a p
induction p with
| nil => rw [homOfPath, F'.map_id, id_as_one]
| cons p e ih =>
rw [homOfPath, F'.map_comp, comp_as_mul, ih, mul_one]
rcases e with ⟨e | e, eT⟩
· rw [hF']
exact dif_pos (Or.inl eT)
· rw [F'.map_inv, inv_as_inv, inv_eq_one, hF']
exact dif_pos (Or.inr eT)
· intro E hE
ext x
suffices (functorOfMonoidHom T E).map x = F'.map x by
simpa only [loopOfHom, functorOfMonoidHom, IsIso.inv_id, treeHom_root,
Category.id_comp, Category.comp_id] using this
congr
apply uF'
intro a b e
change E (loopOfHom T _) = dite _ _ _
split_ifs with h
· rw [loopOfHom_eq_id T e h, ← End.one_def, E.map_one]
· exact hE ⟨⟨a, b, e⟩, h⟩)
end SpanningTree
/-- Another name for the identity function `G → G`, to help type checking. -/
private def symgen {G : Type u} [Groupoid.{v} G] [IsFreeGroupoid G] :
G → Symmetrify (Generators G) :=
id
/-- If there exists a morphism `a → b` in a free groupoid, then there also exists a zigzag
from `a` to `b` in the generating quiver. -/
theorem path_nonempty_of_hom {G} [Groupoid.{u, u} G] [IsFreeGroupoid G] {a b : G} :
Nonempty (a ⟶ b) → Nonempty (Path (symgen a) (symgen b)) := by
rintro ⟨p⟩
rw [← @WeaklyConnectedComponent.eq (Generators G), eq_comm, ← FreeGroup.of_injective.eq_iff, ←
mul_inv_eq_one]
let X := FreeGroup (WeaklyConnectedComponent <| Generators G)
let f : G → X := fun g => FreeGroup.of (WeaklyConnectedComponent.mk g)
let F : G ⥤ CategoryTheory.SingleObj.{u} (X : Type u) := SingleObj.differenceFunctor f
change (F.map p) = ((@CategoryTheory.Functor.const G _ _ (SingleObj.category X)).obj ()).map p
congr; ext
rw [Functor.const_obj_map, id_as_one, differenceFunctor_map, @mul_inv_eq_one _ _ (f _)]
apply congr_arg FreeGroup.of
apply (WeaklyConnectedComponent.eq _ _).mpr
exact ⟨Hom.toPath (Sum.inr (by assumption))⟩
/-- Given a connected free groupoid, its generating quiver is rooted-connected. -/
instance generators_connected (G) [Groupoid.{u, u} G] [IsConnected G] [IsFreeGroupoid G] (r : G) :
RootedConnected (symgen r) :=
⟨fun b => path_nonempty_of_hom (CategoryTheory.nonempty_hom_of_preconnected_groupoid r b)⟩
/-- A vertex group in a free connected groupoid is free. With some work one could drop the
connectedness assumption, by looking at connected components. -/
instance endIsFreeOfConnectedFree
{G : Type u} [Groupoid G] [IsConnected G] [IsFreeGroupoid G] (r : G) :
IsFreeGroup.{u} (End r) :=
SpanningTree.endIsFree <| geodesicSubtree (symgen r)
end IsFreeGroupoid
/-- The Nielsen-Schreier theorem: a subgroup of a free group is free. -/
instance subgroupIsFreeOfIsFree {G : Type u} [Group G] [IsFreeGroup G] (H : Subgroup G) :
IsFreeGroup H :=
IsFreeGroup.ofMulEquiv (endMulEquivSubgroup H) |
.lake/packages/mathlib/Mathlib/GroupTheory/FreeGroup/Reduce.lean | import Mathlib.Data.Finset.Dedup
import Mathlib.Data.Fintype.Defs
import Mathlib.Data.List.Sublists
import Mathlib.GroupTheory.FreeGroup.Basic
/-!
# The maximal reduction of a word in a free group
## Main declarations
* `FreeGroup.reduce`: the maximal reduction of a word in a free group
* `FreeGroup.norm`: the length of the maximal reduction of a word in a free group
-/
namespace FreeGroup
variable {α : Type*}
variable {L L₁ L₂ L₃ L₄ : List (α × Bool)}
section Reduce
variable [DecidableEq α]
/-- The maximal reduction of a word. It is computable
iff `α` has decidable equality. -/
@[to_additive
/-- The maximal reduction of a word. It is computable iff `α` has decidable equality. -/]
def reduce : (L : List (α × Bool)) -> List (α × Bool) :=
List.rec [] fun hd1 _tl1 ih =>
List.casesOn ih [hd1] fun hd2 tl2 =>
if hd1.1 = hd2.1 ∧ hd1.2 = not hd2.2 then tl2 else hd1 :: hd2 :: tl2
@[to_additive (attr := simp)] lemma reduce_nil : reduce ([] : List (α × Bool)) = [] := rfl
@[to_additive] lemma reduce_singleton (s : α × Bool) : reduce [s] = [s] := rfl
@[to_additive (attr := simp)]
theorem reduce.cons (x) :
reduce (x :: L) =
List.casesOn (reduce L) [x] fun hd tl =>
if x.1 = hd.1 ∧ x.2 = not hd.2 then tl else x :: hd :: tl :=
rfl
@[to_additive (attr := simp)]
theorem reduce_replicate (n : ℕ) (x : α × Bool) :
reduce (.replicate n x) = .replicate n x := by
induction n with
| zero => simp [reduce]
| succ n ih =>
rw [List.replicate_succ, reduce.cons, ih]
cases n with
| zero => simp
| succ n => simp [List.replicate_succ]
/-- The first theorem that characterises the function `reduce`: a word reduces to its maximal
reduction. -/
@[to_additive /-- The first theorem that characterises the function `reduce`: a word reduces to its
maximal reduction. -/]
theorem reduce.red : Red L (reduce L) := by
induction L with
| nil => constructor
| cons hd1 tl1 ih =>
dsimp
revert ih
generalize htl : reduce tl1 = TL
intro ih
cases TL with
| nil => exact Red.cons_cons ih
| cons hd2 tl2 =>
dsimp only
split_ifs with h
· cases hd1
cases hd2
cases h
dsimp at *
subst_vars
apply Red.trans (Red.cons_cons ih)
exact Red.Step.cons_not_rev.to_red
· exact Red.cons_cons ih
@[to_additive]
theorem reduce.not {p : Prop} :
∀ {L₁ L₂ L₃ : List (α × Bool)} {x b}, reduce L₁ = L₂ ++ (x, b) :: (x, !b) :: L₃ → p
| [], L2, L3, _, _ => fun h => by cases L2 <;> injections
| (x, b) :: L1, L2, L3, x', b' => by
dsimp
cases r : reduce L1 with
| nil =>
dsimp; intro h
exfalso
have := congr_arg List.length h
grind
| cons hd tail =>
obtain ⟨y, c⟩ := hd
dsimp only
split_ifs with h <;> intro H
· rw [H] at r
exact @reduce.not _ L1 ((y, c) :: L2) L3 x' b' r
rcases L2 with (_ | ⟨a, L2⟩)
· injections; subst_vars
simp at h
· refine @reduce.not _ L1 L2 L3 x' b' ?_
rw [List.cons_append] at H
injection H with _ H
rw [r, H]
/-- The second theorem that characterises the function `reduce`: the maximal reduction of a word
only reduces to itself. -/
@[to_additive /-- The second theorem that characterises the function `reduce`: the maximal
reduction of a word only reduces to itself. -/]
theorem reduce.min (H : Red (reduce L₁) L₂) : reduce L₁ = L₂ := by
induction H with
| refl => rfl
| tail _ H1 H2 =>
obtain ⟨L4, L5, x, b⟩ := H1
exact reduce.not H2
/-- `reduce` is idempotent, i.e. the maximal reduction of the maximal reduction of a word is the
maximal reduction of the word. -/
@[to_additive (attr := simp) /-- `reduce` is idempotent, i.e. the maximal reduction of the maximal
reduction of a word is the maximal reduction of the word. -/]
theorem reduce.idem : reduce (reduce L) = reduce L :=
Eq.symm <| reduce.min reduce.red
@[to_additive]
theorem reduce.Step.eq (H : Red.Step L₁ L₂) : reduce L₁ = reduce L₂ :=
let ⟨_L₃, HR13, HR23⟩ := Red.church_rosser reduce.red (reduce.red.head H)
(reduce.min HR13).trans (reduce.min HR23).symm
/-- If a word reduces to another word, then they have a common maximal reduction. -/
@[to_additive /-- If a word reduces to another word, then they have a common maximal reduction. -/]
theorem reduce.eq_of_red (H : Red L₁ L₂) : reduce L₁ = reduce L₂ :=
let ⟨_L₃, HR13, HR23⟩ := Red.church_rosser reduce.red (Red.trans H reduce.red)
(reduce.min HR13).trans (reduce.min HR23).symm
alias red.reduce_eq := reduce.eq_of_red
alias freeAddGroup.red.reduce_eq := FreeAddGroup.reduce.eq_of_red
@[to_additive]
theorem Red.reduce_right (h : Red L₁ L₂) : Red L₁ (reduce L₂) :=
reduce.eq_of_red h ▸ reduce.red
@[to_additive]
theorem Red.reduce_left (h : Red L₁ L₂) : Red L₂ (reduce L₁) :=
(reduce.eq_of_red h).symm ▸ reduce.red
/-- If two words correspond to the same element in the free group, then they
have a common maximal reduction. This is the proof that the function that sends
an element of the free group to its maximal reduction is well-defined. -/
@[to_additive /-- If two words correspond to the same element in the additive free group, then they
have a common maximal reduction. This is the proof that the function that sends an element of the
free group to its maximal reduction is well-defined. -/]
theorem reduce.sound (H : mk L₁ = mk L₂) : reduce L₁ = reduce L₂ :=
let ⟨_L₃, H13, H23⟩ := Red.exact.1 H
(reduce.eq_of_red H13).trans (reduce.eq_of_red H23).symm
/-- If two words have a common maximal reduction, then they correspond to the same element in the
free group. -/
@[to_additive /-- If two words have a common maximal reduction, then they correspond to the same
element in the additive free group. -/]
theorem reduce.exact (H : reduce L₁ = reduce L₂) : mk L₁ = mk L₂ :=
Red.exact.2 ⟨reduce L₂, H ▸ reduce.red, reduce.red⟩
/-- A word and its maximal reduction correspond to the same element of the free group. -/
@[to_additive /-- A word and its maximal reduction correspond to the same element of the additive
free group. -/]
theorem reduce.self : mk (reduce L) = mk L :=
reduce.exact reduce.idem
/-- If words `w₁ w₂` are such that `w₁` reduces to `w₂`, then `w₂` reduces to the maximal reduction
of `w₁`. -/
@[to_additive /-- If words `w₁ w₂` are such that `w₁` reduces to `w₂`, then `w₂` reduces to the
maximal reduction of `w₁`. -/]
theorem reduce.rev (H : Red L₁ L₂) : Red L₂ (reduce L₁) :=
(reduce.eq_of_red H).symm ▸ reduce.red
/-- The function that sends an element of the free group to its maximal reduction. -/
@[to_additive /-- The function that sends an element of the additive free group to its maximal
reduction. -/]
def toWord : FreeGroup α → List (α × Bool) :=
Quot.lift reduce fun _L₁ _L₂ H => reduce.Step.eq H
@[to_additive]
theorem mk_toWord : ∀ {x : FreeGroup α}, mk (toWord x) = x := by rintro ⟨L⟩; exact reduce.self
@[to_additive]
theorem toWord_injective : Function.Injective (toWord : FreeGroup α → List (α × Bool)) := by
rintro ⟨L₁⟩ ⟨L₂⟩; exact reduce.exact
@[to_additive (attr := simp)]
theorem toWord_inj {x y : FreeGroup α} : toWord x = toWord y ↔ x = y :=
toWord_injective.eq_iff
@[to_additive (attr := simp)]
theorem toWord_mk : (mk L₁).toWord = reduce L₁ :=
rfl
@[to_additive (attr := simp)]
theorem toWord_of (a : α) : (of a).toWord = [(a, true)] :=
rfl
@[to_additive (attr := simp)]
theorem reduce_toWord : ∀ x : FreeGroup α, reduce (toWord x) = toWord x := by
rintro ⟨L⟩
exact reduce.idem
@[to_additive (attr := simp)]
theorem toWord_one : (1 : FreeGroup α).toWord = [] :=
rfl
@[to_additive]
theorem toWord_mul (x y : FreeGroup α) : toWord (x * y) = reduce (toWord x ++ toWord y) := by
rw [← mk_toWord (x := x), ← mk_toWord (x := y)]
simp
@[to_additive]
theorem toWord_pow (x : FreeGroup α) (n : ℕ) :
toWord (x ^ n) = reduce (List.replicate n x.toWord).flatten := by
rw [← mk_toWord (x := x)]
simp
@[to_additive (attr := simp)]
theorem toWord_of_pow (a : α) (n : ℕ) : (of a ^ n).toWord = List.replicate n (a, true) := by
rw [of, pow_mk, List.flatten_replicate_singleton, toWord]
exact reduce_replicate _ _
@[to_additive (attr := simp)]
theorem toWord_eq_nil_iff {x : FreeGroup α} : x.toWord = [] ↔ x = 1 :=
toWord_injective.eq_iff' toWord_one
@[to_additive]
theorem reduce_invRev {w : List (α × Bool)} : reduce (invRev w) = invRev (reduce w) := by
apply reduce.min
rw [← red_invRev_iff, invRev_invRev]
apply Red.reduce_left
have : Red (invRev (invRev w)) (invRev (reduce (invRev w))) := reduce.red.invRev
rwa [invRev_invRev] at this
@[to_additive (attr := simp)]
theorem toWord_inv (x : FreeGroup α) : x⁻¹.toWord = invRev x.toWord := by
rcases x with ⟨L⟩
rw [quot_mk_eq_mk, inv_mk, toWord_mk, toWord_mk, reduce_invRev]
@[to_additive]
theorem reduce_append_reduce_reduce : reduce (reduce L₁ ++ reduce L₂) = reduce (L₁ ++ L₂) := by
rw [← toWord_mk (L₁ := L₁ ++ L₂), ← mul_mk, toWord_mul, toWord_mk, toWord_mk]
@[to_additive]
theorem reduce_cons_reduce (a : α × Bool) : reduce (a :: reduce L) = reduce (a :: L) := by
simp
@[to_additive]
theorem reduce_invRev_left_cancel : reduce (invRev L ++ L) = [] := by
simp [← toWord_mk, ← mul_mk, ← inv_mk]
open List -- for <+ notation
@[to_additive]
lemma toWord_mul_sublist (x y : FreeGroup α) : (x * y).toWord <+ x.toWord ++ y.toWord := by
refine Red.sublist ?_
have : x * y = FreeGroup.mk (x.toWord ++ y.toWord) := by
rw [← FreeGroup.mul_mk, FreeGroup.mk_toWord, FreeGroup.mk_toWord]
rw [this]
exact FreeGroup.reduce.red
/-- **Constructive Church-Rosser theorem** (compare `FreeGroup.Red.church_rosser`). -/
@[to_additive
/-- **Constructive Church-Rosser theorem** (compare `FreeAddGroup.Red.church_rosser`). -/]
def reduce.churchRosser (H12 : Red L₁ L₂) (H13 : Red L₁ L₃) : { L₄ // Red L₂ L₄ ∧ Red L₃ L₄ } :=
⟨reduce L₁, reduce.rev H12, reduce.rev H13⟩
@[to_additive]
instance : DecidableEq (FreeGroup α) :=
toWord_injective.decidableEq
-- TODO @[to_additive] doesn't succeed, possibly due to a bug
-- FreeGroup.Red.decidableRel and FreeAddGroup.Red.decidableRel do not generate the same number
-- of equation lemmas.
instance Red.decidableRel : DecidableRel (@Red α)
| [], [] => isTrue Red.refl
| [], _hd2 :: _tl2 => isFalse fun H => List.noConfusion (Red.nil_iff.1 H)
| (x, b) :: tl, [] =>
match Red.decidableRel tl [(x, not b)] with
| isTrue H => isTrue <| Red.trans (Red.cons_cons H) <| (@Red.Step.not _ [] [] _ _).to_red
| isFalse H => isFalse fun H2 => H <| Red.cons_nil_iff_singleton.1 H2
| (x1, b1) :: tl1, (x2, b2) :: tl2 =>
if h : (x1, b1) = (x2, b2) then
match Red.decidableRel tl1 tl2 with
| isTrue H => isTrue <| h ▸ Red.cons_cons H
| isFalse H => isFalse fun H2 => H <| (Red.cons_cons_iff _).1 <| h.symm ▸ H2
else
match Red.decidableRel tl1 ((x1, ! b1) :: (x2, b2) :: tl2) with
| isTrue H => isTrue <| (Red.cons_cons H).tail Red.Step.cons_not
| isFalse H => isFalse fun H2 => H <| Red.inv_of_red_of_ne h H2
/-- A list containing every word that `w₁` reduces to. -/
def Red.enum (L₁ : List (α × Bool)) : List (List (α × Bool)) :=
List.filter (Red L₁) (List.sublists L₁)
theorem Red.enum.sound (H : L₂ ∈ List.filter (Red L₁) (List.sublists L₁)) : Red L₁ L₂ :=
of_decide_eq_true (@List.of_mem_filter _ _ L₂ _ H)
theorem Red.enum.complete (H : Red L₁ L₂) : L₂ ∈ Red.enum L₁ :=
List.mem_filter_of_mem (List.mem_sublists.2 <| Red.sublist H) (decide_eq_true H)
instance (L₁ : List (α × Bool)) : Fintype { L₂ // Red L₁ L₂ } :=
Fintype.subtype (List.toFinset <| Red.enum L₁) fun _L₂ =>
⟨fun H => Red.enum.sound <| List.mem_toFinset.1 H, fun H =>
List.mem_toFinset.2 <| Red.enum.complete H⟩
@[to_additive]
theorem IsReduced.reduce_eq (h : IsReduced L) : reduce L = L := by
rw [← h.red_iff_eq]
exact reduce.red
@[to_additive]
theorem IsReduced.of_reduce_eq (h : reduce L = L) : IsReduced L := by
rw [IsReduced, List.isChain_iff_forall_rel_of_append_cons_cons]
rintro ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ l₁ l₂ hl rfl
rw [eq_comm, ← Bool.ne_not]
rintro rfl
exact reduce.not (h.trans hl)
@[to_additive]
theorem isReduced_iff_reduce_eq : IsReduced L ↔ reduce L = L where
mp h := h.reduce_eq
mpr := .of_reduce_eq
@[to_additive]
theorem isReduced_toWord {x : FreeGroup α} : IsReduced x.toWord := by
simp [isReduced_iff_reduce_eq]
end Reduce
@[to_additive (attr := simp)]
theorem one_ne_of (a : α) : 1 ≠ of a :=
letI := Classical.decEq α; ne_of_apply_ne toWord <| by simp
@[to_additive (attr := simp)]
theorem of_ne_one (a : α) : of a ≠ 1 := one_ne_of _ |>.symm
@[to_additive]
instance [Nonempty α] : Nontrivial (FreeGroup α) where
exists_pair_ne := let ⟨x⟩ := ‹Nonempty α›; ⟨1, of x, one_ne_of x⟩
section Metric
variable [DecidableEq α]
/-- The length of reduced words provides a norm on a free group. -/
@[to_additive /-- The length of reduced words provides a norm on an additive free group. -/]
def norm (x : FreeGroup α) : ℕ :=
x.toWord.length
@[to_additive (attr := simp)]
theorem norm_inv_eq {x : FreeGroup α} : norm x⁻¹ = norm x := by
simp only [norm, toWord_inv, invRev_length]
@[to_additive (attr := simp)]
theorem norm_eq_zero {x : FreeGroup α} : norm x = 0 ↔ x = 1 := by
simp only [norm, List.length_eq_zero_iff, toWord_eq_nil_iff]
@[to_additive (attr := simp)]
theorem norm_one : norm (1 : FreeGroup α) = 0 :=
rfl
@[to_additive (attr := simp)]
theorem norm_of (a : α) : norm (of a) = 1 :=
rfl
@[to_additive]
theorem norm_mk_le : norm (mk L₁) ≤ L₁.length :=
reduce.red.length_le
@[to_additive]
theorem norm_mul_le (x y : FreeGroup α) : norm (x * y) ≤ norm x + norm y :=
calc
norm (x * y) = norm (mk (x.toWord ++ y.toWord)) := by rw [← mul_mk, mk_toWord, mk_toWord]
_ ≤ (x.toWord ++ y.toWord).length := norm_mk_le
_ = norm x + norm y := List.length_append
@[to_additive (attr := simp)]
theorem norm_of_pow (a : α) (n : ℕ) : norm (of a ^ n) = n := by
rw [norm, toWord_of_pow, List.length_replicate]
@[to_additive]
theorem norm_surjective [Nonempty α] : Function.Surjective (norm (α := α)) := by
let ⟨a⟩ := ‹Nonempty α›
exact Function.RightInverse.surjective <| norm_of_pow a
end Metric
end FreeGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Subgroup/Saturated.lean | import Mathlib.Algebra.Group.Subgroup.Ker
/-!
# Saturated subgroups
## Tags
subgroup, subgroups
-/
namespace Subgroup
variable {G : Type*} [Group G]
/-- A subgroup `H` of `G` is *saturated* if for all `n : ℕ` and `g : G` with `g^n ∈ H`
we have `n = 0` or `g ∈ H`. -/
@[to_additive
/-- An additive subgroup `H` of `G` is *saturated* if for all `n : ℕ` and `g : G` with `n•g ∈ H` we
have `n = 0` or `g ∈ H`. -/]
def Saturated (H : Subgroup G) : Prop :=
∀ ⦃n g⦄, g ^ n ∈ H → n = 0 ∨ g ∈ H
@[to_additive]
theorem saturated_iff_npow {H : Subgroup G} :
Saturated H ↔ ∀ (n : ℕ) (g : G), g ^ n ∈ H → n = 0 ∨ g ∈ H :=
Iff.rfl
@[to_additive]
theorem saturated_iff_zpow {H : Subgroup G} :
Saturated H ↔ ∀ (n : ℤ) (g : G), g ^ n ∈ H → n = 0 ∨ g ∈ H := by
constructor
· intro hH n g hgn
cases n with
| ofNat n =>
simp only [Int.natCast_eq_zero, Int.ofNat_eq_coe, zpow_natCast] at hgn ⊢
exact hH hgn
| negSucc n =>
suffices g ^ (n + 1) ∈ H by
refine (hH this).imp ?_ id
simp only [IsEmpty.forall_iff, Nat.succ_ne_zero]
simpa only [inv_mem_iff, zpow_negSucc] using hgn
· intro h n g hgn
specialize h n g
simp only [Int.natCast_eq_zero, zpow_natCast] at h
apply h hgn
end Subgroup
namespace AddSubgroup
theorem ker_saturated {A₁ A₂ : Type*} [AddGroup A₁] [AddMonoid A₂] [IsAddTorsionFree A₂]
(f : A₁ →+ A₂) : f.ker.Saturated := by simp +contextual [Saturated, or_imp]
end AddSubgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Subgroup/Center.lean | import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.GroupTheory.Submonoid.Center
/-!
# Centers of subgroups
-/
assert_not_exists MonoidWithZero Multiset
variable {G : Type*} [Group G]
namespace Subgroup
variable (G)
/-- The center of a group `G` is the set of elements that commute with everything in `G` -/
@[to_additive
/-- The center of an additive group `G` is the set of elements that commute with
everything in `G` -/]
def center : Subgroup G :=
{ Submonoid.center G with
carrier := Set.center G
inv_mem' := Set.inv_mem_center }
@[to_additive]
theorem coe_center : ↑(center G) = Set.center G :=
rfl
@[to_additive (attr := simp)]
theorem center_toSubmonoid : (center G).toSubmonoid = Submonoid.center G :=
rfl
instance center.isMulCommutative : IsMulCommutative (center G) :=
⟨⟨fun a b => Subtype.ext (b.2.comm a).symm⟩⟩
variable {G} in
/-- The center of isomorphic groups are isomorphic. -/
@[to_additive (attr := simps!) /-- The center of isomorphic additive groups are isomorphic. -/]
def centerCongr {H} [Group H] (e : G ≃* H) : center G ≃* center H := Submonoid.centerCongr e
/-- The center of a group is isomorphic to the center of its opposite. -/
@[to_additive (attr := simps!)
/-- The center of an additive group is isomorphic to the center of its opposite. -/]
def centerToMulOpposite : center G ≃* center Gᵐᵒᵖ := Submonoid.centerToMulOpposite
variable {G}
@[to_additive]
theorem mem_center_iff {z : G} : z ∈ center G ↔ ∀ g, g * z = z * g := by
rw [← Semigroup.mem_center_iff]
exact Iff.rfl
instance decidableMemCenter (z : G) [Decidable (∀ g, g * z = z * g)] : Decidable (z ∈ center G) :=
decidable_of_iff' _ mem_center_iff
@[to_additive]
instance centerCharacteristic : (center G).Characteristic := by
refine characteristic_iff_comap_le.mpr fun ϕ g hg => ?_
rw [mem_center_iff]
intro h
rw [← ϕ.injective.eq_iff, map_mul, map_mul]
exact (hg.comm (ϕ h)).symm
theorem _root_.CommGroup.center_eq_top {G : Type*} [CommGroup G] : center G = ⊤ := by
rw [eq_top_iff']
intro x
rw [Subgroup.mem_center_iff]
intro y
exact mul_comm y x
/-- A group is commutative if the center is the whole group -/
def _root_.Group.commGroupOfCenterEqTop (h : center G = ⊤) : CommGroup G :=
{ ‹Group G› with
mul_comm := by
rw [eq_top_iff'] at h
intro x y
apply Subgroup.mem_center_iff.mp _ x
exact h y
}
variable {H : Subgroup G}
section Normalizer
@[to_additive]
instance instNormalCenter : (center G).Normal :=
⟨fun a ha b ↦ by simp [mul_assoc, mem_center_iff.mp ha b, ha]⟩
@[to_additive]
theorem center_le_normalizer : center G ≤ H.normalizer := fun x hx y => by
simp [← mem_center_iff.mp hx y, mul_assoc]
end Normalizer
end Subgroup
namespace IsConj
variable {M : Type*} [Monoid M]
theorem eq_of_left_mem_center {g h : M} (H : IsConj g h) (Hg : g ∈ Set.center M) : g = h := by
rcases H with ⟨u, hu⟩; rwa [← u.mul_left_inj, Hg.comm u]
theorem eq_of_right_mem_center {g h : M} (H : IsConj g h) (Hh : h ∈ Set.center M) : g = h :=
(H.symm.eq_of_left_mem_center Hh).symm
end IsConj
namespace ConjClasses
theorem mk_bijOn (G : Type*) [Group G] :
Set.BijOn ConjClasses.mk (↑(Subgroup.center G)) (noncenter G)ᶜ := by
refine ⟨fun g hg ↦ ?_, fun x hx y _ H ↦ ?_, ?_⟩
· simp only [mem_noncenter, Set.compl_def, Set.mem_setOf, Set.not_nontrivial_iff]
intro x hx y hy
simp only [mem_carrier_iff_mk_eq, mk_eq_mk_iff_isConj] at hx hy
rw [hx.eq_of_right_mem_center hg, hy.eq_of_right_mem_center hg]
· rw [mk_eq_mk_iff_isConj] at H
exact H.eq_of_left_mem_center hx
· rintro ⟨g⟩ hg
refine ⟨g, ?_, rfl⟩
simp only [mem_noncenter, Set.compl_def, Set.mem_setOf, Set.not_nontrivial_iff] at hg
rw [SetLike.mem_coe, Subgroup.mem_center_iff]
intro h
rw [← mul_inv_eq_iff_eq_mul]
refine hg ?_ mem_carrier_mk
rw [mem_carrier_iff_mk_eq]
apply mk_eq_mk_iff_isConj.mpr
rw [isConj_comm, isConj_iff]
exact ⟨h, rfl⟩
end ConjClasses |
.lake/packages/mathlib/Mathlib/GroupTheory/Subgroup/Simple.lean | import Mathlib.Order.Atoms
import Mathlib.Algebra.Group.Subgroup.Basic
/-!
# Simple groups
This file defines `IsSimpleGroup G`, a class indicating that a group has exactly two normal
subgroups.
## Main definitions
- `IsSimpleGroup G`, a class indicating that a group has exactly two normal subgroups.
## Tags
subgroup, subgroups
-/
variable {G : Type*} [Group G]
variable {A : Type*} [AddGroup A]
section
variable (G) (A)
/-- A `Group` is simple when it has exactly two normal `Subgroup`s. -/
@[mk_iff]
class IsSimpleGroup : Prop extends Nontrivial G where
/-- Any normal subgroup is either `⊥` or `⊤` -/
eq_bot_or_eq_top_of_normal : ∀ H : Subgroup G, H.Normal → H = ⊥ ∨ H = ⊤
/-- An `AddGroup` is simple when it has exactly two normal `AddSubgroup`s. -/
@[mk_iff]
class IsSimpleAddGroup : Prop extends Nontrivial A where
/-- Any normal additive subgroup is either `⊥` or `⊤` -/
eq_bot_or_eq_top_of_normal : ∀ H : AddSubgroup A, H.Normal → H = ⊥ ∨ H = ⊤
attribute [to_additive existing] IsSimpleGroup isSimpleGroup_iff
variable {G} {A}
@[to_additive]
theorem Subgroup.Normal.eq_bot_or_eq_top [IsSimpleGroup G] {H : Subgroup G} (Hn : H.Normal) :
H = ⊥ ∨ H = ⊤ :=
IsSimpleGroup.eq_bot_or_eq_top_of_normal H Hn
@[to_additive]
protected lemma Subgroup.isSimpleGroup_iff {H : Subgroup G} :
IsSimpleGroup ↥H ↔ H ≠ ⊥ ∧ ∀ H' ≤ H, (H'.subgroupOf H).Normal → H' = ⊥ ∨ H' = H := by
rw [isSimpleGroup_iff, H.nontrivial_iff_ne_bot, Subgroup.forall]
simp +contextual [disjoint_of_le_iff_left_eq_bot, LE.le.ge_iff_eq]
namespace IsSimpleGroup
@[to_additive]
instance {C : Type*} [CommGroup C] [IsSimpleGroup C] : IsSimpleOrder (Subgroup C) :=
⟨fun H => H.normal_of_comm.eq_bot_or_eq_top⟩
open Subgroup
@[to_additive]
theorem isSimpleGroup_of_surjective {H : Type*} [Group H] [IsSimpleGroup G] [Nontrivial H]
(f : G →* H) (hf : Function.Surjective f) : IsSimpleGroup H :=
⟨fun H iH => by
refine (iH.comap f).eq_bot_or_eq_top.imp (fun h => ?_) fun h => ?_
· rw [← map_bot f, ← h, map_comap_eq_self_of_surjective hf]
· rw [← comap_top f] at h
exact comap_injective hf h⟩
@[to_additive]
lemma _root_.MulEquiv.isSimpleGroup {H : Type*} [Group H] [IsSimpleGroup H] (e : G ≃* H) :
IsSimpleGroup G :=
haveI : Nontrivial G := e.toEquiv.nontrivial
isSimpleGroup_of_surjective e.symm.toMonoidHom e.symm.surjective
@[to_additive]
lemma _root_.MulEquiv.isSimpleGroup_congr {H : Type*} [Group H] (e : G ≃* H) :
IsSimpleGroup G ↔ IsSimpleGroup H where
mp _ := e.symm.isSimpleGroup
mpr _ := e.isSimpleGroup
end IsSimpleGroup
end |
.lake/packages/mathlib/Mathlib/GroupTheory/Subgroup/Centralizer.lean | import Mathlib.Algebra.Group.Action.End
import Mathlib.GroupTheory.Subgroup.Center
import Mathlib.GroupTheory.Submonoid.Centralizer
/-!
# Centralizers of subgroups
-/
assert_not_exists MonoidWithZero
variable {G G' : Type*} [Group G] [Group G']
namespace Subgroup
variable {H K : Subgroup G}
/-- The `centralizer` of `s` is the subgroup of `g : G` commuting with every `h : s`. -/
@[to_additive
/-- The `centralizer` of `s` is the additive subgroup of `g : G` commuting with every `h : s`. -/]
def centralizer (s : Set G) : Subgroup G :=
{ Submonoid.centralizer s with
carrier := Set.centralizer s
inv_mem' := Set.inv_mem_centralizer }
@[to_additive]
theorem mem_centralizer_iff {g : G} {s : Set G} : g ∈ centralizer s ↔ ∀ h ∈ s, h * g = g * h :=
Iff.rfl
@[to_additive]
theorem mem_centralizer_iff_commutator_eq_one {g : G} {s : Set G} :
g ∈ centralizer s ↔ ∀ h ∈ s, h * g * h⁻¹ * g⁻¹ = 1 := by
simp only [mem_centralizer_iff, mul_inv_eq_iff_eq_mul, one_mul]
@[to_additive]
lemma mem_centralizer_singleton_iff {g k : G} :
k ∈ Subgroup.centralizer {g} ↔ k * g = g * k := by
simp only [mem_centralizer_iff, Set.mem_singleton_iff, forall_eq]
exact eq_comm
@[to_additive]
theorem centralizer_univ : centralizer Set.univ = center G :=
SetLike.ext' (Set.centralizer_univ G)
@[to_additive]
theorem le_centralizer_iff : H ≤ centralizer K ↔ K ≤ centralizer H :=
⟨fun h x hx _y hy => (h hy x hx).symm, fun h x hx _y hy => (h hy x hx).symm⟩
@[to_additive]
theorem center_le_centralizer (s) : center G ≤ centralizer s :=
Set.center_subset_centralizer s
@[to_additive]
theorem centralizer_le {s t : Set G} (h : s ⊆ t) : centralizer t ≤ centralizer s :=
Submonoid.centralizer_le h
@[to_additive (attr := simp)]
theorem centralizer_eq_top_iff_subset {s : Set G} : centralizer s = ⊤ ↔ s ⊆ center G :=
SetLike.ext'_iff.trans Set.centralizer_eq_top_iff_subset
@[to_additive]
theorem map_centralizer_le_centralizer_image (s : Set G) (f : G →* G') :
(Subgroup.centralizer s).map f ≤ Subgroup.centralizer (f '' s) := by
rintro - ⟨g, hg, rfl⟩ - ⟨h, hh, rfl⟩
rw [← map_mul, ← map_mul, hg h hh]
@[to_additive]
instance normal_centralizer [H.Normal] : (centralizer H : Subgroup G).Normal where
conj_mem g hg i h hh := by
simpa [-mul_left_inj, -mul_right_inj, mul_assoc]
using congr(i * $(hg _ <| ‹H.Normal›.conj_mem _ hh i⁻¹) * i⁻¹)
@[to_additive]
instance characteristic_centralizer [hH : H.Characteristic] :
(centralizer (H : Set G)).Characteristic := by
refine Subgroup.characteristic_iff_comap_le.mpr fun ϕ g hg h hh => ϕ.injective ?_
rw [map_mul, map_mul]
exact hg (ϕ h) (Subgroup.characteristic_iff_le_comap.mp hH ϕ hh)
@[to_additive]
theorem le_centralizer_iff_isMulCommutative : K ≤ centralizer K ↔ IsMulCommutative K :=
⟨fun h => ⟨⟨fun x y => Subtype.ext (h y.2 x x.2)⟩⟩,
fun h x hx y hy => congr_arg Subtype.val (h.1.1 ⟨y, hy⟩ ⟨x, hx⟩)⟩
variable (H)
@[to_additive]
theorem le_centralizer [h : IsMulCommutative H] : H ≤ centralizer H :=
le_centralizer_iff_isMulCommutative.mpr h
variable {H} in
@[to_additive]
lemma closure_le_centralizer_centralizer (s : Set G) :
closure s ≤ centralizer (centralizer s) :=
closure_le _ |>.mpr Set.subset_centralizer_centralizer
/-- If all the elements of a set `s` commute, then `closure s` is a commutative group. -/
@[to_additive
/-- If all the elements of a set `s` commute, then `closure s` is an additive commutative group. -/]
abbrev closureCommGroupOfComm {k : Set G} (hcomm : ∀ x ∈ k, ∀ y ∈ k, x * y = y * x) :
CommGroup (closure k) :=
{ (closure k).toGroup with
mul_comm := fun ⟨_, h₁⟩ ⟨_, h₂⟩ ↦
have := closure_le_centralizer_centralizer k
Subtype.ext <| Set.centralizer_centralizer_comm_of_comm hcomm _ (this h₁) _ (this h₂) }
/-- The conjugation action of N(H) on H. -/
@[simps]
instance : MulDistribMulAction H.normalizer H where
smul g h := ⟨g * h * g⁻¹, (g.2 h).mp h.2⟩
one_smul g := by simp [HSMul.hSMul]
mul_smul := by simp [HSMul.hSMul, mul_assoc]
smul_one := by simp [HSMul.hSMul]
smul_mul := by simp [HSMul.hSMul]
/-- The homomorphism N(H) → Aut(H) with kernel C(H). -/
@[simps!]
def normalizerMonoidHom : H.normalizer →* MulAut H :=
MulDistribMulAction.toMulAut H.normalizer H
theorem normalizerMonoidHom_ker :
H.normalizerMonoidHom.ker = (Subgroup.centralizer H).subgroupOf H.normalizer := by
simp [Subgroup.ext_iff, DFunLike.ext_iff, Subtype.ext_iff,
mem_subgroupOf, mem_centralizer_iff, eq_mul_inv_iff_mul_eq, eq_comm]
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Subsemigroup/Center.lean | import Mathlib.Algebra.Group.Center
import Mathlib.Algebra.Group.Subsemigroup.Defs
/-!
# Centers of semigroups, as subsemigroups.
## Main definitions
* `Subsemigroup.center`: the center of a semigroup
* `AddSubsemigroup.center`: the center of an additive semigroup
We provide `Submonoid.center`, `AddSubmonoid.center`, `Subgroup.center`, `AddSubgroup.center`,
`Subsemiring.center`, and `Subring.center` in other files.
## References
* [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1]
[cabreragarciarodriguezpalacios2014]
-/
assert_not_exists RelIso Finset
/-! ### `Set.center` as a `Subsemigroup`. -/
variable (M)
namespace Subsemigroup
section Mul
variable [Mul M]
/-- The center of a semigroup `M` is the set of elements that commute with everything in `M` -/
@[to_additive /-- The center of an additive semigroup `M` is the set of elements that commute with
everything in `M` -/]
def center : Subsemigroup M where
carrier := Set.center M
mul_mem' := Set.mul_mem_center
variable {M}
/-- The center of a magma is commutative and associative. -/
@[to_additive /-- The center of an additive magma is commutative and associative. -/]
instance center.commSemigroup : CommSemigroup (center M) where
mul_assoc _ b _ := Subtype.ext <| b.2.mid_assoc _ _
mul_comm a _ := Subtype.ext <| a.2.comm _
end Mul
section Semigroup
variable {M} [Semigroup M]
@[to_additive]
theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g := by
rw [← Semigroup.mem_center_iff]
exact Iff.rfl
@[to_additive]
instance decidableMemCenter (a) [Decidable <| ∀ b : M, b * a = a * b] :
Decidable (a ∈ center M) :=
decidable_of_iff' _ Semigroup.mem_center_iff
end Semigroup
section CommSemigroup
variable [CommSemigroup M]
@[to_additive (attr := simp)]
theorem center_eq_top : center M = ⊤ :=
SetLike.coe_injective (Set.center_eq_univ M)
end CommSemigroup
end Subsemigroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Subsemigroup/Centralizer.lean | import Mathlib.Algebra.Group.Center
import Mathlib.Algebra.Group.Subsemigroup.Basic
import Mathlib.GroupTheory.Subsemigroup.Center
/-!
# Centralizers in semigroups, as subsemigroups.
## Main definitions
* `Subsemigroup.centralizer`: the centralizer of a subset of a semigroup
* `AddSubsemigroup.centralizer`: the centralizer of a subset of an additive semigroup
We provide `Monoid.centralizer`, `AddMonoid.centralizer`, `Subgroup.centralizer`, and
`AddSubgroup.centralizer` in other files.
-/
-- Guard against import creep
assert_not_exists Finset
variable {M : Type*} {S T : Set M}
namespace Subsemigroup
section
variable [Semigroup M] (S)
/-- The centralizer of a subset of a semigroup `M`. -/
@[to_additive /-- The centralizer of a subset of an additive semigroup. -/]
def centralizer : Subsemigroup M where
carrier := S.centralizer
mul_mem' := Set.mul_mem_centralizer
@[to_additive (attr := simp, norm_cast)]
theorem coe_centralizer : ↑(centralizer S) = S.centralizer :=
rfl
variable {S}
@[to_additive]
theorem mem_centralizer_iff {z : M} : z ∈ centralizer S ↔ ∀ g ∈ S, g * z = z * g :=
Iff.rfl
@[to_additive]
instance decidableMemCentralizer (a) [Decidable <| ∀ b ∈ S, b * a = a * b] :
Decidable (a ∈ centralizer S) :=
decidable_of_iff' _ mem_centralizer_iff
@[to_additive]
theorem center_le_centralizer (S) : center M ≤ centralizer S :=
S.center_subset_centralizer
@[to_additive]
theorem centralizer_le (h : S ⊆ T) : centralizer T ≤ centralizer S :=
Set.centralizer_subset h
@[to_additive (attr := simp)]
theorem centralizer_eq_top_iff_subset {s : Set M} : centralizer s = ⊤ ↔ s ⊆ center M :=
SetLike.ext'_iff.trans Set.centralizer_eq_top_iff_subset
variable (M)
@[to_additive (attr := simp)]
theorem centralizer_univ : centralizer Set.univ = center M :=
SetLike.ext' (Set.centralizer_univ M)
variable {M} in
@[to_additive]
lemma closure_le_centralizer_centralizer (s : Set M) :
closure s ≤ centralizer (centralizer s) :=
closure_le.mpr Set.subset_centralizer_centralizer
/-- If all the elements of a set `s` commute, then `closure s` is a commutative semigroup. -/
@[to_additive
/-- If all the elements of a set `s` commute, then `closure s` forms an additive
commutative semigroup. -/]
abbrev closureCommSemigroupOfComm {s : Set M} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) :
CommSemigroup (closure s) :=
{ MulMemClass.toSemigroup (closure s) with
mul_comm := fun ⟨_, h₁⟩ ⟨_, h₂⟩ ↦
have := closure_le_centralizer_centralizer s
Subtype.ext <| Set.centralizer_centralizer_comm_of_comm hcomm _ (this h₁) _ (this h₂) }
end
end Subsemigroup |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/MooreComplex.lean | import Mathlib.Algebra.Homology.HomologicalComplex
import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.CategoryTheory.Abelian.Basic
/-!
## Moore complex
We construct the normalized Moore complex, as a functor
`SimplicialObject C ⥤ ChainComplex C ℕ`,
for any abelian category `C`.
The `n`-th object is intersection of
the kernels of `X.δ i : X.obj n ⟶ X.obj (n-1)`, for `i = 1, ..., n`.
The differentials are induced from `X.δ 0`,
which maps each of these intersections of kernels to the next.
This functor is one direction of the Dold-Kan equivalence, which we're still working towards.
### References
* https://stacks.math.columbia.edu/tag/0194
* https://ncatlab.org/nlab/show/Moore+complex
-/
universe v u
noncomputable section
open CategoryTheory CategoryTheory.Limits
open Opposite
open scoped Simplicial
namespace AlgebraicTopology
variable {C : Type*} [Category C] [Abelian C]
attribute [local instance] Abelian.hasPullbacks
/-! The definitions in this namespace are all auxiliary definitions for `NormalizedMooreComplex`
and should usually only be accessed via that. -/
namespace NormalizedMooreComplex
open CategoryTheory.Subobject
variable (X : SimplicialObject C)
/-- The normalized Moore complex in degree `n`, as a subobject of `X n`.
-/
def objX : ∀ n : ℕ, Subobject (X.obj (op ⦋n⦌))
| 0 => ⊤
| n + 1 => Finset.univ.inf fun k : Fin (n + 1) => kernelSubobject (X.δ k.succ)
@[simp] theorem objX_zero : objX X 0 = ⊤ :=
rfl
@[simp] theorem objX_add_one (n) :
objX X (n + 1) = Finset.univ.inf fun k : Fin (n + 1) => kernelSubobject (X.δ k.succ) :=
rfl
/-- The differentials in the normalized Moore complex.
-/
@[simp]
def objD : ∀ n : ℕ, (objX X (n + 1) : C) ⟶ (objX X n : C)
| 0 => Subobject.arrow _ ≫ X.δ (0 : Fin 2) ≫ inv (⊤ : Subobject _).arrow
| n + 1 => by
-- The differential is `Subobject.arrow _ ≫ X.δ (0 : Fin (n+3))`,
-- factored through the intersection of the kernels.
refine factorThru _ (arrow _ ≫ X.δ (0 : Fin (n + 3))) ?_
-- We now need to show that it factors!
-- A morphism factors through an intersection of subobjects if it factors through each.
refine (finset_inf_factors _).mpr fun i _ => ?_
-- A morphism `f` factors through the kernel of `g` exactly if `f ≫ g = 0`.
apply kernelSubobject_factors
dsimp [objX]
-- Use a simplicial identity
rw [Category.assoc, ← Fin.castSucc_zero, ← X.δ_comp_δ (Fin.zero_le i.succ)]
-- We can rewrite the arrow out of the intersection of all the kernels as a composition
-- of a morphism we don't care about with the arrow out of the kernel of `X.δ i.succ.succ`.
rw [← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ i.succ (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by
-- It's a pity we need to do a case split here;
-- after the first rw the proofs are almost identical
rcases n with _ | n <;> dsimp [objD]
· rw [Subobject.factorThru_arrow_assoc, Category.assoc, ← Fin.castSucc_zero,
← X.δ_comp_δ_assoc (Fin.zero_le (0 : Fin 2)),
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ (0 : Fin 2) (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
· rw [factorThru_right, factorThru_eq_zero, factorThru_arrow_assoc, Category.assoc,
← Fin.castSucc_zero,
← X.δ_comp_δ (Fin.zero_le (0 : Fin (n + 3))),
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ (0 : Fin (n + 3)) (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
/-- The normalized Moore complex functor, on objects.
-/
@[simps!]
def obj (X : SimplicialObject C) : ChainComplex C ℕ :=
ChainComplex.of (fun n => (objX X n : C))
(-- the coercion here picks a representative of the subobject
objD X) (d_squared X)
variable {X} {Y : SimplicialObject C} (f : X ⟶ Y)
/-- The normalized Moore complex functor, on morphisms.
-/
@[simps!]
def map (f : X ⟶ Y) : obj X ⟶ obj Y :=
ChainComplex.ofHom _ _ _ _ _ _
(fun n => factorThru _ (arrow _ ≫ f.app (op ⦋n⦌)) (by
cases n <;> dsimp
· apply top_factors
· refine (finset_inf_factors _).mpr fun i _ => kernelSubobject_factors _ _ ?_
rw [Category.assoc, SimplicialObject.δ, ← f.naturality,
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ i (by simp)),
Category.assoc]
erw [kernelSubobject_arrow_comp_assoc]
rw [zero_comp, comp_zero]))
fun n => by
cases n <;> dsimp [objD, objX] <;> cat_disch
end NormalizedMooreComplex
open NormalizedMooreComplex
variable (C) in
/-- The (normalized) Moore complex of a simplicial object `X` in an abelian category `C`.
The `n`-th object is intersection of
the kernels of `X.δ i : X.obj n ⟶ X.obj (n-1)`, for `i = 1, ..., n`.
The differentials are induced from `X.δ 0`,
which maps each of these intersections of kernels to the next.
-/
@[simps]
def normalizedMooreComplex : SimplicialObject C ⥤ ChainComplex C ℕ where
obj := obj
map f := map f
-- Not `@[simp]` as `simp` can prove this.
theorem normalizedMooreComplex_objD (X : SimplicialObject C) (n : ℕ) :
((normalizedMooreComplex C).obj X).d (n + 1) n = NormalizedMooreComplex.objD X n :=
ChainComplex.of_d _ _ (d_squared X) n
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/TopologicalSimplex.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.Analysis.Convex.StdSimplex
import Mathlib.Topology.Category.TopCat.ULift
/-!
# Topological simplices
We define the natural functor from `SimplexCategory` to `TopCat` sending `⦋n⦌` to the
topological `n`-simplex.
This is used to define `TopCat.toSSet` in `AlgebraicTopology.SingularSet`.
-/
universe u
open CategoryTheory Simplicial
namespace SimplexCategory
attribute [local simp] stdSimplex.map_comp_apply in
/-- The functor `SimplexCategory ⥤ TopCat.{0}`
associating the topological `n`-simplex to `⦋n⦌ : SimplexCategory`. -/
@[simps obj map]
noncomputable def toTop₀ : CosimplicialObject TopCat.{0} where
obj n := TopCat.of (stdSimplex ℝ (Fin (n.len + 1)))
map f := TopCat.ofHom ⟨_, stdSimplex.continuous_map f⟩
/-- The functor `SimplexCategory ⥤ TopCat.{u}`
associating the topological `n`-simplex to `⦋n⦌ : SimplexCategory`. -/
@[simps! obj map, pp_with_univ]
noncomputable def toTop : SimplexCategory ⥤ TopCat.{u} :=
toTop₀ ⋙ TopCat.uliftFunctor
instance (n : SimplexCategory) : Nonempty (toTop₀.obj n) := by dsimp; infer_instance
instance (n : SimplexCategory) : Nonempty (toTop.{u}.obj n) := inferInstanceAs (Nonempty (ULift _))
instance : Unique (toTop₀.obj ⦋0⦌) := inferInstanceAs (Unique (stdSimplex ℝ (Fin 1)))
instance : Unique (toTop.{u}.obj ⦋0⦌) := inferInstanceAs (Unique (ULift _))
instance (n : SimplexCategory) : PathConnectedSpace (toTop₀.obj n) := by dsimp; infer_instance
instance (n : SimplexCategory) : PathConnectedSpace (toTop.{u}.obj n) :=
ULift.up_surjective.pathConnectedSpace continuous_uliftUp
@[deprecated (since := "2025-08-25")] alias toTopObj := toTop₀
@[deprecated (since := "2025-08-25")] alias toTopObj.ext := stdSimplex.ext
@[deprecated (since := "2025-08-25")] alias toTopObj_zero_apply_zero := stdSimplex.eq_one_of_unique
@[deprecated (since := "2025-08-25")] alias toTopObj_one_add_eq_one := stdSimplex.add_eq_one
@[deprecated (since := "2025-08-25")] alias toTopObj_one_coe_add_coe_eq_one := stdSimplex.add_eq_one
@[deprecated (since := "2025-08-25")] alias toTopObjOneHomeo := stdSimplexHomeomorphUnitInterval
@[deprecated (since := "2025-08-25")] alias toTopMap := toTop₀
@[deprecated (since := "2025-08-25")] alias coe_toTopMap := FunOnFinite.linearMap_apply_apply
@[deprecated (since := "2025-08-25")] alias continuous_toTopMap := stdSimplex.continuous_map
end SimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/AlternatingFaceMapComplex.lean | import Mathlib.Algebra.Homology.Additive
import Mathlib.AlgebraicTopology.MooreComplex
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.CategoryTheory.Preadditive.Opposite
import Mathlib.CategoryTheory.Idempotents.FunctorCategories
/-!
# The alternating face map complex of a simplicial object in a preadditive category
We construct the alternating face map complex, as a
functor `alternatingFaceMapComplex : SimplicialObject C ⥤ ChainComplex C ℕ`
for any preadditive category `C`. For any simplicial object `X` in `C`,
this is the homological complex `... → X_2 → X_1 → X_0`
where the differentials are alternating sums of faces.
The dual version `alternatingCofaceMapComplex : CosimplicialObject C ⥤ CochainComplex C ℕ`
is also constructed.
We also construct the natural transformation
`inclusionOfMooreComplex : normalizedMooreComplex A ⟶ alternatingFaceMapComplex A`
when `A` is an abelian category.
## References
* https://stacks.math.columbia.edu/tag/0194
* https://ncatlab.org/nlab/show/Moore+complex
-/
open CategoryTheory CategoryTheory.Limits CategoryTheory.Subobject
open CategoryTheory.Preadditive CategoryTheory.Category CategoryTheory.Idempotents
open Opposite
open Simplicial
noncomputable section
namespace AlgebraicTopology
namespace AlternatingFaceMapComplex
/-!
## Construction of the alternating face map complex
-/
variable {C : Type*} [Category C] [Preadditive C]
variable (X : SimplicialObject C)
variable (Y : SimplicialObject C)
/-- The differential on the alternating face map complex is the alternate
sum of the face maps -/
@[simp]
def objD (n : ℕ) : X _⦋n + 1⦌ ⟶ X _⦋n⦌ :=
∑ i : Fin (n + 2), (-1 : ℤ) ^ (i : ℕ) • X.δ i
/-!
## The chain complex relation `d ≫ d`
-/
theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by
-- we start by expanding d ≫ d as a double sum
dsimp
simp only [comp_sum, sum_comp, ← Finset.sum_product']
-- then, we decompose the index set P into a subset S and its complement Sᶜ
let P := Fin (n + 2) × Fin (n + 3)
let S : Finset P := {ij : P | (ij.2 : ℕ) ≤ (ij.1 : ℕ)}
rw [Finset.univ_product_univ, ← Finset.sum_add_sum_compl S, ← eq_neg_iff_add_eq_zero,
← Finset.sum_neg_distrib]
/- we are reduced to showing that two sums are equal, and this is obtained
by constructing a bijection φ : S -> Sᶜ, which maps (i,j) to (j,i+1),
and by comparing the terms -/
let φ : ∀ ij : P, ij ∈ S → P := fun ij hij =>
(Fin.castLT ij.2 (lt_of_le_of_lt (Finset.mem_filter.mp hij).right (Fin.is_lt ij.1)), ij.1.succ)
apply Finset.sum_bij φ
· -- φ(S) is contained in Sᶜ
intro ij hij
simp_rw [S, φ, Finset.compl_filter, Finset.mem_filter_univ, Fin.val_succ,
Fin.coe_castLT] at hij ⊢
cutsat
· -- φ : S → Sᶜ is injective
rintro ⟨i, j⟩ hij ⟨i', j'⟩ hij' h
rw [Prod.mk_inj]
exact ⟨by simpa [φ] using congr_arg Prod.snd h,
by simpa [φ, Fin.castSucc_castLT] using congr_arg Fin.castSucc (congr_arg Prod.fst h)⟩
· -- φ : S → Sᶜ is surjective
rintro ⟨i', j'⟩ hij'
simp_rw [S, Finset.compl_filter, Finset.mem_filter_univ, not_le] at hij'
refine ⟨(j'.pred <| ?_, Fin.castSucc i'), ?_, ?_⟩
· rintro rfl
simp only [Fin.val_zero, not_lt_zero'] at hij'
· simpa [S] using Nat.le_sub_one_of_lt hij'
· simp only [φ, Fin.castLT_castSucc, Fin.succ_pred]
· -- identification of corresponding terms in both sums
rintro ⟨i, j⟩ hij
dsimp
simp only [zsmul_comp, comp_zsmul, smul_smul, ← neg_smul]
congr 1
· simp only [φ, Fin.val_succ, pow_add, pow_one, mul_neg, neg_neg, mul_one]
apply mul_comm
· rw [CategoryTheory.SimplicialObject.δ_comp_δ'']
simpa [S] using hij
/-!
## Construction of the alternating face map complex functor
-/
/-- The alternating face map complex, on objects -/
def obj : ChainComplex C ℕ :=
ChainComplex.of (fun n => X _⦋n⦌) (objD X) (d_squared X)
@[simp]
theorem obj_X (X : SimplicialObject C) (n : ℕ) : (AlternatingFaceMapComplex.obj X).X n = X _⦋n⦌ :=
rfl
@[simp]
theorem obj_d_eq (X : SimplicialObject C) (n : ℕ) :
(AlternatingFaceMapComplex.obj X).d (n + 1) n
= ∑ i : Fin (n + 2), (-1 : ℤ) ^ (i : ℕ) • X.δ i := by
apply ChainComplex.of_d
variable {X} {Y}
/-- The alternating face map complex, on morphisms -/
def map (f : X ⟶ Y) : obj X ⟶ obj Y :=
ChainComplex.ofHom _ _ _ _ _ _ (fun n => f.app (op ⦋n⦌)) fun n => by
dsimp
rw [comp_sum, sum_comp]
refine Finset.sum_congr rfl fun _ _ => ?_
rw [comp_zsmul, zsmul_comp]
congr 1
symm
apply f.naturality
@[simp]
theorem map_f (f : X ⟶ Y) (n : ℕ) : (map f).f n = f.app (op ⦋n⦌) :=
rfl
end AlternatingFaceMapComplex
variable (C : Type*) [Category C] [Preadditive C]
/-- The alternating face map complex, as a functor -/
def alternatingFaceMapComplex : SimplicialObject C ⥤ ChainComplex C ℕ where
obj := AlternatingFaceMapComplex.obj
map f := AlternatingFaceMapComplex.map f
variable {C}
@[simp]
theorem alternatingFaceMapComplex_obj_X (X : SimplicialObject C) (n : ℕ) :
((alternatingFaceMapComplex C).obj X).X n = X _⦋n⦌ :=
rfl
@[simp]
theorem alternatingFaceMapComplex_obj_d (X : SimplicialObject C) (n : ℕ) :
((alternatingFaceMapComplex C).obj X).d (n + 1) n = AlternatingFaceMapComplex.objD X n := by
dsimp only [alternatingFaceMapComplex, AlternatingFaceMapComplex.obj]
apply ChainComplex.of_d
@[simp]
theorem alternatingFaceMapComplex_map_f {X Y : SimplicialObject C} (f : X ⟶ Y) (n : ℕ) :
((alternatingFaceMapComplex C).map f).f n = f.app (op ⦋n⦌) :=
rfl
theorem map_alternatingFaceMapComplex {D : Type*} [Category D] [Preadditive D] (F : C ⥤ D)
[F.Additive] :
alternatingFaceMapComplex C ⋙ F.mapHomologicalComplex _ =
(SimplicialObject.whiskering C D).obj F ⋙ alternatingFaceMapComplex D := by
apply CategoryTheory.Functor.ext
· intro X Y f
ext n
simp only [Functor.comp_map, HomologicalComplex.comp_f, alternatingFaceMapComplex_map_f,
Functor.mapHomologicalComplex_map_f, HomologicalComplex.eqToHom_f, eqToHom_refl, comp_id,
id_comp, SimplicialObject.whiskering_obj_map_app]
· intro X
apply HomologicalComplex.ext
· rintro i j (rfl : j + 1 = i)
dsimp only [Functor.comp_obj]
simp only [Functor.mapHomologicalComplex_obj_d, alternatingFaceMapComplex_obj_d,
eqToHom_refl, id_comp, comp_id, AlternatingFaceMapComplex.objD, Functor.map_sum,
Functor.map_zsmul]
rfl
· ext n
rfl
theorem karoubi_alternatingFaceMapComplex_d (P : Karoubi (SimplicialObject C)) (n : ℕ) :
((AlternatingFaceMapComplex.obj (KaroubiFunctorCategoryEmbedding.obj P)).d (n + 1) n).f =
P.p.app (op ⦋n + 1⦌) ≫ (AlternatingFaceMapComplex.obj P.X).d (n + 1) n := by
dsimp
simp only [AlternatingFaceMapComplex.obj_d_eq, Karoubi.sum_hom, Preadditive.comp_sum,
Karoubi.zsmul_hom, Preadditive.comp_zsmul]
rfl
namespace AlternatingFaceMapComplex
/-- The natural transformation which gives the augmentation of the alternating face map
complex attached to an augmented simplicial object. -/
def ε [Limits.HasZeroObject C] :
SimplicialObject.Augmented.drop ⋙ AlgebraicTopology.alternatingFaceMapComplex C ⟶
SimplicialObject.Augmented.point ⋙ ChainComplex.single₀ C where
app X := by
refine (ChainComplex.toSingle₀Equiv _ _).symm ?_
refine ⟨X.hom.app (op ⦋0⦌), ?_⟩
dsimp
rw [alternatingFaceMapComplex_obj_d, objD, Fin.sum_univ_two, Fin.val_zero,
pow_zero, one_smul, Fin.val_one, pow_one, neg_smul, one_smul, add_comp,
neg_comp, SimplicialObject.δ_naturality, SimplicialObject.δ_naturality]
apply add_neg_cancel
naturality X Y f := by
apply HomologicalComplex.to_single_hom_ext
dsimp
erw [ChainComplex.toSingle₀Equiv_symm_apply_f_zero,
ChainComplex.toSingle₀Equiv_symm_apply_f_zero]
simp only [ChainComplex.single₀_map_f_zero]
exact congr_app f.w _
@[simp]
lemma ε_app_f_zero [Limits.HasZeroObject C] (X : SimplicialObject.Augmented C) :
(ε.app X).f 0 = X.hom.app (op ⦋0⦌) :=
ChainComplex.toSingle₀Equiv_symm_apply_f_zero _ _
@[simp]
lemma ε_app_f_succ [Limits.HasZeroObject C] (X : SimplicialObject.Augmented C) (n : ℕ) :
(ε.app X).f (n + 1) = 0 := rfl
end AlternatingFaceMapComplex
/-!
## Construction of the natural inclusion of the normalized Moore complex
-/
variable {A : Type*} [Category A] [Abelian A]
/-- The inclusion map of the Moore complex in the alternating face map complex -/
def inclusionOfMooreComplexMap (X : SimplicialObject A) :
(normalizedMooreComplex A).obj X ⟶ (alternatingFaceMapComplex A).obj X := by
dsimp only [normalizedMooreComplex, NormalizedMooreComplex.obj,
alternatingFaceMapComplex, AlternatingFaceMapComplex.obj]
apply ChainComplex.ofHom _ _ _ _ _ _ (fun n => (NormalizedMooreComplex.objX X n).arrow)
/- we have to show the compatibility of the differentials on the alternating
face map complex with those defined on the normalized Moore complex:
we first get rid of the terms of the alternating sum that are obviously
zero on the normalized_Moore_complex -/
intro i
simp only [AlternatingFaceMapComplex.objD, comp_sum]
rw [Fin.sum_univ_succ, Fintype.sum_eq_zero]
swap
· intro j
rw [NormalizedMooreComplex.objX_add_one, comp_zsmul,
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ _ (Finset.mem_univ j)),
Category.assoc, kernelSubobject_arrow_comp, comp_zero, smul_zero]
-- finally, we study the remaining term which is induced by X.δ 0
rw [add_zero, Fin.val_zero, pow_zero, one_zsmul]
dsimp [NormalizedMooreComplex.objD, NormalizedMooreComplex.objX]
cases i <;> simp
@[simp]
theorem inclusionOfMooreComplexMap_f (X : SimplicialObject A) (n : ℕ) :
(inclusionOfMooreComplexMap X).f n = (NormalizedMooreComplex.objX X n).arrow := by
dsimp only [inclusionOfMooreComplexMap]
exact ChainComplex.ofHom_f _ _ _ _ _ _ _ _ n
variable (A)
/-- The inclusion map of the Moore complex in the alternating face map complex,
as a natural transformation -/
@[simps]
def inclusionOfMooreComplex : normalizedMooreComplex A ⟶ alternatingFaceMapComplex A where
app := inclusionOfMooreComplexMap
namespace AlternatingCofaceMapComplex
variable (X Y : CosimplicialObject C)
/-- The differential on the alternating coface map complex is the alternate
sum of the coface maps -/
@[simp]
def objD (n : ℕ) : X.obj ⦋n⦌ ⟶ X.obj ⦋n + 1⦌ :=
∑ i : Fin (n + 2), (-1 : ℤ) ^ (i : ℕ) • X.δ i
theorem d_eq_unop_d (n : ℕ) :
objD X n =
(AlternatingFaceMapComplex.objD ((cosimplicialSimplicialEquiv C).functor.obj (op X))
n).unop := by
simp only [objD, AlternatingFaceMapComplex.objD, unop_sum, unop_zsmul]
rfl
theorem d_squared (n : ℕ) : objD X n ≫ objD X (n + 1) = 0 := by
simp only [d_eq_unop_d, ← unop_comp, AlternatingFaceMapComplex.d_squared, unop_zero]
/-- The alternating coface map complex, on objects -/
def obj : CochainComplex C ℕ :=
CochainComplex.of (fun n => X.obj ⦋n⦌) (objD X) (d_squared X)
variable {X} {Y}
/-- The alternating face map complex, on morphisms -/
@[simp]
def map (f : X ⟶ Y) : obj X ⟶ obj Y :=
CochainComplex.ofHom _ _ _ _ _ _ (fun n => f.app ⦋n⦌) fun n => by
dsimp
rw [comp_sum, sum_comp]
refine Finset.sum_congr rfl fun x _ => ?_
rw [comp_zsmul, zsmul_comp]
congr 1
symm
apply f.naturality
end AlternatingCofaceMapComplex
variable (C)
/-- The alternating coface map complex, as a functor -/
@[simps]
def alternatingCofaceMapComplex : CosimplicialObject C ⥤ CochainComplex C ℕ where
obj := AlternatingCofaceMapComplex.obj
map f := AlternatingCofaceMapComplex.map f
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ExtraDegeneracy.lean | import Mathlib.AlgebraicTopology.AlternatingFaceMapComplex
import Mathlib.AlgebraicTopology.SimplicialSet.StdSimplex
import Mathlib.AlgebraicTopology.CechNerve
import Mathlib.Algebra.Homology.Homotopy
import Mathlib.Tactic.FinCases
/-!
# Augmented simplicial objects with an extra degeneracy
In simplicial homotopy theory, in order to prove that the connected components
of a simplicial set `X` are contractible, it suffices to construct an extra
degeneracy as it is defined in *Simplicial Homotopy Theory* by Goerss-Jardine p. 190.
It consists of a series of maps `π₀ X → X _⦋0⦌` and `X _⦋n⦌ → X _⦋n+1⦌` which
behave formally like an extra degeneracy `σ (-1)`. It can be thought as a datum
associated to the augmented simplicial set `X → π₀ X`.
In this file, we adapt this definition to the case of augmented
simplicial objects in any category.
## Main definitions
- the structure `ExtraDegeneracy X` for any `X : SimplicialObject.Augmented C`
- `ExtraDegeneracy.map`: extra degeneracies are preserved by the application of any
functor `C ⥤ D`
- `SSet.Augmented.StandardSimplex.extraDegeneracy`: the standard `n`-simplex has
an extra degeneracy
- `Arrow.AugmentedCechNerve.extraDegeneracy`: the Čech nerve of a split
epimorphism has an extra degeneracy
- `ExtraDegeneracy.homotopyEquiv`: in the case the category `C` is preadditive,
if we have an extra degeneracy on `X : SimplicialObject.Augmented C`, then
the augmentation on the alternating face map complex of `X` is a homotopy
equivalence.
## References
* [Paul G. Goerss, John F. Jardine, *Simplicial Homotopy Theory*][goerss-jardine-2009]
-/
open CategoryTheory Category SimplicialObject.Augmented Opposite Simplicial
namespace CategoryTheory
namespace SimplicialObject
namespace Augmented
variable {C : Type*} [Category C]
/-- The datum of an extra degeneracy is a technical condition on
augmented simplicial objects. The morphisms `s'` and `s n` of the
structure formally behave like extra degeneracies `σ (-1)`. -/
@[ext]
structure ExtraDegeneracy (X : SimplicialObject.Augmented C) where
/-- a section of the augmentation in dimension `0` -/
s' : point.obj X ⟶ drop.obj X _⦋0⦌
/-- the extra degeneracy -/
s : ∀ n : ℕ, drop.obj X _⦋n⦌ ⟶ drop.obj X _⦋n + 1⦌
s'_comp_ε : s' ≫ X.hom.app (op ⦋0⦌) = 𝟙 _ := by cat_disch
s₀_comp_δ₁ : s 0 ≫ X.left.δ 1 = X.hom.app (op ⦋0⦌) ≫ s' := by cat_disch
s_comp_δ₀ : ∀ n : ℕ, s n ≫ X.left.δ 0 = 𝟙 _ := by cat_disch
s_comp_δ :
∀ (n : ℕ) (i : Fin (n + 2)), s (n + 1) ≫ X.left.δ i.succ = X.left.δ i ≫ s n := by cat_disch
s_comp_σ :
∀ (n : ℕ) (i : Fin (n + 1)), s n ≫ X.left.σ i.succ = X.left.σ i ≫ s (n + 1) := by cat_disch
namespace ExtraDegeneracy
attribute [reassoc] s₀_comp_δ₁ s_comp_δ s_comp_σ
attribute [reassoc (attr := simp)] s'_comp_ε s_comp_δ₀
/-- If `ed` is an extra degeneracy for `X : SimplicialObject.Augmented C` and
`F : C ⥤ D` is a functor, then `ed.map F` is an extra degeneracy for the
augmented simplicial object in `D` obtained by applying `F` to `X`. -/
def map {D : Type*} [Category D] {X : SimplicialObject.Augmented C} (ed : ExtraDegeneracy X)
(F : C ⥤ D) : ExtraDegeneracy (((whiskering _ _).obj F).obj X) where
s' := F.map ed.s'
s n := F.map (ed.s n)
s'_comp_ε := by
dsimp
rw [comp_id, ← F.map_comp, ed.s'_comp_ε]
dsimp only [point_obj]
rw [F.map_id]
s₀_comp_δ₁ := by
dsimp
rw [comp_id, ← F.map_comp]
dsimp [SimplicialObject.whiskering, SimplicialObject.δ]
rw [← F.map_comp]
erw [ed.s₀_comp_δ₁]
s_comp_δ₀ n := by
dsimp [SimplicialObject.δ]
rw [← F.map_comp]
erw [ed.s_comp_δ₀]
dsimp
rw [F.map_id]
s_comp_δ n i := by
dsimp [SimplicialObject.δ]
rw [← F.map_comp, ← F.map_comp]
erw [ed.s_comp_δ]
rfl
s_comp_σ n i := by
dsimp [SimplicialObject.whiskering, SimplicialObject.σ]
rw [← F.map_comp, ← F.map_comp]
erw [ed.s_comp_σ]
rfl
/-- If `X` and `Y` are isomorphic augmented simplicial objects, then an extra
degeneracy for `X` gives also an extra degeneracy for `Y` -/
def ofIso {X Y : SimplicialObject.Augmented C} (e : X ≅ Y) (ed : ExtraDegeneracy X) :
ExtraDegeneracy Y where
s' := (point.mapIso e).inv ≫ ed.s' ≫ (drop.mapIso e).hom.app (op ⦋0⦌)
s n := (drop.mapIso e).inv.app (op ⦋n⦌) ≫ ed.s n ≫ (drop.mapIso e).hom.app (op ⦋n + 1⦌)
s'_comp_ε := by
simpa only [Functor.mapIso, assoc, w₀, ed.s'_comp_ε_assoc] using (point.mapIso e).inv_hom_id
s₀_comp_δ₁ := by
have h := w₀ e.inv
dsimp at h ⊢
simp only [assoc, ← SimplicialObject.δ_naturality, ed.s₀_comp_δ₁_assoc, reassoc_of% h]
s_comp_δ₀ n := by
have h := ed.s_comp_δ₀
dsimp at h ⊢
simpa only [assoc, ← SimplicialObject.δ_naturality, reassoc_of% h] using
congr_app (drop.mapIso e).inv_hom_id (op ⦋n⦌)
s_comp_δ n i := by
have h := ed.s_comp_δ n i
dsimp at h ⊢
simp only [assoc, ← SimplicialObject.δ_naturality, reassoc_of% h,
← SimplicialObject.δ_naturality_assoc]
s_comp_σ n i := by
have h := ed.s_comp_σ n i
dsimp at h ⊢
simp only [assoc, ← SimplicialObject.σ_naturality, reassoc_of% h,
← SimplicialObject.σ_naturality_assoc]
end ExtraDegeneracy
end Augmented
end SimplicialObject
end CategoryTheory
namespace SSet
namespace Augmented
namespace StandardSimplex
/-- When `[Zero X]`, the shift of a map `f : Fin n → X`
is a map `Fin (n + 1) → X` which sends `0` to `0` and `i.succ` to `f i`. -/
def shiftFun {n : ℕ} {X : Type*} [Zero X] (f : Fin n → X) (i : Fin (n + 1)) : X :=
Matrix.vecCons 0 f i
@[simp]
theorem shiftFun_zero {n : ℕ} {X : Type*} [Zero X] (f : Fin n → X) : shiftFun f 0 = 0 :=
rfl
@[simp]
theorem shiftFun_succ {n : ℕ} {X : Type*} [Zero X] (f : Fin n → X) (i : Fin n) :
shiftFun f i.succ = f i :=
rfl
/-- The shift of a morphism `f : ⦋n⦌ → Δ` in `SimplexCategory` corresponds to
the monotone map which sends `0` to `0` and `i.succ` to `f.toOrderHom i`. -/
@[simp]
def shift {n : ℕ} {Δ : SimplexCategory} (f : ⦋n⦌ ⟶ Δ) : ⦋n + 1⦌ ⟶ Δ :=
SimplexCategory.Hom.mk
{ toFun := shiftFun f.toOrderHom
monotone' := fun i₁ i₂ hi => by
by_cases h₁ : i₁ = 0
· subst h₁
simp only [shiftFun_zero, Fin.zero_le]
· have h₂ : i₂ ≠ 0 := by
intro h₂
subst h₂
exact h₁ (le_antisymm hi (Fin.zero_le _))
obtain ⟨j₁, hj₁⟩ := Fin.eq_succ_of_ne_zero h₁
obtain ⟨j₂, hj₂⟩ := Fin.eq_succ_of_ne_zero h₂
substs hj₁ hj₂
simpa only [shiftFun_succ] using f.toOrderHom.monotone (Fin.succ_le_succ_iff.mp hi) }
open SSet.stdSimplex in
/-- The obvious extra degeneracy on the standard simplex. -/
protected noncomputable def extraDegeneracy (Δ : SimplexCategory) :
SimplicialObject.Augmented.ExtraDegeneracy (stdSimplex.obj Δ) where
s' _ := objMk (OrderHom.const _ 0)
s _ f := objEquiv.symm (shift (objEquiv f))
s'_comp_ε := by
dsimp
subsingleton
s₀_comp_δ₁ := by
dsimp
ext1 x
apply objEquiv.injective
ext j
fin_cases j
rfl
s_comp_δ₀ n := by
ext1 φ
apply objEquiv.injective
apply SimplexCategory.Hom.ext
ext i : 2
dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.stdSimplex,
objEquiv, Equiv.ulift, uliftFunctor]
s_comp_δ n i := by
ext1 φ
apply objEquiv.injective
apply SimplexCategory.Hom.ext
ext j : 2
dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.stdSimplex,
objEquiv, Equiv.ulift, uliftFunctor]
cases j using Fin.cases <;> simp
s_comp_σ n i := by
ext1 φ
apply objEquiv.injective
apply SimplexCategory.Hom.ext
ext j : 2
dsimp [SimplicialObject.σ, SimplexCategory.σ, SSet.stdSimplex, objEquiv, Equiv.ulift,
uliftFunctor, Function.comp_def]
cases j using Fin.cases <;> simp
instance nonempty_extraDegeneracy_stdSimplex (Δ : SimplexCategory) :
Nonempty (SimplicialObject.Augmented.ExtraDegeneracy (stdSimplex.obj Δ)) :=
⟨StandardSimplex.extraDegeneracy Δ⟩
end StandardSimplex
end Augmented
end SSet
namespace CategoryTheory
open Limits
namespace Arrow
namespace AugmentedCechNerve
variable {C : Type*} [Category C] (f : Arrow C)
[∀ n : ℕ, HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
(S : SplitEpi f.hom)
/-- The extra degeneracy map on the Čech nerve of a split epi. It is
given on the `0`-projection by the given section of the split epi,
and by shifting the indices on the other projections. -/
noncomputable def ExtraDegeneracy.s (n : ℕ) :
f.cechNerve.obj (op ⦋n⦌) ⟶ f.cechNerve.obj (op ⦋n + 1⦌) :=
WidePullback.lift (WidePullback.base _)
(Fin.cases (WidePullback.base _ ≫ S.section_) (WidePullback.π _))
fun i => by
cases i using Fin.cases <;> simp
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11119): @[simp] removed as the linter complains the LHS is not in normal form
-- The problem is that the type of `ExtraDegeneracy.s` is not in normal form, this causes the `erw`
-- in the proofs below.
theorem ExtraDegeneracy.s_comp_π_0 (n : ℕ) :
ExtraDegeneracy.s f S n ≫ WidePullback.π _ 0 =
@WidePullback.base _ _ _ f.right (fun _ : Fin (n + 1) => f.left) (fun _ => f.hom) _ ≫
S.section_ := by
dsimp [ExtraDegeneracy.s]
simp
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11119): @[simp] removed as the linter complains the LHS is not in normal form
theorem ExtraDegeneracy.s_comp_π_succ (n : ℕ) (i : Fin (n + 1)) :
ExtraDegeneracy.s f S n ≫ WidePullback.π _ i.succ =
@WidePullback.π _ _ _ f.right (fun _ : Fin (n + 1) => f.left) (fun _ => f.hom) _ i := by
simp [ExtraDegeneracy.s]
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11119): @[simp] removed as the linter complains the LHS is not in normal form
theorem ExtraDegeneracy.s_comp_base (n : ℕ) :
ExtraDegeneracy.s f S n ≫ WidePullback.base _ = WidePullback.base _ := by
apply WidePullback.lift_base
/-- The augmented Čech nerve associated to a split epimorphism has an extra degeneracy. -/
noncomputable def extraDegeneracy :
SimplicialObject.Augmented.ExtraDegeneracy f.augmentedCechNerve where
s' := S.section_ ≫ WidePullback.lift f.hom (fun _ => 𝟙 _) fun i => by rw [id_comp]
s n := ExtraDegeneracy.s f S n
s'_comp_ε := by
dsimp
simp only [assoc, WidePullback.lift_base, SplitEpi.id]
s₀_comp_δ₁ := by
dsimp [cechNerve, SimplicialObject.δ, SimplexCategory.δ]
ext j
· fin_cases j
simpa only [assoc, WidePullback.lift_π, comp_id] using ExtraDegeneracy.s_comp_π_0 f S 0
· simpa only [assoc, WidePullback.lift_base, SplitEpi.id, comp_id] using
ExtraDegeneracy.s_comp_base f S 0
s_comp_δ₀ n := by
dsimp [cechNerve, SimplicialObject.δ, SimplexCategory.δ]
ext j
· simpa only [assoc, WidePullback.lift_π, id_comp] using ExtraDegeneracy.s_comp_π_succ f S n j
· simpa only [assoc, WidePullback.lift_base, id_comp] using ExtraDegeneracy.s_comp_base f S n
s_comp_δ n i := by
dsimp [SimplicialObject.δ, SimplexCategory.δ]
ext j
· simp only [assoc, WidePullback.lift_π]
cases j using Fin.cases with
| zero =>
rw [Fin.succ_succAbove_zero]
erw [ExtraDegeneracy.s_comp_π_0, ExtraDegeneracy.s_comp_π_0]
dsimp
simp only [WidePullback.lift_base_assoc]
| succ k =>
erw [Fin.succ_succAbove_succ, ExtraDegeneracy.s_comp_π_succ,
ExtraDegeneracy.s_comp_π_succ]
simp only [WidePullback.lift_π]
· simp only [assoc, WidePullback.lift_base]
erw [ExtraDegeneracy.s_comp_base, ExtraDegeneracy.s_comp_base]
dsimp
simp only [WidePullback.lift_base]
s_comp_σ n i := by
dsimp [cechNerve, SimplicialObject.σ, SimplexCategory.σ]
ext j
· simp only [assoc, WidePullback.lift_π]
cases j using Fin.cases with
| zero =>
erw [ExtraDegeneracy.s_comp_π_0, ExtraDegeneracy.s_comp_π_0]
dsimp
simp only [WidePullback.lift_base_assoc]
| succ k =>
erw [Fin.succ_predAbove_succ, ExtraDegeneracy.s_comp_π_succ,
ExtraDegeneracy.s_comp_π_succ]
simp only [WidePullback.lift_π]
· simp only [assoc, WidePullback.lift_base]
erw [ExtraDegeneracy.s_comp_base, ExtraDegeneracy.s_comp_base]
dsimp
simp only [WidePullback.lift_base]
end AugmentedCechNerve
end Arrow
namespace SimplicialObject
namespace Augmented
namespace ExtraDegeneracy
open AlgebraicTopology CategoryTheory Limits
variable {C : Type*} [Category C]
/-- The constant augmented simplicial object has an extra degeneracy. -/
@[simps]
def const (X : C) : ExtraDegeneracy (Augmented.const.obj X) where
s' := 𝟙 _
s _ := 𝟙 _
/-- If `C` is a preadditive category and `X` is an augmented simplicial object
in `C` that has an extra degeneracy, then the augmentation on the alternating
face map complex of `X` is a homotopy equivalence. -/
noncomputable def homotopyEquiv [Preadditive C] [HasZeroObject C]
{X : SimplicialObject.Augmented C} (ed : ExtraDegeneracy X) :
HomotopyEquiv (AlgebraicTopology.AlternatingFaceMapComplex.obj (drop.obj X))
((ChainComplex.single₀ C).obj (point.obj X)) where
hom := AlternatingFaceMapComplex.ε.app X
inv := (ChainComplex.fromSingle₀Equiv _ _).symm (by exact ed.s')
homotopyInvHomId := Homotopy.ofEq (by
ext
dsimp
erw [AlternatingFaceMapComplex.ε_app_f_zero,
ChainComplex.fromSingle₀Equiv_symm_apply_f_zero, s'_comp_ε]
rfl)
homotopyHomInvId :=
{ hom i := Pi.single (i + 1) (-ed.s i)
zero i j hij := Pi.single_eq_of_ne (Ne.symm hij) _
comm i := by
cases i with
| zero =>
rw [Homotopy.prevD_chainComplex, Homotopy.dNext_zero_chainComplex, zero_add]
dsimp
erw [ChainComplex.fromSingle₀Equiv_symm_apply_f_zero]
simp only [AlternatingFaceMapComplex.obj_d_eq]
rw [Fin.sum_univ_two]
simp [s_comp_δ₀, s₀_comp_δ₁]
| succ i =>
rw [Homotopy.prevD_chainComplex, Homotopy.dNext_succ_chainComplex]
simp [Fin.sum_univ_succ (n := i + 2), s_comp_δ₀, Preadditive.sum_comp,
Preadditive.comp_sum,
s_comp_δ, pow_succ] }
end ExtraDegeneracy
end Augmented
end SimplicialObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialNerve.lean | import Mathlib.AlgebraicTopology.SimplicialCategory.Basic
import Mathlib.AlgebraicTopology.SimplicialSet.Nerve
/-!
# The simplicial nerve of a simplicial category
This file defines the simplicial nerve (sometimes called homotopy coherent nerve) of a simplicial
category.
We define the *simplicial thickening* of a linear order `J` as the simplicial category whose hom
objects `i ⟶ j` are given by the nerve of the poset of "paths" from `i` to `j` in `J`. This is the
poset of subsets of the interval `[i, j]` in `J`, containing the endpoints.
The simplicial nerve of a simplicial category `C` is then defined as the simplicial set whose
`n`-simplices are given by the set of simplicial functors from the simplicial thickening of
the linear order `Fin (n + 1)` to `C`, in other words
`SimplicialNerve C _⦋n⦌ := EnrichedFunctor SSet (SimplicialThickening (Fin (n + 1))) C`.
## Projects
* Prove that the 0-simplices of `SimplicialNerve C` may be identified with the objects of `C`
* Prove that the 1-simplices of `SimplicialNerve C` may be identified with the morphisms of `C`
* Prove that the simplicial nerve of a simplicial category `C`, such that `sHom X Y` is a Kan
complex for every pair of objects `X Y : C`, is a quasicategory.
* Define the quasicategory of anima as the simplicial nerve of the simplicial category of
Kan complexes.
* Define the functor from topological spaces to anima.
## References
* [Jacob Lurie, *Higher Topos Theory*, Section 1.1.5][LurieHTT]
-/
universe v u
namespace CategoryTheory
open SimplicialCategory EnrichedCategory EnrichedOrdinaryCategory MonoidalCategory
open scoped Simplicial
section SimplicialNerve
/-- A type synonym for a linear order `J`, will be equipped with a simplicial category structure. -/
@[nolint unusedArguments]
def SimplicialThickening (J : Type*) [LinearOrder J] : Type _ := J
instance (J : Type*) [LinearOrder J] : LinearOrder (SimplicialThickening J) :=
inferInstanceAs (LinearOrder J)
namespace SimplicialThickening
/--
A path from `i` to `j` in a linear order `J` is a subset of the interval `[i, j]` in `J` containing
the endpoints.
-/
@[ext]
structure Path {J : Type*} [LinearOrder J] (i j : J) where
/-- The underlying subset -/
I : Set J
left : i ∈ I := by simp
right : j ∈ I := by simp
left_le (k : J) (_ : k ∈ I) : i ≤ k := by simp
le_right (k : J) (_ : k ∈ I) : k ≤ j := by simp
lemma Path.le {J : Type*} [LinearOrder J] {i j : J} (f : Path i j) : i ≤ j :=
f.left_le _ f.right
instance {J : Type*} [LinearOrder J] (i j : J) : Category (Path i j) :=
InducedCategory.category (fun f : Path i j ↦ f.I)
@[simps]
instance (J : Type*) [LinearOrder J] : CategoryStruct (SimplicialThickening J) where
Hom i j := Path i j
id i := { I := {i} }
comp {i j k} f g := {
I := f.I ∪ g.I
left := Or.inl f.left
right := Or.inr g.right
left_le l := by
rintro (h | h)
exacts [(f.left_le l h), (Path.le f).trans (g.left_le l h)]
le_right l := by
rintro (h | h)
exacts [(f.le_right _ h).trans (Path.le g), (g.le_right l h)] }
instance {J : Type*} [LinearOrder J] (i j : SimplicialThickening J) : Category (i ⟶ j) :=
inferInstanceAs (Category (Path _ _))
@[ext]
lemma hom_ext {J : Type*} [LinearOrder J]
(i j : SimplicialThickening J) (x y : i ⟶ j) (h : ∀ t, t ∈ x.I ↔ t ∈ y.I) : x = y := by
apply Path.ext
ext
apply h
instance (J : Type*) [LinearOrder J] : Category (SimplicialThickening J) where
id_comp f := by ext; simpa using fun h ↦ h ▸ f.left
comp_id f := by ext; simpa using fun h ↦ h ▸ f.right
/--
Composition of morphisms in `SimplicialThickening J`, as a functor `(i ⟶ j) × (j ⟶ k) ⥤ (i ⟶ k)`
-/
@[simps]
def compFunctor {J : Type*} [LinearOrder J]
(i j k : SimplicialThickening J) : (i ⟶ j) × (j ⟶ k) ⥤ (i ⟶ k) where
obj x := x.1 ≫ x.2
map f := ⟨⟨Set.union_subset_union f.1.1.1 f.2.1.1⟩⟩
namespace SimplicialCategory
variable {J : Type*} [LinearOrder J]
/-- The hom simplicial set of the simplicial category structure on `SimplicialThickening J` -/
abbrev Hom (i j : SimplicialThickening J) : SSet := (nerve (i ⟶ j))
/-- The identity of the simplicial category structure on `SimplicialThickening J` -/
abbrev id (i : SimplicialThickening J) : 𝟙_ SSet ⟶ Hom i i :=
⟨fun _ _ ↦ (Functor.const _).obj (𝟙 _), fun _ _ _ ↦ by simp; rfl⟩
/-- The composition of the simplicial category structure on `SimplicialThickening J` -/
abbrev comp (i j k : SimplicialThickening J) : Hom i j ⊗ Hom j k ⟶ Hom i k :=
⟨fun _ x ↦ x.1.prod' x.2 ⋙ compFunctor i j k, fun _ _ _ ↦ by simp; rfl⟩
@[simp]
lemma id_comp (i j : SimplicialThickening J) :
(λ_ (Hom i j)).inv ≫ id i ▷ Hom i j ≫ comp i i j = 𝟙 (Hom i j) := by
aesop
@[simp]
lemma comp_id (i j : SimplicialThickening J) :
(ρ_ (Hom i j)).inv ≫ Hom i j ◁ id j ≫ comp i j j = 𝟙 (Hom i j) := by
aesop
@[simp]
lemma assoc (i j k l : SimplicialThickening J) :
(α_ (Hom i j) (Hom j k) (Hom k l)).inv ≫ comp i j k ▷ Hom k l ≫ comp i k l =
Hom i j ◁ comp j k l ≫ comp i j l := by
aesop
end SimplicialCategory
open SimplicialThickening.SimplicialCategory
noncomputable instance (J : Type*) [LinearOrder J] :
SimplicialCategory (SimplicialThickening J) where
Hom := Hom
id := id
comp := comp
homEquiv {i j} := (nerveEquiv _).symm.trans (SSet.unitHomEquiv _).symm
/-- Auxiliary definition for `SimplicialThickening.functorMap` -/
def orderHom {J K : Type*} [LinearOrder J] [LinearOrder K] (f : J →o K) :
SimplicialThickening J →o SimplicialThickening K := f
/-- Auxiliary definition for `SimplicialThickening.functor` -/
noncomputable abbrev functorMap {J K : Type u} [LinearOrder J] [LinearOrder K]
(f : J →o K) (i j : SimplicialThickening J) : (i ⟶ j) ⥤ ((orderHom f i) ⟶ (orderHom f j)) where
obj I := ⟨f '' I.I, Set.mem_image_of_mem f I.left, Set.mem_image_of_mem f I.right,
by rintro _ ⟨k, hk, rfl⟩; exact f.monotone (I.left_le k hk),
by rintro _ ⟨k, hk, rfl⟩; exact f.monotone (I.le_right k hk)⟩
map f := ⟨⟨Set.image_mono f.1.1⟩⟩
/--
The simplicial thickening defines a functor from the category of linear orders to the category of
simplicial categories
-/
@[simps]
noncomputable def functor {J K : Type u} [LinearOrder J] [LinearOrder K]
(f : J →o K) : EnrichedFunctor SSet (SimplicialThickening J) (SimplicialThickening K) where
obj := f
map i j := nerveMap ((functorMap f i j))
map_id i := by
ext
simp only [eId, EnrichedCategory.id]
exact Functor.ext (by cat_disch)
map_comp i j k := by
ext
simp only [eComp, EnrichedCategory.comp]
exact Functor.ext (by cat_disch)
lemma functor_id (J : Type u) [LinearOrder J] :
(functor (OrderHom.id (α := J))) = EnrichedFunctor.id _ _ := by
refine EnrichedFunctor.ext _ (fun _ ↦ rfl) fun i j ↦ ?_
ext
exact Functor.ext (by cat_disch)
lemma functor_comp {J K L : Type u} [LinearOrder J] [LinearOrder K]
[LinearOrder L] (f : J →o K) (g : K →o L) :
functor (g.comp f) =
(functor f).comp _ (functor g) := by
refine EnrichedFunctor.ext _ (fun _ ↦ rfl) fun i j ↦ ?_
ext
exact Functor.ext (by cat_disch)
end SimplicialThickening
/--
The simplicial nerve of a simplicial category `C` is defined as the simplicial set whose
`n`-simplices are given by the set of simplicial functors from the simplicial thickening of
the linear order `Fin (n + 1)` to `C`
-/
noncomputable def SimplicialNerve (C : Type u) [Category.{v} C] [SimplicialCategory C] :
SSet.{max u v} where
obj n := EnrichedFunctor SSet (SimplicialThickening (ULift (Fin (n.unop.len + 1)))) C
map f := (SimplicialThickening.functor f.unop.toOrderHom.uliftMap).comp (E := C) SSet
map_id i := by
change EnrichedFunctor.comp SSet (SimplicialThickening.functor (OrderHom.id)) = _
rw [SimplicialThickening.functor_id]
rfl
map_comp f g := by
change EnrichedFunctor.comp SSet (SimplicialThickening.functor
(f.unop.toOrderHom.uliftMap.comp g.unop.toOrderHom.uliftMap)) = _
rw [SimplicialThickening.functor_comp]
rfl
end SimplicialNerve
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/CechNerve.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.Limits.Shapes.WidePullbacks
import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts
/-!
# The Čech Nerve
This file provides a definition of the Čech nerve associated to an arrow, provided
the base category has the correct wide pullbacks.
Several variants are provided, given `f : Arrow C`:
1. `f.cechNerve` is the Čech nerve, considered as a simplicial object in `C`.
2. `f.augmentedCechNerve` is the augmented Čech nerve, considered as an
augmented simplicial object in `C`.
3. `SimplicialObject.cechNerve` and `SimplicialObject.augmentedCechNerve` are
functorial versions of 1 resp. 2.
We end the file with a description of the Čech nerve of an arrow `X ⟶ ⊤_ C` to a terminal
object, when `C` has finite products. We call this `cechNerveTerminalFrom`. When `C` is
`G`-Set this gives us `EG` (the universal cover of the classifying space of `G`) as a simplicial
`G`-set, which is useful for group cohomology.
-/
open CategoryTheory Limits
open scoped Simplicial
noncomputable section
universe v u w
variable {C : Type u} [Category.{v} C]
namespace CategoryTheory.Arrow
variable (f : Arrow C)
variable [∀ n : ℕ, HasWidePullback.{0} f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
/-- The Čech nerve associated to an arrow. -/
@[simps]
def cechNerve : SimplicialObject C where
obj n := widePullback.{0} f.right (fun _ : Fin (n.unop.len + 1) => f.left) fun _ => f.hom
map g := WidePullback.lift (WidePullback.base _)
(fun i => WidePullback.π _ (g.unop.toOrderHom i)) (by simp)
/-- The morphism between Čech nerves associated to a morphism of arrows. -/
@[simps]
def mapCechNerve {f g : Arrow C}
[∀ n : ℕ, HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
[∀ n : ℕ, HasWidePullback g.right (fun _ : Fin (n + 1) => g.left) fun _ => g.hom] (F : f ⟶ g) :
f.cechNerve ⟶ g.cechNerve where
app n :=
WidePullback.lift (WidePullback.base _ ≫ F.right) (fun i => WidePullback.π _ i ≫ F.left)
fun j => by simp
/-- The augmented Čech nerve associated to an arrow. -/
@[simps]
def augmentedCechNerve : SimplicialObject.Augmented C where
left := f.cechNerve
right := f.right
hom := { app := fun _ => WidePullback.base _ }
/-- The morphism between augmented Čech nerve associated to a morphism of arrows. -/
@[simps]
def mapAugmentedCechNerve {f g : Arrow C}
[∀ n : ℕ, HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
[∀ n : ℕ, HasWidePullback g.right (fun _ : Fin (n + 1) => g.left) fun _ => g.hom] (F : f ⟶ g) :
f.augmentedCechNerve ⟶ g.augmentedCechNerve where
left := mapCechNerve F
right := F.right
end CategoryTheory.Arrow
namespace CategoryTheory
namespace SimplicialObject
variable
[∀ (n : ℕ) (f : Arrow C), HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
/-- The Čech nerve construction, as a functor from `Arrow C`. -/
@[simps]
def cechNerve : Arrow C ⥤ SimplicialObject C where
obj f := f.cechNerve
map F := Arrow.mapCechNerve F
/-- The augmented Čech nerve construction, as a functor from `Arrow C`. -/
@[simps!]
def augmentedCechNerve : Arrow C ⥤ SimplicialObject.Augmented C where
obj f := f.augmentedCechNerve
map F := Arrow.mapAugmentedCechNerve F
/-- A helper function used in defining the Čech adjunction. -/
@[simps]
def equivalenceRightToLeft (X : SimplicialObject.Augmented C) (F : Arrow C)
(G : X ⟶ F.augmentedCechNerve) : Augmented.toArrow.obj X ⟶ F where
left := G.left.app _ ≫ WidePullback.π _ 0
right := G.right
w := by
have := G.w
apply_fun fun e => e.app (Opposite.op ⦋0⦌) at this
simpa using this
/-- A helper function used in defining the Čech adjunction. -/
@[simps]
def equivalenceLeftToRight (X : SimplicialObject.Augmented C) (F : Arrow C)
(G : Augmented.toArrow.obj X ⟶ F) : X ⟶ F.augmentedCechNerve where
left :=
{ app := fun x =>
Limits.WidePullback.lift (X.hom.app _ ≫ G.right)
(fun i => X.left.map (SimplexCategory.const _ x.unop i).op ≫ G.left) fun i => by simp
naturality := by
intro x y f
dsimp
ext
· simp only [WidePullback.lift_π, Category.assoc, ← X.left.map_comp_assoc]
rfl
· simp }
right := G.right
/-- A helper function used in defining the Čech adjunction. -/
@[simps]
def cechNerveEquiv (X : SimplicialObject.Augmented C) (F : Arrow C) :
(Augmented.toArrow.obj X ⟶ F) ≃ (X ⟶ F.augmentedCechNerve) where
toFun := equivalenceLeftToRight _ _
invFun := equivalenceRightToLeft _ _
left_inv A := by ext <;> simp
right_inv := by
intro A
ext x : 2
· refine WidePullback.hom_ext _ _ _ (fun j => ?_) ?_
· simp
rfl
· simpa using congr_app A.w.symm x
· simp
/-- The augmented Čech nerve construction is right adjoint to the `toArrow` functor. -/
abbrev cechNerveAdjunction : (Augmented.toArrow : _ ⥤ Arrow C) ⊣ augmentedCechNerve :=
Adjunction.mkOfHomEquiv
{ homEquiv := cechNerveEquiv
homEquiv_naturality_left_symm := by dsimp [cechNerveEquiv]; cat_disch
homEquiv_naturality_right := by
dsimp [cechNerveEquiv]
-- The next three lines were not needed before https://github.com/leanprover/lean4/pull/2644
intro X Y Y' f g
change equivalenceLeftToRight X Y' (f ≫ g) =
equivalenceLeftToRight X Y f ≫ augmentedCechNerve.map g
cat_disch
}
end SimplicialObject
end CategoryTheory
namespace CategoryTheory.Arrow
variable (f : Arrow C)
variable [∀ n : ℕ, HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
/-- The Čech conerve associated to an arrow. -/
@[simps]
def cechConerve : CosimplicialObject C where
obj n := widePushout f.left (fun _ : Fin (n.len + 1) => f.right) fun _ => f.hom
map {x y} g := by
refine WidePushout.desc (WidePushout.head _)
(fun i => (@WidePushout.ι _ _ _ _ _ (fun _ => f.hom) (_) (g.toOrderHom i))) (fun j => ?_)
rw [← WidePushout.arrow_ι]
/-- The morphism between Čech conerves associated to a morphism of arrows. -/
@[simps]
def mapCechConerve {f g : Arrow C}
[∀ n : ℕ, HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
[∀ n : ℕ, HasWidePushout g.left (fun _ : Fin (n + 1) => g.right) fun _ => g.hom] (F : f ⟶ g) :
f.cechConerve ⟶ g.cechConerve where
app n := WidePushout.desc (F.left ≫ WidePushout.head _)
(fun i => F.right ≫ (by apply WidePushout.ι _ i))
(fun i => (by rw [← Arrow.w_assoc F, ← WidePushout.arrow_ι]))
/-- The augmented Čech conerve associated to an arrow. -/
@[simps]
def augmentedCechConerve : CosimplicialObject.Augmented C where
left := f.left
right := f.cechConerve
hom :=
{ app := fun _ => (WidePushout.head _ : f.left ⟶ _) }
/-- The morphism between augmented Čech conerves associated to a morphism of arrows. -/
@[simps]
def mapAugmentedCechConerve {f g : Arrow C}
[∀ n : ℕ, HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
[∀ n : ℕ, HasWidePushout g.left (fun _ : Fin (n + 1) => g.right) fun _ => g.hom] (F : f ⟶ g) :
f.augmentedCechConerve ⟶ g.augmentedCechConerve where
left := F.left
right := mapCechConerve F
end CategoryTheory.Arrow
namespace CategoryTheory
namespace CosimplicialObject
variable
[∀ (n : ℕ) (f : Arrow C), HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
/-- The Čech conerve construction, as a functor from `Arrow C`. -/
@[simps]
def cechConerve : Arrow C ⥤ CosimplicialObject C where
obj f := f.cechConerve
map F := Arrow.mapCechConerve F
/-- The augmented Čech conerve construction, as a functor from `Arrow C`. -/
@[simps]
def augmentedCechConerve : Arrow C ⥤ CosimplicialObject.Augmented C where
obj f := f.augmentedCechConerve
map F := Arrow.mapAugmentedCechConerve F
/-- A helper function used in defining the Čech conerve adjunction. -/
@[simps]
def equivalenceLeftToRight (F : Arrow C) (X : CosimplicialObject.Augmented C)
(G : F.augmentedCechConerve ⟶ X) : F ⟶ Augmented.toArrow.obj X where
left := G.left
right := (WidePushout.ι _ 0 ≫ G.right.app ⦋0⦌ :)
w := by
dsimp
rw [@WidePushout.arrow_ι_assoc _ _ _ _ _ (fun (_ : Fin 1) => F.hom)
(by dsimp; infer_instance)]
exact congr_app G.w ⦋0⦌
/-- A helper function used in defining the Čech conerve adjunction. -/
@[simps!]
def equivalenceRightToLeft (F : Arrow C) (X : CosimplicialObject.Augmented C)
(G : F ⟶ Augmented.toArrow.obj X) : F.augmentedCechConerve ⟶ X where
left := G.left
right :=
{ app := fun x =>
Limits.WidePushout.desc (G.left ≫ X.hom.app _)
(fun i => G.right ≫ X.right.map (SimplexCategory.const _ x i))
(by
rintro j
rw [← Arrow.w_assoc G]
have t := X.hom.naturality (SimplexCategory.const ⦋0⦌ x j)
dsimp at t ⊢
simp only [Category.id_comp] at t
rw [← t])
naturality := by
intro x y f
dsimp
ext
· dsimp
simp only [WidePushout.ι_desc_assoc, WidePushout.ι_desc]
rw [Category.assoc, ← X.right.map_comp]
rfl
· simp [← NatTrans.naturality] }
/-- A helper function used in defining the Čech conerve adjunction. -/
@[simps]
def cechConerveEquiv (F : Arrow C) (X : CosimplicialObject.Augmented C) :
(F.augmentedCechConerve ⟶ X) ≃ (F ⟶ Augmented.toArrow.obj X) where
toFun := equivalenceLeftToRight _ _
invFun := equivalenceRightToLeft _ _
left_inv := by
intro A
ext x : 2
· rfl
· refine WidePushout.hom_ext _ _ _ (fun j => ?_) ?_
· dsimp
simp only [Category.assoc, ← NatTrans.naturality A.right, Arrow.augmentedCechConerve_right,
SimplexCategory.len_mk, Arrow.cechConerve_map, colimit.ι_desc,
WidePushoutShape.mkCocone_ι_app, colimit.ι_desc_assoc]
rfl
· dsimp
rw [colimit.ι_desc]
exact congr_app A.w x
right_inv := by
intro A
ext
· rfl
· dsimp
rw [WidePushout.ι_desc]
nth_rw 2 [← Category.comp_id A.right]
congr 1
convert X.right.map_id _
ext ⟨a, ha⟩
simp
/-- The augmented Čech conerve construction is left adjoint to the `toArrow` functor. -/
abbrev cechConerveAdjunction : augmentedCechConerve ⊣ (Augmented.toArrow : _ ⥤ Arrow C) :=
Adjunction.mkOfHomEquiv { homEquiv := cechConerveEquiv }
end CosimplicialObject
/-- Given an object `X : C`, the natural simplicial object sending `⦋n⦌` to `Xⁿ⁺¹`. -/
def cechNerveTerminalFrom {C : Type u} [Category.{v} C] [HasFiniteProducts C] (X : C) :
SimplicialObject C where
obj n := ∏ᶜ fun _ : Fin (n.unop.len + 1) => X
map f := Limits.Pi.lift fun i => Limits.Pi.π _ (f.unop.toOrderHom i)
namespace CechNerveTerminalFrom
variable [HasTerminal C] (ι : Type w)
/-- The diagram `Option ι ⥤ C` sending `none` to the terminal object and `some j` to `X`. -/
def wideCospan (X : C) : WidePullbackShape ι ⥤ C :=
WidePullbackShape.wideCospan (terminal C) (fun _ : ι => X) fun _ => terminal.from X
instance uniqueToWideCospanNone (X Y : C) : Unique (Y ⟶ (wideCospan ι X).obj none) := by
dsimp [wideCospan]
infer_instance
variable [HasFiniteProducts C]
/-- The product `Xᶥ` is the vertex of a limit cone on `wideCospan ι X`. -/
def wideCospan.limitCone [Finite ι] (X : C) : LimitCone (wideCospan ι X) where
cone :=
{ pt := ∏ᶜ fun _ : ι => X
π :=
{ app := fun X => Option.casesOn X (terminal.from _) fun i => limit.π _ ⟨i⟩
naturality := fun i j f => by
cases f
· cases i
all_goals simp
· simp only [Functor.const_obj_obj, Functor.const_obj_map, terminal.comp_from]
subsingleton } }
isLimit :=
{ lift := fun s => Limits.Pi.lift fun j => s.π.app (some j)
fac := fun s j => Option.casesOn j (by subsingleton) fun _ => limit.lift_π _ _
uniq := fun s f h => by
dsimp
ext j
dsimp only [Limits.Pi.lift]
rw [limit.lift_π]
dsimp
rw [← h (some j)] }
instance hasWidePullback [Finite ι] (X : C) :
HasWidePullback (Arrow.mk (terminal.from X)).right
(fun _ : ι => (Arrow.mk (terminal.from X)).left)
(fun _ => (Arrow.mk (terminal.from X)).hom) := by
cases nonempty_fintype ι
exact ⟨⟨wideCospan.limitCone ι X⟩⟩
instance hasWidePullback' [Finite ι] (X : C) :
HasWidePullback (⊤_ C)
(fun _ : ι => X)
(fun _ => terminal.from X) :=
hasWidePullback _ _
instance hasLimit_wideCospan [Finite ι] (X : C) : HasLimit (wideCospan ι X) := hasWidePullback _ _
/-- the isomorphism to the product induced by the limit cone `wideCospan ι X` -/
def wideCospan.limitIsoPi [Finite ι] (X : C) :
limit (wideCospan ι X) ≅ ∏ᶜ fun _ : ι => X :=
(IsLimit.conePointUniqueUpToIso (limit.isLimit _)
(wideCospan.limitCone ι X).2)
@[reassoc (attr := simp)]
lemma wideCospan.limitIsoPi_inv_comp_pi [Finite ι] (X : C) (j : ι) :
(wideCospan.limitIsoPi ι X).inv ≫ WidePullback.π _ j = Pi.π _ j :=
IsLimit.conePointUniqueUpToIso_inv_comp _ _ _
@[reassoc (attr := simp)]
lemma wideCospan.limitIsoPi_hom_comp_pi [Finite ι] (X : C) (j : ι) :
(wideCospan.limitIsoPi ι X).hom ≫ Pi.π _ j = WidePullback.π _ j := by
rw [← wideCospan.limitIsoPi_inv_comp_pi, Iso.hom_inv_id_assoc]
/-- Given an object `X : C`, the Čech nerve of the hom to the terminal object `X ⟶ ⊤_ C` is
naturally isomorphic to a simplicial object sending `⦋n⦌` to `Xⁿ⁺¹` (when `C` is `G-Set`, this is
`EG`, the universal cover of the classifying space of `G`. -/
def iso (X : C) : (Arrow.mk (terminal.from X)).cechNerve ≅ cechNerveTerminalFrom X :=
NatIso.ofComponents (fun _ => wideCospan.limitIsoPi _ _) (fun {m n} f => by
dsimp only [cechNerveTerminalFrom, Arrow.cechNerve]
ext ⟨j⟩
simp)
end CechNerveTerminalFrom
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SingularSet.lean | import Mathlib.AlgebraicTopology.SimplicialSet.StdSimplex
import Mathlib.AlgebraicTopology.TopologicalSimplex
import Mathlib.CategoryTheory.Limits.Presheaf
import Mathlib.Topology.Category.TopCat.Limits.Basic
import Mathlib.Topology.Category.TopCat.ULift
/-!
# The singular simplicial set of a topological space and geometric realization of a simplicial set
The *singular simplicial set* `TopCat.toSSet.obj X` of a topological space `X`
has `n`-simplices which identify to continuous maps `stdSimplex ℝ (Fin (n + 1)) → X`,
where `stdSimplex ℝ (Fin (n + 1))` is the standard topological `n`-simplex,
defined as the subtype of `Fin (n + 1) → ℝ` consisting of functions `f`
such that `0 ≤ f i` for all `i` and `∑ i, f i = 1`.
The *geometric realization* functor `SSet.toTop` is left adjoint to `TopCat.toSSet`.
It is the left Kan extension of `SimplexCategory.toTop` along the Yoneda embedding.
## Main definitions
* `TopCat.toSSet : TopCat ⥤ SSet` is the functor
assigning the singular simplicial set to a topological space.
* `SSet.toTop : SSet ⥤ TopCat` is the functor
assigning the geometric realization to a simplicial set.
* `sSetTopAdj : SSet.toTop ⊣ TopCat.toSSet` is the adjunction between these two functors.
## TODO (@joelriou)
- Show that the singular simplicial set is a Kan complex.
- Show the adjunction `sSetTopAdj` is a Quillen equivalence.
-/
universe u
open CategoryTheory
/-- The functor associating the *singular simplicial set* to a topological space.
Let `X : TopCat.{u}` be a topological space.
Then the singular simplicial set of `X`
has as `n`-simplices the continuous maps `ULift.{u} (stdSimplex ℝ (Fin (n + 1))) → X`.
Here, `stdSimplex ℝ (Fin (n + 1))` is the standard topological `n`-simplex,
defined as `{ f : Fin (n + 1) → ℝ // (∀ i, 0 ≤ f i) ∧ ∑ i, f i = 1 }` with its subspace topology. -/
noncomputable def TopCat.toSSet : TopCat.{u} ⥤ SSet.{u} :=
Presheaf.restrictedULiftYoneda.{0} SimplexCategory.toTop.{u}
/-- If `X : TopCat.{u}` and `n : SimplexCategoryᵒᵖ`,
then `(toSSet.obj X).obj n` identifies to the type of continuous
maps from the standard simplex `stdSimplex ℝ (Fin (n.unop.len + 1))` to `X`. -/
noncomputable def TopCat.toSSetObjEquiv (X : TopCat.{u}) (n : SimplexCategoryᵒᵖ) :
(toSSet.obj X).obj n ≃ C(stdSimplex ℝ (Fin (n.unop.len + 1)), X) :=
Equiv.ulift.{0}.trans (ConcreteCategory.homEquiv.trans
(Homeomorph.ulift.continuousMapCongr (.refl _)))
/-- The *geometric realization functor* is
the left Kan extension of `SimplexCategory.toTop` along the Yoneda embedding.
It is left adjoint to `TopCat.toSSet`, as witnessed by `sSetTopAdj`. -/
noncomputable def SSet.toTop : SSet.{u} ⥤ TopCat.{u} :=
stdSimplex.{u}.leftKanExtension SimplexCategory.toTop
/-- Geometric realization is left adjoint to the singular simplicial set construction. -/
noncomputable def sSetTopAdj : SSet.toTop.{u} ⊣ TopCat.toSSet.{u} :=
Presheaf.uliftYonedaAdjunction
(SSet.stdSimplex.{u}.leftKanExtension SimplexCategory.toTop)
(SSet.stdSimplex.{u}.leftKanExtensionUnit SimplexCategory.toTop)
/-- The geometric realization of the representable simplicial sets agree
with the usual topological simplices. -/
noncomputable def SSet.toTopSimplex :
SSet.stdSimplex.{u} ⋙ SSet.toTop ≅ SimplexCategory.toTop :=
Presheaf.isExtensionAlongULiftYoneda _
instance : SSet.toTop.{u}.IsLeftKanExtension SSet.toTopSimplex.inv :=
inferInstanceAs (Functor.IsLeftKanExtension _
(SSet.stdSimplex.{u}.leftKanExtensionUnit SimplexCategory.toTop.{u}))
/-- The singular simplicial set of a totally disconnected space is the constant simplicial set. -/
noncomputable def TopCat.toSSetIsoConst (X : TopCat.{u}) [TotallyDisconnectedSpace X] :
TopCat.toSSet.obj X ≅ (Functor.const _).obj X :=
(NatIso.ofComponents (fun n ↦ Equiv.toIso
((TotallyDisconnectedSpace.continuousMapEquivOfConnectedSpace _ X).symm.trans
(X.toSSetObjEquiv n).symm))).symm |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/RelativeCellComplex/AttachCells.lean | import Mathlib.CategoryTheory.MorphismProperty.Limits
/-!
# Attaching cells
Given a family of morphisms `g a : A a ⟶ B a` and a morphism `f : X₁ ⟶ X₂`,
we introduce a structure `AttachCells g f` which expresses that `X₂`
is obtained from `X₁` by attaching cells of the form `g a`. It means that
there is a pushout diagram of the form
```
⨿ i, A (π i) -----> X₁
| |f
v v
⨿ i, B (π i) -----> X₂
```
In other words, the morphism `f` is a pushout of coproducts of morphisms
of the form `g a : A a ⟶ B a`, see `nonempty_attachCells_iff`.
See the file `Mathlib/AlgebraicTopology/RelativeCellComplex/Basic.lean` for transfinite compositions
of morphisms `f` with `AttachCells g f` structures.
-/
universe w' w t t' v u
open CategoryTheory Limits
namespace HomotopicalAlgebra
variable {C : Type u} [Category.{v} C]
{α : Type t} {A B : α → C} (g : ∀ a, A a ⟶ B a)
{X₁ X₂ : C} (f : X₁ ⟶ X₂)
/-- Given a family of morphisms `g a : A a ⟶ B a` and a morphism `f : X₁ ⟶ X₂`,
this structure contains the data and properties which expresses that `X₂`
is obtained from `X₁` by attaching cells of the form `g a`. -/
structure AttachCells where
/-- the index type of the cells -/
ι : Type w
/-- for each `i : ι`, we shall attach a cell given by the morphism `g (π i)`. -/
π : ι → α
/-- a colimit cofan which gives the coproduct of the object `A (π i)` -/
cofan₁ : Cofan (fun i ↦ A (π i))
/-- a colimit cofan which gives the coproduct of the object `B (π i)` -/
cofan₂ : Cofan (fun i ↦ B (π i))
/-- `cofan₁` is colimit -/
isColimit₁ : IsColimit cofan₁
/-- `cofan₂` is colimit -/
isColimit₂ : IsColimit cofan₂
/-- the coproduct of the maps `g (π i) : A (π i) ⟶ B (π i)` for all `i : ι`. -/
m : cofan₁.pt ⟶ cofan₂.pt
hm (i : ι) : cofan₁.inj i ≫ m = g (π i) ≫ cofan₂.inj i := by cat_disch
/-- the top morphism of the pushout square -/
g₁ : cofan₁.pt ⟶ X₁
/-- the bottom morphism of the pushout square -/
g₂ : cofan₂.pt ⟶ X₂
isPushout : IsPushout g₁ m f g₂
namespace AttachCells
open MorphismProperty
attribute [reassoc (attr := simp)] hm
variable {g f} (c : AttachCells.{w} g f)
include c
lemma pushouts_coproducts : (coproducts.{w} (ofHoms g)).pushouts f := by
refine ⟨_, _, _, _, _, ?_, c.isPushout⟩
have : c.m = c.isColimit₁.desc
(Cocone.mk _ (Discrete.natTrans (fun ⟨i⟩ ↦ by exact g (c.π i)) ≫ c.cofan₂.ι)) :=
c.isColimit₁.hom_ext (fun ⟨i⟩ ↦ by rw [IsColimit.fac]; exact c.hm i)
rw [this, coproducts_iff]
exact ⟨c.ι, ⟨_, _, _, _, c.isColimit₁, c.isColimit₂, _, fun i ↦ ⟨_⟩⟩⟩
/-- The inclusion of a cell. -/
def cell (i : c.ι) : B (c.π i) ⟶ X₂ := c.cofan₂.inj i ≫ c.g₂
@[reassoc]
lemma cell_def (i : c.ι) : c.cell i = c.cofan₂.inj i ≫ c.g₂ := rfl
lemma hom_ext {Z : C} {φ φ' : X₂ ⟶ Z}
(h₀ : f ≫ φ = f ≫ φ') (h : ∀ i, c.cell i ≫ φ = c.cell i ≫ φ') :
φ = φ' := by
apply c.isPushout.hom_ext h₀
apply Cofan.IsColimit.hom_ext c.isColimit₂
simpa [cell_def] using h
/-- If `f` and `f'` are isomorphic morphisms and the target of `f`
is obtained by attaching cells to the source of `f`,
then the same holds for `f'`. -/
@[simps]
def ofArrowIso {Y₁ Y₂ : C} {f' : Y₁ ⟶ Y₂} (e : Arrow.mk f ≅ Arrow.mk f') :
AttachCells.{w} g f' where
ι := c.ι
π := c.π
cofan₁ := c.cofan₁
cofan₂ := c.cofan₂
isColimit₁ := c.isColimit₁
isColimit₂ := c.isColimit₂
m := c.m
g₁ := c.g₁ ≫ Arrow.leftFunc.map e.hom
g₂ := c.g₂ ≫ Arrow.rightFunc.map e.hom
isPushout :=
c.isPushout.of_iso (Iso.refl _) (Arrow.leftFunc.mapIso e) (Iso.refl _)
(Arrow.rightFunc.mapIso e) (by simp) (by simp) (by simp) (by simp)
/-- This definition allows the replacement of the `ι` field of
a `AttachCells g f` structure by an equivalent type. -/
@[simps]
def reindex {ι' : Type w'} (e : ι' ≃ c.ι) :
AttachCells.{w'} g f where
ι := ι'
π i' := c.π (e i')
cofan₁ := Cofan.mk c.cofan₁.pt (fun i' ↦ c.cofan₁.inj (e i'))
cofan₂ := Cofan.mk c.cofan₂.pt (fun i' ↦ c.cofan₂.inj (e i'))
isColimit₁ := IsColimit.whiskerEquivalence (c.isColimit₁) (Discrete.equivalence e)
isColimit₂ := IsColimit.whiskerEquivalence (c.isColimit₂) (Discrete.equivalence e)
m := c.m
g₁ := c.g₁
g₂ := c.g₂
hm i' := c.hm (e i')
isPushout := c.isPushout
section
variable {α' : Type t'} {A' B' : α' → C} (g' : ∀ i', A' i' ⟶ B' i')
(a : α → α') (ha : ∀ (i : α), Arrow.mk (g i) ≅ Arrow.mk (g' (a i)))
/-- If a family of maps `g` is contained in another family `g'` (up to isomorphisms),
if `f : X₁ ⟶ X₂` is a morphism, and `X₂` is obtained from `X₁` by attaching cells
of the form `g`, then it is also obtained by attaching cells of the form `g'`. -/
def reindexCellTypes : AttachCells g' f where
ι := c.ι
π := a ∘ c.π
cofan₁ := Cofan.mk c.cofan₁.pt
(fun i ↦ Arrow.leftFunc.map (ha (c.π i)).inv ≫ c.cofan₁.inj i)
cofan₂ := Cofan.mk c.cofan₂.pt
(fun i ↦ Arrow.rightFunc.map (ha (c.π i)).inv ≫ c.cofan₂.inj i)
isColimit₁ := by
let e : Discrete.functor (fun i ↦ A (c.π i)) ≅
Discrete.functor (fun i ↦ A' (a (c.π i))) :=
Discrete.natIso (fun ⟨i⟩ ↦ Arrow.leftFunc.mapIso (ha (c.π i)))
refine (IsColimit.precomposeHomEquiv e _).1
(IsColimit.ofIsoColimit c.isColimit₁ (Cofan.ext (Iso.refl _) (fun i ↦ ?_)))
simp [Cocones.precompose, e, Cofan.inj]
isColimit₂ := by
let e : Discrete.functor (fun i ↦ B (c.π i)) ≅
Discrete.functor (fun i ↦ B' (a (c.π i))) :=
Discrete.natIso (fun ⟨i⟩ ↦ Arrow.rightFunc.mapIso (ha (c.π i)))
refine (IsColimit.precomposeHomEquiv e _).1
(IsColimit.ofIsoColimit c.isColimit₂ (Cofan.ext (Iso.refl _) (fun i ↦ ?_)))
simp [Cocones.precompose, e, Cofan.inj]
m := c.m
g₁ := c.g₁
g₂ := c.g₂
isPushout := c.isPushout
end
end AttachCells
open MorphismProperty in
lemma nonempty_attachCells_iff :
Nonempty (AttachCells.{w} g f) ↔ (coproducts.{w} (ofHoms g)).pushouts f := by
constructor
· rintro ⟨c⟩
exact c.pushouts_coproducts
· rintro ⟨Y₁, Y₂, m, g₁, g₂, h, sq⟩
rw [coproducts_iff] at h
obtain ⟨ι, ⟨F₁, F₂, c₁, c₂, h₁, h₂, φ, hφ⟩⟩ := h
let π (i : ι) : α := ((ofHoms_iff _ _).1 (hφ ⟨i⟩)).choose
let e (i : ι) : Arrow.mk (φ.app ⟨i⟩) ≅ Arrow.mk (g (π i)) :=
eqToIso (((ofHoms_iff _ _).1 (hφ ⟨i⟩)).choose_spec)
let e₁ (i : ι) : F₁.obj ⟨i⟩ ≅ A (π i) := Arrow.leftFunc.mapIso (e i)
let e₂ (i : ι) : F₂.obj ⟨i⟩ ≅ B (π i) := Arrow.rightFunc.mapIso (e i)
exact ⟨{
ι := ι
π := π
cofan₁ := Cofan.mk c₁.pt (fun i ↦ (e₁ i).inv ≫ c₁.ι.app ⟨i⟩)
cofan₂ := Cofan.mk c₂.pt (fun i ↦ (e₂ i).inv ≫ c₂.ι.app ⟨i⟩)
isColimit₁ :=
(IsColimit.precomposeHomEquiv (Discrete.natIso (fun ⟨i⟩ ↦ e₁ i)) _).1
(IsColimit.ofIsoColimit h₁ (Cocones.ext (Iso.refl _) (by simp)))
isColimit₂ :=
(IsColimit.precomposeHomEquiv (Discrete.natIso (fun ⟨i⟩ ↦ e₂ i)) _).1
(IsColimit.ofIsoColimit h₂ (Cocones.ext (Iso.refl _) (by simp)))
hm i := by simp [e₁, e₂]
isPushout := sq, .. }⟩
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/RelativeCellComplex/Basic.lean | import Mathlib.AlgebraicTopology.RelativeCellComplex.AttachCells
import Mathlib.CategoryTheory.MorphismProperty.TransfiniteComposition
/-!
# Relative cell complexes
In this file, we define a structure `RelativeCellComplex` which expresses
that a morphism `f : X ⟶ Y` is a transfinite composition of morphisms,
all of which consist in attaching cells. Here, we allow a different
family of authorized cells at each step. For example, (relative)
CW-complexes are defined in the file `Mathlib/Topology/CWComplex/Abstract/Basic.lean`
by requiring that at the `n`th step, we attach `n`-disks along their
boundaries.
This structure `RelativeCellComplex` is also used in the
formalization of the small object argument,
see the file `Mathlib/CategoryTheory/SmallObject/IsCardinalForSmallObjectArgument.lean`.
## References
* https://ncatlab.org/nlab/show/small+object+argument
-/
universe w w' t v u
open CategoryTheory
namespace HomotopicalAlgebra
variable {C : Type u} [Category.{v} C]
{J : Type w'} [LinearOrder J] [OrderBot J] [SuccOrder J] [WellFoundedLT J]
{α : J → Type t} {A B : (j : J) → α j → C}
(basicCell : (j : J) → (i : α j) → A j i ⟶ B j i) {X Y : C} (f : X ⟶ Y)
/-- Let `J` be a well-ordered type. Assume that for each `j : J`, we
have a family `basicCell j` of morphisms. A relative cell complex
is a morphism `f : X ⟶ Y` which is a transfinite composition of morphisms
in such a way that at the step `j : J`, we attach cells in the family `basicCell j`. -/
structure RelativeCellComplex
extends TransfiniteCompositionOfShape J f where
/-- If `j` is not the maximum element, `F.obj (Order.succ j)` is obtained
from `F.obj j` by attaching cells in the family of morphisms `basicCell j`. -/
attachCells (j : J) (hj : ¬ IsMax j) :
AttachCells.{w} (basicCell j) (F.map (homOfLE (Order.le_succ j)))
namespace RelativeCellComplex
variable {basicCell f} (c : RelativeCellComplex basicCell f)
/-- The index type of cells in a relative cell complex. -/
structure Cells where
/-- the step where the cell is added -/
j : J
hj : ¬ IsMax j
/-- the index of the cell -/
k : (c.attachCells j hj).ι
variable {c} in
/-- Given a cell `γ` in a relative cell complex, this is the corresponding
index in the family of morphisms `basicCell γ.j`. -/
def Cells.i (γ : Cells c) : α γ.j := (c.attachCells γ.j γ.hj).π γ.k
variable {c} in
/-- The inclusion of a cell. -/
def Cells.ι (γ : Cells c) : B γ.j γ.i ⟶ Y :=
(c.attachCells γ.j γ.hj).cell γ.k ≫ c.incl.app (Order.succ γ.j)
lemma hom_ext {Z : C} {φ₁ φ₂ : Y ⟶ Z} (h₀ : f ≫ φ₁ = f ≫ φ₂)
(h : ∀ (γ : Cells c), γ.ι ≫ φ₁ = γ.ι ≫ φ₂) :
φ₁ = φ₂ := by
refine c.isColimit.hom_ext (fun j ↦ ?_)
dsimp
induction j using SuccOrder.limitRecOn with
| isMin j hj =>
obtain rfl := hj.eq_bot
simpa [← cancel_epi c.isoBot.inv] using h₀
| succ j hj hj' =>
apply (c.attachCells j hj).hom_ext
· simpa using hj'
· intro i
simpa only [Category.assoc, Cells.ι] using h ({ hj := hj, k := i, .. })
| isSuccLimit j hj hj' =>
exact (c.F.isColimitOfIsWellOrderContinuous j hj).hom_ext
(fun ⟨k, hk⟩ ↦ by simpa using hj' k hk)
open MorphismProperty in
/-- If `f` is a relative cell complex with respect to a constant
family of morphisms `g`, then `f` is a transfinite composition
of pushouts of coproducts of morphisms in the family `g`. -/
@[simps toTransfiniteCompositionOfShape]
def transfiniteCompositionOfShape
{α : Type*} {A B : α → C} (g : (i : α) → (A i ⟶ B i))
(c : RelativeCellComplex.{w} (fun (_ : J) ↦ g) f) :
(coproducts.{w} (ofHoms g)).pushouts.TransfiniteCompositionOfShape J f where
toTransfiniteCompositionOfShape := c.toTransfiniteCompositionOfShape
map_mem j hj := (c.attachCells j hj).pushouts_coproducts
end RelativeCellComplex
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Normalized.lean | import Mathlib.AlgebraicTopology.DoldKan.FunctorN
/-!
# Comparison with the normalized Moore complex functor
In this file, we show that when the category `A` is abelian,
there is an isomorphism `N₁_iso_normalizedMooreComplex_comp_toKaroubi` between
the functor `N₁ : SimplicialObject A ⥤ Karoubi (ChainComplex A ℕ)`
defined in `FunctorN.lean` and the composition of
`normalizedMooreComplex A` with the inclusion
`ChainComplex A ℕ ⥤ Karoubi (ChainComplex A ℕ)`.
This isomorphism shall be used in `Equivalence.lean` in order to obtain
the Dold-Kan equivalence
`CategoryTheory.Abelian.DoldKan.equivalence : SimplicialObject A ≌ ChainComplex A ℕ`
with a functor (definitionally) equal to `normalizedMooreComplex A`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Subobject CategoryTheory.Idempotents DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
universe v
variable {A : Type*} [Category A] [Abelian A] {X : SimplicialObject A}
theorem HigherFacesVanish.inclusionOfMooreComplexMap (n : ℕ) :
HigherFacesVanish (n + 1) ((inclusionOfMooreComplexMap X).f (n + 1)) := fun j _ => by
dsimp [AlgebraicTopology.inclusionOfMooreComplexMap, NormalizedMooreComplex.objX]
rw [← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ j
(by simp only [Finset.mem_univ])), assoc, kernelSubobject_arrow_comp, comp_zero]
theorem factors_normalizedMooreComplex_PInfty (n : ℕ) :
Subobject.Factors (NormalizedMooreComplex.objX X n) (PInfty.f n) := by
rcases n with _ | n
· apply top_factors
· rw [PInfty_f, NormalizedMooreComplex.objX, finset_inf_factors]
intro i _
apply kernelSubobject_factors
exact (HigherFacesVanish.of_P (n + 1) n) i le_add_self
/-- `PInfty` factors through the normalized Moore complex -/
@[simps!]
def PInftyToNormalizedMooreComplex (X : SimplicialObject A) : K[X] ⟶ N[X] :=
ChainComplex.ofHom _ _ _ _ _ _
(fun n => factorThru _ _ (factors_normalizedMooreComplex_PInfty n)) fun n => by
rw [← cancel_mono (NormalizedMooreComplex.objX X n).arrow, assoc, assoc, factorThru_arrow,
← inclusionOfMooreComplexMap_f, ← normalizedMooreComplex_objD,
← (inclusionOfMooreComplexMap X).comm (n + 1) n, inclusionOfMooreComplexMap_f,
factorThru_arrow_assoc, ← alternatingFaceMapComplex_obj_d]
exact PInfty.comm (n + 1) n
@[reassoc (attr := simp)]
theorem PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap (X : SimplicialObject A) :
PInftyToNormalizedMooreComplex X ≫ inclusionOfMooreComplexMap X = PInfty := by cat_disch
@[reassoc (attr := simp)]
theorem PInftyToNormalizedMooreComplex_naturality {X Y : SimplicialObject A} (f : X ⟶ Y) :
AlternatingFaceMapComplex.map f ≫ PInftyToNormalizedMooreComplex Y =
PInftyToNormalizedMooreComplex X ≫ NormalizedMooreComplex.map f := by
cat_disch
@[reassoc (attr := simp)]
theorem PInfty_comp_PInftyToNormalizedMooreComplex (X : SimplicialObject A) :
PInfty ≫ PInftyToNormalizedMooreComplex X = PInftyToNormalizedMooreComplex X := by cat_disch
@[reassoc (attr := simp)]
theorem inclusionOfMooreComplexMap_comp_PInfty (X : SimplicialObject A) :
inclusionOfMooreComplexMap X ≫ PInfty = inclusionOfMooreComplexMap X := by
ext (_ | n)
· dsimp
simp only [comp_id]
· exact (HigherFacesVanish.inclusionOfMooreComplexMap n).comp_P_eq_self
instance : Mono (inclusionOfMooreComplexMap X) :=
⟨fun _ _ hf => by
ext n
dsimp
ext
exact HomologicalComplex.congr_hom hf n⟩
/-- `inclusionOfMooreComplexMap X` is a split mono. -/
def splitMonoInclusionOfMooreComplexMap (X : SimplicialObject A) :
SplitMono (inclusionOfMooreComplexMap X) where
retraction := PInftyToNormalizedMooreComplex X
id := by
simp only [← cancel_mono (inclusionOfMooreComplexMap X), assoc, id_comp,
PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap,
inclusionOfMooreComplexMap_comp_PInfty]
variable (A)
/-- When the category `A` is abelian,
the functor `N₁ : SimplicialObject A ⥤ Karoubi (ChainComplex A ℕ)` defined
using `PInfty` identifies to the composition of the normalized Moore complex functor
and the inclusion in the Karoubi envelope. -/
def N₁_iso_normalizedMooreComplex_comp_toKaroubi : N₁ ≅ normalizedMooreComplex A ⋙ toKaroubi _ where
hom :=
{ app := fun X => { f := PInftyToNormalizedMooreComplex X } }
inv :=
{ app := fun X => { f := inclusionOfMooreComplexMap X } }
hom_inv_id := by
ext X : 3
simp only [PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap,
NatTrans.comp_app, Karoubi.comp_f, N₁_obj_p, NatTrans.id_app, Karoubi.id_f]
inv_hom_id := by
ext X : 3
rw [← cancel_mono (inclusionOfMooreComplexMap X)]
simp only [NatTrans.comp_app, Karoubi.comp_f, assoc, NatTrans.id_app, Karoubi.id_f,
PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap,
inclusionOfMooreComplexMap_comp_PInfty]
dsimp only [Functor.comp_obj, toKaroubi]
rw [id_comp]
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Decomposition.lean | import Mathlib.AlgebraicTopology.DoldKan.PInfty
/-!
# Decomposition of the Q endomorphisms
In this file, we obtain a lemma `decomposition_Q` which expresses
explicitly the projection `(Q q).f (n+1) : X _⦋n+1⦌ ⟶ X _⦋n+1⦌`
(`X : SimplicialObject C` with `C` a preadditive category) as
a sum of terms which are postcompositions with degeneracies.
(TODO @joelriou: when `C` is abelian, define the degenerate
subcomplex of the alternating face map complex of `X` and show
that it is a complement to the normalized Moore complex.)
Then, we introduce an ad hoc structure `MorphComponents X n Z` which
can be used in order to define morphisms `X _⦋n+1⦌ ⟶ Z` using the
decomposition provided by `decomposition_Q`. This shall play a critical
role in the proof that the functor
`N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ))`
reflects isomorphisms.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive
Opposite Simplicial
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X X' : SimplicialObject C}
/-- In each positive degree, this lemma decomposes the idempotent endomorphism
`Q q` as a sum of morphisms which are postcompositions with suitable degeneracies.
As `Q q` is the complement projection to `P q`, this implies that in the case of
simplicial abelian groups, any $(n+1)$-simplex $x$ can be decomposed as
$x = x' + \sum (i=0}^{q-1} σ_{n-i}(y_i)$ where $x'$ is in the image of `P q` and
the $y_i$ are in degree $n$. -/
theorem decomposition_Q (n q : ℕ) :
((Q q).f (n + 1) : X _⦋n + 1⦌ ⟶ X _⦋n + 1⦌) =
∑ i : Fin (n + 1) with i.val < q, (P i).f (n + 1) ≫ X.δ i.rev.succ ≫ X.σ (Fin.rev i) := by
induction q with
| zero =>
simp only [Q_zero, HomologicalComplex.zero_f_apply, Nat.not_lt_zero,
Finset.filter_false, Finset.sum_empty]
| succ q hq =>
by_cases! hqn : n < q
· rw [Q_is_eventually_constant (show n + 1 ≤ q by cutsat), hq]
congr 1
ext ⟨x, hx⟩
simp_rw [Finset.mem_filter_univ]
cutsat
· obtain ⟨a, ha⟩ := Nat.le.dest hqn
rw [Q_succ, HomologicalComplex.sub_f_apply, HomologicalComplex.comp_f, hq]
symm
conv_rhs => rw [sub_eq_add_neg, add_comm]
let q' : Fin (n + 1) := ⟨q, Nat.lt_succ_of_le hqn⟩
rw [← @Finset.add_sum_erase _ _ _ _ _ _ q' (by simp [q'])]
congr
· have hnaq' : n = a + q := by omega
simp only [(HigherFacesVanish.of_P q n).comp_Hσ_eq hnaq', q'.rev_eq hnaq', neg_neg]
rfl
· ext ⟨i, hi⟩
simp_rw [Finset.mem_erase, Finset.mem_filter_univ, q', ne_eq, Fin.mk.injEq]
cutsat
variable (X)
/-- The structure `MorphComponents` is an ad hoc structure that is used in
the proof that `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ))`
reflects isomorphisms. The fields are the data that are needed in order to
construct a morphism `X _⦋n+1⦌ ⟶ Z` (see `φ`) using the decomposition of the
identity given by `decomposition_Q n (n+1)`. -/
@[ext]
structure MorphComponents (n : ℕ) (Z : C) where
a : X _⦋n + 1⦌ ⟶ Z
b : Fin (n + 1) → (X _⦋n⦌ ⟶ Z)
namespace MorphComponents
variable {X} {n : ℕ} {Z Z' : C} (f : MorphComponents X n Z) (g : X' ⟶ X) (h : Z ⟶ Z')
/-- The morphism `X _⦋n+1⦌ ⟶ Z` associated to `f : MorphComponents X n Z`. -/
def φ {Z : C} (f : MorphComponents X n Z) : X _⦋n + 1⦌ ⟶ Z :=
PInfty.f (n + 1) ≫ f.a + ∑ i : Fin (n + 1), (P i).f (n + 1) ≫ X.δ i.rev.succ ≫
f.b (Fin.rev i)
variable (X n)
/-- the canonical `MorphComponents` whose associated morphism is the identity
(see `F_id`) thanks to `decomposition_Q n (n+1)` -/
@[simps]
def id : MorphComponents X n (X _⦋n + 1⦌) where
a := PInfty.f (n + 1)
b i := X.σ i
@[simp]
theorem id_φ : (id X n).φ = 𝟙 _ := by
simp only [← P_add_Q_f (n + 1) (n + 1), φ]
congr 1
· simp only [id, PInfty_f, P_f_idem]
· exact Eq.trans (by simp) (decomposition_Q n (n + 1)).symm
variable {X n}
/-- A `MorphComponents` can be postcomposed with a morphism. -/
@[simps]
def postComp : MorphComponents X n Z' where
a := f.a ≫ h
b i := f.b i ≫ h
@[simp]
theorem postComp_φ : (f.postComp h).φ = f.φ ≫ h := by
unfold φ postComp
simp only [add_comp, sum_comp, assoc]
/-- A `MorphComponents` can be precomposed with a morphism of simplicial objects. -/
@[simps]
def preComp : MorphComponents X' n Z where
a := g.app (op ⦋n + 1⦌) ≫ f.a
b i := g.app (op ⦋n⦌) ≫ f.b i
@[simp]
theorem preComp_φ : (f.preComp g).φ = g.app (op ⦋n + 1⦌) ≫ f.φ := by
unfold φ preComp
simp only [PInfty_f, comp_add]
congr 1
· simp only [P_f_naturality_assoc]
· simp only [comp_sum, P_f_naturality_assoc, SimplicialObject.δ_naturality_assoc]
end MorphComponents
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/FunctorGamma.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Split
import Mathlib.AlgebraicTopology.DoldKan.PInfty
/-!
# Construction of the inverse functor of the Dold-Kan equivalence
In this file, we construct the functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`
which shall be the inverse functor of the Dold-Kan equivalence in the case of abelian categories,
and more generally pseudoabelian categories.
By definition, when `K` is a chain_complex, `Γ₀.obj K` is a simplicial object which
sends `Δ : SimplexCategoryᵒᵖ` to a certain coproduct indexed by the set
`Splitting.IndexSet Δ` whose elements consists of epimorphisms `e : Δ.unop ⟶ Δ'.unop`
(with `Δ' : SimplexCategoryᵒᵖ`); the summand attached to such an `e` is `K.X Δ'.unop.len`.
By construction, `Γ₀.obj K` is a split simplicial object whose splitting is `Γ₀.splitting K`.
We also construct `Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)`
which shall be an equivalence for any additive category `C`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits SimplexCategory
SimplicialObject Opposite CategoryTheory.Idempotents Simplicial DoldKan
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] (K K' : ChainComplex C ℕ) (f : K ⟶ K')
{Δ Δ' Δ'' : SimplexCategory}
/-- `Isδ₀ i` is a simple condition used to check whether a monomorphism `i` in
`SimplexCategory` identifies to the coface map `δ 0`. -/
@[nolint unusedArguments]
def Isδ₀ {Δ Δ' : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] : Prop :=
Δ.len = Δ'.len + 1 ∧ i.toOrderHom 0 ≠ 0
namespace Isδ₀
theorem iff {j : ℕ} {i : Fin (j + 2)} : Isδ₀ (SimplexCategory.δ i) ↔ i = 0 := by
constructor
· rintro ⟨_, h₂⟩
by_contra h
exact h₂ (Fin.succAbove_ne_zero_zero h)
· rintro rfl
exact ⟨rfl, by dsimp; exact Fin.succ_ne_zero (0 : Fin (j + 1))⟩
theorem eq_δ₀ {n : ℕ} {i : ⦋n⦌ ⟶ ⦋n + 1⦌} [Mono i] (hi : Isδ₀ i) :
i = SimplexCategory.δ 0 := by
obtain ⟨j, rfl⟩ := SimplexCategory.eq_δ_of_mono i
rw [iff] at hi
rw [hi]
end Isδ₀
namespace Γ₀
namespace Obj
/-- In the definition of `(Γ₀.obj K).obj Δ` as a direct sum indexed by `A : Splitting.IndexSet Δ`,
the summand `summand K Δ A` is `K.X A.1.len`. -/
def summand (Δ : SimplexCategoryᵒᵖ) (A : Splitting.IndexSet Δ) : C :=
K.X A.1.unop.len
/-- The functor `Γ₀` sends a chain complex `K` to the simplicial object which
sends `Δ` to the direct sum of the objects `summand K Δ A` for all `A : Splitting.IndexSet Δ` -/
def obj₂ (K : ChainComplex C ℕ) (Δ : SimplexCategoryᵒᵖ) [HasFiniteCoproducts C] : C :=
∐ fun A : Splitting.IndexSet Δ => summand K Δ A
namespace Termwise
/-- A monomorphism `i : Δ' ⟶ Δ` induces a morphism `K.X Δ.len ⟶ K.X Δ'.len` which
is the identity if `Δ = Δ'`, the differential on the complex `K` if `i = δ 0`, and
zero otherwise. -/
def mapMono (K : ChainComplex C ℕ) {Δ' Δ : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] :
K.X Δ.len ⟶ K.X Δ'.len := by
by_cases Δ = Δ'
· exact eqToHom (by congr)
· by_cases Isδ₀ i
· exact K.d Δ.len Δ'.len
· exact 0
variable (Δ) in
theorem mapMono_id : mapMono K (𝟙 Δ) = 𝟙 _ := by
unfold mapMono
simp only [eqToHom_refl, dite_eq_ite, if_true]
theorem mapMono_δ₀' (i : Δ' ⟶ Δ) [Mono i] (hi : Isδ₀ i) : mapMono K i = K.d Δ.len Δ'.len := by
unfold mapMono
suffices Δ ≠ Δ' by
simp only [dif_neg this, dif_pos hi]
rintro rfl
simpa only [left_eq_add, Nat.one_ne_zero] using hi.1
@[simp]
theorem mapMono_δ₀ {n : ℕ} : mapMono K (δ (0 : Fin (n + 2))) = K.d (n + 1) n :=
mapMono_δ₀' K _ (by rw [Isδ₀.iff])
theorem mapMono_eq_zero (i : Δ' ⟶ Δ) [Mono i] (h₁ : Δ ≠ Δ') (h₂ : ¬Isδ₀ i) : mapMono K i = 0 := by
unfold mapMono
rw [Ne] at h₁
split_ifs
rfl
variable {K K'}
@[reassoc (attr := simp)]
theorem mapMono_naturality (i : Δ ⟶ Δ') [Mono i] :
mapMono K i ≫ f.f Δ.len = f.f Δ'.len ≫ mapMono K' i := by
unfold mapMono
split_ifs with h
· subst h
simp only [id_comp, eqToHom_refl, comp_id]
· rw [HomologicalComplex.Hom.comm]
· rw [zero_comp, comp_zero]
variable (K)
@[reassoc (attr := simp)]
theorem mapMono_comp (i' : Δ'' ⟶ Δ') (i : Δ' ⟶ Δ) [Mono i'] [Mono i] :
mapMono K i ≫ mapMono K i' = mapMono K (i' ≫ i) := by
-- case where i : Δ' ⟶ Δ is the identity
by_cases h₁ : Δ = Δ'
· subst h₁
simp only [SimplexCategory.eq_id_of_mono i, comp_id, id_comp, mapMono_id K]
-- case where i' : Δ'' ⟶ Δ' is the identity
by_cases h₂ : Δ' = Δ''
· subst h₂
simp only [SimplexCategory.eq_id_of_mono i', comp_id, id_comp, mapMono_id K]
-- then the RHS is always zero
obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i h₁)
obtain ⟨k', hk'⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i' h₂)
have eq : Δ.len = Δ''.len + (k + k' + 2) := by omega
rw [mapMono_eq_zero K (i' ≫ i) _ _]; rotate_left
· by_contra h
simp only [left_eq_add, h, add_eq_zero, and_false, reduceCtorEq] at eq
· by_contra h
simp only [h.1, add_right_inj] at eq
cutsat
-- in all cases, the LHS is also zero, either by definition, or because d ≫ d = 0
by_cases h₃ : Isδ₀ i
· by_cases h₄ : Isδ₀ i'
· rw [mapMono_δ₀' K i h₃, mapMono_δ₀' K i' h₄, HomologicalComplex.d_comp_d]
· simp only [mapMono_eq_zero K i' h₂ h₄, comp_zero]
· simp only [mapMono_eq_zero K i h₁ h₃, zero_comp]
end Termwise
variable [HasFiniteCoproducts C]
/-- The simplicial morphism on the simplicial object `Γ₀.obj K` induced by
a morphism `Δ' → Δ` in `SimplexCategory` is defined on each summand
associated to an `A : Splitting.IndexSet Δ` in terms of the epi-mono factorisation
of `θ ≫ A.e`. -/
def map (K : ChainComplex C ℕ) {Δ' Δ : SimplexCategoryᵒᵖ} (θ : Δ ⟶ Δ') : obj₂ K Δ ⟶ obj₂ K Δ' :=
Sigma.desc fun A =>
Termwise.mapMono K (image.ι (θ.unop ≫ A.e)) ≫ Sigma.ι (summand K Δ') (A.pull θ)
@[reassoc]
theorem map_on_summand₀ {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) {θ : Δ ⟶ Δ'}
{Δ'' : SimplexCategory} {e : Δ'.unop ⟶ Δ''} {i : Δ'' ⟶ A.1.unop} [Epi e] [Mono i]
(fac : e ≫ i = θ.unop ≫ A.e) :
Sigma.ι (summand K Δ) A ≫ map K θ =
Termwise.mapMono K i ≫ Sigma.ι (summand K Δ') (Splitting.IndexSet.mk e) := by
simp only [map, colimit.ι_desc, Cofan.mk_ι_app]
have h := SimplexCategory.image_eq fac
subst h
congr
· exact SimplexCategory.image_ι_eq fac
· dsimp only [SimplicialObject.Splitting.IndexSet.pull]
congr
exact SimplexCategory.factorThruImage_eq fac
@[reassoc]
theorem map_on_summand₀' {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) (θ : Δ ⟶ Δ') :
Sigma.ι (summand K Δ) A ≫ map K θ =
Termwise.mapMono K (image.ι (θ.unop ≫ A.e)) ≫ Sigma.ι (summand K _) (A.pull θ) :=
map_on_summand₀ K A (A.fac_pull θ)
end Obj
variable [HasFiniteCoproducts C]
/-- The functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, on objects. -/
@[simps]
def obj (K : ChainComplex C ℕ) : SimplicialObject C where
obj Δ := Obj.obj₂ K Δ
map θ := Obj.map K θ
map_id Δ := colimit.hom_ext (fun ⟨A⟩ => by
dsimp
have fac : A.e ≫ 𝟙 A.1.unop = (𝟙 Δ).unop ≫ A.e := by rw [unop_id, comp_id, id_comp]
rw [Obj.map_on_summand₀ K A fac, Obj.Termwise.mapMono_id, id_comp]
dsimp only [Obj.obj₂]
rw [comp_id]
rfl)
map_comp {Δ'' Δ' Δ} θ' θ := colimit.hom_ext (fun ⟨A⟩ => by
have fac : θ.unop ≫ θ'.unop ≫ A.e = (θ' ≫ θ).unop ≫ A.e := by rw [unop_comp, assoc]
rw [← image.fac (θ'.unop ≫ A.e), ← assoc, ←
image.fac (θ.unop ≫ factorThruImage (θ'.unop ≫ A.e)), assoc] at fac
simp only [Obj.map_on_summand₀'_assoc K A θ', Obj.map_on_summand₀' K _ θ,
Obj.Termwise.mapMono_comp_assoc, Obj.map_on_summand₀ K A fac]
rfl)
/-- By construction, the simplicial `Γ₀.obj K` is equipped with a splitting. -/
def splitting (K : ChainComplex C ℕ) : SimplicialObject.Splitting (Γ₀.obj K) where
N n := K.X n
ι n := Sigma.ι (Γ₀.Obj.summand K (op ⦋n⦌)) (Splitting.IndexSet.id (op ⦋n⦌))
isColimit' Δ := IsColimit.ofIsoColimit (colimit.isColimit _) (Cofan.ext (Iso.refl _) (by
intro A
dsimp [Splitting.cofan']
rw [comp_id, Γ₀.Obj.map_on_summand₀ K (SimplicialObject.Splitting.IndexSet.id A.1)
(show A.e ≫ 𝟙 _ = A.e.op.unop ≫ 𝟙 _ by rfl), Γ₀.Obj.Termwise.mapMono_id]
dsimp
rw [id_comp]
rfl))
@[reassoc]
theorem Obj.map_on_summand {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) (θ : Δ ⟶ Δ')
{Δ'' : SimplexCategory} {e : Δ'.unop ⟶ Δ''} {i : Δ'' ⟶ A.1.unop} [Epi e] [Mono i]
(fac : e ≫ i = θ.unop ≫ A.e) :
((Γ₀.splitting K).cofan Δ).inj A ≫ (Γ₀.obj K).map θ =
Γ₀.Obj.Termwise.mapMono K i ≫ ((Γ₀.splitting K).cofan Δ').inj (Splitting.IndexSet.mk e) := by
dsimp [Splitting.cofan]
change (_ ≫ (Γ₀.obj K).map A.e.op) ≫ (Γ₀.obj K).map θ = _
rw [assoc, ← Functor.map_comp]
dsimp [splitting]
rw [Γ₀.Obj.map_on_summand₀ K (Splitting.IndexSet.id A.1)
(show e ≫ i = ((Splitting.IndexSet.e A).op ≫ θ).unop ≫ 𝟙 _ by rw [comp_id, fac]; rfl)]
dsimp only [Splitting.IndexSet.id_fst, Splitting.IndexSet.mk, op_unop, Splitting.IndexSet.e]
rw [Γ₀.Obj.map_on_summand₀ K (Splitting.IndexSet.id (op Δ''))
(show e ≫ 𝟙 Δ'' = e.op.unop ≫ 𝟙 _ by simp), Termwise.mapMono_id]
dsimp only [Splitting.IndexSet.id_fst]
rw [id_comp]
rfl
@[reassoc]
theorem Obj.map_on_summand' {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) (θ : Δ ⟶ Δ') :
((splitting K).cofan Δ).inj A ≫ (obj K).map θ =
Obj.Termwise.mapMono K (image.ι (θ.unop ≫ A.e)) ≫
((splitting K).cofan Δ').inj (A.pull θ) := by
apply Obj.map_on_summand
apply image.fac
@[reassoc]
theorem Obj.mapMono_on_summand_id {Δ Δ' : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] :
((splitting K).cofan _).inj (Splitting.IndexSet.id (op Δ)) ≫ (obj K).map i.op =
Obj.Termwise.mapMono K i ≫ ((splitting K).cofan _).inj (Splitting.IndexSet.id (op Δ')) :=
Obj.map_on_summand K (Splitting.IndexSet.id (op Δ)) i.op (rfl : 𝟙 _ ≫ i = i ≫ 𝟙 _)
@[reassoc]
theorem Obj.map_epi_on_summand_id {Δ Δ' : SimplexCategory} (e : Δ' ⟶ Δ) [Epi e] :
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op Δ)) ≫ (Γ₀.obj K).map e.op =
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.mk e) := by
simpa only [Γ₀.Obj.map_on_summand K (Splitting.IndexSet.id (op Δ)) e.op
(rfl : e ≫ 𝟙 Δ = e ≫ 𝟙 Δ),
Γ₀.Obj.Termwise.mapMono_id] using id_comp _
/-- The functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, on morphisms. -/
@[simps]
def map {K K' : ChainComplex C ℕ} (f : K ⟶ K') : obj K ⟶ obj K' where
app Δ := (Γ₀.splitting K).desc Δ fun A => f.f A.1.unop.len ≫
((Γ₀.splitting K').cofan _).inj A
naturality {Δ' Δ} θ := by
apply (Γ₀.splitting K).hom_ext'
intro A
simp only [(splitting K).ι_desc_assoc, Obj.map_on_summand'_assoc K _ θ, (splitting K).ι_desc,
assoc, Obj.map_on_summand' K' _ θ]
apply Obj.Termwise.mapMono_naturality_assoc
end Γ₀
variable [HasFiniteCoproducts C]
/-- The functor `Γ₀' : ChainComplex C ℕ ⥤ SimplicialObject.Split C`
that induces `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, which
shall be the inverse functor of the Dold-Kan equivalence for
abelian or pseudo-abelian categories. -/
@[simps]
def Γ₀' : ChainComplex C ℕ ⥤ SimplicialObject.Split C where
obj K := SimplicialObject.Split.mk' (Γ₀.splitting K)
map {K K'} f :=
{ F := Γ₀.map f
f := f.f
comm := fun n => by
dsimp
simp only [← Splitting.cofan_inj_id, (Γ₀.splitting K).ι_desc]
rfl }
/-- The functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, which is
the inverse functor of the Dold-Kan equivalence when `C` is an abelian
category, or more generally a pseudoabelian category. -/
@[simps!]
def Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C :=
Γ₀' ⋙ Split.forget _
/-- The extension of `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`
on the idempotent completions. It shall be an equivalence of categories
for any additive category `C`. -/
@[simps!]
def Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C) :=
(CategoryTheory.Idempotents.functorExtension₂ _ _).obj Γ₀
theorem HigherFacesVanish.on_Γ₀_summand_id (K : ChainComplex C ℕ) (n : ℕ) :
@HigherFacesVanish C _ _ (Γ₀.obj K) _ n (n + 1)
(((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op ⦋n + 1⦌))) := by
intro j _
have eq := Γ₀.Obj.mapMono_on_summand_id K (SimplexCategory.δ j.succ)
rw [Γ₀.Obj.Termwise.mapMono_eq_zero K, zero_comp] at eq; rotate_left
· intro h
exact (Nat.succ_ne_self n) (congr_arg SimplexCategory.len h)
· exact fun h => Fin.succ_ne_zero j (by simpa only [Isδ₀.iff] using h)
exact eq
@[reassoc (attr := simp)]
theorem PInfty_on_Γ₀_splitting_summand_eq_self (K : ChainComplex C ℕ) {n : ℕ} :
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op ⦋n⦌)) ≫
(PInfty : K[Γ₀.obj K] ⟶ _).f n =
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op ⦋n⦌)) := by
rw [PInfty_f]
rcases n with _ | n
· simpa only [P_f_0_eq] using comp_id _
· exact (HigherFacesVanish.on_Γ₀_summand_id K n).comp_P_eq_self
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/HomotopyEquivalence.lean | import Mathlib.AlgebraicTopology.DoldKan.Normalized
/-!
# The normalized Moore complex and the alternating face map complex are homotopy equivalent
In this file, when the category `A` is abelian, we obtain the homotopy equivalence
`homotopyEquivNormalizedMooreComplexAlternatingFaceMapComplex` between the
normalized Moore complex and the alternating face map complex of a simplicial object in `A`.
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Preadditive Simplicial DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] (X : SimplicialObject C)
/-- Inductive construction of homotopies from `P q` to `𝟙 _` -/
noncomputable def homotopyPToId : ∀ q : ℕ, Homotopy (P q : K[X] ⟶ _) (𝟙 _)
| 0 => Homotopy.refl _
| q + 1 => by
refine
Homotopy.trans (Homotopy.ofEq ?_)
(Homotopy.trans
(Homotopy.add (homotopyPToId q) (Homotopy.compLeft (homotopyHσToZero q) (P q)))
(Homotopy.ofEq ?_))
· simp only [P_succ, comp_add, comp_id]
· simp only [add_zero, comp_zero]
/-- The complement projection `Q q` to `P q` is homotopic to zero. -/
def homotopyQToZero (q : ℕ) : Homotopy (Q q : K[X] ⟶ _) 0 :=
Homotopy.equivSubZero.toFun (homotopyPToId X q).symm
theorem homotopyPToId_eventually_constant {q n : ℕ} (hqn : n < q) :
((homotopyPToId X (q + 1)).hom n (n + 1) : X _⦋n⦌ ⟶ X _⦋n + 1⦌) =
(homotopyPToId X q).hom n (n + 1) := by
simp only [homotopyHσToZero, AlternatingFaceMapComplex.obj_X, Homotopy.trans_hom,
Homotopy.ofEq_hom, Pi.zero_apply, Homotopy.add_hom, Homotopy.compLeft_hom, add_zero,
Homotopy.nullHomotopy'_hom, ComplexShape.down_Rel, hσ'_eq_zero hqn (c_mk (n + 1) n rfl),
dite_eq_ite, ite_self, comp_zero, zero_add, homotopyPToId]
/-- Construction of the homotopy from `PInfty` to the identity using eventually
(termwise) constant homotopies from `P q` to the identity for all `q` -/
@[simps]
def homotopyPInftyToId : Homotopy (PInfty : K[X] ⟶ _) (𝟙 _) where
hom i j := (homotopyPToId X (j + 1)).hom i j
zero i j hij := Homotopy.zero _ i j hij
comm n := by
rcases n with _ | n
· simpa only [Homotopy.dNext_zero_chainComplex, Homotopy.prevD_chainComplex,
PInfty_f, P_f_0_eq, zero_add] using (homotopyPToId X 2).comm 0
· simpa only [Homotopy.dNext_succ_chainComplex, Homotopy.prevD_chainComplex,
HomologicalComplex.id_f, PInfty_f, ← P_is_eventually_constant (le_refl <| n + 1),
homotopyPToId_eventually_constant X (Nat.lt_add_one (Nat.succ n)),
Homotopy.dNext_succ_chainComplex, Homotopy.prevD_chainComplex]
using (homotopyPToId X (n + 2)).comm (n + 1)
/-- The inclusion of the Moore complex in the alternating face map complex
is a homotopy equivalence -/
@[simps]
def homotopyEquivNormalizedMooreComplexAlternatingFaceMapComplex {A : Type*} [Category A]
[Abelian A] {Y : SimplicialObject A} :
HomotopyEquiv ((normalizedMooreComplex A).obj Y) ((alternatingFaceMapComplex A).obj Y) where
hom := inclusionOfMooreComplexMap Y
inv := PInftyToNormalizedMooreComplex Y
homotopyHomInvId := Homotopy.ofEq (splitMonoInclusionOfMooreComplexMap Y).id
homotopyInvHomId := Homotopy.trans
(Homotopy.ofEq (PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap Y))
(homotopyPInftyToId Y)
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/SplitSimplicialObject.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Split
import Mathlib.AlgebraicTopology.DoldKan.Degeneracies
import Mathlib.AlgebraicTopology.DoldKan.FunctorN
/-!
# Split simplicial objects in preadditive categories
In this file we define a functor `nondegComplex : SimplicialObject.Split C ⥤ ChainComplex C ℕ`
when `C` is a preadditive category with finite coproducts, and get an isomorphism
`toKaroubiNondegComplexFunctorIsoN₁ : nondegComplex ⋙ toKaroubi _ ≅ forget C ⋙ DoldKan.N₁`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Limits CategoryTheory.Category CategoryTheory.Preadditive
CategoryTheory.Idempotents Opposite AlgebraicTopology AlgebraicTopology.DoldKan
Simplicial DoldKan
namespace SimplicialObject
namespace Splitting
variable {C : Type*} [Category C] {X : SimplicialObject C}
(s : Splitting X)
/-- The projection on a summand of the coproduct decomposition given
by a splitting of a simplicial object. -/
noncomputable def πSummand [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
X.obj Δ ⟶ s.N A.1.unop.len :=
s.desc Δ (fun B => by
by_cases h : B = A
· exact eqToHom (by subst h; rfl)
· exact 0)
@[reassoc (attr := simp)]
theorem cofan_inj_πSummand_eq_id [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
(s.cofan Δ).inj A ≫ s.πSummand A = 𝟙 _ := by
simp [πSummand]
@[reassoc (attr := simp)]
theorem cofan_inj_πSummand_eq_zero [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A B : IndexSet Δ)
(h : B ≠ A) : (s.cofan Δ).inj A ≫ s.πSummand B = 0 := by
dsimp [πSummand]
rw [ι_desc, dif_neg h.symm]
variable [Preadditive C]
theorem decomposition_id (Δ : SimplexCategoryᵒᵖ) :
𝟙 (X.obj Δ) = ∑ A : IndexSet Δ, s.πSummand A ≫ (s.cofan Δ).inj A := by
apply s.hom_ext'
intro A
dsimp
erw [comp_id, comp_sum, Finset.sum_eq_single A, cofan_inj_πSummand_eq_id_assoc]
· intro B _ h₂
rw [s.cofan_inj_πSummand_eq_zero_assoc _ _ h₂, zero_comp]
· simp
@[reassoc (attr := simp)]
theorem σ_comp_πSummand_id_eq_zero {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ s.πSummand (IndexSet.id (op ⦋n + 1⦌)) = 0 := by
apply s.hom_ext'
intro A
dsimp only [SimplicialObject.σ]
rw [comp_zero, s.cofan_inj_epi_naturality_assoc A (SimplexCategory.σ i).op,
cofan_inj_πSummand_eq_zero]
rw [ne_comm]
change ¬(A.epiComp (SimplexCategory.σ i).op).EqId
rw [IndexSet.eqId_iff_len_eq]
have h := SimplexCategory.len_le_of_epi A.e
dsimp at h ⊢
cutsat
/-- If a simplicial object `X` in an additive category is split,
then `PInfty` vanishes on all the summands of `X _⦋n⦌` which do
not correspond to the identity of `⦋n⦌`. -/
theorem cofan_inj_comp_PInfty_eq_zero {X : SimplicialObject C} (s : SimplicialObject.Splitting X)
{n : ℕ} (A : SimplicialObject.Splitting.IndexSet (op ⦋n⦌)) (hA : ¬A.EqId) :
(s.cofan _).inj A ≫ PInfty.f n = 0 := by
rw [SimplicialObject.Splitting.IndexSet.eqId_iff_mono] at hA
rw [SimplicialObject.Splitting.cofan_inj_eq, assoc, degeneracy_comp_PInfty X n A.e hA, comp_zero]
theorem comp_PInfty_eq_zero_iff {Z : C} {n : ℕ} (f : Z ⟶ X _⦋n⦌) :
f ≫ PInfty.f n = 0 ↔ f ≫ s.πSummand (IndexSet.id (op ⦋n⦌)) = 0 := by
constructor
· intro h
rcases n with _ | n
· dsimp at h
rw [comp_id] at h
rw [h, zero_comp]
· have h' := f ≫= PInfty_f_add_QInfty_f (n + 1)
dsimp at h'
rw [comp_id, comp_add, h, zero_add] at h'
rw [← h', assoc, QInfty_f, decomposition_Q, Preadditive.sum_comp, Preadditive.comp_sum,
Finset.sum_eq_zero]
intro i _
simp only [assoc, σ_comp_πSummand_id_eq_zero, comp_zero]
· intro h
rw [← comp_id f, assoc, s.decomposition_id, Preadditive.sum_comp, Preadditive.comp_sum,
Fintype.sum_eq_zero]
intro A
by_cases hA : A.EqId
· dsimp at hA
subst hA
rw [assoc, reassoc_of% h, zero_comp]
· simp only [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]
@[reassoc (attr := simp)]
theorem PInfty_comp_πSummand_id (n : ℕ) :
PInfty.f n ≫ s.πSummand (IndexSet.id (op ⦋n⦌)) = s.πSummand (IndexSet.id (op ⦋n⦌)) := by
conv_rhs => rw [← id_comp (s.πSummand _)]
symm
rw [← sub_eq_zero, ← sub_comp, ← comp_PInfty_eq_zero_iff, sub_comp, id_comp, PInfty_f_idem,
sub_self]
@[reassoc (attr := simp)]
theorem πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty (n : ℕ) :
s.πSummand (IndexSet.id (op ⦋n⦌)) ≫ (s.cofan _).inj (IndexSet.id (op ⦋n⦌)) ≫ PInfty.f n =
PInfty.f n := by
conv_rhs => rw [← id_comp (PInfty.f n)]
dsimp only [AlternatingFaceMapComplex.obj_X]
rw [s.decomposition_id, Preadditive.sum_comp]
rw [Fintype.sum_eq_single (IndexSet.id (op ⦋n⦌)), assoc]
rintro A (hA : ¬A.EqId)
rw [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]
/-- The differentials `s.d i j : s.N i ⟶ s.N j` on nondegenerate simplices of a split
simplicial object are induced by the differentials on the alternating face map complex. -/
@[simp]
noncomputable def d (i j : ℕ) : s.N i ⟶ s.N j :=
(s.cofan _).inj (IndexSet.id (op ⦋i⦌)) ≫ K[X].d i j ≫ s.πSummand (IndexSet.id (op ⦋j⦌))
theorem ιSummand_comp_d_comp_πSummand_eq_zero (j k : ℕ) (A : IndexSet (op ⦋j⦌)) (hA : ¬A.EqId) :
(s.cofan _).inj A ≫ K[X].d j k ≫ s.πSummand (IndexSet.id (op ⦋k⦌)) = 0 := by
rw [A.eqId_iff_mono] at hA
rw [← assoc, ← s.comp_PInfty_eq_zero_iff, assoc, ← PInfty.comm j k, s.cofan_inj_eq, assoc,
degeneracy_comp_PInfty_assoc X j A.e hA, zero_comp, comp_zero]
/-- If `s` is a splitting of a simplicial object `X` in a preadditive category,
`s.nondegComplex` is a chain complex which is given in degree `n` by
the nondegenerate `n`-simplices of `X`. -/
@[simps]
noncomputable def nondegComplex : ChainComplex C ℕ where
X := s.N
d := s.d
shape i j hij := by simp only [d, K[X].shape i j hij, zero_comp, comp_zero]
d_comp_d' i j k _ _ := by
simp only [d, assoc]
have eq : K[X].d i j ≫ 𝟙 (X.obj (op ⦋j⦌)) ≫ K[X].d j k ≫
s.πSummand (IndexSet.id (op ⦋k⦌)) = 0 := by
simp
rw [s.decomposition_id] at eq
classical
rw [Fintype.sum_eq_add_sum_compl (IndexSet.id (op ⦋j⦌)), add_comp, comp_add, assoc,
Preadditive.sum_comp, Preadditive.comp_sum, Finset.sum_eq_zero, add_zero] at eq
swap
· intro A hA
simp only [Finset.mem_compl, Finset.mem_singleton] at hA
simp only [assoc, ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ _ hA, comp_zero]
rw [eq, comp_zero]
/-- The chain complex `s.nondegComplex` attached to a splitting of a simplicial object `X`
becomes isomorphic to the normalized Moore complex `N₁.obj X` defined as a formal direct
factor in the category `Karoubi (ChainComplex C ℕ)`. -/
@[simps]
noncomputable def toKaroubiNondegComplexIsoN₁ :
(toKaroubi _).obj s.nondegComplex ≅ N₁.obj X where
hom :=
{ f :=
{ f := fun n => (s.cofan _).inj (IndexSet.id (op ⦋n⦌)) ≫ PInfty.f n
comm' := fun i j _ => by
dsimp
rw [assoc, assoc, assoc, πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty,
HomologicalComplex.Hom.comm] }
comm := by
ext n
dsimp
rw [id_comp, assoc, PInfty_f_idem] }
inv :=
{ f :=
{ f := fun n => s.πSummand (IndexSet.id (op ⦋n⦌))
comm' := fun i j _ => by
dsimp
slice_rhs 1 1 => rw [← id_comp (K[X].d i j)]
dsimp only [AlternatingFaceMapComplex.obj_X]
rw [s.decomposition_id, sum_comp, sum_comp, Finset.sum_eq_single (IndexSet.id (op ⦋i⦌)),
assoc, assoc]
· intro A _ hA
simp only [assoc, s.ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ hA, comp_zero]
· simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff] }
comm := by
ext n
dsimp
simp only [comp_id, PInfty_comp_πSummand_id] }
hom_inv_id := by
ext n
simp only [assoc, PInfty_comp_πSummand_id, Karoubi.comp_f, HomologicalComplex.comp_f,
cofan_inj_πSummand_eq_id]
rfl
inv_hom_id := by
ext n
simp only [πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty, Karoubi.comp_f,
HomologicalComplex.comp_f, N₁_obj_p, Karoubi.id_f]
end Splitting
namespace Split
variable {C : Type*} [Category C] [Preadditive C] [HasFiniteCoproducts C]
/-- The functor which sends a split simplicial object in a preadditive category to
the chain complex which consists of nondegenerate simplices. -/
@[simps]
noncomputable def nondegComplexFunctor : Split C ⥤ ChainComplex C ℕ where
obj S := S.s.nondegComplex
map {S₁ S₂} Φ :=
{ f := Φ.f
comm' := fun i j _ => by
dsimp
erw [← cofan_inj_naturality_symm_assoc Φ (Splitting.IndexSet.id (op ⦋i⦌)),
((alternatingFaceMapComplex C).map Φ.F).comm_assoc i j]
simp only [assoc]
congr 2
apply S₁.s.hom_ext'
intro A
dsimp [alternatingFaceMapComplex]
rw [cofan_inj_naturality_symm_assoc Φ A]
by_cases h : A.EqId
· dsimp at h
subst h
rw [Splitting.cofan_inj_πSummand_eq_id]
dsimp
rw [comp_id, Splitting.cofan_inj_πSummand_eq_id_assoc]
· rw [S₁.s.cofan_inj_πSummand_eq_zero_assoc _ _ (Ne.symm h),
S₂.s.cofan_inj_πSummand_eq_zero _ _ (Ne.symm h), zero_comp, comp_zero] }
/-- The natural isomorphism (in `Karoubi (ChainComplex C ℕ)`) between the chain complex
of nondegenerate simplices of a split simplicial object and the normalized Moore complex
defined as a formal direct factor of the alternating face map complex. -/
@[simps!]
noncomputable def toKaroubiNondegComplexFunctorIsoN₁ :
nondegComplexFunctor ⋙ toKaroubi (ChainComplex C ℕ) ≅ forget C ⋙ DoldKan.N₁ :=
NatIso.ofComponents (fun S => S.s.toKaroubiNondegComplexIsoN₁) fun Φ => by
ext n
dsimp
simp only [assoc, PInfty_f_idem_assoc]
erw [← Split.cofan_inj_naturality_symm_assoc Φ (Splitting.IndexSet.id (op ⦋n⦌))]
rw [PInfty_f_naturality]
end Split
end SimplicialObject |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/NReflectsIso.lean | import Mathlib.AlgebraicTopology.DoldKan.FunctorN
import Mathlib.AlgebraicTopology.DoldKan.Decomposition
import Mathlib.CategoryTheory.Idempotents.HomologicalComplex
import Mathlib.CategoryTheory.Idempotents.KaroubiKaroubi
/-!
# N₁ and N₂ reflect isomorphisms
In this file, it is shown that the functors
`N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)` and
`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`
reflect isomorphisms for any preadditive category `C`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Idempotents Opposite Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
open MorphComponents
instance : (N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)).ReflectsIsomorphisms :=
⟨fun {X Y} f => by
intro
-- restating the result in a way that allows induction on the degree n
suffices ∀ n : ℕ, IsIso (f.app (op ⦋n⦌)) by
haveI : ∀ Δ : SimplexCategoryᵒᵖ, IsIso (f.app Δ) := fun Δ => this Δ.unop.len
apply NatIso.isIso_of_isIso_app
-- restating the assumption in a more practical form
have h₁ := HomologicalComplex.congr_hom (Karoubi.hom_ext_iff.mp (IsIso.hom_inv_id (N₁.map f)))
have h₂ := HomologicalComplex.congr_hom (Karoubi.hom_ext_iff.mp (IsIso.inv_hom_id (N₁.map f)))
have h₃ := fun n =>
Karoubi.HomologicalComplex.p_comm_f_assoc (inv (N₁.map f)) n (f.app (op ⦋n⦌))
simp only [N₁_map_f, Karoubi.comp_f, HomologicalComplex.comp_f,
AlternatingFaceMapComplex.map_f, N₁_obj_p, Karoubi.id_f, assoc] at h₁ h₂ h₃
-- we have to construct an inverse to f in degree n, by induction on n
intro n
induction n with
-- degree 0
| zero =>
use (inv (N₁.map f)).f.f 0
have h₁₀ := h₁ 0
have h₂₀ := h₂ 0
dsimp at h₁₀ h₂₀
simp only [id_comp] at h₁₀ h₂₀
tauto
| succ n hn =>
use φ { a := PInfty.f (n + 1) ≫ (inv (N₁.map f)).f.f (n + 1)
b := fun i => inv (f.app (op ⦋n⦌)) ≫ X.σ i }
simp only [MorphComponents.id, ← id_φ, ← preComp_φ, preComp, ← postComp_φ, postComp,
PInfty_f_naturality_assoc, IsIso.hom_inv_id_assoc, assoc, IsIso.inv_hom_id_assoc,
SimplicialObject.σ_naturality, h₁, h₂, h₃, and_self]⟩
theorem compatibility_N₂_N₁_karoubi :
N₂ ⋙ (karoubiChainComplexEquivalence C ℕ).functor =
karoubiFunctorCategoryEmbedding SimplexCategoryᵒᵖ C ⋙
N₁ ⋙ (karoubiChainComplexEquivalence (Karoubi C) ℕ).functor ⋙
Functor.mapHomologicalComplex (KaroubiKaroubi.equivalence C).inverse _ := by
refine CategoryTheory.Functor.ext (fun P => ?_) fun P Q f => ?_
· refine HomologicalComplex.ext ?_ ?_
· ext n
· rfl
· dsimp
simp only [karoubi_PInfty_f, comp_id, PInfty_f_naturality, id_comp]
· rintro _ n (rfl : n + 1 = _)
ext
have h := (AlternatingFaceMapComplex.map P.p).comm (n + 1) n
dsimp [N₂, karoubiChainComplexEquivalence,
KaroubiHomologicalComplexEquivalence.Functor.obj] at h ⊢
simp only [assoc, Karoubi.eqToHom_f, eqToHom_refl, comp_id,
karoubi_alternatingFaceMapComplex_d, karoubi_PInfty_f,
← HomologicalComplex.Hom.comm_assoc, ← h, app_idem_assoc]
· ext n
dsimp [KaroubiKaroubi.inverse, Functor.mapHomologicalComplex]
simp only [karoubi_PInfty_f, HomologicalComplex.eqToHom_f, Karoubi.eqToHom_f,
assoc, comp_id, PInfty_f_naturality, app_p_comp,
karoubiChainComplexEquivalence_functor_obj_X_p, N₂_obj_p_f, eqToHom_refl,
PInfty_f_naturality_assoc, app_comp_p, PInfty_f_idem_assoc]
/-- We deduce that `N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`
reflects isomorphisms from the fact that
`N₁ : SimplicialObject (Karoubi C) ⥤ Karoubi (ChainComplex (Karoubi C) ℕ)` does. -/
instance : (N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)).ReflectsIsomorphisms :=
⟨fun f => by
intro
-- The following functor `F` reflects isomorphisms because it is
-- a composition of four functors which reflect isomorphisms.
-- Then, it suffices to show that `F.map f` is an isomorphism.
let F₁ := karoubiFunctorCategoryEmbedding SimplexCategoryᵒᵖ C
let F₂ : SimplicialObject (Karoubi C) ⥤ _ := N₁
let F₃ := (karoubiChainComplexEquivalence (Karoubi C) ℕ).functor
let F₄ := Functor.mapHomologicalComplex (KaroubiKaroubi.equivalence C).inverse
(ComplexShape.down ℕ)
let F := F₁ ⋙ F₂ ⋙ F₃ ⋙ F₄
-- Porting note: we have to help Lean4 find the `ReflectsIsomorphisms` instances
-- could this be fixed by setting better instance priorities?
haveI : F₁.ReflectsIsomorphisms := reflectsIsomorphisms_of_full_and_faithful _
haveI : F₂.ReflectsIsomorphisms := by infer_instance
have : IsIso (F.map f) := by
simp only [F, F₁]
rw [← compatibility_N₂_N₁_karoubi, Functor.comp_map]
apply Functor.map_isIso
exact isIso_of_reflects_iso f F⟩
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Projections.lean | import Mathlib.AlgebraicTopology.DoldKan.Faces
import Mathlib.CategoryTheory.Idempotents.Basic
/-!
# Construction of projections for the Dold-Kan correspondence
In this file, we construct endomorphisms `P q : K[X] ⟶ K[X]` for all
`q : ℕ`. We study how they behave with respect to face maps with the lemmas
`HigherFacesVanish.of_P`, `HigherFacesVanish.comp_P_eq_self` and
`comp_P_eq_self_iff`.
Then, we show that they are projections (see `P_f_idem`
and `P_idem`). They are natural transformations (see `natTransP`
and `P_f_naturality`) and are compatible with the application
of additive functors (see `map_P`).
By passing to the limit, these endomorphisms `P q` shall be used in `PInfty.lean`
in order to define `PInfty : K[X] ⟶ K[X]`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive
CategoryTheory.SimplicialObject Opposite CategoryTheory.Idempotents
open Simplicial DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X : SimplicialObject C}
/-- This is the inductive definition of the projections `P q : K[X] ⟶ K[X]`,
with `P 0 := 𝟙 _` and `P (q+1) := P q ≫ (𝟙 _ + Hσ q)`. -/
noncomputable def P : ℕ → (K[X] ⟶ K[X])
| 0 => 𝟙 _
| q + 1 => P q ≫ (𝟙 _ + Hσ q)
lemma P_zero : (P 0 : K[X] ⟶ K[X]) = 𝟙 _ := rfl
lemma P_succ (q : ℕ) : (P (q+1) : K[X] ⟶ K[X]) = P q ≫ (𝟙 _ + Hσ q) := rfl
/-- All the `P q` coincide with `𝟙 _` in degree 0. -/
@[simp]
theorem P_f_0_eq (q : ℕ) : ((P q).f 0 : X _⦋0⦌ ⟶ X _⦋0⦌) = 𝟙 _ := by
induction q with
| zero => rfl
| succ q hq =>
simp only [P_succ, HomologicalComplex.add_f_apply, HomologicalComplex.comp_f,
HomologicalComplex.id_f, id_comp, hq, Hσ_eq_zero, add_zero]
/-- `Q q` is the complement projection associated to `P q` -/
def Q (q : ℕ) : K[X] ⟶ K[X] :=
𝟙 _ - P q
theorem P_add_Q (q : ℕ) : P q + Q q = 𝟙 K[X] := by
rw [Q]
abel
theorem P_add_Q_f (q n : ℕ) : (P q).f n + (Q q).f n = 𝟙 (X _⦋n⦌) :=
HomologicalComplex.congr_hom (P_add_Q q) n
@[simp]
theorem Q_zero : (Q 0 : K[X] ⟶ _) = 0 :=
sub_self _
theorem Q_succ (q : ℕ) : (Q (q + 1) : K[X] ⟶ _) = Q q - P q ≫ Hσ q := by
simp only [Q, P_succ, comp_add, comp_id]
abel
/-- All the `Q q` coincide with `0` in degree 0. -/
@[simp]
theorem Q_f_0_eq (q : ℕ) : ((Q q).f 0 : X _⦋0⦌ ⟶ X _⦋0⦌) = 0 := by
simp only [HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, Q, P_f_0_eq, sub_self]
namespace HigherFacesVanish
/-- This lemma expresses the vanishing of
`(P q).f (n+1) ≫ X.δ k : X _⦋n+1⦌ ⟶ X _⦋n⦌` when `k≠0` and `k≥n-q+2` -/
theorem of_P : ∀ q n : ℕ, HigherFacesVanish q ((P q).f (n + 1) : X _⦋n + 1⦌ ⟶ X _⦋n + 1⦌)
| 0 => fun n j hj₁ => by omega
| q + 1 => fun n => by
simp only [P_succ]
exact (of_P q n).induction
@[reassoc]
theorem comp_P_eq_self {Y : C} {n q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : HigherFacesVanish q φ) :
φ ≫ (P q).f (n + 1) = φ := by
induction q with
| zero =>
simp only [P_zero]
apply comp_id
| succ q hq =>
simp only [P_succ, comp_add, HomologicalComplex.comp_f, HomologicalComplex.add_f_apply,
comp_id, ← assoc, hq v.of_succ, add_eq_left]
by_cases! hqn : n < q
· exact v.of_succ.comp_Hσ_eq_zero hqn
· obtain ⟨a, ha⟩ := Nat.le.dest hqn
have hnaq : n = a + q := by omega
simp only [v.of_succ.comp_Hσ_eq hnaq, neg_eq_zero, ← assoc]
have eq := v ⟨a, by cutsat⟩ (by
simp only [hnaq, add_assoc]
rfl)
simp only [Fin.succ_mk] at eq
simp only [eq, zero_comp]
end HigherFacesVanish
theorem comp_P_eq_self_iff {Y : C} {n q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} :
φ ≫ (P q).f (n + 1) = φ ↔ HigherFacesVanish q φ := by
constructor
· intro hφ
rw [← hφ]
apply HigherFacesVanish.of_comp
apply HigherFacesVanish.of_P
· exact HigherFacesVanish.comp_P_eq_self
@[reassoc (attr := simp)]
theorem P_f_idem (q n : ℕ) : ((P q).f n : X _⦋n⦌ ⟶ _) ≫ (P q).f n = (P q).f n := by
rcases n with (_ | n)
· rw [P_f_0_eq q, comp_id]
· exact (HigherFacesVanish.of_P q n).comp_P_eq_self
@[reassoc (attr := simp)]
theorem Q_f_idem (q n : ℕ) : ((Q q).f n : X _⦋n⦌ ⟶ _) ≫ (Q q).f n = (Q q).f n :=
idem_of_id_sub_idem _ (P_f_idem q n)
@[reassoc (attr := simp)]
theorem P_idem (q : ℕ) : (P q : K[X] ⟶ K[X]) ≫ P q = P q := by
ext n
exact P_f_idem q n
@[reassoc (attr := simp)]
theorem Q_idem (q : ℕ) : (Q q : K[X] ⟶ K[X]) ≫ Q q = Q q := by
ext n
exact Q_f_idem q n
/-- For each `q`, `P q` is a natural transformation. -/
@[simps]
def natTransP (q : ℕ) : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app _ := P q
naturality _ _ f := by
induction q with
| zero =>
dsimp [alternatingFaceMapComplex]
simp only [P_zero, id_comp, comp_id]
| succ q hq =>
simp only [P_succ, add_comp, comp_add, assoc, comp_id, hq, reassoc_of% hq]
-- `erw` is needed to see through `natTransHσ q).app = Hσ q`
erw [(natTransHσ q).naturality f]
rfl
@[reassoc (attr := simp)]
theorem P_f_naturality (q n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op ⦋n⦌) ≫ (P q).f n = (P q).f n ≫ f.app (op ⦋n⦌) :=
HomologicalComplex.congr_hom ((natTransP q).naturality f) n
@[reassoc (attr := simp)]
theorem Q_f_naturality (q n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op ⦋n⦌) ≫ (Q q).f n = (Q q).f n ≫ f.app (op ⦋n⦌) := by
simp only [Q, HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, comp_sub, P_f_naturality,
sub_comp, sub_left_inj]
dsimp
simp only [comp_id, id_comp]
/-- For each `q`, `Q q` is a natural transformation. -/
@[simps]
def natTransQ (q : ℕ) : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app _ := Q q
theorem map_P {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n : ℕ) :
G.map ((P q : K[X] ⟶ _).f n) = (P q : K[((whiskering C D).obj G).obj X] ⟶ _).f n := by
induction q with
| zero =>
simp only [P_zero]
apply G.map_id
| succ q hq =>
simp only [P_succ, comp_add, HomologicalComplex.comp_f, HomologicalComplex.add_f_apply,
comp_id, Functor.map_add, Functor.map_comp, hq, map_Hσ]
theorem map_Q {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n : ℕ) :
G.map ((Q q : K[X] ⟶ _).f n) = (Q q : K[((whiskering C D).obj G).obj X] ⟶ _).f n := by
rw [← add_right_inj (G.map ((P q : K[X] ⟶ _).f n)), ← G.map_add, map_P G X q n, P_add_Q_f,
P_add_Q_f]
apply G.map_id
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Faces.lean | import Mathlib.AlgebraicTopology.DoldKan.Homotopies
import Mathlib.Tactic.Ring
/-!
# Study of face maps for the Dold-Kan correspondence
In this file, we obtain the technical lemmas that are used in the file
`Projections.lean` in order to get basic properties of the endomorphisms
`P q : K[X] ⟶ K[X]` with respect to face maps (see `Homotopies.lean` for the
role of these endomorphisms in the overall strategy of proof).
The main lemma in this file is `HigherFacesVanish.induction`. It is based
on two technical lemmas `HigherFacesVanish.comp_Hσ_eq` and
`HigherFacesVanish.comp_Hσ_eq_zero`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Limits CategoryTheory.Category
CategoryTheory.Preadditive CategoryTheory.SimplicialObject Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
variable {X : SimplicialObject C}
/-- A morphism `φ : Y ⟶ X _⦋n+1⦌` satisfies `HigherFacesVanish q φ`
when the compositions `φ ≫ X.δ j` are `0` for `j ≥ max 1 (n+2-q)`. When `q ≤ n+1`,
it basically means that the composition `φ ≫ X.δ j` are `0` for the `q` highest
possible values of a nonzero `j`. Otherwise, when `q ≥ n+2`, all the compositions
`φ ≫ X.δ j` for nonzero `j` vanish. See also the lemma `comp_P_eq_self_iff` in
`Projections.lean` which states that `HigherFacesVanish q φ` is equivalent to
the identity `φ ≫ (P q).f (n+1) = φ`. -/
def HigherFacesVanish {Y : C} {n : ℕ} (q : ℕ) (φ : Y ⟶ X _⦋n + 1⦌) : Prop :=
∀ j : Fin (n + 1), n + 1 ≤ (j : ℕ) + q → φ ≫ X.δ j.succ = 0
namespace HigherFacesVanish
@[reassoc]
theorem comp_δ_eq_zero {Y : C} {n : ℕ} {q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : HigherFacesVanish q φ)
(j : Fin (n + 2)) (hj₁ : j ≠ 0) (hj₂ : n + 2 ≤ (j : ℕ) + q) : φ ≫ X.δ j = 0 := by
obtain ⟨i, rfl⟩ := Fin.eq_succ_of_ne_zero hj₁
apply v i
simp only [Fin.val_succ] at hj₂
cutsat
theorem of_succ {Y : C} {n q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : HigherFacesVanish (q + 1) φ) :
HigherFacesVanish q φ := fun j hj => v j (by simpa only [← add_assoc] using le_add_right hj)
theorem of_comp {Y Z : C} {q n : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : HigherFacesVanish q φ) (f : Z ⟶ Y) :
HigherFacesVanish q (f ≫ φ) := fun j hj => by rw [assoc, v j hj, comp_zero]
theorem comp_Hσ_eq {Y : C} {n a q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : HigherFacesVanish q φ)
(hnaq : n = a + q) :
φ ≫ (Hσ q).f (n + 1) = -φ ≫ X.δ ⟨a + 1, by cutsat⟩ ≫ X.σ ⟨a, by cutsat⟩ := by
have hnaq_shift (d : ℕ) : n + d = a + d + q := by omega
rw [Hσ, Homotopy.nullHomotopicMap'_f (c_mk (n + 2) (n + 1) rfl) (c_mk (n + 1) n rfl),
hσ'_eq hnaq (c_mk (n + 1) n rfl), hσ'_eq (hnaq_shift 1) (c_mk (n + 2) (n + 1) rfl)]
simp only [AlternatingFaceMapComplex.obj_d_eq, eqToHom_refl, comp_id, comp_sum, sum_comp,
comp_add]
simp only [comp_zsmul, zsmul_comp, ← assoc, ← mul_zsmul]
-- cleaning up the first sum
rw [← Fin.sum_congr' _ (hnaq_shift 2).symm, Fin.sum_trunc]
swap
· rintro ⟨k, hk⟩
suffices φ ≫ X.δ (⟨a + 2 + k, by cutsat⟩ : Fin (n + 2)) = 0 by
simp only [this, Fin.natAdd_mk, Fin.cast_mk, zero_comp, smul_zero]
convert v ⟨a + k + 1, by cutsat⟩ (by rw [Fin.val_mk]; cutsat)
dsimp
cutsat
-- cleaning up the second sum
rw [← Fin.sum_congr' _ (hnaq_shift 3).symm, @Fin.sum_trunc _ _ (a + 3)]
swap
· rintro ⟨k, hk⟩
rw [assoc, X.δ_comp_σ_of_gt', v.comp_δ_eq_zero_assoc, zero_comp, zsmul_zero]
· intro h
replace h : a + 3 + k = 1 := by simp [Fin.ext_iff] at h
cutsat
· dsimp [Fin.cast, Fin.pred]
rw [Nat.add_right_comm, Nat.add_sub_assoc (by simp : 1 ≤ 3)]
cutsat
· simp only [Fin.lt_iff_val_lt_val]
dsimp [Fin.natAdd, Fin.cast]
cutsat
simp only [assoc]
conv_lhs =>
congr
· rw [Fin.sum_univ_castSucc]
· rw [Fin.sum_univ_castSucc, Fin.sum_univ_castSucc]
dsimp [Fin.cast, Fin.castLE, Fin.castLT]
/- the purpose of the following `simplif` is to create three subgoals in order
to finish the proof -/
have simplif :
∀ a b c d e f : Y ⟶ X _⦋n + 1⦌, b = f → d + e = 0 → c + a = 0 → a + b + (c + d + e) = f := by
intro a b c d e f h1 h2 h3
rw [add_assoc c d e, h2, add_zero, add_comm a, add_assoc, add_comm a, h3, add_zero, h1]
apply simplif
· -- b = f
rw [← pow_add, Odd.neg_one_pow, neg_smul, one_zsmul]
exact ⟨a, by cutsat⟩
· -- d + e = 0
rw [X.δ_comp_σ_self' (Fin.castSucc_mk _ _ _).symm,
X.δ_comp_σ_succ' (Fin.succ_mk _ _ _).symm]
simp only [comp_id, pow_add _ (a + 1) 1, pow_one, mul_neg, mul_one, neg_mul, neg_smul,
add_neg_cancel]
· -- c + a = 0
rw [← Finset.sum_add_distrib]
apply Finset.sum_eq_zero
rintro ⟨i, hi⟩ _
simp only
have hia : (⟨i, by cutsat⟩ : Fin (n + 2)) ≤
Fin.castSucc (⟨a, by cutsat⟩ : Fin (n + 1)) := by
rw [Fin.le_iff_val_le_val]
dsimp
omega
generalize_proofs
rw [← Fin.succ_mk (n + 1) a ‹_›, ← Fin.castSucc_mk (n + 2) i ‹_›,
δ_comp_σ_of_le X hia, add_eq_zero_iff_eq_neg, ← neg_zsmul]
congr 2
ring
theorem comp_Hσ_eq_zero {Y : C} {n q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : HigherFacesVanish q φ)
(hqn : n < q) : φ ≫ (Hσ q).f (n + 1) = 0 := by
simp only [Hσ, Homotopy.nullHomotopicMap'_f (c_mk (n + 2) (n + 1) rfl) (c_mk (n + 1) n rfl)]
rw [hσ'_eq_zero hqn (c_mk (n + 1) n rfl), comp_zero, zero_add]
by_cases hqn' : n + 1 < q
· rw [hσ'_eq_zero hqn' (c_mk (n + 2) (n + 1) rfl), zero_comp, comp_zero]
· simp only [hσ'_eq (show n + 1 = 0 + q by cutsat) (c_mk (n + 2) (n + 1) rfl), pow_zero,
Fin.mk_zero, one_zsmul, eqToHom_refl, comp_id, comp_sum,
AlternatingFaceMapComplex.obj_d_eq]
-- All terms of the sum but the first two are zeros
rw [Fin.sum_univ_succ, Fin.sum_univ_succ, Fintype.sum_eq_zero, add_zero]
· simp only [Fin.val_zero, Fin.val_succ, Fin.coe_castSucc, zero_add, pow_zero, one_smul,
pow_one, neg_smul, comp_neg, ← Fin.castSucc_zero (n := n + 2), δ_comp_σ_self, δ_comp_σ_succ,
add_neg_cancel]
· intro j
rw [comp_zsmul, comp_zsmul, δ_comp_σ_of_gt', v.comp_δ_eq_zero_assoc, zero_comp, zsmul_zero]
· simp [Fin.succ_ne_zero]
· dsimp
cutsat
· simp only [Fin.succ_lt_succ_iff, j.succ_pos]
theorem induction {Y : C} {n q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : HigherFacesVanish q φ) :
HigherFacesVanish (q + 1) (φ ≫ (𝟙 _ + Hσ q).f (n + 1)) := by
intro j hj₁
dsimp
simp only [comp_add, add_comp, comp_id]
-- when n < q, the result follows immediately from the assumption
by_cases! hqn : n < q
· rw [v.comp_Hσ_eq_zero hqn, zero_comp, add_zero, v j (by cutsat)]
-- we now assume that n≥q, and write n=a+q
obtain ⟨a, ha⟩ := Nat.le.dest hqn
rw [v.comp_Hσ_eq (show n = a + q by cutsat), neg_comp, add_neg_eq_zero, assoc, assoc]
rcases n with - | m
-- the boundary case n=0
· simp only [Nat.eq_zero_of_add_eq_zero_left ha, Fin.eq_zero j, Fin.mk_zero,
δ_comp_σ_succ, comp_id]
rfl
-- in the other case, we need to write n as m+1
-- then, we first consider the particular case j = a
by_cases hj₂ : a = (j : ℕ)
· simp only [hj₂, Fin.eta, δ_comp_σ_succ, comp_id]
rfl
-- now, we assume j ≠ a (i.e. a < j)
have haj : a < j := (Ne.le_iff_lt hj₂).mp (by cutsat)
have ham : a ≤ m := by omega
rw [X.δ_comp_σ_of_gt', j.pred_succ]
swap
· rw [Fin.lt_iff_val_lt_val]
simpa only [Fin.val_mk, Fin.val_succ, add_lt_add_iff_right] using haj
obtain _ | ham'' := ham.lt_or_eq
· -- case where `a<m`
rw [← X.δ_comp_δ''_assoc]
swap
· rw [Fin.le_iff_val_le_val]
dsimp
cutsat
simp only [← assoc, v j (by cutsat), zero_comp]
· -- in the last case, a=m, q=1 and j=a+1
rw [X.δ_comp_δ_self'_assoc]
swap
· ext
cases j
dsimp
dsimp only [Nat.succ_eq_add_one] at *
cutsat
simp only [← assoc, v j (by cutsat), zero_comp]
end HigherFacesVanish
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/GammaCompN.lean | import Mathlib.AlgebraicTopology.DoldKan.FunctorGamma
import Mathlib.AlgebraicTopology.DoldKan.SplitSimplicialObject
import Mathlib.CategoryTheory.Idempotents.HomologicalComplex
import Mathlib.Tactic.SuppressCompilation
/-! The counit isomorphism of the Dold-Kan equivalence
The purpose of this file is to construct natural isomorphisms
`N₁Γ₀ : Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ)`
and `N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ))`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
suppress_compilation
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Functor CategoryTheory.Limits
CategoryTheory.Idempotents Opposite SimplicialObject Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] [HasFiniteCoproducts C]
/-- The isomorphism `(Γ₀.splitting K).nondegComplex ≅ K` for all `K : ChainComplex C ℕ`. -/
@[simps!]
def Γ₀NondegComplexIso (K : ChainComplex C ℕ) : (Γ₀.splitting K).nondegComplex ≅ K :=
HomologicalComplex.Hom.isoOfComponents (fun _ => Iso.refl _)
(by
rintro _ n (rfl : n + 1 = _)
dsimp
simp only [id_comp, comp_id, AlternatingFaceMapComplex.obj_d_eq, Preadditive.sum_comp,
Preadditive.comp_sum]
rw [Fintype.sum_eq_single (0 : Fin (n + 2))]
· simp only [Fin.val_zero, pow_zero, one_zsmul]
rw [δ, Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_δ₀,
Splitting.cofan_inj_πSummand_eq_id]
dsimp only [Γ₀.splitting, Splitting.summand.eq_1, Splitting.IndexSet.id_fst]
rw [comp_id]
· intro i hi
dsimp
simp only [Preadditive.zsmul_comp, Preadditive.comp_zsmul]
rw [δ, Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_eq_zero, zero_comp,
zsmul_zero]
· intro h
replace h := congr_arg SimplexCategory.len h
change n + 1 = n at h
cutsat
· simpa only [Isδ₀.iff] using hi)
/-- The natural isomorphism `(Γ₀.splitting K).nondegComplex ≅ K` for `K : ChainComplex C ℕ`. -/
def Γ₀'CompNondegComplexFunctor : Γ₀' ⋙ Split.nondegComplexFunctor ≅ 𝟭 (ChainComplex C ℕ) :=
NatIso.ofComponents Γ₀NondegComplexIso
/-- The natural isomorphism `Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ)`. -/
def N₁Γ₀ : Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ) :=
calc
Γ₀ ⋙ N₁ ≅ Γ₀' ⋙ Split.forget C ⋙ N₁ := Functor.associator _ _ _
_ ≅ Γ₀' ⋙ Split.nondegComplexFunctor ⋙ toKaroubi _ :=
(isoWhiskerLeft Γ₀' Split.toKaroubiNondegComplexFunctorIsoN₁.symm)
_ ≅ (Γ₀' ⋙ Split.nondegComplexFunctor) ⋙ toKaroubi _ := (Functor.associator _ _ _).symm
_ ≅ 𝟭 _ ⋙ toKaroubi (ChainComplex C ℕ) := isoWhiskerRight Γ₀'CompNondegComplexFunctor _
_ ≅ toKaroubi (ChainComplex C ℕ) := Functor.leftUnitor _
theorem N₁Γ₀_app (K : ChainComplex C ℕ) :
N₁Γ₀.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.symm ≪≫
(toKaroubi _).mapIso (Γ₀NondegComplexIso K) := by
ext1
dsimp [N₁Γ₀]
erw [id_comp, comp_id, comp_id]
rfl
theorem N₁Γ₀_hom_app (K : ChainComplex C ℕ) :
N₁Γ₀.hom.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv ≫
(toKaroubi _).map (Γ₀NondegComplexIso K).hom := by
change (N₁Γ₀.app K).hom = _
simp only [N₁Γ₀_app]
rfl
theorem N₁Γ₀_inv_app (K : ChainComplex C ℕ) :
N₁Γ₀.inv.app K = (toKaroubi _).map (Γ₀NondegComplexIso K).inv ≫
(Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.hom := by
change (N₁Γ₀.app K).inv = _
simp only [N₁Γ₀_app]
rfl
@[simp]
theorem N₁Γ₀_hom_app_f_f (K : ChainComplex C ℕ) (n : ℕ) :
(N₁Γ₀.hom.app K).f.f n = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv.f.f n := by
rw [N₁Γ₀_hom_app]
apply comp_id
@[simp]
theorem N₁Γ₀_inv_app_f_f (K : ChainComplex C ℕ) (n : ℕ) :
(N₁Γ₀.inv.app K).f.f n = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.hom.f.f n := by
rw [N₁Γ₀_inv_app]
apply id_comp
/-- Compatibility isomorphism between `toKaroubi _ ⋙ Γ₂ ⋙ N₂` and `Γ₀ ⋙ N₁` which
are functors `ChainComplex C ℕ ⥤ Karoubi (ChainComplex C ℕ)`. -/
def N₂Γ₂ToKaroubiIso : toKaroubi (ChainComplex C ℕ) ⋙ Γ₂ ⋙ N₂ ≅ Γ₀ ⋙ N₁ :=
calc
toKaroubi (ChainComplex C ℕ) ⋙ Γ₂ ⋙ N₂ ≅
toKaroubi (ChainComplex C ℕ) ⋙ (Γ₂ ⋙ N₂) := (Functor.associator _ _ _).symm
_ ≅ (Γ₀ ⋙ toKaroubi (SimplicialObject C)) ⋙ N₂ :=
isoWhiskerRight ((functorExtension₂CompWhiskeringLeftToKaroubiIso _ _).app Γ₀) N₂
_ ≅ Γ₀ ⋙ toKaroubi (SimplicialObject C) ⋙ N₂ := Functor.associator _ _ _
_ ≅ Γ₀ ⋙ N₁ :=
isoWhiskerLeft Γ₀ ((functorExtension₁CompWhiskeringLeftToKaroubiIso _ _).app N₁)
@[simp]
lemma N₂Γ₂ToKaroubiIso_hom_app (X : ChainComplex C ℕ) :
(N₂Γ₂ToKaroubiIso.hom.app X).f = PInfty := by
ext n
dsimp [N₂Γ₂ToKaroubiIso]
simp only [comp_id, assoc, PInfty_f_idem]
conv_rhs =>
rw [← PInfty_f_idem]
congr 1
apply (Γ₀.splitting X).hom_ext'
intro A
rw [Splitting.ι_desc_assoc, assoc]
apply id_comp
@[simp]
lemma N₂Γ₂ToKaroubiIso_inv_app (X : ChainComplex C ℕ) :
(N₂Γ₂ToKaroubiIso.inv.app X).f = PInfty := by
ext n
dsimp [N₂Γ₂ToKaroubiIso]
simp only [comp_id, PInfty_f_idem_assoc, AlternatingFaceMapComplex.obj_X, Γ₀_obj_obj]
convert comp_id _
apply (Γ₀.splitting X).hom_ext'
intro A
rw [Splitting.ι_desc]
erw [comp_id, id_comp]
/-- The counit isomorphism of the Dold-Kan equivalence for additive categories. -/
def N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ)) :=
((whiskeringLeft _ _ _).obj (toKaroubi (ChainComplex C ℕ))).preimageIso
(N₂Γ₂ToKaroubiIso ≪≫ N₁Γ₀)
@[simp]
theorem N₂Γ₂_inv_app_f_f (X : Karoubi (ChainComplex C ℕ)) (n : ℕ) :
(N₂Γ₂.inv.app X).f.f n =
X.p.f n ≫ ((Γ₀.splitting X.X).cofan _).inj (Splitting.IndexSet.id (op ⦋n⦌)) := by
dsimp [N₂Γ₂]
simp only [whiskeringLeft_obj_preimage_app, NatTrans.comp_app, Functor.comp_map,
Karoubi.comp_f, N₂Γ₂ToKaroubiIso_inv_app, HomologicalComplex.comp_f,
N₁Γ₀_inv_app_f_f, toKaroubi_obj_X, Splitting.toKaroubiNondegComplexIsoN₁_hom_f_f,
PInfty_on_Γ₀_splitting_summand_eq_self, N₂_map_f_f, Γ₂_map_f_app, unop_op, Karoubi.decompId_p_f,
PInfty_on_Γ₀_splitting_summand_eq_self_assoc, Splitting.IndexSet.id_fst, SimplexCategory.len_mk,
Splitting.ι_desc]
apply Karoubi.HomologicalComplex.p_idem_assoc
lemma whiskerLeft_toKaroubi_N₂Γ₂_hom :
whiskerLeft (toKaroubi (ChainComplex C ℕ)) N₂Γ₂.hom = N₂Γ₂ToKaroubiIso.hom ≫ N₁Γ₀.hom := by
let e : _ ≅ toKaroubi (ChainComplex C ℕ) ⋙ 𝟭 _ := N₂Γ₂ToKaroubiIso ≪≫ N₁Γ₀
have h := ((whiskeringLeft _ _ (Karoubi (ChainComplex C ℕ))).obj
(toKaroubi (ChainComplex C ℕ))).map_preimage e.hom
dsimp only [whiskeringLeft, N₂Γ₂, Functor.preimageIso] at h ⊢
exact h
theorem N₂Γ₂_compatible_with_N₁Γ₀ (K : ChainComplex C ℕ) :
N₂Γ₂.hom.app ((toKaroubi _).obj K) = N₂Γ₂ToKaroubiIso.hom.app K ≫ N₁Γ₀.hom.app K :=
congr_app whiskerLeft_toKaroubi_N₂Γ₂_hom K
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Degeneracies.lean | import Mathlib.AlgebraicTopology.DoldKan.Decomposition
import Mathlib.Tactic.FinCases
/-!
# Behaviour of P_infty with respect to degeneracies
For any `X : SimplicialObject C` where `C` is an abelian category,
the projector `PInfty : K[X] ⟶ K[X]` is supposed to be the projection
on the normalized subcomplex, parallel to the degenerate subcomplex, i.e.
the subcomplex generated by the images of all `X.σ i`.
In this file, we obtain `degeneracy_comp_P_infty` which states that
if `X : SimplicialObject C` with `C` a preadditive category,
`θ : ⦋n⦌ ⟶ Δ'` is a non-injective map in `SimplexCategory`, then
`X.map θ.op ≫ P_infty.f n = 0`. It follows from the more precise
statement vanishing statement `σ_comp_P_eq_zero` for the `P q`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Preadditive Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
theorem HigherFacesVanish.comp_σ {Y : C} {X : SimplicialObject C} {n b q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌}
(v : HigherFacesVanish q φ) (hnbq : n + 1 = b + q) :
HigherFacesVanish q
(φ ≫
X.σ ⟨b, by
simp only [hnbq, Nat.lt_add_one_iff, le_add_iff_nonneg_right, zero_le]⟩) :=
fun j hj => by
rw [assoc, SimplicialObject.δ_comp_σ_of_gt', Fin.pred_succ, v.comp_δ_eq_zero_assoc _ _ hj,
zero_comp]
· intro hj'
simp only [hnbq, add_comm b, add_assoc, hj', Fin.val_zero, zero_add, add_le_iff_nonpos_right,
nonpos_iff_eq_zero, add_eq_zero, false_and, reduceCtorEq] at hj
· dsimp
rw [Fin.lt_iff_val_lt_val, Fin.val_succ]
linarith
theorem σ_comp_P_eq_zero (X : SimplicialObject C) {n q : ℕ} (i : Fin (n + 1)) (hi : n + 1 ≤ i + q) :
X.σ i ≫ (P q).f (n + 1) = 0 := by
induction q generalizing i with
| zero => cutsat
| succ q hq =>
by_cases h : n + 1 ≤ (i : ℕ) + q
· rw [P_succ, HomologicalComplex.comp_f, ← assoc, hq i h, zero_comp]
· replace hi : n = i + q := by omega
rcases n with _ | n
· fin_cases i
dsimp at h hi
rw [show q = 0 by cutsat]
change X.σ 0 ≫ (P 1).f 1 = 0
simp only [P_succ, HomologicalComplex.add_f_apply, comp_add,
AlternatingFaceMapComplex.obj_d_eq, Hσ,
HomologicalComplex.comp_f, Homotopy.nullHomotopicMap'_f (c_mk 2 1 rfl) (c_mk 1 0 rfl),
comp_id]
rw [hσ'_eq' (zero_add 0).symm, hσ'_eq' (add_zero 1).symm]
dsimp [P_zero]
rw [comp_id, Fin.sum_univ_two,
Fin.sum_univ_succ, Fin.sum_univ_two]
simp only [Fin.val_zero, pow_zero, pow_one, pow_add, one_smul, neg_smul, Fin.val_succ,
Fin.val_one, mul_neg, one_mul, neg_mul, neg_neg, id_comp, add_comp, comp_add, neg_comp,
comp_neg, Fin.succ_zero_eq_one]
rw [← Fin.castSucc_one, SimplicialObject.δ_comp_σ_self, ← Fin.castSucc_zero (n := 1),
SimplicialObject.δ_comp_σ_self_assoc,
SimplicialObject.δ_comp_σ_succ, comp_id, ← Fin.castSucc_zero (n := 2),
← Fin.succ_zero_eq_one,
SimplicialObject.δ_comp_σ_of_le X
(show (0 : Fin 2) ≤ Fin.castSucc 0 by rw [Fin.castSucc_zero]),
← Fin.castSucc_zero (n := 1), SimplicialObject.δ_comp_σ_self_assoc,
SimplicialObject.δ_comp_σ_succ_assoc]
simp only [add_neg_cancel, add_zero, zero_add]
· rw [← id_comp (X.σ i), ← (P_add_Q_f q n.succ : _ = 𝟙 (X.obj _)), add_comp, add_comp,
P_succ]
have v : HigherFacesVanish q ((P q).f n.succ ≫ X.σ i) :=
(HigherFacesVanish.of_P q n).comp_σ hi
dsimp only [AlternatingFaceMapComplex.obj_X, Nat.succ_eq_add_one, HomologicalComplex.comp_f,
HomologicalComplex.add_f_apply, HomologicalComplex.id_f]
rw [← assoc, v.comp_P_eq_self, Preadditive.comp_add,
comp_id, v.comp_Hσ_eq hi, assoc, ← Fin.succ_mk _ _ i.2,
SimplicialObject.δ_comp_σ_succ_assoc,
Fin.eta, decomposition_Q n q, sum_comp, sum_comp, Finset.sum_eq_zero, add_zero,
add_neg_eq_zero]
intro j hj
simp only [Finset.mem_univ, Finset.mem_filter] at hj
obtain ⟨k, hk⟩ := Nat.le.dest (Nat.lt_succ_iff.mp (Fin.is_lt j))
rw [add_comm] at hk
have hi' : i = Fin.castSucc ⟨i, by cutsat⟩ := by
ext
simp only [Fin.castSucc_mk, Fin.eta]
have eq := hq j.rev.succ (by
simp only [← hk, Fin.rev_eq j hk.symm, Fin.succ_mk, Fin.val_mk]
cutsat)
rw [assoc, assoc, assoc, hi',
SimplicialObject.σ_comp_σ_assoc, reassoc_of% eq, zero_comp, comp_zero, comp_zero,
comp_zero]
simp only [Fin.rev_eq j hk.symm, Fin.le_iff_val_le_val]
cutsat
@[reassoc (attr := simp)]
theorem σ_comp_PInfty (X : SimplicialObject C) {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ PInfty.f (n + 1) = 0 := by
rw [PInfty_f, σ_comp_P_eq_zero X i]
simp only [le_add_iff_nonneg_left, zero_le]
@[reassoc]
theorem degeneracy_comp_PInfty (X : SimplicialObject C) (n : ℕ) {Δ' : SimplexCategory}
(θ : ⦋n⦌ ⟶ Δ') (hθ : ¬Mono θ) : X.map θ.op ≫ PInfty.f n = 0 := by
rw [SimplexCategory.mono_iff_injective] at hθ
cases n
· exfalso
apply hθ
intro x y h
fin_cases x
fin_cases y
rfl
· obtain ⟨i, α, h⟩ := SimplexCategory.eq_σ_comp_of_not_injective θ hθ
rw [h, op_comp, X.map_comp, assoc, show X.map (SimplexCategory.σ i).op = X.σ i by rfl,
σ_comp_PInfty, comp_zero]
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Homotopies.lean | import Mathlib.Algebra.Homology.Homotopy
import Mathlib.AlgebraicTopology.DoldKan.Notations
/-!
# Construction of homotopies for the Dold-Kan correspondence
(The general strategy of proof of the Dold-Kan correspondence is explained
in `Equivalence.lean`.)
The purpose of the files `Homotopies.lean`, `Faces.lean`, `Projections.lean`
and `PInfty.lean` is to construct an idempotent endomorphism
`PInfty : K[X] ⟶ K[X]` of the alternating face map complex
for each `X : SimplicialObject C` when `C` is a preadditive category.
In the case `C` is abelian, this `PInfty` shall be the projection on the
normalized Moore subcomplex of `K[X]` associated to the decomposition of the
complex `K[X]` as a direct sum of this normalized subcomplex and of the
degenerate subcomplex.
In `PInfty.lean`, this endomorphism `PInfty` shall be obtained by
passing to the limit idempotent endomorphisms `P q` for all `(q : ℕ)`.
These endomorphisms `P q` are defined by induction. The idea is to
start from the identity endomorphism `P 0` of `K[X]` and to ensure by
induction that the `q` higher face maps (except $d_0$) vanish on the
image of `P q`. Then, in a certain degree `n`, the image of `P q` for
a big enough `q` will be contained in the normalized subcomplex. This
construction is done in `Projections.lean`.
It would be easy to define the `P q` degreewise (similarly as it is done
in *Simplicial Homotopy Theory* by Goerrs-Jardine p. 149), but then we would
have to prove that they are compatible with the differential (i.e. they
are chain complex maps), and also that they are homotopic to the identity.
These two verifications are quite technical. In order to reduce the number
of such technical lemmas, the strategy that is followed here is to define
a series of null homotopic maps `Hσ q` (attached to families of maps `hσ`)
and use these in order to construct `P q` : the endomorphisms `P q`
shall basically be obtained by altering the identity endomorphism by adding
null homotopic maps, so that we get for free that they are morphisms
of chain complexes and that they are homotopic to the identity. The most
technical verifications that are needed about the null homotopic maps `Hσ`
are obtained in `Faces.lean`.
In this file `Homotopies.lean`, we define the null homotopic maps
`Hσ q : K[X] ⟶ K[X]`, show that they are natural (see `natTransHσ`) and
compatible the application of additive functors (see `map_Hσ`).
## References
* [Albrecht Dold, *Homology of Symmetric Products and Other Functors of Complexes*][dold1958]
* [Paul G. Goerss, John F. Jardine, *Simplicial Homotopy Theory*][goerss-jardine-2009]
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive
CategoryTheory.SimplicialObject Homotopy Opposite Simplicial DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
variable {X : SimplicialObject C}
/-- As we are using chain complexes indexed by `ℕ`, we shall need the relation
`c` such `c m n` if and only if `n+1=m`. -/
abbrev c :=
ComplexShape.down ℕ
/-- Helper when we need some `c.rel i j` (i.e. `ComplexShape.down ℕ`),
e.g. `c_mk n (n+1) rfl` -/
theorem c_mk (i j : ℕ) (h : j + 1 = i) : c.Rel i j :=
ComplexShape.down_mk i j h
/-- This lemma is meant to be used with `nullHomotopicMap'_f_of_not_rel_left` -/
theorem cs_down_0_not_rel_left (j : ℕ) : ¬c.Rel 0 j := by
intro hj
dsimp at hj
apply Nat.not_succ_le_zero j
rw [Nat.succ_eq_add_one, hj]
/-- The sequence of maps which gives the null homotopic maps `Hσ` that shall be in
the inductive construction of the projections `P q : K[X] ⟶ K[X]` -/
def hσ (q : ℕ) (n : ℕ) : X _⦋n⦌ ⟶ X _⦋n + 1⦌ :=
if n < q then 0 else (-1 : ℤ) ^ (n - q) • X.σ ⟨n - q, Nat.lt_succ_of_le (Nat.sub_le _ _)⟩
/-- We can turn `hσ` into a datum that can be passed to `nullHomotopicMap'`. -/
def hσ' (q : ℕ) : ∀ n m, c.Rel m n → (K[X].X n ⟶ K[X].X m) := fun n m hnm =>
hσ q n ≫ eqToHom (by congr)
theorem hσ'_eq_zero {q n m : ℕ} (hnq : n < q) (hnm : c.Rel m n) :
(hσ' q n m hnm : X _⦋n⦌ ⟶ X _⦋m⦌) = 0 := by
simp only [hσ', hσ]
split_ifs
exact zero_comp
theorem hσ'_eq {q n a m : ℕ} (ha : n = a + q) (hnm : c.Rel m n) :
(hσ' q n m hnm : X _⦋n⦌ ⟶ X _⦋m⦌) =
((-1 : ℤ) ^ a • X.σ ⟨a, Nat.lt_succ_iff.mpr (Nat.le.intro (Eq.symm ha))⟩) ≫
eqToHom (by congr) := by
grind [hσ', hσ]
theorem hσ'_eq' {q n a : ℕ} (ha : n = a + q) :
(hσ' q n (n + 1) rfl : X _⦋n⦌ ⟶ X _⦋n + 1⦌) =
(-1 : ℤ) ^ a • X.σ ⟨a, Nat.lt_succ_iff.mpr (Nat.le.intro (Eq.symm ha))⟩ := by
rw [hσ'_eq ha rfl, eqToHom_refl, comp_id]
/-- The null homotopic map $(hσ q) ∘ d + d ∘ (hσ q)$ -/
def Hσ (q : ℕ) : K[X] ⟶ K[X] :=
nullHomotopicMap' (hσ' q)
/-- `Hσ` is null homotopic -/
def homotopyHσToZero (q : ℕ) : Homotopy (Hσ q : K[X] ⟶ K[X]) 0 :=
nullHomotopy' (hσ' q)
/-- In degree `0`, the null homotopic map `Hσ` is zero. -/
theorem Hσ_eq_zero (q : ℕ) : (Hσ q : K[X] ⟶ K[X]).f 0 = 0 := by
unfold Hσ
rw [nullHomotopicMap'_f_of_not_rel_left (c_mk 1 0 rfl) cs_down_0_not_rel_left]
rcases q with (_ | q)
· rw [hσ'_eq (show 0 = 0 + 0 by rfl) (c_mk 1 0 rfl)]
simp only [pow_zero, Fin.mk_zero, one_zsmul, eqToHom_refl, Category.comp_id]
-- This `erw` is needed to show `0 + 1 = 1`.
erw [ChainComplex.of_d]
rw [AlternatingFaceMapComplex.objD, Fin.sum_univ_two, Fin.val_zero, Fin.val_one, pow_zero,
pow_one, one_smul, neg_smul, one_smul, comp_add, comp_neg, add_neg_eq_zero,
← Fin.succ_zero_eq_one, δ_comp_σ_succ, δ_comp_σ_self' X (by rw [Fin.castSucc_zero'])]
· rw [hσ'_eq_zero (Nat.succ_pos q) (c_mk 1 0 rfl), zero_comp]
/-- The maps `hσ' q n m hnm` are natural on the simplicial object -/
theorem hσ'_naturality (q : ℕ) (n m : ℕ) (hnm : c.Rel m n) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op ⦋n⦌) ≫ hσ' q n m hnm = hσ' q n m hnm ≫ f.app (op ⦋m⦌) := by
have h : n + 1 = m := hnm
subst h
simp only [hσ', eqToHom_refl, comp_id]
unfold hσ
split_ifs
· rw [zero_comp, comp_zero]
· simp
/-- For each q, `Hσ q` is a natural transformation. -/
def natTransHσ (q : ℕ) : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app _ := Hσ q
naturality _ _ f := by
unfold Hσ
rw [nullHomotopicMap'_comp, comp_nullHomotopicMap']
congr
ext n m hnm
simp only [alternatingFaceMapComplex_map_f, hσ'_naturality]
/-- The maps `hσ' q n m hnm` are compatible with the application of additive functors. -/
theorem map_hσ' {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n m : ℕ) (hnm : c.Rel m n) :
(hσ' q n m hnm : K[((whiskering _ _).obj G).obj X].X n ⟶ _) =
G.map (hσ' q n m hnm : K[X].X n ⟶ _) := by
unfold hσ' hσ
split_ifs
· simp only [Functor.map_zero, zero_comp]
· simp only [eqToHom_map, Functor.map_comp, Functor.map_zsmul]
rfl
/-- The null homotopic maps `Hσ` are compatible with the application of additive functors. -/
theorem map_Hσ {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n : ℕ) :
(Hσ q : K[((whiskering C D).obj G).obj X] ⟶ _).f n = G.map ((Hσ q : K[X] ⟶ _).f n) := by
unfold Hσ
have eq := HomologicalComplex.congr_hom (map_nullHomotopicMap' G (@hσ' _ _ _ X q)) n
simp only [Functor.mapHomologicalComplex_map_f, ← map_hσ'] at eq
rw [eq]
let h := (Functor.congr_obj (map_alternatingFaceMapComplex G) X).symm
congr
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/NCompGamma.lean | import Mathlib.AlgebraicTopology.DoldKan.GammaCompN
import Mathlib.AlgebraicTopology.DoldKan.NReflectsIso
/-! The unit isomorphism of the Dold-Kan equivalence
In order to construct the unit isomorphism of the Dold-Kan equivalence,
we first construct natural transformations
`Γ₂N₁.natTrans : N₁ ⋙ Γ₂ ⟶ toKaroubi (SimplicialObject C)` and
`Γ₂N₂.natTrans : N₂ ⋙ Γ₂ ⟶ 𝟭 (SimplicialObject C)`.
It is then shown that `Γ₂N₂.natTrans` is an isomorphism by using
that it becomes an isomorphism after the application of the functor
`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`
which reflects isomorphisms.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents
SimplexCategory Opposite SimplicialObject Simplicial DoldKan
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
theorem PInfty_comp_map_mono_eq_zero (X : SimplicialObject C) {n : ℕ} {Δ' : SimplexCategory}
(i : Δ' ⟶ ⦋n⦌) [hi : Mono i] (h₁ : Δ'.len ≠ n) (h₂ : ¬Isδ₀ i) :
PInfty.f n ≫ X.map i.op = 0 := by
induction Δ' using SimplexCategory.rec with | _ m
obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i fun h => by
rw [← h] at h₁
exact h₁ rfl)
simp only [len_mk] at hk
rcases k with _ | k
· change n = m + 1 at hk
subst hk
obtain ⟨j, rfl⟩ := eq_δ_of_mono i
rw [Isδ₀.iff] at h₂
have h₃ : 1 ≤ (j : ℕ) := by
by_contra h
exact h₂ (by simpa only [Fin.ext_iff, not_le, Nat.lt_one_iff] using h)
exact (HigherFacesVanish.of_P (m + 1) m).comp_δ_eq_zero j h₂ (by cutsat)
· simp only [← add_assoc] at hk
clear h₂ hi
subst hk
obtain ⟨j₁ : Fin (_ + 1), i, rfl⟩ :=
eq_comp_δ_of_not_surjective i fun h => by
rw [← SimplexCategory.epi_iff_surjective] at h
grind [→ le_of_epi]
obtain ⟨j₂, i, rfl⟩ :=
eq_comp_δ_of_not_surjective i fun h => by
rw [← SimplexCategory.epi_iff_surjective] at h
grind [→ le_of_epi]
by_cases hj₁ : j₁ = 0
· subst hj₁
rw [assoc, ← SimplexCategory.δ_comp_δ'' (Fin.zero_le _)]
simp only [op_comp, X.map_comp, assoc, PInfty_f]
erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ j₂.succ_ne_zero, zero_comp]
simp only [Fin.succ]
cutsat
· simp only [op_comp, X.map_comp, assoc, PInfty_f]
erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ hj₁, zero_comp]
by_contra
exact hj₁ (by simp only [Fin.ext_iff, Fin.val_zero]; cutsat)
@[reassoc]
theorem Γ₀_obj_termwise_mapMono_comp_PInfty (X : SimplicialObject C) {Δ Δ' : SimplexCategory}
(i : Δ ⟶ Δ') [Mono i] :
Γ₀.Obj.Termwise.mapMono (AlternatingFaceMapComplex.obj X) i ≫ PInfty.f Δ.len =
PInfty.f Δ'.len ≫ X.map i.op := by
induction Δ using SimplexCategory.rec with | _ n
induction Δ' using SimplexCategory.rec with | _ n'
dsimp
-- We start with the case `i` is an identity
by_cases h : n = n'
· subst h
simp only [SimplexCategory.eq_id_of_mono i, Γ₀.Obj.Termwise.mapMono_id, op_id, X.map_id]
dsimp
simp only [id_comp, comp_id]
by_cases hi : Isδ₀ i
-- The case `i = δ 0`
· have h' : n' = n + 1 := hi.left
subst h'
simp only [Γ₀.Obj.Termwise.mapMono_δ₀' _ i hi]
dsimp
rw [← PInfty.comm _ n, AlternatingFaceMapComplex.obj_d_eq]
simp only [Preadditive.comp_sum]
rw [Finset.sum_eq_single (0 : Fin (n + 2))]
rotate_left
· intro b _ hb
rw [Preadditive.comp_zsmul, SimplicialObject.δ,
PInfty_comp_map_mono_eq_zero X (SimplexCategory.δ b) h
(by
rw [Isδ₀.iff]
exact hb),
zsmul_zero]
· simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff]
· simp only [hi.eq_δ₀, Fin.val_zero, pow_zero, one_zsmul]
rfl
-- The case `i ≠ δ 0`
· rw [Γ₀.Obj.Termwise.mapMono_eq_zero _ i _ hi, zero_comp]
swap
· by_contra h'
exact h (congr_arg SimplexCategory.len h'.symm)
rw [PInfty_comp_map_mono_eq_zero]
· exact h
· assumption
variable [HasFiniteCoproducts C]
namespace Γ₂N₁
/-- The natural transformation `N₁ ⋙ Γ₂ ⟶ toKaroubi (SimplicialObject C)`. -/
@[simps]
def natTrans : (N₁ : SimplicialObject C ⥤ _) ⋙ Γ₂ ⟶ toKaroubi _ where
app X :=
{ f :=
{ app := fun Δ => (Γ₀.splitting K[X]).desc Δ fun A => PInfty.f A.1.unop.len ≫ X.map A.e.op
naturality := fun Δ Δ' θ => by
apply (Γ₀.splitting K[X]).hom_ext'
intro A
change _ ≫ (Γ₀.obj K[X]).map θ ≫ _ = _
simp only [Splitting.ι_desc_assoc, assoc, Γ₀.Obj.map_on_summand'_assoc,
Splitting.ι_desc]
erw [Γ₀_obj_termwise_mapMono_comp_PInfty_assoc X (image.ι (θ.unop ≫ A.e))]
dsimp only [toKaroubi]
simp only [← X.map_comp]
congr 2
simp only [← op_comp]
exact Quiver.Hom.unop_inj (A.fac_pull θ) }
comm := by
apply (Γ₀.splitting K[X]).hom_ext
intro n
dsimp [N₁]
simp only [← Splitting.cofan_inj_id, Splitting.ι_desc, comp_id, Splitting.ι_desc_assoc,
assoc, PInfty_f_idem_assoc] }
naturality {X Y} f := by
ext1
apply (Γ₀.splitting K[X]).hom_ext
intro n
dsimp [N₁, toKaroubi]
simp only [← Splitting.cofan_inj_id, Splitting.ι_desc, Splitting.ι_desc_assoc, assoc,
PInfty_f_idem_assoc, PInfty_f_naturality_assoc,
NatTrans.naturality, Splitting.IndexSet.id_fst, unop_op, len_mk]
end Γ₂N₁
/-- The compatibility isomorphism relating `N₂ ⋙ Γ₂` and `N₁ ⋙ Γ₂`. -/
@[simps! hom_app inv_app]
def Γ₂N₂ToKaroubiIso : toKaroubi (SimplicialObject C) ⋙ N₂ ⋙ Γ₂ ≅ N₁ ⋙ Γ₂ :=
(Functor.associator _ _ _).symm ≪≫ Functor.isoWhiskerRight toKaroubiCompN₂IsoN₁ Γ₂
namespace Γ₂N₂
/-- The natural transformation `N₂ ⋙ Γ₂ ⟶ 𝟭 (SimplicialObject C)`. -/
def natTrans : (N₂ : Karoubi (SimplicialObject C) ⥤ _) ⋙ Γ₂ ⟶ 𝟭 _ :=
((Functor.whiskeringLeft _ _ _).obj (toKaroubi (SimplicialObject C))).preimage
(Γ₂N₂ToKaroubiIso.hom ≫ Γ₂N₁.natTrans)
theorem natTrans_app_f_app (P : Karoubi (SimplicialObject C)) :
Γ₂N₂.natTrans.app P =
(N₂ ⋙ Γ₂).map P.decompId_i ≫
(Γ₂N₂ToKaroubiIso.hom ≫ Γ₂N₁.natTrans).app P.X ≫ P.decompId_p := by
dsimp only [natTrans]
simp only [whiskeringLeft_obj_preimage_app, Functor.id_map]
end Γ₂N₂
theorem compatibility_Γ₂N₁_Γ₂N₂_natTrans (X : SimplicialObject C) :
Γ₂N₁.natTrans.app X =
(Γ₂N₂ToKaroubiIso.app X).inv ≫
Γ₂N₂.natTrans.app ((toKaroubi (SimplicialObject C)).obj X) := by
rw [Γ₂N₂.natTrans_app_f_app]
dsimp only [Karoubi.decompId_i_toKaroubi, Karoubi.decompId_p_toKaroubi, Functor.comp_map,
NatTrans.comp_app]
rw [N₂.map_id, Γ₂.map_id, Iso.app_inv]
dsimp only [toKaroubi]
erw [id_comp]
rw [comp_id, Iso.inv_hom_id_app_assoc]
theorem identity_N₂_objectwise (P : Karoubi (SimplicialObject C)) :
(N₂Γ₂.inv.app (N₂.obj P) : N₂.obj P ⟶ N₂.obj (Γ₂.obj (N₂.obj P))) ≫
N₂.map (Γ₂N₂.natTrans.app P) = 𝟙 (N₂.obj P) := by
ext n
have eq₁ : (N₂Γ₂.inv.app (N₂.obj P)).f.f n = PInfty.f n ≫ P.p.app (op ⦋n⦌) ≫
((Γ₀.splitting (N₂.obj P).X).cofan _).inj (Splitting.IndexSet.id (op ⦋n⦌)) := by
simp only [N₂Γ₂_inv_app_f_f, N₂_obj_p_f, assoc]
have eq₂ : ((Γ₀.splitting (N₂.obj P).X).cofan _).inj (Splitting.IndexSet.id (op ⦋n⦌)) ≫
(N₂.map (Γ₂N₂.natTrans.app P)).f.f n = PInfty.f n ≫ P.p.app (op ⦋n⦌) := by
dsimp
rw [PInfty_on_Γ₀_splitting_summand_eq_self_assoc, Γ₂N₂.natTrans_app_f_app]
dsimp
rw [Γ₂N₂ToKaroubiIso_hom_app, assoc, Splitting.ι_desc_assoc, assoc, assoc]
dsimp [toKaroubi]
rw [Splitting.ι_desc_assoc]
simp [Splitting.IndexSet.e]
simp only [Karoubi.comp_f, HomologicalComplex.comp_f, Karoubi.id_f, N₂_obj_p_f, assoc,
eq₁, eq₂, PInfty_f_naturality_assoc, app_idem, PInfty_f_idem_assoc]
theorem identity_N₂ :
(𝟙 (N₂ : Karoubi (SimplicialObject C) ⥤ _) ◫ N₂Γ₂.inv) ≫
(Functor.associator _ _ _).inv ≫ Γ₂N₂.natTrans ◫ 𝟙 (@N₂ C _ _) = 𝟙 N₂ := by
ext P : 2
dsimp only [NatTrans.comp_app, NatTrans.hcomp_app, Functor.comp_map, Functor.associator,
NatTrans.id_app, Functor.comp_obj]
rw [Γ₂.map_id, N₂.map_id, comp_id, id_comp, id_comp, identity_N₂_objectwise P]
instance : IsIso (Γ₂N₂.natTrans : (N₂ : Karoubi (SimplicialObject C) ⥤ _) ⋙ _ ⟶ _) := by
have : ∀ P : Karoubi (SimplicialObject C), IsIso (Γ₂N₂.natTrans.app P) := by
intro P
have : IsIso (N₂.map (Γ₂N₂.natTrans.app P)) := by
have h := identity_N₂_objectwise P
dsimp only [Functor.id_obj, Functor.comp_obj] at h
rw [hom_comp_eq_id] at h
rw [h]
infer_instance
exact isIso_of_reflects_iso _ N₂
apply NatIso.isIso_of_isIso_app
instance : IsIso (Γ₂N₁.natTrans : (N₁ : SimplicialObject C ⥤ _) ⋙ _ ⟶ _) := by
have : ∀ X : SimplicialObject C, IsIso (Γ₂N₁.natTrans.app X) := by
intro X
rw [compatibility_Γ₂N₁_Γ₂N₂_natTrans]
infer_instance
apply NatIso.isIso_of_isIso_app
/-- The unit isomorphism of the Dold-Kan equivalence. -/
@[simps! inv]
def Γ₂N₂ : 𝟭 _ ≅ (N₂ : Karoubi (SimplicialObject C) ⥤ _) ⋙ Γ₂ :=
(asIso Γ₂N₂.natTrans).symm
/-- The natural isomorphism `toKaroubi (SimplicialObject C) ≅ N₁ ⋙ Γ₂`. -/
@[simps! inv]
def Γ₂N₁ : toKaroubi _ ≅ (N₁ : SimplicialObject C ⥤ _) ⋙ Γ₂ :=
(asIso Γ₂N₁.natTrans).symm
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/PInfty.lean | import Mathlib.AlgebraicTopology.DoldKan.Projections
import Mathlib.CategoryTheory.Idempotents.FunctorCategories
import Mathlib.CategoryTheory.Idempotents.FunctorExtension
/-!
# Construction of the projection `PInfty` for the Dold-Kan correspondence
In this file, we construct the projection `PInfty : K[X] ⟶ K[X]` by passing
to the limit the projections `P q` defined in `Projections.lean`. This
projection is a critical tool in this formalisation of the Dold-Kan correspondence,
because in the case of abelian categories, `PInfty` corresponds to the
projection on the normalized Moore subcomplex, with kernel the degenerate subcomplex.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive
CategoryTheory.SimplicialObject CategoryTheory.Idempotents Opposite Simplicial DoldKan
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X : SimplicialObject C}
theorem P_is_eventually_constant {q n : ℕ} (hqn : n ≤ q) :
((P (q + 1)).f n : X _⦋n⦌ ⟶ _) = (P q).f n := by
cases n with
| zero => simp only [P_f_0_eq]
| succ n =>
simp only [P_succ, comp_add, comp_id, HomologicalComplex.add_f_apply, HomologicalComplex.comp_f,
add_eq_left]
exact (HigherFacesVanish.of_P q n).comp_Hσ_eq_zero (Nat.succ_le_iff.mp hqn)
theorem Q_is_eventually_constant {q n : ℕ} (hqn : n ≤ q) :
((Q (q + 1)).f n : X _⦋n⦌ ⟶ _) = (Q q).f n := by
simp only [Q, HomologicalComplex.sub_f_apply, P_is_eventually_constant hqn]
/-- The endomorphism `PInfty : K[X] ⟶ K[X]` obtained from the `P q` by passing to the limit. -/
noncomputable def PInfty : K[X] ⟶ K[X] :=
ChainComplex.ofHom _ _ _ _ _ _ (fun n => ((P n).f n : X _⦋n⦌ ⟶ _)) fun n => by
simpa only [← P_is_eventually_constant (show n ≤ n by rfl),
AlternatingFaceMapComplex.obj_d_eq] using (P (n + 1) : K[X] ⟶ _).comm (n + 1) n
/-- The endomorphism `QInfty : K[X] ⟶ K[X]` obtained from the `Q q` by passing to the limit. -/
noncomputable def QInfty : K[X] ⟶ K[X] :=
𝟙 _ - PInfty
@[simp]
theorem PInfty_f_0 : (PInfty.f 0 : X _⦋0⦌ ⟶ X _⦋0⦌) = 𝟙 _ :=
rfl
theorem PInfty_f (n : ℕ) : (PInfty.f n : X _⦋n⦌ ⟶ X _⦋n⦌) = (P n).f n :=
rfl
@[simp]
theorem QInfty_f_0 : (QInfty.f 0 : X _⦋0⦌ ⟶ X _⦋0⦌) = 0 := by
dsimp [QInfty]
simp only [sub_self]
theorem QInfty_f (n : ℕ) : (QInfty.f n : X _⦋n⦌ ⟶ X _⦋n⦌) = (Q n).f n :=
rfl
@[reassoc (attr := simp)]
theorem PInfty_f_naturality (n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op ⦋n⦌) ≫ PInfty.f n = PInfty.f n ≫ f.app (op ⦋n⦌) :=
P_f_naturality n n f
@[reassoc (attr := simp)]
theorem QInfty_f_naturality (n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op ⦋n⦌) ≫ QInfty.f n = QInfty.f n ≫ f.app (op ⦋n⦌) :=
Q_f_naturality n n f
@[reassoc (attr := simp)]
theorem PInfty_f_idem (n : ℕ) : (PInfty.f n : X _⦋n⦌ ⟶ _) ≫ PInfty.f n = PInfty.f n := by
simp only [PInfty_f, P_f_idem]
@[reassoc (attr := simp)]
theorem PInfty_idem : (PInfty : K[X] ⟶ _) ≫ PInfty = PInfty := by
ext n
exact PInfty_f_idem n
@[reassoc (attr := simp)]
theorem QInfty_f_idem (n : ℕ) : (QInfty.f n : X _⦋n⦌ ⟶ _) ≫ QInfty.f n = QInfty.f n :=
Q_f_idem _ _
@[reassoc (attr := simp)]
theorem QInfty_idem : (QInfty : K[X] ⟶ _) ≫ QInfty = QInfty := by
ext n
exact QInfty_f_idem n
@[reassoc (attr := simp)]
theorem PInfty_f_comp_QInfty_f (n : ℕ) : (PInfty.f n : X _⦋n⦌ ⟶ _) ≫ QInfty.f n = 0 := by
dsimp only [QInfty]
simp only [HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, comp_sub, comp_id,
PInfty_f_idem, sub_self]
@[reassoc (attr := simp)]
theorem PInfty_comp_QInfty : (PInfty : K[X] ⟶ _) ≫ QInfty = 0 := by
ext n
apply PInfty_f_comp_QInfty_f
@[reassoc (attr := simp)]
theorem QInfty_f_comp_PInfty_f (n : ℕ) : (QInfty.f n : X _⦋n⦌ ⟶ _) ≫ PInfty.f n = 0 := by
dsimp only [QInfty]
simp only [HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, sub_comp, id_comp,
PInfty_f_idem, sub_self]
@[reassoc (attr := simp)]
theorem QInfty_comp_PInfty : (QInfty : K[X] ⟶ _) ≫ PInfty = 0 := by
ext n
apply QInfty_f_comp_PInfty_f
@[simp]
theorem PInfty_add_QInfty : (PInfty : K[X] ⟶ _) + QInfty = 𝟙 _ := by
dsimp only [QInfty]
simp only [add_sub_cancel]
theorem PInfty_f_add_QInfty_f (n : ℕ) : (PInfty.f n : X _⦋n⦌ ⟶ _) + QInfty.f n = 𝟙 _ :=
HomologicalComplex.congr_hom PInfty_add_QInfty n
variable (C)
/-- `PInfty` induces a natural transformation, i.e. an endomorphism of
the functor `alternatingFaceMapComplex C`. -/
@[simps]
noncomputable def natTransPInfty : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app _ := PInfty
naturality X Y f := by
ext n
exact PInfty_f_naturality n f
/-- The natural transformation in each degree that is induced by `natTransPInfty`. -/
@[simps!]
noncomputable def natTransPInfty_f (n : ℕ) :=
natTransPInfty C ◫ 𝟙 (HomologicalComplex.eval _ _ n)
variable {C}
@[simp]
theorem map_PInfty_f {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (n : ℕ) :
(PInfty : K[((whiskering C D).obj G).obj X] ⟶ _).f n =
G.map ((PInfty : AlternatingFaceMapComplex.obj X ⟶ _).f n) := by
simp only [PInfty_f, map_P]
/-- Given an object `Y : Karoubi (SimplicialObject C)`, this lemma
computes `PInfty` for the associated object in `SimplicialObject (Karoubi C)`
in terms of `PInfty` for `Y.X : SimplicialObject C` and `Y.p`. -/
theorem karoubi_PInfty_f {Y : Karoubi (SimplicialObject C)} (n : ℕ) :
((PInfty : K[(karoubiFunctorCategoryEmbedding _ _).obj Y] ⟶ _).f n).f =
Y.p.app (op ⦋n⦌) ≫ (PInfty : K[Y.X] ⟶ _).f n := by
-- We introduce P_infty endomorphisms P₁, P₂, P₃, P₄ on various objects Y₁, Y₂, Y₃, Y₄.
let Y₁ := (karoubiFunctorCategoryEmbedding _ _).obj Y
let Y₂ := Y.X
let Y₃ := ((whiskering _ _).obj (toKaroubi C)).obj Y.X
let Y₄ := (karoubiFunctorCategoryEmbedding _ _).obj ((toKaroubi _).obj Y.X)
let P₁ : K[Y₁] ⟶ _ := PInfty
let P₂ : K[Y₂] ⟶ _ := PInfty
let P₃ : K[Y₃] ⟶ _ := PInfty
let P₄ : K[Y₄] ⟶ _ := PInfty
-- The statement of lemma relates P₁ and P₂.
change (P₁.f n).f = Y.p.app (op ⦋n⦌) ≫ P₂.f n
-- The proof proceeds by obtaining relations h₃₂, h₄₃, h₁₄.
have h₃₂ : (P₃.f n).f = P₂.f n := Karoubi.hom_ext_iff.mp (map_PInfty_f (toKaroubi C) Y₂ n)
have h₄₃ : P₄.f n = P₃.f n := by
have h := Functor.congr_obj (toKaroubi_comp_karoubiFunctorCategoryEmbedding _ _) Y₂
simp only [P₃, P₄, ← natTransPInfty_f_app]
congr 1
have h₁₄ := Idempotents.natTrans_eq
((𝟙 (karoubiFunctorCategoryEmbedding SimplexCategoryᵒᵖ C)) ◫
(natTransPInfty_f (Karoubi C) n)) Y
dsimp [natTransPInfty_f] at h₁₄
rw [id_comp, id_comp, comp_id, comp_id] at h₁₄
-- We use the three equalities h₃₂, h₄₃, h₁₄.
rw [← h₃₂, ← h₄₃, h₁₄]
simp only [KaroubiFunctorCategoryEmbedding.map_app_f, Karoubi.decompId_p_f,
Karoubi.decompId_i_f, Karoubi.comp_f]
let π : Y₄ ⟶ Y₄ := (toKaroubi _ ⋙ karoubiFunctorCategoryEmbedding _ _).map Y.p
have eq := Karoubi.hom_ext_iff.mp (PInfty_f_naturality n π)
simp only [Karoubi.comp_f] at eq
dsimp [π] at eq
rw [← eq, app_idem_assoc Y (op ⦋n⦌)]
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/EquivalencePseudoabelian.lean | import Mathlib.AlgebraicTopology.DoldKan.EquivalenceAdditive
import Mathlib.AlgebraicTopology.DoldKan.Compatibility
import Mathlib.CategoryTheory.Idempotents.SimplicialObject
import Mathlib.Tactic.SuppressCompilation
/-!
# The Dold-Kan correspondence for pseudoabelian categories
In this file, for any idempotent complete additive category `C`,
the Dold-Kan equivalence
`Idempotents.DoldKan.Equivalence C : SimplicialObject C ≌ ChainComplex C ℕ`
is obtained. It is deduced from the equivalence
`Preadditive.DoldKan.Equivalence` between the respective idempotent
completions of these categories using the fact that when `C` is idempotent complete,
then both `SimplicialObject C` and `ChainComplex C ℕ` are idempotent complete.
The construction of `Idempotents.DoldKan.Equivalence` uses the tools
introduced in the file `Compatibility.lean`. Doing so, the functor
`Idempotents.DoldKan.N` of the equivalence is
the composition of `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`
(defined in `FunctorN.lean`) and the inverse of the equivalence
`ChainComplex C ℕ ≌ Karoubi (ChainComplex C ℕ)`. The functor
`Idempotents.DoldKan.Γ` of the equivalence is by definition the functor
`Γ₀` introduced in `FunctorGamma.lean`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
suppress_compilation
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents
variable {C : Type*} [Category C] [Preadditive C]
namespace CategoryTheory
namespace Idempotents
namespace DoldKan
open AlgebraicTopology.DoldKan
/-- The functor `N` for the equivalence is obtained by composing
`N' : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)` and the inverse
of the equivalence `ChainComplex C ℕ ≌ Karoubi (ChainComplex C ℕ)`. -/
@[simps!, nolint unusedArguments]
def N [IsIdempotentComplete C] [HasFiniteCoproducts C] : SimplicialObject C ⥤ ChainComplex C ℕ :=
N₁ ⋙ (toKaroubiEquivalence _).inverse
/-- The functor `Γ` for the equivalence is `Γ'`. -/
@[simps!, nolint unusedArguments]
def Γ [IsIdempotentComplete C] [HasFiniteCoproducts C] : ChainComplex C ℕ ⥤ SimplicialObject C :=
Γ₀
variable [IsIdempotentComplete C] [HasFiniteCoproducts C]
/-- A reformulation of the isomorphism `toKaroubi (SimplicialObject C) ⋙ N₂ ≅ N₁` -/
def isoN₁ :
(toKaroubiEquivalence (SimplicialObject C)).functor ⋙
Preadditive.DoldKan.equivalence.functor ≅ N₁ := toKaroubiCompN₂IsoN₁
@[simp]
lemma isoN₁_hom_app_f (X : SimplicialObject C) :
(isoN₁.hom.app X).f = PInfty := rfl
/-- A reformulation of the canonical isomorphism
`toKaroubi (ChainComplex C ℕ) ⋙ Γ₂ ≅ Γ ⋙ toKaroubi (SimplicialObject C)`. -/
def isoΓ₀ :
(toKaroubiEquivalence (ChainComplex C ℕ)).functor ⋙ Preadditive.DoldKan.equivalence.inverse ≅
Γ ⋙ (toKaroubiEquivalence _).functor :=
(functorExtension₂CompWhiskeringLeftToKaroubiIso _ _).app Γ₀
@[simp]
lemma N₂_map_isoΓ₀_hom_app_f (X : ChainComplex C ℕ) :
(N₂.map (isoΓ₀.hom.app X)).f = PInfty := by
ext
apply comp_id
/-- The Dold-Kan equivalence for pseudoabelian categories given
by the functors `N` and `Γ`. It is obtained by applying the results in
`Compatibility.lean` to the equivalence `Preadditive.DoldKan.Equivalence`. -/
def equivalence : SimplicialObject C ≌ ChainComplex C ℕ :=
Compatibility.equivalence isoN₁ isoΓ₀
theorem equivalence_functor : (equivalence : SimplicialObject C ≌ _).functor = N :=
rfl
theorem equivalence_inverse : (equivalence : SimplicialObject C ≌ _).inverse = Γ :=
rfl
/-- The natural isomorphism `NΓ'` satisfies the compatibility that is needed
for the construction of our counit isomorphism `η`. -/
theorem hη :
Compatibility.τ₀ =
Compatibility.τ₁ isoN₁ isoΓ₀
(N₁Γ₀ : Γ ⋙ N₁ ≅ (toKaroubiEquivalence (ChainComplex C ℕ)).functor) := by
ext K : 3
simp only [Compatibility.τ₀_hom_app, Compatibility.τ₁_hom_app]
exact (N₂Γ₂_compatible_with_N₁Γ₀ K).trans (by simp )
/-- The counit isomorphism induced by `N₁Γ₀` -/
@[simps!]
def η : Γ ⋙ N ≅ 𝟭 (ChainComplex C ℕ) :=
Compatibility.equivalenceCounitIso
(N₁Γ₀ : (Γ : ChainComplex C ℕ ⥤ _) ⋙ N₁ ≅ (toKaroubiEquivalence _).functor)
theorem equivalence_counitIso :
DoldKan.equivalence.counitIso = (η : Γ ⋙ N ≅ 𝟭 (ChainComplex C ℕ)) :=
Compatibility.equivalenceCounitIso_eq hη
theorem hε :
Compatibility.υ (isoN₁) =
(Γ₂N₁ : (toKaroubiEquivalence _).functor ≅
(N₁ : SimplicialObject C ⥤ _) ⋙ Preadditive.DoldKan.equivalence.inverse) := by
dsimp only [isoN₁]
ext1
rw [← cancel_epi Γ₂N₁.inv, Iso.inv_hom_id]
ext X : 2
rw [NatTrans.comp_app, Γ₂N₁_inv, compatibility_Γ₂N₁_Γ₂N₂_natTrans X, Compatibility.υ_hom_app,
Preadditive.DoldKan.equivalence_unitIso, Iso.app_inv, assoc]
dsimp only [Functor.comp_obj, Preadditive.DoldKan.equivalence_inverse, Preadditive.DoldKan.Γ.eq_1,
toKaroubiEquivalence, Functor.asEquivalence_functor, Preadditive.DoldKan.N.eq_1,
NatTrans.id_app]
rw [← NatTrans.comp_app_assoc, ← Γ₂N₂_inv, Iso.inv_hom_id, NatTrans.id_app, id_comp,
Γ₂N₂ToKaroubiIso_inv_app, ← Γ₂.map_comp, Iso.inv_hom_id_app, Γ₂.map_id]
/-- The unit isomorphism induced by `Γ₂N₁`. -/
def ε : 𝟭 (SimplicialObject C) ≅ N ⋙ Γ :=
Compatibility.equivalenceUnitIso isoΓ₀ Γ₂N₁
theorem equivalence_unitIso :
DoldKan.equivalence.unitIso = (ε : 𝟭 (SimplicialObject C) ≅ N ⋙ Γ) :=
Compatibility.equivalenceUnitIso_eq hε
end DoldKan
end Idempotents
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Equivalence.lean | import Mathlib.AlgebraicTopology.DoldKan.EquivalencePseudoabelian
import Mathlib.AlgebraicTopology.DoldKan.Normalized
/-!
# The Dold-Kan correspondence
The Dold-Kan correspondence states that for any abelian category `A`, there is
an equivalence between the category of simplicial objects in `A` and the
category of chain complexes in `A` (with degrees indexed by `ℕ` and the
homological convention that the degree is decreased by the differentials).
In this file, we finish the construction of this equivalence by providing
`CategoryTheory.Abelian.DoldKan.equivalence` which is of type
`SimplicialObject A ≌ ChainComplex A ℕ` for any abelian category `A`.
The functor `SimplicialObject A ⥤ ChainComplex A ℕ` of this equivalence is
definitionally equal to `normalizedMooreComplex A`.
## Overall strategy of the proof of the correspondence
Before starting the implementation of the proof in Lean, the author noticed
that the Dold-Kan equivalence not only applies to abelian categories, but
should also hold generally for any pseudoabelian category `C`
(i.e. a category with instances `[Preadditive C]`
`[HasFiniteCoproducts C]` and `[IsIdempotentComplete C]`): this is
`CategoryTheory.Idempotents.DoldKan.equivalence`.
When the alternating face map complex `K[X]` of a simplicial object `X` in an
abelian is studied, it is shown that it decomposes as a direct sum of the
normalized subcomplex and of the degenerate subcomplex. The crucial observation
is that in this decomposition, the projection on the normalized subcomplex can
be defined in each degree using simplicial operators. Then, the definition
of this projection `PInfty : K[X] ⟶ K[X]` can be carried out for any
`X : SimplicialObject C` when `C` is a preadditive category.
The construction of the endomorphism `PInfty` is done in the files
`Homotopies.lean`, `Faces.lean`, `Projections.lean` and `PInfty.lean`.
Eventually, as we would also like to show that the inclusion of the normalized
Moore complex is a homotopy equivalence (cf. file `HomotopyEquivalence.lean`),
this projection `PInfty` needs to be homotopic to the identity. In our
construction, we get this for free because `PInfty` is obtained by altering
the identity endomorphism by null homotopic maps. More details about this
aspect of the proof are in the file `Homotopies.lean`.
When the alternating face map complex `K[X]` is equipped with the idempotent
endomorphism `PInfty`, it becomes an object in `Karoubi (ChainComplex C ℕ)`
which is the idempotent completion of the category `ChainComplex C ℕ`. In `FunctorN.lean`,
we obtain this functor `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`,
which is formally extended as
`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`. (Here, some functors
have an index which is the number of occurrences of `Karoubi` at the source or the
target.)
In `FunctorGamma.lean`, assuming that the category `C` is additive,
we define the functor in the other direction
`Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)` as the formal
extension of a functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C` which is
defined similarly as in [*Simplicial Homotopy Theory* by Goerss-Jardine][goerss-jardine-2009].
In `Degeneracies.lean`, we show that `PInfty` vanishes on the image of degeneracy
operators, which is one of the key properties that makes it possible to construct
the isomorphism `N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ))`.
The rest of the proof follows the strategy in the [original paper by Dold][dold1958]. We show
that the functor `N₂` reflects isomorphisms in `NReflectsIso.lean`: this relies on a
decomposition of the identity of `X _⦋n⦌` using `PInfty.f n` and degeneracies obtained in
`Decomposition.lean`. Then, in `NCompGamma.lean`, we construct a natural transformation
`Γ₂N₂.trans : N₂ ⋙ Γ₂ ⟶ 𝟭 (Karoubi (SimplicialObject C))`. It is shown that it is an
isomorphism using the fact that `N₂` reflects isomorphisms, and because we can show
that the composition `N₂ ⟶ N₂ ⋙ Γ₂ ⋙ N₂ ⟶ N₂` is the identity (see `identity_N₂`). The fact
that `N₂` is defined as a formal direct factor makes the proof easier because we only
have to compare endomorphisms of an alternating face map complex `K[X]` and we do not
have to worry with inclusions of kernel subobjects.
In `EquivalenceAdditive.lean`, we obtain
the equivalence `equivalence : Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`.
It is in the namespace `CategoryTheory.Preadditive.DoldKan`. The functors in this
equivalence are named `N` and `Γ`: by definition, they are `N₂` and `Γ₂`.
In `EquivalencePseudoabelian.lean`, assuming `C` is idempotent complete,
we obtain `equivalence : SimplicialObject C ≌ ChainComplex C ℕ`
in the namespace `CategoryTheory.Idempotents.DoldKan`. This could be roughly
obtained by composing the previous equivalence with the equivalences
`SimplicialObject C ≌ Karoubi (SimplicialObject C)` and
`Karoubi (ChainComplex C ℕ) ≌ ChainComplex C ℕ`. Instead, we polish this construction
in `Compatibility.lean` by ensuring good definitional properties of the equivalence (e.g.
the inverse functor is definitionally equal to
`Γ₀' : ChainComplex C ℕ ⥤ SimplicialObject C`) and
showing compatibilities for the unit and counit isomorphisms.
In this file `Equivalence.lean`, assuming the category `A` is abelian, we obtain
`equivalence : SimplicialObject A ≌ ChainComplex A ℕ` in the namespace
`CategoryTheory.Abelian.DoldKan`. This is obtained by replacing the functor
`CategoryTheory.Idempotents.DoldKan.N` of the equivalence in the pseudoabelian case
with the isomorphic functor `normalizedMooreComplex A` thanks to the isomorphism
obtained in `Normalized.lean`.
TODO: Show functoriality properties of the three equivalences above. More precisely,
for example in the case of abelian categories `A` and `B`, if `F : A ⥤ B` is an
additive functor, we can show that the functors `N` for `A` and `B` are compatible
with the functors `SimplicialObject A ⥤ SimplicialObject B` and
`ChainComplex A ℕ ⥤ ChainComplex B ℕ` induced by `F`. (Note that this does not
require that `F` is an exact functor!)
TODO: Introduce the degenerate subcomplex `D[X]` which is generated by
degenerate simplices, show that the projector `PInfty` corresponds to
a decomposition `K[X] ≅ N[X] ⊞ D[X]`.
TODO: dualise all of this as `CosimplicialObject A ⥤ CochainComplex A ℕ`. (It is unclear
what is the best way to do this. The exact design may be decided when it is needed.)
## References
* [Albrecht Dold, Homology of Symmetric Products and Other Functors of Complexes][dold1958]
* [Paul G. Goerss, John F. Jardine, Simplicial Homotopy Theory][goerss-jardine-2009]
-/
noncomputable section
open CategoryTheory Category Idempotents
variable {A : Type*} [Category A] [Abelian A]
namespace CategoryTheory
namespace Abelian
namespace DoldKan
open AlgebraicTopology.DoldKan
/-- The functor `N` for the equivalence is `normalizedMooreComplex A` -/
def N : SimplicialObject A ⥤ ChainComplex A ℕ :=
AlgebraicTopology.normalizedMooreComplex A
/-- The functor `Γ` for the equivalence is the same as in the pseudoabelian case. -/
def Γ : ChainComplex A ℕ ⥤ SimplicialObject A :=
Idempotents.DoldKan.Γ
/-- The comparison isomorphism between `normalizedMooreComplex A` and
the functor `Idempotents.DoldKan.N` from the pseudoabelian case -/
@[simps!]
def comparisonN : (N : SimplicialObject A ⥤ _) ≅ Idempotents.DoldKan.N :=
calc
N ≅ N ⋙ 𝟭 _ := Functor.leftUnitor N
_ ≅ N ⋙ (toKaroubiEquivalence _).functor ⋙ (toKaroubiEquivalence _).inverse :=
Functor.isoWhiskerLeft _ (toKaroubiEquivalence _).unitIso
_ ≅ (N ⋙ (toKaroubiEquivalence _).functor) ⋙ (toKaroubiEquivalence _).inverse :=
Iso.refl _
_ ≅ N₁ ⋙ (toKaroubiEquivalence _).inverse :=
Functor.isoWhiskerRight (N₁_iso_normalizedMooreComplex_comp_toKaroubi A).symm _
_ ≅ Idempotents.DoldKan.N := Iso.refl _
/-- The Dold-Kan equivalence for abelian categories -/
@[simps! functor]
def equivalence : SimplicialObject A ≌ ChainComplex A ℕ :=
(Idempotents.DoldKan.equivalence (C := A)).changeFunctor comparisonN.symm
theorem equivalence_inverse : (equivalence : SimplicialObject A ≌ _).inverse = Γ :=
rfl
end DoldKan
end Abelian
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/EquivalenceAdditive.lean | import Mathlib.AlgebraicTopology.DoldKan.NCompGamma
/-! The Dold-Kan equivalence for additive categories.
This file defines `Preadditive.DoldKan.equivalence` which is the equivalence
of categories `Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Idempotents AlgebraicTopology.DoldKan
variable {C : Type*} [Category C] [Preadditive C]
namespace CategoryTheory
namespace Preadditive
namespace DoldKan
/-- The functor `Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)` of
the Dold-Kan equivalence for additive categories. -/
@[simp]
def N : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ) :=
N₂
variable [HasFiniteCoproducts C]
/-- The inverse functor `Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)` of
the Dold-Kan equivalence for additive categories. -/
@[simp]
def Γ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C) :=
Γ₂
/-- The Dold-Kan equivalence `Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`
for additive categories. -/
@[simps]
def equivalence : Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ) where
functor := N
inverse := Γ
unitIso := Γ₂N₂
counitIso := N₂Γ₂
functor_unitIso_comp P := by
let α := N.mapIso (Γ₂N₂.app P)
let β := N₂Γ₂.app (N.obj P)
symm
change 𝟙 _ = α.hom ≫ β.hom
rw [← Iso.inv_comp_eq, comp_id, ← comp_id β.hom, ← Iso.inv_comp_eq]
exact AlgebraicTopology.DoldKan.identity_N₂_objectwise P
end DoldKan
end Preadditive
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Notations.lean | import Mathlib.AlgebraicTopology.AlternatingFaceMapComplex
/-!
# Notations for the Dold-Kan equivalence
This file defines the notation `K[X] : ChainComplex C ℕ` for the alternating face
map complex of `(X : SimplicialObject C)` where `C` is a preadditive category, as well
as `N[X]` for the normalized subcomplex in the case `C` is an abelian category.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
@[inherit_doc]
scoped[DoldKan] notation "K[" X "]" => AlgebraicTopology.AlternatingFaceMapComplex.obj X
@[inherit_doc]
scoped[DoldKan] notation "N[" X "]" => AlgebraicTopology.NormalizedMooreComplex.obj X |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/FunctorN.lean | import Mathlib.AlgebraicTopology.DoldKan.PInfty
/-!
# Construction of functors N for the Dold-Kan correspondence
In this file, we construct functors `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`
and `N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`
for any preadditive category `C`. (The indices of these functors are the number of occurrences
of `Karoubi` at the source or the target.)
In the case `C` is additive, the functor `N₂` shall be the functor of the equivalence
`CategoryTheory.Preadditive.DoldKan.equivalence` defined in `EquivalenceAdditive.lean`.
In the case the category `C` is pseudoabelian, the composition of `N₁` with the inverse of the
equivalence `ChainComplex C ℕ ⥤ Karoubi (ChainComplex C ℕ)` will be the functor
`CategoryTheory.Idempotents.DoldKan.N` of the equivalence of categories
`CategoryTheory.Idempotents.DoldKan.equivalence : SimplicialObject C ≌ ChainComplex C ℕ`
defined in `EquivalencePseudoabelian.lean`.
When the category `C` is abelian, a relation between `N₁` and the
normalized Moore complex functor shall be obtained in `Normalized.lean`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Idempotents
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
/-- The functor `SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)` which maps
`X` to the formal direct factor of `K[X]` defined by `PInfty`. -/
@[simps]
def N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ) where
obj X :=
{ X := AlternatingFaceMapComplex.obj X
p := PInfty
idem := PInfty_idem }
map f :=
{ f := PInfty ≫ AlternatingFaceMapComplex.map f }
/-- The extension of `N₁` to the Karoubi envelope of `SimplicialObject C`. -/
@[simps!]
def N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ) :=
(functorExtension₁ _ _).obj N₁
/-- The canonical isomorphism `toKaroubi (SimplicialObject C) ⋙ N₂ ≅ N₁`. -/
def toKaroubiCompN₂IsoN₁ : toKaroubi (SimplicialObject C) ⋙ N₂ ≅ N₁ :=
(functorExtension₁CompWhiskeringLeftToKaroubiIso _ _).app N₁
@[simp]
lemma toKaroubiCompN₂IsoN₁_hom_app (X : SimplicialObject C) :
(toKaroubiCompN₂IsoN₁.hom.app X).f = PInfty := rfl
@[simp]
lemma toKaroubiCompN₂IsoN₁_inv_app (X : SimplicialObject C) :
(toKaroubiCompN₂IsoN₁.inv.app X).f = PInfty := rfl
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/DoldKan/Compatibility.lean | import Mathlib.CategoryTheory.Equivalence
/-! Tools for compatibilities between Dold-Kan equivalences
The purpose of this file is to introduce tools which will enable the
construction of the Dold-Kan equivalence `SimplicialObject C ≌ ChainComplex C ℕ`
for a pseudoabelian category `C` from the equivalence
`Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)` and the two
equivalences `simplicial_object C ≅ Karoubi (SimplicialObject C)` and
`ChainComplex C ℕ ≅ Karoubi (ChainComplex C ℕ)`.
It is certainly possible to get an equivalence `SimplicialObject C ≌ ChainComplex C ℕ`
using a compositions of the three equivalences above, but then neither the functor
nor the inverse would have good definitional properties. For example, it would be better
if the inverse functor of the equivalence was exactly the functor
`Γ₀ : SimplicialObject C ⥤ ChainComplex C ℕ` which was constructed in `FunctorGamma.lean`.
In this file, given four categories `A`, `A'`, `B`, `B'`, equivalences `eA : A ≅ A'`,
`eB : B ≅ B'`, `e' : A' ≅ B'`, functors `F : A ⥤ B'`, `G : B ⥤ A` equipped with certain
compatibilities, we construct successive equivalences:
- `equivalence₀` from `A` to `B'`, which is the composition of `eA` and `e'`.
- `equivalence₁` from `A` to `B'`, with the same inverse functor as `equivalence₀`,
but whose functor is `F`.
- `equivalence₂` from `A` to `B`, which is the composition of `equivalence₁` and the
inverse of `eB`:
- `equivalence` from `A` to `B`, which has the same functor `F ⋙ eB.inverse` as `equivalence₂`,
but whose inverse functor is `G`.
When extra assumptions are given, we shall also provide simplification lemmas for the
unit and counit isomorphisms of `equivalence`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category Functor
namespace AlgebraicTopology
namespace DoldKan
namespace Compatibility
variable {A A' B B' : Type*} [Category A] [Category A'] [Category B] [Category B'] (eA : A ≌ A')
(eB : B ≌ B') (e' : A' ≌ B') {F : A ⥤ B'} (hF : eA.functor ⋙ e'.functor ≅ F) {G : B ⥤ A}
(hG : eB.functor ⋙ e'.inverse ≅ G ⋙ eA.functor)
/-- A basic equivalence `A ≅ B'` obtained by composing `eA : A ≅ A'` and `e' : A' ≅ B'`. -/
@[simps! functor inverse unitIso_hom_app]
def equivalence₀ : A ≌ B' :=
eA.trans e'
variable {eA} {e'}
/-- An intermediate equivalence `A ≅ B'` whose functor is `F` and whose inverse is
`e'.inverse ⋙ eA.inverse`. -/
@[simps! functor]
def equivalence₁ : A ≌ B' := (equivalence₀ eA e').changeFunctor hF
theorem equivalence₁_inverse : (equivalence₁ hF).inverse = e'.inverse ⋙ eA.inverse :=
rfl
/-- The counit isomorphism of the equivalence `equivalence₁` between `A` and `B'`. -/
@[simps!]
def equivalence₁CounitIso : (e'.inverse ⋙ eA.inverse) ⋙ F ≅ 𝟭 B' :=
calc
(e'.inverse ⋙ eA.inverse) ⋙ F ≅ (e'.inverse ⋙ eA.inverse) ⋙ eA.functor ⋙ e'.functor :=
isoWhiskerLeft _ hF.symm
_ ≅ e'.inverse ⋙ (eA.inverse ⋙ eA.functor ⋙ e'.functor) := associator _ _ _
_ ≅ e'.inverse ⋙ (eA.inverse ⋙ eA.functor) ⋙ e'.functor :=
isoWhiskerLeft _ (associator _ _ _).symm
_ ≅ e'.inverse ⋙ 𝟭 _ ⋙ e'.functor := isoWhiskerLeft _ (isoWhiskerRight eA.counitIso _)
_ ≅ e'.inverse ⋙ e'.functor := isoWhiskerLeft _ (leftUnitor _)
_ ≅ 𝟭 B' := e'.counitIso
theorem equivalence₁CounitIso_eq : (equivalence₁ hF).counitIso = equivalence₁CounitIso hF := by
ext Y
simp [equivalence₁, equivalence₀]
/-- The unit isomorphism of the equivalence `equivalence₁` between `A` and `B'`. -/
@[simps!]
def equivalence₁UnitIso : 𝟭 A ≅ F ⋙ e'.inverse ⋙ eA.inverse :=
calc
𝟭 A ≅ eA.functor ⋙ eA.inverse := eA.unitIso
_ ≅ eA.functor ⋙ 𝟭 A' ⋙ eA.inverse := isoWhiskerLeft _ (leftUnitor _).symm
_ ≅ eA.functor ⋙ (e'.functor ⋙ e'.inverse) ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight e'.unitIso _)
_ ≅ eA.functor ⋙ (e'.functor ⋙ e'.inverse ⋙ eA.inverse) :=
isoWhiskerLeft _ (associator _ _ _)
_ ≅ (eA.functor ⋙ e'.functor) ⋙ e'.inverse ⋙ eA.inverse := (associator _ _ _).symm
_ ≅ F ⋙ e'.inverse ⋙ eA.inverse := isoWhiskerRight hF _
theorem equivalence₁UnitIso_eq : (equivalence₁ hF).unitIso = equivalence₁UnitIso hF := by
ext X
simp [equivalence₁]
/-- An intermediate equivalence `A ≅ B` obtained as the composition of `equivalence₁` and
the inverse of `eB : B ≌ B'`. -/
@[simps! functor]
def equivalence₂ : A ≌ B :=
(equivalence₁ hF).trans eB.symm
theorem equivalence₂_inverse :
(equivalence₂ eB hF).inverse = eB.functor ⋙ e'.inverse ⋙ eA.inverse :=
rfl
/-- The counit isomorphism of the equivalence `equivalence₂` between `A` and `B`. -/
@[simps!]
def equivalence₂CounitIso : (eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ F ⋙ eB.inverse ≅ 𝟭 B :=
calc
(eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ F ⋙ eB.inverse
≅ eB.functor ⋙ (e'.inverse ⋙ eA.inverse) ⋙ F ⋙ eB.inverse := associator _ _ _
_ ≅ eB.functor ⋙ ((e'.inverse ⋙ eA.inverse) ⋙ F) ⋙ eB.inverse :=
isoWhiskerLeft _ (associator _ _ _).symm
_ ≅ eB.functor ⋙ 𝟭 _ ⋙ eB.inverse :=
isoWhiskerLeft _ (isoWhiskerRight (equivalence₁CounitIso hF) _)
_ ≅ eB.functor ⋙ eB.inverse := isoWhiskerLeft _ (leftUnitor _)
_ ≅ 𝟭 B := eB.unitIso.symm
theorem equivalence₂CounitIso_eq :
(equivalence₂ eB hF).counitIso = equivalence₂CounitIso eB hF := by
ext Y'
simp [equivalence₂, equivalence₁CounitIso_eq]
/-- The unit isomorphism of the equivalence `equivalence₂` between `A` and `B`. -/
@[simps!]
def equivalence₂UnitIso : 𝟭 A ≅ (F ⋙ eB.inverse) ⋙ eB.functor ⋙ e'.inverse ⋙ eA.inverse :=
calc
𝟭 A ≅ F ⋙ e'.inverse ⋙ eA.inverse := equivalence₁UnitIso hF
_ ≅ F ⋙ 𝟭 B' ⋙ e'.inverse ⋙ eA.inverse :=
isoWhiskerLeft _ (leftUnitor _).symm
_ ≅ F ⋙ (eB.inverse ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight eB.counitIso.symm _)
_ ≅ (F ⋙ eB.inverse ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :=
(associator _ _ _).symm
_ ≅ ((F ⋙ eB.inverse) ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :=
isoWhiskerRight (associator _ _ _).symm _
_ ≅ (F ⋙ eB.inverse) ⋙ eB.functor ⋙ e'.inverse ⋙ eA.inverse :=
associator _ _ _
theorem equivalence₂UnitIso_eq : (equivalence₂ eB hF).unitIso = equivalence₂UnitIso eB hF := by
ext X
simp [equivalence₂, equivalence₁]
variable {eB}
/-- The equivalence `A ≅ B` whose functor is `F ⋙ eB.inverse` and
whose inverse is `G : B ≅ A`. -/
@[simps! inverse]
def equivalence : A ≌ B :=
((equivalence₂ eB hF).changeInverse
(calc eB.functor ⋙ e'.inverse ⋙ eA.inverse ≅
(eB.functor ⋙ e'.inverse) ⋙ eA.inverse := (associator _ _ _).symm
_ ≅ (G ⋙ eA.functor) ⋙ eA.inverse := isoWhiskerRight hG _
_ ≅ G ⋙ eA.functor ⋙ eA.inverse := associator _ _ _
_ ≅ G ⋙ 𝟭 A := isoWhiskerLeft _ eA.unitIso.symm
_ ≅ G := G.rightUnitor))
theorem equivalence_functor : (equivalence hF hG).functor = F ⋙ eB.inverse :=
rfl
/-- The isomorphism `eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor` deduced
from the counit isomorphism of `e'`. -/
@[simps! hom_app]
def τ₀ : eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor :=
calc
eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor ⋙ 𝟭 _ := isoWhiskerLeft _ e'.counitIso
_ ≅ eB.functor := Functor.rightUnitor _
/-- The isomorphism `eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor` deduced
from the isomorphisms `hF : eA.functor ⋙ e'.functor ≅ F`,
`hG : eB.functor ⋙ e'.inverse ≅ G ⋙ eA.functor` and the datum of
an isomorphism `η : G ⋙ F ≅ eB.functor`. -/
@[simps! hom_app]
def τ₁ (η : G ⋙ F ≅ eB.functor) : eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor :=
calc
eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ (eB.functor ⋙ e'.inverse) ⋙ e'.functor :=
(associator _ _ _).symm
_ ≅ (G ⋙ eA.functor) ⋙ e'.functor := isoWhiskerRight hG _
_ ≅ G ⋙ eA.functor ⋙ e'.functor := associator _ _ _
_ ≅ G ⋙ F := isoWhiskerLeft _ hF
_ ≅ eB.functor := η
variable (η : G ⋙ F ≅ eB.functor)
/-- The counit isomorphism of `equivalence`. -/
@[simps!]
def equivalenceCounitIso : G ⋙ F ⋙ eB.inverse ≅ 𝟭 B :=
calc
G ⋙ F ⋙ eB.inverse ≅ (G ⋙ F) ⋙ eB.inverse := (associator _ _ _).symm
_ ≅ eB.functor ⋙ eB.inverse := isoWhiskerRight η _
_ ≅ 𝟭 B := eB.unitIso.symm
variable {η hF hG}
theorem equivalenceCounitIso_eq (hη : τ₀ = τ₁ hF hG η) :
(equivalence hF hG).counitIso = equivalenceCounitIso η := by
ext1; apply NatTrans.ext; ext Y
dsimp [equivalence]
simp only [comp_id, id_comp, Functor.map_comp, equivalence₂CounitIso_eq,
equivalence₂CounitIso_hom_app, assoc, equivalenceCounitIso_hom_app]
simp only [equivalence₂_inverse, comp_obj, ← τ₀_hom_app, hη, τ₁_hom_app, ←
eB.inverse.map_comp_assoc]
rw [hF.inv.naturality_assoc, hF.inv.naturality_assoc]
congr 2
simp only [← e'.functor.map_comp_assoc]
simp only [Functor.comp_map, Equivalence.fun_inv_map, comp_obj, id_obj, map_comp, assoc]
simp only [← e'.functor.map_comp_assoc]
simp only [Iso.inv_hom_id_app_assoc, Iso.inv_hom_id_app, comp_obj, comp_id,
Equivalence.functor_unit_comp, map_id, id_comp]
variable (hF)
/-- The isomorphism `eA.functor ≅ F ⋙ e'.inverse` deduced from the
unit isomorphism of `e'` and the isomorphism `hF : eA.functor ⋙ e'.functor ≅ F`. -/
@[simps!]
def υ : eA.functor ≅ F ⋙ e'.inverse :=
calc
eA.functor ≅ eA.functor ⋙ 𝟭 A' := (rightUnitor _).symm
_ ≅ eA.functor ⋙ e'.functor ⋙ e'.inverse := isoWhiskerLeft _ e'.unitIso
_ ≅ (eA.functor ⋙ e'.functor) ⋙ e'.inverse := (associator _ _ _).symm
_ ≅ F ⋙ e'.inverse := isoWhiskerRight hF _
variable (ε : eA.functor ≅ F ⋙ e'.inverse) (hG)
/-- The unit isomorphism of `equivalence`. -/
@[simps!]
def equivalenceUnitIso : 𝟭 A ≅ (F ⋙ eB.inverse) ⋙ G :=
calc
𝟭 A ≅ eA.functor ⋙ eA.inverse := eA.unitIso
_ ≅ (F ⋙ e'.inverse) ⋙ eA.inverse := isoWhiskerRight ε _
_ ≅ F ⋙ e'.inverse ⋙ eA.inverse := associator _ _ _
_ ≅ F ⋙ 𝟭 B' ⋙ e'.inverse ⋙ eA.inverse := isoWhiskerLeft _ (leftUnitor _).symm
_ ≅ F ⋙ (eB.inverse ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight eB.counitIso.symm _)
_ ≅ (F ⋙ eB.inverse ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse := (associator _ _ _).symm
_ ≅ ((F ⋙ eB.inverse) ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :=
isoWhiskerRight (associator _ _ _).symm _
_ ≅ (F ⋙ eB.inverse) ⋙ eB.functor ⋙ e'.inverse ⋙ eA.inverse := associator _ _ _
_ ≅ (F ⋙ eB.inverse) ⋙ (eB.functor ⋙ e'.inverse) ⋙ eA.inverse :=
isoWhiskerLeft _ (associator _ _ _).symm
_ ≅ (F ⋙ eB.inverse) ⋙ (G ⋙ eA.functor) ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight hG _)
_ ≅ ((F ⋙ eB.inverse) ⋙ G ⋙ eA.functor) ⋙ eA.inverse := (associator _ _ _).symm
_ ≅ (((F ⋙ eB.inverse) ⋙ G) ⋙ eA.functor) ⋙ eA.inverse :=
isoWhiskerRight (associator _ _ _).symm _
_ ≅ ((F ⋙ eB.inverse) ⋙ G) ⋙ eA.functor ⋙ eA.inverse := associator _ _ _
_ ≅ ((F ⋙ eB.inverse) ⋙ G) ⋙ 𝟭 A := isoWhiskerLeft _ eA.unitIso.symm
_ ≅ (F ⋙ eB.inverse) ⋙ G := rightUnitor _
variable {ε hF hG}
theorem equivalenceUnitIso_eq (hε : υ hF = ε) :
(equivalence hF hG).unitIso = equivalenceUnitIso hG ε := by
ext1; apply NatTrans.ext; ext X
dsimp [equivalence]
simp only [assoc, comp_id, equivalenceUnitIso_hom_app, equivalence₂_inverse, Functor.comp_obj,
id_comp, equivalence₂UnitIso_eq eB hF, equivalence₂UnitIso_hom_app,
← eA.inverse.map_comp_assoc, assoc, ← hε, υ_hom_app]
end Compatibility
end DoldKan
end AlgebraicTopology |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/FundamentalGroupoid/SimplyConnected.lean | import Mathlib.AlgebraicTopology.FundamentalGroupoid.InducedMaps
import Mathlib.Topology.Homotopy.Contractible
import Mathlib.CategoryTheory.PUnit
import Mathlib.AlgebraicTopology.FundamentalGroupoid.PUnit
/-!
# Simply connected spaces
This file defines simply connected spaces.
A topological space is simply connected if its fundamental groupoid is equivalent to `Unit`.
## Main theorems
- `simply_connected_iff_unique_homotopic` - A space is simply connected if and only if it is
nonempty and there is a unique path up to homotopy between any two points
- `SimplyConnectedSpace.ofContractible` - A contractible space is simply connected
-/
universe u
noncomputable section
open CategoryTheory
open ContinuousMap
open scoped ContinuousMap
/-- A simply connected space is one whose fundamental groupoid is equivalent to `Discrete Unit` -/
@[mk_iff simply_connected_def]
class SimplyConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where
equiv_unit : Nonempty (FundamentalGroupoid X ≌ Discrete Unit)
theorem simply_connected_iff_unique_homotopic (X : Type*) [TopologicalSpace X] :
SimplyConnectedSpace X ↔
Nonempty X ∧ ∀ x y : X, Nonempty (Unique (Path.Homotopic.Quotient x y)) := by
simp only [simply_connected_def, equiv_punit_iff_unique,
FundamentalGroupoid.nonempty_iff X, and_congr_right_iff, Nonempty.forall]
intros
exact ⟨fun h _ _ => h _ _, fun h _ _ => h _ _⟩
namespace SimplyConnectedSpace
variable {X : Type*} [TopologicalSpace X] [SimplyConnectedSpace X]
instance (x y : X) : Subsingleton (Path.Homotopic.Quotient x y) :=
@Unique.instSubsingleton _ (Nonempty.some (by
rw [simply_connected_iff_unique_homotopic] at *; tauto))
instance (priority := 100) : PathConnectedSpace X :=
let unique_homotopic := (simply_connected_iff_unique_homotopic X).mp inferInstance
{ nonempty := unique_homotopic.1
joined := fun x y => ⟨(unique_homotopic.2 x y).some.default.out⟩ }
/-- In a simply connected space, any two paths are homotopic -/
theorem paths_homotopic {x y : X} (p₁ p₂ : Path x y) : Path.Homotopic p₁ p₂ :=
Quotient.eq.mp (@Subsingleton.elim (Path.Homotopic.Quotient x y) _ _ _)
instance (priority := 100) ofContractible (Y : Type u) [TopologicalSpace Y] [ContractibleSpace Y] :
SimplyConnectedSpace Y where
equiv_unit :=
let H : TopCat.of Y ≃ₕ TopCat.of PUnit.{u+1} := (ContractibleSpace.hequiv Y PUnit.{u+1}).some
⟨(FundamentalGroupoidFunctor.equivOfHomotopyEquiv H).trans
FundamentalGroupoid.punitEquivDiscretePUnit⟩
end SimplyConnectedSpace
/-- A space is simply connected iff it is path connected, and there is at most one path
up to homotopy between any two points. -/
theorem simply_connected_iff_paths_homotopic {Y : Type*} [TopologicalSpace Y] :
SimplyConnectedSpace Y ↔
PathConnectedSpace Y ∧ ∀ x y : Y, Subsingleton (Path.Homotopic.Quotient x y) :=
⟨by intro; constructor <;> infer_instance, fun h => by
cases h; rw [simply_connected_iff_unique_homotopic]
exact ⟨inferInstance, fun x y => ⟨uniqueOfSubsingleton ⟦PathConnectedSpace.somePath x y⟧⟩⟩⟩
/-- Another version of `simply_connected_iff_paths_homotopic` -/
theorem simply_connected_iff_paths_homotopic' {Y : Type*} [TopologicalSpace Y] :
SimplyConnectedSpace Y ↔
PathConnectedSpace Y ∧ ∀ {x y : Y} (p₁ p₂ : Path x y), Path.Homotopic p₁ p₂ := by
convert simply_connected_iff_paths_homotopic (Y := Y)
simp [Path.Homotopic.Quotient, Setoid.eq_top_iff]; rfl |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/FundamentalGroupoid/PUnit.lean | import Mathlib.CategoryTheory.PUnit
import Mathlib.AlgebraicTopology.FundamentalGroupoid.Basic
/-!
# Fundamental groupoid of punit
The fundamental groupoid of punit is naturally isomorphic to `CategoryTheory.Discrete PUnit`
-/
noncomputable section
open CategoryTheory
universe u v
namespace Path
instance : Subsingleton (Path PUnit.unit PUnit.unit) :=
⟨fun x y => by ext⟩
end Path
namespace FundamentalGroupoid
instance {x y : FundamentalGroupoid PUnit} : Subsingleton (x ⟶ y) := by
convert_to Subsingleton (Path.Homotopic.Quotient PUnit.unit PUnit.unit)
apply Quotient.instSubsingletonQuotient
/-- Equivalence of groupoids between fundamental groupoid of punit and punit -/
@[simps]
def punitEquivDiscretePUnit : FundamentalGroupoid PUnit.{u + 1} ≌ Discrete PUnit.{v + 1} where
functor := Functor.star _
inverse := (CategoryTheory.Functor.const _).obj ⟨PUnit.unit⟩
unitIso := NatIso.ofComponents (fun _ => Iso.refl _)
counitIso := Iso.refl _
end FundamentalGroupoid |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/FundamentalGroupoid/Product.lean | import Mathlib.CategoryTheory.Groupoid
import Mathlib.AlgebraicTopology.FundamentalGroupoid.Basic
import Mathlib.Topology.Category.TopCat.Limits.Products
import Mathlib.Topology.Homotopy.Product
/-!
# Fundamental groupoid preserves products
In this file, we give the following definitions/theorems:
- `FundamentalGroupoidFunctor.piIso` An isomorphism between Π i, (π Xᵢ) and π (Πi, Xᵢ), whose
inverse is precisely the product of the maps π (Π i, Xᵢ) → π (Xᵢ), each induced by
the projection in `Top` Π i, Xᵢ → Xᵢ.
- `FundamentalGroupoidFunctor.prodIso` An isomorphism between πX × πY and π (X × Y), whose
inverse is precisely the product of the maps π (X × Y) → πX and π (X × Y) → Y, each induced by
the projections X × Y → X and X × Y → Y
- `FundamentalGroupoidFunctor.preservesProduct` A proof that the fundamental groupoid functor
preserves all products.
-/
noncomputable section
open scoped FundamentalGroupoid CategoryTheory
namespace FundamentalGroupoidFunctor
universe u
section Pi
variable {I : Type u} (X : I → TopCat.{u})
/-- The projection map Π i, X i → X i induces a map π(Π i, X i) ⟶ π(X i).
-/
def proj (i : I) : πₓ (TopCat.of (∀ i, X i)) ⥤ πₓ (X i) :=
πₘ (TopCat.ofHom ⟨_, continuous_apply i⟩)
/-- The projection map is precisely `Path.Homotopic.proj` interpreted as a functor -/
@[simp]
theorem proj_map (i : I) (x₀ x₁ : πₓ (TopCat.of (∀ i, X i))) (p : x₀ ⟶ x₁) :
(proj X i).map p = @Path.Homotopic.proj _ _ _ _ _ i p :=
rfl
/-- The map taking the pi product of a family of fundamental groupoids to the fundamental
groupoid of the pi product. This is actually an isomorphism (see `piIso`)
-/
@[simps]
def piToPiTop : (∀ i, πₓ (X i)) ⥤ πₓ (TopCat.of (∀ i, X i)) where
obj g := ⟨fun i => (g i).as⟩
map p := Path.Homotopic.pi p
map_id x := by
change (Path.Homotopic.pi fun i => ⟦_⟧) = _
simp only [Path.Homotopic.pi_lift]
rfl
map_comp f g := (Path.Homotopic.comp_pi_eq_pi_comp f g).symm
/-- Shows `piToPiTop` is an isomorphism, whose inverse is precisely the pi product
of the induced projections. This shows that `fundamentalGroupoidFunctor` preserves products.
-/
@[simps]
def piIso : CategoryTheory.Grpd.of (∀ i : I, πₓ (X i)) ≅ πₓ (TopCat.of (∀ i, X i)) where
hom := piToPiTop X
inv := CategoryTheory.Functor.pi' (proj X)
hom_inv_id := by
change piToPiTop X ⋙ CategoryTheory.Functor.pi' (proj X) = 𝟭 _
apply CategoryTheory.Functor.ext ?_ ?_
· intros; rfl
· intros; ext; simp
inv_hom_id := by
change CategoryTheory.Functor.pi' (proj X) ⋙ piToPiTop X = 𝟭 _
apply CategoryTheory.Functor.ext
· intro _ _ f
suffices Path.Homotopic.pi ((CategoryTheory.Functor.pi' (proj X)).map f) = f by simpa
change Path.Homotopic.pi (fun i => (CategoryTheory.Functor.pi' (proj X)).map f i) = _
simp
· intros; rfl
section Preserves
open CategoryTheory
/-- Equivalence between the categories of cones over the objects `π Xᵢ` written in two ways -/
def coneDiscreteComp :
Limits.Cone (Discrete.functor X ⋙ π) ≌ Limits.Cone (Discrete.functor fun i => πₓ (X i)) :=
Limits.Cones.postcomposeEquivalence (Discrete.compNatIsoDiscrete X π)
theorem coneDiscreteComp_obj_mapCone :
(coneDiscreteComp X).functor.obj (Functor.mapCone π (TopCat.piFan X)) =
Limits.Fan.mk (πₓ (TopCat.of (∀ i, X i))) (proj X) :=
rfl
/-- This is `piIso.inv` as a cone morphism (in fact, isomorphism) -/
def piTopToPiCone :
Limits.Fan.mk (πₓ (TopCat.of (∀ i, X i))) (proj X) ⟶ Grpd.piLimitFan fun i : I => πₓ (X i) where
hom := CategoryTheory.Functor.pi' (proj X)
instance : IsIso (piTopToPiCone X) :=
haveI : IsIso (piTopToPiCone X).hom := (inferInstance : IsIso (piIso X).inv)
Limits.Cones.cone_iso_of_hom_iso (piTopToPiCone X)
/-- The fundamental groupoid functor preserves products -/
lemma preservesProduct : Limits.PreservesLimit (Discrete.functor X) π := by
apply Limits.preservesLimit_of_preserves_limit_cone (TopCat.piFanIsLimit X)
apply (Limits.IsLimit.ofConeEquiv (coneDiscreteComp X)).toFun
simp only [coneDiscreteComp_obj_mapCone]
apply Limits.IsLimit.ofIsoLimit _ (asIso (piTopToPiCone X)).symm
exact Grpd.piLimitFanIsLimit _
end Preserves
end Pi
section Prod
variable (A B : TopCat.{u})
/-- The induced map of the left projection map X × Y → X -/
def projLeft : πₓ (TopCat.of (A × B)) ⥤ πₓ A :=
πₘ (TopCat.ofHom ⟨_, continuous_fst⟩)
/-- The induced map of the right projection map X × Y → Y -/
def projRight : πₓ (TopCat.of (A × B)) ⥤ πₓ B :=
πₘ (TopCat.ofHom ⟨_, continuous_snd⟩)
@[simp]
theorem projLeft_map (x₀ x₁ : πₓ (TopCat.of (A × B))) (p : x₀ ⟶ x₁) :
(projLeft A B).map p = Path.Homotopic.projLeft p :=
rfl
@[simp]
theorem projRight_map (x₀ x₁ : πₓ (TopCat.of (A × B))) (p : x₀ ⟶ x₁) :
(projRight A B).map p = Path.Homotopic.projRight p :=
rfl
/--
The map taking the product of two fundamental groupoids to the fundamental groupoid of the product
of the two topological spaces. This is in fact an isomorphism (see `prodIso`).
-/
@[simps obj]
def prodToProdTop : πₓ A × πₓ B ⥤ πₓ (TopCat.of (A × B)) where
obj g := ⟨g.fst.as, g.snd.as⟩
map {x y} p :=
match x, y, p with
| (_, _), (_, _), (p₀, p₁) => @Path.Homotopic.prod _ _ (_) (_) _ _ _ _ p₀ p₁
map_id := by
rintro ⟨x₀, x₁⟩
simp only
rfl
map_comp {x y z} f g :=
match x, y, z, f, g with
| (_, _), (_, _), (_, _), (f₀, f₁), (g₀, g₁) =>
(Path.Homotopic.comp_prod_eq_prod_comp f₀ f₁ g₀ g₁).symm
theorem prodToProdTop_map {x₀ x₁ : πₓ A} {y₀ y₁ : πₓ B} (p₀ : x₀ ⟶ x₁) (p₁ : y₀ ⟶ y₁) :
(prodToProdTop A B).map (X := (x₀, y₀)) (Y := (x₁, y₁)) (p₀, p₁) =
Path.Homotopic.prod p₀ p₁ :=
rfl
/-- Shows `prodToProdTop` is an isomorphism, whose inverse is precisely the product
of the induced left and right projections.
-/
@[simps]
def prodIso : CategoryTheory.Grpd.of (πₓ A × πₓ B) ≅ πₓ (TopCat.of (A × B)) where
hom := prodToProdTop A B
inv := (projLeft A B).prod' (projRight A B)
hom_inv_id := by
change prodToProdTop A B ⋙ (projLeft A B).prod' (projRight A B) = 𝟭 _
apply CategoryTheory.Functor.hext; · intros; ext <;> simp <;> rfl
rintro ⟨x₀, x₁⟩ ⟨y₀, y₁⟩ ⟨f₀, f₁⟩
have : Path.Homotopic.projLeft ((prodToProdTop A B).map (f₀, f₁)) = f₀ ∧
Path.Homotopic.projRight ((prodToProdTop A B).map (f₀, f₁)) = f₁ :=
And.intro (Path.Homotopic.projLeft_prod f₀ f₁) (Path.Homotopic.projRight_prod f₀ f₁)
simpa
inv_hom_id := by
change (projLeft A B).prod' (projRight A B) ⋙ prodToProdTop A B = 𝟭 _
apply CategoryTheory.Functor.hext
· intros; apply FundamentalGroupoid.ext; apply Prod.ext <;> simp <;> rfl
rintro ⟨x₀, x₁⟩ ⟨y₀, y₁⟩ f
simpa [-Path.Homotopic.prod_projLeft_projRight] using Path.Homotopic.prod_projLeft_projRight f
end Prod
end FundamentalGroupoidFunctor |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/FundamentalGroupoid/Basic.lean | import Mathlib.CategoryTheory.Category.Grpd
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Homotopy.Path
import Mathlib.Data.Set.Subsingleton
/-!
# Fundamental groupoid of a space
Given a topological space `X`, we can define the fundamental groupoid of `X` to be the category with
objects being points of `X`, and morphisms `x ⟶ y` being paths from `x` to `y`, quotiented by
homotopy equivalence. With this, the fundamental group of `X` based at `x` is just the automorphism
group of `x`.
-/
open CategoryTheory
variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]
variable {x₀ x₁ : X}
noncomputable section
open unitInterval
namespace Path
namespace Homotopy
section
/-- Auxiliary function for `reflTransSymm`. -/
def reflTransSymmAux (x : I × I) : ℝ :=
if (x.2 : ℝ) ≤ 1 / 2 then x.1 * 2 * x.2 else x.1 * (2 - 2 * x.2)
@[continuity, fun_prop]
theorem continuous_reflTransSymmAux : Continuous reflTransSymmAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_
iterate 4 fun_prop
intro x hx
norm_num [hx, mul_assoc]
theorem reflTransSymmAux_mem_I (x : I × I) : reflTransSymmAux x ∈ I := by
dsimp only [reflTransSymmAux]
split_ifs
· constructor
· apply mul_nonneg
· apply mul_nonneg
· unit_interval
· simp
· unit_interval
· rw [mul_assoc]
apply mul_le_one₀
· unit_interval
· apply mul_nonneg
· simp
· unit_interval
· linarith
· constructor
· apply mul_nonneg
· unit_interval
linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· apply mul_le_one₀
· unit_interval
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from the constant path based at `x₀` to
`p.trans p.symm`. -/
def reflTransSymm (p : Path x₀ x₁) : Homotopy (Path.refl x₀) (p.trans p.symm) where
toFun x := p ⟨reflTransSymmAux x, reflTransSymmAux_mem_I x⟩
continuous_toFun := by fun_prop
map_zero_left := by simp [reflTransSymmAux]
map_one_left x := by
simp only [reflTransSymmAux, Path.trans]
cases le_or_gt (x : ℝ) 2⁻¹ with
| inl hx => simp [hx, ← extend_extends]
| inr hx =>
have : p.extend (2 - 2 * ↑x) = p.extend (1 - (2 * ↑x - 1)) := by ring_nf
simpa [hx.not_ge, ← extend_extends]
prop' t := by norm_num [reflTransSymmAux]
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from the constant path based at `x₁` to
`p.symm.trans p`. -/
def reflSymmTrans (p : Path x₀ x₁) : Homotopy (Path.refl x₁) (p.symm.trans p) :=
(reflTransSymm p.symm).cast rfl <| congr_arg _ (Path.symm_symm _)
end
section TransRefl
/-- Auxiliary function for `trans_refl_reparam`. -/
def transReflReparamAux (t : I) : ℝ :=
if (t : ℝ) ≤ 1 / 2 then 2 * t else 1
@[continuity, fun_prop]
theorem continuous_transReflReparamAux : Continuous transReflReparamAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_ <;>
[fun_prop; fun_prop; fun_prop; fun_prop; skip]
intro x hx
simp [hx]
theorem transReflReparamAux_mem_I (t : I) : transReflReparamAux t ∈ I := by
unfold transReflReparamAux
split_ifs <;> constructor <;> linarith [unitInterval.le_one t, unitInterval.nonneg t]
theorem transReflReparamAux_zero : transReflReparamAux 0 = 0 := by
norm_num [transReflReparamAux]
theorem transReflReparamAux_one : transReflReparamAux 1 = 1 := by
norm_num [transReflReparamAux]
theorem trans_refl_reparam (p : Path x₀ x₁) :
p.trans (Path.refl x₁) =
p.reparam (fun t => ⟨transReflReparamAux t, transReflReparamAux_mem_I t⟩) (by fun_prop)
(Subtype.ext transReflReparamAux_zero) (Subtype.ext transReflReparamAux_one) := by
ext
unfold transReflReparamAux
simp only [Path.trans_apply, coe_reparam, Function.comp_apply, one_div, Path.refl_apply]
split_ifs
· rfl
· rfl
· simp
· simp
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from `p.trans (Path.refl x₁)` to `p`. -/
def transRefl (p : Path x₀ x₁) : Homotopy (p.trans (Path.refl x₁)) p :=
((Homotopy.reparam p (fun t => ⟨transReflReparamAux t, transReflReparamAux_mem_I t⟩)
(by fun_prop) (Subtype.ext transReflReparamAux_zero)
(Subtype.ext transReflReparamAux_one)).cast
rfl (trans_refl_reparam p).symm).symm
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from `(Path.refl x₀).trans p` to `p`. -/
def reflTrans (p : Path x₀ x₁) : Homotopy ((Path.refl x₀).trans p) p :=
(transRefl p.symm).symm₂.cast (by simp) (by simp)
end TransRefl
section Assoc
/-- Auxiliary function for `trans_assoc_reparam`. -/
def transAssocReparamAux (t : I) : ℝ :=
if (t : ℝ) ≤ 1 / 4 then 2 * t else if (t : ℝ) ≤ 1 / 2 then t + 1 / 4 else 1 / 2 * (t + 1)
@[continuity, fun_prop]
theorem continuous_transAssocReparamAux : Continuous transAssocReparamAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_)
(continuous_if_le ?_ ?_
(Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_).continuousOn
?_ <;>
[fun_prop; fun_prop; fun_prop; fun_prop; fun_prop; fun_prop; fun_prop; skip;
skip] <;>
· intro x hx
norm_num [hx]
theorem transAssocReparamAux_mem_I (t : I) : transAssocReparamAux t ∈ I := by
unfold transAssocReparamAux
split_ifs <;> constructor <;> linarith [unitInterval.le_one t, unitInterval.nonneg t]
theorem transAssocReparamAux_zero : transAssocReparamAux 0 = 0 := by
norm_num [transAssocReparamAux]
theorem transAssocReparamAux_one : transAssocReparamAux 1 = 1 := by
norm_num [transAssocReparamAux]
theorem trans_assoc_reparam {x₀ x₁ x₂ x₃ : X} (p : Path x₀ x₁) (q : Path x₁ x₂) (r : Path x₂ x₃) :
(p.trans q).trans r =
(p.trans (q.trans r)).reparam
(fun t => ⟨transAssocReparamAux t, transAssocReparamAux_mem_I t⟩) (by fun_prop)
(Subtype.ext transAssocReparamAux_zero) (Subtype.ext transAssocReparamAux_one) := by
ext x
simp only [transAssocReparamAux, Path.trans_apply, Function.comp_apply, mul_ite, Path.coe_reparam]
-- TODO: why does split_ifs not reduce the ifs??????
split_ifs with h₁ h₂ h₃ h₄ h₅
· rfl
iterate 6 exfalso; linarith
· have h : 2 * (2 * (x : ℝ)) - 1 = 2 * (2 * (↑x + 1 / 4) - 1) := by linarith
simp [h]
iterate 6 exfalso; linarith
· congr
ring
/-- For paths `p q r`, we have a homotopy from `(p.trans q).trans r` to `p.trans (q.trans r)`. -/
def transAssoc {x₀ x₁ x₂ x₃ : X} (p : Path x₀ x₁) (q : Path x₁ x₂) (r : Path x₂ x₃) :
Homotopy ((p.trans q).trans r) (p.trans (q.trans r)) :=
((Homotopy.reparam (p.trans (q.trans r))
(fun t => ⟨transAssocReparamAux t, transAssocReparamAux_mem_I t⟩) (by fun_prop)
(Subtype.ext transAssocReparamAux_zero) (Subtype.ext transAssocReparamAux_one)).cast
rfl (trans_assoc_reparam p q r).symm).symm
end Assoc
end Homotopy
end Path
/-- The fundamental groupoid of a space `X` is defined to be a wrapper around `X`, and we
subsequently put a `CategoryTheory.Groupoid` structure on it. -/
@[ext]
structure FundamentalGroupoid (X : Type*) where
/-- View a term of `FundamentalGroupoid X` as a term of `X`. -/
as : X
namespace FundamentalGroupoid
/-- The equivalence between `X` and the underlying type of its fundamental groupoid.
This is useful for transferring constructions (instances, etc.)
from `X` to `πₓ X`. -/
@[simps]
def equiv (X : Type*) : FundamentalGroupoid X ≃ X where
toFun x := x.as
invFun x := .mk x
@[simp]
lemma isEmpty_iff (X : Type*) :
IsEmpty (FundamentalGroupoid X) ↔ IsEmpty X :=
equiv _ |>.isEmpty_congr
instance (X : Type*) [IsEmpty X] :
IsEmpty (FundamentalGroupoid X) :=
equiv _ |>.isEmpty
@[simp]
lemma nonempty_iff (X : Type*) :
Nonempty (FundamentalGroupoid X) ↔ Nonempty X :=
equiv _ |>.nonempty_congr
instance (X : Type*) [Nonempty X] :
Nonempty (FundamentalGroupoid X) :=
equiv _ |>.nonempty
@[simp]
lemma subsingleton_iff (X : Type*) :
Subsingleton (FundamentalGroupoid X) ↔ Subsingleton X :=
equiv _ |>.subsingleton_congr
instance (X : Type*) [Subsingleton X] :
Subsingleton (FundamentalGroupoid X) :=
equiv _ |>.subsingleton
-- TODO: It seems that `Equiv.nontrivial_congr` doesn't exist.
-- Once it is added, please add the corresponding lemma and instance.
instance {X : Type*} [Inhabited X] : Inhabited (FundamentalGroupoid X) :=
⟨⟨default⟩⟩
instance : Groupoid (FundamentalGroupoid X) where
Hom x y := Path.Homotopic.Quotient x.as y.as
id x := ⟦Path.refl x.as⟧
comp := Path.Homotopic.Quotient.comp
id_comp := by rintro _ _ ⟨f⟩; exact Quotient.sound ⟨Path.Homotopy.reflTrans f⟩
comp_id := by rintro _ _ ⟨f⟩; exact Quotient.sound ⟨Path.Homotopy.transRefl f⟩
assoc := by rintro _ _ _ _ ⟨f⟩ ⟨g⟩ ⟨h⟩; exact Quotient.sound ⟨Path.Homotopy.transAssoc f g h⟩
inv := Quotient.lift (fun f ↦ ⟦f.symm⟧) (by rintro a b ⟨h⟩; exact Quotient.sound ⟨h.symm₂⟩)
inv_comp := by rintro _ _ ⟨f⟩; exact Quotient.sound ⟨(Path.Homotopy.reflSymmTrans f).symm⟩
comp_inv := by rintro _ _ ⟨f⟩; exact Quotient.sound ⟨(Path.Homotopy.reflTransSymm f).symm⟩
theorem comp_eq (x y z : FundamentalGroupoid X) (p : x ⟶ y) (q : y ⟶ z) : p ≫ q = p.comp q := rfl
theorem id_eq_path_refl (x : FundamentalGroupoid X) : 𝟙 x = ⟦Path.refl x.as⟧ := rfl
/-- The functor on fundamental groupoid induced by a continuous map. -/
@[simps] def map (f : C(X, Y)) : FundamentalGroupoid X ⥤ FundamentalGroupoid Y where
obj x := ⟨f x.as⟩
map p := p.mapFn f
map_id _ := rfl
map_comp := by rintro _ _ _ ⟨p⟩ ⟨q⟩; exact congr_arg Quotient.mk'' (p.map_trans q f.continuous)
/-- The functor sending a topological space `X` to its fundamental groupoid. -/
def fundamentalGroupoidFunctor : TopCat ⥤ Grpd where
obj X := { α := FundamentalGroupoid X }
map f := map f.hom
map_id X := by simp only [map]; congr; ext x y ⟨p⟩; rfl
map_comp f g := by simp only [map]; congr; ext x y ⟨p⟩; rfl
@[inherit_doc] scoped notation "π" => FundamentalGroupoid.fundamentalGroupoidFunctor
/-- The fundamental groupoid of a topological space. -/
scoped notation "πₓ" => FundamentalGroupoid.fundamentalGroupoidFunctor.obj
/-- The functor between fundamental groupoids induced by a continuous map. -/
scoped notation "πₘ" => FundamentalGroupoid.fundamentalGroupoidFunctor.map
theorem map_eq {X Y : TopCat} {x₀ x₁ : X} (f : C(X, Y)) (p : Path.Homotopic.Quotient x₀ x₁) :
(πₘ (TopCat.ofHom f)).map p = p.mapFn f := rfl
/-- Help the typechecker by converting a point in a groupoid back to a point in
the underlying topological space. -/
abbrev toTop {X : TopCat} (x : πₓ X) : X := x.as
/-- Help the typechecker by converting a point in a topological space to a
point in the fundamental groupoid of that space. -/
abbrev fromTop {X : TopCat} (x : X) : πₓ X := ⟨x⟩
/-- Help the typechecker by converting an arrow in the fundamental groupoid of
a topological space back to a path in that space (i.e., `Path.Homotopic.Quotient`). -/
abbrev toPath {X : TopCat} {x₀ x₁ : πₓ X} (p : x₀ ⟶ x₁) :
Path.Homotopic.Quotient x₀.as x₁.as :=
p
/-- Help the typechecker by converting a path in a topological space to an arrow in the
fundamental groupoid of that space. -/
abbrev fromPath {x₀ x₁ : X} (p : Path.Homotopic.Quotient x₀ x₁) :
FundamentalGroupoid.mk x₀ ⟶ FundamentalGroupoid.mk x₁ := p
lemma eqToHom_eq {x₀ x₁ : X} (h : x₀ = x₁) :
eqToHom (congr_arg mk h) = ⟦(Path.refl x₁).cast h rfl⟧ := by subst h; rfl
@[reassoc]
lemma conj_eqToHom {x y x' y' : X} {p : Path x y} (hx : x' = x) (hy : y' = y) :
eqToHom (congr_arg mk hx) ≫ ⟦p⟧ ≫ eqToHom (congr_arg mk hy.symm) = ⟦p.cast hx hy⟧ := by
subst hx hy; simp
end FundamentalGroupoid |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/FundamentalGroupoid/InducedMaps.lean | import Mathlib.Topology.Homotopy.Equiv
import Mathlib.CategoryTheory.Equivalence
import Mathlib.AlgebraicTopology.FundamentalGroupoid.Product
/-!
# Homotopic maps induce naturally isomorphic functors
## Main definitions
- `FundamentalGroupoidFunctor.homotopicMapsNatIso H` The natural isomorphism
between the induced functors `f : π(X) ⥤ π(Y)` and `g : π(X) ⥤ π(Y)`, given a homotopy
`H : f ∼ g`
- `FundamentalGroupoidFunctor.equivOfHomotopyEquiv hequiv` The equivalence of the categories
`π(X)` and `π(Y)` given a homotopy equivalence `hequiv : X ≃ₕ Y` between them.
## Implementation notes
- In order to be more universe polymorphic, we define `ContinuousMap.Homotopy.uliftMap`
which lifts a homotopy from `I × X → Y` to `(TopCat.of ((ULift I) × X)) → Y`. This is because
this construction uses `FundamentalGroupoidFunctor.prodToProdTop` to convert between
pairs of paths in I and X and the corresponding path after passing through a homotopy `H`.
But `FundamentalGroupoidFunctor.prodToProdTop` requires two spaces in the same universe.
-/
noncomputable section
universe u
open FundamentalGroupoid
open CategoryTheory
open FundamentalGroupoidFunctor
open scoped FundamentalGroupoid
open scoped unitInterval
namespace unitInterval
/-- The path 0 ⟶ 1 in `I` -/
def path01 : Path (0 : I) 1 where
toFun := id
source' := rfl
target' := rfl
/-- The path 0 ⟶ 1 in `ULift I` -/
def upath01 : Path (ULift.up 0 : ULift.{u} I) (ULift.up 1) where
toFun := ULift.up
source' := rfl
target' := rfl
/-- The homotopy path class of 0 → 1 in `ULift I` -/
def uhpath01 : @fromTop (TopCat.of <| ULift.{u} I) (ULift.up (0 : I)) ⟶ fromTop (ULift.up 1) :=
⟦upath01⟧
end unitInterval
namespace ContinuousMap.Homotopy
open unitInterval (uhpath01)
section Casts
/-- Abbreviation for `eqToHom` that accepts points in a topological space -/
abbrev hcast {X : TopCat} {x₀ x₁ : X} (hx : x₀ = x₁) : fromTop x₀ ⟶ fromTop x₁ :=
eqToHom <| FundamentalGroupoid.ext hx
@[simp]
theorem hcast_def {X : TopCat} {x₀ x₁ : X} (hx₀ : x₀ = x₁) :
hcast hx₀ = eqToHom (FundamentalGroupoid.ext hx₀) :=
rfl
variable {X₁ X₂ Y : TopCat.{u}} {f : C(X₁, Y)} {g : C(X₂, Y)} {x₀ x₁ : X₁} {x₂ x₃ : X₂}
{p : Path x₀ x₁} {q : Path x₂ x₃} (hfg : ∀ t, f (p t) = g (q t))
include hfg
/-- If `f(p(t) = g(q(t))` for two paths `p` and `q`, then the induced path homotopy classes
`f(p)` and `g(p)` are the same as well, despite having a priori different types -/
theorem heq_path_of_eq_image :
(πₘ (TopCat.ofHom f)).map ⟦p⟧ ≍ (πₘ (TopCat.ofHom g)).map ⟦q⟧ := by
simp only [map_eq, ← Path.Homotopic.map_lift]; apply Path.Homotopic.hpath_hext; exact hfg
private theorem start_path : f x₀ = g x₂ := by convert hfg 0 <;> simp only [Path.source]
private theorem end_path : f x₁ = g x₃ := by convert hfg 1 <;> simp only [Path.target]
theorem eq_path_of_eq_image :
(πₘ (TopCat.ofHom f)).map ⟦p⟧ =
hcast (start_path hfg) ≫ (πₘ (TopCat.ofHom g)).map ⟦q⟧ ≫ hcast (end_path hfg).symm := by
rw [conj_eqToHom_iff_heq
((πₘ (TopCat.ofHom f)).map ⟦p⟧) ((πₘ (TopCat.ofHom g)).map ⟦q⟧)
(FundamentalGroupoid.ext <| start_path hfg)
(FundamentalGroupoid.ext <| end_path hfg)]
exact heq_path_of_eq_image hfg
end Casts
-- We let `X` and `Y` be spaces, and `f` and `g` be homotopic maps between them
variable {X Y : TopCat.{u}} {f g : C(X, Y)} (H : ContinuousMap.Homotopy f g) {x₀ x₁ : X}
(p : fromTop x₀ ⟶ fromTop x₁)
/-!
These definitions set up the following diagram, for each path `p`:
f(p)
*--------*
| \ |
H₀ | \ d | H₁
| \ |
*--------*
g(p)
Here, `H₀ = H.evalAt x₀` is the path from `f(x₀)` to `g(x₀)`,
and similarly for `H₁`. Similarly, `f(p)` denotes the
path in Y that the induced map `f` takes `p`, and similarly for `g(p)`.
Finally, `d`, the diagonal path, is H(0 ⟶ 1, p), the result of the induced `H` on
`Path.Homotopic.prod (0 ⟶ 1) p`, where `(0 ⟶ 1)` denotes the path from `0` to `1` in `I`.
It is clear that the diagram commutes (`H₀ ≫ g(p) = d = f(p) ≫ H₁`), but unfortunately,
many of the paths do not have defeq starting/ending points, so we end up needing some casting.
-/
/-- Interpret a homotopy `H : C(I × X, Y)` as a map `C(ULift I × X, Y)` -/
def uliftMap : C(TopCat.of (ULift.{u} I × X), Y) :=
⟨fun x => H (x.1.down, x.2),
H.continuous.comp ((continuous_uliftDown.comp continuous_fst).prodMk continuous_snd)⟩
theorem ulift_apply (i : ULift.{u} I) (x : X) : H.uliftMap (i, x) = H (i.down, x) :=
rfl
/-- An abbreviation for `prodToProdTop`, with some types already in place to help the
typechecker. In particular, the first path should be on the ulifted unit interval. -/
abbrev prodToProdTopI {a₁ a₂ : TopCat.of (ULift I)} {b₁ b₂ : X} (p₁ : fromTop a₁ ⟶ fromTop a₂)
(p₂ : fromTop b₁ ⟶ fromTop b₂) :=
(prodToProdTop (TopCat.of <| ULift I) X).map (X := (⟨a₁⟩, ⟨b₁⟩)) (Y := (⟨a₂⟩, ⟨b₂⟩)) (p₁, p₂)
/-- The diagonal path `d` of a homotopy `H` on a path `p` -/
def diagonalPath : fromTop (H (0, x₀)) ⟶ fromTop (H (1, x₁)) :=
(πₘ (TopCat.ofHom H.uliftMap)).map (prodToProdTopI uhpath01 p)
/-- The diagonal path, but starting from `f x₀` and going to `g x₁` -/
def diagonalPath' : fromTop (f x₀) ⟶ fromTop (g x₁) :=
hcast (H.apply_zero x₀).symm ≫ H.diagonalPath p ≫ hcast (H.apply_one x₁)
/-- Proof that `f(p) = H(0 ⟶ 0, p)`, with the appropriate casts -/
theorem apply_zero_path : (πₘ (TopCat.ofHom f)).map p = hcast (H.apply_zero x₀).symm ≫
(πₘ (TopCat.ofHom H.uliftMap)).map
(prodToProdTopI (𝟙 (@fromTop (TopCat.of _) (ULift.up 0))) p) ≫
hcast (H.apply_zero x₁) :=
Quotient.inductionOn p fun p' => by
apply @eq_path_of_eq_image _ _ _ _ H.uliftMap _ _ _ _ _ ((Path.refl (ULift.up _)).prod p')
intros
rw [Path.prod_coe, ulift_apply H]
simp
/-- Proof that `g(p) = H(1 ⟶ 1, p)`, with the appropriate casts -/
theorem apply_one_path : (πₘ (TopCat.ofHom g)).map p = hcast (H.apply_one x₀).symm ≫
(πₘ (TopCat.ofHom H.uliftMap)).map
(prodToProdTopI (𝟙 (@fromTop (TopCat.of _) (ULift.up 1))) p) ≫
hcast (H.apply_one x₁) :=
Quotient.inductionOn p fun p' => by
apply @eq_path_of_eq_image _ _ _ _ H.uliftMap _ _ _ _ _ ((Path.refl (ULift.up _)).prod p')
intros
rw [Path.prod_coe, ulift_apply H]
simp
/-- Proof that `H.evalAt x = H(0 ⟶ 1, x ⟶ x)`, with the appropriate casts -/
theorem evalAt_eq (x : X) : ⟦H.evalAt x⟧ = hcast (H.apply_zero x).symm ≫
(πₘ (TopCat.ofHom H.uliftMap)).map (prodToProdTopI uhpath01 (𝟙 (fromTop x))) ≫
hcast (H.apply_one x).symm.symm := by
dsimp only [prodToProdTopI, uhpath01, hcast]
refine (@conj_eqToHom_iff_heq (πₓ Y) _ _ _ _ _ _ _ _
(FundamentalGroupoid.ext <| H.apply_one x).symm).mpr ?_
simp only [map_eq]
apply Path.Homotopic.hpath_hext; intro; rfl
-- Finally, we show `d = f(p) ≫ H₁ = H₀ ≫ g(p)`
theorem eq_diag_path : (πₘ (TopCat.ofHom f)).map p ≫ ⟦H.evalAt x₁⟧ = H.diagonalPath' p ∧
(⟦H.evalAt x₀⟧ ≫ (πₘ (TopCat.ofHom g)).map p :
fromTop (f x₀) ⟶ fromTop (g x₁)) = H.diagonalPath' p := by
rw [H.apply_zero_path, H.apply_one_path, H.evalAt_eq]
erw [H.evalAt_eq]
dsimp only [prodToProdTopI]
constructor
· slice_lhs 2 4 => rw [eqToHom_trans, eqToHom_refl] -- Porting note: this ↓ `simp` didn't do this
slice_lhs 2 4 => simp [← CategoryTheory.Functor.map_comp]
rfl
· slice_lhs 2 4 => rw [eqToHom_trans, eqToHom_refl] -- Porting note: this ↓ `simp` didn't do this
slice_lhs 2 4 => simp [← CategoryTheory.Functor.map_comp]
rfl
end ContinuousMap.Homotopy
namespace FundamentalGroupoidFunctor
open CategoryTheory
open scoped FundamentalGroupoid
variable {X Y : TopCat.{u}} {f g : C(X, Y)} (H : ContinuousMap.Homotopy f g)
/-- Given a homotopy H : f ∼ g, we have an associated natural isomorphism between the induced
functors `f` and `g` -/
-- Porting note: couldn't use category arrow `\hom` in statement, needed to expand
def homotopicMapsNatIso : @Quiver.Hom _ Functor.category.toQuiver
(πₘ (TopCat.ofHom f))
(πₘ (TopCat.ofHom g)) where
app x := ⟦H.evalAt x.as⟧
naturality x y p := by erw [(H.eq_diag_path p).1, (H.eq_diag_path p).2]
instance : IsIso (homotopicMapsNatIso H) := by apply NatIso.isIso_of_isIso_app
open scoped ContinuousMap
/-- Homotopy equivalent topological spaces have equivalent fundamental groupoids. -/
def equivOfHomotopyEquiv (hequiv : X ≃ₕ Y) : πₓ X ≌ πₓ Y := by
apply CategoryTheory.Equivalence.mk (πₘ (TopCat.ofHom hequiv.toFun) : πₓ X ⥤ πₓ Y)
(πₘ (TopCat.ofHom hequiv.invFun) : πₓ Y ⥤ πₓ X) <;>
simp only [← Grpd.id_eq_id]
· convert (asIso (homotopicMapsNatIso hequiv.left_inv.some)).symm
exacts [((π).map_id X).symm, ((π).map_comp _ _).symm]
· convert asIso (homotopicMapsNatIso hequiv.right_inv.some)
exacts [((π).map_comp _ _).symm, ((π).map_id Y).symm]
end FundamentalGroupoidFunctor |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/FundamentalGroupoid/FundamentalGroup.lean | import Mathlib.AlgebraicTopology.FundamentalGroupoid.Basic
import Mathlib.CategoryTheory.Conj
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Connected.PathConnected
import Mathlib.Topology.Homotopy.Path
/-!
# Fundamental group of a space
Given a topological space `X` and a basepoint `x`, the fundamental group is the automorphism group
of `x` i.e. the group with elements being loops based at `x` (quotiented by homotopy equivalence).
-/
variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]
variable {x₀ x₁ : X}
noncomputable section
open CategoryTheory
variable (X)
/-- The fundamental group is the automorphism group (vertex group) of the basepoint
in the fundamental groupoid. -/
def FundamentalGroup (x : X) :=
End (FundamentalGroupoid.mk x)
instance (x : X) : Group (FundamentalGroup X x) := inferInstanceAs (Group (End _))
instance (x : X) : Inhabited (FundamentalGroup X x) := inferInstanceAs (Inhabited (End _))
variable {X}
namespace FundamentalGroup
/-- Get an isomorphism between the fundamental groups at two points given a path -/
def fundamentalGroupMulEquivOfPath (p : Path x₀ x₁) :
FundamentalGroup X x₀ ≃* FundamentalGroup X x₁ :=
((Groupoid.isoEquivHom ..).symm ⟦p⟧).conj
variable (x₀ x₁)
/-- The fundamental group of a path connected space is independent of the choice of basepoint. -/
def fundamentalGroupMulEquivOfPathConnected [PathConnectedSpace X] :
FundamentalGroup X x₀ ≃* FundamentalGroup X x₁ :=
fundamentalGroupMulEquivOfPath (PathConnectedSpace.somePath x₀ x₁)
/-- An element of the fundamental group as an arrow in the fundamental groupoid. -/
abbrev toArrow {x : X} (p : FundamentalGroup X x) :
FundamentalGroupoid.mk x ⟶ FundamentalGroupoid.mk x :=
p
/-- An element of the fundamental group as a quotient of homotopic paths. -/
abbrev toPath {x : X} (p : FundamentalGroup X x) : Path.Homotopic.Quotient x x :=
toArrow p
/-- An element of the fundamental group, constructed from an arrow in the fundamental groupoid. -/
abbrev fromArrow {x : X}
(p : FundamentalGroupoid.mk x ⟶ FundamentalGroupoid.mk x) :
FundamentalGroup X x :=
p
/-- An element of the fundamental group, constructed from a quotient of homotopic paths. -/
abbrev fromPath {x : X} (p : Path.Homotopic.Quotient x x) : FundamentalGroup X x :=
fromArrow p
/-- The homomorphism between fundamental groups induced by a continuous map. -/
@[simps!] def map (f : C(X, Y)) (x : X) : FundamentalGroup X x →* FundamentalGroup Y (f x) :=
(FundamentalGroupoid.map f).mapEnd _
variable (f : C(X, Y)) {x : X} {y : Y} (h : f x = y)
/-- The homomorphism from π₁(X, x) to π₁(Y, y) induced by a continuous map `f` with `f x = y`. -/
def mapOfEq : FundamentalGroup X x →* FundamentalGroup Y y :=
(eqToIso <| congr_arg FundamentalGroupoid.mk h).conj.toMonoidHom.comp (map f x)
theorem mapOfEq_apply (p : Path x x) :
mapOfEq f h (fromPath ⟦p⟧) = fromPath ⟦(p.map f.continuous).cast h.symm h.symm⟧ :=
FundamentalGroupoid.conj_eqToHom ..
end FundamentalGroup |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialCategory/SimplicialObject.lean | import Mathlib.AlgebraicTopology.SimplicialCategory.Basic
import Mathlib.CategoryTheory.Functor.FunctorHom
/-!
# The category of simplicial objects is simplicial
In `CategoryTheory.Functor.FunctorHom`, it was shown that a category of functors
`C ⥤ D` is enriched over a suitable category `C ⥤ Type _` of functors to types.
In this file, we deduce that `SimplicialObject D` is enriched over `SSet.{v} D`
(when `D : Type u` and `[Category.{v} D]`) and that `SimplicialObject D`
is actually a simplicial category. In particular, the category of simplicial
sets is a simplicial category.
-/
universe v u
namespace CategoryTheory
variable {D : Type u} [Category.{v} D]
namespace SimplicialObject
noncomputable instance : EnrichedCategory SSet.{v} (SimplicialObject D) :=
inferInstanceAs (EnrichedCategory (_ ⥤ Type v) (_ ⥤ D))
noncomputable instance : SimplicialCategory (SimplicialObject D) where
homEquiv := Functor.natTransEquiv.symm
noncomputable instance : SimplicialCategory SSet.{v} :=
inferInstanceAs (SimplicialCategory (SimplicialObject (Type v)))
end SimplicialObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialCategory/Basic.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Monoidal
import Mathlib.CategoryTheory.Enriched.Ordinary.Basic
/-!
# Simplicial categories
A simplicial category is a category `C` that is enriched over the
category of simplicial sets in such a way that morphisms in
`C` identify to the `0`-simplices of the enriched hom.
## TODO
* construct a simplicial category structure on simplicial objects, so
that it applies in particular to simplicial sets
* obtain the adjunction property `(K ⊗ X ⟶ Y) ≃ (K ⟶ sHom X Y)` when `K`, `X`, and `Y`
are simplicial sets
* develop the notion of "simplicial tensor" `K ⊗ₛ X : C` with `K : SSet` and `X : C`
an object in a simplicial category `C`
* define the notion of path between `0`-simplices of simplicial sets
* deduce the notion of homotopy between morphisms in a simplicial category
* obtain that homotopies in simplicial categories can be interpreted as given
by morphisms `Δ[1] ⊗ X ⟶ Y`.
## References
* [Daniel G. Quillen, *Homotopical algebra*, II §1][quillen-1967]
-/
universe v u
open CategoryTheory Category Simplicial MonoidalCategory
namespace CategoryTheory
variable (C : Type u) [Category.{v} C]
/-- A simplicial category is a category `C` that is enriched over the
category of simplicial sets in such a way that morphisms in
`C` identify to the `0`-simplices of the enriched hom. -/
abbrev SimplicialCategory := EnrichedOrdinaryCategory SSet.{v} C
namespace SimplicialCategory
variable [SimplicialCategory C]
variable {C}
/-- Abbreviation for the enriched hom of a simplicial category. -/
abbrev sHom (K L : C) : SSet.{v} := K ⟶[SSet] L
/-- Abbreviation for the enriched composition in a simplicial category. -/
abbrev sHomComp (K L M : C) : sHom K L ⊗ sHom L M ⟶ sHom K M := eComp SSet K L M
/-- The bijection `(K ⟶ L) ≃ sHom K L _⦋0⦌` for all objects `K` and `L`
in a simplicial category. -/
def homEquiv' (K L : C) : (K ⟶ L) ≃ sHom K L _⦋0⦌ :=
(eHomEquiv SSet).trans (sHom K L).unitHomEquiv
variable (C) in
/-- The bifunctor `Cᵒᵖ ⥤ C ⥤ SSet.{v}` which sends `K : Cᵒᵖ` and `L : C` to `sHom K.unop L`. -/
noncomputable abbrev sHomFunctor : Cᵒᵖ ⥤ C ⥤ SSet.{v} := eHomFunctor _ _
end SimplicialCategory
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialObject/Split.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.CategoryTheory.Limits.Shapes.Products
import Mathlib.Data.Fintype.Sigma
/-!
# Split simplicial objects
In this file, we introduce the notion of split simplicial object.
If `C` is a category that has finite coproducts, a splitting
`s : Splitting X` of a simplicial object `X` in `C` consists
of the datum of a sequence of objects `s.N : ℕ → C` (which
we shall refer to as "nondegenerate simplices") and a
sequence of morphisms `s.ι n : s.N n → X _⦋n⦌` that have
the property that a certain canonical map identifies `X _⦋n⦌`
with the coproduct of objects `s.N i` indexed by all possible
epimorphisms `⦋n⦌ ⟶ ⦋i⦌` in `SimplexCategory`. (We do not
assume that the morphisms `s.ι n` are monomorphisms: in the
most common categories, this would be a consequence of the
axioms.)
Simplicial objects equipped with a splitting form a category
`SimplicialObject.Split C`.
## References
* [Stacks: Splitting simplicial objects] https://stacks.math.columbia.edu/tag/017O
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits Opposite SimplexCategory
open Simplicial
universe u
variable {C : Type*} [Category C]
namespace SimplicialObject
namespace Splitting
/-- The index set which appears in the definition of split simplicial objects. -/
def IndexSet (Δ : SimplexCategoryᵒᵖ) :=
Σ Δ' : SimplexCategoryᵒᵖ, { α : Δ.unop ⟶ Δ'.unop // Epi α }
namespace IndexSet
/-- The element in `Splitting.IndexSet Δ` attached to an epimorphism `f : Δ ⟶ Δ'`. -/
@[simps]
def mk {Δ Δ' : SimplexCategory} (f : Δ ⟶ Δ') [Epi f] : IndexSet (op Δ) :=
⟨op Δ', f, inferInstance⟩
variable {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ)
/-- The epimorphism in `SimplexCategory` associated to `A : Splitting.IndexSet Δ` -/
def e :=
A.2.1
instance : Epi A.e :=
A.2.2
theorem ext' : A = ⟨A.1, ⟨A.e, A.2.2⟩⟩ := rfl
theorem ext (A₁ A₂ : IndexSet Δ) (h₁ : A₁.1 = A₂.1) (h₂ : A₁.e ≫ eqToHom (by rw [h₁]) = A₂.e) :
A₁ = A₂ := by
rcases A₁ with ⟨Δ₁, ⟨α₁, hα₁⟩⟩
rcases A₂ with ⟨Δ₂, ⟨α₂, hα₂⟩⟩
simp only at h₁
subst h₁
simp only [eqToHom_refl, comp_id, IndexSet.e] at h₂
simp only [h₂]
instance : Fintype (IndexSet Δ) :=
Fintype.ofInjective
(fun A =>
⟨⟨A.1.unop.len, Nat.lt_succ_iff.mpr (len_le_of_epi A.e)⟩,
A.e.toOrderHom⟩ :
IndexSet Δ → Sigma fun k : Fin (Δ.unop.len + 1) => Fin (Δ.unop.len + 1) → Fin (k + 1))
(by
rintro ⟨⟨Δ₁⟩, α₁⟩ ⟨⟨Δ₂⟩, α₂⟩ h₁
simp only [unop_op, Sigma.mk.inj_iff, Fin.mk.injEq] at h₁
have h₂ : Δ₁ = Δ₂ := by
ext1
simpa only [Fin.mk_eq_mk] using h₁.1
subst h₂
refine ext _ _ rfl ?_
ext : 2
exact eq_of_heq h₁.2)
variable (Δ)
/-- The distinguished element in `Splitting.IndexSet Δ` which corresponds to the
identity of `Δ`. -/
@[simps]
def id : IndexSet Δ :=
⟨Δ, ⟨𝟙 _, by infer_instance⟩⟩
instance : Inhabited (IndexSet Δ) :=
⟨id Δ⟩
variable {Δ}
/-- The condition that an element `Splitting.IndexSet Δ` is the distinguished
element `Splitting.IndexSet.Id Δ`. -/
@[simp]
def EqId : Prop :=
A = id _
theorem eqId_iff_eq : A.EqId ↔ A.1 = Δ := by
constructor
· intro h
dsimp at h
rw [h]
rfl
· intro h
rcases A with ⟨_, ⟨f, hf⟩⟩
simp only at h
subst h
refine ext _ _ rfl ?_
simp only [eqToHom_refl, comp_id]
exact eq_id_of_epi f
theorem eqId_iff_len_eq : A.EqId ↔ A.1.unop.len = Δ.unop.len := by
rw [eqId_iff_eq]
constructor
· intro h
rw [h]
· intro h
rw [← unop_inj_iff]
ext
exact h
theorem eqId_iff_len_le : A.EqId ↔ Δ.unop.len ≤ A.1.unop.len := by
rw [eqId_iff_len_eq]
constructor
· intro h
rw [h]
· exact le_antisymm (len_le_of_epi A.e)
theorem eqId_iff_mono : A.EqId ↔ Mono A.e := by
constructor
· intro h
dsimp at h
subst h
dsimp only [id, e]
infer_instance
· intro
rw [eqId_iff_len_le]
exact len_le_of_mono A.e
/-- Given `A : IndexSet Δ₁`, if `p.unop : unop Δ₂ ⟶ unop Δ₁` is an epi, this
is the obvious element in `A : IndexSet Δ₂` associated to the composition
of epimorphisms `p.unop ≫ A.e`. -/
@[simps]
def epiComp {Δ₁ Δ₂ : SimplexCategoryᵒᵖ} (A : IndexSet Δ₁) (p : Δ₁ ⟶ Δ₂) [Epi p.unop] :
IndexSet Δ₂ :=
⟨A.1, ⟨p.unop ≫ A.e, epi_comp _ _⟩⟩
variable {Δ' : SimplexCategoryᵒᵖ} (θ : Δ ⟶ Δ')
/-- When `A : IndexSet Δ` and `θ : Δ → Δ'` is a morphism in `SimplexCategoryᵒᵖ`,
an element in `IndexSet Δ'` can be defined by using the epi-mono factorisation
of `θ.unop ≫ A.e`. -/
def pull : IndexSet Δ' :=
mk (factorThruImage (θ.unop ≫ A.e))
@[reassoc]
theorem fac_pull : (A.pull θ).e ≫ image.ι (θ.unop ≫ A.e) = θ.unop ≫ A.e :=
image.fac _
end IndexSet
variable (N : ℕ → C) (Δ : SimplexCategoryᵒᵖ) (X : SimplicialObject C) (φ : ∀ n, N n ⟶ X _⦋n⦌)
/-- Given a sequences of objects `N : ℕ → C` in a category `C`, this is
a family of objects indexed by the elements `A : Splitting.IndexSet Δ`.
The `Δ`-simplices of a split simplicial objects shall identify to the
coproduct of objects in such a family. -/
@[simp, nolint unusedArguments]
def summand (A : IndexSet Δ) : C :=
N A.1.unop.len
/-- The cofan for `summand N Δ` induced by morphisms `N n ⟶ X _⦋n⦌` for all `n : ℕ`. -/
def cofan' (Δ : SimplexCategoryᵒᵖ) : Cofan (summand N Δ) :=
Cofan.mk (X.obj Δ) (fun A => φ A.1.unop.len ≫ X.map A.e.op)
end Splitting
/-- A splitting of a simplicial object `X` consists of the datum of a sequence
of objects `N`, a sequence of morphisms `ι : N n ⟶ X _⦋n⦌` such that
for all `Δ : SimplexCategoryᵒᵖ`, the canonical map `Splitting.map X ι Δ`
is an isomorphism. -/
structure Splitting (X : SimplicialObject C) where
/-- The "nondegenerate simplices" `N n` for all `n : ℕ`. -/
N : ℕ → C
/-- The "inclusion" `N n ⟶ X _⦋n⦌` for all `n : ℕ`. -/
ι : ∀ n, N n ⟶ X _⦋n⦌
/-- For each `Δ`, `X.obj Δ` identifies to the coproduct of the objects `N A.1.unop.len`
for all `A : IndexSet Δ`. -/
isColimit' : ∀ Δ : SimplexCategoryᵒᵖ, IsColimit (Splitting.cofan' N X ι Δ)
namespace Splitting
variable {X Y : SimplicialObject C} (s : Splitting X)
/-- The cofan for `summand s.N Δ` induced by a splitting of a simplicial object. -/
def cofan (Δ : SimplexCategoryᵒᵖ) : Cofan (summand s.N Δ) :=
Cofan.mk (X.obj Δ) (fun A => s.ι A.1.unop.len ≫ X.map A.e.op)
/-- The cofan `s.cofan Δ` is colimit. -/
def isColimit (Δ : SimplexCategoryᵒᵖ) : IsColimit (s.cofan Δ) := s.isColimit' Δ
@[reassoc]
theorem cofan_inj_eq {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
(s.cofan Δ).inj A = s.ι A.1.unop.len ≫ X.map A.e.op := rfl
theorem cofan_inj_id (n : ℕ) : (s.cofan _).inj (IndexSet.id (op ⦋n⦌)) = s.ι n := by
simp [IndexSet.id, IndexSet.e, cofan_inj_eq]
/-- As it is stated in `Splitting.hom_ext`, a morphism `f : X ⟶ Y` from a split
simplicial object to any simplicial object is determined by its restrictions
`s.φ f n : s.N n ⟶ Y _⦋n⦌` to the distinguished summands in each degree `n`. -/
@[simp]
def φ (f : X ⟶ Y) (n : ℕ) : s.N n ⟶ Y _⦋n⦌ :=
s.ι n ≫ f.app (op ⦋n⦌)
@[reassoc (attr := simp)]
theorem cofan_inj_comp_app (f : X ⟶ Y) {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
(s.cofan Δ).inj A ≫ f.app Δ = s.φ f A.1.unop.len ≫ Y.map A.e.op := by
simp only [cofan_inj_eq_assoc, φ, assoc]
rw [NatTrans.naturality]
theorem hom_ext' {Z : C} {Δ : SimplexCategoryᵒᵖ} (f g : X.obj Δ ⟶ Z)
(h : ∀ A : IndexSet Δ, (s.cofan Δ).inj A ≫ f = (s.cofan Δ).inj A ≫ g) : f = g :=
Cofan.IsColimit.hom_ext (s.isColimit Δ) _ _ h
theorem hom_ext (f g : X ⟶ Y) (h : ∀ n : ℕ, s.φ f n = s.φ g n) : f = g := by
ext ⟨Δ⟩
apply s.hom_ext'
intro A
induction Δ using SimplexCategory.rec with | _ n
dsimp
simp only [s.cofan_inj_comp_app, h]
/-- The map `X.obj Δ ⟶ Z` obtained by providing a family of morphisms on all the
terms of decomposition given by a splitting `s : Splitting X` -/
def desc {Z : C} (Δ : SimplexCategoryᵒᵖ) (F : ∀ A : IndexSet Δ, s.N A.1.unop.len ⟶ Z) :
X.obj Δ ⟶ Z :=
Cofan.IsColimit.desc (s.isColimit Δ) F
@[reassoc (attr := simp)]
theorem ι_desc {Z : C} (Δ : SimplexCategoryᵒᵖ) (F : ∀ A : IndexSet Δ, s.N A.1.unop.len ⟶ Z)
(A : IndexSet Δ) : (s.cofan Δ).inj A ≫ s.desc Δ F = F A := by
apply Cofan.IsColimit.fac
/-- A simplicial object that is isomorphic to a split simplicial object is split. -/
@[simps]
def ofIso (e : X ≅ Y) : Splitting Y where
N := s.N
ι n := s.ι n ≫ e.hom.app (op ⦋n⦌)
isColimit' Δ := IsColimit.ofIsoColimit (s.isColimit Δ ) (Cofan.ext (e.app Δ)
(fun A => by simp [cofan, cofan']))
@[reassoc]
theorem cofan_inj_epi_naturality {Δ₁ Δ₂ : SimplexCategoryᵒᵖ} (A : IndexSet Δ₁) (p : Δ₁ ⟶ Δ₂)
[Epi p.unop] : (s.cofan Δ₁).inj A ≫ X.map p = (s.cofan Δ₂).inj (A.epiComp p) := by
dsimp [cofan]
rw [assoc, ← X.map_comp]
rfl
end Splitting
variable (C)
/-- The category `SimplicialObject.Split C` is the category of simplicial objects
in `C` equipped with a splitting, and morphisms are morphisms of simplicial objects
which are compatible with the splittings. -/
@[ext]
structure Split where
/-- the underlying simplicial object -/
X : SimplicialObject C
/-- a splitting of the simplicial object -/
s : Splitting X
namespace Split
variable {C}
/-- The object in `SimplicialObject.Split C` attached to a splitting `s : Splitting X`
of a simplicial object `X`. -/
@[simps]
def mk' {X : SimplicialObject C} (s : Splitting X) : Split C :=
⟨X, s⟩
/-- Morphisms in `SimplicialObject.Split C` are morphisms of simplicial objects that
are compatible with the splittings. -/
structure Hom (S₁ S₂ : Split C) where
/-- the morphism between the underlying simplicial objects -/
F : S₁.X ⟶ S₂.X
/-- the morphism between the "nondegenerate" `n`-simplices for all `n : ℕ` -/
f : ∀ n : ℕ, S₁.s.N n ⟶ S₂.s.N n
comm : ∀ n : ℕ, S₁.s.ι n ≫ F.app (op ⦋n⦌) = f n ≫ S₂.s.ι n := by cat_disch
@[ext]
theorem Hom.ext {S₁ S₂ : Split C} (Φ₁ Φ₂ : Hom S₁ S₂) (h : ∀ n : ℕ, Φ₁.f n = Φ₂.f n) : Φ₁ = Φ₂ := by
rcases Φ₁ with ⟨F₁, f₁, c₁⟩
rcases Φ₂ with ⟨F₂, f₂, c₂⟩
have h' : f₁ = f₂ := by
ext
apply h
subst h'
simp only [mk.injEq, and_true]
apply S₁.s.hom_ext
intro n
dsimp
rw [c₁, c₂]
attribute [simp, reassoc] Hom.comm
end Split
instance : Category (Split C) where
Hom := Split.Hom
id S :=
{ F := 𝟙 _
f := fun _ => 𝟙 _ }
comp Φ₁₂ Φ₂₃ :=
{ F := Φ₁₂.F ≫ Φ₂₃.F
f := fun n => Φ₁₂.f n ≫ Φ₂₃.f n
comm := fun n => by
dsimp
simp only [assoc, Split.Hom.comm_assoc, Split.Hom.comm] }
variable {C}
namespace Split
@[ext]
theorem hom_ext {S₁ S₂ : Split C} (Φ₁ Φ₂ : S₁ ⟶ S₂) (h : ∀ n : ℕ, Φ₁.f n = Φ₂.f n) : Φ₁ = Φ₂ :=
Hom.ext _ _ h
theorem congr_F {S₁ S₂ : Split C} {Φ₁ Φ₂ : S₁ ⟶ S₂} (h : Φ₁ = Φ₂) : Φ₁.f = Φ₂.f := by rw [h]
theorem congr_f {S₁ S₂ : Split C} {Φ₁ Φ₂ : S₁ ⟶ S₂} (h : Φ₁ = Φ₂) (n : ℕ) : Φ₁.f n = Φ₂.f n := by
rw [h]
@[simp]
theorem id_F (S : Split C) : (𝟙 S : S ⟶ S).F = 𝟙 S.X :=
rfl
@[simp]
theorem id_f (S : Split C) (n : ℕ) : (𝟙 S : S ⟶ S).f n = 𝟙 (S.s.N n) :=
rfl
@[simp]
theorem comp_F {S₁ S₂ S₃ : Split C} (Φ₁₂ : S₁ ⟶ S₂) (Φ₂₃ : S₂ ⟶ S₃) :
(Φ₁₂ ≫ Φ₂₃).F = Φ₁₂.F ≫ Φ₂₃.F :=
rfl
@[simp]
theorem comp_f {S₁ S₂ S₃ : Split C} (Φ₁₂ : S₁ ⟶ S₂) (Φ₂₃ : S₂ ⟶ S₃) (n : ℕ) :
(Φ₁₂ ≫ Φ₂₃).f n = Φ₁₂.f n ≫ Φ₂₃.f n :=
rfl
-- This is not a `@[simp]` lemma as it can later be proved by `simp`.
@[reassoc]
theorem cofan_inj_naturality_symm {S₁ S₂ : Split C} (Φ : S₁ ⟶ S₂) {Δ : SimplexCategoryᵒᵖ}
(A : Splitting.IndexSet Δ) :
(S₁.s.cofan Δ).inj A ≫ Φ.F.app Δ = Φ.f A.1.unop.len ≫ (S₂.s.cofan Δ).inj A := by
rw [S₁.s.cofan_inj_eq, S₂.s.cofan_inj_eq, assoc, Φ.F.naturality, ← Φ.comm_assoc]
variable (C)
/-- The functor `SimplicialObject.Split C ⥤ SimplicialObject C` which forgets
the splitting. -/
@[simps]
def forget : Split C ⥤ SimplicialObject C where
obj S := S.X
map Φ := Φ.F
/-- The functor `SimplicialObject.Split C ⥤ C` which sends a simplicial object equipped
with a splitting to its nondegenerate `n`-simplices. -/
@[simps]
def evalN (n : ℕ) : Split C ⥤ C where
obj S := S.s.N n
map Φ := Φ.f n
/-- The inclusion of each summand in the coproduct decomposition of simplices
in split simplicial objects is a natural transformation of functors
`SimplicialObject.Split C ⥤ C` -/
@[simps]
def natTransCofanInj {Δ : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) :
evalN C A.1.unop.len ⟶ forget C ⋙ (evaluation SimplexCategoryᵒᵖ C).obj Δ where
app S := (S.s.cofan Δ).inj A
naturality _ _ Φ := (cofan_inj_naturality_symm Φ A).symm
end Split
end SimplicialObject |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialObject/Op.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Rev
import Mathlib.AlgebraicTopology.SimplicialObject.Basic
/-!
# The covariant involution of the category of simplicial objects
In this file, we define the covariant involution `SimplicialObject.opFunctor`
of the category of simplicial objects that is induced by the
covariant involution `SimplexCategory.rev : SimplexCategory ⥤ SimplexCategory`.
-/
universe v
open CategoryTheory
namespace SimplicialObject
variable {C : Type*} [Category.{v} C]
/-- The covariant involution of the category of simplicial objects
that is induced by the involution
`SimplexCategory.rev : SimplexCategory ⥤ SimplexCategory`. -/
def opFunctor : SimplicialObject C ⥤ SimplicialObject C :=
(Functor.whiskeringLeft _ _ _).obj SimplexCategory.rev.op
/-- The isomorphism `(opFunctor.obj X).obj n ≅ X.obj n` when `X` is a simplicial object. -/
def opObjIso {X : SimplicialObject C} {n : SimplexCategoryᵒᵖ} :
(opFunctor.obj X).obj n ≅ X.obj n := Iso.refl _
@[simp]
lemma opFunctor_map_app {X Y : SimplicialObject C} (f : X ⟶ Y) (n : SimplexCategoryᵒᵖ) :
(opFunctor.map f).app n = opObjIso.hom ≫ f.app n ≫ opObjIso.inv := by
simp [opFunctor, opObjIso]
@[simp]
lemma opFunctor_obj_map (X : SimplicialObject C) {n m : SimplexCategoryᵒᵖ} (f : n ⟶ m) :
(opFunctor.obj X).map f =
opObjIso.hom ≫ X.map (SimplexCategory.rev.map f.unop).op ≫ opObjIso.inv := by
simp [opFunctor, opObjIso]
@[simp]
lemma opFunctor_obj_δ (X : SimplicialObject C) {n : ℕ} (i : Fin (n + 2)) :
(opFunctor.obj X).δ i = opObjIso.hom ≫ X.δ i.rev ≫ opObjIso.inv := by
simp [SimplicialObject.δ]
@[simp]
lemma opFunctor_obj_σ (X : SimplicialObject C) {n : ℕ} (i : Fin (n + 1)) :
(opFunctor.obj X).σ i = opObjIso.hom ≫ X.σ i.rev ≫ opObjIso.inv := by
simp [SimplicialObject.σ]
/-- The functor `opFunctor : SimplicialObject C ⥤ SimplicialObject C`
is a covariant involution. -/
def opFunctorCompOpFunctorIso : opFunctor (C := C) ⋙ opFunctor ≅ 𝟭 _ :=
(Functor.whiskeringLeftObjCompIso _ _).symm ≪≫
(Functor.whiskeringLeft _ _ _).mapIso
((Functor.opHom _ _).mapIso (SimplexCategory.revCompRevIso).symm.op) ≪≫
Functor.whiskeringLeftObjIdIso
@[simp]
lemma opFunctorCompOpFunctorIso_hom_app_app (X : SimplicialObject C) (n : SimplexCategoryᵒᵖ) :
(opFunctorCompOpFunctorIso.hom.app X).app n = opObjIso.hom ≫ opObjIso.hom := by
simp [opFunctorCompOpFunctorIso, opObjIso, opFunctor]
@[simp]
lemma opFunctorCompOpFunctorIso_inv_app_app (X : SimplicialObject C) (n : SimplexCategoryᵒᵖ) :
(opFunctorCompOpFunctorIso.inv.app X).app n = opObjIso.inv ≫ opObjIso.inv := by
simp [opFunctorCompOpFunctorIso, opObjIso, opFunctor]
/-- The functor `opFunctor : SimplicialObject C ⥤ SimplicialObject C`
as an equivalence of categories. -/
@[simps]
def opEquivalence : SimplicialObject C ≌ SimplicialObject C where
functor := opFunctor
inverse := opFunctor
unitIso := opFunctorCompOpFunctorIso.symm
counitIso := opFunctorCompOpFunctorIso
end SimplicialObject |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialObject/Basic.lean | import Mathlib.AlgebraicTopology.SimplexCategory.Basic
import Mathlib.CategoryTheory.Adjunction.Reflective
import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction
import Mathlib.CategoryTheory.Limits.FunctorCategory.Basic
import Mathlib.CategoryTheory.Opposites
import Mathlib.Util.Superscript
/-!
# Simplicial objects in a category.
A simplicial object in a category `C` is a `C`-valued presheaf on `SimplexCategory`.
(Similarly, a cosimplicial object is a functor `SimplexCategory ⥤ C`.)
## Notation
The following notations can be enabled via `open Simplicial`.
- `X _⦋n⦌` denotes the `n`-th term of a simplicial object `X`, where `n : ℕ`.
- `X ^⦋n⦌` denotes the `n`-th term of a cosimplicial object `X`, where `n : ℕ`.
The following notations can be enabled via
`open CategoryTheory.SimplicialObject.Truncated`.
- `X _⦋m⦌ₙ` denotes the `m`-th term of an `n`-truncated simplicial object `X`.
- `X ^⦋m⦌ₙ` denotes the `m`-th term of an `n`-truncated cosimplicial object `X`.
-/
open Opposite
open CategoryTheory
open CategoryTheory.Limits CategoryTheory.Functor
universe v u v' u'
namespace CategoryTheory
variable (C : Type u) [Category.{v} C]
/-- The category of simplicial objects valued in a category `C`.
This is the category of contravariant functors from `SimplexCategory` to `C`. -/
def SimplicialObject :=
SimplexCategoryᵒᵖ ⥤ C
@[simps!]
instance : Category (SimplicialObject C) := by
dsimp only [SimplicialObject]
infer_instance
namespace SimplicialObject
set_option quotPrecheck false in
/-- `X _⦋n⦌` denotes the `n`th-term of the simplicial object X -/
scoped[Simplicial]
notation3:1000 X " _⦋" n "⦌" =>
(X : CategoryTheory.SimplicialObject _).obj (Opposite.op (SimplexCategory.mk n))
open Simplicial
instance {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (SimplicialObject C) := by
dsimp [SimplicialObject]
infer_instance
instance [HasLimits C] : HasLimits (SimplicialObject C) :=
⟨inferInstance⟩
instance {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (SimplicialObject C) := by
dsimp [SimplicialObject]
infer_instance
instance [HasColimits C] : HasColimits (SimplicialObject C) :=
⟨inferInstance⟩
variable {C}
@[ext]
lemma hom_ext {X Y : SimplicialObject C} (f g : X ⟶ Y)
(h : ∀ (n : SimplexCategoryᵒᵖ), f.app n = g.app n) : f = g :=
NatTrans.ext (by ext; apply h)
variable (X : SimplicialObject C)
/-- Face maps for a simplicial object. -/
def δ {n} (i : Fin (n + 2)) : X _⦋n + 1⦌ ⟶ X _⦋n⦌ :=
X.map (SimplexCategory.δ i).op
lemma δ_def {n} (i : Fin (n + 2)) : X.δ i = X.map (SimplexCategory.δ i).op := rfl
/-- Degeneracy maps for a simplicial object. -/
def σ {n} (i : Fin (n + 1)) : X _⦋n⦌ ⟶ X _⦋n + 1⦌ :=
X.map (SimplexCategory.σ i).op
lemma σ_def {n} (i : Fin (n + 1)) : X.σ i = X.map (SimplexCategory.σ i).op := rfl
/-- The diagonal of a simplex is the long edge of the simplex. -/
def diagonal {n : ℕ} : X _⦋n⦌ ⟶ X _⦋1⦌ := X.map ((SimplexCategory.diag n).op)
/-- Isomorphisms from identities in ℕ. -/
def eqToIso {n m : ℕ} (h : n = m) : X _⦋n⦌ ≅ X _⦋m⦌ :=
X.mapIso (CategoryTheory.eqToIso (by congr))
@[simp]
theorem eqToIso_refl {n : ℕ} (h : n = n) : X.eqToIso h = Iso.refl _ := by
simp [eqToIso]
/-- The generic case of the first simplicial identity -/
@[reassoc]
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) :
X.δ j.succ ≫ X.δ i = X.δ (Fin.castSucc i) ≫ X.δ j := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ H]
@[reassoc]
theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) :
X.δ j ≫ X.δ i =
X.δ (Fin.castSucc i) ≫
X.δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ' H]
@[reassoc]
theorem δ_comp_δ'' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) :
X.δ j.succ ≫ X.δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) =
X.δ i ≫ X.δ j := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ'' H]
/-- The special case of the first simplicial identity -/
@[reassoc]
theorem δ_comp_δ_self {n} {i : Fin (n + 2)} :
X.δ (Fin.castSucc i) ≫ X.δ i = X.δ i.succ ≫ X.δ i := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ_self]
@[reassoc]
theorem δ_comp_δ_self' {n} {j : Fin (n + 3)} {i : Fin (n + 2)} (H : j = Fin.castSucc i) :
X.δ j ≫ X.δ i = X.δ i.succ ≫ X.δ i := by
subst H
rw [δ_comp_δ_self]
/-- The second simplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_le {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ Fin.castSucc j) :
X.σ j.succ ≫ X.δ (Fin.castSucc i) = X.δ i ≫ X.σ j := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_le H]
/-- The first part of the third simplicial identity -/
@[reassoc]
theorem δ_comp_σ_self {n} {i : Fin (n + 1)} : X.σ i ≫ X.δ (Fin.castSucc i) = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_self, op_id, X.map_id]
@[reassoc]
theorem δ_comp_σ_self' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = Fin.castSucc i) :
X.σ i ≫ X.δ j = 𝟙 _ := by
subst H
rw [δ_comp_σ_self]
/-- The second part of the third simplicial identity -/
@[reassoc]
theorem δ_comp_σ_succ {n} {i : Fin (n + 1)} : X.σ i ≫ X.δ i.succ = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_succ, op_id, X.map_id]
@[reassoc]
theorem δ_comp_σ_succ' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = i.succ) :
X.σ i ≫ X.δ j = 𝟙 _ := by
subst H
rw [δ_comp_σ_succ]
/-- The fourth simplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSucc j < i) :
X.σ (Fin.castSucc j) ≫ X.δ i.succ = X.δ i ≫ X.σ j := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt H]
@[reassoc]
theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) :
X.σ j ≫ X.δ i =
X.δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) ≫
X.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt' H]
/-- The fifth simplicial identity -/
@[reassoc]
theorem σ_comp_σ {n} {i j : Fin (n + 1)} (H : i ≤ j) :
X.σ j ≫ X.σ (Fin.castSucc i) = X.σ i ≫ X.σ j.succ := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.σ_comp_σ H]
open Simplicial
@[reassoc (attr := simp)]
theorem δ_naturality {X' X : SimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 2)) :
X.δ i ≫ f.app (op ⦋n⦌) = f.app (op ⦋n + 1⦌) ≫ X'.δ i :=
f.naturality _
@[reassoc (attr := simp)]
theorem σ_naturality {X' X : SimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ f.app (op ⦋n + 1⦌) = f.app (op ⦋n⦌) ≫ X'.σ i :=
f.naturality _
variable (C)
/-- Functor composition induces a functor on simplicial objects. -/
@[simps!]
def whiskering (D : Type*) [Category D] : (C ⥤ D) ⥤ SimplicialObject C ⥤ SimplicialObject D :=
whiskeringRight _ _ _
/-- Truncated simplicial objects. -/
def Truncated (n : ℕ) :=
(SimplexCategory.Truncated n)ᵒᵖ ⥤ C
instance {n : ℕ} : Category (Truncated C n) := by
dsimp [Truncated]
infer_instance
variable {C}
namespace Truncated
instance {n} {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (SimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasLimits C] : HasLimits (SimplicialObject.Truncated C n) :=
⟨inferInstance⟩
instance {n} {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (SimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasColimits C] : HasColimits (SimplicialObject.Truncated C n) :=
⟨inferInstance⟩
variable (C) in
/-- Functor composition induces a functor on truncated simplicial objects. -/
@[simps!]
def whiskering {n} (D : Type*) [Category D] : (C ⥤ D) ⥤ Truncated C n ⥤ Truncated D n :=
whiskeringRight _ _ _
open Mathlib.Tactic (subscriptTerm) in
/-- For `X : Truncated C n` and `m ≤ n`, `X _⦋m⦌ₙ` is the `m`-th term of X. The
proof `p : m ≤ n` can also be provided using the syntax `X _⦋m, p⦌ₙ`. -/
scoped syntax:max (name := mkNotation)
term " _⦋" term ("," term)? "⦌" noWs subscriptTerm : term
open scoped SimplexCategory.Truncated in
scoped macro_rules
| `($X:term _⦋$m:term⦌$n:subscript) =>
`(($X : CategoryTheory.SimplicialObject.Truncated _ $n).obj
(Opposite.op ⟨SimplexCategory.mk $m, by first | get_elem_tactic |
fail "Failed to prove truncation property. Try writing `X _⦋m, by ...⦌ₙ`."⟩))
| `($X:term _⦋$m:term, $p:term⦌$n:subscript) =>
`(($X : CategoryTheory.SimplicialObject.Truncated _ $n).obj
(Opposite.op ⟨SimplexCategory.mk $m, $p⟩))
variable (C) in
/-- Further truncation of truncated simplicial objects. -/
@[simps!]
def trunc (n m : ℕ) (h : m ≤ n := by omega) : Truncated C n ⥤ Truncated C m :=
(whiskeringLeft _ _ _).obj (SimplexCategory.Truncated.incl m n).op
end Truncated
section Truncation
/-- The truncation functor from simplicial objects to truncated simplicial objects. -/
def truncation (n : ℕ) : SimplicialObject C ⥤ SimplicialObject.Truncated C n :=
(whiskeringLeft _ _ _).obj (SimplexCategory.Truncated.inclusion n).op
/-- For all `m ≤ n`, `truncation m` factors through `Truncated n`. -/
def truncationCompTrunc {n m : ℕ} (h : m ≤ n) :
truncation n ⋙ Truncated.trunc C n m ≅ truncation m :=
Iso.refl _
end Truncation
noncomputable section
/-- The n-skeleton as a functor `SimplicialObject.Truncated C n ⥤ SimplicialObject C`. -/
protected abbrev Truncated.sk (n : ℕ) [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasLeftKanExtension F] :
SimplicialObject.Truncated C n ⥤ SimplicialObject C :=
lan (SimplexCategory.Truncated.inclusion n).op
/-- The n-coskeleton as a functor `SimplicialObject.Truncated C n ⥤ SimplicialObject C`. -/
protected abbrev Truncated.cosk (n : ℕ) [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasRightKanExtension F] :
SimplicialObject.Truncated C n ⥤ SimplicialObject C :=
ran (SimplexCategory.Truncated.inclusion n).op
/-- The n-skeleton as an endofunctor on `SimplicialObject C`. -/
abbrev sk (n : ℕ) [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasLeftKanExtension F] :
SimplicialObject C ⥤ SimplicialObject C := truncation n ⋙ Truncated.sk n
/-- The n-coskeleton as an endofunctor on `SimplicialObject C`. -/
abbrev cosk (n : ℕ) [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasRightKanExtension F] :
SimplicialObject C ⥤ SimplicialObject C := truncation n ⋙ Truncated.cosk n
end
section adjunctions
/- When the left and right Kan extensions exist, `Truncated.sk n` and `Truncated.cosk n`
respectively define left and right adjoints to `truncation n`. -/
variable (n : ℕ)
variable [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasRightKanExtension F]
variable [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasLeftKanExtension F]
/-- The adjunction between the n-skeleton and n-truncation. -/
noncomputable def skAdj : Truncated.sk (C := C) n ⊣ truncation n :=
lanAdjunction _ _
/-- The adjunction between n-truncation and the n-coskeleton. -/
noncomputable def coskAdj : truncation (C := C) n ⊣ Truncated.cosk n :=
ranAdjunction _ _
instance : ((sk n).obj X).IsLeftKanExtension ((skAdj n).unit.app _) := by
dsimp [sk, skAdj]
rw [lanAdjunction_unit]
infer_instance
instance : ((cosk n).obj X).IsRightKanExtension ((coskAdj n).counit.app _) := by
dsimp [cosk, coskAdj]
rw [ranAdjunction_counit]
infer_instance
namespace Truncated
/- When the left and right Kan extensions exist and are pointwise Kan extensions,
`skAdj n` and `coskAdj n` are respectively coreflective and reflective. -/
variable [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasPointwiseRightKanExtension F]
variable [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasPointwiseLeftKanExtension F]
instance cosk_reflective : IsIso (coskAdj (C := C) n).counit :=
reflective' (SimplexCategory.Truncated.inclusion n).op
instance sk_coreflective : IsIso (skAdj (C := C) n).unit :=
coreflective' (SimplexCategory.Truncated.inclusion n).op
/-- Since `Truncated.inclusion` is fully faithful, so is right Kan extension along it. -/
noncomputable def cosk.fullyFaithful :
(Truncated.cosk (C := C) n).FullyFaithful := by
apply Adjunction.fullyFaithfulROfIsIsoCounit (coskAdj n)
instance cosk.full : (Truncated.cosk (C := C) n).Full := FullyFaithful.full (cosk.fullyFaithful _)
instance cosk.faithful : (Truncated.cosk (C := C) n).Faithful :=
FullyFaithful.faithful (cosk.fullyFaithful _)
noncomputable instance coskAdj.reflective : Reflective (Truncated.cosk (C := C) n) :=
Reflective.mk (truncation _) (coskAdj _)
/-- Since `Truncated.inclusion` is fully faithful, so is left Kan extension along it. -/
noncomputable def sk.fullyFaithful : (Truncated.sk (C := C) n).FullyFaithful :=
Adjunction.fullyFaithfulLOfIsIsoUnit (skAdj n)
instance sk.full : (Truncated.sk (C := C) n).Full := FullyFaithful.full (sk.fullyFaithful _)
instance sk.faithful : (Truncated.sk (C := C) n).Faithful :=
FullyFaithful.faithful (sk.fullyFaithful _)
noncomputable instance skAdj.coreflective : Coreflective (Truncated.sk (C := C) n) :=
Coreflective.mk (truncation _) (skAdj _)
end Truncated
end adjunctions
variable (C)
/-- The constant simplicial object is the constant functor. -/
abbrev const : C ⥤ SimplicialObject C :=
CategoryTheory.Functor.const _
/-- The category of augmented simplicial objects, defined as a comma category. -/
def Augmented :=
Comma (𝟭 (SimplicialObject C)) (const C)
@[simps!]
instance : Category (Augmented C) := by
dsimp only [Augmented]
infer_instance
variable {C}
namespace Augmented
@[ext]
lemma hom_ext {X Y : Augmented C} (f g : X ⟶ Y) (h₁ : f.left = g.left) (h₂ : f.right = g.right) :
f = g :=
Comma.hom_ext _ _ h₁ h₂
/-- Drop the augmentation. -/
@[simps!]
def drop : Augmented C ⥤ SimplicialObject C :=
Comma.fst _ _
/-- The point of the augmentation. -/
@[simps!]
def point : Augmented C ⥤ C :=
Comma.snd _ _
/-- The functor from augmented objects to arrows. -/
@[simps]
def toArrow : Augmented C ⥤ Arrow C where
obj X :=
{ left := drop.obj X _⦋0⦌
right := point.obj X
hom := X.hom.app _ }
map η :=
{ left := (drop.map η).app _
right := point.map η
w := by
dsimp
rw [← NatTrans.comp_app]
erw [η.w]
rfl }
/-- The compatibility of a morphism with the augmentation, on 0-simplices -/
@[reassoc]
theorem w₀ {X Y : Augmented C} (f : X ⟶ Y) :
(Augmented.drop.map f).app (op ⦋0⦌) ≫ Y.hom.app (op ⦋0⦌) =
X.hom.app (op ⦋0⦌) ≫ Augmented.point.map f := by
convert congr_app f.w (op ⦋0⦌)
variable (C)
/-- Functor composition induces a functor on augmented simplicial objects. -/
@[simp]
def whiskeringObj (D : Type*) [Category D] (F : C ⥤ D) : Augmented C ⥤ Augmented D where
obj X :=
{ left := ((whiskering _ _).obj F).obj (drop.obj X)
right := F.obj (point.obj X)
hom := whiskerRight X.hom F ≫ (Functor.constComp _ _ _).hom }
map η :=
{ left := whiskerRight η.left _
right := F.map η.right
w := by
ext
dsimp [whiskerRight]
simp only [Category.comp_id, ← F.map_comp, ← NatTrans.comp_app]
erw [η.w]
rfl }
/-- Functor composition induces a functor on augmented simplicial objects. -/
@[simps]
def whiskering (D : Type u') [Category.{v'} D] : (C ⥤ D) ⥤ Augmented C ⥤ Augmented D where
obj := whiskeringObj _ _
map η :=
{ app := fun A =>
{ left := whiskerLeft _ η
right := η.app _
w := by
ext n
dsimp
rw [Category.comp_id, Category.comp_id, η.naturality] } }
map_comp := fun _ _ => by ext <;> rfl
variable {C}
/-- The constant augmented simplicial object functor. -/
@[simps]
def const : C ⥤ Augmented C where
obj X :=
{ left := (SimplicialObject.const C).obj X
right := X
hom := 𝟙 _ }
map f :=
{ left := (SimplicialObject.const C).map f
right := f }
end Augmented
/-- Augment a simplicial object with an object. -/
@[simps]
def augment (X : SimplicialObject C) (X₀ : C) (f : X _⦋0⦌ ⟶ X₀)
(w : ∀ (i : SimplexCategory) (g₁ g₂ : ⦋0⦌ ⟶ i),
X.map g₁.op ≫ f = X.map g₂.op ≫ f) :
SimplicialObject.Augmented C where
left := X
right := X₀
hom :=
{ app := fun _ => X.map (SimplexCategory.const _ _ 0).op ≫ f
naturality := by
intro i j g
dsimp
rw [← g.op_unop]
simpa only [← X.map_comp, ← Category.assoc, Category.comp_id, ← op_comp] using w _ _ _ }
-- Not `@[simp]` since `simp` can prove this.
theorem augment_hom_zero (X : SimplicialObject C) (X₀ : C) (f : X _⦋0⦌ ⟶ X₀) (w) :
(X.augment X₀ f w).hom.app (op ⦋0⦌) = f := by simp
end SimplicialObject
/-- Cosimplicial objects. -/
def CosimplicialObject :=
SimplexCategory ⥤ C
namespace CosimplicialObject
@[simps!]
instance : Category (CosimplicialObject C) := by
dsimp only [CosimplicialObject]
infer_instance
/-- `X ^⦋n⦌` denotes the `n`th-term of the cosimplicial object X -/
scoped[Simplicial]
notation3:1000 X " ^⦋" n "⦌" =>
(X : CategoryTheory.CosimplicialObject _).obj (SimplexCategory.mk n)
instance {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (CosimplicialObject C) := by
dsimp [CosimplicialObject]
infer_instance
instance [HasLimits C] : HasLimits (CosimplicialObject C) :=
⟨inferInstance⟩
instance {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (CosimplicialObject C) := by
dsimp [CosimplicialObject]
infer_instance
instance [HasColimits C] : HasColimits (CosimplicialObject C) :=
⟨inferInstance⟩
variable {C}
@[ext]
lemma hom_ext {X Y : CosimplicialObject C} (f g : X ⟶ Y)
(h : ∀ (n : SimplexCategory), f.app n = g.app n) : f = g :=
NatTrans.ext (by ext; apply h)
variable (X : CosimplicialObject C)
open Simplicial
/-- Coface maps for a cosimplicial object. -/
def δ {n} (i : Fin (n + 2)) : X ^⦋n⦌ ⟶ X ^⦋n + 1⦌ :=
X.map (SimplexCategory.δ i)
/-- Codegeneracy maps for a cosimplicial object. -/
def σ {n} (i : Fin (n + 1)) : X ^⦋n + 1⦌ ⟶ X ^⦋n⦌ :=
X.map (SimplexCategory.σ i)
/-- Isomorphisms from identities in ℕ. -/
def eqToIso {n m : ℕ} (h : n = m) : X ^⦋n⦌ ≅ X ^⦋m⦌ :=
X.mapIso (CategoryTheory.eqToIso (by rw [h]))
@[simp]
theorem eqToIso_refl {n : ℕ} (h : n = n) : X.eqToIso h = Iso.refl _ := by
simp [eqToIso]
/-- The generic case of the first cosimplicial identity -/
@[reassoc]
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) :
X.δ i ≫ X.δ j.succ = X.δ j ≫ X.δ (Fin.castSucc i) := by
dsimp [δ]
simp only [← X.map_comp, SimplexCategory.δ_comp_δ H]
@[reassoc]
theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) :
X.δ i ≫ X.δ j =
X.δ (j.pred fun (hj : j = 0) => by simp only [hj, Fin.not_lt_zero] at H) ≫
X.δ (Fin.castSucc i) := by
dsimp [δ]
simp only [← X.map_comp, SimplexCategory.δ_comp_δ' H]
@[reassoc]
theorem δ_comp_δ'' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) :
X.δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) ≫ X.δ j.succ =
X.δ j ≫ X.δ i := by
dsimp [δ]
simp only [← X.map_comp, SimplexCategory.δ_comp_δ'' H]
/-- The special case of the first cosimplicial identity -/
@[reassoc]
theorem δ_comp_δ_self {n} {i : Fin (n + 2)} :
X.δ i ≫ X.δ (Fin.castSucc i) = X.δ i ≫ X.δ i.succ := by
dsimp [δ]
simp only [← X.map_comp, SimplexCategory.δ_comp_δ_self]
@[reassoc]
theorem δ_comp_δ_self' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : j = Fin.castSucc i) :
X.δ i ≫ X.δ j = X.δ i ≫ X.δ i.succ := by
subst H
rw [δ_comp_δ_self]
/-- The second cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_le {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ Fin.castSucc j) :
X.δ (Fin.castSucc i) ≫ X.σ j.succ = X.σ j ≫ X.δ i := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_of_le H]
/-- The first part of the third cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_self {n} {i : Fin (n + 1)} : X.δ (Fin.castSucc i) ≫ X.σ i = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_self, X.map_id]
@[reassoc]
theorem δ_comp_σ_self' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = Fin.castSucc i) :
X.δ j ≫ X.σ i = 𝟙 _ := by
subst H
rw [δ_comp_σ_self]
/-- The second part of the third cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_succ {n} {i : Fin (n + 1)} : X.δ i.succ ≫ X.σ i = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_succ, X.map_id]
@[reassoc]
theorem δ_comp_σ_succ' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = i.succ) :
X.δ j ≫ X.σ i = 𝟙 _ := by
subst H
rw [δ_comp_σ_succ]
/-- The fourth cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSucc j < i) :
X.δ i.succ ≫ X.σ (Fin.castSucc j) = X.σ j ≫ X.δ i := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_of_gt H]
@[reassoc]
theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) :
X.δ i ≫ X.σ j =
X.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) ≫
X.δ (i.pred <|
fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_of_gt' H]
/-- The fifth cosimplicial identity -/
@[reassoc]
theorem σ_comp_σ {n} {i j : Fin (n + 1)} (H : i ≤ j) :
X.σ (Fin.castSucc i) ≫ X.σ j = X.σ j.succ ≫ X.σ i := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.σ_comp_σ H]
@[reassoc (attr := simp)]
theorem δ_naturality {X' X : CosimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 2)) :
X.δ i ≫ f.app ⦋n + 1⦌ = f.app ⦋n⦌ ≫ X'.δ i :=
f.naturality _
@[reassoc (attr := simp)]
theorem σ_naturality {X' X : CosimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ f.app ⦋n⦌ = f.app ⦋n + 1⦌ ≫ X'.σ i :=
f.naturality _
variable (C)
/-- Functor composition induces a functor on cosimplicial objects. -/
@[simps!]
def whiskering (D : Type*) [Category D] : (C ⥤ D) ⥤ CosimplicialObject C ⥤ CosimplicialObject D :=
whiskeringRight _ _ _
/-- Truncated cosimplicial objects. -/
def Truncated (n : ℕ) :=
SimplexCategory.Truncated n ⥤ C
instance {n : ℕ} : Category (Truncated C n) := by
dsimp [Truncated]
infer_instance
variable {C}
namespace Truncated
instance {n} {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (CosimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasLimits C] : HasLimits (CosimplicialObject.Truncated C n) :=
⟨inferInstance⟩
instance {n} {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (CosimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasColimits C] : HasColimits (CosimplicialObject.Truncated C n) :=
⟨inferInstance⟩
variable (C) in
/-- Functor composition induces a functor on truncated cosimplicial objects. -/
@[simps!]
def whiskering {n} (D : Type*) [Category D] : (C ⥤ D) ⥤ Truncated C n ⥤ Truncated D n :=
whiskeringRight _ _ _
open Mathlib.Tactic (subscriptTerm) in
/-- For `X : Truncated C n` and `m ≤ n`, `X ^⦋m⦌ₙ` is the `m`-th term of X. The
proof `p : m ≤ n` can also be provided using the syntax `X ^⦋m, p⦌ₙ`. -/
scoped syntax:max (name := mkNotation)
term " ^⦋" term ("," term)? "⦌" noWs subscriptTerm : term
open scoped SimplexCategory.Truncated in
scoped macro_rules
| `($X:term ^⦋$m:term⦌$n:subscript) =>
`(($X : CategoryTheory.CosimplicialObject.Truncated _ $n).obj
⟨SimplexCategory.mk $m, by first | get_elem_tactic |
fail "Failed to prove truncation property. Try writing `X ^⦋m, by ...⦌ₙ`."⟩)
| `($X:term ^⦋$m:term, $p:term⦌$n:subscript) =>
`(($X : CategoryTheory.CosimplicialObject.Truncated _ $n).obj
⟨SimplexCategory.mk $m, $p⟩)
variable (C) in
/-- Further truncation of truncated cosimplicial objects. -/
def trunc (n m : ℕ) (h : m ≤ n := by omega) : Truncated C n ⥤ Truncated C m :=
(whiskeringLeft _ _ _).obj <| SimplexCategory.Truncated.incl m n
end Truncated
section Truncation
/-- The truncation functor from cosimplicial objects to truncated cosimplicial objects. -/
def truncation (n : ℕ) : CosimplicialObject C ⥤ CosimplicialObject.Truncated C n :=
(whiskeringLeft _ _ _).obj (SimplexCategory.Truncated.inclusion n)
/-- For all `m ≤ n`, `truncation m` factors through `Truncated n`. -/
def truncationCompTrunc {n m : ℕ} (h : m ≤ n) :
truncation n ⋙ Truncated.trunc C n m ≅ truncation m :=
Iso.refl _
end Truncation
variable (C)
/-- The constant cosimplicial object. -/
abbrev const : C ⥤ CosimplicialObject C :=
CategoryTheory.Functor.const _
/-- Augmented cosimplicial objects. -/
def Augmented :=
Comma (const C) (𝟭 (CosimplicialObject C))
@[simps!]
instance : Category (Augmented C) := by
dsimp only [Augmented]
infer_instance
variable {C}
namespace Augmented
@[ext]
lemma hom_ext {X Y : Augmented C} (f g : X ⟶ Y) (h₁ : f.left = g.left) (h₂ : f.right = g.right) :
f = g :=
Comma.hom_ext _ _ h₁ h₂
/-- Drop the augmentation. -/
@[simps!]
def drop : Augmented C ⥤ CosimplicialObject C :=
Comma.snd _ _
/-- The point of the augmentation. -/
@[simps!]
def point : Augmented C ⥤ C :=
Comma.fst _ _
/-- The functor from augmented objects to arrows. -/
@[simps!]
def toArrow : Augmented C ⥤ Arrow C where
obj X :=
{ left := point.obj X
right := (drop.obj X) ^⦋0⦌
hom := X.hom.app _ }
map η :=
{ left := point.map η
right := (drop.map η).app _
w := by
dsimp
rw [← NatTrans.comp_app]
erw [← η.w]
rfl }
variable (C)
/-- Functor composition induces a functor on augmented cosimplicial objects. -/
@[simp]
def whiskeringObj (D : Type*) [Category D] (F : C ⥤ D) : Augmented C ⥤ Augmented D where
obj X :=
{ left := F.obj (point.obj X)
right := ((whiskering _ _).obj F).obj (drop.obj X)
hom := (Functor.constComp _ _ _).inv ≫ whiskerRight X.hom F }
map η :=
{ left := F.map η.left
right := whiskerRight η.right _
w := by
ext
dsimp
rw [Category.id_comp, Category.id_comp, ← F.map_comp, ← F.map_comp, ← NatTrans.comp_app]
erw [← η.w]
rfl }
/-- Functor composition induces a functor on augmented cosimplicial objects. -/
@[simps]
def whiskering (D : Type u') [Category.{v'} D] : (C ⥤ D) ⥤ Augmented C ⥤ Augmented D where
obj := whiskeringObj _ _
map η :=
{ app := fun A =>
{ left := η.app _
right := whiskerLeft _ η
w := by
ext n
dsimp
rw [Category.id_comp, Category.id_comp, η.naturality] }
naturality := fun _ _ f => by ext <;> simp }
variable {C}
/-- The constant augmented cosimplicial object functor. -/
@[simps]
def const : C ⥤ Augmented C where
obj X :=
{ left := X
right := (CosimplicialObject.const C).obj X
hom := 𝟙 _ }
map f :=
{ left := f
right := (CosimplicialObject.const C).map f }
end Augmented
open Simplicial
/-- Augment a cosimplicial object with an object. -/
@[simps]
def augment (X : CosimplicialObject C) (X₀ : C) (f : X₀ ⟶ X.obj ⦋0⦌)
(w : ∀ (i : SimplexCategory) (g₁ g₂ : ⦋0⦌ ⟶ i),
f ≫ X.map g₁ = f ≫ X.map g₂) : CosimplicialObject.Augmented C where
left := X₀
right := X
hom :=
{ app := fun _ => f ≫ X.map (SimplexCategory.const _ _ 0)
naturality := by
intro i j g
dsimp
rw [Category.id_comp, Category.assoc, ← X.map_comp, w] }
-- Not `@[simp]` since `simp` can prove this.
theorem augment_hom_zero (X : CosimplicialObject C) (X₀ : C) (f : X₀ ⟶ X.obj ⦋0⦌) (w) :
(X.augment X₀ f w).hom.app ⦋0⦌ = f := by simp
end CosimplicialObject
/-- The anti-equivalence between simplicial objects and cosimplicial objects. -/
@[simps!]
def simplicialCosimplicialEquiv : (SimplicialObject C)ᵒᵖ ≌ CosimplicialObject Cᵒᵖ :=
Functor.leftOpRightOpEquiv _ _
/-- The anti-equivalence between cosimplicial objects and simplicial objects. -/
@[simps!]
def cosimplicialSimplicialEquiv : (CosimplicialObject C)ᵒᵖ ≌ SimplicialObject Cᵒᵖ :=
Functor.opUnopEquiv _ _
variable {C}
/-- Construct an augmented cosimplicial object in the opposite
category from an augmented simplicial object. -/
@[simps!]
def SimplicialObject.Augmented.rightOp (X : SimplicialObject.Augmented C) :
CosimplicialObject.Augmented Cᵒᵖ where
left := Opposite.op X.right
right := X.left.rightOp
hom := NatTrans.rightOp X.hom
/-- Construct an augmented simplicial object from an augmented cosimplicial
object in the opposite category. -/
@[simps!]
def CosimplicialObject.Augmented.leftOp (X : CosimplicialObject.Augmented Cᵒᵖ) :
SimplicialObject.Augmented C where
left := X.right.leftOp
right := X.left.unop
hom := NatTrans.leftOp X.hom
/-- Converting an augmented simplicial object to an augmented cosimplicial
object and back is isomorphic to the given object. -/
@[simps!]
def SimplicialObject.Augmented.rightOpLeftOpIso (X : SimplicialObject.Augmented C) :
X.rightOp.leftOp ≅ X :=
Comma.isoMk X.left.rightOpLeftOpIso (CategoryTheory.eqToIso <| by simp)
/-- Converting an augmented cosimplicial object to an augmented simplicial
object and back is isomorphic to the given object. -/
@[simps!]
def CosimplicialObject.Augmented.leftOpRightOpIso (X : CosimplicialObject.Augmented Cᵒᵖ) :
X.leftOp.rightOp ≅ X :=
Comma.isoMk (CategoryTheory.eqToIso <| by simp) X.right.leftOpRightOpIso
variable (C)
/-- A functorial version of `SimplicialObject.Augmented.rightOp`. -/
@[simps]
def simplicialToCosimplicialAugmented :
(SimplicialObject.Augmented C)ᵒᵖ ⥤ CosimplicialObject.Augmented Cᵒᵖ where
obj X := X.unop.rightOp
map f :=
{ left := f.unop.right.op
right := NatTrans.rightOp f.unop.left
w := by
ext x
dsimp
simp_rw [← op_comp]
congr 1
exact (congr_app f.unop.w (op x)).symm }
/-- A functorial version of `Cosimplicial_object.Augmented.leftOp`. -/
@[simps]
def cosimplicialToSimplicialAugmented :
CosimplicialObject.Augmented Cᵒᵖ ⥤ (SimplicialObject.Augmented C)ᵒᵖ where
obj X := Opposite.op X.leftOp
map f :=
Quiver.Hom.op <|
{ left := NatTrans.leftOp f.right
right := f.left.unop
w := by
ext x
dsimp
simp_rw [← unop_comp]
congr 1
exact (congr_app f.w (unop x)).symm }
/-- The contravariant categorical equivalence between augmented simplicial
objects and augmented cosimplicial objects in the opposite category. -/
@[simps! functor inverse]
def simplicialCosimplicialAugmentedEquiv :
(SimplicialObject.Augmented C)ᵒᵖ ≌ CosimplicialObject.Augmented Cᵒᵖ where
functor := simplicialToCosimplicialAugmented _
inverse := cosimplicialToSimplicialAugmented _
unitIso := NatIso.ofComponents (fun X => X.unop.rightOpLeftOpIso.op) fun f => by
dsimp
rw [← f.op_unop]
simp_rw [← op_comp]
congr 1
cat_disch
counitIso := NatIso.ofComponents fun X => X.leftOpRightOpIso
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialObject/II.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Basic
/-!
# A construction by Gabriel and Zisman
In this file, we construct a cosimplicial object `SimplexCategory.II`
in `SimplexCategoryᵒᵖ`, i.e. a functor `SimplexCategory ⥤ SimplexCategoryᵒᵖ`.
If we identify `SimplexCategory` with the category of finite nonempty
linearly ordered types, this functor could be interpreted as the
contravariant functor which sends a finite nonempty linearly ordered type `T`
to `T →o Fin 2` (with `f ≤ g ↔ ∀ i, g i ≤ f i`, which turns out to
be a linear order); in particular, it sends `Fin (n + 1)` to a linearly
ordered type which is isomorphic to `Fin (n + 2)`. As a result, we define
`SimplexCategory.II` as a functor which sends `⦋n⦌` to `⦋n + 1⦌`: on morphisms,
it sends faces to degeneracies and vice versa. This construction appeared
in *Calculus of fractions and homotopy theory*, chapter III, paragraph 1.1,
by Gabriel and Zisman.
## References
* [P. Gabriel, M. Zisman, *Calculus of fractions and homotopy theory*][gabriel-zisman-1967]
-/
open CategoryTheory Simplicial Opposite
namespace SimplexCategory
namespace II
variable {n m : ℕ}
/-- Auxiliary definition for `map'`. Given `f : Fin (n + 1) →o Fin (m + 1)` and
`x : Fin (m + 2)`, `map' f x` shall be the smallest element in
this `finset f x : Finset (Fin (n + 2))`. -/
def finset (f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) : Finset (Fin (n + 2)) :=
Finset.univ.filter (fun i ↦ i = Fin.last _ ∨
∃ (h : i ≠ Fin.last _), x ≤ (f (i.castPred h)).castSucc)
lemma mem_finset_iff (f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) (i : Fin (n + 2)) :
i ∈ finset f x ↔ i = Fin.last _ ∨
∃ (h : i ≠ Fin.last _), x ≤ (f (i.castPred h)).castSucc := by
simp [finset]
@[simp]
lemma last_mem_finset (f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) :
Fin.last _ ∈ finset f x := by
simp [mem_finset_iff]
@[simp]
lemma castSucc_mem_finset_iff
(f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) (i : Fin (n + 1)) :
i.castSucc ∈ finset f x ↔ x ≤ (f i).castSucc := by
simp [mem_finset_iff, Fin.castPred_castSucc]
lemma nonempty_finset (f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) :
(finset f x).Nonempty :=
⟨Fin.last _, by simp [mem_finset_iff]⟩
/-- Auxiliary definition for the definition of the action of the
functor `SimplexCategory.II` on morphisms. -/
def map' (f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) : Fin (n + 2) :=
(finset f x).min' (nonempty_finset f x)
lemma map'_eq_last_iff (f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) :
map' f x = Fin.last _ ↔ ∀ (i : Fin (n + 1)), (f i).castSucc < x := by
simp only [map', Finset.min'_eq_iff, last_mem_finset, Fin.last_le_iff, true_and]
constructor
· intro h i
by_contra!
exact i.castSucc_ne_last (h i.castSucc (by simpa))
· intro h i hi
by_contra!
obtain ⟨i, rfl⟩ := Fin.eq_castSucc_of_ne_last this
simp only [castSucc_mem_finset_iff] at hi
exact hi.not_gt (h i)
lemma map'_eq_castSucc_iff (f : Fin (n + 1) →o Fin (m + 1)) (x : Fin (m + 2)) (y : Fin (n + 1)) :
map' f x = y.castSucc ↔ x ≤ (f y).castSucc ∧
∀ (i : Fin (n + 1)) (_ : i < y), (f i).castSucc < x := by
simp only [map', Finset.min'_eq_iff, castSucc_mem_finset_iff, and_congr_right_iff]
intro h
constructor
· intro h' i hi
by_contra!
exact hi.not_ge (by simpa using h' i.castSucc (by simpa))
· intro h' i hi
obtain ⟨i, rfl⟩ | rfl := i.eq_castSucc_or_eq_last
· simp only [Fin.castSucc_le_castSucc_iff]
by_contra!
exact (h' i this).not_ge (by simpa using hi)
· apply Fin.le_last
@[simp]
lemma map'_last (f : Fin (n + 1) →o Fin (m + 1)) :
map' f (Fin.last _) = Fin.last _ := by
simp [map'_eq_last_iff]
@[simp]
lemma map'_zero (f : Fin (n + 1) →o Fin (m + 1)) :
map' f 0 = 0 := by
simp [← Fin.castSucc_zero, -Fin.castSucc_zero', map'_eq_castSucc_iff]
@[simp]
lemma map'_id (x : Fin (n + 2)) : map' OrderHom.id x = x := by
obtain ⟨x, rfl⟩ | rfl := Fin.eq_castSucc_or_eq_last x
· rw [map'_eq_castSucc_iff]
aesop
· simp
lemma map'_map' {p : ℕ} (f : Fin (n + 1) →o Fin (m + 1))
(g : Fin (m + 1) →o Fin (p + 1)) (x : Fin (p + 2)) :
map' f (map' g x) = map' (g.comp f) x := by
obtain ⟨x, rfl⟩ | rfl := Fin.eq_castSucc_or_eq_last x
· obtain ⟨y, hy⟩ | hx := Fin.eq_castSucc_or_eq_last (map' g x.castSucc)
· rw [hy]
rw [map'_eq_castSucc_iff] at hy
obtain ⟨z, hz⟩ | hz := Fin.eq_castSucc_or_eq_last (map' f y.castSucc)
· rw [hz, Eq.comm]
rw [map'_eq_castSucc_iff] at hz ⊢
constructor
· refine hy.1.trans ?_
simp only [OrderHom.comp_coe, Function.comp_apply, Fin.castSucc_le_castSucc_iff]
exact g.monotone (by simpa using hz.1)
· intro i hi
exact hy.2 (f i) (by simpa using hz.2 i hi)
· rw [hz, Eq.comm]
rw [map'_eq_last_iff] at hz ⊢
intro i
exact hy.2 (f i) (by simpa using hz i)
· rw [Eq.comm, hx, map'_last]
rw [map'_eq_last_iff] at hx ⊢
intro i
apply hx
· simp
@[simp]
lemma map'_succAboveOrderEmb {n : ℕ} (i : Fin (n + 2)) (x : Fin (n + 3)) :
map' i.succAboveOrderEmb.toOrderHom x = i.predAbove x := by
obtain ⟨x, rfl⟩ | rfl := x.eq_castSucc_or_eq_last
· by_cases! hx : x ≤ i
· rw [Fin.predAbove_of_le_castSucc _ _ (by simpa), Fin.castPred_castSucc]
obtain ⟨x, rfl⟩ | rfl := x.eq_castSucc_or_eq_last
· simp only [map'_eq_castSucc_iff, OrderEmbedding.toOrderHom_coe,
Fin.succAboveOrderEmb_apply, Fin.castSucc_le_castSucc_iff,
Fin.castSucc_lt_castSucc_iff]
constructor
· obtain hx | rfl := hx.lt_or_eq
· rwa [Fin.succAbove_of_castSucc_lt]
· simpa only [Fin.succAbove_castSucc_self] using Fin.castSucc_le_succ x
· intro j hj
rwa [Fin.succAbove_of_castSucc_lt _ _ (lt_of_lt_of_le (by simpa) hx),
Fin.castSucc_lt_castSucc_iff]
· obtain rfl : i = Fin.last _ := Fin.last_le_iff.1 hx
simp [map'_eq_last_iff]
· obtain ⟨x, rfl⟩ := Fin.eq_succ_of_ne_zero (Fin.ne_zero_of_lt hx)
rw [Fin.predAbove_of_castSucc_lt _ _ (by simpa [Fin.le_castSucc_iff]),
Fin.pred_castSucc_succ, map'_eq_castSucc_iff]
simp only [Fin.succAbove_of_lt_succ _ _ hx,
OrderEmbedding.toOrderHom_coe, Fin.succAboveOrderEmb_apply,
le_refl, Fin.castSucc_lt_castSucc_iff, true_and]
intro j hj
by_cases! h : j.castSucc < i
· simpa [Fin.succAbove_of_castSucc_lt _ _ h] using hj.le
· rwa [Fin.succAbove_of_le_castSucc _ _ h, Fin.succ_lt_succ_iff]
· simp
@[simp]
lemma map'_predAbove {n : ℕ} (i : Fin (n + 1)) (x : Fin (n + 2)) :
map' { toFun := i.predAbove, monotone' := Fin.predAbove_right_monotone i } x =
i.succ.castSucc.succAbove x := by
obtain ⟨x, rfl⟩ | rfl := x.eq_castSucc_or_eq_last
· by_cases! hi : i < x
· rw [Fin.succAbove_of_le_castSucc _ _ (by simpa), Fin.succ_castSucc, map'_eq_castSucc_iff]
simp only [OrderHom.coe_mk, Fin.castSucc_le_castSucc_iff, Fin.castSucc_lt_castSucc_iff]
constructor
· rw [Fin.predAbove_of_castSucc_lt _ _
(by simpa only [Fin.castSucc_lt_succ_iff] using hi.le), Fin.pred_succ]
· intro j hj
by_cases! h : i.castSucc < j
· rwa [Fin.predAbove_of_castSucc_lt _ _ h, ← Fin.succ_lt_succ_iff,
Fin.succ_pred]
· rw [Fin.predAbove_of_le_castSucc _ _ h, ← Fin.castSucc_lt_castSucc_iff,
Fin.castSucc_castPred]
exact lt_of_le_of_lt h hi
· rw [Fin.succAbove_of_castSucc_lt _ _ (by simpa), map'_eq_castSucc_iff]
simp only [OrderHom.coe_mk, Fin.castSucc_le_castSucc_iff, Fin.castSucc_lt_castSucc_iff]
constructor
· simp only [i.predAbove_of_le_castSucc x.castSucc (by simpa),
Fin.castPred_castSucc, le_refl]
· intro j hj
by_cases! h : i.castSucc < j
· rw [Fin.predAbove_of_castSucc_lt _ _ h, ← Fin.succ_lt_succ_iff, Fin.succ_pred]
exact hj.trans x.castSucc_lt_succ
· rwa [Fin.predAbove_of_le_castSucc _ _ h, ← Fin.castSucc_lt_castSucc_iff,
Fin.castSucc_castPred]
· simp [map'_last]
lemma monotone_map' (f : Fin (n + 1) →o Fin (m + 1)) :
Monotone (map' f) := by
intro x y hxy
exact Finset.min'_subset _ (fun z hz ↦ by
obtain ⟨z, rfl⟩ | rfl := z.eq_castSucc_or_eq_last
· simp only [castSucc_mem_finset_iff] at hz ⊢
exact hxy.trans hz
· simp)
end II
/-- The functor `SimplexCategory ⥤ SimplexCategoryᵒᵖ` (i.e. a cosimplicial
object in `SimplexCategoryᵒᵖ`) which sends `⦋n⦌` to the object in `SimplexCategoryᵒᵖ`
that is associated to the linearly ordered type `⦋n + 1⦌` (which could be
identified to the ordered type `⦋n⦌ →o ⦋1⦌`). -/
@[simps obj]
def II : CosimplicialObject SimplexCategoryᵒᵖ where
obj n := op ⦋n.len + 1⦌
map f := op (Hom.mk
{ toFun := II.map' f.toOrderHom
monotone' := II.monotone_map' _ })
map_id n := Quiver.Hom.unop_inj (by
ext x : 3
exact II.map'_id x)
map_comp {m n p} f g := Quiver.Hom.unop_inj (by
ext x : 3
exact (II.map'_map' _ _ _).symm)
@[simp]
lemma II_δ {n : ℕ} (i : Fin (n + 2)) :
II.δ i = (σ i).op :=
Quiver.Hom.unop_inj (by ext : 3; apply II.map'_succAboveOrderEmb)
@[simp]
lemma II_σ {n : ℕ} (i : Fin (n + 1)) :
II.σ i = (δ i.succ.castSucc).op :=
Quiver.Hom.unop_inj (by ext x : 3; apply II.map'_predAbove)
end SimplexCategory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialObject/Coskeletal.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction
import Mathlib.CategoryTheory.Functor.KanExtension.Basic
/-!
# Coskeletal simplicial objects
The identity natural transformation exhibits a simplicial object `X` as a right extension of its
restriction along `(Truncated.inclusion n).op` recorded by `rightExtensionInclusion X n`.
The simplicial object `X` is *n-coskeletal* if `rightExtensionInclusion X n` is a right Kan
extension.
When the ambient category admits right Kan extensions along `(Truncated.inclusion n).op`,
then when `X` is `n`-coskeletal, the unit of `coskAdj n` defines an isomorphism:
`isoCoskOfIsCoskeletal : X ≅ (cosk n).obj X`.
TODO: Prove that `X` is `n`-coskeletal whenever a certain canonical cone is a limit cone.
-/
open Opposite
open CategoryTheory
open CategoryTheory.Limits CategoryTheory.Functor SimplexCategory
universe v u v' u'
namespace CategoryTheory
namespace SimplicialObject
variable {C : Type u} [Category.{v} C]
variable (X : SimplicialObject C) (n : ℕ)
namespace Truncated
/-- The identity natural transformation exhibits a simplicial set as a right extension of its
restriction along `(Truncated.inclusion n).op`. -/
@[simps!]
def rightExtensionInclusion :
RightExtension (Truncated.inclusion n).op
((Truncated.inclusion n).op ⋙ X) := RightExtension.mk _ (𝟙 _)
end Truncated
open Truncated
/-- A simplicial object `X` is `n`-coskeletal when it is the right Kan extension of its restriction
along `(Truncated.inclusion n).op` via the identity natural transformation. -/
@[mk_iff]
class IsCoskeletal : Prop where
isRightKanExtension : IsRightKanExtension X (𝟙 ((Truncated.inclusion n).op ⋙ X))
attribute [instance] IsCoskeletal.isRightKanExtension
section
variable [∀ (F : (SimplexCategory.Truncated n)ᵒᵖ ⥤ C),
(SimplexCategory.Truncated.inclusion n).op.HasRightKanExtension F]
/-- If `X` is `n`-coskeletal, then `Truncated.rightExtensionInclusion X n` is a terminal object in
the category `RightExtension (Truncated.inclusion n).op (Truncated.inclusion.op ⋙ X)`. -/
noncomputable def IsCoskeletal.isUniversalOfIsRightKanExtension [X.IsCoskeletal n] :
(rightExtensionInclusion X n).IsUniversal := by
apply Functor.isUniversalOfIsRightKanExtension
theorem isCoskeletal_iff_isIso : X.IsCoskeletal n ↔ IsIso ((coskAdj n).unit.app X) := by
rw [isCoskeletal_iff]
exact isRightKanExtension_iff_isIso ((coskAdj n).unit.app X)
((coskAdj n).counit.app _) (𝟙 _) ((coskAdj n).left_triangle_components X)
instance [X.IsCoskeletal n] : IsIso ((coskAdj n).unit.app X) := by
rw [← isCoskeletal_iff_isIso]
infer_instance
/-- The canonical isomorphism `X ≅ (cosk n).obj X` defined when `X` is coskeletal and the
`n`-coskeleton functor exists. -/
@[simps! hom]
noncomputable def isoCoskOfIsCoskeletal [X.IsCoskeletal n] : X ≅ (cosk n).obj X :=
asIso ((coskAdj n).unit.app X)
end
end SimplicialObject
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/CategoryWithCofibrations.lean | import Mathlib.CategoryTheory.MorphismProperty.Basic
/-!
# Categories with classes of fibrations, cofibrations, weak equivalences
We introduce typeclasses `CategoryWithFibrations`, `CategoryWithCofibrations` and
`CategoryWithWeakEquivalences` to express that a category `C` is equipped with
classes of morphisms named "fibrations", "cofibrations" or "weak equivalences".
-/
universe v u
namespace HomotopicalAlgebra
open CategoryTheory
variable (C : Type u) [Category.{v} C]
/-- A category with fibrations is a category equipped with
a class of morphisms named "fibrations". -/
class CategoryWithFibrations where
/-- the class of fibrations -/
fibrations : MorphismProperty C
/-- A category with cofibrations is a category equipped with
a class of morphisms named "cofibrations". -/
class CategoryWithCofibrations where
/-- the class of cofibrations -/
cofibrations : MorphismProperty C
/-- A category with weak equivalences is a category equipped with
a class of morphisms named "weak equivalences". -/
class CategoryWithWeakEquivalences where
/-- the class of weak equivalences -/
weakEquivalences : MorphismProperty C
variable {X Y : C} (f : X ⟶ Y)
section Fib
variable [CategoryWithFibrations C]
/-- The class of fibrations in a category with fibrations. -/
def fibrations : MorphismProperty C := CategoryWithFibrations.fibrations
variable {C}
/-- A morphism `f` satisfies `[Fibration f]` if it belongs to `fibrations C`. -/
@[mk_iff]
class Fibration : Prop where
mem : fibrations C f
lemma mem_fibrations [Fibration f] : fibrations C f := Fibration.mem
end Fib
section Cof
variable [CategoryWithCofibrations C]
/-- The class of cofibrations in a category with cofibrations. -/
def cofibrations : MorphismProperty C := CategoryWithCofibrations.cofibrations
variable {C}
/-- A morphism `f` satisfies `[Cofibration f]` if it belongs to `cofibrations C`. -/
@[mk_iff]
class Cofibration : Prop where
mem : cofibrations C f
lemma mem_cofibrations [Cofibration f] : cofibrations C f := Cofibration.mem
end Cof
section W
variable [CategoryWithWeakEquivalences C]
/-- The class of weak equivalences in a category with weak equivalences. -/
def weakEquivalences : MorphismProperty C := CategoryWithWeakEquivalences.weakEquivalences
variable {C}
/-- A morphism `f` satisfies `[WeakEquivalence f]` if it belongs to `weakEquivalences C`. -/
@[mk_iff]
class WeakEquivalence : Prop where
mem : weakEquivalences C f
lemma mem_weakEquivalences [WeakEquivalence f] : weakEquivalences C f := WeakEquivalence.mem
end W
section TrivFib
variable [CategoryWithFibrations C] [CategoryWithWeakEquivalences C]
/-- A trivial fibration is a morphism that is both a fibration and a weak equivalence. -/
def trivialFibrations : MorphismProperty C := fibrations C ⊓ weakEquivalences C
lemma trivialFibrations_sub_fibrations : trivialFibrations C ≤ fibrations C :=
fun _ _ _ hf ↦ hf.1
lemma trivialFibrations_sub_weakEquivalences : trivialFibrations C ≤ weakEquivalences C :=
fun _ _ _ hf ↦ hf.2
variable {C}
lemma mem_trivialFibrations [Fibration f] [WeakEquivalence f] :
trivialFibrations C f :=
⟨mem_fibrations f, mem_weakEquivalences f⟩
lemma mem_trivialFibrations_iff :
trivialFibrations C f ↔ Fibration f ∧ WeakEquivalence f := by
rw [fibration_iff, weakEquivalence_iff]
rfl
end TrivFib
section TrivCof
variable [CategoryWithCofibrations C] [CategoryWithWeakEquivalences C]
/-- A trivial cofibration is a morphism that is both a cofibration and a weak equivalence. -/
def trivialCofibrations : MorphismProperty C := cofibrations C ⊓ weakEquivalences C
lemma trivialCofibrations_sub_cofibrations : trivialCofibrations C ≤ cofibrations C :=
fun _ _ _ hf ↦ hf.1
lemma trivialCofibrations_sub_weakEquivalences : trivialCofibrations C ≤ weakEquivalences C :=
fun _ _ _ hf ↦ hf.2
variable {C}
lemma mem_trivialCofibrations [Cofibration f] [WeakEquivalence f] :
trivialCofibrations C f :=
⟨mem_cofibrations f, mem_weakEquivalences f⟩
lemma mem_trivialCofibrations_iff :
trivialCofibrations C f ↔ Cofibration f ∧ WeakEquivalence f := by
rw [cofibration_iff, weakEquivalence_iff]
rfl
end TrivCof
section
variable [CategoryWithCofibrations C]
instance : CategoryWithFibrations Cᵒᵖ where
fibrations := (cofibrations C).op
lemma fibrations_op : fibrations Cᵒᵖ = (cofibrations C).op := rfl
lemma cofibrations_eq_unop : cofibrations C = (fibrations Cᵒᵖ).unop := rfl
variable {C}
lemma fibration_op_iff : Fibration f.op ↔ Cofibration f := by
simp [cofibration_iff, fibration_iff, cofibrations_eq_unop]
lemma cofibration_unop_iff {X Y : Cᵒᵖ} (f : X ⟶ Y) :
Cofibration f.unop ↔ Fibration f := by
simp [cofibration_iff, fibration_iff, cofibrations_eq_unop]
instance [Cofibration f] : Fibration f.op := by
rwa [fibration_op_iff]
instance {X Y : Cᵒᵖ} (f : X ⟶ Y) [Fibration f] : Cofibration f.unop := by
rwa [cofibration_unop_iff]
end
section
variable [CategoryWithFibrations C]
instance : CategoryWithCofibrations Cᵒᵖ where
cofibrations := (fibrations C).op
lemma cofibrations_op : cofibrations Cᵒᵖ = (fibrations C).op := rfl
lemma fibrations_eq_unop : fibrations C = (cofibrations Cᵒᵖ).unop := rfl
variable {C}
lemma cofibration_op_iff : Cofibration f.op ↔ Fibration f := by
simp [cofibration_iff, fibration_iff, fibrations_eq_unop]
lemma fibration_unop_iff {X Y : Cᵒᵖ} (f : X ⟶ Y) :
Fibration f.unop ↔ Cofibration f := by
simp [cofibration_iff, fibration_iff, fibrations_eq_unop]
instance [Fibration f] : Cofibration f.op := by
rwa [cofibration_op_iff]
instance {X Y : Cᵒᵖ} (f : X ⟶ Y) [Cofibration f] : Fibration f.unop := by
rwa [fibration_unop_iff]
end
section
variable [CategoryWithWeakEquivalences C]
instance : CategoryWithWeakEquivalences Cᵒᵖ where
weakEquivalences := (weakEquivalences C).op
lemma weakEquivalences_op : weakEquivalences Cᵒᵖ = (weakEquivalences C).op := rfl
lemma weakEquivalences_eq_unop : weakEquivalences C = (weakEquivalences Cᵒᵖ).unop := rfl
variable {C}
lemma weakEquivalences_op_iff : WeakEquivalence f.op ↔ WeakEquivalence f := by
simp [weakEquivalence_iff, weakEquivalences_op]
lemma weakEquivalences_unop_iff {X Y : Cᵒᵖ} (f : X ⟶ Y) :
WeakEquivalence f.unop ↔ WeakEquivalence f :=
(weakEquivalences_op_iff f.unop).symm
instance [WeakEquivalence f] : WeakEquivalence f.op := by
rwa [weakEquivalences_op_iff]
instance {X Y : Cᵒᵖ} (f : X ⟶ Y) [WeakEquivalence f] : WeakEquivalence f.unop := by
rwa [weakEquivalences_unop_iff]
end
section
variable [CategoryWithWeakEquivalences C] [CategoryWithCofibrations C]
lemma trivialFibrations_op : trivialFibrations Cᵒᵖ = (trivialCofibrations C).op := rfl
lemma trivialCofibrations_eq_unop : trivialCofibrations C = (trivialFibrations Cᵒᵖ).unop := rfl
end
section
variable [CategoryWithWeakEquivalences C] [CategoryWithFibrations C]
lemma trivialCofibrations_op : trivialCofibrations Cᵒᵖ = (trivialFibrations C).op := rfl
lemma trivialFibrations_eq_unop : trivialFibrations C = (trivialCofibrations Cᵒᵖ).unop := rfl
end
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/Instances.lean | import Mathlib.CategoryTheory.MorphismProperty.WeakFactorizationSystem
import Mathlib.AlgebraicTopology.ModelCategory.CategoryWithCofibrations
/-!
# Consequences of model category axioms
In this file, we deduce basic properties of fibrations, cofibrations,
and weak equivalences from the axioms of model categories.
-/
universe w v u
open CategoryTheory Limits MorphismProperty
namespace HomotopicalAlgebra
variable (C : Type u) [Category.{v} C]
instance [CategoryWithWeakEquivalences C] [CategoryWithCofibrations C]
[(cofibrations C).IsStableUnderRetracts]
[(weakEquivalences C).IsStableUnderRetracts] :
(trivialCofibrations C).IsStableUnderRetracts := by
dsimp [trivialCofibrations]
infer_instance
instance [CategoryWithWeakEquivalences C] [CategoryWithFibrations C]
[(fibrations C).IsStableUnderRetracts]
[(weakEquivalences C).IsStableUnderRetracts] :
(trivialFibrations C).IsStableUnderRetracts := by
dsimp [trivialFibrations]
infer_instance
section IsStableUnderComposition
variable {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z)
instance [CategoryWithCofibrations C] [(cofibrations C).IsStableUnderComposition]
[hf : Cofibration f] [hg : Cofibration g] : Cofibration (f ≫ g) :=
(cofibration_iff _).2 ((cofibrations C).comp_mem _ _ hf.mem hg.mem)
instance [CategoryWithFibrations C] [(fibrations C).IsStableUnderComposition]
[hf : Fibration f] [hg : Fibration g] : Fibration (f ≫ g) :=
(fibration_iff _).2 ((fibrations C).comp_mem _ _ hf.mem hg.mem)
instance [CategoryWithWeakEquivalences C] [(weakEquivalences C).IsStableUnderComposition]
[hf : WeakEquivalence f] [hg : WeakEquivalence g] : WeakEquivalence (f ≫ g) :=
(weakEquivalence_iff _).2 ((weakEquivalences C).comp_mem _ _ hf.mem hg.mem)
end IsStableUnderComposition
variable [CategoryWithWeakEquivalences C]
section HasTwoOutOfThreeProperty
variable [(weakEquivalences C).HasTwoOutOfThreeProperty]
{C} {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z)
lemma weakEquivalence_of_postcomp
[hg : WeakEquivalence g] [hfg : WeakEquivalence (f ≫ g)] :
WeakEquivalence f := by
rw [weakEquivalence_iff] at hg hfg ⊢
exact of_postcomp _ _ _ hg hfg
lemma weakEquivalence_of_precomp
[hf : WeakEquivalence f] [hfg : WeakEquivalence (f ≫ g)] :
WeakEquivalence g := by
rw [weakEquivalence_iff] at hf hfg ⊢
exact of_precomp _ _ _ hf hfg
lemma weakEquivalence_postcomp_iff [WeakEquivalence g] :
WeakEquivalence (f ≫ g) ↔ WeakEquivalence f :=
⟨fun _ ↦ weakEquivalence_of_postcomp f g, fun _ ↦ inferInstance⟩
lemma weakEquivalence_precomp_iff [WeakEquivalence f] :
WeakEquivalence (f ≫ g) ↔ WeakEquivalence g :=
⟨fun _ ↦ weakEquivalence_of_precomp f g, fun _ ↦ inferInstance⟩
variable {f g} {fg : X ⟶ Z}
lemma weakEquivalence_of_postcomp_of_fac (fac : f ≫ g = fg)
[WeakEquivalence g] [hfg : WeakEquivalence fg] :
WeakEquivalence f := by
subst fac
exact weakEquivalence_of_postcomp f g
lemma weakEquivalence_of_precomp_of_fac (fac : f ≫ g = fg)
[WeakEquivalence f] [WeakEquivalence fg] :
WeakEquivalence g := by
subst fac
exact weakEquivalence_of_precomp f g
end HasTwoOutOfThreeProperty
variable [CategoryWithCofibrations C] [CategoryWithFibrations C]
section
variable [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)]
lemma fibrations_llp :
(fibrations C).llp = trivialCofibrations C :=
llp_eq_of_wfs _ _
lemma trivialCofibrations_rlp :
(trivialCofibrations C).rlp = fibrations C :=
rlp_eq_of_wfs _ _
instance : (trivialCofibrations C).IsStableUnderCobaseChange := by
rw [← fibrations_llp]
infer_instance
instance : (fibrations C).IsStableUnderBaseChange := by
rw [← trivialCofibrations_rlp]
infer_instance
instance : (trivialCofibrations C).IsMultiplicative := by
rw [← fibrations_llp]
infer_instance
instance : (fibrations C).IsMultiplicative := by
rw [← trivialCofibrations_rlp]
infer_instance
variable (J : Type w)
instance isStableUnderCoproductsOfShape_trivialCofibrations :
(trivialCofibrations C).IsStableUnderCoproductsOfShape J := by
rw [← fibrations_llp]
apply MorphismProperty.llp_isStableUnderCoproductsOfShape
instance isStableUnderProductsOfShape_fibrations :
(fibrations C).IsStableUnderProductsOfShape J := by
rw [← trivialCofibrations_rlp]
apply MorphismProperty.rlp_isStableUnderProductsOfShape
end
section
variable [IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C)]
lemma trivialFibrations_llp :
(trivialFibrations C).llp = cofibrations C :=
llp_eq_of_wfs _ _
lemma cofibrations_rlp :
(cofibrations C).rlp = trivialFibrations C :=
rlp_eq_of_wfs _ _
instance : (cofibrations C).IsStableUnderCobaseChange := by
rw [← trivialFibrations_llp]
infer_instance
instance : (trivialFibrations C).IsStableUnderBaseChange := by
rw [← cofibrations_rlp]
infer_instance
instance : (cofibrations C).IsMultiplicative := by
rw [← trivialFibrations_llp]
infer_instance
instance : (trivialFibrations C).IsMultiplicative := by
rw [← cofibrations_rlp]
infer_instance
variable (J : Type w)
instance isStableUnderCoproductsOfShape_cofibrations :
(cofibrations C).IsStableUnderCoproductsOfShape J := by
rw [← trivialFibrations_llp]
apply MorphismProperty.llp_isStableUnderCoproductsOfShape
instance isStableUnderProductsOfShape_trivialFibrations :
(trivialFibrations C).IsStableUnderProductsOfShape J := by
rw [← cofibrations_rlp]
apply MorphismProperty.rlp_isStableUnderProductsOfShape
end
section Pullbacks
section
variable {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g]
instance [(cofibrations C).IsStableUnderCobaseChange] [hg : Cofibration g] :
Cofibration (pushout.inl f g) := by
rw [cofibration_iff] at hg ⊢
exact MorphismProperty.of_isPushout (IsPushout.of_hasPushout f g) hg
instance [(cofibrations C).IsStableUnderCobaseChange] [hf : Cofibration f] :
Cofibration (pushout.inr f g) := by
rw [cofibration_iff] at hf ⊢
exact MorphismProperty.of_isPushout (IsPushout.of_hasPushout f g).flip hf
instance [(trivialCofibrations C).IsStableUnderCobaseChange]
[Cofibration g] [WeakEquivalence g] : WeakEquivalence (pushout.inl f g) := by
rw [weakEquivalence_iff]
exact (MorphismProperty.of_isPushout (IsPushout.of_hasPushout f g)
(mem_trivialCofibrations g)).2
instance [(trivialCofibrations C).IsStableUnderCobaseChange]
[Cofibration f] [WeakEquivalence f] : WeakEquivalence (pushout.inr f g) := by
rw [weakEquivalence_iff]
exact (MorphismProperty.of_isPushout (IsPushout.of_hasPushout f g).flip
(mem_trivialCofibrations f)).2
end
section
variable {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g]
instance [(fibrations C).IsStableUnderBaseChange]
[hf : Fibration f] : Fibration (pullback.snd f g) := by
rw [fibration_iff] at hf ⊢
exact MorphismProperty.of_isPullback (IsPullback.of_hasPullback f g) hf
instance [(fibrations C).IsStableUnderBaseChange]
[hg : Fibration g] : Fibration (pullback.fst f g) := by
rw [fibration_iff] at hg ⊢
exact MorphismProperty.of_isPullback (IsPullback.of_hasPullback f g).flip hg
instance [(trivialFibrations C).IsStableUnderBaseChange]
[Fibration f] [WeakEquivalence f] : WeakEquivalence (pullback.snd f g) := by
rw [weakEquivalence_iff]
exact (MorphismProperty.of_isPullback (IsPullback.of_hasPullback f g)
(mem_trivialFibrations f)).2
instance [(trivialFibrations C).IsStableUnderBaseChange]
[Fibration g] [WeakEquivalence g] : WeakEquivalence (pullback.fst f g) := by
rw [weakEquivalence_iff]
exact (MorphismProperty.of_isPullback (IsPullback.of_hasPullback f g).flip
(mem_trivialFibrations g)).2
end
end Pullbacks
section Products
variable (J : Type w) {C J} {X Y : J → C} (f : ∀ i, X i ⟶ Y i)
section
variable [HasCoproduct X] [HasCoproduct Y] [h : ∀ i, Cofibration (f i)]
instance [IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C)] :
Cofibration (Limits.Sigma.map f) := by
simp only [cofibration_iff] at h ⊢
exact MorphismProperty.colimMap _ (fun ⟨i⟩ ↦ h i)
instance [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)]
[∀ i, WeakEquivalence (f i)] :
WeakEquivalence (Limits.Sigma.map f) := by
rw [weakEquivalence_iff]
exact (MorphismProperty.colimMap (W := (trivialCofibrations C)) _
(fun ⟨i⟩ ↦ mem_trivialCofibrations (f i))).2
end
section
variable [HasProduct X] [HasProduct Y] [h : ∀ i, Fibration (f i)]
instance [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)] :
Fibration (Limits.Pi.map f) := by
simp only [fibration_iff] at h ⊢
exact MorphismProperty.limMap _ (fun ⟨i⟩ ↦ h i)
instance [IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C)]
[∀ i, WeakEquivalence (f i)] :
WeakEquivalence (Limits.Pi.map f) := by
rw [weakEquivalence_iff]
exact (MorphismProperty.limMap (W := (trivialFibrations C)) _
(fun ⟨i⟩ ↦ mem_trivialFibrations (f i))).2
end
end Products
section BinaryProducts
variable {X₁ X₂ Y₁ Y₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂)
instance [IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C)]
[h₁ : Cofibration f₁] [h₂ : Cofibration f₂] [HasBinaryCoproduct X₁ X₂]
[HasBinaryCoproduct Y₁ Y₂] : Cofibration (coprod.map f₁ f₂) := by
rw [cofibration_iff] at h₁ h₂ ⊢
apply MorphismProperty.colimMap
rintro (_ | _) <;> assumption
instance [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)]
[h₁ : Fibration f₁] [h₂ : Fibration f₂] [HasBinaryProduct X₁ X₂]
[HasBinaryProduct Y₁ Y₂] : Fibration (prod.map f₁ f₂) := by
rw [fibration_iff] at h₁ h₂ ⊢
apply MorphismProperty.limMap
rintro (_ | _) <;> assumption
end BinaryProducts
section IsIso
variable {X Y : C} (f : X ⟶ Y)
instance [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)] [IsIso f] :
Cofibration f := by
have := (fibrations C).llp_of_isIso f
rw [fibrations_llp] at this
simpa only [cofibration_iff] using this.1
instance [IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C)] [IsIso f] :
Fibration f := by
have := (cofibrations C).rlp_of_isIso f
rw [cofibrations_rlp] at this
simpa only [fibration_iff] using this.1
instance [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)]
[(weakEquivalences C).IsStableUnderRetracts] [IsIso f] :
WeakEquivalence f := by
have h := MorphismProperty.factorizationData (trivialCofibrations C) (fibrations C) f
rw [weakEquivalence_iff]
exact MorphismProperty.of_retract (RetractArrow.ofLeftLiftingProperty h.fac) h.hi.2
end IsIso
instance [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)]
[(weakEquivalences C).IsStableUnderRetracts]
[(weakEquivalences C).IsStableUnderComposition] :
(weakEquivalences C).IsMultiplicative where
id_mem _ := by
rw [← weakEquivalence_iff]
infer_instance
instance [IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)]
[(weakEquivalences C).IsStableUnderRetracts]
[(weakEquivalences C).IsStableUnderComposition] :
(weakEquivalences C).RespectsIso :=
MorphismProperty.respectsIso_of_isStableUnderComposition (fun _ _ _ (_ : IsIso _) ↦ by
rw [← weakEquivalence_iff]
infer_instance)
instance [(weakEquivalences C).ContainsIdentities] (X : C) :
WeakEquivalence (𝟙 X) := by
rw [weakEquivalence_iff]
apply id_mem
section MapFactorizationData
variable {X Y : C} (f : X ⟶ Y)
section
variable (h : MapFactorizationData (cofibrations C) (trivialFibrations C) f)
instance : Cofibration h.i := by
simpa only [cofibration_iff] using h.hi
instance : Fibration h.p := by
simpa only [fibration_iff] using h.hp.1
instance : WeakEquivalence h.p := by
simpa only [weakEquivalence_iff] using h.hp.2
end
section
variable (h : MapFactorizationData (trivialCofibrations C) (fibrations C) f)
instance : Cofibration h.i := by
simpa only [cofibration_iff] using h.hi.1
instance : WeakEquivalence h.i := by
simpa only [weakEquivalence_iff] using h.hi.2
instance : Fibration h.p := by
simpa only [fibration_iff] using h.hp
end
end MapFactorizationData
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/Opposite.lean | import Mathlib.AlgebraicTopology.ModelCategory.Basic
/-!
# The opposite of a model category structure
-/
universe v u
open CategoryTheory
namespace HomotopicalAlgebra
variable (C : Type u) [Category.{v} C] [ModelCategory C]
instance [(weakEquivalences C).HasTwoOutOfThreeProperty] :
(weakEquivalences Cᵒᵖ).HasTwoOutOfThreeProperty := by
rw [weakEquivalences_op]
infer_instance
instance [(weakEquivalences C).IsStableUnderRetracts] :
(weakEquivalences Cᵒᵖ).IsStableUnderRetracts := by
rw [weakEquivalences_op]
infer_instance
instance [(cofibrations C).IsStableUnderRetracts] :
(fibrations Cᵒᵖ).IsStableUnderRetracts := by
rw [fibrations_op]
infer_instance
instance [(fibrations C).IsStableUnderRetracts] :
(cofibrations Cᵒᵖ).IsStableUnderRetracts := by
rw [cofibrations_op]
infer_instance
instance [(trivialCofibrations C).HasFactorization (fibrations C)] :
(cofibrations Cᵒᵖ).HasFactorization (trivialFibrations Cᵒᵖ) := by
rw [cofibrations_op, trivialFibrations_op]
infer_instance
instance [(cofibrations C).HasFactorization (trivialFibrations C)] :
(trivialCofibrations Cᵒᵖ).HasFactorization (fibrations Cᵒᵖ) := by
rw [trivialCofibrations_op, fibrations_op, ]
infer_instance
instance : ModelCategory Cᵒᵖ where
cm4a i p _ _ _ := (HasLiftingProperty.iff_unop i p).2 inferInstance
cm4b i p _ _ _ := (HasLiftingProperty.iff_unop i p).2 inferInstance
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/PathObject.lean | import Mathlib.AlgebraicTopology.ModelCategory.Basic
import Mathlib.AlgebraicTopology.ModelCategory.IsCofibrant
/-!
# Path objects
We introduce a notion of path object for an object `A : C` in a model category.
It consists of an object `P`, a weak equivalence `ι : A ⟶ P` equipped with two retractions
`p₀` and `p₁`. This notion shall be important in the definition of "right homotopies"
in model categories.
This file dualizes the definitions in the file
`Mathlib/AlgebraicTopology/ModelCategory/Cylinder.lean`.
## Implementation notes
The most important definition in this file is `PathObject A`. This structure
extends another structure `PrepathObject A` (which does not assume that `C`
has a notion of weak equivalences, which can be interesting in situations
where we have not yet obtained the model category axioms).
The good properties of path objects are stated as typeclasses `PathObject.IsGood`
and `PathObject.IsVeryGood`.
The existence of very good path objects in model categories is stated
in the lemma `PathObject.exists_very_good`.
## References
* [Daniel G. Quillen, Homotopical algebra][Quillen1967]
* https://ncatlab.org/nlab/show/path+space+object
-/
universe v u
open CategoryTheory Category Limits
namespace HomotopicalAlgebra
variable {C : Type u} [Category.{v} C]
/-- A pre-path object for `A : C` is the data of a morphism
`ι : A ⟶ P` equipped with two retractions. -/
structure PrepathObject (A : C) where
/-- the underlying object of a (pre)path object -/
P : C
/-- the first "projection" from the (pre)path object -/
p₀ : P ⟶ A
/-- the second "projection" from the (pre)path object -/
p₁ : P ⟶ A
/-- the diagonal of the (pre)path object -/
ι : A ⟶ P
ι_p₀ : ι ≫ p₀ = 𝟙 A := by aesop_cat
ι_p₁ : ι ≫ p₁ = 𝟙 A := by aesop_cat
namespace PrepathObject
attribute [reassoc (attr := simp)] ι_p₀ ι_p₁
variable {A : C} (P : PrepathObject A)
/-- The pre-path object obtained by switching the two projections. -/
@[simps]
def symm : PrepathObject A where
P := P.P
p₀ := P.p₁
p₁ := P.p₀
ι := P.ι
/-- The gluing of two pre-path objects. -/
@[simps]
noncomputable def trans (P' : PrepathObject A) [HasPullback P.p₁ P'.p₀] :
PrepathObject A where
P := pullback P.p₁ P'.p₀
p₀ := pullback.fst _ _ ≫ P.p₀
p₁ := pullback.snd _ _ ≫ P'.p₁
ι := pullback.lift P.ι P'.ι (by simp)
section
variable [HasBinaryProduct A A]
/-- The map from `P.P` to the product of two copies of `A`, when `P` is
a pre-path object for `A`. `P` shall be a *good* path object
when this morphism is a fibration. -/
noncomputable def p : P.P ⟶ A ⨯ A := prod.lift P.p₀ P.p₁
@[reassoc (attr := simp)]
lemma p_fst : P.p ≫ prod.fst = P.p₀ := by simp [p]
@[reassoc (attr := simp)]
lemma p_snd : P.p ≫ prod.snd = P.p₁ := by simp [p]
end
@[simp, reassoc]
lemma symm_p [HasBinaryProducts C] :
P.symm.p = P.p ≫ (prod.braiding A A).hom := by aesop_cat
end PrepathObject
/-- In a category with weak equivalences, a path object is the
data of a weak equivalence `ι : A ⟶ P` equipped with two retractions. -/
structure PathObject [CategoryWithWeakEquivalences C] (A : C) extends PrepathObject A where
weakEquivalence_ι : WeakEquivalence ι := by infer_instance
namespace PathObject
attribute [instance] weakEquivalence_ι
section
variable {A : C} [CategoryWithWeakEquivalences C] (P : PathObject A)
/-- The path object obtained by switching the two projections. -/
@[simps!]
def symm : PathObject A where
__ := P.toPrepathObject.symm
weakEquivalence_ι := by dsimp; infer_instance
@[simp, reassoc]
lemma symm_p [HasBinaryProducts C] :
P.symm.p = P.p ≫ (prod.braiding A A).hom :=
P.toPrepathObject.symm_p
section
variable [(weakEquivalences C).HasTwoOutOfThreeProperty]
[(weakEquivalences C).ContainsIdentities]
instance : WeakEquivalence P.p₀ :=
weakEquivalence_of_precomp_of_fac P.ι_p₀
instance : WeakEquivalence P.p₁ :=
weakEquivalence_of_precomp_of_fac P.ι_p₁
end
/-- A path object `P` is good if the morphism
`P.p : P.P ⟶ A ⨯ A` is a fibration. -/
class IsGood [HasBinaryProduct A A] [CategoryWithFibrations C] : Prop where
fibration_p : Fibration P.p := by infer_instance
/-- A good path object `P` is very good if `P.ι` is a (trivial) cofibration. -/
class IsVeryGood [HasBinaryProduct A A] [CategoryWithFibrations C]
[CategoryWithCofibrations C] : Prop extends P.IsGood where
cofibration_ι : Cofibration P.ι := by infer_instance
attribute [instance] IsGood.fibration_p IsVeryGood.cofibration_ι
section
variable [HasBinaryProduct A A] [CategoryWithFibrations C]
[HasTerminal C] [(fibrations C).IsStableUnderComposition]
[(fibrations C).IsStableUnderBaseChange]
[IsFibrant A] [P.IsGood]
instance : Fibration P.p₀ := by
rw [← P.p_fst]
infer_instance
instance : Fibration P.p₁ := by
rw [← P.p_snd]
infer_instance
instance : IsFibrant P.P :=
isFibrant_of_fibration P.p₀
end
instance [HasBinaryProducts C] [CategoryWithFibrations C] [P.IsGood]
[(fibrations C).RespectsIso] : P.symm.IsGood where
fibration_p := by
have hp : fibrations C P.p := by rw [← fibration_iff]; infer_instance
rw [P.symm_p, fibration_iff]
refine ((fibrations C).arrow_mk_iso_iff ?_).2 hp
exact Arrow.isoMk (Iso.refl _) (prod.braiding A A)
section
variable [CategoryWithFibrations C] [CategoryWithCofibrations C]
[(cofibrations C).IsStableUnderComposition]
instance [HasBinaryProduct A A] [HasInitial C] [IsCofibrant A] [P.IsVeryGood] : IsCofibrant P.P :=
isCofibrant_of_cofibration P.ι
instance [(fibrations C).RespectsIso] [HasBinaryProducts C] [P.IsVeryGood] :
P.symm.IsVeryGood where
cofibration_ι := by dsimp; infer_instance
end
end
variable [ModelCategory C] {A : C} (P : PathObject A)
section
variable (h : MorphismProperty.MapFactorizationData
(trivialCofibrations C) (fibrations C) (diag A))
/-- A path object for `A` can be obtained from a factorization of the obvious
map `A ⟶ A ⨯ A` as a trivial cofibration followed by a fibration. -/
@[simps]
noncomputable def ofFactorizationData : PathObject A where
P := h.Z
p₀ := h.p ≫ prod.fst
p₁ := h.p ≫ prod.snd
ι := h.i
@[simp]
lemma ofFactorizationData_p : (ofFactorizationData h).p = h.p := by aesop_cat
instance : (ofFactorizationData h).IsVeryGood where
fibration_p := by simpa using inferInstanceAs (Fibration h.p)
cofibration_ι := by dsimp; infer_instance
instance [HasInitial C] [IsCofibrant A] [(cofibrations C).IsStableUnderComposition] :
IsCofibrant (ofFactorizationData h).P :=
isCofibrant_of_cofibration (ofFactorizationData h).ι
end
variable (A) in
lemma exists_very_good :
∃ (P : PathObject A), P.IsVeryGood :=
⟨ofFactorizationData (MorphismProperty.factorizationData _ _ _),
inferInstance⟩
instance : Nonempty (PathObject A) := ⟨(exists_very_good A).choose⟩
/-- The gluing of two good path objects. -/
@[simps!]
noncomputable def trans [IsFibrant A] (P P' : PathObject A) [P'.IsGood] :
PathObject A where
__ := P.toPrepathObject.trans P'.toPrepathObject
weakEquivalence_ι := by
have : WeakEquivalence (pullback.lift P.ι P'.ι (by simp) ≫
pullback.fst P.p₁ P'.p₀ ≫ P.p₀) := by
rw [pullback.lift_fst_assoc, PrepathObject.ι_p₀]
infer_instance
dsimp
apply weakEquivalence_of_postcomp _ (pullback.fst P.p₁ P'.p₀ ≫ P.p₀)
instance [IsFibrant A] (P P' : PathObject A) [P.IsGood] [P'.IsGood] :
(P.trans P').IsGood where
fibration_p := by
let ψ : (P.trans P').P ⟶ P.P ⨯ A := prod.lift (pullback.fst _ _) (pullback.snd _ _ ≫ P'.p₁)
rw [show (P.trans P').p = ψ ≫ prod.map P.p₀ (𝟙 A) by simp [PrepathObject.p, ψ]]
have fac : ψ ≫ prod.map P.p₁ (𝟙 A) = pullback.snd _ _ ≫ P'.p := by
ext
· simp [ψ, pullback.condition]
· simp [ψ]
have sq : IsPullback (ψ ≫ prod.fst) (pullback.snd P.p₁ P'.p₀) P.p₁ (P'.p ≫ prod.fst) := by
simpa [ψ] using IsPullback.of_hasPullback P.p₁ P'.p₀
have : Fibration ψ := by
rw [fibration_iff]
exact (fibrations C).of_isPullback
(IsPullback.of_right sq fac (IsPullback.of_prod_fst_with_id P.p₁ A)).flip
(by rw [← fibration_iff]; infer_instance)
infer_instance
end PathObject
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/RightHomotopy.lean | import Mathlib.AlgebraicTopology.ModelCategory.PathObject
import Mathlib.CategoryTheory.Localization.Quotient
/-!
# Right homotopies in model categories
We introduce the types `PrepathObject.RightHomotopy` and `PathObject.RightHomotopy`
of homotopies between morphisms `X ⟶ Y` relative to a (pre)path object of `Y`.
Given two morphisms `f` and `g`, we introduce the relation `RightHomotopyRel f g`
asserting the existence of a path object `P` and
a right homotopy `P.RightHomotopy f g`, and we define the quotient
type `RightHomotopyClass X Y`. We show that if `Y` is a fibrant
object in a model category, then `RightHomotopyRel` is an equivalence
relation on `X ⟶ Y`.
(This file dualizes the definitions in `Mathlib/AlgebraicTopology/ModelCategory/LeftHomotopy.lean`.)
## References
* [Daniel G. Quillen, Homotopical algebra, section I.1][Quillen1967]
-/
universe v u
open CategoryTheory Limits
namespace HomotopicalAlgebra
variable {C : Type u} [Category.{v} C]
namespace PrepathObject
variable {Y : C} (P : PrepathObject Y) {X : C}
/-- Given a pre-path object `P` for `Y`, two maps `f` and `g` in `X ⟶ Y` are
homotopic relative to `P` when there is a morphism `h : X ⟶ P.P`
such that `h ≫ P.p₀ = f` and `h ≫ P.p₁ = g`. -/
structure RightHomotopy (f g : X ⟶ Y) where
/-- a morphism from the source to the pre-path object -/
h : X ⟶ P.P
h₀ : h ≫ P.p₀ = f := by cat_disch
h₁ : h ≫ P.p₁ = g := by cat_disch
namespace RightHomotopy
attribute [reassoc (attr := simp)] h₀ h₁
/-- `f : X ⟶ Y` is right homotopic to itself relative to any pre-path object. -/
@[simps]
def refl (f : X ⟶ Y) : P.RightHomotopy f f where
h := f ≫ P.ι
variable {P}
/-- If `f` and `g` are homotopic relative to a pre-path object `P`, then `g` and `f`
are homotopic relative to `P.symm` -/
@[simps]
def symm {f g : X ⟶ Y} (h : P.RightHomotopy f g) : P.symm.RightHomotopy g f where
h := h.h
/-- If `f₀` is homotopic to `f₁` relative to a pre-path object `P`,
and `f₁` is homotopic to `f₂` relative to `P'`, then
`f₀` is homotopic to `f₂` relative to `P.trans P'`. -/
@[simps]
noncomputable def trans {f₀ f₁ f₂ : X ⟶ Y}
(h : P.RightHomotopy f₀ f₁) {P' : PrepathObject Y}
(h' : P'.RightHomotopy f₁ f₂) [HasPullback P.p₁ P'.p₀] :
(P.trans P').RightHomotopy f₀ f₂ where
h := pullback.lift h.h h'.h (by simp)
/-- Right homotopies are compatible with precomposition. -/
@[simps]
def precomp {f g : X ⟶ Y} (h : P.RightHomotopy f g) {Z : C} (i : Z ⟶ X) :
P.RightHomotopy (i ≫ f) (i ≫ g) where
h := i ≫ h.h
end RightHomotopy
end PrepathObject
namespace PathObject
variable {X Y : C}
/-- Given a path object `P` for `X`, two maps `f` and `g` in `X ⟶ Y`
are homotopic relative to `P` when there is a morphism `h : P.I ⟶ Y`
such that `P.i₀ ≫ h = f` and `P.i₁ ≫ h = g`. -/
abbrev RightHomotopy [CategoryWithWeakEquivalences C] (P : PathObject Y) (f g : X ⟶ Y) : Type v :=
P.toPrepathObject.RightHomotopy f g
namespace RightHomotopy
section
variable [CategoryWithWeakEquivalences C] (P : PathObject Y)
/-- `f : X ⟶ Y` is right homotopic to itself relative to any path object. -/
abbrev refl (f : X ⟶ Y) : P.RightHomotopy f f := PrepathObject.RightHomotopy.refl _ f
variable {P} in
/-- If `f` and `g` are homotopic relative to a path object `P`, then `g` and `f`
are homotopic relative to `P.symm`. -/
abbrev symm {f g : X ⟶ Y} (h : P.RightHomotopy f g) : P.symm.RightHomotopy g f :=
PrepathObject.RightHomotopy.symm h
variable {P} in
/-- Right homotopies are compatible with precomposition. -/
abbrev precomp {f g : X ⟶ Y} (h : P.RightHomotopy f g) {Z : C} (i : Z ⟶ X) :
P.RightHomotopy (i ≫ f) (i ≫ g) :=
PrepathObject.RightHomotopy.precomp h i
lemma weakEquivalence_iff [(weakEquivalences C).HasTwoOutOfThreeProperty]
[(weakEquivalences C).ContainsIdentities]
{f₀ f₁ : X ⟶ Y} (h : P.RightHomotopy f₀ f₁) :
WeakEquivalence f₀ ↔ WeakEquivalence f₁ := by
revert P f₀ f₁
suffices ∀ (P : PathObject Y) {f₀ f₁ : X ⟶ Y} (h : P.RightHomotopy f₀ f₁),
WeakEquivalence f₀ → WeakEquivalence f₁
from fun _ _ _ h ↦ ⟨this _ h, this _ h.symm⟩
intro P f₀ f₁ h h₀
have := weakEquivalence_of_postcomp_of_fac h.h₀
rw [← h.h₁]
infer_instance
end
section
variable [ModelCategory C] {P : PathObject Y}
/-- If `f₀ : X ⟶ Y` is homotopic to `f₁` relative to a path object `P`,
and `f₁` is homotopic to `f₂` relative to a good path object `P'`,
then `f₀` is homotopic to `f₂` relative to the path object `P.trans P'`
when `Y` is fibrant. -/
noncomputable abbrev trans [IsFibrant Y] {f₀ f₁ f₂ : X ⟶ Y}
(h : P.RightHomotopy f₀ f₁) {P' : PathObject Y} [P'.IsGood]
(h' : P'.RightHomotopy f₁ f₂) [HasPullback P.p₁ P'.p₀] :
(P.trans P').RightHomotopy f₀ f₂ :=
PrepathObject.RightHomotopy.trans h h'
lemma exists_good_pathObject {f g : X ⟶ Y} (h : P.RightHomotopy f g) :
∃ (P' : PathObject Y), P'.IsGood ∧ Nonempty (P'.RightHomotopy f g) := by
let d := MorphismProperty.factorizationData (trivialCofibrations C) (fibrations C) P.p
exact
⟨{ P := d.Z
p₀ := d.p ≫ prod.fst
p₁ := d.p ≫ prod.snd
ι := P.ι ≫ d.i }, ⟨by
rw [fibration_iff]
convert d.hp
aesop⟩, ⟨{ h := h.h ≫ d.i }⟩⟩
/-- The homotopy extension theorem: if `p : A ⟶ X` is a cofibration,
`l₀ : X ⟶ B` is a morphism, if there is a right homotopy `h` between
the composition `f₀ := i ≫ l₀` and a morphism `f₁ : A ⟶ B`,
then there exists a morphism `l₁ : X ⟶ B` and a right homotopy `h'` from
`l₀` to `l₁` which is compatible with `h` (in particular, `i ≫ l₁ = f₁`). -/
lemma homotopy_extension {A B X : C} {P : PathObject B} {f₀ f₁ : A ⟶ B}
[IsFibrant B] [P.IsGood]
(h : P.RightHomotopy f₀ f₁) (i : A ⟶ X) [Cofibration i]
(l₀ : X ⟶ B) (hl₀ : i ≫ l₀ = f₀ := by cat_disch) :
∃ (l₁ : X ⟶ B) (h' : P.RightHomotopy l₀ l₁), i ≫ h'.h = h.h :=
have sq : CommSq h.h i P.p₀ l₀ := { }
⟨sq.lift ≫ P.p₁, { h := sq.lift }, by simp⟩
end
end RightHomotopy
end PathObject
/-- The right homotopy relation on morphisms in a category with weak equivalences. -/
def RightHomotopyRel [CategoryWithWeakEquivalences C] : HomRel C :=
fun _ Y f g ↦ ∃ (P : PathObject Y), Nonempty (P.RightHomotopy f g)
lemma PathObject.RightHomotopy.rightHomotopyRel [CategoryWithWeakEquivalences C]
{X Y : C} {f g : X ⟶ Y}
{P : PathObject Y} (h : P.RightHomotopy f g) :
RightHomotopyRel f g :=
⟨_, ⟨h⟩⟩
namespace RightHomotopyRel
variable (C) in
lemma factorsThroughLocalization [CategoryWithWeakEquivalences C] :
RightHomotopyRel.FactorsThroughLocalization (weakEquivalences C) := by
rintro X Y f g ⟨P, ⟨h⟩⟩
let L := (weakEquivalences C).Q
rw [areEqualizedByLocalization_iff L]
suffices L.map P.p₀ = L.map P.p₁ by
simp only [← h.h₀, ← h.h₁, L.map_comp, this]
have := Localization.inverts L (weakEquivalences C) P.ι (by
rw [← weakEquivalence_iff]
infer_instance)
simp [← cancel_epi (L.map P.ι), ← L.map_comp]
variable {X Y : C}
lemma refl [ModelCategory C] (f : X ⟶ Y) : RightHomotopyRel f f :=
⟨Classical.arbitrary _, ⟨PathObject.RightHomotopy.refl _ _⟩⟩
lemma precomp [CategoryWithWeakEquivalences C]
{f g : X ⟶ Y} (h : RightHomotopyRel f g) {Z : C} (i : Z ⟶ X) :
RightHomotopyRel (i ≫ f) (i ≫ g) := by
obtain ⟨P, ⟨h⟩⟩ := h
exact (h.precomp i).rightHomotopyRel
lemma exists_good_pathObject [ModelCategory C] {f g : X ⟶ Y} (h : RightHomotopyRel f g) :
∃ (P : PathObject Y), P.IsGood ∧ Nonempty (P.RightHomotopy f g) := by
obtain ⟨P, ⟨h⟩⟩ := h
exact h.exists_good_pathObject
lemma exists_very_good_pathObject [ModelCategory C] {f g : X ⟶ Y} [IsCofibrant X]
(h : RightHomotopyRel f g) :
∃ (P : PathObject Y), P.IsVeryGood ∧ Nonempty (P.RightHomotopy f g) := by
obtain ⟨P, _, ⟨h⟩⟩ := h.exists_good_pathObject
let fac := MorphismProperty.factorizationData (cofibrations C) (trivialFibrations C) P.ι
let P' : PathObject Y :=
{ P := fac.Z
p₀ := fac.p ≫ P.p₀
p₁ := fac.p ≫ P.p₁
ι := fac.i
weakEquivalence_ι := weakEquivalence_of_postcomp_of_fac fac.fac }
have : Fibration P'.p := by
rw [show P'.p = fac.p ≫ P.p by cat_disch]
infer_instance
have sq : CommSq (initial.to _) (initial.to _) fac.p h.h := { }
exact ⟨P', { }, ⟨{ h := sq.lift }⟩⟩
lemma symm [CategoryWithWeakEquivalences C]
{f g : X ⟶ Y} (h : RightHomotopyRel f g) : RightHomotopyRel g f := by
obtain ⟨P, ⟨h⟩⟩ := h
exact h.symm.rightHomotopyRel
lemma trans [ModelCategory C]
{f₀ f₁ f₂ : X ⟶ Y} [IsFibrant Y] (h : RightHomotopyRel f₀ f₁)
(h' : RightHomotopyRel f₁ f₂) : RightHomotopyRel f₀ f₂ := by
obtain ⟨P, ⟨h⟩⟩ := h
obtain ⟨P', _, ⟨h'⟩⟩ := h'.exists_good_pathObject
exact (h.trans h').rightHomotopyRel
lemma equivalence [ModelCategory C] (X Y : C) [IsFibrant Y] :
_root_.Equivalence (RightHomotopyRel (X := X) (Y := Y)) where
refl := .refl
symm h := h.symm
trans h h' := h.trans h'
lemma postcomp [ModelCategory C] {f g : X ⟶ Y} [IsCofibrant X] (h : RightHomotopyRel f g)
{Z : C} (p : Y ⟶ Z) : RightHomotopyRel (f ≫ p) (g ≫ p) := by
obtain ⟨P, _, ⟨h⟩⟩ := h.exists_very_good_pathObject
obtain ⟨Q, _⟩ := PathObject.exists_very_good Z
have sq : CommSq (p ≫ Q.ι) P.ι Q.p (prod.lift (P.p₀ ≫ p) (P.p₁ ≫ p)) := { }
exact ⟨Q,
⟨{ h := h.h ≫ sq.lift
h₀ := by
have := sq.fac_right =≫ prod.fst
simp only [Category.assoc, prod.lift_fst, Q.p_fst] at this
simp [this]
h₁ := by
have := sq.fac_right =≫ prod.snd
simp only [Category.assoc, prod.lift_snd, Q.p_snd] at this
simp [this]
}⟩⟩
end RightHomotopyRel
variable (X Y Z : C)
/-- In a category with weak equivalences, this is the quotient of the type
of morphisms `X ⟶ Y` by the equivalence relation generated by right homotopies. -/
def RightHomotopyClass [CategoryWithWeakEquivalences C] :=
_root_.Quot (RightHomotopyRel (X := X) (Y := Y))
variable {X Y Z}
/-- Given `f : X ⟶ Y`, this is the class of `f` in the quotient `RightHomotopyClass X Y`. -/
def RightHomotopyClass.mk [CategoryWithWeakEquivalences C] :
(X ⟶ Y) → RightHomotopyClass X Y := Quot.mk _
lemma RightHomotopyClass.mk_surjective [CategoryWithWeakEquivalences C] :
Function.Surjective (mk : (X ⟶ Y) → _) :=
Quot.mk_surjective
namespace RightHomotopyClass
lemma sound [CategoryWithWeakEquivalences C] {f g : X ⟶ Y} (h : RightHomotopyRel f g) :
mk f = mk g := Quot.sound h
/-- The precomposition map `RightHomotopyClass Y Z → (X ⟶ Y) → RightHomotopyClass X Z`. -/
def precomp [CategoryWithWeakEquivalences C] :
RightHomotopyClass Y Z → (X ⟶ Y) → RightHomotopyClass X Z :=
fun g f ↦ Quot.lift (fun g ↦ mk (f ≫ g)) (fun _ _ h ↦ sound (h.precomp f)) g
@[simp]
lemma precomp_mk [CategoryWithWeakEquivalences C] (f : X ⟶ Y) (g : Y ⟶ Z) :
(mk g).precomp f = mk (f ≫ g) := rfl
lemma mk_eq_mk_iff [ModelCategory C] [IsFibrant Y] (f g : X ⟶ Y) :
mk f = mk g ↔ RightHomotopyRel f g := by
rw [← (RightHomotopyRel.equivalence X Y).eqvGen_iff]
exact Quot.eq
end RightHomotopyClass
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/Basic.lean | import Mathlib.CategoryTheory.Limits.Shapes.FiniteLimits
import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts
import Mathlib.CategoryTheory.MorphismProperty.Composition
import Mathlib.CategoryTheory.MorphismProperty.Factorization
import Mathlib.CategoryTheory.MorphismProperty.LiftingProperty
import Mathlib.CategoryTheory.MorphismProperty.WeakFactorizationSystem
import Mathlib.AlgebraicTopology.ModelCategory.Instances
/-!
# Model categories
We introduce a typeclass `ModelCategory C` expressing that `C` is equipped with
classes of morphisms named "fibrations", "cofibrations" and "weak equivalences"
which satisfy the axioms of (closed) model categories as they appear for example
in *Simplicial Homotopy Theory* by Goerss and Jardine. We also provide an
alternate constructor `ModelCategory.mk'` which uses a formulation of the axioms
using weak factorization systems.
As a given category `C` may have several model category structures, it is advisable
to define only local instances of `ModelCategory`, or to set these instances on type synonyms.
## References
* [Daniel G. Quillen, Homotopical algebra][Quillen1967]
* [Paul G. Goerss, John F. Jardine, Simplicial Homotopy Theory][goerss-jardine-2009]
* https://ncatlab.org/nlab/show/model+category
-/
universe w v u
namespace HomotopicalAlgebra
open CategoryTheory Limits
variable (C : Type u) [Category.{v} C]
/-- A model category is a category equipped with classes of morphisms named cofibrations,
fibrations and weak equivalences which satisfy the axioms CM1/CM2/CM3/CM4/CM5
of (closed) model categories. -/
class ModelCategory where
categoryWithFibrations : CategoryWithFibrations C := by infer_instance
categoryWithCofibrations : CategoryWithCofibrations C := by infer_instance
categoryWithWeakEquivalences : CategoryWithWeakEquivalences C := by infer_instance
cm1a : HasFiniteLimits C := by infer_instance
cm1b : HasFiniteColimits C := by infer_instance
cm2 : (weakEquivalences C).HasTwoOutOfThreeProperty := by infer_instance
cm3a : (weakEquivalences C).IsStableUnderRetracts := by infer_instance
cm3b : (fibrations C).IsStableUnderRetracts := by infer_instance
cm3c : (cofibrations C).IsStableUnderRetracts := by infer_instance
cm4a {A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y) [Cofibration i] [WeakEquivalence i] [Fibration p] :
HasLiftingProperty i p := by intros; infer_instance
cm4b {A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y) [Cofibration i] [Fibration p] [WeakEquivalence p] :
HasLiftingProperty i p := by intros; infer_instance
cm5a : MorphismProperty.HasFactorization (trivialCofibrations C) (fibrations C) := by
infer_instance
cm5b : MorphismProperty.HasFactorization (cofibrations C) (trivialFibrations C) := by
infer_instance
namespace ModelCategory
attribute [instance] categoryWithFibrations categoryWithCofibrations categoryWithWeakEquivalences
cm1a cm1b cm2 cm3a cm3b cm3c cm4a cm4b cm5a cm5b
section
variable [ModelCategory C]
instance : MorphismProperty.IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C) :=
MorphismProperty.IsWeakFactorizationSystem.mk' _ _ (fun {A B X Y} i p hi hp ↦ by
obtain ⟨_, _⟩ := mem_trivialCofibrations_iff i|>.mp hi
rw [← fibration_iff] at hp
infer_instance)
instance : MorphismProperty.IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C) :=
MorphismProperty.IsWeakFactorizationSystem.mk' _ _ (fun {A B X Y} i p hi hp ↦ by
rw [mem_trivialFibrations_iff] at hp
rw [← cofibration_iff] at hi
have := hp.1
have := hp.2
infer_instance)
end
section mk'
open MorphismProperty
variable {C} in
private lemma mk'.cm3a_aux [CategoryWithFibrations C] [CategoryWithCofibrations C]
[CategoryWithWeakEquivalences C]
[(weakEquivalences C).HasTwoOutOfThreeProperty]
[IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)]
[IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C)] {A B X Y : C}
{f : A ⟶ B} {w : X ⟶ Y} [Fibration f] [WeakEquivalence w]
(h : RetractArrow f w) : WeakEquivalence f := by
have hw := factorizationData (trivialCofibrations C) (fibrations C) w
have : (trivialFibrations C).IsStableUnderRetracts := by
rw [← cofibrations_rlp]
infer_instance
have sq : CommSq h.r.left hw.i f (hw.p ≫ h.r.right) := ⟨by simp⟩
have hf : fibrations C f := by rwa [← fibration_iff]
have : HasLiftingProperty hw.i f := hasLiftingProperty_of_wfs _ _ hw.hi hf
have : RetractArrow f hw.p :=
{ i := Arrow.homMk (h.i.left ≫ hw.i) h.i.right
r := Arrow.homMk sq.lift h.r.right }
have h' : trivialFibrations C hw.p :=
⟨hw.hp, (weakEquivalence_iff _).1 (weakEquivalence_of_precomp_of_fac hw.fac)⟩
simpa only [weakEquivalence_iff] using (of_retract this h').2
/-- Constructor for `ModelCategory C` which assumes a formulation of axioms
using weak factorization systems. -/
def mk' [CategoryWithFibrations C] [CategoryWithCofibrations C]
[CategoryWithWeakEquivalences C] [HasFiniteLimits C] [HasFiniteColimits C]
[(weakEquivalences C).HasTwoOutOfThreeProperty]
[IsWeakFactorizationSystem (cofibrations C) (trivialFibrations C)]
[IsWeakFactorizationSystem (trivialCofibrations C) (fibrations C)] :
ModelCategory C where
cm3a := ⟨fun {A B X Y f w h hw} ↦ by
rw [← weakEquivalence_iff] at hw
have hf := factorizationData (trivialCofibrations C) (fibrations C) f
have : Cofibration hf.i := by
simpa only [cofibration_iff] using hf.hi.1
have : WeakEquivalence hf.i := by
simpa only [weakEquivalence_iff] using hf.hi.2
let φ : pushout hf.i h.i.left ⟶ Y :=
pushout.desc (hf.p ≫ h.i.right) w (by simp)
have : Fibration hf.p := by simpa only [fibration_iff] using hf.hp
have : WeakEquivalence (pushout.inr _ _ ≫ φ) := by simpa [φ]
have := weakEquivalence_of_precomp (pushout.inr _ _) φ
have hp : RetractArrow hf.p φ :=
{ i := Arrow.homMk (pushout.inl _ _) h.i.right
r := Arrow.homMk (pushout.desc (𝟙 _) (h.r.left ≫ hf.i) (by simp)) h.r.right }
have := mk'.cm3a_aux hp
rw [← weakEquivalence_iff, ← hf.fac]
infer_instance⟩
cm3b := by
rw [← rlp_eq_of_wfs (trivialCofibrations C) (fibrations C)]
infer_instance
cm3c := by
rw [← llp_eq_of_wfs (cofibrations C) (trivialFibrations C)]
infer_instance
cm4a i p _ _ _ := hasLiftingProperty_of_wfs i p (mem_trivialCofibrations i) (mem_fibrations p)
cm4b i p _ _ _ := hasLiftingProperty_of_wfs i p (mem_cofibrations i) (mem_trivialFibrations p)
end mk'
end ModelCategory
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/JoyalTrick.lean | import Mathlib.AlgebraicTopology.ModelCategory.CategoryWithCofibrations
import Mathlib.CategoryTheory.MorphismProperty.Limits
/-!
# A trick by Joyal
In order to construct a model category, we may sometimes have basically
proven all the axioms with the exception of the left lifting property
of cofibrations with respect to trivial fibrations. A trick by Joyal
allows to obtain this lifting property under suitable assumptions,
namely that cofibrations are stable under composition and cobase change.
(The dual result is also formalized.)
## References
* [John F. Jardine, Simplicial presheaves][jardine-1987]
-/
open CategoryTheory Category Limits MorphismProperty
namespace HomotopicalAlgebra
namespace ModelCategory
variable {C : Type*} [Category C]
[CategoryWithCofibrations C] [CategoryWithFibrations C] [CategoryWithWeakEquivalences C]
[(weakEquivalences C).HasTwoOutOfThreeProperty]
/-- Joyal's trick: that cofibrations have the left lifting property
with respect to trivial fibrations follows from the left lifting property
of trivial cofibrations with respect to fibrations and a few other
consequences of the model categories axioms. -/
lemma hasLiftingProperty_of_joyalTrick
[HasFactorization (cofibrations C) (trivialFibrations C)] [HasPushouts C]
[(cofibrations C).IsStableUnderComposition] [(cofibrations C).IsStableUnderCobaseChange]
(h : ∀ {A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y)
[Cofibration i] [WeakEquivalence i] [Fibration p], HasLiftingProperty i p)
{A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y)
[Cofibration i] [Fibration p] [WeakEquivalence p] :
HasLiftingProperty i p where
sq_hasLift {f g} sq := by
let h := factorizationData (cofibrations C) (trivialFibrations C)
(pushout.desc p g sq.w)
have sq' : CommSq (𝟙 X) (pushout.inl _ _ ≫ h.i) p h.p := .mk
have h₁ : WeakEquivalence ((pushout.inl f i ≫ h.i) ≫ h.p) := by simpa
have h₂ := comp_mem _ _ _ ((cofibrations C).of_isPushout
(IsPushout.of_hasPushout f i) (mem_cofibrations i)) h.hi
rw [← cofibration_iff] at h₂
have : WeakEquivalence (pushout.inl f i ≫ h.i) := by
rw [weakEquivalence_iff] at h₁ ⊢
exact of_postcomp _ _ _ h.hp.2 h₁
exact ⟨⟨{ l := pushout.inr f i ≫ h.i ≫ sq'.lift
fac_left := by
simpa only [assoc, comp_id, pushout.condition_assoc] using
f ≫= sq'.fac_left }⟩⟩
/-- Joyal's trick (dual): that trivial cofibrations have the left lifting
property with respect to fibrations follows from the left lifting property
of cofibrations with respect to trivial fibrations and a few other
consequences of the model categories axioms. -/
lemma hasLiftingProperty_of_joyalTrickDual
[HasFactorization (trivialCofibrations C) (fibrations C)] [HasPullbacks C]
[(fibrations C).IsStableUnderComposition] [(fibrations C).IsStableUnderBaseChange]
(h : ∀ {A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y)
[Cofibration i] [WeakEquivalence p] [Fibration p], HasLiftingProperty i p)
{A B X Y : C} (i : A ⟶ B) (p : X ⟶ Y)
[Cofibration i] [Fibration p] [WeakEquivalence i] :
HasLiftingProperty i p where
sq_hasLift {f g} sq := by
let h := factorizationData (trivialCofibrations C) (fibrations C)
(pullback.lift f i sq.w)
have sq' : CommSq h.i i (h.p ≫ pullback.snd _ _) (𝟙 B) := .mk
have h₁ : WeakEquivalence (h.i ≫ h.p ≫ pullback.snd p g) := by simpa
have h₂ := comp_mem _ _ _ h.hp ((fibrations C).of_isPullback
(IsPullback.of_hasPullback p g) (mem_fibrations p))
rw [← fibration_iff] at h₂
have : WeakEquivalence (h.p ≫ pullback.snd p g) := by
rw [weakEquivalence_iff] at h₁ ⊢
exact of_precomp _ _ _ h.hi.2 h₁
exact ⟨⟨{ l := sq'.lift ≫ h.p ≫ pullback.fst p g
fac_right := by
rw [assoc, assoc, pullback.condition, reassoc_of% sq'.fac_right] }⟩⟩
end ModelCategory
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/IsCofibrant.lean | import Mathlib.AlgebraicTopology.ModelCategory.Instances
import Mathlib.CategoryTheory.Limits.Shapes.Terminal
/-!
# Fibrant and cofibrant objects in a model category
Once a category `C` has been endowed with a `CategoryWithCofibrations C`
instance, it is possible to define the property `IsCofibrant X` for
any `X : C` as an abbreviation for `Cofibration (initial.to X : ⊥_ C ⟶ X)`.
(Fibrant objects are defined similarly.)
-/
open CategoryTheory Limits
namespace HomotopicalAlgebra
variable {C : Type*} [Category C]
section
variable [CategoryWithCofibrations C] [HasInitial C]
/-- An object `X` is cofibrant if `⊥_ C ⟶ X` is a cofibration. -/
abbrev IsCofibrant (X : C) : Prop := Cofibration (initial.to X)
lemma isCofibrant_iff (X : C) :
IsCofibrant X ↔ Cofibration (initial.to X) := Iff.rfl
lemma isCofibrant_iff_of_isInitial [(cofibrations C).RespectsIso]
{A X : C} (i : A ⟶ X) (hA : IsInitial A) :
IsCofibrant X ↔ Cofibration i := by
simp only [cofibration_iff]
apply (cofibrations C).arrow_mk_iso_iff
exact Arrow.isoMk (IsInitial.uniqueUpToIso initialIsInitial hA) (Iso.refl _)
lemma isCofibrant_of_cofibration [(cofibrations C).IsStableUnderComposition]
{X Y : C} (i : X ⟶ Y) [Cofibration i] [hX : IsCofibrant X] :
IsCofibrant Y := by
rw [isCofibrant_iff] at hX ⊢
rw [Subsingleton.elim (initial.to Y) (initial.to X ≫ i)]
infer_instance
section
variable (X Y : C) [(cofibrations C).IsStableUnderCobaseChange] [HasInitial C]
[HasBinaryCoproduct X Y]
instance [hY : IsCofibrant Y] :
Cofibration (coprod.inl : X ⟶ X ⨿ Y) := by
rw [isCofibrant_iff] at hY
rw [cofibration_iff] at hY ⊢
exact MorphismProperty.of_isPushout
((IsPushout.of_isColimit_binaryCofan_of_isInitial
(colimit.isColimit (pair X Y)) initialIsInitial).flip) hY
instance [HasInitial C] [HasBinaryCoproduct X Y] [hX : IsCofibrant X] :
Cofibration (coprod.inr : Y ⟶ X ⨿ Y) := by
rw [isCofibrant_iff] at hX
rw [cofibration_iff] at hX ⊢
exact MorphismProperty.of_isPushout
(IsPushout.of_isColimit_binaryCofan_of_isInitial
(colimit.isColimit (pair X Y)) initialIsInitial) hX
end
end
section
variable [CategoryWithFibrations C] [HasTerminal C]
/-- An object `X` is fibrant if `X ⟶ ⊤_ C` is a fibration. -/
abbrev IsFibrant (X : C) : Prop := Fibration (terminal.from X)
lemma isFibrant_iff (X : C) :
IsFibrant X ↔ Fibration (terminal.from X) := Iff.rfl
lemma isFibrant_iff_of_isTerminal [(fibrations C).RespectsIso]
{X Y : C} (p : X ⟶ Y) (hY : IsTerminal Y) :
IsFibrant X ↔ Fibration p := by
simp only [fibration_iff]
symm
apply (fibrations C).arrow_mk_iso_iff
exact Arrow.isoMk (Iso.refl _) (IsTerminal.uniqueUpToIso hY terminalIsTerminal)
lemma isFibrant_of_fibration [(fibrations C).IsStableUnderComposition]
{X Y : C} (p : X ⟶ Y) [Fibration p] [hY : IsFibrant Y] :
IsFibrant X := by
rw [isFibrant_iff] at hY ⊢
rw [Subsingleton.elim (terminal.from X) (p ≫ terminal.from Y)]
infer_instance
section
variable (X Y : C) [(fibrations C).IsStableUnderBaseChange] [HasTerminal C]
[HasBinaryProduct X Y]
instance [hY : IsFibrant Y] :
Fibration (prod.fst : X ⨯ Y ⟶ X) := by
rw [isFibrant_iff] at hY
rw [fibration_iff] at hY ⊢
exact MorphismProperty.of_isPullback
(IsPullback.of_isLimit_binaryFan_of_isTerminal
(limit.isLimit (pair X Y)) terminalIsTerminal).flip hY
instance [HasTerminal C] [HasBinaryProduct X Y] [hX : IsFibrant X] :
Fibration (prod.snd : X ⨯ Y ⟶ Y) := by
rw [isFibrant_iff] at hX
rw [fibration_iff] at hX ⊢
exact MorphismProperty.of_isPullback
(IsPullback.of_isLimit_binaryFan_of_isTerminal
(limit.isLimit (pair X Y)) terminalIsTerminal) hX
end
end
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/BrownLemma.lean | import Mathlib.AlgebraicTopology.ModelCategory.Basic
import Mathlib.AlgebraicTopology.ModelCategory.IsCofibrant
/-!
# The factorization lemma by K. S. Brown
In a model category, any morphism `f : X ⟶ Y` between
cofibrant objects can be factored as `i ≫ p`
with `i` a cofibration and `p` a trivial fibration
which has a section `s` that is a cofibration.
In order to state this, we introduce a structure
`CofibrantBrownFactorization f` with the data
of such morphisms `i`, `p` and `s` with the expected
properties, and show it is nonempty.
Moreover, if `f` is a weak equivalence, then all the
morphisms `i`, `p` and `s` are weak equivalences.
(We also obtain the dual results about morphisms
between fibrant objects.)
## References
* [Brown, Kenneth S., *Abstract homotopy theory and generalized sheaf cohomology*, §I.1][brown-1973]
-/
open CategoryTheory Limits MorphismProperty
namespace HomotopicalAlgebra
variable {C : Type*} [Category C] [ModelCategory C]
{X Y : C} (f : X ⟶ Y)
/-- Given a morphism `f : X ⟶ Y` in a model category,
this structure contains the data of a factorization `i ≫ p = f`
with `i` a cofibration, `p` a trivial fibration which
has a section `s` that is a cofibration.
That this structure is nonempty when `X`
and `Y` are cofibrant is Ken Brown's factorization lemma. -/
structure CofibrantBrownFactorization extends
MapFactorizationData (cofibrations C) (trivialFibrations C) f where
/-- a cofibration that is a section of `p` -/
s : Y ⟶ Z
s_p : s ≫ p = 𝟙 Y := by cat_disch
cofibration_s : Cofibration s := by infer_instance
namespace CofibrantBrownFactorization
attribute [reassoc (attr := simp)] s_p
attribute [instance] cofibration_s
variable (h : CofibrantBrownFactorization f)
instance [WeakEquivalence f] : WeakEquivalence h.i :=
weakEquivalence_of_postcomp_of_fac h.fac
instance : WeakEquivalence h.s :=
weakEquivalence_of_postcomp_of_fac h.s_p
/-- The term in `CofibrantBrownFactorization f` that is deduced from
a factorization of `coprod.desc f (𝟙 Y) : X ⨿ Y ⟶ Y`
as a cofibration followed by a trivial fibration. -/
@[simps]
noncomputable def mk' [IsCofibrant X] [IsCofibrant Y]
(h : MapFactorizationData (cofibrations C) (trivialFibrations C) (coprod.desc f (𝟙 Y))) :
CofibrantBrownFactorization f where
Z := h.Z
i := coprod.inl ≫ h.i
p := h.p
s := coprod.inr ≫ h.i
hi := by rw [← cofibration_iff]; infer_instance
hp := by rw [mem_trivialFibrations_iff]; constructor <;> infer_instance
variable (h : MapFactorizationData (cofibrations C) (trivialFibrations C) (coprod.desc f (𝟙 Y)))
instance [IsCofibrant X] [IsCofibrant Y] :
Nonempty (CofibrantBrownFactorization f) :=
⟨.mk' f (MorphismProperty.factorizationData _ _ _)⟩
end CofibrantBrownFactorization
/-- Given a morphism `f : X ⟶ Y` in a model category,
this structure contains the data of a factorization `i ≫ p = f`
with `p` a fibration, `i` a trivial cofibration which
has a retraction `r` that is a fibration.
That this structure is nonempty when `X`
and `Y` are fibrant is Ken Brown's factorization lemma. -/
structure FibrantBrownFactorization extends
MapFactorizationData (trivialCofibrations C) (fibrations C) f where
/-- a fibration that is a retraction of `i` -/
r : Z ⟶ X
i_r : i ≫ r = 𝟙 X := by cat_disch
fibration_r : Fibration r := by infer_instance
namespace FibrantBrownFactorization
attribute [reassoc (attr := simp)] i_r
attribute [instance] fibration_r
variable (h : FibrantBrownFactorization f)
instance [WeakEquivalence f] : WeakEquivalence h.p :=
weakEquivalence_of_precomp_of_fac h.fac
instance : WeakEquivalence h.r :=
weakEquivalence_of_precomp_of_fac h.i_r
/-- The term in `CofibrantBrownFactorization f` that is deduced from
a factorization of `prod.lift f (𝟙 X) : X ⟶ Y ⨯ X`
as a cofibration followed by a trivial fibration. -/
@[simps]
noncomputable def mk' [IsFibrant X] [IsFibrant Y]
(h : MapFactorizationData (trivialCofibrations C) (fibrations C) (prod.lift f (𝟙 X))) :
FibrantBrownFactorization f where
Z := h.Z
i := h.i
p := h.p ≫ prod.fst
r := h.p ≫ prod.snd
hi := by rw [mem_trivialCofibrations_iff]; constructor <;> infer_instance
hp := by rw [← fibration_iff]; infer_instance
instance [IsFibrant X] [IsFibrant Y] :
Nonempty (FibrantBrownFactorization f) :=
⟨.mk' f (MorphismProperty.factorizationData _ _ _)⟩
end FibrantBrownFactorization
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/Cylinder.lean | import Mathlib.AlgebraicTopology.ModelCategory.Basic
import Mathlib.AlgebraicTopology.ModelCategory.IsCofibrant
/-!
# Cylinders
We introduce a notion of cylinder for an object `A : C` in a model category.
It consists of an object `I`, a weak equivalence `π : I ⟶ A` equipped with two sections
`i₀` and `i₁`. This notion shall be important in the definition of "left homotopies"
in model categories.
## Implementation notes
The most important definition in this file is `Cylinder A`. This structure
extends another structure `Precylinder A` (which does not assume that `C`
has a notion of weak equivalences, which can be interesting in situations
where we have not yet obtained the model category axioms).
The good properties of cylinders are stated as typeclasses `Cylinder.IsGood`
and `Cylinder.IsVeryGood`.
The existence of very good cylinder objects in model categories is stated
in the lemma `Cylinder.exists_very_good`.
## References
* [Daniel G. Quillen, Homotopical algebra][Quillen1967]
* https://ncatlab.org/nlab/show/cylinder+object
-/
universe v u
open CategoryTheory Category Limits
namespace HomotopicalAlgebra
variable {C : Type u} [Category.{v} C]
/-- A precylinder for `A : C` is the data of a morphism
`π : I ⟶ A` equipped with two sections. -/
structure Precylinder (A : C) where
/-- the underlying object of a (pre)cylinder -/
I : C
/-- the first "inclusion" in the (pre)cylinder -/
i₀ : A ⟶ I
/-- the second "inclusion" in the (pre)cylinder -/
i₁ : A ⟶ I
/-- the codiagonal of the (pre)cylinder -/
π : I ⟶ A
i₀_π : i₀ ≫ π = 𝟙 A := by cat_disch
i₁_π : i₁ ≫ π = 𝟙 A := by cat_disch
namespace Precylinder
attribute [reassoc (attr := simp)] i₀_π i₁_π
variable {A : C} (P : Precylinder A)
/-- The precylinder object obtained by switching the two inclusions. -/
@[simps]
def symm : Precylinder A where
I := P.I
i₀ := P.i₁
i₁ := P.i₀
π := P.π
/-- The gluing of two precylinders. -/
@[simps]
noncomputable def trans (P' : Precylinder A) [HasPushout P.i₁ P'.i₀] :
Precylinder A where
I := pushout P.i₁ P'.i₀
i₀ := P.i₀ ≫ pushout.inl _ _
i₁ := P'.i₁ ≫ pushout.inr _ _
π := pushout.desc P.π P'.π (by simp)
section
variable [HasBinaryCoproduct A A]
/-- the map from the coproduct of two copies of `A` to `P.I`, when `P` is
a cylinder object for `A`. `P` shall be a *good* cylinder object
when this morphism is a cofibration. -/
noncomputable def i : A ⨿ A ⟶ P.I := coprod.desc P.i₀ P.i₁
@[reassoc (attr := simp)]
lemma inl_i : coprod.inl ≫ P.i = P.i₀ := by simp [i]
@[reassoc (attr := simp)]
lemma inr_i : coprod.inr ≫ P.i = P.i₁ := by simp [i]
end
@[simp, reassoc]
lemma symm_i [HasBinaryCoproducts C] : P.symm.i = (coprod.braiding A A).hom ≫ P.i := by cat_disch
end Precylinder
/-- In a category with weak equivalences, a cylinder is the
data of a weak equivalence `π : I ⟶ A` equipped with two sections -/
structure Cylinder [CategoryWithWeakEquivalences C] (A : C) extends Precylinder A where
weakEquivalence_π : WeakEquivalence π := by infer_instance
namespace Cylinder
attribute [instance] weakEquivalence_π
section
variable {A : C} [CategoryWithWeakEquivalences C] (P : Cylinder A)
/-- The cylinder object obtained by switching the two inclusions. -/
@[simps!]
def symm : Cylinder A where
__ := P.toPrecylinder.symm
weakEquivalence_π := by dsimp; infer_instance
@[simp, reassoc]
lemma symm_i [HasBinaryCoproducts C] :
P.symm.i = (coprod.braiding A A).hom ≫ P.i :=
P.toPrecylinder.symm_i
section
variable [(weakEquivalences C).HasTwoOutOfThreeProperty]
[(weakEquivalences C).ContainsIdentities]
instance : WeakEquivalence P.i₀ :=
weakEquivalence_of_postcomp_of_fac P.i₀_π
instance : WeakEquivalence P.i₁ :=
weakEquivalence_of_postcomp_of_fac P.i₁_π
end
/-- A cylinder object `P` is good if the morphism
`P.i : A ⨿ A ⟶ P.I` is a cofibration. -/
class IsGood [HasBinaryCoproduct A A] [CategoryWithCofibrations C] : Prop where
cofibration_i : Cofibration P.i := by infer_instance
/-- A good cylinder object `P` is very good if `P.π` is a (trivial) fibration. -/
class IsVeryGood [HasBinaryCoproduct A A] [CategoryWithCofibrations C]
[CategoryWithFibrations C] : Prop extends P.IsGood where
fibration_π : Fibration P.π := by infer_instance
attribute [instance] IsGood.cofibration_i IsVeryGood.fibration_π
section
variable [HasBinaryCoproduct A A] [CategoryWithCofibrations C]
[HasInitial C] [(cofibrations C).IsStableUnderComposition]
[(cofibrations C).IsStableUnderCobaseChange]
[IsCofibrant A] [P.IsGood]
instance : Cofibration P.i₀ := by
rw [← P.inl_i]
infer_instance
instance : Cofibration P.i₁ := by
rw [← P.inr_i]
infer_instance
instance : IsCofibrant P.I :=
isCofibrant_of_cofibration P.i₀
end
instance [HasBinaryCoproducts C] [CategoryWithCofibrations C] [P.IsGood]
[(cofibrations C).RespectsIso] : P.symm.IsGood where
cofibration_i := by
have hi : cofibrations C P.i := by rw [← cofibration_iff]; infer_instance
rw [P.symm_i, cofibration_iff]
refine ((cofibrations C).arrow_mk_iso_iff ?_).2 hi
exact Arrow.isoMk (coprod.braiding A A) (Iso.refl _)
section
variable [CategoryWithCofibrations C] [CategoryWithFibrations C]
[(fibrations C).IsStableUnderComposition]
instance [HasBinaryCoproduct A A] [HasTerminal C] [IsFibrant A] [P.IsVeryGood] : IsFibrant P.I :=
isFibrant_of_fibration P.π
instance [(cofibrations C).RespectsIso] [HasBinaryCoproducts C] [P.IsVeryGood] :
P.symm.IsVeryGood where
fibration_π := by dsimp; infer_instance
end
end
variable [ModelCategory C] {A : C} (P : Cylinder A)
section
variable (h : MorphismProperty.MapFactorizationData (cofibrations C) (trivialFibrations C)
(codiag A))
/-- A cylinder object for `A` can be obtained from a factorization of the obvious
map `A ⨿ A ⟶ A` as a cofibration followed by a trivial fibration. -/
@[simps]
noncomputable def ofFactorizationData : Cylinder A where
I := h.Z
i₀ := coprod.inl ≫ h.i
i₁ := coprod.inr ≫ h.i
π := h.p
@[simp]
lemma ofFactorizationData_i : (ofFactorizationData h).i = h.i := by cat_disch
instance : (ofFactorizationData h).IsVeryGood where
cofibration_i := by simpa using inferInstanceAs (Cofibration h.i)
fibration_π := by dsimp; infer_instance
instance [HasTerminal C] [IsFibrant A] [(fibrations C).IsStableUnderComposition] :
IsFibrant (ofFactorizationData h).I :=
isFibrant_of_fibration (ofFactorizationData h).π
end
variable (A) in
lemma exists_very_good :
∃ (P : Cylinder A), P.IsVeryGood :=
⟨ofFactorizationData (MorphismProperty.factorizationData _ _ _),
inferInstance⟩
instance : Nonempty (Cylinder A) := ⟨(exists_very_good A).choose⟩
/-- The gluing of two good cylinders. -/
@[simps!]
noncomputable def trans [IsCofibrant A] (P P' : Cylinder A) [P'.IsGood] :
Cylinder A where
__ := P.toPrecylinder.trans P'.toPrecylinder
weakEquivalence_π := by
have : WeakEquivalence ((P.i₀ ≫ pushout.inl P.i₁ P'.i₀) ≫
pushout.desc P.π P'.π (by simp)) := by
simp only [assoc, colimit.ι_desc, PushoutCocone.mk_ι_app,
Precylinder.i₀_π]
infer_instance
dsimp
apply weakEquivalence_of_precomp (P.i₀ ≫ pushout.inl _ _)
instance [IsCofibrant A] (P P' : Cylinder A) [P.IsGood] [P'.IsGood] :
(P.trans P').IsGood where
cofibration_i := by
let ψ : P.I ⨿ A ⟶ (P.trans P').I := coprod.desc (pushout.inl _ _) (P'.i₁ ≫ pushout.inr _ _)
rw [show (P.trans P').i = coprod.map P.i₀ (𝟙 A) ≫ ψ by simp [Precylinder.i, ψ]]
have fac : coprod.map P.i₁ (𝟙 A) ≫ ψ = P'.i ≫ pushout.inr _ _ := by
ext
· simp [ψ, pushout.condition]
· simp [ψ]
have sq : IsPushout P.i₁ (coprod.inl ≫ P'.i) (coprod.inl ≫ ψ) (pushout.inr _ _) := by
simpa [ψ] using IsPushout.of_hasPushout P.i₁ P'.i₀
have : Cofibration ψ := by
rw [cofibration_iff]
exact (cofibrations C).of_isPushout
(IsPushout.of_top sq fac (IsPushout.of_coprod_inl_with_id P.i₁ A).flip)
(by rw [← cofibration_iff]; infer_instance)
infer_instance
end Cylinder
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/LeftHomotopy.lean | import Mathlib.AlgebraicTopology.ModelCategory.Cylinder
import Mathlib.CategoryTheory.Localization.Quotient
/-!
# Left homotopies in model categories
We introduce the types `Precylinder.LeftHomotopy` and `Cylinder.LeftHomotopy`
of homotopies between morphisms `X ⟶ Y` relative to a (pre)cylinder of `X`.
Given two morphisms `f` and `g`, we introduce the relation `LeftHomotopyRel f g`
asserting the existence of a cylinder object `P` and
a left homotopy `P.LeftHomotopy f g`, and we define the quotient
type `LeftHomotopyClass X Y`. We show that if `X` is a cofibrant
object in a model category, then `LeftHomotopyRel` is an equivalence
relation on `X ⟶ Y`.
## References
* [Daniel G. Quillen, Homotopical algebra, section I.1][Quillen1967]
-/
universe v u
open CategoryTheory Limits
namespace HomotopicalAlgebra
variable {C : Type u} [Category.{v} C]
namespace Precylinder
variable {X : C} (P : Precylinder X) {Y : C}
/-- Given a precylinder `P` for `X`, two maps `f` and `g` in `X ⟶ Y` are
homotopic relative to `P` when there is a morphism `h : P.I ⟶ Y`
such that `P.i₀ ≫ h = f` and `P.i₁ ≫ h = g`. -/
structure LeftHomotopy (f g : X ⟶ Y) where
/-- a morphism from the (pre)cylinder object to the target -/
h : P.I ⟶ Y
h₀ : P.i₀ ≫ h = f := by cat_disch
h₁ : P.i₁ ≫ h = g := by cat_disch
namespace LeftHomotopy
attribute [reassoc (attr := simp)] h₀ h₁
/-- `f : X ⟶ Y` is left homotopic to itself relative to any precylinder. -/
@[simps]
def refl (f : X ⟶ Y) : P.LeftHomotopy f f where
h := P.π ≫ f
variable {P}
/-- If `f` and `g` are homotopic relative to a precylinder `P`, then `g` and `f`
are homotopic relative to `P.symm` -/
@[simps]
def symm {f g : X ⟶ Y} (h : P.LeftHomotopy f g) : P.symm.LeftHomotopy g f where
h := h.h
/-- If `f₀` is homotopic to `f₁` relative to a precylinder `P`,
and `f₁` is homotopic to `f₂` relative to `P'`, then
`f₀` is homotopic to `f₂` relative to `P.trans P'`. -/
@[simps]
noncomputable def trans {f₀ f₁ f₂ : X ⟶ Y}
(h : P.LeftHomotopy f₀ f₁) {P' : Precylinder X}
(h' : P'.LeftHomotopy f₁ f₂) [HasPushout P.i₁ P'.i₀] :
(P.trans P').LeftHomotopy f₀ f₂ where
h := pushout.desc h.h h'.h (by simp)
/-- Left homotopies are compatible with postcomposition. -/
@[simps]
def postcomp {f g : X ⟶ Y} (h : P.LeftHomotopy f g) {Z : C} (p : Y ⟶ Z) :
P.LeftHomotopy (f ≫ p) (g ≫ p) where
h := h.h ≫ p
end LeftHomotopy
end Precylinder
namespace Cylinder
variable {X Y : C}
/-- Given a cylinder `P` for `X`, two maps `f` and `g` in `X ⟶ Y`
are homotopic relative to `P` when there is a morphism `h : P.I ⟶ Y`
such that `P.i₀ ≫ h = f` and `P.i₁ ≫ h = g`. -/
abbrev LeftHomotopy [CategoryWithWeakEquivalences C] (P : Cylinder X) (f g : X ⟶ Y) : Type v :=
P.toPrecylinder.LeftHomotopy f g
namespace LeftHomotopy
section
variable [CategoryWithWeakEquivalences C] (P : Cylinder X)
/-- `f : X ⟶ Y` is left homotopic to itself relative to any cylinder. -/
abbrev refl (f : X ⟶ Y) : P.LeftHomotopy f f := Precylinder.LeftHomotopy.refl _ f
variable {P} in
/-- If `f` and `g` are homotopic relative to a cylinder `P`, then `g` and `f`
are homotopic relative to `P.symm`. -/
abbrev symm {f g : X ⟶ Y} (h : P.LeftHomotopy f g) : P.symm.LeftHomotopy g f :=
Precylinder.LeftHomotopy.symm h
variable {P} in
/-- Left homotopies are compatible with postcomposition. -/
abbrev postcomp {f g : X ⟶ Y} (h : P.LeftHomotopy f g) {Z : C} (p : Y ⟶ Z) :
P.LeftHomotopy (f ≫ p) (g ≫ p) :=
Precylinder.LeftHomotopy.postcomp h p
lemma weakEquivalence_iff [(weakEquivalences C).HasTwoOutOfThreeProperty]
[(weakEquivalences C).ContainsIdentities]
{f₀ f₁ : X ⟶ Y} (h : P.LeftHomotopy f₀ f₁) :
WeakEquivalence f₀ ↔ WeakEquivalence f₁ := by
revert P f₀ f₁
suffices ∀ (P : Cylinder X) {f₀ f₁ : X ⟶ Y} (h : P.LeftHomotopy f₀ f₁),
WeakEquivalence f₀ → WeakEquivalence f₁
from fun _ _ _ h ↦ ⟨this _ h, this _ h.symm⟩
intro P f₀ f₁ h h₀
have := weakEquivalence_of_precomp_of_fac h.h₀
rw [← h.h₁]
infer_instance
end
section
variable [ModelCategory C] {P : Cylinder X}
/-- If `f₀ : X ⟶ Y` is homotopic to `f₁` relative to a cylinder `P`,
and `f₁` is homotopic to `f₂` relative to a good cylinder `P'`,
then `f₀` is homotopic to `f₂` relative to the cylinder `P.trans P'`
when `X` is cofibrant. -/
noncomputable abbrev trans [IsCofibrant X] {f₀ f₁ f₂ : X ⟶ Y}
(h : P.LeftHomotopy f₀ f₁) {P' : Cylinder X} [P'.IsGood]
(h' : P'.LeftHomotopy f₁ f₂) [HasPushout P.i₁ P'.i₀] :
(P.trans P').LeftHomotopy f₀ f₂ :=
Precylinder.LeftHomotopy.trans h h'
lemma exists_good_cylinder {f g : X ⟶ Y} (h : P.LeftHomotopy f g) :
∃ (P' : Cylinder X), P'.IsGood ∧ Nonempty (P'.LeftHomotopy f g) := by
let d := MorphismProperty.factorizationData (cofibrations C) (trivialFibrations C) P.i
exact
⟨{ I := d.Z
i₀ := coprod.inl ≫ d.i
i₁ := coprod.inr ≫ d.i
π := d.p ≫ P.π }, ⟨by
rw [cofibration_iff]
convert d.hi
aesop⟩, ⟨{ h := d.p ≫ h.h }⟩⟩
/-- The covering homotopy theorem: if `p : E ⟶ B` is a fibration,
`l₀ : A ⟶ E` is a morphism, if there is a left homotopy `h` between
the composition `f₀ := l₀ ≫ p` and a morphism `f₁ : A ⟶ B`,
then there exists a morphism `l₁ : A ⟶ E` and a left homotopy `h'` from
`l₀` to `l₁` which is compatible with `h` (in particular, `l₁ ≫ p = f₁`). -/
lemma covering_homotopy {A E B : C} {P : Cylinder A} {f₀ f₁ : A ⟶ B}
[IsCofibrant A] [P.IsGood]
(h : P.LeftHomotopy f₀ f₁) (p : E ⟶ B) [Fibration p]
(l₀ : A ⟶ E) (hl₀ : l₀ ≫ p = f₀ := by cat_disch) :
∃ (l₁ : A ⟶ E) (h' : P.LeftHomotopy l₀ l₁), h'.h ≫ p = h.h :=
have sq : CommSq l₀ P.i₀ p h.h := { }
⟨P.i₁ ≫ sq.lift, { h := sq.lift }, by simp⟩
end
end LeftHomotopy
end Cylinder
/-- The left homotopy relation on morphisms in a category with weak equivalences. -/
def LeftHomotopyRel [CategoryWithWeakEquivalences C] : HomRel C :=
fun X _ f g ↦ ∃ (P : Cylinder X), Nonempty (P.LeftHomotopy f g)
lemma Cylinder.LeftHomotopy.leftHomotopyRel [CategoryWithWeakEquivalences C]
{X Y : C} {f g : X ⟶ Y}
{P : Cylinder X} (h : P.LeftHomotopy f g) :
LeftHomotopyRel f g :=
⟨_, ⟨h⟩⟩
namespace LeftHomotopyRel
variable (C) in
lemma factorsThroughLocalization [CategoryWithWeakEquivalences C] :
LeftHomotopyRel.FactorsThroughLocalization (weakEquivalences C) := by
rintro X Y f g ⟨P, ⟨h⟩⟩
let L := (weakEquivalences C).Q
rw [areEqualizedByLocalization_iff L]
suffices L.map P.i₀ = L.map P.i₁ by
simp only [← h.h₀, ← h.h₁, L.map_comp, this]
have := Localization.inverts L (weakEquivalences C) P.π (by
rw [← weakEquivalence_iff]
infer_instance)
simp [← cancel_mono (L.map P.π), ← L.map_comp, P.i₀_π, P.i₁_π]
variable {X Y : C}
lemma refl [ModelCategory C] (f : X ⟶ Y) : LeftHomotopyRel f f :=
⟨Classical.arbitrary _, ⟨Cylinder.LeftHomotopy.refl _ _⟩⟩
lemma postcomp [CategoryWithWeakEquivalences C]
{f g : X ⟶ Y} (h : LeftHomotopyRel f g) {Z : C} (p : Y ⟶ Z) :
LeftHomotopyRel (f ≫ p) (g ≫ p) := by
obtain ⟨P, ⟨h⟩⟩ := h
exact (h.postcomp p).leftHomotopyRel
lemma exists_good_cylinder [ModelCategory C] {f g : X ⟶ Y} (h : LeftHomotopyRel f g) :
∃ (P : Cylinder X), P.IsGood ∧ Nonempty (P.LeftHomotopy f g) := by
obtain ⟨P, ⟨h⟩⟩ := h
exact h.exists_good_cylinder
lemma exists_very_good_cylinder [ModelCategory C] {f g : X ⟶ Y} [IsFibrant Y]
(h : LeftHomotopyRel f g) :
∃ (P : Cylinder X), P.IsVeryGood ∧ Nonempty (P.LeftHomotopy f g) := by
obtain ⟨P, _, ⟨h⟩⟩ := h.exists_good_cylinder
let fac := MorphismProperty.factorizationData (trivialCofibrations C) (fibrations C) P.π
let P' : Cylinder X :=
{ I := fac.Z
i₀ := P.i₀ ≫ fac.i
i₁ := P.i₁ ≫ fac.i
π := fac.p
weakEquivalence_π := weakEquivalence_of_precomp_of_fac fac.fac }
have : Cofibration P'.i := by
rw [show P'.i = P.i ≫ fac.i by cat_disch]
infer_instance
have sq : CommSq h.h fac.i (terminal.from _) (terminal.from _) := { }
exact ⟨P', { }, ⟨{ h := sq.lift }⟩ ⟩
lemma symm [CategoryWithWeakEquivalences C]
{f g : X ⟶ Y} (h : LeftHomotopyRel f g) : LeftHomotopyRel g f := by
obtain ⟨P, ⟨h⟩⟩ := h
exact h.symm.leftHomotopyRel
lemma trans [ModelCategory C]
{f₀ f₁ f₂ : X ⟶ Y} [IsCofibrant X] (h : LeftHomotopyRel f₀ f₁)
(h' : LeftHomotopyRel f₁ f₂) : LeftHomotopyRel f₀ f₂ := by
obtain ⟨P, ⟨h⟩⟩ := h
obtain ⟨P', _, ⟨h'⟩⟩ := h'.exists_good_cylinder
exact (h.trans h').leftHomotopyRel
lemma equivalence [ModelCategory C] (X Y : C) [IsCofibrant X] :
_root_.Equivalence (LeftHomotopyRel (X := X) (Y := Y)) where
refl := .refl
symm h := h.symm
trans h h' := h.trans h'
lemma precomp [ModelCategory C] {f g : X ⟶ Y} [IsFibrant Y] (h : LeftHomotopyRel f g)
{Z : C} (i : Z ⟶ X) : LeftHomotopyRel (i ≫ f) (i ≫ g) := by
obtain ⟨P, _, ⟨h⟩⟩ := h.exists_very_good_cylinder
obtain ⟨Q, _⟩ := Cylinder.exists_very_good Z
have sq : CommSq (coprod.desc (i ≫ P.i₀) (i ≫ P.i₁)) Q.i P.π (Q.π ≫ i) := ⟨by aesop_cat⟩
exact ⟨Q,
⟨{ h := sq.lift ≫ h.h
h₀ := by
have := coprod.inl ≫= sq.fac_left
simp only [Q.inl_i_assoc, coprod.inl_desc] at this
simp [reassoc_of% this]
h₁ := by
have := coprod.inr ≫= sq.fac_left
simp only [Q.inr_i_assoc, coprod.inr_desc] at this
simp [reassoc_of% this] }⟩⟩
end LeftHomotopyRel
variable (X Y Z : C)
/-- In a category with weak equivalences, this is the quotient of the type
of morphisms `X ⟶ Y` by the equivalence relation generated by left homotopies. -/
def LeftHomotopyClass [CategoryWithWeakEquivalences C] :=
_root_.Quot (LeftHomotopyRel (X := X) (Y := Y))
variable {X Y Z}
/-- Given `f : X ⟶ Y`, this is the class of `f` in the quotient `LeftHomotopyClass X Y`. -/
def LeftHomotopyClass.mk [CategoryWithWeakEquivalences C] :
(X ⟶ Y) → LeftHomotopyClass X Y := Quot.mk _
lemma LeftHomotopyClass.mk_surjective [CategoryWithWeakEquivalences C] :
Function.Surjective (mk : (X ⟶ Y) → _) :=
Quot.mk_surjective
namespace LeftHomotopyClass
lemma sound [CategoryWithWeakEquivalences C] {f g : X ⟶ Y} (h : LeftHomotopyRel f g) :
mk f = mk g := Quot.sound h
/-- The postcomposition map `LeftHomotopyClass X Y → (Y ⟶ Z) → LeftHomotopyClass X Z`. -/
def postcomp [CategoryWithWeakEquivalences C] :
LeftHomotopyClass X Y → (Y ⟶ Z) → LeftHomotopyClass X Z :=
fun f g ↦ Quot.lift (fun f ↦ mk (f ≫ g)) (fun _ _ h ↦ sound (h.postcomp g)) f
@[simp]
lemma postcomp_mk [CategoryWithWeakEquivalences C] (f : X ⟶ Y) (g : Y ⟶ Z) :
(mk f).postcomp g = mk (f ≫ g) := rfl
lemma mk_eq_mk_iff [ModelCategory C] [IsCofibrant X] (f g : X ⟶ Y) :
mk f = mk g ↔ LeftHomotopyRel f g := by
rw [← (LeftHomotopyRel.equivalence X Y).eqvGen_iff]
exact Quot.eq
end LeftHomotopyClass
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/ModelCategory/Homotopy.lean | import Mathlib.AlgebraicTopology.ModelCategory.BrownLemma
import Mathlib.AlgebraicTopology.ModelCategory.LeftHomotopy
import Mathlib.AlgebraicTopology.ModelCategory.RightHomotopy
/-!
# Homotopies in model categories
In this file, we relate left and right homotopies between
morphisms `X ⟶ Y` in model categories. In particular, if `X` is cofibrant
and `Y` is fibrant, these notions coincide (for arbitrary choices of good
cylinders or good path objects).
Using the factorization lemma by K. S. Brown, we deduce versions of the Whitehead
theorem (`LeftHomotopyClass.whitehead` and `RightHomotopyClass.whitehead`)
which assert that when both `X` and `Y` are fibrant and cofibrant,
then any weak equivalence `X ⟶ Y` is a homotopy equivalence.
## References
* [Daniel G. Quillen, Homotopical algebra, section I.1][Quillen1967]
-/
universe v u
open CategoryTheory Limits
namespace HomotopicalAlgebra
variable {C : Type u} [Category.{v} C] [ModelCategory C] {X Y Z : C}
namespace LeftHomotopyRel
variable {f g : X ⟶ Y} [IsCofibrant X]
/-- When two morphisms `X ⟶ Y` with `X` cofibrant are related by a left homotopy,
this is a choice of a right homotopy relative to any good path object for `Y`. -/
noncomputable def rightHomotopy (h : LeftHomotopyRel f g) (Q : PathObject Y) [Q.IsGood] :
Q.RightHomotopy f g :=
let P := h.exists_good_cylinder.choose
have h := h.exists_good_cylinder.choose_spec.2.some
have h' := h.exists_good_cylinder.choose_spec.1
have sq : CommSq (f ≫ Q.ι) P.i₀ Q.p (prod.lift (P.π ≫ f) h.h) := { }
{ h := P.i₁ ≫ sq.lift
h₀ := by
have := sq.fac_right =≫ prod.fst
rw [Category.assoc, Q.p_fst, prod.lift_fst] at this
simp [this]
h₁ := by
have := sq.fac_right =≫ prod.snd
rw [Category.assoc, Q.p_snd, prod.lift_snd] at this
simp [this] }
lemma rightHomotopyRel (h : LeftHomotopyRel f g) : RightHomotopyRel f g := by
obtain ⟨P, _⟩ := PathObject.exists_very_good Y
exact ⟨_, ⟨h.rightHomotopy P⟩⟩
end LeftHomotopyRel
namespace RightHomotopyRel
variable {f g : X ⟶ Y} [IsFibrant Y]
/-- When two morphisms `X ⟶ Y` with `Y` fibrant are related by a right homotopy,
this is a choice of a left homotopy relative to any good cylinder object for `X`. -/
noncomputable def leftHomotopy (h : RightHomotopyRel f g) (Q : Cylinder X) [Q.IsGood] :
Q.LeftHomotopy f g :=
let P := h.exists_good_pathObject.choose
have h := h.exists_good_pathObject.choose_spec.2.some
have h' := h.exists_good_pathObject.choose_spec.1
have sq : CommSq (coprod.desc (f ≫ P.ι) h.h) Q.i P.p₀ (Q.π ≫ f) := { }
{ h := sq.lift ≫ P.p₁
h₀ := by
have := coprod.inl ≫= sq.fac_left
rw [Q.inl_i_assoc, coprod.inl_desc] at this
simp [reassoc_of% this]
h₁ := by
have := coprod.inr ≫= sq.fac_left
rw [Q.inr_i_assoc, coprod.inr_desc] at this
simp [reassoc_of% this, P] }
lemma leftHomotopyRel (h : RightHomotopyRel f g) : LeftHomotopyRel f g := by
obtain ⟨P, _⟩ := Cylinder.exists_very_good X
exact ⟨P, ⟨h.leftHomotopy P⟩⟩
end RightHomotopyRel
lemma leftHomotopyRel_iff_rightHomotopyRel {X Y : C} (f g : X ⟶ Y)
[IsCofibrant X] [IsFibrant Y] :
LeftHomotopyRel f g ↔ RightHomotopyRel f g :=
⟨fun h ↦ h.rightHomotopyRel, fun h ↦ h.leftHomotopyRel⟩
namespace LeftHomotopyClass
variable (X)
lemma postcomp_bijective_of_fibration_of_weakEquivalence
[IsCofibrant X] (g : Y ⟶ Z) [Fibration g] [WeakEquivalence g] :
Function.Bijective (fun (f : LeftHomotopyClass X Y) ↦ f.postcomp g) := by
constructor
· intro f₀ f₁ h
obtain ⟨f₀, rfl⟩ := f₀.mk_surjective
obtain ⟨f₁, rfl⟩ := f₁.mk_surjective
simp only [postcomp_mk, mk_eq_mk_iff] at h
obtain ⟨P, _, ⟨h⟩⟩ := h.exists_good_cylinder
have sq : CommSq (coprod.desc f₀ f₁) P.i g h.h := { }
rw [mk_eq_mk_iff]
exact ⟨P,
⟨{h := sq.lift
h₀ := by
have := coprod.inl ≫= sq.fac_left
rwa [P.inl_i_assoc, coprod.inl_desc] at this
h₁ := by
have := coprod.inr ≫= sq.fac_left
rwa [P.inr_i_assoc, coprod.inr_desc] at this }⟩⟩
· intro φ
obtain ⟨φ, rfl⟩ := φ.mk_surjective
have sq : CommSq (initial.to Y) (initial.to X) g φ := { }
exact ⟨mk sq.lift, by simp⟩
lemma postcomp_bijective_of_weakEquivalence
[IsCofibrant X] (g : Y ⟶ Z) [IsFibrant Y] [IsFibrant Z] [WeakEquivalence g] :
Function.Bijective (fun (f : LeftHomotopyClass X Y) ↦ f.postcomp g) := by
let h : FibrantBrownFactorization g := Classical.arbitrary _
have hi : Function.Bijective (fun (f : LeftHomotopyClass X Y) ↦ f.postcomp h.i) := by
rw [← Function.Bijective.of_comp_iff'
(postcomp_bijective_of_fibration_of_weakEquivalence X h.r)]
convert Function.bijective_id
ext φ
obtain ⟨φ, rfl⟩ := φ.mk_surjective
simp
convert (postcomp_bijective_of_fibration_of_weakEquivalence X h.p).comp hi using 1
ext φ
obtain ⟨φ, rfl⟩ := φ.mk_surjective
simp
end LeftHomotopyClass
namespace RightHomotopyClass
variable (Z)
lemma precomp_bijective_of_cofibration_of_weakEquivalence
[IsFibrant Z] (f : X ⟶ Y) [Cofibration f] [WeakEquivalence f] :
Function.Bijective (fun (g : RightHomotopyClass Y Z) ↦ g.precomp f) := by
constructor
· intro f₀ f₁ h
obtain ⟨f₀, rfl⟩ := f₀.mk_surjective
obtain ⟨f₁, rfl⟩ := f₁.mk_surjective
simp only [precomp_mk, mk_eq_mk_iff] at h
obtain ⟨P, _, ⟨h⟩⟩ := h.exists_good_pathObject
have sq : CommSq h.h f P.p (prod.lift f₀ f₁) := { }
rw [mk_eq_mk_iff]
exact ⟨P,
⟨{h := sq.lift
h₀ := by
have := sq.fac_right =≫ prod.fst
rwa [Category.assoc, P.p_fst, prod.lift_fst] at this
h₁ := by
have := sq.fac_right =≫ prod.snd
rwa [Category.assoc, P.p_snd, prod.lift_snd] at this }⟩⟩
· intro φ
obtain ⟨φ, rfl⟩ := φ.mk_surjective
have sq : CommSq φ f (terminal.from _) (terminal.from _) := { }
exact ⟨mk sq.lift, by simp⟩
lemma precomp_bijective_of_weakEquivalence
[IsFibrant Z] (f : X ⟶ Y) [IsCofibrant X] [IsCofibrant Y] [WeakEquivalence f] :
Function.Bijective (fun (g : RightHomotopyClass Y Z) ↦ g.precomp f) := by
let h : CofibrantBrownFactorization f := Classical.arbitrary _
have hj : Function.Bijective (fun (g : RightHomotopyClass Y Z) ↦ g.precomp h.p) := by
rw [← Function.Bijective.of_comp_iff'
(precomp_bijective_of_cofibration_of_weakEquivalence Z h.s)]
convert Function.bijective_id
ext φ
obtain ⟨φ, rfl⟩ := φ.mk_surjective
simp
convert (precomp_bijective_of_cofibration_of_weakEquivalence Z h.i).comp hj using 1
ext φ
obtain ⟨φ, rfl⟩ := φ.mk_surjective
simp
lemma whitehead [IsCofibrant X] [IsCofibrant Y] [IsFibrant X] [IsFibrant Y]
(f : X ⟶ Y) [WeakEquivalence f] :
∃ (g : Y ⟶ X), RightHomotopyRel (f ≫ g) (𝟙 X) ∧ RightHomotopyRel (g ≫ f) (𝟙 Y) := by
obtain ⟨g, hg⟩ := (precomp_bijective_of_weakEquivalence X f).2 (.mk (𝟙 X))
obtain ⟨g, rfl⟩ := g.mk_surjective
dsimp at hg
refine ⟨g, by rwa [← mk_eq_mk_iff], ?_⟩
rw [← mk_eq_mk_iff]
apply (precomp_bijective_of_weakEquivalence Y f).1
simp only [precomp_mk, Category.comp_id]
rw [mk_eq_mk_iff, ← leftHomotopyRel_iff_rightHomotopyRel] at hg ⊢
simpa using hg.postcomp f
end RightHomotopyClass
lemma LeftHomotopyClass.whitehead [IsCofibrant X] [IsCofibrant Y] [IsFibrant X] [IsFibrant Y]
(f : X ⟶ Y) [WeakEquivalence f] :
∃ (g : Y ⟶ X), LeftHomotopyRel (f ≫ g) (𝟙 X) ∧ LeftHomotopyRel (g ≫ f) (𝟙 Y) := by
simp only [leftHomotopyRel_iff_rightHomotopyRel]
apply RightHomotopyClass.whitehead
section
variable [IsCofibrant X] [IsFibrant Y]
/-- Left homotopy classes of maps `X ⟶ Y` identify to right homotopy classes
when `X` is cofibrant and `Y` is fibrant. -/
def leftHomotopyClassEquivRightHomotopyClass :
LeftHomotopyClass X Y ≃ RightHomotopyClass X Y where
toFun := Quot.lift (fun f ↦ .mk f) (fun _ _ h ↦ by
dsimp
rw [RightHomotopyClass.mk_eq_mk_iff]
exact h.rightHomotopyRel)
invFun := Quot.lift (fun f ↦ .mk f) (fun _ _ h ↦ by
dsimp
rw [LeftHomotopyClass.mk_eq_mk_iff]
exact h.leftHomotopyRel)
left_inv := by rintro ⟨f⟩; rfl
right_inv := by rintro ⟨f⟩; rfl
@[simp]
lemma leftHomotopyClassEquivRightHomotopyClass_mk (f : X ⟶ Y) :
leftHomotopyClassEquivRightHomotopyClass (.mk f) = .mk f := rfl
@[simp]
lemma leftHomotopyClassEquivRightHomotopyClass_symm_mk (f : X ⟶ Y) :
leftHomotopyClassEquivRightHomotopyClass.symm (.mk f) = .mk f := rfl
end
end HomotopicalAlgebra |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/NerveAdjunction.lean | import Mathlib.AlgebraicTopology.SimplexCategory.MorphismProperty
import Mathlib.AlgebraicTopology.SimplicialSet.HomotopyCat
import Mathlib.CategoryTheory.Category.Cat.CartesianClosed
import Mathlib.CategoryTheory.Closed.FunctorToTypes
import Mathlib.CategoryTheory.Limits.Presheaf
/-!
# The adjunction between the nerve and the homotopy category functor.
We define an adjunction `nerveAdjunction : hoFunctor ⊣ nerveFunctor` between the functor that
takes a simplicial set to its homotopy category and the functor that takes a category to its nerve.
Up to natural isomorphism, this is constructed as the composite of two other adjunctions,
namely `nerve₂Adj : hoFunctor₂ ⊣ nerveFunctor₂` between analogously-defined functors involving
the category of 2-truncated simplicial sets and `coskAdj 2 : truncation 2 ⊣ Truncated.cosk 2`. The
aforementioned natural isomorphism
`cosk₂Iso : nerveFunctor ≅ nerveFunctor₂ ⋙ Truncated.cosk 2`
exists because nerves of categories are 2-coskeletal.
We also prove that `nerveFunctor` is fully faithful, demonstrating that `nerveAdjunction` is
reflective. Since the category of simplicial sets is cocomplete, we conclude in
`Mathlib/CategoryTheory/Category/Cat/Colimit.lean` that the category of categories has colimits.
Finally we show that `hoFunctor : SSet.{u} ⥤ Cat.{u, u}` preserves finite cartesian products; note
that it fails to preserve infinite products.
-/
namespace CategoryTheory
open Category Functor Limits Opposite SimplexCategory Simplicial SSet Nerve
open SSet.Truncated SimplexCategory.Truncated SimplicialObject.Truncated
universe v u v' u'
section
/-- The components of the counit of `nerve₂Adj`. -/
@[simps!]
def nerve₂Adj.counit.app (C : Type u) [SmallCategory C] :
(nerveFunctor₂.obj (Cat.of C)).HomotopyCategory ⥤ C := by
fapply Quotient.lift
· exact
(whiskerRight (OneTruncation₂.ofNerve₂.natIso).hom _ ≫ ReflQuiv.adj.{u}.counit).app (Cat.of C)
· intro x y f g rel
obtain ⟨φ⟩ := rel
simpa [ReflQuiv.adj, Quot.liftOn, Cat.FreeRefl.quotientFunctor, Quotient.functor,
pathComposition, Quiv.adj, OneTruncation₂.nerveHomEquiv] using
φ.map_comp (X := 0) (Y := 1) (Z := 2) (homOfLE (by decide)) (homOfLE (by decide))
@[simp]
theorem nerve₂Adj.counit.app_eq (C : Type u) [SmallCategory C] :
SSet.Truncated.HomotopyCategory.quotientFunctor (nerveFunctor₂.obj (Cat.of C)) ⋙
nerve₂Adj.counit.app.{u} C =
(whiskerRight OneTruncation₂.ofNerve₂.natIso.hom _ ≫
ReflQuiv.adj.{u}.counit).app (Cat.of C) := rfl
/-- The naturality of `nerve₂Adj.counit.app`. -/
theorem nerve₂Adj.counit.naturality {C D : Type u} [SmallCategory C] [SmallCategory D]
(F : C ⥤ D) :
(nerveFunctor₂ ⋙ hoFunctor₂).map F ⋙ nerve₂Adj.counit.app D =
nerve₂Adj.counit.app C ⋙ F := by
apply HomotopyCategory.lift_unique'
change ((oneTruncation₂ ⋙ Cat.freeRefl).map (nerveFunctor₂.map _)) ⋙
HomotopyCategory.quotientFunctor (nerveFunctor₂.obj (Cat.of D)) ⋙ app D = _
rw [nerve₂Adj.counit.app_eq D]
rw [← Functor.assoc _ _ F, nerve₂Adj.counit.app_eq C]
exact (whiskerRight OneTruncation₂.ofNerve₂.natIso.{u}.hom Cat.freeRefl ≫
ReflQuiv.adj.counit).naturality _
/-- The counit of `nerve₂Adj.` -/
@[simps]
def nerve₂Adj.counit : nerveFunctor₂ ⋙ hoFunctor₂.{u} ⟶ 𝟭 Cat where
app _ := nerve₂Adj.counit.app _
naturality _ _ _ := nerve₂Adj.counit.naturality _
variable {C : Type u} [SmallCategory C] {X : SSet.Truncated.{u} 2}
(F : SSet.oneTruncation₂.obj X ⟶ ReflQuiv.of C)
/-- Because nerves are 2-coskeletal, the components of a map of 2-truncated simplicial sets valued
in a nerve can be recovered from the underlying ReflPrefunctor. -/
def toNerve₂.mk.app (n : SimplexCategory.Truncated 2) :
X.obj (op n) ⟶ (nerveFunctor₂.obj (Cat.of C)).obj (op n) := by
obtain ⟨n, hn⟩ := n
induction n using SimplexCategory.rec with | _ n
match n with
| 0 => exact fun x => .mk₀ (F.obj x)
| 1 => exact fun f => .mk₁ (F.map ⟨f, rfl, rfl⟩)
| 2 => exact fun φ => .mk₂ (F.map (ev01₂ φ)) (F.map (ev12₂ φ))
@[simp] theorem toNerve₂.mk.app_zero (x : X _⦋0⦌₂) : mk.app F ⦋0⦌₂ x = .mk₀ (F.obj x) := rfl
@[simp] theorem toNerve₂.mk.app_one (f : X _⦋1⦌₂) :
mk.app F ⦋1⦌₂ f = .mk₁ (F.map ⟨f, rfl, rfl⟩) := rfl
@[simp] theorem toNerve₂.mk.app_two (φ : X _⦋2⦌₂) :
mk.app F ⦋2⦌₂ φ = .mk₂ (F.map (ev01₂ φ)) (F.map (ev12₂ φ)) := rfl
/-- This is similar to one of the famous Segal maps, except valued in a product rather than a
pullback. -/
noncomputable def nerve₂.seagull (C : Type u) [Category C] :
(nerveFunctor₂.obj (Cat.of C)).obj (op ⦋2⦌₂) ⟶
(nerveFunctor₂.obj (Cat.of C)).obj (op ⦋1⦌₂) ⨯ (nerveFunctor₂.obj (Cat.of C)).obj (op ⦋1⦌₂) :=
prod.lift
((nerveFunctor₂.obj (Cat.of C)).map (.op δ2₂)) ((nerveFunctor₂.obj (Cat.of C)).map (.op δ0₂))
instance (C : Type u) [Category C] : Mono (nerve₂.seagull C) where
right_cancellation {X} (f g : X → ComposableArrows C 2) eq := by
ext x
simp only [nerve₂.seagull, prod.comp_lift] at eq
have eq1 := congr($eq ≫ prod.fst)
have eq2 := congr($eq ≫ prod.snd)
simp only [limit.lift_π, BinaryFan.mk_fst, BinaryFan.mk_snd] at eq1 eq2
replace eq1 := congr_fun eq1 x
replace eq2 := congr_fun eq2 x
simp only [types_comp_apply] at eq1 eq2
generalize f x = fx at *
generalize g x = gx at *
fapply ComposableArrows.ext₂
· exact congrArg (·.obj 0) <| eq1
· exact congrArg (·.obj 1) <| eq1
· exact congrArg (·.obj 1) <| eq2
· exact (conj_eqToHom_iff_heq' _ _ _ _).2 (congr_arg_heq (·.hom) <| eq1)
· exact (conj_eqToHom_iff_heq' _ _ _ _).2 (congr_arg_heq (·.hom) <| eq2)
/-- Naturality of the components defined by `toNerve₂.mk.app` as a morphism property of
maps in `SimplexCategory.Truncated 2`. -/
abbrev toNerve₂.mk.naturalityProperty : MorphismProperty (SimplexCategory.Truncated 2) :=
(MorphismProperty.naturalityProperty (fun n => toNerve₂.mk.app F n.unop)).unop
lemma ReflPrefunctor.congr_mk₁_map
{Y : Type u'} [ReflQuiver.{v'} Y] {C : Type u} [Category.{v} C]
(F : ReflPrefunctor Y (ReflQuiv.of C))
{x₁ y₁ x₂ y₂ : Y} (f : x₁ ⟶ y₁) (g : x₂ ⟶ y₂)
(hx : x₁ = x₂) (hy : y₁ = y₂) (hfg : Quiver.homOfEq f hx hy = g) :
ComposableArrows.mk₁ (C := C) (F.map f) = ComposableArrows.mk₁ (C := C) (F.map g) := by
subst hx hy hfg; rfl
lemma toNerve₂.mk_naturality_σ00 : toNerve₂.mk.naturalityProperty F (σ₂ (n := 0) 0) := by
ext x
refine Eq.trans ?_ (nerve.σ₀_mk₀_eq (C := C) (F.obj x)).symm
have := ReflPrefunctor.map_id F x
dsimp at this ⊢
rw [← this, ← OneTruncation₂.id_edge x]
fapply ReflPrefunctor.congr_mk₁_map
· simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· aesop
lemma toNerve₂.mk_naturality_δ0i (i : Fin 2) : toNerve₂.mk.naturalityProperty F (δ₂ i) := by
ext x
apply ComposableArrows.ext₀
fin_cases i <;> rfl
section
variable
(hyp : ∀ φ, F.map (ev02₂ φ) = CategoryStruct.comp (obj := C) (F.map (ev01₂ φ)) (F.map (ev12₂ φ)))
include hyp
lemma toNerve₂.mk_naturality_δ1i (i : Fin 3) : toNerve₂.mk.naturalityProperty F (δ₂ i) := by
ext x
simp only [types_comp_apply]
rw [toNerve₂.mk.app_one]
unfold nerveFunctor₂ truncation SimplicialObject.truncation
simp only [comp_obj, nerveFunctor_obj, Cat.of_α, whiskeringLeft_obj_obj, op_obj,
nerve_obj, oneTruncation₂_obj, ReflQuiv.of_val, Nat.reduceAdd, mk.app_two,
Functor.comp_map, op_map, Quiver.Hom.unop_op]
unfold δ₂ inclusion
simp only [ObjectProperty.ι_map]
fin_cases i
· simp only [Fin.zero_eta]
change _ = (nerve C).δ 0 _
rw [nerve.δ₀_mk₂_eq]
fapply ReflPrefunctor.congr_mk₁_map
· unfold ev1₂ ι1₂ δ₂
simp only [← FunctorToTypes.map_comp_apply, ← op_comp]
have := δ_comp_δ (n := 0) (i := 0) (j := 1) (by decide)
dsimp at this
exact congrFun (congrArg X.map (congrArg Quiver.Hom.op this.symm)) x
· unfold ev2₂ ι2₂ δ₂
simp only [← FunctorToTypes.map_comp_apply, ← op_comp]
have := δ_comp_δ (n := 0) (i := 0) (j := 0) (by decide)
dsimp at this
exact congrFun (congrArg X.map (congrArg Quiver.Hom.op this.symm)) x
· aesop
· simp only [Fin.mk_one]
change _ = (nerve C).δ 1 _
rw [nerve.δ₁_mk₂_eq]
rw [← hyp]
fapply ReflPrefunctor.congr_mk₁_map
· unfold ev0₂ ι0₂ δ₂
simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· unfold ev2₂ ι2₂ δ₂
simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· aesop
· simp only [Fin.reduceFinMk]
change _ = (nerve C).δ 2 _
rw [nerve.δ₂_mk₂_eq]
fapply ReflPrefunctor.congr_mk₁_map
· unfold ev0₂ ι0₂ δ₂
simp only [← FunctorToTypes.map_comp_apply, ← op_comp]
have := δ_comp_δ (n := 0) (i := 1) (j := 1) (by decide)
dsimp at this
exact congrFun (congrArg X.map (congrArg Quiver.Hom.op this)) x
· unfold ev1₂ ι1₂ δ₂
simp [← FunctorToTypes.map_comp_apply, ← op_comp]
· aesop
lemma toNerve₂.mk_naturality_σ1i (i : Fin 2) : toNerve₂.mk.naturalityProperty F (σ₂ i) := by
apply (cancel_mono (nerve₂.seagull _)).1
simp only [nerve₂.seagull, prod.comp_lift, assoc]
congr 1 <;> rw [← map_comp, ← op_comp]
· unfold δ2₂
rw [← toNerve₂.mk_naturality_δ1i F hyp, ← assoc, ← map_comp, ← op_comp]
change toNerve₂.mk.naturalityProperty F (δ₂ 2 ≫ σ₂ i)
fin_cases i
· dsimp only [Fin.zero_eta]
rw [δ₂_two_comp_σ₂_zero]
exact (toNerve₂.mk.naturalityProperty F).comp_mem _ _
(toNerve₂.mk_naturality_σ00 F) (toNerve₂.mk_naturality_δ0i F _)
· dsimp only [Fin.mk_one]
rw [δ₂_two_comp_σ₂_one]
exact (toNerve₂.mk.naturalityProperty F).id_mem _
· unfold δ0₂
rw [← toNerve₂.mk_naturality_δ1i F hyp, ← assoc, ← map_comp, ← op_comp]
change toNerve₂.mk.naturalityProperty F (δ₂ 0 ≫ σ₂ i)
fin_cases i <;> dsimp only [Fin.zero_eta, Fin.isValue, Fin.mk_one]
· rw [δ₂_zero_comp_σ₂_zero]
exact (toNerve₂.mk.naturalityProperty F).id_mem _
· rw [δ₂_zero_comp_σ₂_one]
exact (toNerve₂.mk.naturalityProperty F).comp_mem _ _
(toNerve₂.mk_naturality_σ00 F) (toNerve₂.mk_naturality_δ0i F _)
/-- A proof that the components defined by `toNerve₂.mk.app` are natural. -/
theorem toNerve₂.mk_naturality : toNerve₂.mk.naturalityProperty F = ⊤ :=
Truncated.morphismProperty_eq_top (toNerve₂.mk.naturalityProperty F)
(fun
| 0, _, _ => toNerve₂.mk_naturality_δ0i F _
| 1, _, _ => toNerve₂.mk_naturality_δ1i F hyp _)
(fun
| 0, _, 0 => toNerve₂.mk_naturality_σ00 F
| 1, _, _ => toNerve₂.mk_naturality_σ1i F hyp _)
/-- The morphism `X ⟶ nerveFunctor₂.obj (Cat.of C)` of 2-truncated simplicial sets that is
constructed from a refl prefunctor `F : SSet.oneTruncation₂.obj X ⟶ ReflQuiv.of C` assuming
`∀ (φ : : X _⦋2⦌₂), F.map (ev02₂ φ) = F.map (ev01₂ φ) ≫ F.map (ev12₂ φ)`. -/
@[simps!]
def toNerve₂.mk : X ⟶ nerveFunctor₂.obj (Cat.of C) where
app n := toNerve₂.mk.app F n.unop
naturality _ _ f := MorphismProperty.of_eq_top (toNerve₂.mk_naturality F hyp) f.unop
end
section
variable (F : SSet.oneTruncation₂.obj X ⟶ SSet.oneTruncation₂.obj (nerveFunctor₂.obj (Cat.of C)))
variable (hyp : (φ : X _⦋2⦌₂) →
(F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom).map (ev02₂ φ) =
CategoryStruct.comp (obj := C)
((F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom).map (ev01₂ φ))
((F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom).map (ev12₂ φ)))
/-- An alternate version of `toNerve₂.mk`, which constructs a map of 2-truncated simplicial sets
`X ⟶ nerveFunctor₂.obj (Cat.of C)` from the underlying refl prefunctor under a composition
hypothesis, where that prefunctor the central hypothesis is conjugated by the isomorphism
`nerve₂Adj.NatIso.app C`. -/
@[simps!] def toNerve₂.mk' : X ⟶ nerveFunctor₂.obj (Cat.of C) :=
toNerve₂.mk (F ≫ (OneTruncation₂.ofNerve₂.natIso.app (Cat.of C)).hom) hyp
/-- A computation about `toNerve₂.mk'`. -/
theorem oneTruncation₂_toNerve₂Mk' : oneTruncation₂.map (toNerve₂.mk' F hyp) = F := by
refine ReflPrefunctor.ext (fun _ ↦ ComposableArrows.ext₀ rfl)
(fun X Y g ↦ eq_of_heq (heq_eqRec_iff_heq.2 <| heq_eqRec_iff_heq.2 ?_))
simp [oneTruncation₂]
refine Quiver.heq_of_homOfEq_ext ?_ ?_ (f' := F.map g) ?_
· exact ComposableArrows.ext₀ rfl
· exact ComposableArrows.ext₀ rfl
· apply OneTruncation₂.Hom.ext
simp only [oneTruncation₂_obj, ReflQuiv.of_val, OneTruncation₂.homOfEq_edge]
fapply ComposableArrows.ext₁ <;> simp [ReflQuiv.comp_eq_comp]
· rw [g.src_eq]; exact congr_arg (·.obj 0) (F.map g).src_eq.symm
· rw [g.tgt_eq]; exact congr_arg (·.obj 1) (F.map g).tgt_eq.symm
· refine (conj_eqToHom_iff_heq' _ _ _ _).2 ?_
simp [OneTruncation₂.nerveHomEquiv]
obtain ⟨g, rfl, rfl⟩ := g
rfl
end
/-- An equality between maps into the 2-truncated nerve is detected by an equality between their
underlying refl prefunctors. -/
theorem toNerve₂.ext (F G : X ⟶ nerveFunctor₂.obj (Cat.of C))
(hyp : SSet.oneTruncation₂.map F = SSet.oneTruncation₂.map G) : F = G := by
have eq₀ (x : X _⦋0⦌₂) : F.app (op ⦋0⦌₂) x = G.app (op ⦋0⦌₂) x := congr(($hyp).obj x)
have eq₁ (x : X _⦋1⦌₂) : F.app (op ⦋1⦌₂) x = G.app (op ⦋1⦌₂) x :=
congr((($hyp).map ⟨x, rfl, rfl⟩).1)
ext ⟨⟨n, hn⟩⟩ x
induction n using SimplexCategory.rec with | _ n
match n with
| 0 => apply eq₀
| 1 => apply eq₁
| 2 =>
apply Functor.hext (fun i : Fin 3 => ?_) (fun (i j : Fin 3) k => ?_)
· let pt : ⦋0⦌₂ ⟶ ⦋2⦌₂ := SimplexCategory.const _ _ i
refine congr(($(F.naturality pt.op) x).obj 0).symm.trans ?_
refine .trans ?_ congr(($(G.naturality pt.op) x).obj 0)
exact congr($(eq₀ _).obj 0)
· let ar : ⦋1⦌₂ ⟶ ⦋2⦌₂ := mkOfLe _ _ k.le
have h1 := congr_arg_heq (fun x => x.map' 0 1) (congr_fun (F.naturality (op ar)) x)
have h2 := congr_arg_heq (fun x => x.map' 0 1) (congr_fun (G.naturality (op ar)) x)
exact h1.symm.trans <| .trans (congr_arg_heq (fun x => x.map' 0 1) (eq₁ _)) h2
/-- The components of the 2-truncated nerve adjunction unit. -/
def nerve₂Adj.unit.app (X : SSet.Truncated.{u} 2) :
X ⟶ nerveFunctor₂.obj (hoFunctor₂.obj X) := by
fapply toNerve₂.mk' (C := hoFunctor₂.obj X)
· exact (ReflQuiv.adj.{u}.unit.app (SSet.oneTruncation₂.obj X) ⋙rq
(SSet.Truncated.HomotopyCategory.quotientFunctor X).toReflPrefunctor ⋙rq
(OneTruncation₂.ofNerve₂.natIso).inv.app (hoFunctor₂.obj X))
· exact fun φ ↦ Quotient.sound _ (HoRel₂.mk φ)
theorem nerve₂Adj.unit.map_app_eq (X : SSet.Truncated.{u} 2) :
SSet.oneTruncation₂.map (nerve₂Adj.unit.app X) =
ReflQuiv.adj.{u}.unit.app (SSet.oneTruncation₂.obj X) ⋙rq
(SSet.Truncated.HomotopyCategory.quotientFunctor X).toReflPrefunctor ⋙rq
(OneTruncation₂.ofNerve₂.natIso).inv.app (hoFunctor₂.obj X) := by
apply oneTruncation₂_toNerve₂Mk'
@[reassoc]
lemma nerve₂Adj.unit.naturality {X Y : SSet.Truncated.{u} 2} (f : X ⟶ Y) :
f ≫ unit.app Y = unit.app X ≫ nerveFunctor₂.map (hoFunctor₂.map f) :=
toNerve₂.ext _ _ (by
have := (OneTruncation₂.ofNerve₂.natIso).inv.naturality (hoFunctor₂.map f)
dsimp at this ⊢
rw [Functor.map_comp, Functor.map_comp, nerve₂Adj.unit.map_app_eq,
nerve₂Adj.unit.map_app_eq, ← ReflQuiv.comp_eq_comp (Y := ReflQuiv.of _),
← ReflQuiv.comp_eq_comp (Y := ReflQuiv.of _), assoc, ← this]
rfl)
/-- The 2-truncated nerve adjunction unit. -/
@[simps]
def nerve₂Adj.unit : 𝟭 (SSet.Truncated.{u} 2) ⟶ hoFunctor₂ ⋙ nerveFunctor₂ where
app := nerve₂Adj.unit.app
naturality _ _ _ := unit.naturality _
/-- The adjunction between the 2-truncated nerve functor and the 2-truncated homotopy category
functor. -/
nonrec def nerve₂Adj : hoFunctor₂.{u} ⊣ nerveFunctor₂ :=
Adjunction.mkOfUnitCounit {
unit := nerve₂Adj.unit
counit := nerve₂Adj.counit
left_triangle := by
ext X
apply HomotopyCategory.lift_unique'
dsimp
rw [Cat.comp_eq_comp, ← Functor.assoc]
dsimp only [hoFunctor₂]
rw [← hoFunctor₂_naturality (nerve₂Adj.unit.app X)]
dsimp
rw [nerve₂Adj.unit.map_app_eq X, Functor.assoc, id_comp]
change _ ⋙ (HomotopyCategory.quotientFunctor _ ⋙ nerve₂Adj.counit.app (hoFunctor₂.obj X)) = _
rw [nerve₂Adj.counit.app_eq]
dsimp
rw [← Cat.comp_eq_comp, ← assoc, ← Cat.freeRefl.map_comp, ReflQuiv.comp_eq_comp,
ReflPrefunctor.comp_assoc]
dsimp
rw [← ReflQuiv.comp_eq_comp, Iso.inv_hom_id_app, ReflQuiv.id_eq_id]
dsimp
rw [ReflPrefunctor.comp_id (V := hoFunctor₂.obj X), ← ReflQuiv.comp_eq_comp (Z := .of _),
Cat.freeRefl.map_comp, assoc]
have := ReflQuiv.adj.counit.naturality
(X := Cat.freeRefl.obj (ReflQuiv.of (OneTruncation₂ X)))
(Y := hoFunctor₂.obj X) (SSet.Truncated.HomotopyCategory.quotientFunctor X)
dsimp at this
rw [this]
apply Adjunction.left_triangle_components_assoc
right_triangle := by
refine NatTrans.ext (funext fun C ↦ ?_)
apply toNerve₂.ext
dsimp
simp only [id_comp, map_comp, oneTruncation₂_obj, map_id]
rw [nerve₂Adj.unit.map_app_eq, ReflPrefunctor.comp_assoc]
rw [← ReflQuiv.comp_eq_comp,
← ReflQuiv.comp_eq_comp (X := ReflQuiv.of _) (Y := ReflQuiv.of _),
assoc, assoc, ← Functor.comp_map, ← OneTruncation₂.ofNerve₂.natIso.inv.naturality]
conv => lhs; rhs; rw [← assoc]
change _ ≫ (ReflQuiv.forget.map _ ≫ ReflQuiv.forget.map _) ≫ _ = _
rw [← ReflQuiv.forget.map_comp]
dsimp
conv => lhs; rhs; lhs; rw [Cat.comp_eq_comp]
have : HomotopyCategory.quotientFunctor (nerveFunctor₂.obj C) ⋙ _ = _ :=
nerve₂Adj.counit.app_eq C
rw [this]
dsimp
rw [← assoc, Cat.comp_eq_comp, toReflPrefunctor.map_comp]
rw [← ReflQuiv.comp_eq_comp (X := ReflQuiv.of _) (Y := ReflQuiv.of _) (Z := ReflQuiv.of _)]
have := ReflQuiv.adj.unit.naturality (OneTruncation₂.ofNerve₂.natIso.hom.app C)
dsimp at this ⊢
rw [← assoc, ← this]
have := ReflQuiv.adj.right_triangle_components C
dsimp [ReflQuiv.forget] at this
simp [reassoc_of% this]
}
instance nerveFunctor₂.faithful : nerveFunctor₂.{u, u}.Faithful :=
Functor.Faithful.of_comp_iso
(G := oneTruncation₂) (H := ReflQuiv.forget) OneTruncation₂.ofNerve₂.natIso
instance nerveFunctor₂.full : nerveFunctor₂.{u, u}.Full where
map_surjective := by
intro X Y F
let uF := SSet.oneTruncation₂.map F
let uF' : X ⥤rq Y :=
OneTruncation₂.ofNerve₂.natIso.inv.app X ≫ uF ≫ OneTruncation₂.ofNerve₂.natIso.hom.app Y
have {a b c : X} (h : a ⟶ b) (k : b ⟶ c) :
uF'.map (h ≫ k) = uF'.map h ≫ uF'.map k := by
let hk := ComposableArrows.mk₂ h k
let Fh : ComposableArrows Y 1 := F.app (op ⦋1⦌₂) (.mk₁ h)
let Fk : ComposableArrows Y 1 := F.app (op ⦋1⦌₂) (.mk₁ k)
let Fhk' : ComposableArrows Y 1 := F.app (op ⦋1⦌₂) (.mk₁ (h ≫ k))
let Fhk : ComposableArrows Y 2 := F.app (op ⦋2⦌₂) hk
have lem0 := congr_arg_heq (·.map' 0 1) (congr_fun (F.naturality δ0₂.op) hk)
have lem1 := congr_arg_heq (·.map' 0 1) (congr_fun (F.naturality δ1₂.op) hk)
have lem2 := congr_arg_heq (·.map' 0 1) (congr_fun (F.naturality δ2₂.op) hk)
have eq0 : (nerveFunctor₂.obj X).map δ0₂.op hk = .mk₁ k := by
apply ComposableArrows.ext₁ rfl rfl
simp [nerveFunctor₂, SSet.truncation]
have eq2 : (nerveFunctor₂.obj X).map δ2₂.op hk = .mk₁ h := by
apply ComposableArrows.ext₁ (by rfl) (by rfl)
simp [nerveFunctor₂, SSet.truncation]; rfl
have eq1 : (nerveFunctor₂.obj X).map δ1₂.op hk = .mk₁ (h ≫ k) := by
apply ComposableArrows.ext₁ (by rfl) (by rfl)
simp [nerveFunctor₂, SSet.truncation]; rfl
dsimp at lem0 lem1 lem2
rw [eq0] at lem0
rw [eq1] at lem1
rw [eq2] at lem2
replace lem0 : uF'.map k ≍ Fhk.map' 1 2 := by
refine HEq.trans (b := Fk.map' 0 1) ?_ lem0
simp [uF', nerveFunctor₂, SSet.truncation,
ReflQuiv.comp_eq_comp, OneTruncation₂.nerveHomEquiv, Fk, uF]
replace lem2 : uF'.map h ≍ Fhk.map' 0 1 := by
refine HEq.trans (b := Fh.map' 0 1) ?_ lem2
simp [uF', nerveFunctor₂, SSet.truncation,
ReflQuiv.comp_eq_comp, OneTruncation₂.nerveHomEquiv, uF, ComposableArrows.hom, Fh]
replace lem1 : uF'.map (h ≫ k) ≍ Fhk.map' 0 2 := by
refine HEq.trans (b := Fhk'.map' 0 1) ?_ lem1
simp only [Nat.reduceAdd,
Fin.zero_eta, Fin.isValue, Fin.mk_one,
ComposableArrows.map', homOfLE_leOfHom, uF, uF']
simp [nerveFunctor₂, SSet.truncation,
ReflQuiv.comp_eq_comp, OneTruncation₂.nerveHomEquiv, ComposableArrows.hom, Fhk']
rw [Fhk.map'_comp 0 1 2] at lem1
refine eq_of_heq (lem1.trans (heq_comp ?_ ?_ ?_ lem2.symm lem0.symm)) <;>
simp [uF', nerveFunctor₂, SSet.truncation, ReflQuiv.comp_eq_comp, uF, Fhk] <;>
[let ι := ι0₂; let ι := ι1₂; let ι := ι2₂] <;>
· replace := congr_arg (·.obj 0) (congr_fun (F.naturality ι.op) hk)
dsimp [oneTruncation₂, ComposableArrows.left, SimplicialObject.truncation,
nerveFunctor₂, SSet.truncation, forget₂, HasForget₂.forget₂] at this ⊢
convert this.symm
apply ComposableArrows.ext₀; rfl
let fF : X ⥤ Y := ReflPrefunctor.toFunctor uF' this
have eq : fF.toReflPrefunctor = uF' := rfl
refine ⟨fF, toNerve₂.ext (nerveFunctor₂.{u,u}.map fF) F ?_⟩
· have nat := OneTruncation₂.ofNerve₂.natIso.hom.naturality fF
simp at nat
rw [eq] at nat
simp [uF', uF] at nat
exact (Iso.cancel_iso_hom_right (oneTruncation₂.map (nerveFunctor₂.map fF))
(oneTruncation₂.map F) (OneTruncation₂.ofNerve₂.natIso.app Y)).mp nat
/-- The 2-truncated nerve functor is both full and faithful and thus is fully faithful. -/
noncomputable def nerveFunctor₂.fullyfaithful : nerveFunctor₂.FullyFaithful :=
FullyFaithful.ofFullyFaithful nerveFunctor₂
instance nerve₂Adj.reflective : Reflective nerveFunctor₂.{u, u} :=
Reflective.mk hoFunctor₂ nerve₂Adj
end
/-- The adjunction between the nerve functor and the homotopy category functor is, up to
isomorphism, the composite of the adjunctions `SSet.coskAdj 2` and `nerve₂Adj`. -/
noncomputable def nerveAdjunction : hoFunctor ⊣ nerveFunctor :=
Adjunction.ofNatIsoRight ((SSet.coskAdj 2).comp nerve₂Adj) Nerve.cosk₂Iso.symm
/-- Repleteness exists for full and faithful functors but not fully faithful functors, which is
why we do this inefficiently. -/
instance nerveFunctor.faithful : nerveFunctor.{u, u}.Faithful :=
have : (Nerve.nerveFunctor₂ ⋙ SSet.Truncated.cosk 2).Faithful :=
Faithful.comp nerveFunctor₂ (SSet.Truncated.cosk 2)
Functor.Faithful.of_iso Nerve.cosk₂Iso.symm
instance nerveFunctor.full : nerveFunctor.{u, u}.Full :=
have : (Nerve.nerveFunctor₂ ⋙ SSet.Truncated.cosk 2).Full :=
Full.comp nerveFunctor₂ (SSet.Truncated.cosk 2)
Functor.Full.of_iso Nerve.cosk₂Iso.symm
/-- The nerve functor is both full and faithful and thus is fully faithful. -/
noncomputable def nerveFunctor.fullyfaithful : nerveFunctor.FullyFaithful :=
FullyFaithful.ofFullyFaithful nerveFunctor
instance nerveAdjunction.isIso_counit : IsIso nerveAdjunction.counit :=
Adjunction.counit_isIso_of_R_fully_faithful _
/-- The counit map of `nerveAdjunction` is an isomorphism since the nerve functor is fully
faithful. -/
noncomputable def nerveFunctorCompHoFunctorIso : nerveFunctor.{u, u} ⋙ hoFunctor ≅ 𝟭 Cat :=
asIso (nerveAdjunction.counit)
noncomputable instance : Reflective nerveFunctor where
L := hoFunctor
adj := nerveAdjunction
section
instance (C D : Type v) [Category.{v} C] [Category.{v} D] :
IsIso (prodComparison (nerveFunctor ⋙ hoFunctor ⋙ nerveFunctor)
(Cat.of C) (Cat.of D)) := by
let iso : nerveFunctor ⋙ hoFunctor ⋙ nerveFunctor ≅ nerveFunctor :=
(nerveFunctor.associator hoFunctor nerveFunctor).symm ≪≫
isoWhiskerRight nerveFunctorCompHoFunctorIso nerveFunctor ≪≫ nerveFunctor.leftUnitor
exact IsIso.of_isIso_fac_right (prodComparison_natural_of_natTrans iso.hom).symm
namespace hoFunctor
instance : hoFunctor.IsLeftAdjoint := nerveAdjunction.isLeftAdjoint
instance (C D : Type v) [Category.{v} C] [Category.{v} D] :
IsIso (prodComparison hoFunctor (nerve C) (nerve D)) := by
have : IsIso (nerveFunctor.map (prodComparison hoFunctor (nerve C) (nerve D))) := by
have : IsIso (prodComparison (hoFunctor ⋙ nerveFunctor) (nerve C) (nerve D)) :=
IsIso.of_isIso_fac_left
(prodComparison_comp nerveFunctor (hoFunctor ⋙ nerveFunctor)
(A := Cat.of C) (B := Cat.of D)).symm
exact IsIso.of_isIso_fac_right (prodComparison_comp hoFunctor nerveFunctor).symm
exact isIso_of_fully_faithful nerveFunctor _
instance isIso_prodComparison_stdSimplex.{w} (n m : ℕ) :
IsIso (prodComparison hoFunctor (Δ[n] : SSet.{w}) Δ[m]) :=
IsIso.of_isIso_fac_right (prodComparison_natural
hoFunctor (stdSimplex.isoNerve n).hom (stdSimplex.isoNerve m).hom).symm
attribute [local instance]
CartesianMonoidalCategory.isLeftAdjoint_prod_functor in
lemma isIso_prodComparison_of_stdSimplex {D : SSet.{u}} (X : SSet.{u})
(H : ∀ m, IsIso (prodComparison hoFunctor D Δ[m])) :
IsIso (prodComparison hoFunctor D X) := by
have : IsIso (whiskerLeft (CostructuredArrow.proj uliftYoneda X ⋙ uliftYoneda)
(prodComparisonNatTrans hoFunctor.{u} D)) := by
rw [NatTrans.isIso_iff_isIso_app]
exact fun x ↦ H (x.left).len
exact isIso_app_coconePt_of_preservesColimit _ (prodComparisonNatTrans hoFunctor _) _
(Presheaf.isColimitTautologicalCocone' X)
instance isIso_prodComparison (X Y : SSet) :
IsIso (prodComparison hoFunctor X Y) := isIso_prodComparison_of_stdSimplex _ fun m ↦ by
convert_to IsIso (hoFunctor.map (prod.braiding _ _).hom ≫
prodComparison hoFunctor Δ[m] X ≫ (prod.braiding _ _).hom)
· ext <;> simp [← Functor.map_comp]
suffices IsIso (prodComparison hoFunctor Δ[m] X) by infer_instance
exact isIso_prodComparison_of_stdSimplex _ (isIso_prodComparison_stdSimplex _)
/-- The functor `hoFunctor : SSet ⥤ Cat` preserves binary products of simplicial sets `X` and
`Y`. -/
instance preservesBinaryProduct (X Y : SSet) :
PreservesLimit (pair X Y) hoFunctor :=
PreservesLimitPair.of_iso_prod_comparison hoFunctor X Y
/-- The functor `hoFunctor : SSet ⥤ Cat` preserves limits of functors out of
`Discrete Limits.WalkingPair`. -/
instance preservesBinaryProducts :
PreservesLimitsOfShape (Discrete Limits.WalkingPair) hoFunctor where
preservesLimit {F} := preservesLimit_of_iso_diagram hoFunctor (diagramIsoPair F).symm
/-- The functor `hoFunctor : SSet ⥤ Cat` preserves finite products of simplicial sets. -/
instance preservesFiniteProducts : PreservesFiniteProducts hoFunctor :=
Limits.PreservesFiniteProducts.of_preserves_binary_and_terminal _
/-- The homotopy category functor `hoFunctor : SSet.{u} ⥤ Cat.{u, u}` is (cartesian) monoidal. -/
noncomputable instance Monoidal : Monoidal hoFunctor :=
Monoidal.ofChosenFiniteProducts hoFunctor
end hoFunctor
end
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean | import Mathlib.AlgebraicTopology.SimplicialSet.StdSimplex
import Mathlib.CategoryTheory.Subpresheaf.Equalizer
/-!
# Horns
This file introduces horns `Λ[n, i]`.
-/
universe u
open CategoryTheory Simplicial Opposite
namespace SSet
/-- `horn n i` (or `Λ[n, i]`) is the `i`-th horn of the `n`-th standard simplex,
where `i : n`. It consists of all `m`-simplices `α` of `Δ[n]`
for which the union of `{i}` and the range of `α` is not all of `n`
(when viewing `α` as monotone function `m → n`). -/
@[simps -isSimp obj]
def horn (n : ℕ) (i : Fin (n + 1)) : (Δ[n] : SSet.{u}).Subcomplex where
obj _ := setOf (fun s ↦ Set.range (stdSimplex.asOrderHom s) ∪ {i} ≠ Set.univ)
map φ s hs h := hs (by
rw [Set.eq_univ_iff_forall] at h ⊢; intro j
apply Or.imp _ id (h j)
intro hj
exact Set.range_comp_subset_range _ _ hj)
/-- The `i`-th horn `Λ[n, i]` of the standard `n`-simplex -/
scoped[Simplicial] notation3 "Λ[" n ", " i "]" => SSet.horn (n : ℕ) i
lemma horn_eq_iSup (n : ℕ) (i : Fin (n + 1)) :
horn.{u} n i =
⨆ (j : ({i}ᶜ : Set (Fin (n + 1)))), stdSimplex.face {j.1}ᶜ := by
ext m j
simp [stdSimplex.face_obj, horn, Set.eq_univ_iff_forall]
rfl
lemma face_le_horn {n : ℕ} (i j : Fin (n + 1)) (h : i ≠ j) :
stdSimplex.face.{u} {i}ᶜ ≤ horn n j := by
rw [horn_eq_iSup]
exact le_iSup (fun (k : ({j}ᶜ : Set (Fin (n + 1)))) ↦ stdSimplex.face.{u} {k.1}ᶜ) ⟨i, h⟩
@[simp]
lemma horn_obj_zero (n : ℕ) (i : Fin (n + 3)) :
(horn.{u} (n + 2) i).obj (op (.mk 0)) = ⊤ := by
ext j
-- this was produced using `simp? [horn_eq_iSup]`
simp only [horn_eq_iSup, Subpresheaf.iSup_obj, Set.iUnion_coe_set,
Set.mem_compl_iff, Set.mem_singleton_iff, Set.mem_iUnion, stdSimplex.mem_face_iff,
Nat.reduceAdd, Finset.mem_compl, Finset.mem_singleton, exists_prop, Set.top_eq_univ,
Set.mem_univ, iff_true]
let S : Finset (Fin (n + 3)) := {i, j 0}
have hS : ¬ (S = Finset.univ) := fun hS ↦ by
have := Finset.card_le_card hS.symm.le
simp only [Finset.card_univ, Fintype.card_fin, S] at this
have := this.trans Finset.card_le_two
cutsat
rw [Finset.eq_univ_iff_forall, not_forall] at hS
obtain ⟨k, hk⟩ := hS
simp only [Finset.mem_insert, Finset.mem_singleton, not_or, S] at hk
refine ⟨k, hk.1, fun a ↦ ?_⟩
fin_cases a
exact Ne.symm hk.2
namespace horn
open SimplexCategory Finset Opposite
section
variable (n : ℕ) (i k : Fin (n + 3))
/-- The (degenerate) subsimplex of `Λ[n+2, i]` concentrated in vertex `k`. -/
def const (m : SimplexCategoryᵒᵖ) : Λ[n+2, i].obj m :=
SSet.yonedaEquiv (X := Λ[n+2, i])
(SSet.const ⟨stdSimplex.obj₀Equiv.symm k, by simp⟩)
@[simp]
lemma const_val_apply {m : ℕ} (a : Fin (m + 1)) :
(const n i k (op (.mk m))).val a = k :=
rfl
end
/-- The edge of `Λ[n, i]` with endpoints `a` and `b`.
This edge only exists if `{i, a, b}` has cardinality less than `n`. -/
@[simps]
def edge (n : ℕ) (i a b : Fin (n + 1)) (hab : a ≤ b) (H : #{i, a, b} ≤ n) :
(Λ[n, i] : SSet.{u}) _⦋1⦌ :=
⟨stdSimplex.edge n a b hab, by
have hS : ¬ ({i, a, b} = Finset.univ) := fun hS ↦ by
have := Finset.card_le_card hS.symm.le
simp only [card_univ, Fintype.card_fin] at this
cutsat
rw [Finset.eq_univ_iff_forall, not_forall] at hS
obtain ⟨k, hk⟩ := hS
simp only [mem_insert, mem_singleton, not_or] at hk
-- this was produced by `simp? [horn_eq_iSup]`
simp only [horn_eq_iSup, Subpresheaf.iSup_obj, Set.iUnion_coe_set, Set.mem_compl_iff,
Set.mem_singleton_iff, Set.mem_iUnion, stdSimplex.mem_face_iff, Nat.reduceAdd, mem_compl,
mem_singleton, exists_prop]
refine ⟨k, hk.1, fun a ↦ ?_⟩
fin_cases a
· exact Ne.symm hk.2.1
· exact Ne.symm hk.2.2⟩
/-- Alternative constructor for the edge of `Λ[n, i]` with endpoints `a` and `b`,
assuming `3 ≤ n`. -/
@[simps!]
def edge₃ (n : ℕ) (i a b : Fin (n + 1)) (hab : a ≤ b) (H : 3 ≤ n) :
(Λ[n, i] : SSet.{u}) _⦋1⦌ :=
edge n i a b hab <| Finset.card_le_three.trans H
/-- The edge of `Λ[n, i]` with endpoints `j` and `j+1`.
This constructor assumes `0 < i < n`,
which is the type of horn that occurs in the horn-filling condition of quasicategories. -/
@[simps!]
def primitiveEdge {n : ℕ} {i : Fin (n + 1)}
(h₀ : 0 < i) (hₙ : i < Fin.last n) (j : Fin n) :
(Λ[n, i] : SSet.{u}) _⦋1⦌ := by
refine edge n i j.castSucc j.succ ?_ ?_
· simp only [← Fin.val_fin_le, Fin.coe_castSucc, Fin.val_succ, le_add_iff_nonneg_right, zero_le]
simp only [← Fin.val_fin_lt, Fin.val_zero, Fin.val_last] at h₀ hₙ
obtain rfl | hn : n = 2 ∨ 2 < n := by
rw [eq_comm, or_comm, ← le_iff_lt_or_eq]; cutsat
· revert i j; decide
· exact Finset.card_le_three.trans hn
/-- The triangle in the standard simplex with vertices `k`, `k+1`, and `k+2`.
This constructor assumes `0 < i < n`,
which is the type of horn that occurs in the horn-filling condition of quasicategories. -/
@[simps]
def primitiveTriangle {n : ℕ} (i : Fin (n + 4))
(h₀ : 0 < i) (hₙ : i < Fin.last (n + 3))
(k : ℕ) (h : k < n + 2) : (Λ[n+3, i] : SSet.{u}) _⦋2⦌ := by
refine ⟨stdSimplex.triangle
(n := n+3) ⟨k, by cutsat⟩ ⟨k+1, by cutsat⟩ ⟨k+2, by cutsat⟩ ?_ ?_, ?_⟩
· simp only [Fin.mk_le_mk, le_add_iff_nonneg_right, zero_le]
· simp only [Fin.mk_le_mk, add_le_add_iff_left, one_le_two]
-- this was produced using `simp? [horn_eq_iSup]`
simp only [horn_eq_iSup, Subpresheaf.iSup_obj, Set.iUnion_coe_set,
Set.mem_compl_iff, Set.mem_singleton_iff, Set.mem_iUnion, stdSimplex.mem_face_iff,
Nat.reduceAdd, mem_compl, mem_singleton, exists_prop]
have hS : ¬ ({i, (⟨k, by cutsat⟩ : Fin (n + 4)), (⟨k + 1, by cutsat⟩ : Fin (n + 4)),
(⟨k + 2, by cutsat⟩ : Fin (n + 4))} = Finset.univ) := fun hS ↦ by
obtain ⟨i, hi⟩ := i
by_cases hk : k = 0
· subst hk
have := Finset.mem_univ (Fin.last _ : Fin (n + 4))
rw [← hS] at this
-- this was produced using `simp? [Fin.ext_iff] at this`
simp only [Fin.zero_eta, zero_add, Fin.mk_one, mem_insert, Fin.ext_iff, Fin.val_last,
Fin.val_zero, AddLeftCancelMonoid.add_eq_zero, OfNat.ofNat_ne_zero, and_false,
Fin.val_one, Nat.reduceEqDiff, mem_singleton, or_self, or_false] at this
simp only [Fin.lt_iff_val_lt_val, Fin.val_last] at hₙ
cutsat
· have := Finset.mem_univ (0 : Fin (n + 4))
rw [← hS] at this
-- this was produced using `simp? [Fin.ext_iff] at this`
simp only [mem_insert, Fin.ext_iff, Fin.val_zero, right_eq_add,
AddLeftCancelMonoid.add_eq_zero, one_ne_zero, and_false, mem_singleton,
OfNat.ofNat_ne_zero, or_self, or_false] at this
obtain rfl | rfl := this <;> tauto
rw [Finset.eq_univ_iff_forall, not_forall] at hS
obtain ⟨l, hl⟩ := hS
simp only [mem_insert, mem_singleton, not_or] at hl
refine ⟨l, hl.1, fun a ↦ ?_⟩
fin_cases a
· exact Ne.symm hl.2.1
· exact Ne.symm hl.2.2.1
· exact Ne.symm hl.2.2.2
/-- The `j`th face of codimension `1` of the `i`-th horn. -/
def face {n : ℕ} (i j : Fin (n + 2)) (h : j ≠ i) : (Λ[n + 1, i] : SSet.{u}) _⦋n⦌ :=
yonedaEquiv (Subpresheaf.lift (stdSimplex.δ j) (by
simpa using face_le_horn _ _ h))
/-- Two morphisms from a horn are equal if they are equal on all suitable faces. -/
protected
lemma hom_ext {n : ℕ} {i : Fin (n + 2)} {S : SSet} (σ₁ σ₂ : (Λ[n + 1, i] : SSet.{u}) ⟶ S)
(h : ∀ (j) (h : j ≠ i), σ₁.app _ (face i j h) = σ₂.app _ (face i j h)) :
σ₁ = σ₂ := by
rw [← Subpresheaf.equalizer_eq_iff]
apply le_antisymm (Subpresheaf.equalizer_le σ₁ σ₂)
simp only [horn_eq_iSup, iSup_le_iff,
Subtype.forall, Set.mem_compl_iff, Set.mem_singleton_iff,
← stdSimplex.ofSimplex_yonedaEquiv_δ, Subcomplex.ofSimplex_le_iff]
intro j hj
exact (Subpresheaf.mem_equalizer_iff σ₁ σ₂ (face i j hj)).2 (by apply h)
end horn
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/CategoryWithFibrations.lean | import Mathlib.AlgebraicTopology.ModelCategory.CategoryWithCofibrations
import Mathlib.AlgebraicTopology.SimplicialSet.Boundary
import Mathlib.AlgebraicTopology.SimplicialSet.Horn
import Mathlib.CategoryTheory.MorphismProperty.LiftingProperty
/-!
# Cofibrations and fibrations in the category of simplicial sets
We endow `SSet` with `CategoryWithCofibrations` and `CategoryWithFibrations`
instances. Cofibrations are monomorphisms, and fibrations are morphisms
having the right lifting property with respect to horn inclusions.
We have an instance `mono_of_cofibration` (but only a lemma `cofibration_of_mono`).
Then, when stating lemmas about cofibrations of simplicial sets, it is advisable
to use the assumption `[Mono f]` instead of `[Cofibration f]`.
-/
open CategoryTheory HomotopicalAlgebra MorphismProperty Simplicial
universe u
namespace SSet
namespace modelCategoryQuillen
/-- The generating cofibrations: this is the family of morphisms in `SSet`
which consists of boundary inclusions `∂Δ[n].ι : ∂Δ[n] ⟶ Δ[n]`. -/
def I : MorphismProperty SSet.{u} :=
.ofHoms (fun n ↦ ∂Δ[n].ι)
lemma boundary_ι_mem_I (n : ℕ) :
I (boundary.{u} n).ι := by constructor
/-- The generating trivial cofibrations: this is the family of morphisms in `SSet`
which consists of horn inclusions `Λ[n, i].ι : Λ[n, i] ⟶ Δ[n]` (for positive `n`). -/
def J : MorphismProperty SSet.{u} :=
⨆ n, .ofHoms (fun (i : Fin (n + 2)) ↦ Λ[n + 1, i].ι)
lemma horn_ι_mem_J (n : ℕ) (i : Fin (n + 2)) :
J (horn.{u} (n + 1) i).ι := by
simp only [J, iSup_iff]
exact ⟨n, ⟨i⟩⟩
lemma I_le_monomorphisms : I.{u} ≤ monomorphisms _ := by
rintro _ _ _ ⟨n⟩
exact monomorphisms.infer_property _
lemma J_le_monomorphisms : J.{u} ≤ monomorphisms _ := by
rintro _ _ _ h
simp only [J, iSup_iff] at h
obtain ⟨n, ⟨i⟩⟩ := h
exact monomorphisms.infer_property _
/-- The cofibrations for the Quillen model category structure (TODO)
on `SSet` are monomorphisms. -/
scoped instance : CategoryWithCofibrations SSet.{u} where
cofibrations := .monomorphisms _
/-- The fibrations for the Quillen model category structure (TODO)
on `SSet` are the morphisms which have the right lifting property
with respect to horn inclusions. -/
scoped instance : CategoryWithFibrations SSet.{u} where
fibrations := J.rlp
lemma cofibrations_eq : cofibrations SSet.{u} = monomorphisms _ := rfl
lemma fibrations_eq : fibrations SSet.{u} = J.rlp := rfl
section
variable {X Y : SSet.{u}} (f : X ⟶ Y)
lemma cofibration_iff : Cofibration f ↔ Mono f := by
rw [HomotopicalAlgebra.cofibration_iff]
rfl
lemma fibration_iff : Fibration f ↔ J.rlp f := by
rw [HomotopicalAlgebra.fibration_iff]
rfl
instance mono_of_cofibration [Cofibration f] : Mono f := by rwa [← cofibration_iff]
lemma cofibration_of_mono [Mono f] : Cofibration f := by rwa [cofibration_iff]
instance [hf : Fibration f] {n : ℕ} (i : Fin (n + 2)) :
HasLiftingProperty (horn (n + 1) i).ι f := by
rw [fibration_iff] at hf
exact hf _ (horn_ι_mem_J _ _)
end
end modelCategoryQuillen
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/StrictSegal.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Nerve
import Mathlib.AlgebraicTopology.SimplicialSet.Path
/-!
# Strict Segal simplicial sets
A simplicial set `X` satisfies the `StrictSegal` condition if for all `n`, the map
`X.spine n : X _⦋n⦌ → X.Path n` is an equivalence, with equivalence inverse
`spineToSimplex {n : ℕ} : Path X n → X _⦋n⦌`.
Examples of `StrictSegal` simplicial sets are given by nerves of categories.
TODO: Show that these are the only examples: that a `StrictSegal` simplicial set is isomorphic to
the nerve of its homotopy category.
`StrictSegal` simplicial sets have an important property of being 2-coskeletal which is proven
in `Mathlib/AlgebraicTopology/SimplicialSet/Coskeletal.lean`.
-/
universe v u
open CategoryTheory Simplicial SimplexCategory
namespace SSet
namespace Truncated
open Opposite SimplexCategory.Truncated Truncated.Hom SimplicialObject.Truncated
variable {n : ℕ} (X : SSet.Truncated.{u} (n + 1))
/-- An `n + 1`-truncated simplicial set satisfies the strict Segal condition if
its `m`-simplices are uniquely determined by their spine for all `m ≤ n + 1`. -/
structure StrictSegal where
/-- The inverse to `spine X m`. -/
spineToSimplex (m : ℕ) (h : m ≤ n + 1 := by omega) : Path X m → X _⦋m⦌ₙ₊₁
/-- `spineToSimplex` is a right inverse to `spine X m`. -/
spine_spineToSimplex (m : ℕ) (h : m ≤ n + 1) :
spine X m ∘ spineToSimplex m = id
/-- `spineToSimplex` is a left inverse to `spine X m`. -/
spineToSimplex_spine (m : ℕ) (h : m ≤ n + 1) :
spineToSimplex m ∘ spine X m = id
/-- For an `n + 1`-truncated simplicial set `X`, `IsStrictSegal X` asserts the
mere existence of an inverse to `spine X m` for all `m ≤ n + 1`. -/
class IsStrictSegal (X : SSet.Truncated.{u} (n + 1)) : Prop where
spine_bijective (X) (m : ℕ) (h : m ≤ n + 1 := by grind) : Function.Bijective (X.spine m)
export IsStrictSegal (spine_bijective)
@[deprecated (since := "2025-11-04")] alias IsStrictSegal.segal := spine_bijective
lemma spine_injective (X : SSet.Truncated.{u} (n + 1)) [X.IsStrictSegal]
{m : ℕ} {h : m ≤ n + 1} :
Function.Injective (X.spine m) :=
(spine_bijective X m).injective
lemma spine_surjective (X : SSet.Truncated.{u} (n + 1)) [X.IsStrictSegal]
{m : ℕ} (p : X.Path m) (h : m ≤ n + 1 := by grind) :
∃ (x : X _⦋m⦌ₙ₊₁), X.spine m _ x = p :=
(spine_bijective X m).surjective p
variable {X} in
lemma IsStrictSegal.ext [X.IsStrictSegal] {d : ℕ} {hd} {x y : X _⦋d + 1⦌ₙ₊₁}
(h : ∀ (i : Fin (d + 1)),
X.map (SimplexCategory.Truncated.Hom.tr (mkOfSucc i)).op x =
X.map (SimplexCategory.Truncated.Hom.tr (mkOfSucc i)).op y) :
x = y :=
X.spine_injective (by ext i; apply h)
variable {X} in
lemma IsStrictSegal.hom_ext {Y : SSet.Truncated.{u} (n + 1)} [Y.IsStrictSegal]
{f g : X ⟶ Y} (h : ∀ (x : X _⦋1⦌ₙ₊₁), f.app _ x = g.app _ x) : f = g := by
ext ⟨⟨m, hm⟩⟩ x
induction m using SimplexCategory.rec with | _ m
obtain _ | m := m
· have fac := δ_comp_σ_self (i := (0 : Fin 1))
dsimp at fac
simpa [← FunctorToTypes.naturality,
← FunctorToTypes.map_comp_apply, ← op_comp,
← SimplexCategory.Truncated.Hom.tr_comp, fac] using
congr_arg (Y.map (SimplexCategory.Truncated.Hom.tr (SimplexCategory.δ 0)).op)
(h (X.map (SimplexCategory.Truncated.Hom.tr (SimplexCategory.σ 0)).op x))
· exact IsStrictSegal.ext (fun i ↦ by simp only [← FunctorToTypes.naturality, h])
namespace StrictSegal
/-- Given `IsStrictSegal X`, a choice of inverse to `spine X m` for all
`m ≤ n + 1` determines an inhabitant of `StrictSegal X`. -/
noncomputable def ofIsStrictSegal [IsStrictSegal X] : StrictSegal X where
spineToSimplex m h :=
Equiv.ofBijective (X.spine m) (X.spine_bijective m h) |>.invFun
spine_spineToSimplex m _ :=
funext <| Equiv.ofBijective (X.spine m) _ |>.right_inv
spineToSimplex_spine m _ :=
funext <| Equiv.ofBijective (X.spine m) _ |>.left_inv
variable {X} (sx : StrictSegal X)
section spineToSimplex
@[simp]
lemma spine_spineToSimplex_apply (m : ℕ) (h : m ≤ n + 1) (f : Path X m) :
X.spine m h (sx.spineToSimplex m h f) = f :=
congr_fun (sx.spine_spineToSimplex m h) f
@[simp]
lemma spineToSimplex_spine_apply (m : ℕ) (h : m ≤ n + 1) (Δ : X _⦋m⦌ₙ₊₁) :
sx.spineToSimplex m h (X.spine m h Δ) = Δ :=
congr_fun (sx.spineToSimplex_spine m h) Δ
section autoParam
variable (m : ℕ) (h : m ≤ n + 1 := by omega)
/-- The fields of `StrictSegal` define an equivalence between `X _⦋m⦌ₙ₊₁`
and `Path X m`. -/
def spineEquiv : X _⦋m⦌ₙ₊₁ ≃ Path X m where
toFun := X.spine m
invFun := sx.spineToSimplex m h
left_inv := sx.spineToSimplex_spine_apply m h
right_inv := sx.spine_spineToSimplex_apply m h
theorem spineInjective : Function.Injective (sx.spineEquiv m h) :=
Equiv.injective _
/-- In the presence of the strict Segal condition, a path of length `m` can be
"composed" by taking the diagonal edge of the resulting `m`-simplex. -/
def spineToDiagonal : Path X m → X _⦋1⦌ₙ₊₁ :=
X.map (tr (diag m)).op ∘ sx.spineToSimplex m h
end autoParam
/-- The unique existence of an inverse to `spine X m` for all `m ≤ n + 1`
implies the mere existence of such an inverse. -/
lemma isStrictSegal (sx : StrictSegal X) : IsStrictSegal X where
spine_bijective m h := sx.spineEquiv m h |>.bijective
variable (m : ℕ) (h : m ≤ n + 1)
@[simp]
theorem spineToSimplex_vertex (i : Fin (m + 1)) (f : Path X m) :
X.map (tr (SimplexCategory.const ⦋0⦌ ⦋m⦌ i)).op (sx.spineToSimplex m h f) =
f.vertex i := by
rw [← spine_vertex, spine_spineToSimplex_apply]
@[simp]
theorem spineToSimplex_arrow (i : Fin m) (f : Path X m) :
X.map (tr (mkOfSucc i)).op (sx.spineToSimplex m h f) = f.arrow i := by
rw [← spine_arrow, spine_spineToSimplex_apply]
@[simp]
theorem spineToSimplex_interval (f : Path X m) (j l : ℕ) (hjl : j + l ≤ m) :
X.map (tr (subinterval j l hjl)).op (sx.spineToSimplex m h f) =
sx.spineToSimplex l _ (f.interval j l hjl) := by
apply sx.spineInjective l
dsimp only [spineEquiv, Equiv.coe_fn_mk]
rw [spine_spineToSimplex_apply]
convert spine_map_subinterval X m h j l hjl <| sx.spineToSimplex m h f
exact sx.spine_spineToSimplex_apply m h f |>.symm
theorem spineToSimplex_edge (f : Path X m) (j l : ℕ) (hjl : j + l ≤ m) :
X.map (tr (intervalEdge j l hjl)).op (sx.spineToSimplex m h f) =
sx.spineToDiagonal l (by cutsat) (f.interval j l hjl) := by
dsimp only [spineToDiagonal, Function.comp_apply]
rw [← spineToSimplex_interval, ← FunctorToTypes.map_comp_apply, ← op_comp,
← tr_comp, diag_subinterval_eq]
end spineToSimplex
/-- For any `σ : X ⟶ Y` between `n + 1`-truncated `StrictSegal` simplicial sets,
`spineToSimplex` commutes with `Path.map`. -/
lemma spineToSimplex_map {X Y : SSet.Truncated.{u} (n + 1)} (sx : StrictSegal X)
(sy : StrictSegal Y) (m : ℕ) (h : m ≤ n) (f : Path X (m + 1)) (σ : X ⟶ Y) :
sy.spineToSimplex (m + 1) _ (f.map σ) =
σ.app (op ⦋m + 1⦌ₙ₊₁) (sx.spineToSimplex (m + 1) _ f) := by
apply sy.spineInjective (m + 1)
ext k
dsimp only [spineEquiv, Equiv.coe_fn_mk, spine_arrow]
rw [← types_comp_apply (σ.app _) (Y.map _), ← σ.naturality]
simp
section spine_δ
variable (m : ℕ) (h : m ≤ n) (f : Path X (m + 1))
variable {i : Fin (m + 1)} {j : Fin (m + 2)}
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
the common vertices will agree with those of the original path `f`. In particular,
a vertex `i` with `i < j` can be identified with the same vertex in `f`. -/
lemma spine_δ_vertex_lt (hij : i.castSucc < j) :
(X.spine m _ (X.map (tr (δ j)).op
(sx.spineToSimplex (m + 1) _ f))).vertex i = f.vertex i.castSucc := by
rw [spine_vertex, ← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
SimplexCategory.const_comp, spineToSimplex_vertex]
dsimp only [δ, len_mk, mkHom, Hom.toOrderHom_mk, Fin.succAboveOrderEmb_apply,
OrderEmbedding.toOrderHom_coe]
rw [Fin.succAbove_of_castSucc_lt j i hij]
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
a vertex `i` with `j ≤ i` can be identified with vertex `i + 1` in the original
path. -/
lemma spine_δ_vertex_ge (hij : j ≤ i.castSucc) :
(X.spine m _ (X.map (tr (δ j)).op
(sx.spineToSimplex (m + 1) _ f))).vertex i = f.vertex i.succ := by
rw [spine_vertex, ← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
SimplexCategory.const_comp, spineToSimplex_vertex]
dsimp only [δ, len_mk, mkHom, Hom.toOrderHom_mk, Fin.succAboveOrderEmb_apply,
OrderEmbedding.toOrderHom_coe]
rw [Fin.succAbove_of_le_castSucc j i hij]
variable {i : Fin m} {j : Fin (m + 2)}
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
the common arrows will agree with those of the original path `f`. In particular,
an arrow `i` with `i + 1 < j` can be identified with the same arrow in `f`. -/
lemma spine_δ_arrow_lt (hij : i.succ.castSucc < j) :
(X.spine m _ (X.map (tr (δ j)).op
(sx.spineToSimplex (m + 1) _ f))).arrow i = f.arrow i.castSucc := by
rw [spine_arrow, ← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
mkOfSucc_δ_lt hij, spineToSimplex_arrow]
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
an arrow `i` with `i + 1 > j` can be identified with arrow `i + 1` in the
original path. -/
lemma spine_δ_arrow_gt (hij : j < i.succ.castSucc) :
(X.spine m _ (X.map (tr (δ j)).op
(sx.spineToSimplex (m + 1) _ f))).arrow i = f.arrow i.succ := by
rw [spine_arrow, ← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
mkOfSucc_δ_gt hij, spineToSimplex_arrow]
end spine_δ
variable {X : SSet.Truncated.{u} (n + 2)} (sx : StrictSegal X) (m : ℕ)
(h : m ≤ n + 1) (f : Path X (m + 1)) {i : Fin m} {j : Fin (m + 2)}
lemma spine_δ_arrow_eq (hij : j = i.succ.castSucc) :
(X.spine m _ (X.map (tr (δ j)).op
(sx.spineToSimplex (m + 1) _ f))).arrow i =
sx.spineToDiagonal 2 (by cutsat) (f.interval i 2 (by cutsat)) := by
rw [spine_arrow, ← FunctorToTypes.map_comp_apply, ← op_comp, ← tr_comp,
mkOfSucc_δ_eq hij, spineToSimplex_edge]
end StrictSegal
end Truncated
variable (X : SSet.{u})
/-- A simplicial set `X` satisfies the strict Segal condition if its simplices
are uniquely determined by their spine. -/
structure StrictSegal where
/-- The inverse to `spine X n`. -/
spineToSimplex {n : ℕ} : Path X n → X _⦋n⦌
/-- `spineToSimplex` is a right inverse to `spine X n`. -/
spine_spineToSimplex (n : ℕ) : spine X n ∘ spineToSimplex = id
/-- `spineToSimplex` is a left inverse to `spine X n`. -/
spineToSimplex_spine (n : ℕ) : spineToSimplex ∘ spine X n = id
/-- For `X` a simplicial set, `IsStrictSegal X` asserts the mere existence of
an inverse to `spine X n` for all `n : ℕ`. -/
class IsStrictSegal : Prop where
segal (n : ℕ) : Function.Bijective (spine X n)
namespace StrictSegal
/-- Given `IsStrictSegal X`, a choice of inverse to `spine X n` for all `n : ℕ`
determines an inhabitant of `StrictSegal X`. -/
noncomputable def ofIsStrictSegal [IsStrictSegal X] : StrictSegal X where
spineToSimplex {n} :=
Equiv.ofBijective (X.spine n) (IsStrictSegal.segal n) |>.invFun
spine_spineToSimplex n :=
funext <| Equiv.ofBijective (X.spine n) _ |>.right_inv
spineToSimplex_spine n :=
funext <| Equiv.ofBijective (X.spine n) _ |>.left_inv
variable {X} (sx : StrictSegal X)
/-- A `StrictSegal` structure on a simplicial set `X` restricts to a
`Truncated.StrictSegal` structure on the `n + 1`-truncation of `X`. -/
protected def truncation (n : ℕ) : truncation (n + 1) |>.obj X |>.StrictSegal where
spineToSimplex _ _ := sx.spineToSimplex
spine_spineToSimplex m _ := sx.spine_spineToSimplex m
spineToSimplex_spine m _ := sx.spineToSimplex_spine m
instance [X.IsStrictSegal] (n : ℕ) :
((truncation (n + 1)).obj X).IsStrictSegal :=
((ofIsStrictSegal X).truncation n).isStrictSegal
@[simp]
lemma spine_spineToSimplex_apply {n : ℕ} (f : Path X n) :
X.spine n (sx.spineToSimplex f) = f :=
congr_fun (sx.spine_spineToSimplex n) f
@[simp]
lemma spineToSimplex_spine_apply {n : ℕ} (Δ : X _⦋n⦌) :
sx.spineToSimplex (X.spine n Δ) = Δ :=
congr_fun (sx.spineToSimplex_spine n) Δ
/-- The fields of `StrictSegal` define an equivalence between `X _⦋n⦌`
and `Path X n`. -/
def spineEquiv (n : ℕ) : X _⦋n⦌ ≃ Path X n where
toFun := X.spine n
invFun := sx.spineToSimplex
left_inv := sx.spineToSimplex_spine_apply
right_inv := sx.spine_spineToSimplex_apply
variable {n : ℕ}
theorem spineInjective : Function.Injective (sx.spineEquiv n) :=
Equiv.injective _
/-- The unique existence of an inverse to `spine X n` forall `n : ℕ` implies
the mere existence of such an inverse. -/
lemma isStrictSegal (sx : StrictSegal X) : IsStrictSegal X where
segal n := sx.spineEquiv n |>.bijective
@[simp]
theorem spineToSimplex_vertex (i : Fin (n + 1)) (f : Path X n) :
X.map (SimplexCategory.const ⦋0⦌ ⦋n⦌ i).op (sx.spineToSimplex f) =
f.vertex i := by
rw [← spine_vertex, spine_spineToSimplex_apply]
@[simp]
theorem spineToSimplex_arrow (i : Fin n) (f : Path X n) :
X.map (mkOfSucc i).op (sx.spineToSimplex f) = f.arrow i := by
rw [← spine_arrow, spine_spineToSimplex_apply]
/-- In the presence of the strict Segal condition, a path of length `n` can be
"composed" by taking the diagonal edge of the resulting `n`-simplex. -/
def spineToDiagonal (f : Path X n) : X _⦋1⦌ :=
SimplicialObject.diagonal X (sx.spineToSimplex f)
section interval
variable (f : Path X n) (j l : ℕ) (hjl : j + l ≤ n)
@[simp]
theorem spineToSimplex_interval :
X.map (subinterval j l hjl).op (sx.spineToSimplex f) =
sx.spineToSimplex (f.interval j l hjl) := by
apply sx.spineInjective
dsimp only [spineEquiv, Equiv.coe_fn_mk]
rw [spine_spineToSimplex_apply, spine_map_subinterval,
spine_spineToSimplex_apply]
theorem spineToSimplex_edge :
X.map (intervalEdge j l hjl).op (sx.spineToSimplex f) =
sx.spineToDiagonal (f.interval j l hjl) := by
dsimp only [spineToDiagonal, SimplicialObject.diagonal]
rw [← spineToSimplex_interval, ← FunctorToTypes.map_comp_apply, ← op_comp,
diag_subinterval_eq]
end interval
/-- For any `σ : X ⟶ Y` between `StrictSegal` simplicial sets, `spineToSimplex`
commutes with `Path.map`. -/
lemma spineToSimplex_map {X Y : SSet.{u}} (sx : StrictSegal X)
(sy : StrictSegal Y) {n : ℕ} (f : Path X (n + 1)) (σ : X ⟶ Y) :
sy.spineToSimplex (f.map σ) = σ.app _ (sx.spineToSimplex f) := by
apply sy.spineInjective
ext k
dsimp only [spineEquiv, Equiv.coe_fn_mk, spine_arrow]
rw [← types_comp_apply (σ.app _) (Y.map _), ← σ.naturality, types_comp_apply,
spineToSimplex_arrow, spineToSimplex_arrow, Path.map_arrow]
variable (f : Path X (n + 1))
variable {i : Fin (n + 1)} {j : Fin (n + 2)}
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
the common vertices will agree with those of the original path `f`. In particular,
a vertex `i` with `i < j` can be identified with the same vertex in `f`. -/
lemma spine_δ_vertex_lt (h : i.castSucc < j) :
(X.spine n (X.δ j (sx.spineToSimplex f))).vertex i =
f.vertex i.castSucc := by
simp only [SimplicialObject.δ, spine_vertex]
rw [← FunctorToTypes.map_comp_apply, ← op_comp, SimplexCategory.const_comp,
spineToSimplex_vertex]
simp only [SimplexCategory.δ, Hom.toOrderHom, len_mk, mkHom, Hom.mk,
OrderEmbedding.toOrderHom_coe, Fin.succAboveOrderEmb_apply]
rw [Fin.succAbove_of_castSucc_lt j i h]
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
a vertex `i` with `i ≥ j` can be identified with vertex `i + 1` in the original
path. -/
lemma spine_δ_vertex_ge (h : j ≤ i.castSucc) :
(X.spine n (X.δ j (sx.spineToSimplex f))).vertex i = f.vertex i.succ := by
simp only [SimplicialObject.δ, spine_vertex]
rw [← FunctorToTypes.map_comp_apply, ← op_comp, SimplexCategory.const_comp,
spineToSimplex_vertex]
simp only [SimplexCategory.δ, Hom.toOrderHom, len_mk, mkHom, Hom.mk,
OrderEmbedding.toOrderHom_coe, Fin.succAboveOrderEmb_apply]
rw [Fin.succAbove_of_le_castSucc j i h]
variable {i : Fin n} {j : Fin (n + 2)}
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
the common arrows will agree with those of the original path `f`. In particular,
an arrow `i` with `i + 1 < j` can be identified with the same arrow in `f`. -/
lemma spine_δ_arrow_lt (h : i.succ.castSucc < j) :
(X.spine n (X.δ j (sx.spineToSimplex f))).arrow i = f.arrow i.castSucc := by
simp only [SimplicialObject.δ, spine_arrow]
rw [← FunctorToTypes.map_comp_apply, ← op_comp]
rw [mkOfSucc_δ_lt h, spineToSimplex_arrow]
/-- If we take the path along the spine of the `j`th face of a `spineToSimplex`,
an arrow `i` with `i + 1 > j` can be identified with arrow `i + 1` in the
original path. -/
lemma spine_δ_arrow_gt (h : j < i.succ.castSucc) :
(X.spine n (X.δ j (sx.spineToSimplex f))).arrow i = f.arrow i.succ := by
simp only [SimplicialObject.δ, spine_arrow]
rw [← FunctorToTypes.map_comp_apply, ← op_comp]
rw [mkOfSucc_δ_gt h, spineToSimplex_arrow]
/-- If we take the path along the spine of a face of a `spineToSimplex`, the
arrows not contained in the original path can be recovered as the diagonal edge
of the `spineToSimplex` that "composes" arrows `i` and `i + 1`. -/
lemma spine_δ_arrow_eq (h : j = i.succ.castSucc) :
(X.spine n (X.δ j (sx.spineToSimplex f))).arrow i =
sx.spineToDiagonal (f.interval i 2 (by cutsat)) := by
simp only [SimplicialObject.δ, spine_arrow]
rw [← FunctorToTypes.map_comp_apply, ← op_comp]
rw [mkOfSucc_δ_eq h, spineToSimplex_edge]
end StrictSegal
/-- Helper structure in order to show that a simplicial set is strict Segal. -/
structure StrictSegalCore (n : ℕ) where
/-- Map which produces a `n + 1`-simplex from a `1`-simplex and a `n`-simplex when
the target vertex of the `1`-simplex equals the zeroth simplex of the `n`-simplex. -/
concat (x : X _⦋1⦌) (s : X _⦋n⦌) (h : X.δ 0 x = X.map (SimplexCategory.const _ _ 0).op s) :
X _⦋n + 1⦌
map_mkOfSucc_zero_concat x s h : X.map (mkOfSucc 0).op (concat x s h) = x
δ₀_concat x s h : X.δ 0 (concat x s h) = s
injective {x y : X _⦋n + 1⦌} (h : X.map (mkOfSucc 0).op x = X.map (mkOfSucc 0).op y)
(h₀ : X.δ 0 x = X.δ 0 y) : x = y
namespace StrictSegalCore
variable {X} (h : ∀ n, X.StrictSegalCore n) {n : ℕ} (p : X.Path n)
/-- Auxiliary definition for `StrictSegalCore.spineToSimplex`. -/
def spineToSimplexAux : { s : X _⦋n⦌ // X.spine _ s = p } := by
induction n with
| zero => exact ⟨p.vertex 0, by aesop⟩
| succ n hn =>
refine ⟨(h n).concat (p.arrow 0) (hn (p.interval 1 n)).val ?_, ?_⟩
· rw [p.arrow_tgt 0]
exact Path.congr_vertex (hn (p.interval 1 n)).prop.symm 0
· ext i
obtain rfl | ⟨i, rfl⟩ := i.eq_zero_or_eq_succ
· dsimp
rw [map_mkOfSucc_zero_concat]
· simpa [spine_arrow, ← SimplexCategory.mkOfSucc_δ_gt (j := 0) (i := i) (by simp),
op_comp, FunctorToTypes.map_comp_apply, ← SimplicialObject.δ_def, δ₀_concat,
← p.arrow_interval 1 n i i.succ (by grind) (by grind [Fin.val_succ])] using
Path.congr_arrow (hn (p.interval 1 n)).prop i
/-- Auxiliary definition for `StrictSegal.ofCore`. -/
def spineToSimplex : X _⦋n⦌ := (spineToSimplexAux h p).val
@[simp]
lemma spine_spineToSimplex : X.spine n (spineToSimplex h p) = p := (spineToSimplexAux h p).prop
lemma spineToSimplex_zero (p : X.Path 0) : spineToSimplex h p = p.vertex 0 := rfl
lemma spineToSimplex_succ (p : X.Path (n + 1)) :
spineToSimplex h p = (h n).concat (p.arrow 0) (spineToSimplex h (p.interval 1 n)) (by
rw [p.arrow_tgt 0]
exact Path.congr_vertex (spine_spineToSimplex h (p.interval 1 n)).symm 0) :=
rfl
lemma map_mkOfSucc_zero_spineToSimplex (p : X.Path (n + 1)) :
X.map (mkOfSucc 0).op (spineToSimplex h p) = p.arrow 0 := by
rw [spineToSimplex_succ, map_mkOfSucc_zero_concat]
lemma δ₀_spineToSimplex (p : X.Path (n + 1)) :
X.δ 0 (spineToSimplex h p) = spineToSimplex h (p.interval 1 n) := by
rw [spineToSimplex_succ, δ₀_concat]
@[simp]
lemma spineToSimplex_spine (s : X _⦋n⦌) : spineToSimplex h (X.spine _ s) = s := by
induction n with
| zero => simp [spineToSimplex_zero]
| succ n hn =>
exact (h n).injective (map_mkOfSucc_zero_spineToSimplex _ _)
(by rw [δ₀_spineToSimplex, ← hn (X.δ 0 s), spine_δ₀])
end StrictSegalCore
variable {X} in
/-- Given a simplicial set `X`, this constructs a `StrictSegal` structure for `X` from
`StrictSegalCore` structures for all `n : ℕ`. -/
def StrictSegal.ofCore (h : ∀ n, X.StrictSegalCore n) : X.StrictSegal where
spineToSimplex := StrictSegalCore.spineToSimplex h
spine_spineToSimplex := by aesop
spineToSimplex_spine n := by aesop
end SSet
namespace CategoryTheory.Nerve
open SSet
variable (C : Type u) [Category.{v} C]
/-- Simplices in the nerve of categories are uniquely determined by their spine.
Indeed, this property describes the essential image of the nerve functor. -/
def strictSegal : StrictSegal (nerve C) :=
StrictSegal.ofCore (fun n ↦
{ concat f s h := s.precomp (f.hom ≫ eqToHom (Functor.congr_obj h 0))
map_mkOfSucc_zero_concat f s h :=
ComposableArrows.ext₁ rfl (Functor.congr_obj h 0).symm (by cat_disch)
δ₀_concat f s h := rfl
injective {f g} h h₀ :=
ComposableArrows.ext_succ (Functor.congr_obj h 0) h₀
((Arrow.mk_eq_mk_iff _ _).1
(DFunLike.congr_arg ComposableArrows.arrowEquiv h)).2.2 })
instance isStrictSegal : IsStrictSegal (nerve C) :=
strictSegal C |>.isStrictSegal
end CategoryTheory.Nerve |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/NerveNondegenerate.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Degenerate
import Mathlib.AlgebraicTopology.SimplicialSet.Nerve
/-!
# The nondegenerate simplices in the nerve of a partially ordered type
In this file, we show that if `X` is a partially ordered type,
then an `n`-simplex `s` of the nerve is nondegenerate iff
the monotone map `s.obj : Fin (n + 1) → X` is strictly monotone.
-/
universe u
open CategoryTheory Simplicial
namespace PartialOrder
variable {X : Type*} [PartialOrder X] {n : ℕ}
lemma mem_range_nerve_σ_iff (s : (nerve X) _⦋n + 1⦌) (i : Fin (n + 1)) :
s ∈ Set.range ((nerve X).σ i) ↔
s.obj i.castSucc = s.obj i.succ := by
constructor
· rintro ⟨s, rfl⟩
simp [nerve.σ_obj]
· intro h
refine ⟨(nerve X).δ i.castSucc s, ?_⟩
ext j
rw [nerve.σ_obj, nerve.δ_obj]
by_cases h₁ : i.castSucc < j
· obtain ⟨j, rfl⟩ := Fin.eq_succ_of_ne_zero (Fin.ne_zero_of_lt h₁)
rw [Fin.predAbove_of_castSucc_lt _ _ h₁, Fin.pred_succ,
Fin.succAbove_of_le_castSucc _ _ (Fin.le_castSucc_iff.2 h₁)]
· simp only [not_lt] at h₁
grind [SimplexCategory.len_mk, → Fin.succAbove_of_castSucc_lt,
→ Fin.predAbove_of_le_castSucc, Fin.castSucc_castPred, Fin.castPred_castSucc,
Fin.succAbove_castSucc_self, → LE.le.lt_or_eq]
lemma mem_nerve_degenerate_of_eq (s : (nerve X) _⦋n + 1⦌) {i : Fin (n + 1)}
(hi : s.obj i.castSucc = s.obj i.succ) :
s ∈ (nerve X).degenerate (n + 1) := by
simp only [nerve_obj, SSet.degenerate_eq_iUnion_range_σ, Set.mem_iUnion]
exact ⟨i, by rwa [mem_range_nerve_σ_iff]⟩
lemma mem_nerve_nonDegenerate_iff_strictMono (s : (nerve X) _⦋n⦌) :
s ∈ (nerve X).nonDegenerate n ↔ StrictMono s.obj := by
obtain _ | n := n
· simpa using Subsingleton.strictMono _
· rw [← not_iff_not, ← SSet.mem_degenerate_iff_notMem_nonDegenerate,
Fin.strictMono_iff_lt_succ, SSet.degenerate_eq_iUnion_range_σ, Set.mem_iUnion]
simp only [mem_range_nerve_σ_iff, not_forall]
apply exists_congr
intro i
have := s.monotone i.castSucc_le_succ
grind [SimplexCategory.len_mk, lt_self_iff_false, LE.le.lt_or_eq]
lemma mem_nerve_nonDegenerate_iff_injective (s : (nerve X) _⦋n⦌) :
s ∈ (nerve X).nonDegenerate n ↔ Function.Injective s.obj := by
rw [mem_nerve_nonDegenerate_iff_strictMono]
refine ⟨fun h ↦ h.injective, fun h i j hij ↦ ?_⟩
obtain h' | h' := (s.monotone hij.le).lt_or_eq
· exact h'
· exact ((h h').not_lt hij).elim
end PartialOrder |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Monoidal.lean | import Mathlib.AlgebraicTopology.SimplicialSet.StdSimplex
import Mathlib.CategoryTheory.Closed.FunctorToTypes
import Mathlib.CategoryTheory.Monoidal.Cartesian.FunctorCategory
/-!
# The monoidal category structure on simplicial sets
This file defines an instance of chosen finite products
for the category `SSet`. It follows from the fact
the `SSet` if a category of functors to the category
of types and that the category of types have chosen
finite products. As a result, we obtain a monoidal
category structure on `SSet`.
-/
universe u
open Simplicial CategoryTheory MonoidalCategory Limits
namespace SSet
instance : CartesianMonoidalCategory SSet.{u} :=
(inferInstance : CartesianMonoidalCategory (SimplexCategoryᵒᵖ ⥤ Type u))
instance : MonoidalClosed (SSet.{u}) :=
inferInstanceAs (MonoidalClosed (SimplexCategoryᵒᵖ ⥤ Type u))
@[simp]
lemma leftUnitor_hom_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : (𝟙_ _ ⊗ K).obj Δ) :
(λ_ K).hom.app Δ x = x.2 := rfl
@[simp]
lemma leftUnitor_inv_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : K.obj Δ) :
(λ_ K).inv.app Δ x = ⟨PUnit.unit, x⟩ := rfl
@[simp]
lemma rightUnitor_hom_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ 𝟙_ _).obj Δ) :
(ρ_ K).hom.app Δ x = x.1 := rfl
@[simp]
lemma rightUnitor_inv_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : K.obj Δ) :
(ρ_ K).inv.app Δ x = ⟨x, PUnit.unit⟩ := rfl
@[simp]
lemma tensorHom_app_apply {K K' L L' : SSet.{u}} (f : K ⟶ K') (g : L ⟶ L')
{Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ L).obj Δ) :
(f ⊗ₘ g).app Δ x = ⟨f.app Δ x.1, g.app Δ x.2⟩ := rfl
@[simp]
lemma whiskerLeft_app_apply (K : SSet.{u}) {L L' : SSet.{u}} (g : L ⟶ L')
{Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ L).obj Δ) :
(K ◁ g).app Δ x = ⟨x.1, g.app Δ x.2⟩ := rfl
@[simp]
lemma whiskerRight_app_apply {K K' : SSet.{u}} (f : K ⟶ K') (L : SSet.{u})
{Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ L).obj Δ) :
(f ▷ L).app Δ x = ⟨f.app Δ x.1, x.2⟩ := rfl
@[simp]
lemma associator_hom_app_apply (K L M : SSet.{u}) {Δ : SimplexCategoryᵒᵖ}
(x : ((K ⊗ L) ⊗ M).obj Δ) :
(α_ K L M).hom.app Δ x = ⟨x.1.1, x.1.2, x.2⟩ := rfl
@[simp]
lemma associator_inv_app_apply (K L M : SSet.{u}) {Δ : SimplexCategoryᵒᵖ}
(x : (K ⊗ L ⊗ M).obj Δ) :
(α_ K L M).inv.app Δ x = ⟨⟨x.1, x.2.1⟩, x.2.2⟩ := rfl
/-- The bijection `(𝟙_ SSet ⟶ K) ≃ K _⦋0⦌`. -/
def unitHomEquiv (K : SSet.{u}) : (𝟙_ _ ⟶ K) ≃ K _⦋0⦌ where
toFun φ := φ.app _ PUnit.unit
invFun x :=
{ app := fun Δ _ => K.map (SimplexCategory.const Δ.unop ⦋0⦌ 0).op x
naturality := fun Δ Δ' f => by
ext ⟨⟩
dsimp
rw [← FunctorToTypes.map_comp_apply]
rfl }
left_inv φ := by
ext Δ ⟨⟩
dsimp
rw [← FunctorToTypes.naturality]
rfl
right_inv x := by simp
/-- The object `Δ[0]` is terminal in `SSet`. -/
def stdSimplex.isTerminalObj₀ : IsTerminal (Δ[0] : SSet.{u}) :=
IsTerminal.ofUniqueHom (fun _ ↦ SSet.const (obj₀Equiv.symm 0))
(fun _ _ ↦ by
ext ⟨n⟩
exact objEquiv.injective (by ext; simp))
@[ext]
lemma stdSimplex.ext₀ {X : SSet.{u}} {f g : X ⟶ Δ[0]} : f = g :=
isTerminalObj₀.hom_ext _ _
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/CompStruct.lean | import Mathlib.AlgebraicTopology.SimplicialSet.CompStructTruncated
/-!
# Edges and "triangles" in simplicial sets
Given a 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`.
(This API parallels similar definitions for `2`-truncated simplicial sets.
The definitions in this file are definitionally equal to their `2`-truncated
counterparts.)
-/
universe v u
open CategoryTheory Simplicial
namespace SSet
variable {X Y : SSet.{u}} {x₀ x₁ x₂ : X _⦋0⦌}
variable (x₀ x₁) in
/-- In a simplicial set, an edge from a vertex `x₀` to `x₁` is
a `1`-simplex with prescribed `0`-dimensional faces. -/
def Edge := ((truncation 2).obj X).Edge x₀ x₁
namespace Edge
/-- Constructor for `SSet.Edge` which takes as an input a term in the definitionally
equal type `SSet.Truncated.Edge` for the `2`-truncation of the simplicial set.
(This definition is made to contain abuse of defeq in other definitions.) -/
def ofTruncated (e : ((truncation 2).obj X).Edge x₀ x₁) :
Edge x₀ x₁ := e
/-- The edge of the `2`-truncation of a simplicial set `X` that is induced
by an edge of `X`. -/
def toTruncated (e : Edge x₀ x₁) :
((truncation 2).obj X).Edge x₀ x₁ :=
e
/-- In a simplicial set, an edge from a vertex `x₀` to `x₁` is
a `1`-simplex with prescribed `0`-dimensional faces. -/
def edge (e : Edge x₀ x₁) : X _⦋1⦌ := e.toTruncated.edge
@[simp]
lemma ofTruncated_edge (e : ((truncation 2).obj X).Edge x₀ x₁) :
(ofTruncated e).edge = e.edge := rfl
@[simp]
lemma toTruncated_edge (e : Edge x₀ x₁) :
(toTruncated e).edge = e.edge := rfl
@[simp]
lemma src_eq (e : Edge x₀ x₁) : X.δ 1 e.edge = x₀ := Truncated.Edge.src_eq e
@[simp]
lemma tgt_eq (e : Edge x₀ x₁) : X.δ 0 e.edge = x₁ := Truncated.Edge.tgt_eq e
@[ext]
lemma ext {e e' : Edge x₀ x₁} (h : e.edge = e'.edge) :
e = e' := Truncated.Edge.ext h
variable (x₀) in
/-- The constant edge on a `0`-simplex. -/
def id : Edge x₀ x₀ := ofTruncated (.id _)
variable (x₀) in
@[simp]
lemma id_edge : (id x₀).edge = X.σ 0 x₀ := rfl
/-- The image of an edge by a morphism of simplicial sets. -/
def map (e : Edge x₀ x₁) (f : X ⟶ Y) : Edge (f.app _ x₀) (f.app _ x₁) :=
ofTruncated (e.toTruncated.map ((truncation 2).map f))
variable (x₀) in
@[simp]
lemma map_id (f : X ⟶ Y) :
(Edge.id x₀).map f = Edge.id (f.app _ x₀) :=
Truncated.Edge.map_id _ _
/-- The edge given by a `1`-simplex. -/
def mk' (s : X _⦋1⦌) : Edge (X.δ 1 s) (X.δ 0 s) :=
.ofTruncated (Truncated.Edge.mk' (X := (truncation 2).obj X) s)
@[simp]
lemma mk'_edge (s : X _⦋1⦌) : (mk' s).edge = s := rfl
lemma exists_of_simplex (s : X _⦋1⦌) :
∃ (x₀ x₁ : X _⦋0⦌) (e : Edge x₀ x₁), e.edge = s :=
⟨_, _, mk' s, rfl⟩
/-- Let `x₀`, `x₁`, `x₂` be `0`-simplices of a 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 simplicial sets
(and specialized constructions for quasicategories and Kan complexes.). -/
def CompStruct (e₀₁ : Edge x₀ x₁) (e₁₂ : Edge x₁ x₂) (e₀₂ : Edge x₀ x₂) :=
Truncated.Edge.CompStruct e₀₁.toTruncated e₁₂.toTruncated e₀₂.toTruncated
namespace CompStruct
variable {e₀₁ : Edge x₀ x₁} {e₁₂ : Edge x₁ x₂} {e₀₂ : Edge x₀ x₂}
/-- Constructor for `SSet.Edge.CompStruct` which takes as an input a term in the
definitionally equal type `SSet.Truncated.Edge.CompStruct` for the `2`-truncation of
the simplicial set. (This definition is made to contain abuse of defeq in
other definitions.) -/
def ofTruncated (h : Truncated.Edge.CompStruct e₀₁.toTruncated e₁₂.toTruncated e₀₂.toTruncated) :
CompStruct e₀₁ e₁₂ e₀₂ := h
/-- Conversion from `SSet.Edge.CompStruct` to `SSet.Truncated.Edge.CompStruct`. -/
def toTruncated (h : CompStruct e₀₁ e₁₂ e₀₂) :
Truncated.Edge.CompStruct e₀₁.toTruncated e₁₂.toTruncated e₀₂.toTruncated :=
h
/-- The underlying `2`-simplex in a structure `SSet.Edge.CompStruct`. -/
def simplex (h : CompStruct e₀₁ e₁₂ e₀₂) : X _⦋2⦌ :=
h.toTruncated.simplex
section
variable (simplex : X _⦋2⦌)
(d₂ : X.δ 2 simplex = e₀₁.edge := by cat_disch)
(d₀ : X.δ 0 simplex = e₁₂.edge := by cat_disch)
(d₁ : X.δ 1 simplex = e₀₂.edge := by cat_disch)
/-- Constructor for `SSet.Edge.CompStruct`. -/
def mk : CompStruct e₀₁ e₁₂ e₀₂ where
simplex := simplex
@[simp]
lemma mk_simplex : (mk simplex).simplex = simplex := rfl
end
@[ext]
lemma ext {h h' : CompStruct e₀₁ e₁₂ e₀₂} (eq : h.simplex = h'.simplex) :
h = h' :=
Truncated.Edge.CompStruct.ext eq
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 :=
Truncated.Edge.CompStruct.exists_of_simplex (X := (truncation 2).obj X) s
/-- `e : Edge x₀ x₁` is a composition of `Edge.id x₀` with `e`. -/
def idComp (e : Edge x₀ x₁) : CompStruct (.id x₀) e e :=
ofTruncated (.idComp _)
@[simp]
lemma idComp_simplex (e : Edge x₀ x₁) : (idComp e).simplex = X.σ 0 e.edge := rfl
/-- `e : Edge x₀ x₁` is a composition of `e` with `Edge.id x₁` -/
def compId (e : Edge x₀ x₁) : CompStruct e (.id x₁) e :=
ofTruncated (.compId _)
@[simp]
lemma compId_simplex (e : Edge x₀ x₁) : (compId e).simplex = X.σ 1 e.edge := rfl
/-- The image of a `Edge.CompStruct` by a morphism of simplicial sets. -/
def map (h : CompStruct e₀₁ e₁₂ e₀₂) (f : X ⟶ Y) :
CompStruct (e₀₁.map f) (e₁₂.map f) (e₀₂.map f) :=
.ofTruncated (h.toTruncated.map ((truncation 2).map f))
@[simp]
lemma map_simplex (h : CompStruct e₀₁ e₁₂ e₀₂) (f : X ⟶ Y) :
(h.map f).simplex = f.app _ h.simplex := rfl
end CompStruct
end Edge
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean | import Mathlib.AlgebraicTopology.SimplicialSet.Basic
import Mathlib.CategoryTheory.ComposableArrows.Basic
/-!
# The nerve of a category
This file provides the definition of the nerve of a category `C`,
which is a simplicial set `nerve C` (see [goerss-jardine-2009], Example I.1.4).
By definition, the type of `n`-simplices of `nerve C` is `ComposableArrows C n`,
which is the category `Fin (n + 1) ⥤ C`.
## References
* [Paul G. Goerss, John F. Jardine, *Simplicial Homotopy Theory*][goerss-jardine-2009]
-/
open CategoryTheory.Category Simplicial
universe v u
namespace CategoryTheory
/-- The nerve of a category -/
@[simps]
def nerve (C : Type u) [Category.{v} C] : SSet.{max u v} where
obj Δ := ComposableArrows C (Δ.unop.len)
map f x := x.whiskerLeft (SimplexCategory.toCat.map f.unop)
-- `aesop` can prove these but is slow, help it out:
map_id _ := rfl
map_comp _ _ := rfl
instance {C : Type*} [Category C] {Δ : SimplexCategoryᵒᵖ} : Category ((nerve C).obj Δ) :=
(inferInstance : Category (ComposableArrows C (Δ.unop.len)))
/-- Given a functor `C ⥤ D`, we obtain a morphism `nerve C ⟶ nerve D` of simplicial sets. -/
@[simps]
def nerveMap {C D : Type u} [Category.{v} C] [Category.{v} D] (F : C ⥤ D) : nerve C ⟶ nerve D :=
{ app := fun _ => (F.mapComposableArrows _).obj }
/-- The nerve of a category, as a functor `Cat ⥤ SSet` -/
@[simps]
def nerveFunctor : Cat.{v, u} ⥤ SSet where
obj C := nerve C
map F := nerveMap F
/-- The 0-simplices of the nerve of a category are equivalent to the objects of the category. -/
def nerveEquiv (C : Type u) [Category.{v} C] : nerve C _⦋0⦌ ≃ C where
toFun f := f.obj ⟨0, by omega⟩
invFun f := (Functor.const _).obj f
left_inv f := ComposableArrows.ext₀ rfl
namespace nerve
/-- Nerves of finite non-empty ordinals are representable functors. -/
def representableBy {n : ℕ} (α : Type u) [Preorder α] (e : α ≃o Fin (n + 1)) :
(nerve α).RepresentableBy ⦋n⦌ where
homEquiv := SimplexCategory.homEquivFunctor.trans
{ toFun F := F ⋙ e.symm.monotone.functor
invFun F := F ⋙ e.monotone.functor
left_inv F := Functor.ext (fun x ↦ by simp)
right_inv F := Functor.ext (fun x ↦ by simp) }
homEquiv_comp _ _ := rfl
variable {C : Type*} [Category C] {n : ℕ}
lemma δ_obj {n : ℕ} (i : Fin (n + 2)) (x : (nerve C) _⦋n + 1⦌) (j : Fin (n + 1)) :
((nerve C).δ i x).obj j = x.obj (i.succAbove j) :=
rfl
lemma σ_obj {n : ℕ} (i : Fin (n + 1)) (x : (nerve C) _⦋n⦌) (j : Fin (n + 2)) :
((nerve C).σ i x).obj j = x.obj (i.predAbove j) :=
rfl
lemma δ₀_eq {x : nerve C _⦋n + 1⦌} : (nerve C).δ (0 : Fin (n + 2)) x = x.δ₀ := rfl
lemma σ₀_mk₀_eq (x : C) : (nerve C).σ (0 : Fin 1) (.mk₀ x) = .mk₁ (𝟙 x) :=
ComposableArrows.ext₁ rfl rfl (by simp; rfl)
section
variable {X₀ X₁ X₂ : C} (f : X₀ ⟶ X₁) (g : X₁ ⟶ X₂)
theorem δ₂_mk₂_eq : (nerve C).δ 2 (ComposableArrows.mk₂ f g) = ComposableArrows.mk₁ f :=
ComposableArrows.ext₁ rfl rfl (by simp; rfl)
theorem δ₀_mk₂_eq : (nerve C).δ 0 (ComposableArrows.mk₂ f g) = ComposableArrows.mk₁ g :=
ComposableArrows.ext₁ rfl rfl (by simp; rfl)
theorem δ₁_mk₂_eq : (nerve C).δ 1 (ComposableArrows.mk₂ f g) = ComposableArrows.mk₁ (f ≫ g) :=
ComposableArrows.ext₁ rfl rfl (by simp; rfl)
end
@[ext]
lemma ext_of_isThin [Quiver.IsThin C] {n : SimplexCategoryᵒᵖ} {x y : (nerve C).obj n}
(h : x.obj = y.obj) :
x = y :=
ComposableArrows.ext (by simp [h]) (by subsingleton)
end nerve
end CategoryTheory |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/HomotopyCat.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Basic
import Mathlib.AlgebraicTopology.SimplicialSet.Coskeletal
import Mathlib.AlgebraicTopology.SimplexCategory.Truncated
import Mathlib.CategoryTheory.Category.ReflQuiv
import Mathlib.Combinatorics.Quiver.ReflQuiver
import Mathlib.AlgebraicTopology.SimplicialSet.Monoidal
import Mathlib.CategoryTheory.Category.Cat.Terminal
/-!
# The homotopy category of a simplicial set
The homotopy category of a simplicial set is defined as a quotient of the free category on its
underlying reflexive quiver (equivalently its one truncation). The quotient imposes an additional
hom relation on this free category, asserting that `f ≫ g = h` whenever `f`, `g`, and `h` are
respectively the 2nd, 0th, and 1st faces of a 2-simplex.
In fact, the associated functor
`SSet.hoFunctor : SSet.{u} ⥤ Cat.{u, u} := SSet.truncation 2 ⋙ SSet.hoFunctor₂`
is defined by first restricting from simplicial sets to 2-truncated simplicial sets (throwing away
the data that is not used for the construction of the homotopy category) and then composing with an
analogously defined `SSet.hoFunctor₂ : SSet.Truncated.{u} 2 ⥤ Cat.{u,u}` implemented relative to
the syntax of the 2-truncated simplex category.
In the file `Mathlib/AlgebraicTopology/SimplicialSet/NerveAdjunction.lean` we show the functor
`SSet.hoFunctor` to be left adjoint to the nerve by providing an analogous decomposition of the
nerve functor, made by possible by the fact that nerves of categories are 2-coskeletal, and then
composing a pair of adjunctions, which factor through the category of 2-truncated simplicial sets.
-/
namespace SSet
open CategoryTheory Category Limits Functor Opposite Simplicial Nerve
open SimplexCategory.Truncated SimplicialObject.Truncated
universe v u
section
/-- A 2-truncated simplicial set `S` has an underlying refl quiver with `S _⦋0⦌₂` as its underlying
type. -/
def OneTruncation₂ (S : SSet.Truncated 2) := S _⦋0⦌₂
/-- The hom-types of the refl quiver underlying a simplicial set `S` are types of edges in `S _⦋1⦌₂`
together with source and target equalities. -/
@[ext]
structure OneTruncation₂.Hom {S : SSet.Truncated 2} (X Y : OneTruncation₂ S) where
/-- An arrow in `OneTruncation₂.Hom X Y` includes the data of a 1-simplex. -/
edge : S _⦋1⦌₂
/-- An arrow in `OneTruncation₂.Hom X Y` includes a source equality. -/
src_eq : S.map (δ₂ 1).op edge = X
/-- An arrow in `OneTruncation₂.Hom X Y` includes a target equality. -/
tgt_eq : S.map (δ₂ 0).op edge = Y
/-- A 2-truncated simplicial set `S` has an underlying refl quiver `SSet.OneTruncation₂ S`. -/
instance (S : SSet.Truncated 2) : ReflQuiver (OneTruncation₂ S) where
Hom X Y := SSet.OneTruncation₂.Hom X Y
id X :=
{ edge := S.map (σ₂ (n := 0) 0).op X
src_eq := by
simp only [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_one_comp_σ₂_zero,
op_id, FunctorToTypes.map_id_apply]
tgt_eq := by
simp only [← FunctorToTypes.map_comp_apply, ← op_comp, δ₂_zero_comp_σ₂_zero,
op_id, FunctorToTypes.map_id_apply] }
@[simp]
lemma OneTruncation₂.id_edge {S : SSet.Truncated 2} (X : OneTruncation₂ S) :
OneTruncation₂.Hom.edge (𝟙rq X) = S.map (σ₂ 0).op X := rfl
/-- The functor that carries a 2-truncated simplicial set to its underlying refl quiver. -/
@[simps]
def oneTruncation₂ : SSet.Truncated.{u} 2 ⥤ ReflQuiv.{u, u} where
obj S := ReflQuiv.of (OneTruncation₂ S)
map {S T} F := {
obj := F.app (op ⦋0⦌₂)
map := fun f ↦
{ edge := F.app _ f.edge
src_eq := by rw [← FunctorToTypes.naturality, f.src_eq]
tgt_eq := by rw [← FunctorToTypes.naturality, f.tgt_eq] }
map_id := fun X ↦ OneTruncation₂.Hom.ext (by
dsimp
rw [← FunctorToTypes.naturality]) }
@[ext]
lemma OneTruncation₂.hom_ext {S : SSet.Truncated 2} {x y : OneTruncation₂ S} {f g : x ⟶ y} :
f.edge = g.edge → f = g := OneTruncation₂.Hom.ext
@[simp]
lemma OneTruncation₂.homOfEq_edge
{X : SSet.Truncated.{u} 2} {x₁ y₁ x₂ y₂ : OneTruncation₂ X}
(f : x₁ ⟶ y₁) (hx : x₁ = x₂) (hy : y₁ = y₂) :
(Quiver.homOfEq f hx hy).edge = f.edge := by
subst hx hy
rfl
section
variable {C : Type u} [Category.{v} C]
/-- An equivalence between the type of objects underlying a category and the type of 0-simplices in
the 2-truncated nerve. -/
@[simps]
def OneTruncation₂.nerveEquiv :
OneTruncation₂ ((SSet.truncation 2).obj (nerve C)) ≃ C where
toFun X := X.obj' 0
invFun X := .mk₀ X
left_inv _ := ComposableArrows.ext₀ rfl
/-- A hom equivalence over the function `OneTruncation₂.nerveEquiv`. -/
def OneTruncation₂.nerveHomEquiv (X Y : OneTruncation₂ ((SSet.truncation 2).obj (nerve C))) :
(X ⟶ Y) ≃ (nerveEquiv X ⟶ nerveEquiv Y) where
toFun φ := eqToHom (congr_arg ComposableArrows.left φ.src_eq.symm) ≫ φ.edge.hom ≫
eqToHom (congr_arg ComposableArrows.left φ.tgt_eq)
invFun f :=
{ edge := ComposableArrows.mk₁ f
src_eq := ComposableArrows.ext₀ rfl
tgt_eq := ComposableArrows.ext₀ rfl }
left_inv φ := by
ext
exact ComposableArrows.ext₁ (congr_arg ComposableArrows.left φ.src_eq).symm
(congr_arg ComposableArrows.left φ.tgt_eq).symm rfl
right_inv f := by dsimp; simp only [comp_id, id_comp]; rfl
/-- The refl quiver underlying a nerve is isomorphic to the refl quiver underlying the category. -/
def OneTruncation₂.ofNerve₂ (C : Type u) [Category.{u} C] :
ReflQuiv.of (OneTruncation₂ (nerveFunctor₂.obj (Cat.of C))) ≅ ReflQuiv.of C := by
apply ReflQuiv.isoOfEquiv.{u,u} OneTruncation₂.nerveEquiv OneTruncation₂.nerveHomEquiv ?_
intro X
unfold nerveEquiv nerveHomEquiv
simp only [Cat.of_α, op_obj, ComposableArrows.obj', Fin.zero_eta, Fin.isValue, Equiv.coe_fn_mk,
nerveEquiv_apply, Nat.reduceAdd, id_edge, eqToHom_refl, comp_id, id_comp, ReflQuiver.id_eq_id]
unfold nerve truncation SimplicialObject.truncation SimplexCategory.Truncated.inclusion
-- the following was obtained by `simp?`
simp only [ObjectProperty.ι_obj, SimplexCategory.len_mk, Nat.reduceAdd, Fin.isValue,
SimplexCategory.toCat_map, whiskeringLeft_obj_obj, Functor.comp_map, op_obj, op_map,
Quiver.Hom.unop_op, ObjectProperty.ι_map, ComposableArrows.whiskerLeft_map, Fin.zero_eta,
Monotone.functor_obj, Fin.mk_one, homOfLE_leOfHom]
change X.map (𝟙 _) = _
rw [X.map_id]
rfl
/-- The refl quiver underlying a nerve is naturally isomorphic to the refl quiver underlying the
category. -/
@[simps! hom_app_obj hom_app_map inv_app_obj_obj inv_app_obj_map inv_app_map]
def OneTruncation₂.ofNerve₂.natIso :
nerveFunctor₂.{u,u} ⋙ SSet.oneTruncation₂ ≅ ReflQuiv.forget :=
NatIso.ofComponents (fun C => OneTruncation₂.ofNerve₂ C) (by
· intro C D F
fapply ReflPrefunctor.ext <;> simp
· exact fun _ ↦ rfl
· intro X Y f
obtain ⟨f, rfl, rfl⟩ := f
unfold SSet.oneTruncation₂ nerveFunctor₂ SSet.truncation SimplicialObject.truncation
nerveFunctor toReflPrefunctor
simp only [comp_obj, whiskeringLeft_obj_obj, ReflQuiv.of_val, Functor.comp_map,
whiskeringLeft_obj_map, whiskerLeft_app, op_obj, ofNerve₂, Cat.of_α, nerveEquiv,
ComposableArrows.obj', Fin.zero_eta, Fin.isValue, ReflQuiv.comp_eq_comp, Nat.reduceAdd,
op_map, Quiver.Hom.unop_op, nerve_map, SimplexCategory.toCat_map, ReflPrefunctor.comp_obj,
ReflPrefunctor.comp_map]
simp [nerveHomEquiv, ReflQuiv.isoOfEquiv, ReflQuiv.isoOfQuivIso, Quiv.isoOfEquiv])
end
section
private lemma map_map_of_eq.{w} {C : Type u} [Category.{v} C] (V : Cᵒᵖ ⥤ Type w) {X Y Z : C}
{α : X ⟶ Y} {β : Y ⟶ Z} {γ : X ⟶ Z} {φ} :
α ≫ β = γ → V.map α.op (V.map β.op φ) = V.map γ.op φ := by
rintro rfl
simp
variable {V : SSet}
namespace Truncated
/-- The map that picks up the initial vertex of a 2-simplex, as a morphism in the 2-truncated
simplex category. -/
def ι0₂ : ⦋0⦌₂ ⟶ ⦋2⦌₂ := δ₂ (n := 0) 1 ≫ δ₂ (n := 1) 1
/-- The map that picks up the middle vertex of a 2-simplex, as a morphism in the 2-truncated
simplex category. -/
def ι1₂ : ⦋0⦌₂ ⟶ ⦋2⦌₂ := δ₂ (n := 0) 0 ≫ δ₂ (n := 1) 2
/-- The map that picks up the final vertex of a 2-simplex, as a morphism in the 2-truncated
simplex category. -/
def ι2₂ : ⦋0⦌₂ ⟶ ⦋2⦌₂ := δ₂ (n := 0) 0 ≫ δ₂ (n := 1) 1
/-- The initial vertex of a 2-simplex in a 2-truncated simplicial set. -/
def ev0₂ {V : SSet.Truncated 2} (φ : V _⦋2⦌₂) : OneTruncation₂ V := V.map ι0₂.op φ
/-- The middle vertex of a 2-simplex in a 2-truncated simplicial set. -/
def ev1₂ {V : SSet.Truncated 2} (φ : V _⦋2⦌₂) : OneTruncation₂ V := V.map ι1₂.op φ
/-- The final vertex of a 2-simplex in a 2-truncated simplicial set. -/
def ev2₂ {V : SSet.Truncated 2} (φ : V _⦋2⦌₂) : OneTruncation₂ V := V.map ι2₂.op φ
/-- The 0th face of a 2-simplex, as a morphism in the 2-truncated simplex category. -/
def δ0₂ : ⦋1⦌₂ ⟶ ⦋2⦌₂ := δ₂ (n := 1) 0
/-- The 1st face of a 2-simplex, as a morphism in the 2-truncated simplex category. -/
def δ1₂ : ⦋1⦌₂ ⟶ ⦋2⦌₂ := δ₂ (n := 1) 1
/-- The 2nd face of a 2-simplex, as a morphism in the 2-truncated simplex category. -/
def δ2₂ : ⦋1⦌₂ ⟶ ⦋2⦌₂ := δ₂ (n := 1) 2
/-- The arrow in the ReflQuiver `OneTruncation₂ V` of a 2-truncated simplicial set arising from the
0th face of a 2-simplex. -/
def ev12₂ {V : SSet.Truncated 2} (φ : V _⦋2⦌₂) : ev1₂ φ ⟶ ev2₂ φ :=
⟨V.map δ0₂.op φ,
map_map_of_eq V (SimplexCategory.δ_comp_δ (i := 0) (j := 1) (by decide)).symm,
map_map_of_eq V rfl⟩
/-- The arrow in the ReflQuiver `OneTruncation₂ V` of a 2-truncated simplicial set arising from the
1st face of a 2-simplex. -/
def ev02₂ {V : SSet.Truncated 2} (φ : V _⦋2⦌₂) : ev0₂ φ ⟶ ev2₂ φ :=
⟨V.map δ1₂.op φ, map_map_of_eq V rfl, map_map_of_eq V rfl⟩
/-- The arrow in the ReflQuiver `OneTruncation₂ V` of a 2-truncated simplicial set arising from the
2nd face of a 2-simplex. -/
def ev01₂ {V : SSet.Truncated 2} (φ : V _⦋2⦌₂) : ev0₂ φ ⟶ ev1₂ φ :=
⟨V.map δ2₂.op φ, map_map_of_eq V (SimplexCategory.δ_comp_δ (j := 1) le_rfl), map_map_of_eq V rfl⟩
/-- The 2-simplices in a 2-truncated simplicial set `V` generate a hom relation on the free
category on the underlying refl quiver of `V`. -/
inductive HoRel₂ {V : SSet.Truncated 2} :
(X Y : Cat.FreeRefl (OneTruncation₂ V)) → (f g : X ⟶ Y) → Prop
| mk (φ : V _⦋2⦌₂) :
HoRel₂ _ _
(Quot.mk _ (Quiver.Hom.toPath (ev02₂ φ)))
(Quot.mk _ ((Quiver.Hom.toPath (ev01₂ φ)).comp
(Quiver.Hom.toPath (ev12₂ φ))))
/-- A 2-simplex whose faces are identified with certain arrows in `OneTruncation₂ V` defines
a term of type `HoRel₂` between those arrows. -/
theorem HoRel₂.mk' {V : SSet.Truncated 2} (φ : V _⦋2⦌₂) {X₀ X₁ X₂ : OneTruncation₂ V}
(f₀₁ : X₀ ⟶ X₁) (f₁₂ : X₁ ⟶ X₂) (f₀₂ : X₀ ⟶ X₂)
(h₀₁ : f₀₁.edge = V.map (δ₂ 2).op φ) (h₁₂ : f₁₂.edge = V.map (δ₂ 0).op φ)
(h₀₂ : f₀₂.edge = V.map (δ₂ 1).op φ) :
HoRel₂ _ _ (Quot.mk _ (Quiver.Hom.toPath f₀₂))
(Quot.mk _ ((Quiver.Hom.toPath f₀₁).comp (Quiver.Hom.toPath f₁₂))) := by
obtain rfl : X₀ = ev0₂ φ := by
rw [← f₀₂.src_eq, h₀₂, ← FunctorToTypes.map_comp_apply, ← op_comp]
rfl
obtain rfl : X₁ = ev1₂ φ := by
rw [← f₀₁.tgt_eq, h₀₁, ← FunctorToTypes.map_comp_apply, ← op_comp]
rfl
obtain rfl : X₂ = ev2₂ φ := by
rw [← f₁₂.tgt_eq, h₁₂, ← FunctorToTypes.map_comp_apply, ← op_comp]
rfl
obtain rfl : f₀₁ = ev01₂ φ := by ext; assumption
obtain rfl : f₁₂ = ev12₂ φ := by ext; assumption
obtain rfl : f₀₂ = ev02₂ φ := by ext; assumption
constructor
/-- The type underlying the homotopy category of a 2-truncated simplicial set `V`. -/
def _root_.SSet.Truncated.HomotopyCategory (V : SSet.Truncated.{u} 2) : Type u :=
Quotient (HoRel₂ (V := V))
instance (V : SSet.Truncated.{u} 2) : Category.{u} (V.HomotopyCategory) :=
inferInstanceAs (Category (CategoryTheory.Quotient ..))
/-- A canonical functor from the free category on the refl quiver underlying a 2-truncated
simplicial set `V` to its homotopy category. -/
def _root_.SSet.Truncated.HomotopyCategory.quotientFunctor (V : SSet.Truncated.{u} 2) :
Cat.FreeRefl (OneTruncation₂ V) ⥤ V.HomotopyCategory :=
Quotient.functor _
/-- By `Quotient.lift_unique'` (not `Quotient.lift`) we have that `quotientFunctor V` is an
epimorphism. -/
theorem HomotopyCategory.lift_unique' (V : SSet.Truncated.{u} 2) {D} [Category D]
(F₁ F₂ : V.HomotopyCategory ⥤ D)
(h : HomotopyCategory.quotientFunctor V ⋙ F₁ = HomotopyCategory.quotientFunctor V ⋙ F₂) :
F₁ = F₂ :=
Quotient.lift_unique' (C := Cat.FreeRefl (OneTruncation₂ V))
(HoRel₂ (V := V)) _ _ h
/-- A map of 2-truncated simplicial sets induces a functor between homotopy categories. -/
def mapHomotopyCategory {V W : SSet.Truncated.{u} 2} (F : V ⟶ W) :
V.HomotopyCategory ⥤ W.HomotopyCategory :=
CategoryTheory.Quotient.lift _
((oneTruncation₂ ⋙ Cat.freeRefl).map F ⋙ HomotopyCategory.quotientFunctor W)
(by
rintro _ _ _ _ ⟨φ⟩
apply CategoryTheory.Quotient.sound
apply HoRel₂.mk' (φ := F.app _ φ)
(f₀₁ := (oneTruncation₂.map F).map (ev01₂ φ))
(f₀₂ := (oneTruncation₂.map F).map (ev02₂ φ))
(f₁₂ := (oneTruncation₂.map F).map (ev12₂ φ))
all_goals
apply FunctorToTypes.naturality)
/-- The functor that takes a 2-truncated simplicial set to its homotopy category. -/
def hoFunctor₂ : SSet.Truncated.{u} 2 ⥤ Cat.{u,u} where
obj V := Cat.of (V.HomotopyCategory)
map {S T} F := mapHomotopyCategory F
map_id S := by
apply Quotient.lift_unique'
simp [mapHomotopyCategory, Quotient.lift_spec]
exact Eq.trans (Functor.id_comp ..) (Functor.comp_id _).symm
map_comp {S T U} F G := by
apply Quotient.lift_unique'
simp [mapHomotopyCategory, SSet.Truncated.HomotopyCategory.quotientFunctor]
rw [Quotient.lift_spec, Cat.comp_eq_comp, Cat.comp_eq_comp, ← Functor.assoc, Functor.assoc,
Quotient.lift_spec, Functor.assoc, Quotient.lift_spec]
theorem hoFunctor₂_naturality {X Y : SSet.Truncated.{u} 2} (f : X ⟶ Y) :
(oneTruncation₂ ⋙ Cat.freeRefl).map f ⋙ SSet.Truncated.HomotopyCategory.quotientFunctor Y =
SSet.Truncated.HomotopyCategory.quotientFunctor X ⋙ mapHomotopyCategory f := rfl
end Truncated
/-- The functor that takes a simplicial set to its homotopy category by passing through the
2-truncation. -/
def hoFunctor : SSet.{u} ⥤ Cat.{u, u} := SSet.truncation 2 ⋙ Truncated.hoFunctor₂
end
end
section
/-- Since `⦋0⦌ : SimplexCategory` is terminal, `Δ[0]` has a unique point and thus
`OneTruncation₂ ((truncation 2).obj Δ[0])` has a unique inhabitant. -/
instance instUniqueOneTruncation₂DeltaZero : Unique (OneTruncation₂ ((truncation 2).obj Δ[0])) :=
inferInstanceAs (Unique (ULift.{_, 0} (⦋0⦌ ⟶ ⦋0⦌)))
/-- Since `⦋0⦌ : SimplexCategory` is terminal, `Δ[0]` has a unique edge and thus the homs of
`OneTruncation₂ ((truncation 2).obj Δ[0])` have unique inhabitants. -/
instance (x y : OneTruncation₂ ((truncation 2).obj Δ[0])) : Unique (x ⟶ y) where
default := by
obtain rfl : x = default := Unique.uniq _ _
obtain rfl : y = default := Unique.uniq _ _
exact 𝟙rq instUniqueOneTruncation₂DeltaZero.default
uniq _ := by
letI : Subsingleton (((truncation 2).obj Δ[0]).obj (.op ⦋1⦌₂)) :=
inferInstanceAs (Subsingleton (ULift.{_, 0} (⦋1⦌ ⟶ ⦋0⦌)))
ext
exact this.allEq _ _
/-- The category `hoFunctor.obj (Δ[0])` is terminal. -/
def isTerminalHoFunctorDeltaZero : IsTerminal (hoFunctor.obj (Δ[0])) := by
letI : Unique ((truncation 2).obj Δ[0]).HomotopyCategory :=
inferInstanceAs (Unique <| CategoryTheory.Quotient Truncated.HoRel₂)
letI sub : Subsingleton ((truncation 2).obj Δ[0]).HomotopyCategory := by infer_instance
letI : IsDiscrete ((truncation 2).obj Δ[0]).HomotopyCategory :=
{ subsingleton X Y :=
inferInstanceAs <| Subsingleton ((_ : CategoryTheory.Quotient Truncated.HoRel₂) ⟶ _)
eq_of_hom f := sub.allEq _ _ }
apply Cat.isTerminalOfUniqueOfIsDiscrete
/-- The homotopy category functor preserves generic terminal objects. -/
noncomputable def hoFunctor.terminalIso : hoFunctor.obj (⊤_ SSet) ≅ ⊤_ Cat :=
hoFunctor.mapIso (terminalIsoIsTerminal stdSimplex.isTerminalObj₀) ≪≫
(terminalIsoIsTerminal isTerminalHoFunctorDeltaZero).symm
instance hoFunctor.preservesTerminal : PreservesLimit (empty.{0} SSet) hoFunctor :=
preservesTerminal_of_iso hoFunctor hoFunctor.terminalIso
instance hoFunctor.preservesTerminal' :
PreservesLimitsOfShape (Discrete PEmpty.{1}) hoFunctor :=
preservesLimitsOfShape_pempty_of_preservesTerminal _
end
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Op.lean | import Mathlib.AlgebraicTopology.SimplicialObject.Op
import Mathlib.AlgebraicTopology.SimplicialSet.Basic
/-!
# The covariant involution of the category of simplicial sets
In this file, we define the covariant involution `opFunctor : SSet ⥤ SSet`
of the category of simplicial sets that is induced by the
covariant involution `SimplexCategory.op : SimplexCategory ⥤ SimplexCategory`.
We use an abbreviation `X.op` for `opFunctor.obj X`.
## TODO
* Show that this involution sends `Δ[n]` to itself, and that via
this identification, the horn `horn n i` is sent to `horn n i.rev` (@joelriou)
* Construct an isomorphism `nerve Cᵒᵖ ≅ (nerve C).op` (@robin-carlier)
* Show that the topological realization of `X.op` identifies to the
topological realization of `X` (@joelriou)
-/
universe u
open CategoryTheory Simplicial
namespace SSet
/-- The covariant involution of the category of simplicial sets that
is induced by `SimplexCategory.rev : SimplexCategory ⥤ SimplexCategory`. -/
def opFunctor : SSet.{u} ⥤ SSet.{u} := SimplicialObject.opFunctor
/-- The image of a simplicial set by the involution `opFunctor : SSet ⥤ SSet`. -/
protected abbrev op (X : SSet.{u}) : SSet.{u} := opFunctor.obj X
/-- The type of `n`-simplices of `X.op` identify to type of `n`-simplices of `X`. -/
def opObjEquiv {X : SSet.{u}} {n : SimplexCategoryᵒᵖ} :
X.op.obj n ≃ X.obj n := Equiv.refl _
lemma opFunctor_map {X Y : SSet.{u}} (f : X ⟶ Y) {n : SimplexCategoryᵒᵖ} (x : X.op.obj n) :
(opFunctor.map f).app n x = opObjEquiv.symm (f.app _ (opObjEquiv x)) :=
rfl
lemma op_map (X : SSet.{u}) {n m : SimplexCategoryᵒᵖ} (f : n ⟶ m) (x : X.op.obj n) :
X.op.map f x =
opObjEquiv.symm (X.map (SimplexCategory.rev.map f.unop).op (opObjEquiv x)) :=
rfl
@[simp]
lemma op_δ (X : SSet.{u}) {n : ℕ} (i : Fin (n + 2)) (x : X _⦋n + 1⦌) :
X.op.δ i x = opObjEquiv.symm (X.δ i.rev (opObjEquiv x)) := by
simp [SimplicialObject.δ, op_map]
@[simp]
lemma op_σ (X : SSet.{u}) {n : ℕ} (i : Fin (n + 1)) (x : X _⦋n⦌) :
X.op.σ i x = opObjEquiv.symm (X.σ i.rev (opObjEquiv x)) := by
simp [SimplicialObject.σ, op_map]
attribute [local simp] op_map in
/-- The functor `opFunctor : SSet ⥤ SSet` is an involution. -/
@[simps!]
def opFunctorCompOpFunctorIso : opFunctor.{u} ⋙ opFunctor ≅ 𝟭 _ :=
NatIso.ofComponents (fun X ↦ NatIso.ofComponents
(fun n ↦ Equiv.toIso (opObjEquiv.trans opObjEquiv)))
/-- The covariant involution `opFunctor : SSet ⥤ SSet`,
as an equivalence of categories. -/
@[simps]
def opEquivalence : SSet.{u} ≌ SSet.{u} where
functor := opFunctor
inverse := opFunctor
unitIso := opFunctorCompOpFunctorIso.symm
counitIso := opFunctorCompOpFunctorIso
end SSet |
.lake/packages/mathlib/Mathlib/AlgebraicTopology/SimplicialSet/Simplices.lean | import Mathlib.CategoryTheory.Elements
import Mathlib.AlgebraicTopology.SimplicialSet.Subcomplex
/-!
# The preordered type of simplices of a simplicial set
In this file, we define the type `X.S` of simplices of a simplicial set `X`,
where a simplex consists of the data of `dim : ℕ` and `simplex : X _⦋dim⦌`.
We endow this type with a preorder defined by
`x ≤ y ↔ Subcomplex.ofSimplex x.simplex ≤ Subcomplex.ofSimplex y.simplex`.
In particular, as a preordered type, `X.S` is a category, but this is
not what is called "the category of simplices of `X`" in the literature
(and which is `X.Elementsᵒᵖ` in mathlib).
## TODO (@joelriou)
* Extend the `S` structure to define the type of nondegenerate
simplices of a simplicial set `X`, and also the type of nondegenerate
simplices of a simplicial set `X` which do not belong to a given subcomplex.
-/
universe u
open CategoryTheory Simplicial
namespace SSet
variable (X : SSet.{u})
/-- The type of simplices of a simplicial set `X`. This type `X.S` is in bijection
with `X.Elements` (see `SSet.S.equivElements`), but `X.S` is not what the literature
names "category of simplices of `X`", as the category on `X.S` comes from
a preorder (see `S.le_iff_nonempty_hom`). -/
structure S where
/-- the dimension of the simplex -/
{dim : ℕ}
/-- the simplex -/
simplex : X _⦋dim⦌
variable {X}
namespace S
lemma mk_surjective (s : X.S) :
∃ (n : ℕ) (x : X _⦋n⦌), s = mk x :=
⟨s.dim, s.simplex, rfl⟩
/-- The image of a simplex by a morphism of simplicial sets. -/
def map {Y : SSet.{u}} (f : X ⟶ Y) (s : X.S) : Y.S :=
S.mk (f.app _ s.simplex)
lemma dim_eq_of_eq {s t : X.S} (h : s = t) :
s.dim = t.dim :=
congr_arg dim h
lemma dim_eq_of_mk_eq {n m : ℕ} {x : X _⦋n⦌} {y : X _⦋m⦌}
(h : S.mk x = S.mk y) : n = m :=
dim_eq_of_eq h
section
variable (s : X.S) {d : ℕ} (hd : s.dim = d)
/-- When `s : X.S` is such that `s.dim = d`, this is a term
that is equal to `s`, but whose dimension if definitionally equal to `d`. -/
@[simps dim]
def cast : X.S where
dim := d
simplex := _root_.cast (by simp only [hd]) s.simplex
lemma cast_eq_self : s.cast hd = s := by
obtain ⟨d, _, rfl⟩ := s.mk_surjective
obtain rfl := hd
rfl
@[simp]
lemma cast_simplex_rfl : (s.cast rfl).simplex = s.simplex := rfl
end
lemma ext_iff' (s t : X.S) :
s = t ↔ ∃ (h : s.dim = t.dim), (s.cast h).simplex = t.simplex :=
⟨by rintro rfl; exact ⟨rfl, rfl⟩, fun ⟨h₁, h₂⟩ ↦ by
obtain ⟨_, _, rfl⟩ := s.mk_surjective
obtain ⟨_, _, rfl⟩ := t.mk_surjective
aesop⟩
lemma ext_iff {n : ℕ} (x y : X _⦋n⦌) :
S.mk x = S.mk y ↔ x = y := by
simp
/-- The subcomplex generated by a simplex. -/
abbrev subcomplex (s : X.S) : X.Subcomplex := Subcomplex.ofSimplex s.simplex
/-- If `s : X.S` and `t : X.S` are simplices of a simplicial set, `s ≤ t` means
that the subcomplex generated by `s` is contained in the subcomplex generated by `t`,
see `SSet.S.le_def` and `SSet.S.le_iff`. Note that the
category structure on `X.S` induced by this preorder is not
the "category of simplices" of `X` (which is see `X.Elementsᵒᵖ`);
see `SSet.S.le_iff_nonempty_hom` for the precise relation. -/
instance : Preorder X.S := Preorder.lift subcomplex
lemma le_def {s t : X.S} : s ≤ t ↔ s.subcomplex ≤ t.subcomplex :=
Iff.rfl
lemma le_iff {s t : X.S} :
s ≤ t ↔ ∃ (f : ⦋s.dim⦌ ⟶ ⦋t.dim⦌), X.map f.op t.simplex = s.simplex := by
rw [le_def, Subcomplex.ofSimplex_le_iff, Subpresheaf.ofSection_obj, Set.mem_setOf_eq]
tauto
lemma mk_map_le {n m : ℕ} (x : X _⦋n⦌) (f : ⦋m⦌ ⟶ ⦋n⦌) :
S.mk (X.map f.op x) ≤ S.mk x := by
rw [le_iff]
tauto
lemma mk_map_eq_iff_of_mono {n m : ℕ} (x : X _⦋n⦌)
(f : ⦋m⦌ ⟶ ⦋n⦌) [Mono f] :
S.mk (X.map f.op x) = S.mk x ↔ IsIso f := by
constructor
· intro h
obtain rfl := S.dim_eq_of_mk_eq h
obtain rfl := SimplexCategory.eq_id_of_mono f
infer_instance
· intro hf
obtain rfl := SimplexCategory.eq_of_isIso f
obtain rfl := SimplexCategory.eq_id_of_isIso f
simp
/-- The type of simplices of `X : SSet.{u}` identifies to the type
of elements of `X` considered as a functor `SimplexCategoryᵒᵖ ⥤ Type u`.
(Note that this is not an (anti)equivalence of categories,
see `S.le_iff_nonempty_hom`.) -/
@[simps!]
def equivElements : X.S ≃ X.Elements where
toFun s := X.elementsMk _ s.simplex
invFun := by
rintro ⟨⟨n⟩, x⟩
induction n using SimplexCategory.rec
exact S.mk x
left_inv _ := rfl
right_inv _ := rfl
lemma le_iff_nonempty_hom (x y : X.S) :
x ≤ y ↔ Nonempty (equivElements y ⟶ equivElements x) := by
rw [le_iff]
constructor
· rintro ⟨f, hf⟩
exact ⟨⟨f.op, hf⟩⟩
· rintro ⟨f, hf⟩
exact ⟨f.unop, hf⟩
end S
end SSet |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.