|
| 1 | +/- |
| 2 | +Copyright (c) 2019 Scott Morrison. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Scott Morrison |
| 5 | +-/ |
| 6 | +import category_theory.monad.algebra |
| 7 | +import category_theory.adjunction.fully_faithful |
| 8 | + |
| 9 | +namespace category_theory |
| 10 | +open category |
| 11 | + |
| 12 | +universes v₁ v₂ u₁ u₂ -- declare the `v`'s first; see `category_theory.category` for an explanation |
| 13 | + |
| 14 | +variables {C : Type u₁} [𝒞 : category.{v₁} C] {D : Type u₂} [𝒟 : category.{v₂} D] |
| 15 | +include 𝒞 𝒟 |
| 16 | +variables (R : D ⥤ C) |
| 17 | + |
| 18 | +namespace adjunction |
| 19 | + |
| 20 | +instance monad (R : D ⥤ C) [is_right_adjoint R] : monad.{v₁} ((left_adjoint R) ⋙ R) := |
| 21 | +let L := left_adjoint R in |
| 22 | +let h := (is_right_adjoint.adj R) in |
| 23 | +{ η := h.unit, |
| 24 | + μ := whisker_right (whisker_left L h.counit) R, |
| 25 | + assoc' := λ X, by { dsimp, erw [←R.map_comp, h.counit.naturality, R.map_comp], refl }, |
| 26 | + right_unit' := λ X, by { dsimp, rw [←R.map_comp], simp }, } |
| 27 | + |
| 28 | +@[simp] lemma monad_η_app [is_right_adjoint R] (X) : (η_ ((left_adjoint R) ⋙ R)).app X = (is_right_adjoint.adj R).unit.app X := rfl |
| 29 | +@[simp] lemma monad_μ_app [is_right_adjoint R] (X) : (μ_ ((left_adjoint R) ⋙ R)).app X = R.map ((is_right_adjoint.adj R).counit.app ((left_adjoint R).obj X)) := rfl |
| 30 | + |
| 31 | +end adjunction |
| 32 | + |
| 33 | +namespace monad |
| 34 | + |
| 35 | +def comparison [is_right_adjoint R] : D ⥤ algebra ((left_adjoint R) ⋙ R) := |
| 36 | +let h := (is_right_adjoint.adj R) in |
| 37 | +{ obj := λ X, |
| 38 | + { A := R.obj X, |
| 39 | + a := R.map (h.counit.app X), |
| 40 | + assoc' := by { dsimp, conv { to_rhs, erw [←R.map_comp, h.counit.naturality, R.map_comp], }, refl } }, |
| 41 | + map := λ X Y f, |
| 42 | + { f := R.map f, |
| 43 | + h' := begin dsimp, erw [←R.map_comp, h.counit.naturality, R.map_comp, functor.id_map], refl, end } }. |
| 44 | + |
| 45 | +@[simp] lemma comparison_map_f [is_right_adjoint R] {X Y} (f : X ⟶ Y) : ((comparison R).map f).f = R.map f := rfl |
| 46 | +@[simp] lemma comparison_obj_a [is_right_adjoint R] (X) : ((comparison R).obj X).a = R.map ((is_right_adjoint.adj R).counit.app X) := rfl |
| 47 | + |
| 48 | +def comparison_forget [is_right_adjoint R] : comparison R ⋙ forget ((left_adjoint R) ⋙ R) ≅ R := |
| 49 | +{ hom := { app := λ X, 𝟙 _, }, |
| 50 | + inv := { app := λ X, 𝟙 _, } } |
| 51 | + |
| 52 | +end monad |
| 53 | + |
| 54 | +class reflective (R : D ⥤ C) extends is_right_adjoint R, full R, faithful R. |
| 55 | + |
| 56 | +instance μ_iso_of_reflective [reflective R] : is_iso (μ_ ((left_adjoint R) ⋙ R)) := |
| 57 | +by { dsimp [adjunction.monad], apply_instance } |
| 58 | + |
| 59 | +class monadic_right_adjoint (R : D ⥤ C) extends is_right_adjoint R := |
| 60 | +(eqv : is_equivalence (monad.comparison R)) |
| 61 | + |
| 62 | +attribute [instance] monadic_right_adjoint.eqv |
| 63 | + |
| 64 | +-- PROJECT prove Beck's monadicity theorem, e.g. from Section 5.5 of Riehl |
| 65 | + |
| 66 | +namespace reflective |
| 67 | + |
| 68 | +lemma comparison_ess_surj_aux [reflective R] (X : monad.algebra ((left_adjoint R) ⋙ R)) : |
| 69 | + ((is_right_adjoint.adj R).unit).app (R.obj ((left_adjoint R).obj (X.A))) = R.map ((left_adjoint R).map ((is_right_adjoint.adj R).unit.app X.A)) := |
| 70 | +begin |
| 71 | + -- both are left inverses to μ_X. |
| 72 | + apply (cancel_mono ((μ_ ((left_adjoint R) ⋙ R)).app _)).1, |
| 73 | + { dsimp, erw [adjunction.right_triangle_components, ←R.map_comp], simp, }, |
| 74 | + { apply is_iso.mono_of_iso _, |
| 75 | + apply nat_iso.is_iso_app_of_is_iso } |
| 76 | +end |
| 77 | + |
| 78 | +instance [reflective R] (X : monad.algebra ((left_adjoint R) ⋙ R)) : |
| 79 | + is_iso ((is_right_adjoint.adj R).unit.app X.A) := |
| 80 | +let L := left_adjoint R in |
| 81 | +let h := (is_right_adjoint.adj R) in |
| 82 | +{ inv := X.a, |
| 83 | + hom_inv_id' := X.unit, |
| 84 | + inv_hom_id' := |
| 85 | + begin |
| 86 | + dsimp, |
| 87 | + erw [h.unit.naturality, comparison_ess_surj_aux, |
| 88 | + ←R.map_comp, ←L.map_comp, X.unit, L.map_id, R.map_id], |
| 89 | + refl |
| 90 | + end } |
| 91 | + |
| 92 | +instance comparison_ess_surj [reflective R]: ess_surj (monad.comparison R) := |
| 93 | +let L := left_adjoint R in |
| 94 | +let h := (is_right_adjoint.adj R) in |
| 95 | +{ obj_preimage := λ X, L.obj X.A, |
| 96 | + iso' := λ X, |
| 97 | + { hom := |
| 98 | + { f := (as_iso (h.unit.app X.A)).inv, |
| 99 | + h' := |
| 100 | + begin |
| 101 | + dsimp, |
| 102 | + apply (cancel_epi (R.map (L.map ((h.unit).app (X.A))))).1, |
| 103 | + rw [is_iso.hom_inv_id_assoc, ←category.assoc, ←R.map_comp,adjunction.left_triangle_components], |
| 104 | + erw [functor.map_id, category.id_comp], |
| 105 | + apply (cancel_epi ((h.unit).app (X.A))).1, |
| 106 | + rw is_iso.hom_inv_id, |
| 107 | + exact X.unit, |
| 108 | + end }, |
| 109 | + inv := |
| 110 | + { f := (as_iso (h.unit.app X.A)).hom, |
| 111 | + h' := |
| 112 | + begin |
| 113 | + dsimp, |
| 114 | + erw [←R.map_comp, adjunction.left_triangle_components, R.map_id], |
| 115 | + apply (cancel_epi ((h.unit).app (X.A))).1, |
| 116 | + conv { to_rhs, erw [←category.assoc, X.unit] }, |
| 117 | + erw [comp_id, id_comp], |
| 118 | + end }, |
| 119 | + hom_inv_id' := by { ext, exact (as_iso (h.unit.app X.A)).inv_hom_id, }, |
| 120 | + inv_hom_id' := by { ext, exact (as_iso (h.unit.app X.A)).hom_inv_id, }, } } |
| 121 | + |
| 122 | +instance comparison_full [full R] [is_right_adjoint R] : full (monad.comparison R) := |
| 123 | +{ preimage := λ X Y f, R.preimage f.f } |
| 124 | +instance comparison_faithful [faithful R] [is_right_adjoint R] : faithful (monad.comparison R) := |
| 125 | +{ injectivity' := λ X Y f g w, by { have w' := (congr_arg monad.algebra.hom.f w), exact R.injectivity w' } } |
| 126 | + |
| 127 | +end reflective |
| 128 | + |
| 129 | +-- Proposition 5.3.3 of Riehl |
| 130 | +instance monadic_of_reflective [reflective R] : monadic_right_adjoint R := |
| 131 | +{ eqv := equivalence.equivalence_of_fully_faithfully_ess_surj _ } |
| 132 | + |
| 133 | +end category_theory |
0 commit comments