Other Agda modules in this section (76)
- AbsoluteObjects
- Coherence
- CompositionCalculus.CompositionInputBaseCalculus
- CompositionCalculus.CompositionInputCalculus
- CompositionCalculus.CompositionInputParameterChange
- CompositionCalculus.CompositionNaturality
- CompositionCalculus.CompositionParameterChange
- CompositionCalculus.CompositionRestrictionCalculus
- CompositionCalculus.InternalCoherence
- CompositionCalculus.InternalPentagon
- CompositionCalculus.RetainedComparisonLaws
- CompositionCalculus.RetainedCompositionBaseChange
- CompositionCalculus.RetainedCompositionParameterChange
- CompositionCalculus.RetainedCompositionRoutes
- CompositionCalculus.UniversalAssociatorRestriction
- CompositionCalculus.UniversalCoherence
- CompositionCalculus.UniversalCoherenceCalculus
- CompositionCalculus.UniversalUnitCalculus
- CompositionCalculus.UniversalUnitChange
- Core
- Currying
- EquivalenceDetection
- Everything
- Functoriality
- MappingAnimae
- MappingProducts
- Points
- ProductCalculus.PairSectionEvaluation
- ProductCalculus.ProductAssociativity
- ProductCalculus.ProductPairingComparisons
- ProductCalculus.ProductSecondCoordinate
- ProductCalculus.ProductSubstitution
- ProductCalculus.ProductSubstitutionPairing
- ProductCalculus.ProductSubstitutionUnits
- ProductCalculus.TerminalInsertion
- Setup
- SquareCalculus.EquivalenceSectionFrames
- SquareCalculus.FramedCornerCalculus
- SquareCalculus.ParameterSquareNaturality
- SquareCalculus.ParameterSquarePasting
- SquareCalculus.ParameterSquareUnits
- SquareCalculus.ProjectionSquares
- SquareCalculus.RetainedParameterChangeProjections
- SquareCalculus.SectionFrames
- SquareCalculus.SplitProjectionCalculus
- SquareCalculus.SplitProjectionNaturality
- SquareCalculus.SquareEvaluation
- SquareCalculus.SquareEvaluationPostcomposition
- SquareCalculus.SquareEvaluationVerticalPasting
- SquareCalculus.TriangleEvaluation
- Substitution.ApplicationRestriction
- Substitution.ApplicationRouteNormalization
- Substitution.CoherenceTransport
- Substitution.ComparisonCancellation
- Substitution.Compatibility
- Substitution.ConstantPointRestriction
- Substitution.ConstantSubstitution
- Substitution.DecodingNaturality
- Substitution.EvaluationInputChange
- Substitution.EvaluationParameterChange
- Substitution.IdentityParameterChange
- Substitution.IsomorphismReasoning
- Substitution.IteratedCompatibility
- Substitution.MappingProofCalculus
- Substitution.NestedApplicationRestriction
- Substitution.ParameterChange
- Substitution.ParameterChangeNaturality
- Substitution.PrecompositionNaturality
- Substitution.ProofCalculus
- Substitution.RetainedIdentityParameterChange
- Substitution.SectionComparisonEvaluation
- Substitution.SectionComparisonRestriction
- Substitution.Specialization
- Substitution.SubstitutionCoherence
- Substitution.UncurriedIdentityParameterChange
- Uncurrying
Complete compiler-highlighted source. Follow a symbol to its declaration.
Corresponding book passages
# Composition and application `mapComp` is the composition functor from `Map D E Γ Map C D` to `Map C E`, constructed by currying double evaluation. `composeTerm g f` applies this functor to two mapping terms with a common parameter. Thus `mapComp` names the operation itself, while `composeTerm` applies it. Similarly, `applyTerm f x` evaluates a mapping term on an object term by pairing them and applying evaluation. Both constructions accept terms with any common parameter category. ```agda {-# OPTIONS --safe --without-K #-} open import Agda.Primitive using (Level) open import SCT.VolumeI.Chapter01.Theory using (Theory) import SCT.VolumeI.Chapter01.Section04.Setup as Setup import SCT.VolumeI.Chapter01.Section04.MappingAnimae as MappingAnimae module SCT.VolumeI.Chapter01.Section04.Composition {c m a : Level} (π― : Theory c m a) (M : MappingAnimae.MappingAnimae π―) where open Setup π― open MappingAnimae.MappingAnimae M applyTerm : {Ξ C D : CAT} β MAP Ξ (Map C D) β MAP Ξ C β MAP Ξ D applyTerm f x = mapEval β pair f x doubleEvaluation : {C D E : CAT} β MAP ((Map D E Γ Map C D) Γ C) E doubleEvaluation = applyTerm (prβ β prβ) (applyTerm (prβ β prβ) prβ) mapComp : {C D E : CAT} β MAP (Map D E Γ Map C D) (Map C E) mapComp {C} {D} {E} = mapCurry (product-isAn (map-isAn D E) (map-isAn C D)) doubleEvaluation mapComp-Ξ² : {C D E : CAT} β (mapUncurry (mapComp {C} {D} {E})) =β doubleEvaluation mapComp-Ξ² {C} {D} {E} = mapCurry-Ξ² (product-isAn (map-isAn D E) (map-isAn C D)) doubleEvaluation mapId : (C : CAT) β Obj-abs (Map C C) mapId C = mapCurry one-isAn prβ mapId-Ξ² : (C : CAT) β (mapUncurry (mapId C)) =β prβ mapId-Ξ² C = mapCurry-Ξ² one-isAn prβ composeTerm : {Ξ C D E : CAT} β MAP Ξ (Map D E) β MAP Ξ (Map C D) β MAP Ξ (Map C E) composeTerm g f = mapComp β pair g f identityTerm : {Ξ : CAT} (C : CAT) β MAP Ξ (Map C C) identityTerm C = const (mapId C) applyTerm-cong : {Ξ C D : CAT} {f g : MAP Ξ (Map C D)} {x y : MAP Ξ C} β f =β g β x =β y β (applyTerm f x) =β (applyTerm g y) applyTerm-cong Ξ± Ξ² = mapEval β pair-cong Ξ± Ξ² applyTerm-pre : {Ξ Ξ C D : CAT} (f : MAP Ξ (Map C D)) (x : MAP Ξ C) (Ο : MAP Ξ Ξ) β (applyTerm f x β Ο) =β (applyTerm (f β Ο) (x β Ο)) applyTerm-pre f x Ο = (mapEval β pair-pre f x Ο) β comp-assoc Ο (pair f x) mapEval composeTerm-cong : {Ξ C D E : CAT} {g gβ² : MAP Ξ (Map D E)} {f fβ² : MAP Ξ (Map C D)} β g =β gβ² β f =β fβ² β (composeTerm g f) =β (composeTerm gβ² fβ²) composeTerm-cong Ξ± Ξ² = mapComp β pair-cong Ξ± Ξ² composeTerm-pre : {Ξ Ξ C D E : CAT} (g : MAP Ξ (Map D E)) (f : MAP Ξ (Map C D)) (Ο : MAP Ξ Ξ) β (composeTerm g f β Ο) =β (composeTerm (g β Ο) (f β Ο)) composeTerm-pre g f Ο = (mapComp β pair-pre g f Ο) β comp-assoc Ο (pair g f) mapComp ``` The next comparisons spell out evaluation at a specified parameter and argument. They use the product beta comparisons and the external associator. ```agda productMap-pair : {Ξ A B C D : CAT} (f : MAP A B) (g : MAP C D) (p : MAP Ξ A) (q : MAP Ξ C) β (productMap f g β pair p q) =β (pair (f β p) (g β q)) productMap-pair f g p q = pair-cong ((f β pair-Ξ²β p q) β comp-assoc (pair p q) prβ f) ((g β pair-Ξ²β p q) β comp-assoc (pair p q) prβ g) β pair-pre (f β prβ) (g β prβ) (pair p q) mapUncurry-at : {Ξ X C D : CAT} (f : MAP X (Map C D)) (p : MAP Ξ X) (x : MAP Ξ C) β (mapUncurry f β pair p x) =β (applyTerm (f β p) x) mapUncurry-at {C = C} f p x = (mapEval β (pair-cong (idIso (f β p)) (comp-unitΛ‘ x) β productMap-pair f (id C) p x)) β comp-assoc (pair p x) (productMap f (id C)) mapEval mapUncurry-as-apply : {Ξ C D : CAT} (f : MAP Ξ (Map C D)) β (mapUncurry f) =β (applyTerm (f β prβ) prβ) mapUncurry-as-apply f = mapEval β pair-cong (idIso (f β prβ)) (comp-unitΛ‘ prβ) apply-compose : {Ξ C D E : CAT} (g : MAP Ξ (Map D E)) (f : MAP Ξ (Map C D)) (x : MAP Ξ C) β (applyTerm (composeTerm g f) x) =β (applyTerm g (applyTerm f x)) apply-compose g f x = let point = pair (pair g f) x first = pair-Ξ²β g f β ((prβ β pair-Ξ²β (pair g f) x) β comp-assoc point prβ prβ) second = pair-Ξ²β g f β ((prβ β pair-Ξ²β (pair g f) x) β comp-assoc point prβ prβ) third = pair-Ξ²β (pair g f) x inner = applyTerm-cong second third β applyTerm-pre (prβ β prβ) prβ point outer = applyTerm-cong first inner β applyTerm-pre (prβ β prβ) (applyTerm (prβ β prβ) prβ) point in outer β ((mapComp-Ξ² β· point) β (mapUncurry-at mapComp (pair g f) x) β»ΒΉ) apply-identity : {Ξ C : CAT} (x : MAP Ξ C) β (applyTerm (identityTerm C) x) =β x apply-identity {Ξ} {C} x = pair-Ξ²β (terminate Ξ) x β ((mapId-Ξ² C β· pair (terminate Ξ) x) β (mapUncurry-at (mapId C) (terminate Ξ) x) β»ΒΉ) ```