Other Agda modules in this section (188)

Complete compiler-highlighted source. Follow a symbol to its declaration.

# The composition functor between functor categories

Curry the evaluation formula `((F,u),b) ↦ F(u(b))`. Its named values
agree with ordinary composition. Fixing either input gives the existing
precomposition or postcomposition functor, with retained uncurried images.

```agda
{-# OPTIONS --safe --without-K #-}
open import Agda.Primitive using (Level)
open import SCT.VolumeI.Chapter01.Theory using (Theory)
import SCT.VolumeI.Chapter01.Section04.MappingAnimae as Mapping
import SCT.VolumeI.Chapter01.Section07.FunctorCategories as Categories

module SCT.VolumeI.Chapter02.Section02.InternalComposition
  {c m a : Level} (𝒯 : Theory c m a) (M : Mapping.MappingAnimae 𝒯)
  (β„± : Categories.FunctorCategories 𝒯 M) where

open import SCT.VolumeI.Chapter02.Section01.EvaluationCalculus.EndpointEvaluation 𝒯 M β„± public
open import SCT.VolumeI.Chapter01.Section07.EvaluationCalculus.IsomorphismLifting 𝒯 M β„± using (funIsoReflect; funIsoReflect-Ξ²)

product-pair : {Ξ“ A B C D : CAT} (f : MAP A C) (g : MAP B D) (h : MAP Ξ“ A) (k : MAP Ξ“ B) β†’
  (productMap f g ∘ pair h k) =₁ pair (f ∘ h) (g ∘ k)
product-pair f g h k = pair-cong
  ((f ◁ pair-β₁ h k) βˆ™ comp-assoc (pair h k) pr₁ f)
  ((g ◁ pair-Ξ²β‚‚ h k) βˆ™ comp-assoc (pair h k) prβ‚‚ g) βˆ™
  pair-pre (f ∘ pr₁) (g ∘ prβ‚‚) (pair h k)

named-application : {Ξ“ C D : CAT} (f : MAP C D) (r : MAP Ξ“ One) (h : MAP Ξ“ C) β†’
  (funEval ∘ pair (nameFun f ∘ r) h) =₁ (f ∘ h)
named-application f r h = (f ◁ pair-Ξ²β‚‚ r h) βˆ™
  comp-assoc (pair r h) prβ‚‚ f βˆ™ (funCurry-Ξ² (f ∘ prβ‚‚) β–· pair r h) βˆ™
  (comp-assoc (pair r h) (productMap (nameFun f) (id _)) funEval) ⁻¹ βˆ™
  (funEval ◁ (pair-cong (idIso (nameFun f ∘ r)) (comp-unitΛ‘ h) βˆ™
    product-pair (nameFun f) (id _) r h) ⁻¹)

named-uncurry : {Ξ“ C D : CAT} (f : MAP C D) (r : MAP Ξ“ One) β†’
  funUncurry (nameFun f ∘ r) =₁ (f ∘ prβ‚‚)
named-uncurry {C = C} f r = (f ◁ (comp-unitΛ‘ prβ‚‚ βˆ™ pair-Ξ²β‚‚ (r ∘ pr₁) (id C ∘ prβ‚‚))) βˆ™
  comp-assoc (productMap r (id C)) prβ‚‚ f βˆ™
  (funCurry-Ξ² (f ∘ prβ‚‚) β–· productMap r (id C)) βˆ™ funUncurry-restrict (nameFun f) r

module At (B C D : CAT) where
  X = Fun C D
  Y = Fun B C
  parameter = X Γ— Y
  inner : MAP (parameter Γ— B) C
  inner = funEval ∘ pair (prβ‚‚ ∘ pr₁) prβ‚‚
  input : MAP (parameter Γ— B) (X Γ— C)
  input = pair (pr₁ ∘ pr₁) inner
  diagram : MAP (parameter Γ— B) D
  diagram = funEval ∘ input
  composeFunctor : MAP parameter (Fun B D)
  composeFunctor = funCurry diagram

  module Apply {Ξ“ : CAT} (F : MAP Ξ“ X) (u : MAP Ξ“ Y) where
    step : MAP (Ξ“ Γ— B) (parameter Γ— B)
    step = productMap (pair F u) (id B)
    first : ((pr₁ ∘ pr₁) ∘ step) =₁ (F ∘ pr₁)
    first = (pair-β₁ F u β–· pr₁) βˆ™ (comp-assoc pr₁ (pair F u) pr₁) ⁻¹ βˆ™
      (pr₁ ◁ pair-β₁ (pair F u ∘ pr₁) (id B ∘ prβ‚‚)) βˆ™ comp-assoc step pr₁ pr₁
    second : ((prβ‚‚ ∘ pr₁) ∘ step) =₁ (u ∘ pr₁)
    second = (pair-Ξ²β‚‚ F u β–· pr₁) βˆ™ (comp-assoc pr₁ (pair F u) prβ‚‚) ⁻¹ βˆ™
      (prβ‚‚ ◁ pair-β₁ (pair F u ∘ pr₁) (id B ∘ prβ‚‚)) βˆ™ comp-assoc step pr₁ prβ‚‚
    inner-comparison : (inner ∘ step) =₁ funUncurry u
    inner-comparison = (funEval ◁
      (pair-cong second (pair-Ξ²β‚‚ (pair F u ∘ pr₁) (id B ∘ prβ‚‚)) βˆ™
        pair-pre (prβ‚‚ ∘ pr₁) prβ‚‚ step)) βˆ™ comp-assoc step (pair (prβ‚‚ ∘ pr₁) prβ‚‚) funEval
    input-comparison : (input ∘ step) =₁ pair (F ∘ pr₁) (funUncurry u)
    input-comparison = pair-cong first inner-comparison βˆ™ pair-pre (pr₁ ∘ pr₁) inner step
    comparison : funUncurry (composeFunctor ∘ pair F u) =₁
      (funEval ∘ pair (F ∘ pr₁) (funUncurry u))
    comparison = (funEval ◁ input-comparison) βˆ™ comp-assoc step input funEval βˆ™
      (funCurry-Ξ² diagram β–· step) βˆ™ funUncurry-restrict composeFunctor (pair F u)

  module Named (F : MAP C D) (u : MAP B C) where
    raw : funUncurry (composeFunctor ∘ pair (nameFun F) (nameFun u)) =₁ funUncurry (nameFun (F ∘ u))
    raw = (funCurry-Ξ² ((F ∘ u) ∘ prβ‚‚)) ⁻¹ βˆ™ (comp-assoc prβ‚‚ u F) ⁻¹ βˆ™
      named-application F pr₁ (u ∘ prβ‚‚) βˆ™
      (funEval ◁ pair-cong (idIso (nameFun F ∘ pr₁)) (funCurry-Ξ² (u ∘ prβ‚‚))) βˆ™
      Apply.comparison (nameFun F) (nameFun u)
    comparison : (composeFunctor ∘ pair (nameFun F) (nameFun u)) =₁ nameFun (F ∘ u)
    comparison = funIsoReflect _ _ raw
    image : funUncurryIso comparison =β‚‚ raw
    image = funIsoReflect-Ξ² _ _ raw

  module FixRight (u : MAP B C) where
    insertion : MAP X parameter
    insertion = pair (id X) (const (nameFun u))
    raw : funUncurry (composeFunctor ∘ insertion) =₁ funUncurry (funPre {D = D} u)
    raw = (funPre-Ξ² u) ⁻¹ βˆ™
      (funEval ◁ pair-cong (idIso (id X ∘ pr₁)) (named-uncurry u (terminate X))) βˆ™
      Apply.comparison (id X) (const (nameFun u))
    comparison : (composeFunctor ∘ insertion) =₁ funPre u
    comparison = funIsoReflect _ _ raw
    image : funUncurryIso comparison =β‚‚ raw
    image = funIsoReflect-Ξ² _ _ raw

  module FixLeft (F : MAP C D) where
    insertion : MAP Y parameter
    insertion = pair (const (nameFun F)) (id Y)
    raw : funUncurry (composeFunctor ∘ insertion) =₁ funUncurry (funPost {C = B} F)
    raw = (funPost-Ξ² F) ⁻¹ βˆ™ named-application F (terminate Y ∘ pr₁) funEval βˆ™
      (funEval ◁ pair-cong (comp-assoc pr₁ (terminate Y) (nameFun F)) (funUncurry-id B C)) βˆ™
      Apply.comparison (const (nameFun F)) (id Y)
    comparison : (composeFunctor ∘ insertion) =₁ funPost F
    comparison = funIsoReflect _ _ raw
    image : funUncurryIso comparison =β‚‚ raw
    image = funIsoReflect-Ξ² _ _ raw
```