Other Agda modules in this section (76)

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

# Application and uncurrying comparisons

The lemmas below describe how application and uncurrying interact with
composition, identifications, and restriction of parameters. They collect
the statements needed in later mapping-anima calculations; the imported
modules contain their proofs.

The aliases are `abstract` to avoid repeatedly expanding those proofs
during checking. This changes neither the chosen comparisons nor the
axiom interface.

```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 ProofCalculus
import SCT.VolumeI.Chapter01.Section04.MappingAnimae as Mapping
import SCT.VolumeI.Chapter01.Section04.Composition as MapComposition
import SCT.VolumeI.Chapter01.Section04.CompositionCalculus.CompositionNaturality as Naturality
import SCT.VolumeI.Chapter01.Section04.Substitution.ApplicationRestriction as Application
import SCT.VolumeI.Chapter01.Section04.Substitution.EvaluationParameterChange as Evaluation
import SCT.VolumeI.Chapter01.Section04.Currying as Currying

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

open ProofCalculus 𝒯
open Mapping.MappingAnimae M
open MapComposition 𝒯 M
open Currying 𝒯 M using (mapUncurryIso; mapUncurry-cong; mapUncurry-restrict)

abstract
  apply-cong-Isoβ‚‚ : {X C D : CAT}
    {f fβ€² : MAP X (Map C D)} {x xβ€² : MAP X C}
    {Ξ± Ξ±β€² : f =₁ fβ€²} {Ξ² Ξ²β€² : x =₁ xβ€²}
    β†’ Ξ± =β‚‚ Ξ±β€² β†’ Ξ² =β‚‚ Ξ²β€²
    β†’ (applyTerm-cong Ξ± Ξ²) =β‚‚ (applyTerm-cong Ξ±β€² Ξ²β€²)
  apply-cong-Isoβ‚‚ = Naturality.apply-cong-Isoβ‚‚ 𝒯 M

  apply-cong-comp : {X C D : CAT}
    {fβ‚€ f₁ fβ‚‚ : MAP X (Map C D)} {xβ‚€ x₁ xβ‚‚ : MAP X C}
    (Ξ±β‚‚ : f₁ =₁ fβ‚‚) (α₁ : fβ‚€ =₁ f₁)
    (Ξ²β‚‚ : x₁ =₁ xβ‚‚) (β₁ : xβ‚€ =₁ x₁)
    β†’ (applyTerm-cong (Ξ±β‚‚ βˆ™ α₁) (Ξ²β‚‚ βˆ™ β₁)) =β‚‚
        (applyTerm-cong Ξ±β‚‚ Ξ²β‚‚ βˆ™ applyTerm-cong α₁ β₁)
  apply-cong-comp = Naturality.apply-cong-comp 𝒯 M

  mapUncurry-at-inner : {Ξ“ X C D : CAT} (f : MAP X (Map C D))
    {p pβ€² : MAP Ξ“ X} {x xβ€² : MAP Ξ“ C} (Οƒ : p =₁ pβ€²) (Ο„ : x =₁ xβ€²)
    β†’ (mapUncurry-at f pβ€² xβ€² βˆ™ (mapUncurry f ◁ pair-cong Οƒ Ο„)) =β‚‚
        (applyTerm-cong (f ◁ Οƒ) Ο„ βˆ™ mapUncurry-at f p x)
  mapUncurry-at-inner = Naturality.mapUncurry-at-inner 𝒯 M

  mapUncurry-as-apply-natural : {X C D : CAT} {f g : MAP X (Map C D)}
    (Ξ± : f =₁ g)
    β†’ (mapUncurry-as-apply g βˆ™ mapUncurry-cong Ξ±) =β‚‚
        (applyTerm-cong (Ξ± β–· pr₁) (idIso prβ‚‚) βˆ™ mapUncurry-as-apply f)
  mapUncurry-as-apply-natural = Naturality.mapUncurry-as-apply-natural 𝒯 M

  binary-pre-inputs : {X Y A B C : CAT} (F : MAP (A Γ— B) C)
    {f fβ€² : MAP X A} {g gβ€² : MAP X B}
    (Ξ± : f =₁ fβ€²) (Ξ² : g =₁ gβ€²) (r : MAP Y X)
    β†’ let before = (F ◁ pair-pre f g r) βˆ™ comp-assoc r (pair f g) F
          after = (F ◁ pair-pre fβ€² gβ€² r) βˆ™ comp-assoc r (pair fβ€² gβ€²) F
      in (after βˆ™ ((F ◁ pair-cong Ξ± Ξ²) β–· r)) =β‚‚
          ((F ◁ pair-cong (Ξ± β–· r) (Ξ² β–· r)) βˆ™ before)
  binary-pre-inputs = Naturality.binary-pre-inputs 𝒯 M

  combine-apply : {X C D : CAT}
    {fβ‚€ f₁ fβ‚‚ : MAP X (Map C D)} {xβ‚€ x₁ xβ‚‚ : MAP X C} {source : MAP X D}
    (Ξ± : f₁ =₁ fβ‚‚) (Ξ² : x₁ =₁ xβ‚‚)
    (Ξ³ : fβ‚€ =₁ f₁) (Ξ΄ : xβ‚€ =₁ x₁)
    (base : source =₁ (applyTerm fβ‚€ xβ‚€))
    β†’ (applyTerm-cong Ξ± Ξ² βˆ™ (applyTerm-cong Ξ³ Ξ΄ βˆ™ base)) =β‚‚
        (applyTerm-cong (Ξ± βˆ™ Ξ³) (Ξ² βˆ™ Ξ΄) βˆ™ base)
  combine-apply = Application.combine-apply 𝒯 M

  post-iterated-comparison : {Q R X A B : CAT}
    (F : MAP A B) (H : MAP X A) (r : MAP R X) (s : MAP Q R)
    {H₁ : MAP R A} {Hβ‚‚ H₃ : MAP Q A}
    (u : (H ∘ r) =₁ H₁) (v : (H₁ ∘ s) =₁ Hβ‚‚)
    (w : (H ∘ (r ∘ s)) =₁ H₃) (z : Hβ‚‚ =₁ H₃)
    β†’ (w βˆ™ comp-assoc s r H) =β‚‚ (z βˆ™ (v βˆ™ (u β–· s)))
    β†’
        (((F ◁ w) βˆ™ comp-assoc (r ∘ s) H F) βˆ™ comp-assoc s r (F ∘ H)) =β‚‚
        ((F ◁ z) βˆ™ (((F ◁ v) βˆ™ comp-assoc s H₁ F) βˆ™
          (((F ◁ u) βˆ™ comp-assoc r H F) β–· s)))
  post-iterated-comparison = Application.post-iterated-comparison 𝒯 M

  mapUncurry-at-restriction : {R Ξ“ X C D : CAT}
    (f : MAP X (Map C D)) (p : MAP Ξ“ X) (x : MAP Ξ“ C) (r : MAP R Ξ“)
    β†’
        (applyTerm-cong (comp-assoc r p f) (idIso (x ∘ r)) βˆ™
          (applyTerm-pre (f ∘ p) x r βˆ™ (mapUncurry-at f p x β–· r))) =β‚‚
        (mapUncurry-at f (p ∘ r) (x ∘ r) βˆ™
          ((mapUncurry f ◁ pair-pre p x r) βˆ™ comp-assoc r (pair p x) (mapUncurry f)))
  mapUncurry-at-restriction = Evaluation.mapUncurry-at-restriction 𝒯 M

  mapUncurry-as-apply-parameter-change : {P Q C D : CAT}
    (f : MAP P (Map C D)) (Οƒ : MAP Q P)
    β†’ let s = productMap Οƒ (id C)
          a = (f ◁ pair-β₁ (Οƒ ∘ pr₁) (id C ∘ prβ‚‚)) βˆ™ comp-assoc s pr₁ f
          b = comp-unitΛ‘ prβ‚‚ βˆ™ pair-Ξ²β‚‚ (Οƒ ∘ pr₁) (id C ∘ prβ‚‚)
      in
        (applyTerm-cong (comp-assoc pr₁ Οƒ f) (idIso prβ‚‚) βˆ™ mapUncurry-as-apply (f ∘ Οƒ)) =β‚‚
        (applyTerm-cong a b βˆ™
          (applyTerm-pre (f ∘ pr₁) prβ‚‚ s βˆ™ ((mapUncurry-as-apply f β–· s) βˆ™ mapUncurry-restrict f Οƒ)))
  mapUncurry-as-apply-parameter-change = Evaluation.mapUncurry-as-apply-parameter-change 𝒯 M

  mapUncurry-actions-agree : {X C D : CAT} {f g : MAP X (Map C D)} (Ξ± : f =₁ g)
    β†’ (mapUncurryIso Ξ±) =β‚‚ (mapUncurry-cong Ξ±)
  mapUncurry-actions-agree = Currying.mapUncurry-actions-agree 𝒯 M

```