Redirected from "dependent function types".
Dependent product types
Dependent product types
Idea
In dependent type theory, a dependent product type , for a dependent type is the type of “dependently typed functions” assigning to each an element of .
In a model of the type theory in categorical semantics, this is a dependent product. In set theory, it is an element of an indexed product.
It includes function types as the special case when is not dependent on , product types as a special case when is the type of Booleans, and dependent sequence types as a special case when is the natural numbers type.
Overview
Definition
Like any type constructor in type theory, a dependent product 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 for dependent product type is:
As a negative type
Dependent product types are almost always defined as negative types. In this presentation, primacy is given to the eliminators. The natural eliminator of a dependent product 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 . This yields the usual “-abstraction” constructor:
The beta-reduction rule is the obvious one, saying that when we evaluate a -abstraction, we do it by substituting for the bound variable.
If we want an eta-conversion rule, the natural one says that every dependently typed function is a -abstraction:
As a positive type
It is also possible to present dependent product 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 ”. 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 dependent product 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).
Dependent product 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 the family of types indexed by
-
is a term representation for a family of terms in the family of types 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 dependent product types a la Russell and function types a la Tarski.
Dependent product types a la Russell and a la Tarski are expressed respectively via the elimination rule of function types:
- given type and the type family and an element , one could form the family of terms
- given type and the type family one could form the family of terms
Dependent product types a la Tarski corresponds to the notion of dependent product in category theory where the dependent product literally comes with a morphism in the slice category , but dependent product types a la Russell are the one most commonly used in dependent type theory.
The conversion rules for dependent product types a la Russell are as follows:
and the conversion rules for dependent product types a la Tarski are as follows:
For the rest of the article we shall assume the use of dependent product types a la Russell.
Weak and strict dependent product types
In dependent type theory, weak dependent product types are dependent product types for which the computation rules (-conversion) and uniqueness rules (-conversion) are propositional rather than judgmental:
Weak dependent product types appear in weak type theories.
This contrasts with strict dependent product types which use judgmental computation and uniqueness rules:
Strict dependent product types appear in most dependent type theories such as Martin-Löf type theory, observational type theory, and cubical type theory.
For strict dependent product 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.
In terms of function types
Given a dependent type theory with function types, dependent sum types, and identity types, the dependent product type of a type family indexed by can be defined as the type of functions from to the dependent sum type such that the composite of with the first projection function is the identity function on
The underlying family of elements is then given by the composite of with the second projection function of the dependent sum type:
Similarly, given a family of elements , one could construct the function
such that given , . By lambda abstraction, one has
and so the dependent function is given by
One also has which is the associated computation rule for dependent function types. Meanwhile, from the judgmental -conversion rules for negative dependent sum types and function types, one could prove the judgmental -conversion rule for dependent function types. Given
one has
As types of dependent anafunctions
In the same way that one could define equivalence types as types of one-to-one correspondences and function types as types of anafunctions, one could define dependent function types as types of dependent anafunctions. This requires both identity types and indexed heterogeneous identity types being defined first, which we shall write as and respectively for , , , , and . We use Agda notation for dependent function types rather than the dependent product type notation or in this section.
Rules for dependent function types
By the rules for dependent pair types and dependent function types, one could derive that
which is precisely the statement that is a dependent anafunction for all dependent functions .
Properties
Universal property of dependent product types
The universal property of dependent product types states that for all types and type families , there is a family of functions
such that for any other type and family of functions , there is a unique function such that
If there is a type universe , then one could wrap this into a single axiom.
Typal computation and uniqueness rules
The typal computation rule for function types is provable from the other four typal type formers of function types. Given type , type family and dependent function , we have, by the elimination rule and the introduction rule, a dependent function , which by the uniqueness rules of dependent product types are equal to each other
By the inductively defined function which takes identifications between dependent functions to homotopies between dependent functions, we have that
which is the typal computation rule for dependent function types.
Application in logic
In logic, dependent functions types express universal quantifications. More precisely, for a predicate on a type , under propositions as types the universal quantification is the dependent product type (or rather the bracket type of that if one wishes to force this to be of type again ).
Graph of a dependent function
Given a type and a type family , there is a function
which takes a dependent function and returns the graph of a dependent function
defined by for all . As a dependent anafunction the graph of the dependent function is represented by the identity type family
Relation to sections
A family of type is equivalently a type with a function . Then each is defined as the fiber of at element . Then the dependent product of a function is defined as the dependent product type
or equivalently, due to the type theoretic axiom of choice, as the dependent sum type
which says that is a section of . One could eliminate the use of the dependent product type entirely by using the definition of dependent product type from function types:
Categorical interpretation
In categorical semantics, the dependent product types are relative right adjoints to context extension in comprehension categories.
There is also another interpretation in category theory of the dependent product type over as the terminal -indexed wide span under , the object with a family of morphisms
such that for any other object with a family of morphisms , there exists a unique morphism such that
References
The standard rules for type-formation, term introduction/elimination and computation of dependent product type are listed for instance in part I of
Another textbook account could be found in section 2.1 of:
as well as sections 1.4 and 2.9 of:
See also:
On the categorical semantics of dependent product types as relative right adjoints to context extension in comprehension categories:
- Michael Lindgren, Dependent products as relative adjoints, Stockholm (2021) [pdf]