Contents
Context
Type theory
Mapping space
internal hom/mapping space
General abstract
Topology
Simplicial homotopy theory
Differential topology
Stable homotopy theory
Geometric homotopy theory
Contents
Idea
In type theory a function type for two types is the type of functions from to .
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 , 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
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:
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:
The constructor is then determined as usual for a negative type: to construct a term of , we have to specify how it behaves when applied to any input. In other words, we should have a term of type containing a free variable of type . This yields the usual “-abstraction” constructor:
The ∞-reduction? rule is the obvious one (the ur-example of all -reductions), saying that when we evaluate a -abstraction, we do it by substituting for the bound variable.
If we want an ∞-conversion? rule, the natural one says that every function is a -abstraction:
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 (-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.
This rule cannot be formulated in the usual presentation of type theory, since it involves a “higher-order judgment”: the context of the term involves a “term of type containing a free variable of type ”. However, it is possible to make sense of it. In dependent type theory, we need additionally to allow to depend on .
The natural -reduction rule for this eliminator is
and its -conversion rule looks something like
Here is a term containing a free variable of type . By substituting for , we obtain a term of type which depends on “a term containing a free variable ”. We then apply the positive eliminator at , and the -rule says that this can be computed by just substituting for in .
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:
The conversion rules also correspond.
In dependent type theory, this definition of only gives us a properly typed dependent eliminator if the negative function type satisfies -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 -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 :
-
is literally a family of terms in indexed by
-
is a term representation for a family of terms in indexed by
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 and and a term , one could form the family of terms
- given types and , one could form the family of terms
Function types a la Tarski corresponds to the notion of exponential object in category theory where the exponential object literally comes with a morphism , 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:
and the conversion rules for function types a la Tarski are as follows:
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 (-conversion) and uniqueness rules (-conversion) are propositional rather than judgmental:
Weak function types appear in weak type theories.
This contrasts with strict function types which use judgmental computation and uniqueness rules:
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 and respectively for , , , , and .
Rules for function types
By the rules for dependent sum types and dependent product types, one could derive that
which is precisely the statement that is an anafunction for all functions .
Properties
Relation to dependent product types
In dependent type theory a function type is the special case the dependent product type over for the special case that is regarded as an -dependent type that actually happens to be -independent; this type family can always be constructed by the weakening rule of dependent type theory, which is an admissible rule.
In categorical semantics this is the statement that a section of a product projection is equivalently just a morphism .
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 and and function , we have, by the elimination rule and the introduction rule, a function , which by the uniqueness rules of dependent product types are equal to each other
By the inductively defined function which takes identifications between functions to homotopies between functions]], we have that
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:
-
For strict function types, the associative and unital laws are represented by judgmental equality
-
For weak function types, the associative and unital laws are represented by associator and unitor homotopies, and, assuming function extensionality, also by associator and unitor identifications. In addition, there is also an infinite tower of coherence laws representing the -categorical structure of function types by constructing the pentagonator and so forth, but this isn’t demonstrated in this section, and is unnecessary in the presence of a set truncation axiom like UIP or axiom K.
Strict function types
Definition
Given a type , we define the identity function on as the function
Theorem
By the computation rules for strict function types, the identity function on a type comes with a family of judgmental equalities
Definition
Given types , , and and functions , and , function composition of and is defined as
Theorem
By the computation rules for strict function types, function composition comes with a family of judgmental equalities
Theorem
For all types and and functions , there is a family of judgmental equalities
Proof
By the computation rule for strict function types, there is a family of judgmental equalities
and a family of judgmental equalities
Now, by the structural rules for judgmental equality, there is a family of judgmental equalities
Theorem
For all types and and functions , there is a family of judgmental equalities
Proof
By the computation rule for strict function types, there is a family of judgmental equalities
and a family of identifications
Now, by the structural rules for judgmental equality, there is a family of judgmental equalities
Theorem
For all types , , , and , and functions , , and , there is a family of judgmental equalities
Proof
By the computation rule for strict function types, there are families of judgmental equalities
Now, by the structural rules for judgmental equality, there is a family of judgmental equalities
Now, the judgmental uniqueness rule for strict function types implies function extensionality for judgmental equality: for types and and functions and such that there is a family of judgmental equalities , there is a judgmental equality . (See exercise 2.1 of Rijke 2022)
As a result, the associative and unital laws hold for functions:
Theorem
For all types and and functions , there is a judgmental equality
Theorem
For all types and and functions , there is a judgmental equality
Theorem
For all types , , , and , and functions , , and , there is a judgmental equality
Weak function types
Definition
Given a type , we define the identity function on as the function
Theorem
By the computation rules for weak function types, the identity function on a type comes with a family of identifications
Definition
Given types , , and and functions , and , function composition of and is defined as
Theorem
By the computation rules for weak function types, function composition comes with a family of identifications
Theorem
For all types and and functions , the dependent function type
has a homotopy.
Proof
By the computation rule for weak function types, there is a family of identifications
and a family of identifications
Now, by concatenating the individual identifications together and then using lambda abstraction, we have the homotopy
Definition
For types and and function , we define the left unitor homotopy as the homotopy
Theorem
For all types and and functions , the dependent function type
has a homotopy.
Proof
By the computation rule for weak function types, there is a family of identifications
and also by the action on identifications of the function , a family of identifications
Now, by concatenating the individual identifications together and then using lambda abstraction, we have the homotopy
Definition
For types and and function , we define the right unitor homotopy as the homotopy
Theorem
For all types , , , and , and functions , , and , the dependent function type
has a homotopy.
Proof
By the computation rule for weak function types, there are families of identifications
and also by the action on identifications of the function , there is a family of identifications
Now, by concatenating and inverting the individual identifications together and then using lambda abstraction, we have the homotopy
Definition
For types , , , and and functions , , and , we define the associator homotopy as the homotopy
Now, recall that the canonical function
is inductively defined by
function extensionality states that is an equivalence of types for all functions and
Thus, there is an inverse function
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 and and functions , the identity type
has an identification.
Proof
By function extensionality, the function
has an inverse function
One then gets the identification
Definition
For types and and function , we define the left unitor as the identification
Theorem
Assuming function extensionality, for all types and and functions , the identity type
has an identification.
Proof
By function extensionality, the function
has an inverse function
One then gets the identification
Definition
For types and and function , we define the right unitor as the identification
Theorem
Assuming function extensionality, for all types , , , and and functions , , and , the identity type
has an identification.
Proof
By function extensionality, the function
has an inverse function
One then gets the identification
Definition
For types , , , and and functions , , and , we define the associator as the identification
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 and , functions and and an identification there are families of identifications .
Proof
We simply define the dependent function to be the canonical inductively defined function 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 and , families of elements and , and families of identifications , there is an identification
Proof
By the computation rule of strict function types, there are families of judgmental equalities
Thus, by the structural rules of judgmental equality, there are families of identificaitons
and by -abstraction, one gets the dependent function
By function extensionality, there is an equivalence of types
which yields an identification
We define
Finally, we present the typal congruence rule for the formation rule of function types, which relies upon the previous two results.
Theorem
Given types , , , and equivalences and , there is an equivalence
Proof
We define the function by
and the inverse function by
Now it suffices to construct homotopies
from where it implies that has a coherent inverse and contractible fibers and is thus an equivalence of types.
By definition,
By the computation rules of strict function types, there is a family of judgmental equalities
and thus by the structural rules of judgmental equalities and the judgmental congruence rules for function types, a judgmental equality
The equivalence has a family of identifications
witnessing that is a retraction of .
This means that by applying the canonical inductively defined function which takes identifications between functions to homotopies between functions, one gets the family of identifications
Similarly, the equivalence has a family of identifications
witnessing that is a retraction of .
This means by applying to the above family of identifications, one gets the family of identifications
By concatenation of identifications, one gets the family of identifications
By lambda abstraction, one gets the homotopy
and by function extensionality, this is the same as
By the computation rules of strict function types and the structural rules of judgmental equality, the type
is judgmentally equal to , so we have
-abstraction on functions leads to the dependent function
By a similar argument swapping the types around and the corresponding equivalences with inverse equivalences; one also has
Thus, is an equivalence of types.
Weak function types
Theorem
Given types , , , and equivalences and , there is an equivalence
Proof
We define the function by
and the inverse function by
Now it suffices to construct homotopies
from where it implies that 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 and , functions and and an identification there are families of identifications .
Proof
We simply define the dependent function to be the canonical inductively defined function 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 and , functions and , and an identification , there is an identification
Proof
We simply define to be the dependent function application to identifications
where
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 and , families of elements and , and families of identifications , there is an identification
Proof
By the computation rule of weak function types, there are families of identifications
Thus, there are families of identifications
and by -abstraction, one gets the dependent function
By function extensionality, there is an equivalence of types
which yields an identification
We define
Application in logic
In logic, functions types express implication. More precisely, for two propositions, under propositions as types the implication is the function type (or rather the bracket type of that if one wishes to force this to be of type again ).
Graph of a function
Given a type and , there is a function
which takes a function and returns the graph of a function
defined by for all . As a dependent anafunction the graph of the function is represented by the identity type family
and so is equivalently the dependent sum type
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.