Other Agda modules in this section (47)

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

Corresponding book passages
# Morphisms, natural transformations, and the arrow category

Three declarations describe different aspects of `def:Morphisms`.
`Ar C = Fun [1] C` is the internal arrow category. `Mor C = MAP [1] C`
is the external type of absolute interval diagrams. `Morphism x y`
equips such a diagram with identifications of its source and target
with the specified objects `x` and `y`.

`NatTrans C D` is a morphism of `Fun C D`; its two endpoint functors
are determined by the diagram. `MorphismExpression`, below, uses the
arrow category to describe a family with specified endpoints.
No property of the interval beyond its two objects is used in these
definitions.

```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
import SCT.VolumeI.Chapter02.Section01.WalkingMorphism as Walking

module SCT.VolumeI.Chapter02.Section01.Morphisms
  {c m a : Level} (𝒯 : Theory c m a) (M : Mapping.MappingAnimae 𝒯)
  (β„± : Categories.FunctorCategories 𝒯 M) (I : Walking.WalkingMorphism 𝒯) where

open import SCT.VolumeI.Chapter02.Section01.EvaluationCalculus.EndpointEvaluation 𝒯 M β„± public
open import SCT.VolumeI.Chapter01.Section07.EvaluationCalculus.IsomorphismLifting 𝒯 M β„± using (funIsoReflect)
open Walking.WalkingMorphism I public

Ar : CAT β†’ CAT
Ar C = Fun [1] C

Mor : CAT β†’ Set m
Mor C = MAP [1] C

source target : {C : CAT} β†’ Mor C β†’ Obj-abs C
source f = f ∘ zero
target f = f ∘ one

evβ‚€ ev₁ : {C : CAT} β†’ MAP (Ar C) C
evβ‚€ = evaluate zero
ev₁ = evaluate one

record Morphism {C : CAT} (x y : Obj-abs C) : Set m where
  field
    diagram : Mor C
    source-identification : (source diagram) =₁ x
    target-identification : (target diagram) =₁ y

NatTrans : (C D : CAT) β†’ Set m
NatTrans C D = Mor (Fun C D)

transformation-diagram : {C D : CAT} β†’ NatTrans C D β†’ MAP ([1] Γ— C) D
transformation-diagram = funUncurry

diagram-transformation : {C D : CAT} β†’ MAP ([1] Γ— C) D β†’ NatTrans C D
diagram-transformation = funCurry

transformation-Ξ² : {C D : CAT} (H : MAP ([1] Γ— C) D) β†’
  (transformation-diagram (diagram-transformation H)) =₁ H
transformation-Ξ² = funCurry-Ξ²

transformation-Ξ· : {C D : CAT} (Ξ± : NatTrans C D) β†’
  (diagram-transformation (transformation-diagram Ξ±)) =₁ Ξ±
transformation-Ξ· = funCurry-Ξ·
```

The following record is `con:Morphism_Expressions`. Its comparisons retain
compatibility with the displayed source and target, not just the interval
diagram. Currying and the endpoint evaluation comparison relate it to the
book's presentation by a functor `Ξ“ Γ— [1] β†’ C`.

```agda
record MorphismExpression {Ξ“ C : CAT} (f g : MAP Ξ“ C) : Set m where
  field
    arrow : MAP Ξ“ (Ar C)
    source-frame : (evβ‚€ ∘ arrow) =₁ f
    target-frame : (ev₁ ∘ arrow) =₁ g

record ExpressionIso {Ξ“ C : CAT} {f g : MAP Ξ“ C}
  (Ξ± Ξ² : MorphismExpression f g) : Set m where
  field
    comparison : (MorphismExpression.arrow Ξ±) =₁ (MorphismExpression.arrow Ξ²)
    source-compatible : (MorphismExpression.source-frame Ξ² βˆ™ (evβ‚€ ◁ comparison)) =β‚‚
      (MorphismExpression.source-frame Ξ±)
    target-compatible : (MorphismExpression.target-frame Ξ² βˆ™ (ev₁ ◁ comparison)) =β‚‚
      (MorphismExpression.target-frame Ξ±)

expression : {Ξ“ C : CAT} {f g : MAP Ξ“ C} (H : MAP (Ξ“ Γ— [1]) C) β†’
  (H ∘ insert zero) =₁ f β†’ (H ∘ insert one) =₁ g β†’ MorphismExpression f g
expression H Ξ± Ξ² = record
  { arrow = funCurry H
  ; source-frame = Ξ± βˆ™ evaluate-curry zero H
  ; target-frame = Ξ² βˆ™ evaluate-curry one H }

restrict-expression : {Ξ“ Ξ” C : CAT} {f g : MAP Ξ“ C} β†’
  MorphismExpression f g β†’ (r : MAP Ξ” Ξ“) β†’ MorphismExpression (f ∘ r) (g ∘ r)
restrict-expression Ξ± r = record
  { arrow = MorphismExpression.arrow α ∘ r
  ; source-frame = (MorphismExpression.source-frame Ξ± β–· r) βˆ™
      (comp-assoc r (MorphismExpression.arrow Ξ±) evβ‚€) ⁻¹
  ; target-frame = (MorphismExpression.target-frame Ξ± β–· r) βˆ™
      (comp-assoc r (MorphismExpression.arrow Ξ±) ev₁) ⁻¹ }

retarget-expression : {Ξ“ C : CAT} {f g fβ€² gβ€² : MAP Ξ“ C} β†’
  MorphismExpression f g β†’ f =₁ fβ€² β†’ g =₁ gβ€² β†’ MorphismExpression fβ€² gβ€²
retarget-expression Ξ± p q = record
  { arrow = MorphismExpression.arrow Ξ±
  ; source-frame = p βˆ™ MorphismExpression.source-frame Ξ±
  ; target-frame = q βˆ™ MorphismExpression.target-frame Ξ± }

identityArrow : {C : CAT} β†’ MAP C (Ar C)
identityArrow {C} = constantDiagram [1] C

identity-source : {C : CAT} β†’ (evβ‚€ ∘ identityArrow) =₁ (id C)
identity-source = evaluate-constant zero

identity-target : {C : CAT} β†’ (ev₁ ∘ identityArrow) =₁ (id C)
identity-target = evaluate-constant one

identity-boundary : {Ξ“ C : CAT} (x : Obj-abs [1]) (f : MAP Ξ“ C) β†’
  ((f ∘ pr₁) ∘ insert x) =₁ f
identity-boundary x f = comp-unitΚ³ f βˆ™ ((f ◁ pair-β₁ _ _) βˆ™ comp-assoc (insert x) pr₁ f)

constant-boundary : {C : CAT} (y : Obj-abs [1]) (x : Obj-abs C) β†’ (const x ∘ y) =₁ x
constant-boundary y x = comp-unitΚ³ x βˆ™
  ((x ◁ terminal-iso (terminate [1] ∘ y) (id One)) βˆ™ comp-assoc y (terminate [1]) x)
identity-expression : {Ξ“ C : CAT} (f : MAP Ξ“ C) β†’ MorphismExpression f f
identity-expression f = expression (f ∘ pr₁) (identity-boundary zero f) (identity-boundary one f)

isomorphism-expression : {Ξ“ C : CAT} {f g : MAP Ξ“ C} β†’ f =₁ g β†’ MorphismExpression f g
isomorphism-expression {f = f} Ξ± = record
  { arrow = MorphismExpression.arrow (identity-expression f)
  ; source-frame = MorphismExpression.source-frame (identity-expression f)
  ; target-frame = Ξ± βˆ™ MorphismExpression.target-frame (identity-expression f) }

post-boundary : {Ξ“ C D : CAT} (x : Obj-abs [1]) (F : MAP C D) (h : MAP Ξ“ (Ar C))
  {f : MAP Ξ“ C} β†’ (evaluate x ∘ h) =₁ f β†’ (evaluate x ∘ (funPost F ∘ h)) =₁ (F ∘ f)
post-boundary x F h p = (F ◁ (p βˆ™ (evaluate-uncurry x h) ⁻¹)) βˆ™
  (comp-assoc (insert x) (funUncurry h) F βˆ™
    ((funPost-uncurry F h β–· insert x) βˆ™ evaluate-uncurry x (funPost F ∘ h)))
post-expression : {Ξ“ C D : CAT} (F : MAP C D) {f g : MAP Ξ“ C} β†’
  MorphismExpression f g β†’ MorphismExpression (F ∘ f) (F ∘ g)
post-expression F Ξ± = record
  { arrow = funPost F ∘ MorphismExpression.arrow α
  ; source-frame = post-boundary zero F (MorphismExpression.arrow Ξ±) (MorphismExpression.source-frame Ξ±)
  ; target-frame = post-boundary one F (MorphismExpression.arrow Ξ±) (MorphismExpression.target-frame Ξ±) }

post-identity-arrow : {Ξ“ C D : CAT} (F : MAP C D) (f : MAP Ξ“ C) β†’
  (MorphismExpression.arrow (post-expression F (identity-expression f))) =₁
    (MorphismExpression.arrow (identity-expression (F ∘ f)))
post-identity-arrow F f = funIsoReflect _ _
  ((funCurry-Ξ² ((F ∘ f) ∘ pr₁)) ⁻¹ βˆ™
    ((comp-assoc pr₁ f F) ⁻¹ βˆ™
      ((F ◁ funCurry-Ξ² (f ∘ pr₁)) βˆ™ funPost-uncurry F (funCurry (f ∘ pr₁)))))
```