nLab list

Redirected from "lists".
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

Deduction and Induction

Foundations

foundations

The basis of it all

 Set theory

set theory

Foundational axioms

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 EE of admissible elements is given — also called an “alphabet”, in this context — then a list of EE-elements is a tuple (e 1,e 2,,e )(e_1, e_2, \cdots, e_\ell) of elements e iEe_i \,\in\, E, of any length \ell \,\in\, \mathbb{N} — also called a word in the given alphabet.

Typically one will write “List(E)List(E)” or similar for the set of all lists with entries in EE.

For instance, for EE the (underlying set of) a field, the component-expressions of vectors in the vector space k nk^n may be thought of as lists of length nn with elements in kk. 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 List(E)List(E) 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, (List(E),conc)\big(List(E), conc\big) is the free monoid on EE.

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 EE 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 EE, only that now the corresponding type List(E)List(E) 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 EE. It is, of course, still a free monoid in the proper higher algebraic sense (cf. monoid in a monoidal \infty -category).

Definition

The type of lists on a type AA is defined as the dependent sum type

List(A) n:Fin(n)A\mathrm{List}(A) \coloneqq \sum_{n:\mathbb{N}} \mathrm{Fin}(n) \to A

where Fin(n)\mathrm{Fin}(n) is the finite set with nn 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 AA of generators is the inductive type List(A)\mathrm{List}(A) generated by an element nil:List(A)\mathrm{nil}:\mathrm{List}(A) and a function cons:AList(A)List(A)\mathrm{cons}:A \to \mathrm{List}(A) \to \mathrm{List}(A):

Formation rules for the type of lists:

ΓAtypeΓList(A)type\frac{\Gamma \vdash A \; \mathrm{type}}{\Gamma \vdash \mathrm{List}(A) \; \mathrm{type}}

Introduction rules for the type of lists:

ΓAtypeΓnil:List(A)ΓAtypeΓcons:A(List(A)List(A))\frac{\Gamma \vdash A \; \mathrm{type}}{\Gamma \vdash \mathrm{nil}:\mathrm{List}(A)} \qquad \frac{\Gamma \vdash A \; \mathrm{type}}{\Gamma \vdash \mathrm{cons}:A \to (\mathrm{List}(A) \to \mathrm{List}(A))}

Elimination rules for the type of lists:

ΓAtypeΓ,x:List(A)C(x)type Γc nil:C(nil)Γc cons: a:A x:List(A))C(x)C(cons(a)(x)) Γg:List(A))Γind List(A) C(c nil,c cons,g):C(g)\frac{ \begin{array}{l} \Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \\ \Gamma \vdash c_\mathrm{nil}:C(\mathrm{nil}) \quad \Gamma \vdash c_\mathrm{cons}:\prod_{a:A} \prod_{x:\mathrm{List}(A))} C(x) \to C(\mathrm{cons}(a)(x)) \\ \Gamma \vdash g:\mathrm{List}(A)) \end{array} }{\Gamma \vdash \mathrm{ind}_{\mathrm{List}(A)}^C(c_\mathrm{nil}, c_\mathrm{cons}, g):C(g)}

Computation rules for the type of lists:

  • Judgmental computation rules
ΓAtypeΓ,x:List(A)C(x)type Γc nil:C(nil)Γc cons: a:A x:List(A))C(x)C(cons(a)(x))Γind List(A) C(c nil,c cons,nil)c nil:C(nil)\frac{ \begin{array}{l} \Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \\ \Gamma \vdash c_\mathrm{nil}:C(\mathrm{nil}) \quad \Gamma \vdash c_\mathrm{cons}:\prod_{a:A} \prod_{x:\mathrm{List}(A))} C(x) \to C(\mathrm{cons}(a)(x)) \end{array} }{\Gamma \vdash \mathrm{ind}_{\mathrm{List}(A)}^C(c_\mathrm{nil}, c_\mathrm{cons}, \mathrm{nil}) \equiv c_\mathrm{nil}:C(\mathrm{nil})}


ΓAtypeΓ,x:List(A)C(x)type Γc nil:C(nil)Γc cons: a:A x:List(A))C(x)C(cons(a)(x)) Γb:AΓg:List(A))Γind List(A) C(c nil,c cons,cons(b)(g))c cons(b)(g)(ind List(A) C(c nil,c cons,g)):C(cons(b)(g))\frac{ \begin{array}{l} \Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \\ \Gamma \vdash c_\mathrm{nil}:C(\mathrm{nil}) \quad \Gamma \vdash c_\mathrm{cons}:\prod_{a:A} \prod_{x:\mathrm{List}(A))} C(x) \to C(\mathrm{cons}(a)(x)) \\ \Gamma \vdash b:A \quad \Gamma \vdash g:\mathrm{List}(A)) \end{array} }{\Gamma \vdash \mathrm{ind}_{\mathrm{List}(A)}^C(c_\mathrm{nil}, c_\mathrm{cons}, \mathrm{cons}(b)(g)) \equiv c_\mathrm{cons}(b)(g)(\mathrm{ind}_{\mathrm{List}(A)}^C(c_\mathrm{nil}, c_\mathrm{cons}, g)):C(\mathrm{cons}(b)(g))}


  • Typal computation rules
ΓAtypeΓ,x:List(A)C(x)type Γc nil:C(nil)Γc cons: a:A x:List(A))C(x)C(cons(a)(x))Γβ List(A) nil(c nil,c cons):Id C(nil)(ind List(A) C(c nil,c cons,nil),c nil)\frac{ \begin{array}{l} \Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \\ \Gamma \vdash c_\mathrm{nil}:C(\mathrm{nil}) \quad \Gamma \vdash c_\mathrm{cons}:\prod_{a:A} \prod_{x:\mathrm{List}(A))} C(x) \to C(\mathrm{cons}(a)(x)) \end{array} }{\Gamma \vdash \beta_{\mathrm{List}(A)}^\mathrm{nil}(c_\mathrm{nil}, c_\mathrm{cons}):\mathrm{Id}_{C(\mathrm{nil})}(\mathrm{ind}_{\mathrm{List}(A)}^C(c_\mathrm{nil}, c_\mathrm{cons}, \mathrm{nil}), c_\mathrm{nil})}


ΓAtypeΓ,x:List(A)C(x)type Γc nil:C(nil)Γc cons: a:A x:List(A))C(x)C(cons(a)(x)) Γb:AΓg:List(A))Γβ List(A) cons(c nil,c cons,b,g):Id C(cons(b)(g))(ind List(A) C(c nil,c cons,cons(b)(g)),c cons(b)(g)(ind List(A) C(c nil,c cons,g)))\frac{ \begin{array}{l} \Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \\ \Gamma \vdash c_\mathrm{nil}:C(\mathrm{nil}) \quad \Gamma \vdash c_\mathrm{cons}:\prod_{a:A} \prod_{x:\mathrm{List}(A))} C(x) \to C(\mathrm{cons}(a)(x)) \\ \Gamma \vdash b:A \quad \Gamma \vdash g:\mathrm{List}(A)) \end{array} }{\Gamma \vdash \beta_{\mathrm{List}(A)}^\mathrm{cons}(c_\mathrm{nil}, c_\mathrm{cons}, b, g):\mathrm{Id}_{C(\mathrm{cons}(b)(g))}(\mathrm{ind}_{\mathrm{List}(A)}^C(c_\mathrm{nil}, c_\mathrm{cons}, \mathrm{cons}(b)(g)), c_\mathrm{cons}(b)(g)(\mathrm{ind}_{\mathrm{List}(A)}^C(c_\mathrm{nil}, c_\mathrm{cons}, g)))}


Uniqueness rules for the type of lists:

  • Judgmental uniqueness rules
ΓAtypeΓ,x:List(A)C(x)typeΓc: x:List(A)C(x)Γg:List(A)Γind List(A) C(c(nil),λa:A.λx:List(A).c(cons(a)(x)),g)c(g):C(g)\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \quad \Gamma \vdash c:\prod_{x:\mathrm{List}(A)} C(x) \quad \Gamma \vdash g:\mathrm{List}(A)}{\Gamma \vdash \mathrm{ind}_{\mathrm{List}(A)}^C(c(\mathrm{nil}), \lambda a:A.\lambda x:\mathrm{List}(A).c(\mathrm{cons}(a)(x)), g) \equiv c(g):C(g)}
  • Typal uniqueness rules
ΓAtypeΓ,x:List(A)C(x)typeΓc: x:List(A)C(x)Γg:List(A)Γη List(A)(c,n):Id C(g)(ind List(A) C(c(nil),λa:A.λx:List(A).c(cons(a)(x)),g),c(g))\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \quad \Gamma \vdash c:\prod_{x:\mathrm{List}(A)} C(x) \quad \Gamma \vdash g:\mathrm{List}(A)}{\Gamma \vdash \eta_{\mathrm{List}(A)}(c, n):\mathrm{Id}_{C(g)}(\mathrm{ind}_{\mathrm{List}(A)}^C(c(\mathrm{nil}), \lambda a:A.\lambda x:\mathrm{List}(A).c(\mathrm{cons}(a)(x)), g), c(g))}

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:

ΓAtypeΓ,x:List(A)C(x)typeΓc nil:C(nil)Γc cons: a:A x:List(A))C(x)C(cons(a)(x))Γup C(c nil,c cons):!c: x:List(A))C(x).Id C(nil)(c(nil),c nil)× a:A x:List(A)Id C(cons(a)(x))(c(cons(a)(x)),c cons(a)(c(x)))\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:\mathrm{List}(A) \vdash C(x) \; \mathrm{type} \quad \Gamma \vdash c_\mathrm{nil}:C(\mathrm{nil}) \quad \Gamma \vdash c_\mathrm{cons}:\prod_{a:A} \prod_{x:\mathrm{List}(A))} C(x) \to C(\mathrm{cons}(a)(x))}{\Gamma \vdash \mathrm{up}_\mathbb{Z}^C(c_\mathrm{nil}, c_\mathrm{cons}):\exists!c:\prod_{x:\mathrm{List}(A))} C(x).\mathrm{Id}_{C(\mathrm{nil})}(c(\mathrm{nil}), c_\mathrm{nil}) \times \prod_{a:A} \prod_{x:\mathrm{List}(A)} \mathrm{Id}_{C(\mathrm{cons}(a)(x))}(c(\mathrm{cons}(a)(x)), c_\mathrm{cons}(a)(c(x)))}

See also

References

Types of lists are defined in section 5.1 in:

Last revised on January 25, 2023 at 04:24:46. See the history of this page for a list of all contributions to it.