Other Agda modules in this section (28)

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

# Assembling pairing comparisons

A comparison between successive substitutions is determined by its two
coordinate comparisons. We retain both routes explicitly and normalize each
to a paired coordinate comparison followed by the common substitution base.
This calculation uses only the specified pairing functoriality laws.

```agda
{-# OPTIONS --safe --without-K #-}
open import Agda.Primitive using (Level)
open import SCT.VolumeI.Chapter01.Section01.Vocabulary
import SCT.VolumeI.Chapter01.Section01.Terminal as Terminal
import SCT.VolumeI.Chapter01.Section01.Products as Products
import SCT.VolumeI.Chapter01.Section02.Coherence as Coherence
import SCT.VolumeI.Chapter01.Section02.Specialization as Specialization
import SCT.VolumeI.Chapter01.Section03.ProductCalculus.PairingInterface as Interface

module SCT.VolumeI.Chapter01.Section03.ProductCalculus.PairingAssembly
  {c m a : Level} (V : Vocabulary c m a)
  (T : Terminal.TerminalStructure V) (P : Products.ProductData V)
  (PL : Products.ProductLaws V P)
  (S : Coherence.CompositionStructure V T P)
  (VC : Coherence.VerticalCoherence V T P S)
  (W : Coherence.WhiskeringCoherence V T P S)
  (O : Interface.PairingOperations V T P S)
  (F : Interface.PairingFunctoriality V T P S O) where

open Vocabulary V
open Operations V
open Products.ProductData P
open Coherence.CompositionStructure S
open Coherence.Composition V T P S
open Specialization V T P PL S hiding (pair-cong; pair-pre)
open Specialization.Units V T P PL S VC
open Specialization.Whiskering V T P PL S W
open Interface.PairingOperations O
open Interface.PairingFunctoriality F

combine-pair : {X A B : CAT} {aβ‚€ a₁ aβ‚‚ : MAP X A} {bβ‚€ b₁ bβ‚‚ : MAP X B}
  {source : MAP X (A Γ— B)}
  (Ξ± : a₁ =₁ aβ‚‚) (Ξ² : b₁ =₁ bβ‚‚)
  (Ξ³ : aβ‚€ =₁ a₁) (Ξ΄ : bβ‚€ =₁ b₁)
  (base : source =₁ (pair aβ‚€ bβ‚€))
  β†’ (pair-cong Ξ± Ξ² βˆ™ (pair-cong Ξ³ Ξ΄ βˆ™ base)) =β‚‚
      (pair-cong (Ξ± βˆ™ Ξ³) (Ξ² βˆ™ Ξ΄) βˆ™ base)
combine-pair Ξ± Ξ² Ξ³ Ξ΄ base =
  isoComp-cong ((pair-cong-comp Ξ± Ξ³ Ξ² Ξ΄) ⁻¹) (idIso base) βˆ™
    (isoComp-assoc-at (pair-cong α β) (pair-cong γ δ) base) ⁻¹

module PairingAssembly {Q R X A B : CAT}
  (b : MAP X A) (c : MAP X B) (r : MAP R X) (t : MAP Q R)
  (s : MAP Q X) (Ξ΄ : (r ∘ t) =₁ s)
  {b₁ : MAP R A} {c₁ : MAP R B} {bβ‚‚ b₃ : MAP Q A} {cβ‚‚ c₃ : MAP Q B}
  (u : (b ∘ r) =₁ b₁) (v : (c ∘ r) =₁ c₁)
  (w : (b₁ ∘ t) =₁ bβ‚‚) (z : (c₁ ∘ t) =₁ cβ‚‚)
  (a : (b ∘ s) =₁ b₃) (d : (c ∘ s) =₁ c₃)
  (Ξ· : bβ‚‚ =₁ b₃) (ΞΈ : cβ‚‚ =₁ c₃) where

  base : ((pair b c ∘ r) ∘ t) =₁ (pair ((b ∘ r) ∘ t) ((c ∘ r) ∘ t))
  base = pair-pre (b ∘ r) (c ∘ r) t βˆ™ (pair-pre b c r β–· t)

  shortFirst : ((b ∘ r) ∘ t) =₁ b₃
  shortFirst = a βˆ™ ((b ◁ Ξ΄) βˆ™ comp-assoc t r b)

  shortSecond : ((c ∘ r) ∘ t) =₁ c₃
  shortSecond = d βˆ™ ((c ◁ Ξ΄) βˆ™ comp-assoc t r c)

  longFirst : ((b ∘ r) ∘ t) =₁ b₃
  longFirst = Ξ· βˆ™ (w βˆ™ (u β–· t))

  longSecond : ((c ∘ r) ∘ t) =₁ c₃
  longSecond = ΞΈ βˆ™ (z βˆ™ (v β–· t))

  short : ((pair b c ∘ r) ∘ t) =₁ (pair b₃ c₃)
  short = (pair-cong a d βˆ™ pair-pre b c s) βˆ™
    ((pair b c ◁ Ξ΄) βˆ™ comp-assoc t r (pair b c))

  long : ((pair b c ∘ r) ∘ t) =₁ (pair b₃ c₃)
  long = pair-cong Ξ· ΞΈ βˆ™ ((pair-cong w z βˆ™ pair-pre b₁ c₁ t) βˆ™
    ((pair-cong u v βˆ™ pair-pre b c r) β–· t))

  short-normalization : short =β‚‚ (pair-cong shortFirst shortSecond βˆ™ base)
  short-normalization =
    let paired = pair-cong a d
        changed = pair-cong (b ◁ Ξ΄) (c ◁ Ξ΄)
        A = comp-assoc t r (pair b c)
        pairedA = pair-cong (comp-assoc t r b) (comp-assoc t r c)
        substitute = isoComp-assoc-at changed (pair-pre b c (r ∘ t)) A βˆ™
          (isoComp-cong ((pair-pre-natural-substitution b c Ξ΄) ⁻¹) (idIso A) βˆ™
            (isoComp-assoc-at (pair-pre b c s) (pair b c ◁ Ξ΄) A) ⁻¹)
        iterate = isoComp-cong (idIso changed) (pair-pre-iterated b c r t)
        combineInner = combine-pair (b ◁ Ξ΄) (c ◁ Ξ΄)
          (comp-assoc t r b) (comp-assoc t r c) base
    in combine-pair a d ((b ◁ Ξ΄) βˆ™ comp-assoc t r b) ((c ◁ Ξ΄) βˆ™ comp-assoc t r c) base βˆ™
      (isoComp-cong (idIso paired) (combineInner βˆ™ (iterate βˆ™ substitute)) βˆ™
        isoComp-assoc-at paired (pair-pre b c s) ((pair b c ◁ Ξ΄) βˆ™ A))

  intermediate-normalization :
    ((pair-cong w z βˆ™ pair-pre b₁ c₁ t) βˆ™ ((pair-cong u v βˆ™ pair-pre b c r) β–· t)) =β‚‚
    (pair-cong (w βˆ™ (u β–· t)) (z βˆ™ (v β–· t)) βˆ™ base)
  intermediate-normalization =
    let outer = pair-cong w z
        before = pair-pre b c r β–· t
        middle = pair-pre b₁ c₁ t
        input = pair-cong u v β–· t
        output = pair-cong (u β–· t) (v β–· t)
        exchange = isoComp-assoc-at output (pair-pre (b ∘ r) (c ∘ r) t) before βˆ™
          (isoComp-cong ((pair-pre-natural-inputs u v t) ⁻¹) (idIso before) βˆ™
            (isoComp-assoc-at middle input before) ⁻¹)
    in combine-pair w z (u β–· t) (v β–· t) base βˆ™
      (isoComp-cong (idIso outer) exchange βˆ™
        (isoComp-assoc-at outer middle (input βˆ™ before) βˆ™
          isoComp-cong (idIso (outer βˆ™ middle))
            (preWhisker-isoComp-at (pair-cong u v) (pair-pre b c r) t)))

  long-normalization : long =β‚‚ (pair-cong longFirst longSecond βˆ™ base)
  long-normalization =
    combine-pair Ξ· ΞΈ (w βˆ™ (u β–· t)) (z βˆ™ (v β–· t)) base βˆ™
      isoComp-cong (idIso (pair-cong Ξ· ΞΈ)) intermediate-normalization

  assemble : shortFirst =β‚‚ longFirst β†’ shortSecond =β‚‚ longSecond β†’ short =β‚‚ long
  assemble first second = long-normalization ⁻¹ βˆ™
    (isoComp-cong (pair-cong-Isoβ‚‚ first second) (idIso base) βˆ™ short-normalization)
```

Changing the two coordinate frames gives a square for the paired comparison.
Normalize the given substitution comparison and both boundary routes, then
apply the two supplied coordinate squares.

```agda
module FramedPairing {Q R A B : CAT} (s : MAP Q R)
  {aβ‚€ a₁ : MAP R A} {bβ‚€ b₁ : MAP R B}
  {aβ‚‚ a₃ aβ‚„ : MAP Q A} {bβ‚‚ b₃ bβ‚„ : MAP Q B}
  (u : aβ‚€ =₁ a₁) (v : bβ‚€ =₁ b₁)
  (uβ€² : aβ‚‚ =₁ a₃) (vβ€² : bβ‚‚ =₁ b₃)
  (Ξ· : a₃ =₁ aβ‚„) (ΞΈ : b₃ =₁ bβ‚„)
  (e : (aβ‚€ ∘ s) =₁ aβ‚‚) (d : (bβ‚€ ∘ s) =₁ bβ‚‚)
  (first : (a₁ ∘ s) =₁ aβ‚„) (second : (b₁ ∘ s) =₁ bβ‚„)
  (ΞΊ : (pair aβ‚€ bβ‚€ ∘ s) =₁ (pair aβ‚‚ bβ‚‚))
  (normalization : ΞΊ =β‚‚ (pair-cong e d βˆ™ pair-pre aβ‚€ bβ‚€ s)) where

  before = pair-cong u v
  after = pair-cong uβ€² vβ€²
  finish = pair-cong Ξ· ΞΈ
  changed = pair-cong first second βˆ™ pair-pre a₁ b₁ s

  comparison-square :
    (Ξ· βˆ™ (uβ€² βˆ™ e)) =β‚‚ (first βˆ™ (u β–· s))
    β†’ (ΞΈ βˆ™ (vβ€² βˆ™ d)) =β‚‚ (second βˆ™ (v β–· s))
    β†’ ((finish βˆ™ after) βˆ™ ΞΊ) =β‚‚ (changed βˆ™ (before β–· s))
  comparison-square firstNormalize secondNormalize =
    let base = pair-pre aβ‚€ bβ‚€ s
        normalizeLeft = combine-pair Ξ· ΞΈ (uβ€² βˆ™ e) (vβ€² βˆ™ d) base βˆ™
          (isoComp-cong (idIso finish) (combine-pair uβ€² vβ€² e d base) βˆ™
          (isoComp-assoc-at finish after (pair-cong e d βˆ™ base) βˆ™
            isoComp-cong (idIso (finish βˆ™ after)) normalization))
        normalizeRight = combine-pair first second (u β–· s) (v β–· s) base βˆ™
          (isoComp-cong (idIso (pair-cong first second))
            ((pair-pre-natural-inputs u v s) ⁻¹) βˆ™
            isoComp-assoc-at (pair-cong first second) (pair-pre a₁ b₁ s) (before β–· s))
    in normalizeRight ⁻¹ βˆ™
      (isoComp-cong (pair-cong-Isoβ‚‚ firstNormalize secondNormalize) (idIso base) βˆ™ normalizeLeft)
```