Redirected from "type of lists".
Contents
Context
Type theory
Deduction and Induction
Foundations
foundations
The basis of it all
-
mathematical logic
-
deduction system, natural deduction, sequent calculus, lambda-calculus, judgment
-
type theory, simple type theory, dependent type theory
-
collection, object, type, term, set, element
-
equality, judgmental equality, typal equality
-
universe, size issues
-
higher-order logic
Set theory
Foundational axioms
Removing axioms
Contents
Idea
In mathematics and specifically in formal logic, by a “list” one means the fairly evident formalization of the colloquial notion of a “list of elements”:
If a set of admissible elements is given — also called an “alphabet”, in this context — then a list of -elements is a tuple of elements , of any length — also called a word in the given alphabet.
Typically one will write “” or similar for the set of all lists with entries in .
For instance, for the (underlying set of) a field, the component-expressions of vectors in the vector space may be thought of as lists of length with elements in . However, doing so means to disregard the vector space-structure on the collection of all such lists.
Instead, the notion of list is a concept with an attitude: While lists are just tuples of any length, calling them lists indicates that one intends to consider the operation of concatenation of lists to larger lists, in particular the operations of appending an element to a list.
It is evident that the operation of concatenation makes a monoid (the neutral element under concatenation is the empty list, i.e. the unique list of length zero). In fact, a moment of reflection shows that, as such, is the free monoid on .
Therefore, in much of the mathematical literature, lists are understood as free monoids.
Specifically in computer science one commonly deals with the corresponding notion of the data type of lists (with entries in a prescribed data type), which serve as a basic and common kind of data structure?. In programming languages supporting something like a calculus of constructions, this data type, essentially with the free monoid-structure as above, may be defined as an inductive type in an evident way (made explicit below).
On the other hand, in dependent type theories which have a homotopy type theory-interpretation — in that they do not verify uniqueness of identity proofs (or “axiom K”) — one may want to distinguish between lists and free monoids:
Because, in such theories it may happen that the given alphabet type is not actually a set but a higher homotopy type, in that it is not 0-truncated. In this case it still makes good sense to speak of lists of elements (terms) of , only that now the corresponding type is itself not 0-truncated. But since the term “monoid” carries with it a connotation of being 0-truncated, one may no longer want to call this the free monoid on . It is, of course, still a free monoid in the proper higher algebraic sense (cf. monoid in a monoidal -category).
Definition
The type of lists on a type is defined as the dependent sum type
where is the finite set with elements. This shows that lists are just tuples.
Rules for types of lists
Assuming that identification types, function types and dependent product types exist in the type theory, the type of lists on a type of generators is the inductive type generated by an element and a function :
Formation rules for the type of lists:
Introduction rules for the type of lists:
Elimination rules for the type of lists:
Computation rules for the type of lists:
- Judgmental computation rules
Uniqueness rules for the type of lists:
- Judgmental uniqueness rules
The elimination, typal computation, and typal uniqueness rules for the type of lists type state that the type of lists satisfy the dependent universal property of the type of lists. If the dependent type theory also has dependent sum types and product types, allowing one to define the uniqueness quantifier, the dependent universal property of the type of lists could be simplified to the following rule:
See also
References
Types of lists are defined in section 5.1 in: