Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat(algebraic_topology): introduce the simplex category #6173

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
e982fb9
feature(fin): cast_succ_mk and succ_mk simp lemmas
semorrison Feb 8, 2021
fb2fa5b
more cast lemmas, and fix some doc-strings
semorrison Feb 8, 2021
3036326
broken
semorrison Feb 8, 2021
d3b93fd
Merge branch 'fin_cast_succ_mk' into pred_above
semorrison Feb 8, 2021
f83e244
hrmm... pred_above is being used differently than I expected
semorrison Feb 8, 2021
0422730
chore(data/fin): reorder file to group declarations
pechersky Feb 8, 2021
5cd8588
fix and make proof more robust
fpvandoorn Feb 8, 2021
e5372d9
section titles
pechersky Feb 8, 2021
2b03eb3
fix missing simp call
pechersky Feb 8, 2021
72d0f8c
fix rw
pechersky Feb 8, 2021
8dd5420
still broken
semorrison Feb 9, 2021
2a54476
maybe good
semorrison Feb 9, 2021
0641792
Merge remote-tracking branch 'origin/master' into pred_above
semorrison Feb 9, 2021
ecc4d70
restoring insert_nth
semorrison Feb 9, 2021
6ada915
doc-strings
semorrison Feb 9, 2021
2814b97
fix
semorrison Feb 9, 2021
cb8604c
merge
semorrison Feb 9, 2021
b1b36c9
cleanup
semorrison Feb 9, 2021
96cd0d3
update docs
semorrison Feb 9, 2021
aa798e6
reorg
semorrison Feb 9, 2021
0119f6a
purge `pred_above'` and add `cast_pred`
pechersky Feb 10, 2021
d22811e
Merge remote-tracking branch 'refs/remotes/origin/pred_above' into pr…
pechersky Feb 10, 2021
fb9eb33
repurge pred_above'
pechersky Feb 10, 2021
d0df714
merge
semorrison Feb 10, 2021
d74d6e5
Merge branch 'fin_cast_succ_mk' into pred_above
semorrison Feb 10, 2021
cd33ed8
Rob's fix for linarith error
semorrison Feb 10, 2021
83cca03
Merge branch 'pred_above' of github.com:leanprover-community/mathlib …
semorrison Feb 10, 2021
32c61c3
fix error
pechersky Feb 11, 2021
79276b0
remove evil second instance of has_zero
semorrison Feb 11, 2021
af09a1e
feat(data/fin): pred_above_monotone
semorrison Feb 11, 2021
5aeb62b
feat(simplex_category): introduce the simplex category
semorrison Feb 11, 2021
5a6b795
feat(simplex_category): introduce the simplex category
semorrison Feb 11, 2021
f38cb6f
restore simp lemma
semorrison Feb 11, 2021
56aad54
fixes
semorrison Feb 11, 2021
41f765a
linting
semorrison Feb 11, 2021
f601768
Merge branch 'succ_above_monotone' into simplex_category
semorrison Feb 11, 2021
8c923b6
cast_pred simp lemmas
pechersky Feb 11, 2021
b11d13d
cast_pred mention in module docstring
pechersky Feb 11, 2021
3b047a3
Merge remote-tracking branch 'origin/pred_above' into succ_above_mono…
pechersky Feb 11, 2021
c7973d0
cast_pred_monotone
pechersky Feb 11, 2021
a698bb9
pred_above_left_monotone
pechersky Feb 11, 2021
6a00a0b
Update src/data/fin.lean
semorrison Feb 11, 2021
9684d1c
Merge remote-tracking branch 'origin/pred_above' into succ_above_mono…
semorrison Feb 11, 2021
20c5b8e
Merge branch 'succ_above_monotone' of github.com:leanprover-community…
semorrison Feb 11, 2021
2b3a816
Merge remote-tracking branch 'origin/master' into succ_above_monotone
semorrison Feb 11, 2021
8f31531
Merge branch 'succ_above_monotone' into simplex_category
semorrison Feb 11, 2021
44f43a7
use category_theory.skeletal
semorrison Feb 12, 2021
2be9ebf
fix
semorrison Feb 12, 2021
19e67af
fill in sorry
semorrison Feb 12, 2021
f4f9e6d
linting
semorrison Feb 12, 2021
22c7c5f
merge
semorrison Feb 13, 2021
13d2e7e
Merge branch 'pred_above' into succ_above_monotone
semorrison Feb 13, 2021
93760b5
Merge branch 'succ_above_monotone' into simplex_category
semorrison Feb 13, 2021
71a1357
merge
semorrison Feb 17, 2021
418a6dc
Merge branch 'succ_above_monotone' into simplex_category
semorrison Feb 17, 2021
16a06fa
move to algebraic_topology/ per jcommelin's suggestion
semorrison Feb 17, 2021
9aa6253
remove unnecessary instance name
semorrison Feb 17, 2021
f3c89bf
oops, bad merge
semorrison Feb 17, 2021
be7a36c
Merge branch 'succ_above_monotone' into simplex_category
semorrison Feb 17, 2021
80514da
cleanup
semorrison Feb 18, 2021
8d5d3f6
Merge remote-tracking branch 'origin/master' into simplex_category
semorrison Feb 18, 2021
5c1eac8
Merge remote-tracking branch 'origin/master' into simplex_category
semorrison Feb 23, 2021
f260687
fixes
semorrison Feb 23, 2021
e0f4ea4
replace some non-terminal simps with suffices
jcommelin Feb 24, 2021
d374b96
finish removing non-terminal simps?
semorrison Feb 25, 2021
115cf2b
Merge remote-tracking branch 'origin/master' into simplex_category
semorrison Feb 25, 2021
aaef009
Apply b-mehta's suggestions from code review
semorrison Feb 25, 2021
314f511
lint
semorrison Feb 25, 2021
81a92a3
Apply suggestions from code review
jcommelin Feb 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
252 changes: 252 additions & 0 deletions src/algebraic_topology/simplex_category.lean
@@ -0,0 +1,252 @@
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/

import order.category.NonemptyFinLinOrd
import category_theory.skeletal
import data.finset.sort
import tactic.linarith

/-! # The simplex category

We construct a skeletal model of the simplex category, with objects `ℕ` and the
morphism `n ⟶ m` being the monotone maps from `fin (n+1)` to `fin (m+1)`.

We show that this category is equivalent to `NonemptyFinLinOrd`.
-/

universe variables u

open category_theory

/-- The simplex category:
* objects are natural numbers `n : ℕ`
* morphisms from `n` to `m` are monotone functions `fin (n+1) → fin (m+1)`
-/
@[derive inhabited]
def simplex_category := ℕ

namespace simplex_category

instance : small_category simplex_category :=
{ hom := λ n m, preorder_hom (fin (n+1)) (fin (m+1)),
id := λ m, preorder_hom.id,
comp := λ _ _ _ f g, preorder_hom.comp g f, }

@[simp] lemma id_apply {n : simplex_category} (i : fin (n+1)) :
(𝟙 n : fin _ → fin _) i = i := rfl
@[simp] lemma comp_apply {l m n : simplex_category} (f : l ⟶ m) (g : m ⟶ n) (i : fin (l+1)) :
(f ≫ g) i = g (f i) := rfl

section generators
/-!
## Generating maps for the simplex category

PROJECT: prove that the simplex category is equivalent to
semorrison marked this conversation as resolved.
Show resolved Hide resolved
one given by the following generators and relations.
-/

/-- The `i`-th face map from `[n]` to `[n+1]` -/
def δ {n} (i : fin (n+2)) :
@has_hom.hom simplex_category _ n (n+1 : ℕ) :=
(fin.succ_above i).to_preorder_hom

/-- The `i`-th degeneracy map from `[n+1]` to `[n]` -/
def σ {n} (i : fin (n+1)) :
@has_hom.hom simplex_category _ (n+1 : ℕ) n :=
{ to_fun := fin.pred_above i,
monotone' := fin.pred_above_right_monotone i }

/-- The generic case of the first simplicial identity -/
lemma δ_comp_δ {n} {i j : fin (n+2)} (H : i ≤ j) :
δ i ≫ δ j.succ = δ j ≫ δ i.cast_succ :=
begin
ext k,
dsimp [δ, fin.succ_above],
rcases i with ⟨i, _⟩,
rcases j with ⟨j, _⟩,
rcases k with ⟨k, _⟩,
split_ifs; { simp at *; linarith },
end

/-- The special case of the first simplicial identity -/
lemma δ_comp_δ_self {n} {i : fin (n+2)} : δ i ≫ δ i.cast_succ = δ i ≫ δ i.succ :=
begin
ext j,
dsimp [δ, fin.succ_above],
rcases i with ⟨i, _⟩,
rcases j with ⟨j, _⟩,
split_ifs; { simp at *; linarith },
end

/-- The second simplicial identity -/
lemma δ_comp_σ_of_le {n} {i : fin (n+2)} {j : fin (n+1)} (H : i ≤ j.cast_succ) :
δ i.cast_succ ≫ σ j.succ = σ j ≫ δ i :=
begin
ext k,
dsimp [δ, σ, fin.succ_above, fin.pred_above],
rcases i with ⟨i, _⟩,
rcases j with ⟨j, _⟩,
rcases k with ⟨k, _⟩,
simp only [subtype.mk_le_mk, fin.cast_succ_mk] at H,
simp with push_cast, -- `simp?` doesn't work here
semorrison marked this conversation as resolved.
Show resolved Hide resolved
split_ifs,
-- Hope for the best from `linarith`:
all_goals { simp at *, try { linarith }, },
-- Two of the goals need special handling:
{ replace h_3 := nat.le_of_pred_lt h_3, change k ≤ i at h_3, linarith, },
{ exact (nat.succ_pred_eq_of_pos (lt_of_le_of_lt (zero_le _) h_1)).symm, },
end

/-- The first part of the third simplicial identity -/
lemma δ_comp_σ_self {n} {i : fin (n+1)} :
δ i.cast_succ ≫ σ i = 𝟙 _ :=
begin
ext j,
rcases i with ⟨i, _⟩,
rcases j with ⟨j, _⟩,
dsimp [δ, σ, fin.succ_above, fin.pred_above],
simp with push_cast,
split_ifs; { simp at *; linarith, },
end

/-- The second part of the third simplicial identity -/
lemma δ_comp_σ_succ {n} {i : fin (n+1)} :
δ i.succ ≫ σ i = 𝟙 _ :=
begin
ext j,
rcases i with ⟨i, _⟩,
rcases j with ⟨j, _⟩,
dsimp [δ, σ, fin.succ_above, fin.pred_above],
simp with push_cast,
split_ifs; { simp at *; linarith, },
end

/-- The fourth simplicial identity -/
lemma δ_comp_σ_of_gt {n} {i : fin (n+2)} {j : fin (n+1)} (H : j.cast_succ < i) :
δ i.succ ≫ σ j.cast_succ = σ j ≫ δ i :=
begin
ext k,
dsimp [δ, σ, fin.succ_above, fin.pred_above],
rcases i with ⟨i, _⟩,
rcases j with ⟨j, _⟩,
rcases k with ⟨k, _⟩,
simp at H,
semorrison marked this conversation as resolved.
Show resolved Hide resolved
-- rw apply_dite fin.cast_succ,
semorrison marked this conversation as resolved.
Show resolved Hide resolved
simp [apply_dite fin.cast_succ] with push_cast, -- `simp?` doesn't work here
split_ifs,
-- Hope for the best from `linarith`:
any_goals { simp at *, try { linarith }, },
-- Four of the goals need special handling:
{ simp at h_1,
exact lt_irrefl (k - 1) (lt_of_lt_of_le
(nat.pred_lt (ne_of_lt (lt_of_le_of_lt (zero_le _) h_1)).symm)
(le_trans (nat.le_of_lt_succ h) h_2)) },
{ simp at h_1, linarith, },
{ exfalso, exact lt_irrefl _ (lt_of_le_of_lt (nat.le_pred_of_lt (nat.lt_of_succ_le h)) h_3), },
{ exact (nat.succ_pred_eq_of_pos (lt_of_le_of_lt (zero_le _) h_2)).symm, },
end

local attribute [simp] fin.pred_mk

/-- The fifth simplicial identity -/
lemma σ_comp_σ {n} {i j : fin (n+1)} (H : i ≤ j) :
σ i.cast_succ ≫ σ j = σ j.succ ≫ σ i :=
begin
ext k,
dsimp [σ, fin.pred_above],
rcases i with ⟨i, _⟩,
rcases j with ⟨j, _⟩,
rcases k with ⟨k, _⟩,
simp at H,
simp with push_cast,
semorrison marked this conversation as resolved.
Show resolved Hide resolved
split_ifs,
-- Hope for the best from `linarith`:
any_goals { simp at *, try { linarith }, },
semorrison marked this conversation as resolved.
Show resolved Hide resolved
{ exact false.elim
(lt_irrefl (k - 1)
(lt_of_lt_of_le (nat.pred_lt (id (ne_of_lt (lt_of_le_of_lt (zero_le i) h)).symm))
(le_trans h_2 (nat.succ_le_of_lt h_1)))) },
{ exact false.elim
(lt_irrefl j (lt_of_lt_of_le (nat.pred_lt_pred (nat.succ_ne_zero j) h_2) h_1)) },
end

end generators

section skeleton

lemma skeletal : skeletal simplex_category :=
λ X Y I,
begin
rcases I with ⟨I⟩,
suffices : fintype.card (fin (X+1)) = fintype.card (fin (Y+1)),
{ simpa, },
{ apply fintype.card_congr,
refine ⟨I.hom, I.inv, _, _⟩,
intro x, exact congr_fun (congr_arg (preorder_hom.to_fun) I.hom_inv_id : _) x,
intro y, exact congr_fun (congr_arg (preorder_hom.to_fun) I.inv_hom_id : _) y, }
end

/-- The functor that exhibits `simplex_category` as skeleton
of `NonemptyFinLinOrd` -/
def skeletal_functor :
simplex_category ⥤ NonemptyFinLinOrd.{u} :=
jcommelin marked this conversation as resolved.
Show resolved Hide resolved
{ obj := λ n, NonemptyFinLinOrd.of $ ulift (fin (n+1)),
map := λ m n f, ⟨λ i, ⟨f i.down⟩, λ ⟨i⟩ ⟨j⟩ h, show f i ≤ f j, from f.monotone h⟩, }
semorrison marked this conversation as resolved.
Show resolved Hide resolved

namespace skeletal_functor

instance : full skeletal_functor.{u} :=
{ preimage := λ m n f, ⟨λ i, (f ⟨i⟩).down, λ i j h, f.monotone h⟩,
witness' := by { intros m n f, dsimp at *, ext1 ⟨i⟩, ext1, refl } }

instance : faithful skeletal_functor.{u} :=
{ map_injective' := λ m n f g h,
begin
ext1 i, apply equiv.ulift.symm.injective,
semorrison marked this conversation as resolved.
Show resolved Hide resolved
show skeletal_functor.map f ⟨i⟩ = skeletal_functor.map g ⟨i⟩,
rw h,
end }

instance : ess_surj skeletal_functor.{u} :=
{ mem_ess_image := λ X, ⟨(fintype.card X - 1 : ℕ), ⟨begin
have aux : fintype.card X = fintype.card X - 1 + 1,
{ exact (nat.succ_pred_eq_of_pos $ fintype.card_pos_iff.mpr ⟨⊥⟩).symm, },
let f := mono_equiv_of_fin X aux,
have hf := (finset.univ.order_emb_of_fin aux).strict_mono,
refine
{ hom := ⟨λ i, f i.down, _⟩,
inv := ⟨λ i, ⟨f.symm i⟩, _⟩,
hom_inv_id' := _,
inv_hom_id' := _ },
{ rintro ⟨i⟩ ⟨j⟩ h, show f i ≤ f j, exact hf.monotone h, },
{ intros i j h, show f.symm i ≤ f.symm j, rw ← hf.le_iff_le,
show f (f.symm i) ≤ f (f.symm j), simpa only [order_iso.apply_symm_apply], },
{ ext1 ⟨i⟩, ext1, exact f.symm_apply_apply i },
{ ext1 i, exact f.apply_symm_apply i },
end⟩⟩,}

noncomputable instance is_equivalence : is_equivalence skeletal_functor.{u} :=
equivalence.equivalence_of_fully_faithfully_ess_surj skeletal_functor

end skeletal_functor

/-- The equivalence that exhibits `simplex_category` as skeleton
of `NonemptyFinLinOrd` -/
noncomputable def skeletal_equivalence :
simplex_category ≌ NonemptyFinLinOrd.{u} :=
jcommelin marked this conversation as resolved.
Show resolved Hide resolved
functor.as_equivalence skeletal_functor.{u}

end skeleton

/--
`simplex_category` is a skeleton of `NonemptyFinLinOrd`.
-/
noncomputable
def is_skeleton_of : is_skeleton_of NonemptyFinLinOrd.{u} simplex_category skeletal_functor.{u} :=
{ skel := skeletal,
eqv := is_equivalence.of_equivalence skeletal_equivalence }
semorrison marked this conversation as resolved.
Show resolved Hide resolved

end simplex_category
6 changes: 6 additions & 0 deletions src/data/fin.lean
Expand Up @@ -726,6 +726,12 @@ by { cases i, refl }
fin.pred ⟨i + 1, add_lt_add_right h 1⟩ (ne_of_vne (ne_of_gt (mk_succ_pos i h))) = ⟨i, h⟩ :=
by simp only [ext_iff, coe_pred, coe_mk, nat.add_sub_cancel]

-- This is not a simp lemma by default, because `pred_mk_succ` is nicer when it applies.
lemma pred_mk {n : ℕ} (i : ℕ) (h : i < n + 1) (w) :
fin.pred ⟨i, h⟩ w =
⟨i - 1, by rwa nat.sub_lt_right_iff_lt_add (nat.pos_of_ne_zero (fin.vne_of_ne w))⟩ :=
rfl

@[simp] lemma pred_le_pred_iff {n : ℕ} {a b : fin n.succ} {ha : a ≠ 0} {hb : b ≠ 0} :
a.pred ha ≤ b.pred hb ↔ a ≤ b :=
by rw [←succ_le_succ_iff, succ_pred, succ_pred]
Expand Down