nLab function type



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
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


Mapping space



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.


type theorycategory theory
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)


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).

As a special case of the dependent product

In dependent type theory a function type ABA \to B is the special case the dependent product over a:Aa : A for the special case that BB is regarded as an AA-dependent type that actually happens to be AA-independent. The rules are given as follows:

ΓAtypeΓ,x:ABtypeΓ,a:A,b:AB[a/x]B[b/x]typeΓABtype\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:A \vdash B \; \mathrm{type} \quad \Gamma, a:A, b:A \vdash B[a/x] \equiv B[b/x] \; \mathrm{type}}{\Gamma \vdash A \to B \; \mathrm{type}}
ΓAtypeΓ,x:ABtypeΓ,a:A,b:AB[a/x]B[b/x]typeΓAB x:ABtype\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:A \vdash B \; \mathrm{type} \quad \Gamma, a:A, b:A \vdash B[a/x] \equiv B[b/x] \; \mathrm{type}}{\Gamma \vdash A \to B \equiv \prod_{x:A} B\; \mathrm{type}}

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.

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.


Relation to dependent product types

A function type is the special case of a dependent product type for the case where the dependent type does not actually depend.

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

See also at function monad.

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 ).


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

See also

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

Last revised on May 19, 2023 at 22:54:32. See the history of this page for a list of all contributions to it.