Documentation

ToMathlib.Control.Monad.Relative

Relative monad #

This file defines the RelativeMonad type class, both as a category-theoretic object and a programming object.

structure CategoryTheory.RelativeMonad (C : Type u₁) [Category.{v₁, u₁} C] (D : Type u₂) [Category.{v₂, u₂} D] (J : Functor C D) :
Type (max (max u₁ u₂) v₂)

The data of a relative monad over a functor J : C ⟶ D consists of:

  • a map between objects T : C → D
  • a natural transformation η : ∀ {X}, J X ⟶ T X
  • a natural transformation μ : ∀ {X Y}, (J X ⟶ T Y) ⟶ (T X ⟶ T Y) satisfying three equations:
  • μ_{X, X} ∘ η_X = 1_{T X} (left unit)
  • ∀ f, η_X ≫ μ_{X, Y} = f (right unit)
  • ∀ f g, μ_{X, Z} (f ≫ μ_{Y, Z} g) = μ_{X, Y} f ≫ μ_{Y, Z} g (associativity)
Instances For
    @[simp]
    theorem CategoryTheory.RelativeMonad.right_unit_assoc {C : Type u₁} [Category.{v₁, u₁} C] {D : Type u₂} [Category.{v₂, u₂} D] {J : Functor C D} (self : RelativeMonad C D J) {X Y : C} (f : J.obj X self.T Y) {Z : D} (h : self.T Y Z) :

    η composed with μ is identity.

    @[simp]
    theorem CategoryTheory.RelativeMonad.left_unit_assoc {C : Type u₁} [Category.{v₁, u₁} C] {D : Type u₂} [Category.{v₂, u₂} D] {J : Functor C D} (self : RelativeMonad C D J) {X : C} {Z : D} (h : self.T X Z) :
    CategoryStruct.comp (self.μ self.η) h = h

    μ applied to η is identity.

    @[simp]
    theorem CategoryTheory.RelativeMonad.assoc_assoc {C : Type u₁} [Category.{v₁, u₁} C] {D : Type u₂} [Category.{v₂, u₂} D] {J : Functor C D} (self : RelativeMonad C D J) {X Y Z : C} (f : J.obj X self.T Y) (g : J.obj Y self.T Z) {Z✝ : D} (h : self.T Z Z✝) :

    μ is associative.

    The functor induced by a relative monad.

    Note: this is not the same as the underlying functor of the relative monad.

    Equations
      Instances For
        @[simp]
        theorem CategoryTheory.RelativeMonad.inducedFunctor_map {C : Type u₁} [Category.{v₁, u₁} C] {D : Type u₂} [Category.{v₂, u₂} D] {J : Functor C D} (M : RelativeMonad C D J) {X✝ Y✝ : C} (f : X✝ Y✝) :
        @[simp]

        The natural transformation from the underlying functor of the relative monad, to the functor induced by the relative monad.

        Equations
          Instances For

            If a relative monad is over the identity functor, it is a monad.

            Equations
              Instances For
                def CategoryTheory.RelativeMonad.ofNatIso {C : Type u₁} [Category.{v₁, u₁} C] {D : Type u₂} [Category.{v₂, u₂} D] {J₁ J₂ : Functor C D} (φ : J₁ J₂) (M : RelativeMonad C D J₁) :
                RelativeMonad C D J₂

                Transport a relative monad along a natural isomorphism of the underlying functor.

                Equations
                  Instances For
                    def CategoryTheory.RelativeMonad.precompose {C : Type u₁} [Category.{v₁, u₁} C] {D : Type u₂} [Category.{v₂, u₂} D] {J : Functor C D} {C' : Type u₃} [Category.{v₃, u₃} C'] (J' : Functor C' C) (M : RelativeMonad C D J) :
                    RelativeMonad C' D (J'.comp J)

                    Precompose a relative monad M : RelativeMonad C D J along a functor J' : C' ⥤ C.

                    Equations
                      Instances For
                        def CategoryTheory.RelativeMonad.prod {C₁ : Type u₁} [Category.{v₁, u₁} C₁] {D₁ : Type u₂} [Category.{v₂, u₂} D₁] {C₂ : Type u₃} [Category.{v₃, u₃} C₂] {D₂ : Type u₄} [Category.{v₄, u₄} D₂] {J₁ : Functor C₁ D₁} {J₂ : Functor C₂ D₂} (M₁ : RelativeMonad C₁ D₁ J₁) (M₂ : RelativeMonad C₂ D₂ J₂) :
                        RelativeMonad (C₁ × C₂) (D₁ × D₂) (J₁.prod J₂)

                        The product of two relative monads is a relative monad on the corresponding product categories.

                        Equations
                          Instances For
                            @[simp]
                            theorem CategoryTheory.RelativeMonad.prod_μ {C₁ : Type u₁} [Category.{v₁, u₁} C₁] {D₁ : Type u₂} [Category.{v₂, u₂} D₁] {C₂ : Type u₃} [Category.{v₃, u₃} C₂] {D₂ : Type u₄} [Category.{v₄, u₄} D₂] {J₁ : Functor C₁ D₁} {J₂ : Functor C₂ D₂} (M₁ : RelativeMonad C₁ D₁ J₁) (M₂ : RelativeMonad C₂ D₂ J₂) {X✝ Y✝ : C₁ × C₂} (f : (J₁.prod J₂).obj X✝ (M₁.T Y✝.1, M₂.T Y✝.2)) :
                            (M₁.prod M₂).μ f = (M₁.μ f.1, M₂.μ f.2)
                            @[simp]
                            theorem CategoryTheory.RelativeMonad.prod_η {C₁ : Type u₁} [Category.{v₁, u₁} C₁] {D₁ : Type u₂} [Category.{v₂, u₂} D₁] {C₂ : Type u₃} [Category.{v₃, u₃} C₂] {D₂ : Type u₄} [Category.{v₄, u₄} D₂] {J₁ : Functor C₁ D₁} {J₂ : Functor C₂ D₂} (M₁ : RelativeMonad C₁ D₁ J₁) (M₂ : RelativeMonad C₂ D₂ J₂) {X✝ : C₁ × C₂} :
                            (M₁.prod M₂).η = (M₁.η, M₂.η)
                            @[simp]
                            theorem CategoryTheory.RelativeMonad.prod_T {C₁ : Type u₁} [Category.{v₁, u₁} C₁] {D₁ : Type u₂} [Category.{v₂, u₂} D₁] {C₂ : Type u₃} [Category.{v₃, u₃} C₂] {D₂ : Type u₄} [Category.{v₄, u₄} D₂] {J₁ : Functor C₁ D₁} {J₂ : Functor C₂ D₂} (M₁ : RelativeMonad C₁ D₁ J₁) (M₂ : RelativeMonad C₂ D₂ J₂) (X : C₁ × C₂) :
                            (M₁.prod M₂).T X = (M₁.T X.1, M₂.T X.2)
                            structure CategoryTheory.RelativeMonadHom {C : Type u₁} [Category.{v₁, u₁} C] {D₁ : Type u₂} [Category.{v₂, u₂} D₁] {D₂ : Type u₃} [Category.{v₃, u₃} D₂] {J₁ : Functor C D₁} {J₂ : Functor C D₂} (M₁ : RelativeMonad C D₁ J₁) (M₂ : RelativeMonad C D₂ J₂) :
                            Type (max (max (max (max u₁ u₂) u₃) v₂) v₃)

                            A morphism of relative monads, where the two ending categories may be different. We require another functor & a natural isomorphism to correct for this discrepancy.

                            Instances For
                              @[simp]
                              theorem CategoryTheory.RelativeMonadHom.map_η_assoc {C : Type u₁} [Category.{v₁, u₁} C] {D₁ : Type u₂} [Category.{v₂, u₂} D₁] {D₂ : Type u₃} [Category.{v₃, u₃} D₂] {J₁ : Functor C D₁} {J₂ : Functor C D₂} {M₁ : RelativeMonad C D₁ J₁} {M₂ : RelativeMonad C D₂ J₂} (self : RelativeMonadHom M₁ M₂) {X : C} {Z : D₂} (h : M₂.T X Z) :
                              @[simp]
                              theorem CategoryTheory.RelativeMonadHom.map_μ_assoc {C : Type u₁} [Category.{v₁, u₁} C] {D₁ : Type u₂} [Category.{v₂, u₂} D₁] {D₂ : Type u₃} [Category.{v₃, u₃} D₂] {J₁ : Functor C D₁} {J₂ : Functor C D₂} {M₁ : RelativeMonad C D₁ J₁} {M₂ : RelativeMonad C D₂ J₂} (self : RelativeMonadHom M₁ M₂) {X Y : C} (f : J₁.obj X M₁.T Y) {Z : D₂} (h : M₂.T Y Z) :

                              Old stuff below. #

                              Turns out one cannot just work with Type u → Type v, since in the relational context, relative relational specification monad actually has signature Type u₁ × Type u₂ → Type v₁ × Type v₂. This means that we have to develop the general theory at the category-theoretic level.

                              class RelativePure (j : Type u → Type w) (f : Type u → Type v) :
                              Type (max (max (u + 1) v) w)

                              Type class for the relative pure operation

                              • pureᵣ {α : Type u} : j αf α

                                The relative pure operation

                              Instances
                                class RelativeBind (j : Type u → Type w) (m : Type u → Type v) :
                                Type (max (max (u + 1) v) w)

                                Type class for the relative bind operation

                                • bindᵣ {α β : Type u} : m α(j αm β)m β

                                  The relative bind operation

                                Instances
                                  class RelativeFunctor (j : Type u → Type w) (f : Type u → Type v) :
                                  Type (max (max (u + 1) v) w)

                                  Type class for the relative map operation

                                  • mapᵣ {α β : Type u} : (j αj β)f αf β

                                    The relative map operation

                                  • mapConstᵣ {α β : Type u} : j αf βf α
                                  Instances

                                    The relative bind operation

                                    Equations
                                      Instances For

                                        The relative map operation

                                        Equations
                                          Instances For
                                            class RelativeMonad (j : Type u → Type w) (m : Type u → Type v) extends RelativePure j m, RelativeBind j m, RelativeFunctor j m :
                                            Type (max (max (u + 1) v) w)

                                            Type class for the relative monad

                                            Instances
                                              def instFunctorOfRelativeMonad {j : Type u → Type w} [Functor j] {m : Type u → Type v} [RelativeMonad j m] :
                                              Equations
                                                Instances For
                                                  def instSeqOfRelativeMonadOfSeq {j : Type u → Type w} [Seq j] {m : Type u → Type v} [RelativeMonad j m] :
                                                  Seq m
                                                  Equations
                                                    Instances For
                                                      instance instPureOfRelativePureId {f : Type u → Type v} [RelativePure Id f] :
                                                      Equations
                                                        instance instBindOfRelativeBindId {m : Type u → Type v} [RelativeBind Id m] :
                                                        Equations
                                                          Equations
                                                            class LawfulRelativeFunctor (j : Type u → Type w) (f : Type u → Type v) [RelativeFunctor j f] :
                                                            Instances
                                                              @[simp]
                                                              theorem id_mapᵣ' {j : Type u → Type w} {f : Type u → Type v} {α : Type u} [RelativeFunctor j f] [LawfulRelativeFunctor j f] (x : f α) :
                                                              (fun (a : j α) => a) <$>ᵣ x = x
                                                              @[simp]
                                                              theorem RelativeFunctor.map_map {j : Type u → Type w} {f : Type u → Type v} {α β γ : Type u} [RelativeFunctor j f] [LawfulRelativeFunctor j f] (h : j αj β) (g : j βj γ) (x : f α) :
                                                              g <$>ᵣ h <$>ᵣ x = (fun (a : j α) => g (h a)) <$>ᵣ x
                                                              class LawfulRelativeMonad (j : Type u → Type w) (m : Type u → Type v) [RelativeMonad j m] extends LawfulRelativeFunctor j m :
                                                              Instances
                                                                @[simp]
                                                                theorem bind_pureᵣ {j : Type u → Type w} {m : Type u → Type v} {α : Type u} [RelativeMonad j m] [LawfulRelativeMonad j m] (x : m α) :
                                                                theorem map_eq_pure_bindᵣ {j : Type u → Type w} {m : Type u → Type v} {α β : Type u} [RelativeMonad j m] [LawfulRelativeMonad j m] (f : j αj β) (x : m α) :
                                                                f <$>ᵣ x = x >>=ᵣ fun (a : j α) => pureᵣ (f a)
                                                                theorem bind_congrᵣ {j : Type u → Type w} {m : Type u → Type v} {α β : Type u} [RelativeBind j m] {x : m α} {f g : j αm β} (h : ∀ (a : j α), f a = g a) :
                                                                x >>=ᵣ f = x >>=ᵣ g
                                                                theorem bind_pure_unitᵣ {j : Type u → Type w} {m : Type u → Type v} [RelativeMonad j m] [LawfulRelativeMonad j m] {x : m PUnit.{u + 1}} :
                                                                (x >>=ᵣ fun (y : j PUnit.{u + 1}) => pureᵣ y) = x
                                                                theorem map_congrᵣ {j : Type u → Type w} {m : Type u → Type v} {α β : Type u} [RelativeFunctor j m] {x : m α} {f g : j αj β} (h : ∀ (a : j α), f a = g a) :
                                                                f <$>ᵣ x = g <$>ᵣ x
                                                                @[simp]
                                                                theorem map_bindᵣ {j : Type u → Type w} {m : Type u → Type v} {α β γ : Type u} [RelativeMonad j m] [LawfulRelativeMonad j m] (f : j βj γ) (x : m α) (g : j αm β) :
                                                                f <$>ᵣ (x >>=ᵣ g) = x >>=ᵣ fun (a : j α) => f <$>ᵣ g a
                                                                @[simp]
                                                                theorem bind_map_leftᵣ {j : Type u → Type w} {m : Type u → Type v} {α β γ : Type u} [RelativeMonad j m] [LawfulRelativeMonad j m] (f : j αj β) (x : m α) (g : j βm γ) :
                                                                (f <$>ᵣ x >>=ᵣ fun (b : j β) => g b) = x >>=ᵣ fun (a : j α) => g (f a)
                                                                theorem RelativeFunctor.map_unitᵣ {j : Type u → Type w} {m : Type u → Type v} [RelativeMonad j m] [LawfulRelativeMonad j m] {a : m PUnit.{u + 1}} :
                                                                (fun (y : j PUnit.{u + 1}) => y) <$>ᵣ a = a
                                                                class MonadIso (m : Type u → Type v) (n : Type u → Type w) :
                                                                Type (max (max (u + 1) v) w)
                                                                Instances
                                                                  class RelativeMonadMorphism (r₁ m₁ : Type u → Type v₁) (r₂ m₂ : Type u → Type v₂) [RelativeMonad r₁ m₁] [RelativeMonad r₂ m₂] :
                                                                  Type (max (max (u + 1) (v₁ + 1)) (v₂ + 1))
                                                                  Instances