natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory
basic constructions:
strong axioms
further
In type theory: the the natural numbers type is the type of natural numbers.
The type of natural numbers is the inductive type defined by the following inference rules.
(In the last line, “” denotes judgemental equality.)
That this is the right definition (and a special case of the general principle of inductive types) was clearly understood around Martin-Löf (1984), pp. 38; Coquand & Paulin (1990, p. 52-53); Paulin-Mohring (1993, §1.3); Dybjer (1994, §3). For review see also, e.g., Pfenning (2009, §2); UFP (2013, §1.9); Söhnen (2018, §2.4.5).
In Coq-syntax the natural numbers are the inductive type defined [cf. Paulin-Mohring (2014, p. 6)] by:
Inductive nat : Type :=
| zero : nat
| succ : nat -> nat.
In the categorical semantics (via the categorical model of dependent types, see below) this is interpreted as the initial algebra for the endofunctor that sends an object to its coproduct with the terminal object
or in different equivalent notation, which is very suggestive here:
That initial algebra is (as also explained there) precisely a natural number object . The two components of the morphism that defines the algebra structure are the 0-element and the successor endomorphism
Assuming that identification types, function types and dependent sequence types exist in the type theory, the natural numbers type is the inductive type generated by an element and a function:
Formation rules for the natural numbers type:
Introduction rules for the natural numbers type:
Elimination rules for the natural numbers type:
Computation rules for the natural numbers type:
Uniqueness rules for the natural numbers type:
The elimination, computation, and uniqueness rules for the natural numbers type state that the natural numbers type satisfy the dependent universal property of the natural numbers. 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 natural numbers could be simplified to the following rule:
First we inductively define a binary function into the boolean domain called observational equality of the natural numbers:
The extensionality principle of the natural numbers states that the natural numbers has decidable equality given by observational equality:
or equivalently
(natural numbers type as a -type)
The natural numbers type (Def. ) is equivalently the -type with:
;
(empty type);
We spell out how under the canonical categorical model of dependent types, the categorical semantics of the natural numbers types yields a natural numbers object together with its expected recursion and induction principle.
Throughout, we consider an ambient category (e.g. Set) and write
for the category of algebras over the endofunctor (1).
We spell out how the fact that satisfies Def. is the classical recursion principle.
We begin with a simple special case of recursion (cf. Rem. ), where not only the underlying type but also its successor-map is independent of (we come to the general form of recursion further below).
So consider any -algebra (2), hence an object equipped with a morphism
and a morphism
By initiality of the -algebra , there is then a (unique) morphism
such that the following diagram commutes:
This means precisely that is the function defined recursively by
and
More generally, consider an -algebra in the slice over , but with the underlying slice object assumed (dropping also this assumption leads to the fully general notion of induction further below) to be independent of , hence of the form
while the -algebra structure may now depend on :
in that
may depend on .
Now, since with being the initial object in , the identity morphism on is the initial object in the slice category (cf. there), it follows that from such data is induced a unique morphism in the following commuting diagram:
Here the commutativity of the top square means equivalently that
and
(the need for dependent recursion [cf. Paulin-Mohring (1993, p. 330)])
The appearance of the argument “” on the right of (5) – in contrast to formula (3) for non-dependent recursion – means (in view of the argument “” on the left) that the recursor has access to the predecessor partial function . This is necessary in order to express all computable functions on the natural numbers inductively and hence explains the need for the dependently typed recursion principle (4)
Dropping the above constraint (4) on the dependent -algebra, we spell out in detail how the fact that satisfied Def. is the classical induction principle.
That principle says informally that if a proposition depending on the natural numbers is true at and such that if it is true for some then it is true for , then it is true for all natural numbers.
Here is how this is formalized in type theory and then interpreted in some suitable ambient category .
First of all, that is a proposition depending on the natural numbers means that it is a dependent type
The categorical interpretation of this is by a display map
in the given category .
With this, the commuting diagram which interprets the induction principle is the following:
We now unwind again how this comes about and what it all means:
First, the fact that holds at 0 means that there is a (proof-)term
In the categorical semantics the substitution of for 0 that gives is given by the pullback of the given display map (6):
and the term is interpreted as a section of the resulting fibration over the terminal object
But by the defining universal property of the pullback, this is equivalently just a commuting diagram
Next the induction step. Formally it says that for all there is an implication
The categorical semantics of the substitution of for is given by the pullback
and the interpretation of the implication term is as a morphism in
Again by the universal property of the pullback this is equivalently a commuting diagram
In summary this shows that
is interpreted precisely as an endofunctor-algebra homomorphism
for the endofunctor (1).
The induction principle is supposed to deduce from this that holds for every , hence that there is a proof for all :
The categorical interpretation of this is as a morphism in . The existence of this is indeed exactly what the interpretation of the elimination rule (Def. ) gives exactly what the initiality of the -algebra gives.
Original articles with emphasis on the nature of as an inductive type:
Per Martin-Löf (notes by Giovanni Sambin), pp. 38 of: Intuitionistic type theory, Lecture notes Padua 1984, Bibliopolis, Napoli (1984) [pdf, pdf]
Thierry Coquand, Christine Paulin, p. 52-53 in: Inductively defined types, COLOG-88 Lecture Notes in Computer Science 417, Springer (1990) 50-66 [doi:10.1007/3-540-52335-9_47]
Christine Paulin-Mohring, §1.3 in: Inductive definitions in the system Coq – Rules and Properties, in: Typed Lambda Calculi and Applications TLCA 1993, Lecture Notes in Computer Science 664 Springer (1993) [doi:10.1007/BFb0037116]
Peter Dybjer, §3 in: Inductive families, Formal Aspects of Computing 6 (1994) 440–465 doi:10.1007/BF01211308, doi:10.1007/BF01211308, pdf
The syntax in Coq:
See also:
Discussion in a context of homotopy type theory and in view of higher inductive types:
Univalent Foundations Project, §1.9 in: Homotopy Type Theory – Univalent Foundations of Mathematics (2013) [web, pdf]
Kajetan Söhnen, §2.4.5 in: Higher Inductive Types in Homotopy Type Theory, Munich (2018) [pdf, pdf]
Equivalence to binary presentations:
Nicolas Magaud?, Yves Bertot?, Changing Data Structures in Type Theory: A Study of Natural Numbers, in Types for Proofs and Programs. TYPES 2000, Lecture Notes in Computer Science 2277 [doi:10.1007/3-540-45842-5_12, pdf]
Nicolas Magaud?, Changing Data Representation within the Coq, in Theorem Proving in Higher Order Logics. TPHOLs 2003, Lecture Notes in Computer Science 2758 [doi:10.1007/10930755_6]
Last revised on March 27, 2023 at 23:53:50. See the history of this page for a list of all contributions to it.