Other Agda modules in this section (54)

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

# Transferring iterated substitution through evaluation

The calculation in this module isolates the exact product associativity
comparison needed for iterated uncurrying. Its final transfer theorem is
conditional on that explicitly displayed comparison; the condition is not
an added axiom of the theory.

```agda
{-# OPTIONS --safe --without-K #-}
open import Agda.Primitive using (Level)
open import SCT.VolumeI.Chapter01.Theory using (Theory)
import SCT.VolumeI.Chapter01.Section07.Setup as Setup
import SCT.VolumeI.Chapter01.Section04.MappingAnimae as MappingAnimae
import SCT.VolumeI.Chapter01.Section04.Currying as Currying
import SCT.VolumeI.Chapter01.Section04.Substitution.Compatibility as Compatibility
import SCT.VolumeI.Chapter01.Section03.ProductCalculus.IteratedPairing as IteratedPairing
import SCT.VolumeI.Chapter01.Section03.ProductCalculus.PairingNaturality as PairingNaturality
import SCT.VolumeI.Chapter01.Section02.Isomorphisms as Isomorphisms

import SCT.VolumeI.Chapter01.Section07.FunctorCategories as Categories

module SCT.VolumeI.Chapter01.Section07.EvaluationCalculus.IteratedCompatibility
  {c m a : Level} (š’Æ : Theory c m a)
  (M : MappingAnimae.MappingAnimae š’Æ) (ℱ : Categories.FunctorCategories š’Æ M) where

open Setup š’Æ M ℱ



open IteratedPairing vocabulary terminal products productLaws composition vertical whiskering pentagonTriangle
  using (pentagon-whiskered; pre-inverse-at; solve-pentagon; mixed-at)
open PairingNaturality vocabulary terminal products productLaws composition vertical whiskering
  using (move-square)
import SCT.VolumeI.Chapter01.Section03.IdentificationCalculus.Parameterized as Parameterized
open Parameterized.WhiskeringLaws vocabulary terminal products productLaws composition vertical whiskering
  using (postWhisker-comp-at)
open Isomorphisms vocabulary terminal products productLaws composition vertical whiskering
  using (reassociateFour)

exchange-middle : {X Y : CAT} {a b c d e c′ : MAP X Y}
  (Ī“ : d =₁ e) (γ : c =₁ d) (β : b =₁ c) (α : a =₁ b)
  (γ′ : c′ =₁ d) (β′ : b =₁ c′)
  → (γ āˆ™ β) =ā‚‚ (γ′ āˆ™ β′)
  → ((Ī“ āˆ™ γ) āˆ™ (β āˆ™ α)) =ā‚‚ ((Ī“ āˆ™ γ′) āˆ™ (β′ āˆ™ α))
exchange-middle Ī“ γ β α γ′ β′ p =
  (reassociateFour Ī“ γ′ β′ α) ⁻¹ āˆ™
    (isoComp-cong (idIso Ī“) (isoComp-cong p (idIso α)) āˆ™ reassociateFour Ī“ γ β α)

evaluation-step : {R X Z D : CAT} (e : MAP Z D) (p : MAP X Z) (s : MAP R X)
  {q : MAP R Z} → q =₁ (p ∘ s) → (e ∘ q) =₁ ((e ∘ p) ∘ s)
evaluation-step e p s a = (comp-assoc s p e) ⁻¹ āˆ™ (e ◁ a)

evaluation-step-iterated : {Q R X Z D : CAT}
  (e : MAP Z D) (p : MAP X Z) (s : MAP R X) (t : MAP Q R)
  {q : MAP R Z} {r : MAP Q Z} (a : q =₁ (p ∘ s)) (b : r =₁ (q ∘ t))
  →
      (comp-assoc t s (e ∘ p) āˆ™
        ((evaluation-step e p s a ā–· t) āˆ™ evaluation-step e q t b)) =ā‚‚
      ((comp-assoc (s ∘ t) p e) ⁻¹ āˆ™
        (e ◁ (comp-assoc t s p āˆ™ ((a ā–· t) āˆ™ b))))
evaluation-step-iterated e p s t {q} {r} a b =
  let A = comp-assoc t s (e ∘ p)
      B = (comp-assoc s p e) ⁻¹ ā–· t
      C = (e ◁ a) ā–· t
      D = (comp-assoc t q e) ⁻¹
      E = e ◁ b
      D′ = (comp-assoc t (p ∘ s) e) ⁻¹
      C′ = e ◁ (a ā–· t)
      total = (comp-assoc (s ∘ t) p e) ⁻¹
      inner = comp-assoc t s p
      exchange = (move-square (comp-assoc t (p ∘ s) e)
        C C′ (comp-assoc t q e) (mixed-at e a t)) ⁻¹
      pentagon = solve-pentagon (comp-assoc (s ∘ t) p e) A
        (e ◁ inner) (comp-assoc t (p ∘ s) e) (comp-assoc s p e ā–· t)
        (pentagon-whiskered t s p e) āˆ™
        isoComp-cong (idIso A) (isoComp-cong (pre-inverse-at (comp-assoc s p e) t) (idIso D′))
  in isoComp-cong (idIso total)
      ((postWhisker-isoComp-at e inner ((a ā–· t) āˆ™ b)) ⁻¹ āˆ™
        isoComp-cong (idIso (e ◁ inner)) ((postWhisker-isoComp-at e (a ā–· t) b) ⁻¹)) āˆ™
    (isoComp-assoc-at total (e ◁ inner) (C′ āˆ™ E) āˆ™
    (isoComp-cong pentagon (idIso (C′ āˆ™ E)) āˆ™
    ((isoComp-assoc-at A (B āˆ™ D′) (C′ āˆ™ E)) ⁻¹ āˆ™
    (isoComp-cong (idIso A) (exchange-middle B C D E D′ C′ exchange) āˆ™
      isoComp-cong (idIso A)
        (isoComp-cong (preWhisker-isoComp-at ((comp-assoc s p e) ⁻¹) (e ◁ a) t)
          (idIso (D āˆ™ E)))))))

module Iteration {W Y X C D : CAT}
  (f : MAP X (Fun C D)) (σ : MAP Y X) (Ļ„ : MAP W Y) where

  F : {A B : CAT} → MAP A B → MAP (A Ɨ C) (B Ɨ C)
  F h = productMap h (id C)

  Īŗ : {A B Z : CAT} (h : MAP B Z) (r : MAP A B)
    → (F h ∘ F r) =₁ (F (h ∘ r))
  Īŗ = slice-comparison

  ProductAssociativity : Set m
  ProductAssociativity =
    (Īŗ f (σ ∘ Ļ„) āˆ™ ((F f ◁ Īŗ σ Ļ„) āˆ™ comp-assoc (F Ļ„) (F σ) (F f))) =ā‚‚
    (productMap-cong (comp-assoc Ļ„ σ f) (idIso (id C)) āˆ™
      (Īŗ (f ∘ σ) Ļ„ āˆ™ (Īŗ f σ ā–· F Ļ„)))

  together : (funUncurry ((f ∘ σ) ∘ Ļ„)) =₁ (funUncurry f ∘ F (σ ∘ Ļ„))
  together = funUncurry-restrict f (σ ∘ Ļ„) āˆ™ funUncurryIso (comp-assoc Ļ„ σ f)

  successively : (funUncurry ((f ∘ σ) ∘ Ļ„)) =₁ (funUncurry f ∘ F (σ ∘ Ļ„))
  successively = (funUncurry f ◁ Īŗ σ Ļ„) āˆ™
    (comp-assoc (F Ļ„) (F σ) (funUncurry f) āˆ™
      ((funUncurry-restrict f σ ā–· F Ļ„) āˆ™ funUncurry-restrict (f ∘ σ) Ļ„))

  transfer : ProductAssociativity → together =ā‚‚ successively
  transfer product-assoc =
    (isoComp-cong (idIso (funUncurry-restrict f (σ ∘ Ļ„))) ((funUncurryIso-at (comp-assoc Ļ„ σ f)) ⁻¹) āˆ™
    let p = F f
        s = F σ
        t = F Ļ„
        e = funEval
        k = Īŗ σ Ļ„
        a = (κ f σ) ⁻¹
        b = (Īŗ (f ∘ σ) Ļ„) ⁻¹
        inner = comp-assoc t s p āˆ™ ((a ā–· t) āˆ™ b)
        outside = (comp-assoc (F (σ ∘ Ļ„)) p e) ⁻¹
        middle = (comp-assoc (s ∘ t) p e) ⁻¹
        whiskered-k = p ◁ k
        associator = productMap-cong (comp-assoc Ļ„ σ f) (idIso (id C))
        commute = (move-square (comp-assoc (F (σ ∘ Ļ„)) p e)
          (funUncurry f ◁ k) (e ◁ whiskered-k) (comp-assoc (s ∘ t) p e)
          (postWhisker-comp-at k p e)) ⁻¹
        solve = solve-pentagon (Īŗ f (σ ∘ Ļ„)) (whiskered-k āˆ™ comp-assoc t s p)
          associator (Īŗ (f ∘ σ) Ļ„) (Īŗ f σ ā–· t) product-assoc āˆ™
          ((isoComp-assoc-at whiskered-k (comp-assoc t s p)
            ((Īŗ f σ ā–· t) ⁻¹ āˆ™ b)) ⁻¹ āˆ™
            isoComp-cong (idIso whiskered-k)
              (isoComp-cong (idIso (comp-assoc t s p))
                (isoComp-cong (pre-inverse-at (κ f σ) t) (idIso b))))
    in (isoComp-assoc-at outside (e ◁ (Īŗ f (σ ∘ Ļ„)) ⁻¹) (e ◁ associator)) ⁻¹ āˆ™
      (isoComp-cong (idIso outside) (postWhisker-isoComp-at e ((Īŗ f (σ ∘ Ļ„)) ⁻¹) associator) āˆ™
      (isoComp-cong (idIso outside) (postWhisker e ◁ solve) āˆ™
      (isoComp-cong (idIso outside) ((postWhisker-isoComp-at e whiskered-k inner) ⁻¹) āˆ™
      (isoComp-assoc-at outside (e ◁ whiskered-k) (e ◁ inner) āˆ™
      (isoComp-cong commute (idIso (e ◁ inner)) āˆ™
      ((isoComp-assoc-at (funUncurry f ◁ k) middle (e ◁ inner)) ⁻¹ āˆ™
        isoComp-cong (idIso (funUncurry f ◁ k))
          (evaluation-step-iterated e p s t a b)))))))) ⁻¹
```