Other Agda modules in this section (89)

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

# Associativity of composition in both product coordinates

The pasting comparison uses products with a changing second coordinate.
We therefore retain both coordinate associators. The proof reuses the
pairing assembly from Section 1.4; its two projection hypotheses follow
from the specified product comparisons.

```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.Section03.ProductCalculus.ProductFunctorUnits as ProductFunctorUnits
import SCT.VolumeI.Chapter01.Section03.IdentificationCalculus.Structural as Structural

module SCT.VolumeI.Chapter01.Section08.ProductCalculus.ProductCompositionAssociativity
  {c m a : Level} (𝒯 : Theory c m a) (M : Mapping.MappingAnimae 𝒯) where

open import SCT.VolumeI.Chapter01.Section04.Setup 𝒯
open import SCT.VolumeI.Chapter01.Section04.ProductCalculus.ProductAssociativity 𝒯 M
  using (post-pasting; cancel-forward; module PairingAssembly)
open import SCT.VolumeI.Chapter01.Section04.ProductCalculus.ProductSubstitution 𝒯 M
  using (coordinate-outer-comp)
open ProductFunctorUnits vocabulary terminal products productLaws composition
  vertical whiskering pentagonTriangle
  using (pair-pre-cong-triangle₁; pair-pre-cong-triangleβ‚‚)
open Structural vocabulary terminal products productLaws composition whiskering
  using (postWhisker-comp-at)

module CoordinateAssociativity
  {Kβ‚€ K₁ Kβ‚‚ Aβ‚€ A₁ Aβ‚‚ A₃ : CAT}
  (Ο€β‚€ : MAP Kβ‚€ Aβ‚€) (π₁ : MAP K₁ A₁) (Ο€β‚‚ : MAP Kβ‚‚ Aβ‚‚)
  (fβ‚€ : MAP Aβ‚€ A₁) (f₁ : MAP A₁ Aβ‚‚) (fβ‚‚ : MAP Aβ‚‚ A₃)
  (h : MAP K₁ Kβ‚‚) (k : MAP Kβ‚€ K₁) (l : MAP Kβ‚€ Kβ‚‚)
  (ΞΊ : (h ∘ k) =₁ l)
  (b : (Ο€β‚‚ ∘ h) =₁ (f₁ ∘ π₁))
  (d : (π₁ ∘ k) =₁ (fβ‚€ ∘ Ο€β‚€))
  (bβ€² : (Ο€β‚‚ ∘ l) =₁ ((f₁ ∘ fβ‚€) ∘ Ο€β‚€)) where

  middle : ((f₁ ∘ π₁) ∘ k) =₁ ((f₁ ∘ fβ‚€) ∘ Ο€β‚€)
  middle = coordinate-comparison Ο€β‚€ fβ‚€ π₁ k d f₁
  firstStep : ((fβ‚‚ ∘ Ο€β‚‚) ∘ h) =₁ ((fβ‚‚ ∘ f₁) ∘ π₁)
  firstStep = coordinate-comparison π₁ f₁ Ο€β‚‚ h b fβ‚‚
  secondStep : (((fβ‚‚ ∘ f₁) ∘ π₁) ∘ k) =₁ (((fβ‚‚ ∘ f₁) ∘ fβ‚€) ∘ Ο€β‚€)
  secondStep = coordinate-comparison Ο€β‚€ fβ‚€ π₁ k d (fβ‚‚ ∘ f₁)
  direct : ((fβ‚‚ ∘ Ο€β‚‚) ∘ l) =₁ ((fβ‚‚ ∘ (f₁ ∘ fβ‚€)) ∘ Ο€β‚€)
  direct = coordinate-comparison Ο€β‚€ (f₁ ∘ fβ‚€) Ο€β‚‚ l bβ€² fβ‚‚
  short : (((fβ‚‚ ∘ Ο€β‚‚) ∘ h) ∘ k) =₁ ((fβ‚‚ ∘ (f₁ ∘ fβ‚€)) ∘ Ο€β‚€)
  short = direct βˆ™ (((fβ‚‚ ∘ Ο€β‚‚) ◁ ΞΊ) βˆ™ comp-assoc k h (fβ‚‚ ∘ Ο€β‚‚))
  long : (((fβ‚‚ ∘ Ο€β‚‚) ∘ h) ∘ k) =₁ ((fβ‚‚ ∘ (f₁ ∘ fβ‚€)) ∘ Ο€β‚€)
  long = (comp-assoc fβ‚€ f₁ fβ‚‚ β–· Ο€β‚€) βˆ™ (secondStep βˆ™ (firstStep β–· k))

  abstract
    comparison :
      (bβ€² βˆ™ (Ο€β‚‚ ◁ ΞΊ)) =β‚‚
        (middle βˆ™ ((b β–· k) βˆ™ (comp-assoc k h Ο€β‚‚) ⁻¹)) β†’ short =β‚‚ long
    comparison projection =
      let outside = (comp-assoc Ο€β‚€ (f₁ ∘ fβ‚€) fβ‚‚) ⁻¹
          leftImage = fβ‚‚ ◁ bβ€²
          inputA = comp-assoc l Ο€β‚‚ fβ‚‚
          change = (fβ‚‚ ∘ Ο€β‚‚) ◁ ΞΊ
          sourceA = comp-assoc k h (fβ‚‚ ∘ Ο€β‚‚)
          across = fβ‚‚ ◁ (Ο€β‚‚ ◁ ΞΊ)
          afterA = comp-assoc (h ∘ k) Ο€β‚‚ fβ‚‚
          projectImage = (postWhisker fβ‚‚ ◁ projection) βˆ™
            (postWhisker-isoComp-at fβ‚‚ bβ€² (Ο€β‚‚ ◁ ΞΊ)) ⁻¹
          moveInput = isoComp-assoc-at across afterA sourceA βˆ™
            (isoComp-cong (postWhisker-comp-at ΞΊ Ο€β‚‚ fβ‚‚) (idIso sourceA) βˆ™
              (isoComp-assoc-at inputA change sourceA) ⁻¹)
          removeInner = isoComp-cong projectImage (idIso (afterA βˆ™ sourceA)) βˆ™
            (isoComp-assoc-at leftImage across (afterA βˆ™ sourceA)) ⁻¹
          normalizeShort = isoComp-cong (idIso outside)
            (post-pasting fβ‚‚ Ο€β‚‚ h k b middle βˆ™
              (removeInner βˆ™
                (isoComp-cong (idIso leftImage) moveInput βˆ™
                  isoComp-assoc-at leftImage inputA (change βˆ™ sourceA)))) βˆ™
            isoComp-assoc-at outside (leftImage βˆ™ inputA) (change βˆ™ sourceA)
          Ξ· = comp-assoc fβ‚€ f₁ fβ‚‚ β–· Ο€β‚€
          sourceCorner = comp-assoc π₁ f₁ fβ‚‚
          imageBefore = (fβ‚‚ ◁ b) βˆ™ comp-assoc h Ο€β‚‚ fβ‚‚
          nextCoordinate = coordinate-comparison Ο€β‚€ (f₁ ∘ fβ‚€) (f₁ ∘ π₁) k middle fβ‚‚
          outerSquare = coordinate-outer-comp Ο€β‚€ fβ‚€ π₁ k d f₁ fβ‚‚
          simplifyCorner = (preWhisker k ◁ cancel-forward sourceCorner imageBefore) βˆ™
            (preWhisker-isoComp-at sourceCorner firstStep k) ⁻¹
          normalizeLong = isoComp-cong (idIso outside)
            (isoComp-assoc-at (fβ‚‚ ◁ middle) (comp-assoc k (f₁ ∘ π₁) fβ‚‚) (imageBefore β–· k)) βˆ™
            (isoComp-assoc-at outside
              ((fβ‚‚ ◁ middle) βˆ™ comp-assoc k (f₁ ∘ π₁) fβ‚‚) (imageBefore β–· k) βˆ™
            (isoComp-cong (idIso nextCoordinate) simplifyCorner βˆ™
            (isoComp-assoc-at nextCoordinate (sourceCorner β–· k) (firstStep β–· k) βˆ™
            (isoComp-cong outerSquare (idIso (firstStep β–· k)) βˆ™
              (isoComp-assoc-at Ξ· secondStep (firstStep β–· k)) ⁻¹))))
      in normalizeLong ⁻¹ βˆ™ normalizeShort

module ProductCompositor
  {Aβ‚€ A₁ Aβ‚‚ A₃ Bβ‚€ B₁ Bβ‚‚ B₃ : CAT}
  (fβ‚€ : MAP Aβ‚€ A₁) (f₁ : MAP A₁ Aβ‚‚) (fβ‚‚ : MAP Aβ‚‚ A₃)
  (gβ‚€ : MAP Bβ‚€ B₁) (g₁ : MAP B₁ Bβ‚‚) (gβ‚‚ : MAP Bβ‚‚ B₃) where

  h = productMap f₁ g₁
  k = productMap fβ‚€ gβ‚€
  l = productMap (f₁ ∘ fβ‚€) (g₁ ∘ gβ‚€)
  ΞΊ = productMap-comp fβ‚€ f₁ gβ‚€ g₁
  b₁ = pair-β₁ (f₁ ∘ pr₁) (g₁ ∘ prβ‚‚)
  bβ‚‚ = pair-Ξ²β‚‚ (f₁ ∘ pr₁) (g₁ ∘ prβ‚‚)
  d₁ = pair-β₁ (fβ‚€ ∘ pr₁) (gβ‚€ ∘ prβ‚‚)
  dβ‚‚ = pair-Ξ²β‚‚ (fβ‚€ ∘ pr₁) (gβ‚€ ∘ prβ‚‚)
  b′₁ = pair-β₁ ((f₁ ∘ fβ‚€) ∘ pr₁) ((g₁ ∘ gβ‚€) ∘ prβ‚‚)
  bβ€²β‚‚ = pair-Ξ²β‚‚ ((f₁ ∘ fβ‚€) ∘ pr₁) ((g₁ ∘ gβ‚€) ∘ prβ‚‚)
  module First = CoordinateAssociativity pr₁ pr₁ pr₁ fβ‚€ f₁ fβ‚‚ h k l ΞΊ b₁ d₁ b′₁
  module Second = CoordinateAssociativity prβ‚‚ prβ‚‚ prβ‚‚ gβ‚€ g₁ gβ‚‚ h k l ΞΊ bβ‚‚ dβ‚‚ bβ€²β‚‚

  abstract
    first-coordinate : First.short =β‚‚ First.long
    first-coordinate = First.comparison
      (pair-pre-cong-triangle₁ (f₁ ∘ pr₁) (g₁ ∘ prβ‚‚) k First.middle Second.middle)
    second-coordinate : Second.short =β‚‚ Second.long
    second-coordinate = Second.comparison
      (pair-pre-cong-triangleβ‚‚ (f₁ ∘ pr₁) (g₁ ∘ prβ‚‚) k First.middle Second.middle)

    law :
      (productMap-comp (f₁ ∘ fβ‚€) fβ‚‚ (g₁ ∘ gβ‚€) gβ‚‚ βˆ™
        ((productMap fβ‚‚ gβ‚‚ ◁ productMap-comp fβ‚€ f₁ gβ‚€ g₁) βˆ™
          comp-assoc (productMap fβ‚€ gβ‚€) (productMap f₁ g₁) (productMap fβ‚‚ gβ‚‚))) =β‚‚
      (productMap-cong (comp-assoc fβ‚€ f₁ fβ‚‚) (comp-assoc gβ‚€ g₁ gβ‚‚) βˆ™
        (productMap-comp fβ‚€ (fβ‚‚ ∘ f₁) gβ‚€ (gβ‚‚ ∘ g₁) βˆ™
          (productMap-comp f₁ fβ‚‚ g₁ gβ‚‚ β–· productMap fβ‚€ gβ‚€)))
    law = PairingAssembly.assemble (fβ‚‚ ∘ pr₁) (gβ‚‚ ∘ prβ‚‚) h k l ΞΊ
      First.firstStep Second.firstStep First.secondStep Second.secondStep
      First.direct Second.direct (comp-assoc fβ‚€ f₁ fβ‚‚ β–· pr₁) (comp-assoc gβ‚€ g₁ gβ‚‚ β–· prβ‚‚)
      first-coordinate second-coordinate
```