# Peano axioms expressed in type theory

I have a very strong understanding of 1st order logic and am trying to lean type theory as an alternative. Could someone express the Peano axioms with type-theory? I am especially interested to see how induction is represented.

-

## 3 Answers

Let $\bot$ be the uninhabited type of kind $*$, and let types

• $\mathtt{Zero}$ be of kind $*$,
• $\mathtt{Nat}$ and $\mathtt{S}$ be of kind $* \to *$,
• $\mathtt{Eq}$ be of kind $* \to * \to *$.


and also, for any type $\mathtt{T}$ of kind $\mathtt{T} : * \to *$ the following type is also inhabited: $$\pa{T} : \T{\Zero} \to (\Nat{x} \to \T{x} \to \T{\S{x}}) \to \Nat{y} \to \T{y}.$$

Those are Peano axioms as in Wikipedia, but I think there also should be something implying that $\mathtt{S}$ is a function (with respect to $\mathtt{Eq}$) instead of any relation, that is:

$$f : \Nat{x} \to \Nat{y} \to \Eq{x}{y} \to \Eq{\S{x}}{\S{y}}.$$

I hope this helps ;-)

-
does this mean "4" has type "$* \to * \to * \to * \to *$" ? –  user833970 Mar 26 '13 at 21:44
What do you mean by "4"? –  dtldarek Mar 26 '13 at 22:24
the natural number 4 as described by this formulation, s(s(s(s(0)))) –  user833970 Mar 27 '13 at 0:01
0 is of kind $*$ and $s$ is of kind $* \to *$ so $s(0)$ is of kind $*$ and so $s(s(0))$ is of kind $*$ etc. –  dtldarek Mar 27 '13 at 0:13
Here, $x$ is a natural number iff $Nat\ x$ is inhabited. To prove that 4 is a natural number you would like to prove that $Nat\ (S\ (S\ (S\ (S\ Zero))))$ is inhabited. However, $(pa_5\ (pa_5\ (pa_5\ (pa_5\ pa_1))))$ is exactly of the type you need, i.e. the inhabitant you are looking for. –  dtldarek Apr 2 '13 at 19:05

Professor Peter B. Andrews book "An Introduction to Mathematical Logic and Type Theory" (2002) covers exactly this subject. He expresses the postulates like this. (I omit type symbols from variables and constants.)

$1.\ N\ 0$

$2.\ \forall x(N\ x\implies N\ (S \ x))$

$3.\ \forall p(p\ 0\ \land \forall x(N\ x\land p\ x\implies p\ (S\ x))$

$4.\ \forall x(N\ x\implies S\ x \neq 0)$

$5.\ \forall x \forall y(N\ x\ \land\ N\ y\ \land\ S\ x = S\ y \implies x = y)$

Type theory is higher-order logic, and induction quantifies over predicates "p".

-

I just want to add

http://people.inf.elte.hu/divip/AgdaTutorial/Index.html

is a good resource that has a lot of Peano Arithmatic problems.

-