nLab function type

Contents

Context

Type theory

natural deduction metalanguage, practical foundations

  1. type formation rule
  2. term introduction rule
  3. term elimination rule
  4. computation rule

type theory (dependent, intensional, observational type theory, homotopy type theory)

syntax object language

computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory

logicset theory (internal logic of)category theorytype theory
propositionsetobjecttype
predicatefamily of setsdisplay morphismdependent type
proofelementgeneralized elementterm/program
cut rulecomposition of classifying morphisms / pullback of display mapssubstitution
introduction rule for implicationcounit for hom-tensor adjunctionlambda
elimination rule for implicationunit for hom-tensor adjunctionapplication
cut elimination for implicationone of the zigzag identities for hom-tensor adjunctionbeta reduction
identity elimination for implicationthe other zigzag identity for hom-tensor adjunctioneta conversion
truesingletonterminal object/(-2)-truncated objecth-level 0-type/unit type
falseempty setinitial objectempty type
proposition, truth valuesubsingletonsubterminal object/(-1)-truncated objecth-proposition, mere proposition
logical conjunctioncartesian productproductproduct type
disjunctiondisjoint union (support of)coproduct ((-1)-truncation of)sum type (bracket type of)
implicationfunction set (into subsingleton)internal hom (into subterminal object)function type (into h-proposition)
negationfunction set into empty setinternal hom into initial objectfunction type into empty type
universal quantificationindexed cartesian product (of family of subsingletons)dependent product (of family of subterminal objects)dependent product type (of family of h-propositions)
existential quantificationindexed disjoint union (support of)dependent sum ((-1)-truncation of)dependent sum type (bracket type of)
logical equivalencebijection setobject of isomorphismsequivalence type
support setsupport object/(-1)-truncationpropositional truncation/bracket type
n-image of morphism into terminal object/n-truncationn-truncation modality
equalitydiagonal function/diagonal subset/diagonal relationpath space objectidentity type/path type
completely presented setsetdiscrete object/0-truncated objecth-level 2-type/set/h-set
setset with equivalence relationinternal 0-groupoidBishop set/setoid with its pseudo-equivalence relation an actual equivalence relation
equivalence class/quotient setquotientquotient type
inductioncolimitinductive type, W-type, M-type
higher inductionhigher colimithigher inductive type
-0-truncated higher colimitquotient inductive type
coinductionlimitcoinductive type
presettype without identity types
set of truth valuessubobject classifiertype of propositions
domain of discourseuniverseobject classifiertype universe
modalityclosure operator, (idempotent) monadmodal type theory, monad (in computer science)
linear logic(symmetric, closed) monoidal categorylinear type theory/quantum computation
proof netstring diagramquantum circuit
(absence of) contraction rule(absence of) diagonalno-cloning theorem
synthetic mathematicsdomain specific embedded programming language

homotopy levels

semantics

Mapping space

Contents

Idea

In type theory a function type XYX \to Y for two types X,YX,Y is the type of functions from XX to YY.

In a model of the type theory in categorical semantics, this is an exponential object. In set theory, it is a function set. In dependent type theory, it is a special case of a dependent product type.

Function types are important because they allow the user to quantify over functions in type theory. In material set theory functions are sets and one could quantify over sets, while in structural set theory, while functions are different from sets, one could still quantify over the sort of functions. However, in type theory, one cannot quantify over families of elements x:Ab(x):Bx:A \vdash b(x):B, which are the analogue of functions in material and structural set theory, since families of elements are not elements of a single type, and quantification only occurs over a single type. Instead, one uses function types whose elements, called functions, represent families of elements, in the same way that the elements of type universes represent types.

Overview

type theorycategory theory
syntaxsemantics
natural deductionuniversal construction
function typeinternal hom
type formationX:TypeA:Type(XA):Type\frac{\vdash\: X \colon Type \;\;\;\;\; \vdash\; A\colon Type}{\vdash \; \left(X \to A\right) \colon Type}
term introductionx:Xa(x):A(xa(x)):(XA)\frac{x \colon X \;\vdash\; a(x) \colon A}{\vdash (x \mapsto a\left(x\right)) \colon \left(X \to A\right) }
term eliminationf:(XA)x:Xf(x):A\frac{\vdash\; f \colon \left(X \to A\right)\;\;\;\; \vdash \; x \colon X}{\;\;\;\vdash\; f(x) \colon A}
computation rule(ya(y))(x)=a(x)(y \mapsto a(y))(x) = a(x)

Definition

Like any type constructor in type theory, a function type is specified by rules saying when we can introduce it as a type, how to construct terms of that type, how to use or “eliminate” terms of that type, and how to compute when we combine the constructors with the eliminators.

The type formation rule to build a function type is easy:

A:TypeB:TypeAB:Type\frac{A\colon Type \qquad B \colon Type}{A\to B\colon Type}

As a negative type

Function types are almost always defined as a negative type. In this presentation, primacy is given to the eliminators. The natural eliminator of a function type says that we can apply it to any input:

f:ABa:Af(a):B\frac{f\colon A\to B \qquad a\colon A}{f(a) \colon B}

The constructor is then determined as usual for a negative type: to construct a term of ABA\to B, we have to specify how it behaves when applied to any input. In other words, we should have a term of type BB containing a free variable of type AA. This yields the usual “λ\lambda-abstraction” constructor:

x:Ab:Bλx.b:AB\frac{x\colon A\vdash b\colon B}{\lambda x.b\colon A\to B}

The ∞-reduction? rule is the obvious one (the ur-example of all β\beta-reductions), saying that when we evaluate a λ\lambda-abstraction, we do it by substituting for the bound variable.

(λx.b)(a) βb[a/x](\lambda x.b)(a) \;\to_\beta\; b[a/x]

If we want an ∞-conversion? rule, the natural one says that every function is a λ\lambda-abstraction:

λx.f(x) ηf \lambda x.f(x) \;\to_\eta\; f

As a positive type

It is also possible to present function types as a positive type. However, this requires a stronger metatheory, such as a logical framework. We use the same constructor (λ\lambda-abstraction), but now the eliminator says that to define an operation using a function, it suffices to say what to do in the case that that function is a lambda abstraction.

(x:Ab:B)c:Cf:ABfunsplit(c,f):C\frac{(x\colon A \vdash b\colon B) \vdash c\colon C \qquad f\colon A\to B}{funsplit(c,f)\colon C}

This rule cannot be formulated in the usual presentation of type theory, since it involves a “higher-order judgment”: the context of the term c:Cc\colon C involves a “term of type BB containing a free variable of type AA”. However, it is possible to make sense of it. In dependent type theory, we need additionally to allow CC to depend on ABA\to B.

The natural β\beta-reduction rule for this eliminator is

funsplit(c,λx.g) βc[g/b] funsplit(c, \lambda x.g) \;\to_\beta c[g/b]

and its η\eta-conversion rule looks something like

funsplit(c[λx.b/g],f) ηc[f/g]. funsplit(c[\lambda x.b / g], f) \;\to_\eta\; c[f/g].

Here g:ABc:Cg\colon A\to B \vdash c\colon C is a term containing a free variable of type ABA\to B. By substituting λx.b\lambda x.b for gg, we obtain a term of type CC which depends on “a term b:Bb\colon B containing a free variable x:Ax\colon A”. We then apply the positive eliminator at f:ABf\colon A\to B, and the η\eta-rule says that this can be computed by just substituting ff for gg in cc.

Positive versus negative

As usual, the positive and negative formulations are equivalent in a suitable sense. They have the same constructor, while we can formulate the eliminators in terms of each other:

f(a) funsplit(b[a/x],f) funsplit(c,f) c[f(x)/b] \begin{aligned} f(a) &\coloneqq funsplit(b[a/x], f)\\ funsplit(c, f) &\coloneqq c[f(x)/b] \end{aligned}

The conversion rules also correspond.

In dependent type theory, this definition of funsplitfunsplit only gives us a properly typed dependent eliminator if the negative function type satisfies η\eta-conversion. As usual, if it satisfies propositional eta-conversion then we can transport along that instead—and conversely, the dependent eliminator allows us to prove propositional η\eta-conversion. This is the content of Propositions 3.5, 3.6, and 3.7 in (Garner).

Function types a la Russell and a la Tarski

In dependent type theory, there are two different ways to interpret the term f:ABf:A \to B:

  1. ff is literally a family of terms in BB indexed by AA

  2. ff is a term representation for a family of terms in BB indexed by AA

This situation is similar to how there are two notions of type universe where small types of a universe are interpreted a la Russell, literally as types, or a la Tarski, as a term representation of types. Thus, in analogy to type universes, we can refer to function types a la Russell and function types a la Tarski.

Function types a la Russell and a la Tarski are expressed respectively via the elimination rule of function types:

  • given types AA and BB and a term f:ABf:A \to B, one could form the family of terms x:Af(x):Bx:A \vdash f(x):B
ΓAtypeΓBtypeΓf:ABΓ,x:Af(x):B\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma \vdash f:A \to B}{\Gamma, x:A \vdash f(x):B}
  • given types AA and BB, one could form the family of terms f:AB,x:Aeval(f,x):Bf:A \to B, x:A \vdash \mathrm{eval}(f, x):B
ΓAtypeΓBtypeΓ,f:AB,x:Aeval(f,x):B\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B, x:A \vdash \mathrm{eval}(f, x):B}

Function types a la Tarski corresponds to the notion of exponential object in category theory where the exponential object B AB^A literally comes with a morphism eval:B A×AB\mathrm{eval}:B^A \times A \to B, but function types a la Russell are the one most commonly used in dependent type theory.

The conversion rules for function types a la Russell are as follows:

ΓAtypeΓBtypeΓ,x:Ab(x):BΓ,x:A(λx:A.b(x))(x)b(x):B\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma, x:A \vdash b(x):B}{\Gamma, x:A \vdash (\lambda x:A.b(x))(x) \equiv b(x):B}
ΓAtypeΓBtypeΓf:ABΓfλx:A.f(x):AB\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma \vdash f:A \to B}{\Gamma \vdash f \equiv \lambda x:A.f(x):A \to B}

and the conversion rules for function types a la Tarski are as follows:

ΓAtypeΓBtypeΓ,x:Ab(x):BΓ,x:Aeval(λx:A.b(x),x)b(x):B\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma, x:A \vdash b(x):B}{\Gamma, x:A \vdash \mathrm{eval}(\lambda x:A.b(x), x) \equiv b(x):B}
ΓAtypeΓBtypeΓ,f:ABfλx:A.eval(f,x):AB\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B \vdash f \equiv \lambda x:A.\mathrm{eval}(f, x):A \to B}

For the rest of the article we shall assume the use of function types a la Russell.

Weak and strict function types

In dependent type theory, weak function types are function types for which the computation rules (β\beta-conversion) and uniqueness rules (η\eta-conversion) are propositional rather than judgmental:

ΓAtypeΓBtypeΓ,x:Ab(x):BΓ,a:Aβ AB x:A.b(x)(a):(λ(x:A).b(x))(a)= Bb(a)\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma, x:A \vdash b(x):B}{\Gamma, a:A \vdash \beta_{A \to B}^{x:A.b(x)}(a):(\lambda(x:A).b(x))(a) =_{B} b(a)}
ΓAtypeΓBtypeΓ,f:ABη AB(f):f= ABλ(x:A).f(x)\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B \vdash \eta_{A \to B}(f):f =_{A \to B} \lambda(x:A).f(x)}

Weak function types appear in weak type theories.

This contrasts with strict function types which use judgmental computation and uniqueness rules:

ΓAtypeΓBtypeΓ,x:Ab(x):BΓ,a:A(λ(x:A).b(x))(a)b(a):B\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma, x:A \vdash b(x):B}{\Gamma, a:A \vdash (\lambda(x:A).b(x))(a) \equiv b(a):B}
ΓAtypeΓBtypeΓ,f:ABfλ(x:A).f(x):AB\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B \vdash f \equiv \lambda(x:A).f(x):A \to B}

Strict function types appear in most dependent type theories such as Martin-Löf type theory, observational type theory, and cubical type theory.

For strict function types, the judgmental computation and uniqueness rules automatically imply the propositional computation and uniqueness rules, as by the rules for judgmental equality and identity types, judgmental equality of two terms always implies propositional equality of the two terms.

As types of anafunctions

In dependent type theory, in the same way that one could define equivalence types as types of one-to-one correspondences, one could also define function types as types of anafunctions. This requires both identity types and heterogeneous identity types being defined first, which we shall write as a= Aba =_A b and x= B pyx =_{B}^{p} y respectively for a:Aa:A, b:Ab:A, p:a= Abp:a =_A b, x:B(a)x:B(a), and y:B(b)y:B(b).

Rules for function types

ΓAtypeΓBtypeΓABtypeΓAtypeΓBtypeΓ,f:AB,x:A,y:B A,B(f,x,y)type\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma \vdash A \to B \; \mathrm{type}} \qquad \frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B, x:A, y:B \vdash \mathcal{F}_{A, B}(f, x, y) \; \mathrm{type}}
ΓAtypeΓBtypeΓ,x:Af(x):BΓxf(x):AB\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma, x:A \vdash f(x):B}{\Gamma \vdash x \mapsto f(x):A \to B}
ΓAtypeΓBtypeΓ,x:Af(x):BΓ,x:Aα(x): A,B(xf(x),x,f(x))\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma, x:A \vdash f(x):B}{\Gamma, x:A \vdash \alpha(x):\mathcal{F}_{A, B}(x \mapsto f(x), x, f(x))}
ΓAtypeΓBtypeΓ,f:AB,x:Aev(f,x):B\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B, x:A \vdash \mathrm{ev}(f, x):B}
ΓAtypeΓBtypeΓ,f:AB,x:Aβ(f,x): A,B(f,x,ev(f,x))\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B, x:A \vdash \beta(f, x):\mathcal{F}_{A, B}(f, x, \mathrm{ev}(f, x))}
ΓAtypeΓBtypeΓ,f:AB,x:A,y:B,u: A,B(f,x,y)κ(f,x,y,u):ev(f,x)= By\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B, x:A, y:B, u:\mathcal{F}_{A, B}(f, x, y) \vdash \kappa(f, x, y, u):\mathrm{ev}(f, x) =_B y}
ΓAtypeΓBtypeΓ,f:AB,x:A,y:B,u: A,B(f,x,y)η(f,x,y,u):β(f,x)= A,B(f,x) κ(f,x,y,u)u\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B, x:A, y:B, u:\mathcal{F}_{A, B}(f, x, y) \vdash \eta(f, x, y, u):\beta(f, x) =_{\mathcal{F}_{A, B}(f, x)}^{\kappa(f, x, y, u)} u}

By the rules for dependent sum types and dependent product types, one could derive that

ΓAtypeΓBtypeΓ,f:ABη(f): x:AisContr( y:B A,B(f,x,y))\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type}}{\Gamma, f:A \to B \vdash \eta(f):\prod_{x:A} \mathrm{isContr}\left(\sum_{y:B} \mathcal{F}_{A, B}(f, x, y) \right)}

which is precisely the statement that A,B(f)\mathcal{F}_{A, B}(f) is an anafunction for all functions f:ABf:A \to B.

Properties

Relation to dependent product types

In dependent type theory a function type ABA \to B is the special case the dependent product type over a:Aa : A for the special case that BB is regarded as an AA-dependent type x:ABx:A \vdash B that actually happens to be AA-independent; this type family x:ABx:A \vdash B can always be constructed by the weakening rule of dependent type theory, which is an admissible rule.

(XA)= x:XA. (X \to A) = \prod_{x \colon X} A \,.

In categorical semantics this is the statement that a section of a product projection A×BAA \times B \to A is equivalently just a morphism ABA \to B.

See also at function monad.

Typal congruence rules and uniqueness rules

The typal computation rule for function types is provable from the other four typal type formers of function types. Given types AA and BB and function f:ABf:A \to B, we have, by the elimination rule and the introduction rule, a function λx:A.f(x):AB\lambda x:A.f(x):A \to B, which by the uniqueness rules of dependent product types are equal to each other

η AB(f):f= ABλx:A.f(x)\eta_{A \to B}(f):f =_{A \to B} \lambda x:A.f(x)

By the inductively defined function idtohomotopy\mathrm{idtohomotopy} which takes identifications between functions to homotopies between functions]], we have that

idtohomotopy(f,λx:A.f(x))(η AB(f)): x:Af(x)= AB(λx:A.f(x))(x)\mathrm{idtohomotopy}(f, \lambda x:A.f(x))(\eta_{A \to B}(f)):\prod_{x:A} f(x) =_{A \to B} (\lambda x:A.f(x))(x)

which is the typal computation rule for function types.

Function types as hom-objects

Function types play the role of hom-objects in a kind of enriched category whose objects are the types. (In fact, in the presence of compatible product types this is a cartesian closed category-structure, cf. Lambek & Scott 1986). They have identity functions and a composition-operation which together satisfy the associativity and unitality laws:

Strict function types

Definition

Given a type AA, we define the identity function on AA as the function

id Aλ(x:A).x:AA\mathrm{id}_A \equiv \lambda (x:A).x:A \to A

Theorem

By the computation rules for strict function types, the identity function on a type AA comes with a family of judgmental equalities

x:Aid A(x)x:Ax:A \vdash \mathrm{id}_A(x) \equiv x:A

Definition

Given types AA, BB, and CC and functions f:ABf:A \to B, and g:BCg:B \to C, function composition of ff and gg is defined as

g A,B,Cfλ(x:A).g(f(x)):ACg \circ_{A, B, C} f \equiv \lambda (x:A).g(f(x)):A \to C

Theorem

By the computation rules for strict function types, function composition comes with a family of judgmental equalities

x:A(g A,B,Cf)(x)g(f(x)):Cx:A \vdash (g \circ_{A, B, C} f)(x) \equiv g(f(x)):C

Theorem

For all types AA and BB and functions f:ABf:A \to B, there is a family of judgmental equalities

x:A(id B A,B,Bf)(x)f(x):Bx:A \vdash (\mathrm{id}_B \circ_{A, B, B} f)(x) \equiv f(x):B

Proof

By the computation rule for strict function types, there is a family of judgmental equalities

x:A(id B A,B,Bf)(x)id B(f(x)):Bx:A \vdash (\mathrm{id}_B \circ_{A, B, B} f)(x) \equiv \mathrm{id}_B(f(x)):B

and a family of judgmental equalities

x:Aid B(f(x))f(x):Bx:A \vdash \mathrm{id}_B(f(x)) \equiv f(x):B

Now, by the structural rules for judgmental equality, there is a family of judgmental equalities

x:A(id B A,B,Bf)(x)f(x):Bx:A \vdash (\mathrm{id}_B \circ_{A, B, B} f)(x) \equiv f(x):B

Theorem

For all types AA and BB and functions f:ABf:A \to B, there is a family of judgmental equalities

x:A(f A,A,Bid A)(x)f(x):Bx:A \vdash (f \circ_{A, A, B} \mathrm{id}_A)(x) \equiv f(x):B

Proof

By the computation rule for strict function types, there is a family of judgmental equalities

x:A(f A,A,Bid A)(x)f(id A(x)):Bx:A \vdash (f \circ_{A, A, B} \mathrm{id}_A)(x) \equiv f(\mathrm{id}_A(x)):B

and a family of identifications

x:Af(id A(x))f(x):Bx:A \vdash f(\mathrm{id}_A(x)) \equiv f(x):B

Now, by the structural rules for judgmental equality, there is a family of judgmental equalities

x:A(f A,A,Bid A)(x)f(x):Bx:A \vdash (f \circ_{A, A, B} \mathrm{id}_A)(x) \equiv f(x):B

Theorem

For all types AA, BB, CC, and DD, and functions f:ABf:A \to B, g:BCg:B \to C, and h:CDh:C \to D, there is a family of judgmental equalities

x:A(h A,C,D(g A,B,Cf))(x)((h B,C,Dg) A,B,Df)(x):Dx:A \vdash (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) \equiv ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x):D

Proof

By the computation rule for strict function types, there are families of judgmental equalities

x:A(h A,C,D(g A,B,Cf))(x)h((g A,B,Cf)(x)):Dx:A \vdash (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) \equiv h((g \circ_{A, B, C} f)(x)):D
x:A((h B,C,Dg) A,B,Df)(x)(h B,C,Dg)(f(x)):Dx:A \vdash ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x) \equiv (h \circ_{B, C, D} g)(f(x)):D
x:A(h B,C,Dg)(f(x))h(g(f(x))):Dx:A \vdash (h \circ_{B, C, D} g)(f(x)) \equiv h(g(f(x))):D
x:Ah((g A,B,Cf)(x))h(g(f(x)):Dx:A \vdash h((g \circ_{A, B, C} f)(x)) \equiv h(g(f(x)):D

Now, by the structural rules for judgmental equality, there is a family of judgmental equalities

x:A(h A,C,D(g A,B,Cf))(x)((h B,C,Dg) A,B,Df)(x):Dx:A \vdash (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) \equiv ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x):D

Now, the judgmental uniqueness rule for strict function types implies function extensionality for judgmental equality: for types AA and BB and functions f:ABf:A \to B and g:ABg:A \to B such that there is a family of judgmental equalities x:Af(x)g(x):Bx:A \vdash f(x) \equiv g(x):B, there is a judgmental equality fg:ABf \equiv g:A \to B. (See exercise 2.1 of Rijke 2022)

As a result, the associative and unital laws hold for functions:

Theorem

For all types AA and BB and functions f:ABf:A \to B, there is a judgmental equality

id B A,B,Bff:AB\mathrm{id}_B \circ_{A, B, B} f \equiv f:A \to B

Theorem

For all types AA and BB and functions f:ABf:A \to B, there is a judgmental equality

f A,A,Bid Af:ABf \circ_{A, A, B} \mathrm{id}_A \equiv f:A \to B

Theorem

For all types AA, BB, CC, and DD, and functions f:ABf:A \to B, g:BCg:B \to C, and h:CDh:C \to D, there is a judgmental equality

(h A,C,D(g A,B,Cf))((h B,C,Dg) A,B,Df):AD(h \circ_{A, C, D} (g \circ_{A, B, C} f)) \equiv ((h \circ_{B, C, D} g) \circ_{A, B, D} f):A \to D

Weak function types

Definition

Given a type AA, we define the identity function on AA as the function

id Aλ(x:A).x:AA\mathrm{id}_A \equiv \lambda (x:A).x:A \to A

Theorem

By the computation rules for weak function types, the identity function on a type AA comes with a family of identifications

x:Aβ AA x:A.x(x):id A(x)= Axx:A \vdash \beta_{A \to A}^{x:A.x}(x):\mathrm{id}_A(x) =_{A} x

Definition

Given types AA, BB, and CC and functions f:ABf:A \to B, and g:BCg:B \to C, function composition of ff and gg is defined as

g A,B,Cfλ(x:A).g(f(x)):ACg \circ_{A, B, C} f \equiv \lambda (x:A).g(f(x)):A \to C

Theorem

By the computation rules for weak function types, function composition comes with a family of identifications

x:Aβ AC x:A.g(f(x))(x):(g A,B,Cf)(x)= Cg(f(x))x:A \vdash \beta_{A \to C}^{x:A.g(f(x))}(x):(g \circ_{A, B, C} f)(x) =_{C} g(f(x))

Theorem

For all types AA and BB and functions f:ABf:A \to B, the dependent function type

x:A(id B A,B,Bf)(x)= Bf(x)\prod_{x:A} (\mathrm{id}_B \circ_{A, B, B} f)(x) =_{B} f(x)

has a homotopy.

Proof

By the computation rule for weak function types, there is a family of identifications

x:Aβ AB x:A.id B(f(x))(x):(id B A,B,Bf)(x)= Bid B(f(x))x:A \vdash \beta_{A \to B}^{x:A.\mathrm{id}_B(f(x))}(x):(\mathrm{id}_B \circ_{A, B, B} f)(x) =_{B} \mathrm{id}_B(f(x))

and a family of identifications

x:Aβ BB x:A.f(x)(x):id B(f(x))= Bf(x)x:A \vdash \beta_{B \to B}^{x:A.f(x)}(x):\mathrm{id}_B(f(x)) =_{B} f(x)

Now, by concatenating the individual identifications together and then using lambda abstraction, we have the homotopy

λ(x:A).β AB x:A.id B(f(x))(x)β BB x:A.f(x)(x): x:A(id B A,B,Bf)(x)= Bf(x)\lambda (x:A).\beta_{A \to B}^{x:A.\mathrm{id}_B(f(x))}(x) \bullet \beta_{B \to B}^{x:A.f(x)}(x):\prod_{x:A} (\mathrm{id}_B \circ_{A, B, B} f)(x) =_{B} f(x)

Definition

For types AA and BB and function f:ABf:A \to B, we define the left unitor homotopy as the homotopy

lunith A,B(f)λ(x:A).β AB x:A.id B(f(x))(x)β BB x:A.f(x)(x): x:A(id B A,B,Bf)(x)= Bf(x)\mathrm{lunith}_{A, B}(f) \equiv \lambda (x:A).\beta_{A \to B}^{x:A.\mathrm{id}_B(f(x))}(x) \bullet \beta_{B \to B}^{x:A.f(x)}(x):\prod_{x:A} (\mathrm{id}_B \circ_{A, B, B} f)(x) =_{B} f(x)

Theorem

For all types AA and BB and functions f:ABf:A \to B, the dependent function type

x:A(f A,A,Bid A)(x)= Bf(x)\prod_{x:A} (f \circ_{A, A, B} \mathrm{id}_A)(x) =_{B} f(x)

has a homotopy.

Proof

By the computation rule for weak function types, there is a family of identifications

x:Aβ AB x:A.f(id A(x))(x):(f A,A,Bid A)(x)= Bf(id A(x))x:A \vdash \beta_{A \to B}^{x:A.f(\mathrm{id}_A(x))}(x):(f \circ_{A, A, B} \mathrm{id}_A)(x) =_{B} f(\mathrm{id}_A(x))

and also by the action on identifications of the function f:ABf:A \to B, a family of identifications

x:Aap B(f,id A(x),x,β AA x:A.x(x)):f(id A(x))= Bf(x)x:A \vdash \mathrm{ap}_B(f, \mathrm{id}_A(x), x, \beta_{A \to A}^{x:A.x}(x)):f(\mathrm{id}_A(x)) =_{B} f(x)

Now, by concatenating the individual identifications together and then using lambda abstraction, we have the homotopy

λ(x:A).β AB x:A.f(id A(x))(x)ap B(f,id A(x),x,β AA x:A.x(x)): x:A(f A,A,Bid A)(x)= Bf(x)\lambda (x:A).\beta_{A \to B}^{x:A.f(\mathrm{id}_A(x))}(x) \bullet \mathrm{ap}_B(f, \mathrm{id}_A(x), x, \beta_{A \to A}^{x:A.x}(x)):\prod_{x:A} (f \circ_{A, A, B} \mathrm{id}_A)(x) =_{B} f(x)

Definition

For types AA and BB and function f:ABf:A \to B, we define the right unitor homotopy as the homotopy

runith A,B(f)λ(x:A).β AB x:A.f(id A(x))(x)ap B(f,id A(x),x,β AA x:A.x(x)): x:A(f A,A,Bid A)(x)= Bf(x)\mathrm{runith}_{A, B}(f) \equiv \lambda (x:A).\beta_{A \to B}^{x:A.f(\mathrm{id}_A(x))}(x) \bullet \mathrm{ap}_B(f, \mathrm{id}_A(x), x, \beta_{A \to A}^{x:A.x}(x)):\prod_{x:A} (f \circ_{A, A, B} \mathrm{id}_A)(x) =_{B} f(x)

Theorem

For all types AA, BB, CC, and DD, and functions f:ABf:A \to B, g:BCg:B \to C, and h:CDh:C \to D, the dependent function type

x:A(h A,C,D(g A,B,Cf))(x)= D((h B,C,Dg) A,B,Df)(x)\prod_{x:A} (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) =_{D} ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x)

has a homotopy.

Proof

By the computation rule for weak function types, there are families of identifications

x:Aβ AD x:A.h((g A,B,Cf)(x))(x):(h A,C,D(g A,B,Cf))(x)= Dh((g A,B,Cf)(x))x:A \vdash \beta_{A \to D}^{x:A.h((g \circ_{A, B, C} f)(x))}(x):(h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) =_{D} h((g \circ_{A, B, C} f)(x))
x:Aβ AD x:A.(h B,C,Dg)(f(x))(x):((h B,C,Dg) A,B,Df)(x)= D(h B,C,Dg)(f(x))x:A \vdash \beta_{A \to D}^{x:A.(h \circ_{B, C, D} g)(f(x))}(x):((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x) =_{D} (h \circ_{B, C, D} g)(f(x))
x:Aβ AD x:A.h(g(f(x)))(x):(h B,C,Dg)(f(x))= Dh(g(f(x)))x:A \vdash \beta_{A \to D}^{x:A.h(g(f(x)))}(x):(h \circ_{B, C, D} g)(f(x)) =_{D} h(g(f(x)))

and also by the action on identifications of the function h:CDh:C \to D, there is a family of identifications

x:Aap D(h,(g A,B,Cf)(x),g(f(x)),β AC x:A.g(f(x))(x)):h((g A,B,Cf)(x))= Dh(g(f(x))x:A \vdash \mathrm{ap}_D(h, (g \circ_{A, B, C} f)(x), g(f(x)), \beta_{A \to C}^{x:A.g(f(x))}(x)):h((g \circ_{A, B, C} f)(x)) =_{D} h(g(f(x))

Now, by concatenating and inverting the individual identifications together and then using lambda abstraction, we have the homotopy

λ(x:A).β AD x:A.h((g A,B,Cf)(x))(x)ap D(h,(g A,B,Cf)(x),g(f(x)),β AC x:A.g(f(x))(x)) β AD x:A.h(g(f(x)))(x) 1β AD x:A.(h B,C,Dg)(f(x))(x) 1: x:A(h A,C,D(g A,B,Cf))(x)= D((h B,C,Dg) A,B,Df)(x)\begin{array}{c} \lambda (x:A).\beta_{A \to D}^{x:A.h((g \circ_{A, B, C} f)(x))}(x) \bullet \mathrm{ap}_D(h, (g \circ_{A, B, C} f)(x), g(f(x)), \beta_{A \to C}^{x:A.g(f(x))}(x)) \\ \bullet \beta_{A \to D}^{x:A.h(g(f(x)))}(x)^{-1} \bullet \beta_{A \to D}^{x:A.(h \circ_{B, C, D} g)(f(x))}(x)^{-1}:\prod_{x:A} (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) =_{D} ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x) \end{array}

Definition

For types AA, BB, CC, and DD and functions f:ABf:A \to B, f:BCf:B \to C, and h:CDh:C \to D, we define the associator homotopy as the homotopy

assoch A,B,C,D(f,g,h)λ(x:A).β AD x:A.h((g A,B,Cf)(x))(x)ap D(h,(g A,B,Cf)(x),g(f(x)),β AC x:A.g(f(x))(x)) β AD x:A.h(g(f(x)))(x) 1β AD x:A.(h B,C,Dg)(f(x))(x) 1: x:A(h A,C,D(g A,B,Cf))(x)= D((h B,C,Dg) A,B,Df)(x)\begin{array}{c} \mathrm{assoch}_{A, B, C, D}(f, g, h) \equiv \lambda (x:A).\beta_{A \to D}^{x:A.h((g \circ_{A, B, C} f)(x))}(x) \bullet \mathrm{ap}_D(h, (g \circ_{A, B, C} f)(x), g(f(x)), \beta_{A \to C}^{x:A.g(f(x))}(x)) \\ \bullet \beta_{A \to D}^{x:A.h(g(f(x)))}(x)^{-1} \bullet \beta_{A \to D}^{x:A.(h \circ_{B, C, D} g)(f(x))}(x)^{-1}:\prod_{x:A} (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) =_{D} ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x) \end{array}

Now, recall that the canonical idtohomotopy\mathrm{idtohomotopy} function

idtohomotopy A,B(f,g):f= ABg x:Af(x)= Bg(x)\mathrm{idtohomotopy}_{A, B}(f, g):f =_{A \to B} g \to \prod_{x:A} f(x) =_{B} g(x)

is inductively defined by

idtohomotopy A,B(f,f)(refl AB(f))λ(x:A).refl B(f(x)): x:Af(x)= Bg(x)\mathrm{idtohomotopy}_{A, B}(f, f)(\mathrm{refl}_{A \to B}(f)) \equiv \lambda (x:A).\mathrm{refl}_{B}(f(x)):\prod_{x:A} f(x) =_{B} g(x)

function extensionality states that idtohomotopy A,B(f,g)\mathrm{idtohomotopy}_{A, B}(f, g) is an equivalence of types for all functions f:ABf:A \to B and g:ABg:A \to B

funext A,B: f:AB g:ABisEquiv(idtohomotopy A,B(f,g))\mathrm{funext}_{A, B}:\prod_{f:A \to B} \prod_{g:A \to B} \mathrm{isEquiv}(\mathrm{idtohomotopy}_{A, B}(f, g))

Thus, there is an inverse function

idtohomotopy A,B(f,g) 1:( x:AId B(f(x),g(x)))f= ABg\mathrm{idtohomotopy}_{A, B}(f, g)^{-1}:\left(\prod_{x:A} \mathrm{Id}_{B}(f(x), g(x))\right) \to f =_{A \to B} g

With function extensionality, we can now prove the associative and unital laws, showing that function are a category:

Theorem

Assuming function extensionality, for all types AA and BB and functions f:ABf:A \to B, the identity type

id B A,B,Bf= ABf\mathrm{id}_B \circ_{A, B, B} f =_{A \to B} f

has an identification.

Proof

By function extensionality, the function

idtohomotopy A,B(id B A,B,Bf,f):(id B A,B,Bf= ABf) x:A(id B A,B,Bf)(x)= Bf(x)\mathrm{idtohomotopy}_{A, B}(\mathrm{id}_B \circ_{A, B, B} f, f):(\mathrm{id}_B \circ_{A, B, B} f =_{A \to B} f) \to \prod_{x:A} (\mathrm{id}_B \circ_{A, B, B} f)(x) =_{B} f(x)

has an inverse function

idtohomotopy A,B(id B A,B,Bf,f) 1:( x:A(id B A,B,Bf)(x)= Bf(x))(id B A,B,Bf= ABf)\mathrm{idtohomotopy}_{A, B}(\mathrm{id}_B \circ_{A, B, B} f, f)^{-1}:\left(\prod_{x:A} (\mathrm{id}_B \circ_{A, B, B} f)(x) =_{B} f(x)\right) \to (\mathrm{id}_B \circ_{A, B, B} f =_{A \to B} f)

One then gets the identification

idtohomotopy A,B(id B A,B,Bf,f) 1(lunith A,B(f)):id B A,B,Bf= ABf\mathrm{idtohomotopy}_{A, B}(\mathrm{id}_B \circ_{A, B, B} f, f)^{-1}(\mathrm{lunith}_{A, B}(f)):\mathrm{id}_B \circ_{A, B, B} f =_{A \to B} f

Definition

For types AA and BB and function f:ABf:A \to B, we define the left unitor as the identification

lunit A,B(f)idtohomotopy A,B(id B A,B,Bf,f) 1(lunith A,B(f)):id B A,B,Bf= ABf\mathrm{lunit}_{A, B}(f) \equiv \mathrm{idtohomotopy}_{A, B}(\mathrm{id}_B \circ_{A, B, B} f, f)^{-1}(\mathrm{lunith}_{A, B}(f)):\mathrm{id}_B \circ_{A, B, B} f =_{A \to B} f

Theorem

Assuming function extensionality, for all types AA and BB and functions f:ABf:A \to B, the identity type

f A,A,Bid A= ABff \circ_{A, A, B} \mathrm{id}_A =_{A \to B} f

has an identification.

Proof

By function extensionality, the function

idtohomotopy A,B(f A,A,Bid A,f):(f A,A,Bid A= ABf) x:A(f A,A,Bid A)(x)= Bf(x)\mathrm{idtohomotopy}_{A, B}(f \circ_{A, A, B} \mathrm{id}_A, f):(f \circ_{A, A, B} \mathrm{id}_A =_{A \to B} f) \to \prod_{x:A} (f \circ_{A, A, B} \mathrm{id}_A)(x) =_{B} f(x)

has an inverse function

idtohomotopy A,B(f A,A,Bid A,f) 1:( x:A(f A,A,Bid A)(x)= Bf(x))(f A,A,Bid A= ABf)\mathrm{idtohomotopy}_{A, B}(f \circ_{A, A, B} \mathrm{id}_A, f)^{-1}:\left(\prod_{x:A} (f \circ_{A, A, B} \mathrm{id}_A)(x) =_{B} f(x)\right) \to (f \circ_{A, A, B} \mathrm{id}_A =_{A \to B} f)

One then gets the identification

idtohomotopy A,B(f A,A,Bid A,f) 1(runith A,B(f)):f A,A,Bid A= ABf\mathrm{idtohomotopy}_{A, B}(f \circ_{A, A, B} \mathrm{id}_A, f)^{-1}(\mathrm{runith}_{A, B}(f)):f \circ_{A, A, B} \mathrm{id}_A =_{A \to B} f

Definition

For types AA and BB and function f:ABf:A \to B, we define the right unitor as the identification

runit A,B(f)idtohomotopy A,B(f A,A,Bid A,f) 1(runith A,B(f)):f A,A,Bid A= ABf\mathrm{runit}_{A, B}(f) \equiv \mathrm{idtohomotopy}_{A, B}(f \circ_{A, A, B} \mathrm{id}_A, f)^{-1}(\mathrm{runith}_{A, B}(f)):f \circ_{A, A, B} \mathrm{id}_A =_{A \to B} f

Theorem

Assuming function extensionality, for all types AA, BB, CC, and DD and functions f:ABf:A \to B, f:BCf:B \to C, and h:CDh:C \to D, the identity type

h A,C,D(g A,B,Cf)= AD(h B,C,Dg) A,B,Dfh \circ_{A, C, D} (g \circ_{A, B, C} f) =_{A \to D} (h \circ_{B, C, D} g) \circ_{A, B, D} f

has an identification.

Proof

By function extensionality, the function

idtohomotopy A,D(h A,C,D(g A,B,Cf),(h B,C,Dg) A,B,Df): (h A,C,D(g A,B,Cf)= AD(h B,C,Dg) A,B,Df) x:A(h A,C,D(g A,B,Cf))(x)= D((h B,C,Dg) A,B,Df)(x) \begin{array}{c} \mathrm{idtohomotopy}_{A, D}(h \circ_{A, C, D} (g \circ_{A, B, C} f), (h \circ_{B, C, D} g) \circ_{A, B, D} f): \\ (h \circ_{A, C, D} (g \circ_{A, B, C} f) =_{A \to D} (h \circ_{B, C, D} g) \circ_{A, B, D} f) \\ \to \prod_{x:A} (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) =_{D} ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x) \end{array}

has an inverse function

idtohomotopy A,D(h A,C,D(g A,B,Cf),(h B,C,Dg) A,B,Df) 1: ( x:A(h A,C,D(g A,B,Cf))(x)= D((h B,C,Dg) A,B,Df)(x)) (h A,C,D(g A,B,Cf)= AD(h B,C,Dg) A,B,Df) \begin{array}{c} \mathrm{idtohomotopy}_{A, D}(h \circ_{A, C, D} (g \circ_{A, B, C} f), (h \circ_{B, C, D} g) \circ_{A, B, D} f)^{-1}: \\ \left(\prod_{x:A} (h \circ_{A, C, D} (g \circ_{A, B, C} f))(x) =_{D} ((h \circ_{B, C, D} g) \circ_{A, B, D} f)(x)\right) \\ \to (h \circ_{A, C, D} (g \circ_{A, B, C} f) =_{A \to D} (h \circ_{B, C, D} g) \circ_{A, B, D} f) \end{array}

One then gets the identification

idtohomotopy A,D(h A,C,D(g A,B,Cf),(h B,C,Dg) A,B,Df) 1(assoch A,B,C,D(f,g,h)): h A,C,D(g A,B,Cf)= AD(h B,C,Dg) A,B,Df \begin{array}{c} \mathrm{idtohomotopy}_{A, D}(h \circ_{A, C, D} (g \circ_{A, B, C} f), (h \circ_{B, C, D} g) \circ_{A, B, D} f)^{-1}(\mathrm{assoch}_{A, B, C, D}(f, g, h)):\\ h \circ_{A, C, D} (g \circ_{A, B, C} f) =_{A \to D} (h \circ_{B, C, D} g) \circ_{A, B, D} f \end{array}

Definition

For types AA, BB, CC, and DD and functions f:ABf:A \to B, f:BCf:B \to C, and h:CDh:C \to D, we define the associator as the identification

assoc A,B,C,D(f,g,h)idtohomotopy A,D(h A,C,D(g A,B,Cf),(h B,C,Dg) A,B,Df) 1(assoch A,B,C,D(f,g,h)): h A,C,D(g A,B,Cf)= AD(h B,C,Dg) A,B,Df \begin{array}{c} \mathrm{assoc}_{A, B, C, D}(f, g, h) \equiv \mathrm{idtohomotopy}_{A, D}(h \circ_{A, C, D} (g \circ_{A, B, C} f), (h \circ_{B, C, D} g) \circ_{A, B, D} f)^{-1}(\mathrm{assoch}_{A, B, C, D}(f, g, h)):\\ h \circ_{A, C, D} (g \circ_{A, B, C} f) =_{A \to D} (h \circ_{B, C, D} g) \circ_{A, B, D} f \end{array}

Typal congruence rules

These are called typal congruence rules because they are the analogue of the judgmental congruence rules which use identity types and equivalence types instead of judgmental equality.

Strict function types

Since function types are negative types, we first present the typal congruence rule for the elimination rule of function types

Theorem

Given types AA and BB, functions f:ABf:A \to B and g:ABg:A \to B and an identification p:f= ABgp:f =_{A \to B} g there are families of identifications x:Acompelim(f,g,p)(x):f(x)= Bg(x)x:A \vdash \mathrm{compelim}(f, g, p)(x):f(x) =_B g(x).

Proof

We simply define the dependent function compelim\mathrm{compelim} to be the canonical inductively defined function idtohomotopy\mathrm{idtohomotopy} which takes identifications between functions to homotopies between functions.

The next is the typal congruence rule for the introduction rule of function types. However, unlike the case for the other two rules, one needs function extensionality.

Theorem

Assuming function extensionality, given types AA and BB, families of elements x:Ab(x):Bx:A \vdash b(x):B and x:Ab(x):Bx:A \vdash b'(x):B, and families of identifications x:Ap(x):b(x)= Bb(x)x:A \vdash p(x):b(x) =_B b'(x), there is an identification

congintro x:A.p(x):λ(x:A).b(x)= ABλ(x:A).b(x)\mathrm{congintro}_{x:A.p(x)}:\lambda (x:A).b(x) =_{A \to B} \lambda (x:A).b'(x)

Proof

By the computation rule of strict function types, there are families of judgmental equalities

x:A((λx:A.b(x))(x)b(x):Bx:A \vdash ((\lambda x:A.b(x))(x) \equiv b(x):B
x:A((λx:A.b(x))(x)b(x):Bx:A \vdash ((\lambda x:A.b'(x))(x) \equiv b'(x):B

Thus, by the structural rules of judgmental equality, there are families of identificaitons

x:Ap(x):(λx:A.b(x))(x)= B(λx:A.b(x))(x)x:A \vdash p(x):(\lambda x:A.b(x))(x) =_B (\lambda x:A.b'(x))(x)

and by λ\lambda-abstraction, one gets the dependent function

λ(x:A).p(x): x:A(λx:A.b(x))(x)= B(λx:A.b(x))(x)\lambda (x:A).p(x):\prod_{x:A} (\lambda x:A.b(x))(x) =_B (\lambda x:A.b'(x))(x)

By function extensionality, there is an equivalence of types

funext:(λx:A.b(x))= AB(λx:A.b(x)) x:AId B((λx:A.b(x))(x),(λx:A.b(x))(x))\mathrm{funext}:(\lambda x:A.b(x)) =_{A \to B} (\lambda x:A.b'(x)) \simeq \prod_{x:A} \mathrm{Id}_B((\lambda x:A.b(x))(x), (\lambda x:A.b'(x))(x))

which yields an identification

funext 1(λ(x:A).p(x)):(λx:A.b(x))= AB(λx:A.b(x))\mathrm{funext}^{-1}(\lambda (x:A).p(x)):(\lambda x:A.b(x)) =_{A \to B} (\lambda x:A.b'(x))

We define

congintro x:A.p(x)funext 1(λ(x:A).p(x)):(λx:A.b(x))= AB(λx:A.b(x))\mathrm{congintro}_{x:A.p(x)} \coloneqq \mathrm{funext}^{-1}(\lambda (x:A).p(x)):(\lambda x:A.b(x)) =_{A \to B} (\lambda x:A.b'(x))

Finally, we present the typal congruence rule for the formation rule of function types, which relies upon the previous two results.

Theorem

Given types AA, AA', BB, BB' and equivalences e A:AAe_A:A \simeq A' and e B:BBe_B:B \simeq B', there is an equivalence

congform(e A,e B):(AB)(AB)\mathrm{congform}(e_A, e_B):(A \to B) \simeq (A' \to B')

Proof

We define the function congform(e A,e B):(AB)(AB)\mathrm{congform}(e_A, e_B):(A \to B) \to (A' \to B') by

congform(e A,e B)λ(f:AB).λx:A.e B(f(e A 1(x)))\mathrm{congform}(e_A, e_B) \coloneqq \lambda (f:A \to B).\lambda x:A'.e_B(f(e_A^{-1}(x)))

and the inverse function by

congform(e A,e B) 1λ(g:AB).λx:A.e B 1(g(e A(x)))\mathrm{congform}(e_A, e_B)^{-1} \coloneqq \lambda (g:A' \to B').\lambda x:A.e_B^{-1}(g(e_A(x)))

Now it suffices to construct homotopies

f:ABcongform(e A,e B) 1(congform(e A,e B)(f))= ABf\prod_{f:A \to B} \mathrm{congform}(e_A, e_B)^{-1}(\mathrm{congform}(e_A, e_B)(f)) =_{A \to B} f
g:ABcongform(e A,e B)(congform(e A,e B) 1(g))= ABg\prod_{g:A' \to B'} \mathrm{congform}(e_A, e_B)(\mathrm{congform}(e_A, e_B)^{-1}(g)) =_{A' \to B'} g

from where it implies that congform(e A,e B)\mathrm{congform}(e_A, e_B) has a coherent inverse and contractible fibers and is thus an equivalence of types.

By definition,

congform(e A,e B) 1(congform(e A,e B)(f))λx:A.e B 1((λx:A.e B(f(e A 1(x))))(e A(x)))\mathrm{congform}(e_A, e_B)^{-1}(\mathrm{congform}(e_A, e_B)(f)) \equiv \lambda x:A.e_B^{-1}((\lambda x:A'.e_B(f(e_A^{-1}(x))))(e_A(x)))

By the computation rules of strict function types, there is a family of judgmental equalities

x:A(λx:A.e B(f(e A 1(x))))(e A(x))e B(f(e A 1(e A(x))))x:A \vdash (\lambda x:A'.e_B(f(e_A^{-1}(x))))(e_A(x)) \equiv e_B(f(e_A^{-1}(e_A(x))))

and thus by the structural rules of judgmental equalities and the judgmental congruence rules for function types, a judgmental equality

congform(e A,e B) 1(congform(e A,e B)(f))λx:A.e B 1(e B(f(e A 1(e A(x)))))\mathrm{congform}(e_A, e_B)^{-1}(\mathrm{congform}(e_A, e_B)(f)) \equiv \lambda x:A.e_B^{-1}(e_B(f(e_A^{-1}(e_A(x)))))

The equivalence e B:BBe_B:B \simeq B' has a family of identifications

x:Bret e B(x):e B 1(e B(x))= Bxx:B \vdash \mathrm{ret}_{e_B}(x):e_B^{-1}(e_B(x)) =_{B} x

witnessing that e B 1e_B^{-1} is a retraction of e Be_B.

This means that by applying the canonical inductively defined function idtohomotopy\mathrm{idtohomotopy} which takes identifications between functions to homotopies between functions, one gets the family of identifications

idtohomotopy(λx:A.e B 1(e B(x)),λx:A.x,f(e A 1(e A(x))):e B 1(e B(f(e A 1(e A(x)))))= Bf(e A 1(e A(x)))\mathrm{idtohomotopy}(\lambda x:A.e_B^{-1}(e_B(x)), \lambda x:A.x, f(e_A^{-1}(e_A(x))):e_B^{-1}(e_B(f(e_A^{-1}(e_A(x))))) =_{B} f(e_A^{-1}(e_A(x)))

Similarly, the equivalence e A:AAe_A:A \simeq A' has a family of identifications

x:Bret e A(x):e A 1(e A(x))= Axx:B \vdash \mathrm{ret}_{e_A}(x):e_A^{-1}(e_A(x)) =_{A} x

witnessing that e A 1e_A^{-1} is a retraction of e Ae_A.

This means by applying ff to the above family of identifications, one gets the family of identifications

x:Aap(f,e A 1(e A(x)),x,ret e A(x)):f(e A 1(e A(x)))= Bf(x)x:A \vdash \mathrm{ap}(f, e_A^{-1}(e_A(x)), x, \mathrm{ret}_{e_A}(x)):f(e_A^{-1}(e_A(x))) =_{B} f(x)

By concatenation of identifications, one gets the family of identifications

x:Aidtohomotopy(λx:A.e B 1(e B(x)),λx:A.x,f(e A 1(e A(x)))ap(f,e A 1(e A(x)),x,ret e A(x)):e B 1(e B(f(e A 1(e A(x)))))= Bf(x)x:A \vdash \mathrm{idtohomotopy}(\lambda x:A.e_B^{-1}(e_B(x)), \lambda x:A.x, f(e_A^{-1}(e_A(x))) \bullet \mathrm{ap}(f, e_A^{-1}(e_A(x)), x, \mathrm{ret}_{e_A}(x)):e_B^{-1}(e_B(f(e_A^{-1}(e_A(x))))) =_{B} f(x)

By lambda abstraction, one gets the homotopy

λx:A.idtohomotopy(λx:A.e B 1(e B(x)),λx:A.x,f(e A 1(e A(x)))ap(f,e A 1(e A(x)),x,ret e A(x)): x:Ae B 1(e B(f(e A 1(e A(x)))))= Bf(x)\lambda x:A.\mathrm{idtohomotopy}(\lambda x:A.e_B^{-1}(e_B(x)), \lambda x:A.x, f(e_A^{-1}(e_A(x))) \bullet \mathrm{ap}(f, e_A^{-1}(e_A(x)), x, \mathrm{ret}_{e_A}(x)):\prod_{x:A} e_B^{-1}(e_B(f(e_A^{-1}(e_A(x))))) =_{B} f(x)

and by function extensionality, this is the same as

funext 1(λx:A.idtohomotopy(λx:A.e B 1(e B(x)),λx:A.x,f(e A 1(e A(x)))ap(f,e A 1(e A(x)),x,ret e A(x))):λ(x:A).e B 1(e B(f(e A 1(e A(x)))))= ABλx:A.f(x)\mathrm{funext}^{-1}(\lambda x:A.\mathrm{idtohomotopy}(\lambda x:A.e_B^{-1}(e_B(x)), \lambda x:A.x, f(e_A^{-1}(e_A(x))) \bullet \mathrm{ap}(f, e_A^{-1}(e_A(x)), x, \mathrm{ret}_{e_A}(x))):\lambda (x:A).e_B^{-1}(e_B(f(e_A^{-1}(e_A(x))))) =_{A \to B} \lambda x:A.f(x)

By the computation rules of strict function types and the structural rules of judgmental equality, the type

λ(x:A).e B 1(e B(f(e A 1(e A(x)))))= ABλx:A.f(x)\lambda (x:A).e_B^{-1}(e_B(f(e_A^{-1}(e_A(x))))) =_{A \to B} \lambda x:A.f(x)

is judgmentally equal to congform(e A,e B) 1(congform(e A,e B)(f))= ABf\mathrm{congform}(e_A, e_B)^{-1}(\mathrm{congform}(e_A, e_B)(f)) =_{A \to B} f, so we have

funext 1(λx:A.idtohomotopy(λx:A.e B 1(e B(x)),λx:A.x,f(e A 1(e A(x)))ap(f,e A 1(e A(x)),x,ret e A(x))):congform(e A,e B) 1(congform(e A,e B)(f))= ABf\mathrm{funext}^{-1}(\lambda x:A.\mathrm{idtohomotopy}(\lambda x:A.e_B^{-1}(e_B(x)), \lambda x:A.x, f(e_A^{-1}(e_A(x))) \bullet \mathrm{ap}(f, e_A^{-1}(e_A(x)), x, \mathrm{ret}_{e_A}(x))):\mathrm{congform}(e_A, e_B)^{-1}(\mathrm{congform}(e_A, e_B)(f)) =_{A \to B} f

λ\lambda-abstraction on functions f:ABf:A \to B leads to the dependent function

λ(f:AB).funext 1(λx:A.idtohomotopy(λx:A.e B 1(e B(x)),λx:A.x,f(e A 1(e A(x)))ap(f,e A 1(e A(x)),x,ret e A(x))): f:ABcongform(e A,e B) 1(congform(e A,e B)(f))= ABf\lambda (f:A \to B).\mathrm{funext}^{-1}(\lambda x:A.\mathrm{idtohomotopy}(\lambda x:A.e_B^{-1}(e_B(x)), \lambda x:A.x, f(e_A^{-1}(e_A(x))) \bullet \mathrm{ap}(f, e_A^{-1}(e_A(x)), x, \mathrm{ret}_{e_A}(x))):\prod_{f:A \to B} \mathrm{congform}(e_A, e_B)^{-1}(\mathrm{congform}(e_A, e_B)(f)) =_{A \to B} f

By a similar argument swapping the types around and the corresponding equivalences with inverse equivalences; one also has

λ(g:AB).funext 1(λx:A.idtohomotopy(λx:A.e B(e B 1(x)),λx:A.x,g(e A(e A 1(x)))ap(g,e A(e A 1(x)),x,ret e A 1(x))): g:ABcongform(e A,e B)(congform(e A,e B) 1(g))= ABg\lambda (g:A' \to B').\mathrm{funext}^{-1}(\lambda x:A'.\mathrm{idtohomotopy}(\lambda x:A'.e_B(e_B^{-1}(x)), \lambda x:A'.x, g(e_A(e_A^{-1}(x))) \bullet \mathrm{ap}(g, e_A(e_A^{-1}(x)), x, \mathrm{ret}_{e_A^{-1}}(x))):\prod_{g:A' \to B'} \mathrm{congform}(e_A, e_B)(\mathrm{congform}(e_A, e_B)^{-1}(g)) =_{A' \to B'} g

Thus, congform(e A,e B):(AB)(AB)\mathrm{congform}(e_A, e_B):(A \to B) \to (A' \to B') is an equivalence of types.

Weak function types

Theorem

Given types AA, AA', BB, BB' and equivalences e A:AAe_A:A \simeq A' and e B:BBe_B:B \simeq B', there is an equivalence

congform(e A,e B):(AB)(AB)\mathrm{congform}(e_A, e_B):(A \to B) \simeq (A' \to B')

Proof

We define the function congform(e A,e B):(AB)(AB)\mathrm{congform}(e_A, e_B):(A \to B) \to (A' \to B') by

congform(e A,e B)λ(f:AB).λx:A.e B(f(e A 1(x)))\mathrm{congform}(e_A, e_B) \coloneqq \lambda (f:A \to B).\lambda x:A'.e_B(f(e_A^{-1}(x)))

and the inverse function by

congform(e A,e B) 1λ(g:AB).λx:A.e B 1(g(e A(x)))\mathrm{congform}(e_A, e_B)^{-1} \coloneqq \lambda (g:A' \to B').\lambda x:A.e_B^{-1}(g(e_A(x)))

Now it suffices to construct homotopies

f:ABcongform(e A,e B) 1(congform(e A,e B)(f))= ABf\prod_{f:A \to B} \mathrm{congform}(e_A, e_B)^{-1}(\mathrm{congform}(e_A, e_B)(f)) =_{A \to B} f
g:ABcongform(e A,e B)(congform(e A,e B) 1(g))= ABg\prod_{g:A' \to B'} \mathrm{congform}(e_A, e_B)(\mathrm{congform}(e_A, e_B)^{-1}(g)) =_{A' \to B'} g

from where it implies that congform(e A,e B)\mathrm{congform}(e_A, e_B) has a coherent inverse and contractible fibers and is thus an equivalence of types.

To be finished…

Since function types are negative types, we first present the typal congruence rule for the elimination rule of function types

Theorem

Given types AA and BB, functions f:ABf:A \to B and g:ABg:A \to B and an identification p:f= ABgp:f =_{A \to B} g there are families of identifications x:Acompelim(f,g,p)(x):f(x)= Bg(x)x:A \vdash \mathrm{compelim}(f, g, p)(x):f(x) =_B g(x).

Proof

We simply define the dependent function compelim\mathrm{compelim} to be the canonical inductively defined function idtohomotopy\mathrm{idtohomotopy} which takes identifications between functions to homotopies between functions.

The next is the typal congruence rule for the uniqueness rule of function types.

Theorem

Given types AA and BB, functions f:ABf:A \to B and g:ABg:A \to B, and an identification p:f= ABgp:f =_{A \to B} g, there is an identification

etaCong AB(f,g,p):transport h:AB.h= ABλx:A.h(x)(f,g,p)(η AB(f))= g= ABλx:A.g(x)η AB(g)\mathrm{etaCong}_{A \to B}(f, g, p):\mathrm{transport}_{h:A \to B.h =_{A \to B} \lambda x:A.h(x)}(f, g, p)(\eta_{A \to B}(f)) =_{g =_{A \to B} \lambda x:A.g(x)} \eta_{A \to B}(g)

Proof

We simply define etaCong AB(f,g,p)\mathrm{etaCong}_{A \to B}(f, g, p) to be the dependent function application to identifications

apd h:AB.h= ABλx:A.h(x)(λx:AB.η AB(x),f,g,p)\mathrm{apd}_{h:A \to B.h =_{A \to B} \lambda x:A.h(x)}(\lambda x:A \to B.\eta_{A \to B}(x), f, g, p)

where

f:ABη AB(f):f= ABλx:A.f(x)f:A \to B \vdash \eta_{A \to B}(f):f =_{A \to B} \lambda x:A.f(x)

is the family of elements in the conclusion of the uniqueness rule for weak function types.

The next is the typal congruence rule for the introduction rule of function types. However, unlike the case for the other two rules, one needs function extensionality.

Theorem

Assuming function extensionality, given types AA and BB, families of elements x:Ab(x):Bx:A \vdash b(x):B and x:Ab(x):Bx:A \vdash b'(x):B, and families of identifications x:Ap(x):b(x)= Bb(x)x:A \vdash p(x):b(x) =_B b'(x), there is an identification

congintro x:A.p(x):λ(x:A).b(x)= ABλ(x:A).b(x)\mathrm{congintro}_{x:A.p(x)}:\lambda (x:A).b(x) =_{A \to B} \lambda (x:A).b'(x)

Proof

By the computation rule of weak function types, there are families of identifications

x:Aβ AB x:A.b(x)(b(x)):((λx:A.b(x))(x)= Bb(x)x:A \vdash \beta_{A \to B}^{x:A.b(x)}(b(x)):((\lambda x:A.b(x))(x) =_{B} b(x)
x:Aβ AB x:A.b(x)(b(x)):((λx:A.b(x))(x)= Bb(x)x:A \vdash \beta_{A \to B}^{x:A.b'(x)}(b'(x)):((\lambda x:A.b'(x))(x) =_{B} b'(x)

Thus, there are families of identifications

x:Aβ AB x:A.b(x)(b(x))p(x)β AB x:A.b(x)(b(x)) 1:(λx:A.b(x))(x)= B(λx:A.b(x))(x)x:A \vdash \beta_{A \to B}^{x:A.b(x)}(b(x)) \bullet p(x) \bullet \beta_{A \to B}^{x:A.b'(x)}(b'(x))^{-1}:(\lambda x:A.b(x))(x) =_B (\lambda x:A.b'(x))(x)

and by λ\lambda-abstraction, one gets the dependent function

λ(x:A).β AB x:A.b(x)(b(x))p(x)β AB x:A.b(x)(b(x)) 1: x:A(λx:A.b(x))(x)= B(λx:A.b(x))(x)\lambda (x:A).\beta_{A \to B}^{x:A.b(x)}(b(x)) \bullet p(x) \bullet \beta_{A \to B}^{x:A.b'(x)}(b'(x))^{-1}:\prod_{x:A} (\lambda x:A.b(x))(x) =_B (\lambda x:A.b'(x))(x)

By function extensionality, there is an equivalence of types

funext:(λx:A.b(x))= AB(λx:A.b(x)) x:A(λx:A.b(x))(x)= B(λx:A.b(x))(x)\mathrm{funext}:(\lambda x:A.b(x)) =_{A \to B} (\lambda x:A.b'(x)) \simeq \prod_{x:A} (\lambda x:A.b(x))(x) =_B (\lambda x:A.b'(x))(x)

which yields an identification

funext 1(λ(x:A).β AB x:A.b(x)(b(x))p(x)β AB x:A.b(x)(b(x)) 1):(λx:A.b(x))= AB(λx:A.b(x))\mathrm{funext}^{-1}(\lambda (x:A).\beta_{A \to B}^{x:A.b(x)}(b(x)) \bullet p(x) \bullet \beta_{A \to B}^{x:A.b'(x)}(b'(x))^{-1}):(\lambda x:A.b(x)) =_{A \to B} (\lambda x:A.b'(x))

We define

congintro x:A.p(x)funext 1(λ(x:A).β AB x:A.b(x)(b(x))p(x)β AB x:A.b(x)(b(x)) 1):(λx:A.b(x))= AB(λx:A.b(x))\mathrm{congintro}_{x:A.p(x)} \coloneqq \mathrm{funext}^{-1}(\lambda (x:A).\beta_{A \to B}^{x:A.b(x)}(b(x)) \bullet p(x) \bullet \beta_{A \to B}^{x:A.b'(x)}(b'(x))^{-1}):(\lambda x:A.b(x)) =_{A \to B} (\lambda x:A.b'(x))

Application in logic

In logic, functions types express implication. More precisely, for ϕ,ψ\phi, \psi two propositions, under propositions as types the implication ϕψ\phi \Rightarrow \psi is the function type ϕψ\phi \to \psi (or rather the bracket type of that if one wishes to force this to be of type PropProp again ).

Graph of a function

Given a type AA and BB, there is a function

graph:(AB)(AA×B)\mathrm{graph}:\left(A \to B\right) \to \left(A \to A \times B\right)

which takes a function f:ABf:A \to B and returns the graph of a function

graph(f):A(A×B)\mathrm{graph}(f):A \to (A \times B)

defined by graph(f)(x)(x,f(x))\mathrm{graph}(f)(x) \equiv (x, f(x)) for all x:Ax:A. As a dependent anafunction the graph of the function is represented by the identity type family

x:A,y:Bf(x)= Byx:A, y:B \vdash f(x) =_{B} y

and so is equivalently the dependent sum type

graph(f) x:A y:Bf(x)= By\mathrm{graph}(f) \coloneqq \sum_{x:A} \sum_{y:B} f(x) =_{B} y

References

A textbook account in the context of programming languages is in section III of

Another textbook account could be found in section 2.2 of:

See also

  • Richard Garner, On the strength of dependent products in the type theory of Martin-Löf.

Last revised on January 30, 2024 at 16:11:21. See the history of this page for a list of all contributions to it.