2.4. Definition of addition
Recall the set-up: a is a fixed natural number,
and we want to define the function which sends x to a+x.
By "That's it", here's what we have to do:
-
Define
a+0; -
If we have already defined
a+n, we must definea+S(n).
We want addition to agree with our real world intuition, so let's make the following definition:
Definition 4 (Addition)
-
Define
a+0to bea. -
If
a+nis already defined to bey, then definea+S(n)to beS(y). In other words,a+S(n)is defined to beS(a+n).
def add : ℕ → ℕ → ℕ
| a, 0 => a
| a, succ n => succ (add a n)
"That's it" ensures that this is a valid definition.
The logic in the successor case is that a+S(n) is a and n and one more, so it's the number after a+n.
Let's now prove that 1+1=2.
Theorem 5
1+1=2.
Proof
\begin{align*}
1+1&=1+S(0) &&\mathrm{(by\ definition\ of\ 1)}\\
&=S(1+0) &&\mathrm{(by\ definition\ of\ }a+S(n))\\
&=S(1) &&\mathrm{(by\ definition\ of\ }a+0)\\
&=2 &&\mathrm{(by\ definition\ of\ }2).
\end{align*}
Exercise. Prove that 2+2=4.
Now we have defined addition, the equation S(x)=x+1 finally makes sense.
Let's prove that it is true.
Lemma 6
If x is a natural number then S(x)=x+1.
Proof
\begin{align*}
x+1&=x+S(0)&& \mathrm{(by\ definition\ of\ 1)}\\
&=S(x+0)&& \mathrm{(by\ definition\ of\ }+)\\
&=S(x)&& \mathrm{(by\ definition\ of\ }+).
\end{align*}