Other Agda modules in this section (76)

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

# Boundaries for composition under parameter change

There are two comparisons from the uncurried restricted composite to
successive evaluation with the original parameter retained. `restrict-output`
uses the restriction comparison for the composite; `change-input` uses
the restriction comparison for its inner factor.

`Boundaries` names their common source and target and the nested application
expression used to compare them. `InputNormalization` prepares the
factorization of `change-input` through that expression. The proof is
completed in `CompositionInputCalculus`.

```agda
{-# OPTIONS --safe --without-K #-}
open import Agda.Primitive using (Level)
open import SCT.VolumeI.Chapter01.Theory using (Theory)
import SCT.VolumeI.Chapter01.Section04.Substitution.ProofCalculus as Setup
import SCT.Calculus.Squares as Squares
import SCT.VolumeI.Chapter01.Section04.MappingAnimae as Mapping
import SCT.VolumeI.Chapter01.Section04.Currying as Currying
import SCT.VolumeI.Chapter01.Section04.Composition as MapComposition
import SCT.VolumeI.Chapter01.Section04.Substitution.MappingProofCalculus as CompositionNaturality
import SCT.VolumeI.Chapter01.Section04.CompositionCalculus.InternalCoherence as InternalCoherence
import SCT.VolumeI.Chapter01.Section04.Substitution.ParameterChangeNaturality as ParameterChangeNaturality
import SCT.VolumeI.Chapter01.Section04.Substitution.MappingProofCalculus as EvaluationParameterChange
import SCT.VolumeI.Chapter01.Section04.Substitution.EvaluationInputChange as EvaluationInputChange
import SCT.VolumeI.Chapter01.Section04.ProductCalculus.ProductSubstitution as ProductSubstitution
import SCT.VolumeI.Chapter01.Section02.Isomorphisms as Isomorphisms
import SCT.VolumeI.Chapter01.Section03.ProductCalculus.PairingNaturality as PairingNaturality
import SCT.VolumeI.Chapter01.Section03.ProductCalculus.PairingCoherence as PairingCoherence
import SCT.VolumeI.Chapter01.Section04.Substitution.EvaluationParameterChange as EvaluationPairs
import SCT.VolumeI.Chapter01.Section04.Substitution.ParameterChange as ParameterChange

module SCT.VolumeI.Chapter01.Section04.CompositionCalculus.CompositionInputBaseCalculus
  {c m a : Level} (𝒯 : Theory c m a) (M : Mapping.MappingAnimae 𝒯) where

open Setup 𝒯
open Mapping.MappingAnimae M
open Currying 𝒯 M
open MapComposition 𝒯 M
open CompositionNaturality 𝒯 M using (apply-cong-comp; apply-cong-Isoβ‚‚; mapUncurry-at-inner)
open InternalCoherence 𝒯 M using (uncurry-compose; evaluate-compose; module RetainedEvaluation)
open EvaluationParameterChange 𝒯 M using (mapUncurry-at-restriction)
open EvaluationInputChange 𝒯 M using (mapUncurry-at-input-change)
module AtCoordinates = EvaluationPairs.AtCoordinates 𝒯 M
open ParameterChange 𝒯 M using (retained-parameter-change)
module Routes = ParameterChangeNaturality.Routes 𝒯 M
open ProductSubstitution 𝒯 M using (module Coordinates)
open Isomorphisms vocabulary terminal products productLaws composition vertical whiskering
  using (reassociateFour; cancel-inverse)
open PairingNaturality vocabulary terminal products productLaws composition vertical whiskering
  using (cancel-right; cancel-left-reflect)
open PairingCoherence vocabulary terminal products productLaws composition vertical whiskering
  using (pair-cong-comp; pair-cong-Isoβ‚‚; pair-cong-id)

module Boundaries {P Q C D E : CAT}
  (g : MAP P (Map D E)) (f : MAP P (Map C D)) (Οƒ : MAP Q P) where

  source : MAP (Q Γ— C) E
  source = mapUncurry (composeTerm g f ∘ Οƒ)

  target : MAP (Q Γ— C) E
  target = mapUncurry g ∘ (RetainedEvaluation.retained P f ∘ productMap Οƒ (id C))

  restrict-output : source =₁ target
  restrict-output = comp-assoc (productMap Οƒ (id C)) (RetainedEvaluation.retained P f) (mapUncurry g) βˆ™
    ((uncurry-compose g f β–· productMap Οƒ (id C)) βˆ™ mapUncurry-restrict (composeTerm g f) Οƒ)

  change-input : source =₁ target
  change-input = (mapUncurry g ◁ retained-parameter-change f Οƒ) βˆ™
    (comp-assoc (RetainedEvaluation.retained Q (f ∘ Οƒ)) (productMap Οƒ (id D)) (mapUncurry g) βˆ™
      ((mapUncurry-restrict g Οƒ β–· RetainedEvaluation.retained Q (f ∘ Οƒ)) βˆ™
        (uncurry-compose (g ∘ Οƒ) (f ∘ Οƒ) βˆ™ mapUncurryIso (composeTerm-pre g f Οƒ))))

  application-target : MAP (Q Γ— C) E
  application-target = applyTerm ((g ∘ Οƒ) ∘ pr₁) (applyTerm ((f ∘ Οƒ) ∘ pr₁) prβ‚‚)

  application-route : source =₁ application-target
  application-route = evaluate-compose (g ∘ Οƒ) (f ∘ Οƒ) βˆ™ mapUncurryIso (composeTerm-pre g f Οƒ)

  target-normalization : target =₁ application-target
  target-normalization =
    applyTerm-cong (Coordinates.first C g Οƒ)
      (mapUncurry-as-apply (f ∘ Οƒ) βˆ™ (mapUncurry-restrict f Οƒ) ⁻¹) βˆ™
    (applyTerm-pre (g ∘ pr₁) (mapUncurry f) (productMap Οƒ (id C)) βˆ™
      ((mapUncurry-at g pr₁ (mapUncurry f) β–· productMap Οƒ (id C)) βˆ™
        (comp-assoc (productMap Οƒ (id C)) (RetainedEvaluation.retained P f) (mapUncurry g)) ⁻¹))


module InputNormalization {P Q C D E : CAT}
  (g : MAP P (Map D E)) (f : MAP P (Map C D)) (Οƒ : MAP Q P) where

  open Boundaries {C = C} {D = D} {E = E} g f Οƒ
  open Routes {C = C} {D = D} Οƒ using (common; input-route; output-route; input-normalization; output-normalization)

  s : MAP (Q Γ— C) (P Γ— C)
  s = productMap Οƒ (id C)

  inner-change : (mapUncurry (f ∘ Οƒ)) =₁ (mapUncurry f ∘ s)
  inner-change = mapUncurry-restrict f Οƒ

  inner-application : (mapUncurry (f ∘ Οƒ)) =₁ (applyTerm ((f ∘ Οƒ) ∘ pr₁) prβ‚‚)
  inner-application = mapUncurry-as-apply (f ∘ Οƒ)

  corner : _=₁_ {C = Q Γ— C} ((g ∘ Οƒ) ∘ pr₁) (g ∘ (Οƒ ∘ pr₁))
  corner = comp-assoc pr₁ Οƒ g

  common-action :
    (applyTerm (g ∘ (Οƒ ∘ pr₁)) (mapUncurry f ∘ s)) =₁ application-target
  common-action = applyTerm-cong (corner ⁻¹) (inner-application βˆ™ inner-change ⁻¹)

  common-normalization : (mapUncurry g ∘ common f) =₁ application-target
  common-normalization = common-action βˆ™ mapUncurry-at g (Οƒ ∘ pr₁) (mapUncurry f ∘ s)

  opaque
    normalization-on-common : target-normalization =β‚‚
      (common-normalization βˆ™ (mapUncurry g ◁ output-route f))
    normalization-on-common =
      let Ξ² = pair-β₁ (Οƒ ∘ pr₁) (id C ∘ prβ‚‚)
          Ξ· = inner-application βˆ™ inner-change ⁻¹
          Ain = comp-assoc s pr₁ g
          Aret = comp-assoc s (RetainedEvaluation.retained P f) (mapUncurry g)
          a = corner ⁻¹ βˆ™ ((g ◁ Ξ²) βˆ™ Ain)
          N = applyTerm-cong a Ξ·
          G = applyTerm-cong (g ◁ Ξ²) (idIso (mapUncurry f ∘ s))
          A = applyTerm-cong Ain (idIso (mapUncurry f ∘ s))
          pre = applyTerm-pre (g ∘ pr₁) (mapUncurry f) s
          W = mapUncurry-at g pr₁ (mapUncurry f) β–· s
          W₁ = mapUncurry-at g (pr₁ ∘ s) (mapUncurry f ∘ s)
          Wβ‚‚ = mapUncurry-at g (Οƒ ∘ pr₁) (mapUncurry f ∘ s)
          paired = mapUncurry g ◁ output-normalization f
          pairPre = mapUncurry g ◁ pair-pre pr₁ (mapUncurry f) s
          postB = mapUncurry g ◁ output-route f
          combineGA : (G βˆ™ A) =β‚‚
            (applyTerm-cong ((g ◁ Ξ²) βˆ™ Ain) (idIso (mapUncurry f ∘ s)))
          combineGA = apply-cong-Isoβ‚‚ (idIso ((g ◁ Ξ²) βˆ™ Ain)) (isoComp-unitΛ‘-at _) βˆ™
            (apply-cong-comp (g ◁ Ξ²) Ain (idIso _) (idIso _)) ⁻¹
          splitN : N =β‚‚ (common-action βˆ™ (G βˆ™ A))
          splitN =
            (apply-cong-Isoβ‚‚ (idIso a) (isoComp-unitΚ³-at Ξ·) βˆ™
              ((apply-cong-comp (corner ⁻¹) ((g ◁ Ξ²) βˆ™ Ain) Ξ· (idIso _)) ⁻¹ βˆ™
                isoComp-cong (idIso common-action) combineGA)) ⁻¹
          restriction : (A βˆ™ (pre βˆ™ W)) =β‚‚ (W₁ βˆ™ (pairPre βˆ™ Aret))
          restriction = mapUncurry-at-restriction g pr₁ (mapUncurry f) s
          natural : (G βˆ™ W₁) =β‚‚ (Wβ‚‚ βˆ™ paired)
          natural = (mapUncurry-at-inner g β (idIso (mapUncurry f ∘ s))) ⁻¹
      in Squares.common-frame-pasting
        (comparisonAlgebra (Q Γ— C) E) (comparisonLaws (Q Γ— C) E)
        common-action G A N pre W W₁ Wβ‚‚ paired pairPre postB Aret (Aret ⁻¹)
        splitN restriction natural
        ((postWhisker-isoComp-at (mapUncurry g)
          (output-normalization f) (pair-pre pr₁ (mapUncurry f) s)) ⁻¹)
        (reassociateFour Wβ‚‚ paired pairPre Aret)
        (cancel-right Aret (common-normalization βˆ™ postB))


  input-pair :
    (productMap Οƒ (id D) ∘ RetainedEvaluation.retained Q (f ∘ Οƒ)) =₁
    (pair (Οƒ ∘ pr₁) (mapUncurry (f ∘ Οƒ)))
  input-pair = AtCoordinates.comparison Οƒ pr₁ (mapUncurry (f ∘ Οƒ))

  opaque
    input-factor : (input-route f) =β‚‚
      (pair-cong (idIso (Οƒ ∘ pr₁)) inner-change βˆ™ input-pair)
    input-factor =
      (isoComp-cong
        (pair-cong-Isoβ‚‚ (isoComp-unitΛ‘-at (idIso (Οƒ ∘ pr₁))) (idIso _) βˆ™
          (pair-cong-comp (idIso (Οƒ ∘ pr₁)) (idIso (Οƒ ∘ pr₁))
            inner-change (comp-unitΛ‘ (mapUncurry (f ∘ Οƒ)))) ⁻¹) (idIso _) βˆ™
        (isoComp-assoc-at (pair-cong (idIso (Οƒ ∘ pr₁)) inner-change)
          (pair-cong (idIso (Οƒ ∘ pr₁)) (comp-unitΛ‘ (mapUncurry (f ∘ Οƒ))))
          (productMap-pair Οƒ (id D) pr₁ (mapUncurry (f ∘ Οƒ)))) ⁻¹) ⁻¹

  changed-action :
    (applyTerm (g ∘ (Οƒ ∘ pr₁)) (mapUncurry (f ∘ Οƒ))) =₁ application-target
  changed-action = applyTerm-cong (corner ⁻¹) inner-application

  changed-evaluation :
    (mapUncurry g ∘ pair (Οƒ ∘ pr₁) (mapUncurry (f ∘ Οƒ))) =₁ application-target
  changed-evaluation = changed-action βˆ™ mapUncurry-at g (Οƒ ∘ pr₁) (mapUncurry (f ∘ Οƒ))


```