Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit ecdb138

Browse files
kim-emmergify[bot]
andauthored
feat(category/equiv_functor): type-level functoriality w.r.t. equiv (#2255)
* feat(data/equiv/functor): bifunctor.map_equiv * start * sketch of equiv_functor * update * removing unimpressive inhabited example; easier later * omit * revert unnecessary change * fix doc-string * fix names * finish fix Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent d500210 commit ecdb138

File tree

5 files changed

+103
-1
lines changed

5 files changed

+103
-1
lines changed

src/category/equiv_functor.lean

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/-
2+
Copyright (c) 2020 Scott Morrison. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Author: Scott Morrison
5+
-/
6+
7+
import category_theory.category
8+
import data.equiv.functor
9+
10+
/-!
11+
# Functions functorial with respect to equivalences
12+
13+
An `equiv_functor` is a function from `Type → Type` equipped with the additional data of
14+
coherently mapping equivalences to equivalences.
15+
16+
In categorical language, it is an endofunctor of the "core" of the category `Type`.
17+
-/
18+
19+
universes u₀ u₁ u₂ v₀ v₁ v₂
20+
21+
open function
22+
23+
/--
24+
An `equiv_functor` is only functorial with respect to equivalences.
25+
26+
To construct an `equiv_functor`, it suffices to supply just the function `f α → f β` from
27+
an equivalence `α ≃ β`, and then prove the functor laws. It's then a consequence that
28+
this function is part of an equivalence, provided by `equiv_functor.map_equiv`.
29+
-/
30+
class equiv_functor (f : Type u₀ → Type u₁) :=
31+
(map : Π {α β}, (α ≃ β) → (f α → f β))
32+
(map_refl' : Π α, map (equiv.refl α) = @id (f α) . obviously)
33+
(map_trans' : Π {α β γ} (k : α ≃ β) (h : β ≃ γ),
34+
map (k.trans h) = (map h) ∘ (map k) . obviously)
35+
36+
restate_axiom equiv_functor.map_refl'
37+
restate_axiom equiv_functor.map_trans'
38+
attribute [simp] equiv_functor.map_refl
39+
40+
namespace equiv_functor
41+
42+
section
43+
variables (f : Type u₀ → Type u₁) [equiv_functor f] {α β : Type u₀} (e : α ≃ β)
44+
45+
/-- An `equiv_functor` in fact takes every equiv to an equiv. -/
46+
def map_equiv :
47+
f α ≃ f β :=
48+
{ to_fun := equiv_functor.map e,
49+
inv_fun := equiv_functor.map e.symm,
50+
left_inv := λ x, begin convert (congr_fun (equiv_functor.map_trans f e e.symm) x).symm, simp, end,
51+
right_inv := λ y, begin convert (congr_fun (equiv_functor.map_trans f e.symm e) y).symm, simp, end, }
52+
53+
@[simp] lemma map_equiv_apply (x : f α) :
54+
map_equiv f e x = equiv_functor.map e x := rfl
55+
56+
@[simp] lemma map_equiv_symm_apply (y : f β) :
57+
(map_equiv f e).symm y = equiv_functor.map e.symm y := rfl
58+
end
59+
60+
@[priority 100]
61+
instance of_is_lawful_functor
62+
(f : Type u₀ → Type u₁) [functor f] [is_lawful_functor f] : equiv_functor f :=
63+
{ map := λ α β e, functor.map e,
64+
map_refl' := λ α, by { ext, apply is_lawful_functor.id_map, },
65+
map_trans' := λ α β γ k h, by { ext x, apply (is_lawful_functor.comp_map k h x), } }
66+
67+
-- TODO Include more examples here;
68+
-- once `equiv_rw` is available these are hopefully easy to construct,
69+
-- and in turn make `equiv_rw` more powerful.
70+
instance equiv_functor_unique : equiv_functor unique :=
71+
{ map := λ α β e, equiv.unique_congr e, }
72+
73+
end equiv_functor

src/category_theory/core.lean

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Authors: Scott Morrison
66

77
import category_theory.groupoid
88
import category_theory.whiskering
9+
import category.equiv_functor
10+
import category_theory.types
911

1012
namespace category_theory
1113

@@ -47,4 +49,24 @@ def functor_to_core (F : G ⥤ C) : G ⥤ core C :=
4749
def forget_functor_to_core : (G ⥤ core C) ⥤ (G ⥤ C) := (whiskering_right _ _ _).obj inclusion
4850
end core
4951

52+
omit 𝒞
53+
54+
/--
55+
`of_equiv_functor m` lifts a type-level `equiv_functor`
56+
to a categorical functor `core (Type u₁) ⥤ core (Type u₂)`.
57+
-/
58+
def of_equiv_functor (m : Type u₁ → Type u₂) [equiv_functor m] :
59+
core (Type u₁) ⥤ core (Type u₂) :=
60+
{ obj := m,
61+
map := λ α β f, (equiv_functor.map_equiv m f.to_equiv).to_iso,
62+
-- These are not very pretty.
63+
map_id' := λ α, begin ext, exact (congr_fun (equiv_functor.map_refl _ _) x), end,
64+
map_comp' := λ α β γ f g,
65+
begin
66+
ext,
67+
simp only [equiv_functor.map_equiv_apply, equiv.to_iso_hom,
68+
function.comp_app, core.comp_hom, types_comp],
69+
erw [iso.to_equiv_comp, equiv_functor.map_trans],
70+
end, }
71+
5072
end category_theory

src/category_theory/types.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def to_iso (e : X ≃ Y) : X ≅ Y :=
160160
end equiv
161161

162162
namespace category_theory.iso
163+
open category_theory
163164

164165
universe u
165166

@@ -174,6 +175,10 @@ def to_equiv (i : X ≅ Y) : X ≃ Y :=
174175
@[simp] lemma to_equiv_fun (i : X ≅ Y) : (i.to_equiv : X → Y) = i.hom := rfl
175176
@[simp] lemma to_equiv_symm_fun (i : X ≅ Y) : (i.to_equiv.symm : Y → X) = i.inv := rfl
176177

178+
@[simp] lemma to_equiv_id (X : Type u) : (iso.refl X).to_equiv = equiv.refl X := rfl
179+
@[simp] lemma to_equiv_comp {X Y Z : Type u} (f : X ≅ Y) (g : Y ≅ Z) :
180+
(f ≪≫ g).to_equiv = f.to_equiv.trans (g.to_equiv) := rfl
181+
177182
end category_theory.iso
178183

179184

src/data/equiv/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ calc (false → α) ≃ (empty → α) : arrow_congr false_equiv_empty (equiv.re
298298

299299
end
300300

301-
@[congr] def prod_congr {α₁ β₁ α₂ β₂ : Sort*} (e₁ : α₁ ≃ α₂) (e₂ :β₁ ≃ β₂) : α₁ × β₁ ≃ α₂ × β₂ :=
301+
@[congr] def prod_congr {α₁ β₁ α₂ β₂ : Sort*} (e₁ : α₁ ≃ α₂) (e₂ : β₁ ≃ β₂) : α₁ × β₁ ≃ α₂ × β₂ :=
302302
⟨λp, (e₁ p.1, e₂ p.2), λp, (e₁.symm p.1, e₂.symm p.2),
303303
λ ⟨a, b⟩, show (e₁.symm (e₁ a), e₂.symm (e₂ b)) = (a, b), by rw [symm_apply_apply, symm_apply_apply],
304304
λ ⟨a, b⟩, show (e₁ (e₁.symm a), e₂ (e₂.symm b)) = (a, b), by rw [apply_symm_apply, apply_symm_apply]⟩

src/logic/unique.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ Copyright (c) 2019 Johan Commelin. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johan Commelin
55
-/
6+
import tactic.ext
67

78
universes u v w
89

910
variables {α : Sort u} {β : Sort v} {γ : Sort w}
1011

12+
@[ext]
1113
structure unique (α : Sort u) extends inhabited α :=
1214
(uniq : ∀ a:α, a = default)
1315

0 commit comments

Comments
 (0)