Defining Operations on ℕ
Addition, multiplication, exponentiation via recursive equations
Once we have naturals, we want to do things with them. We define operations
by defining equations that mirror the Peano construction.
Addition :
-
-
Multiplication :
-
-
Exponentiation :
-
-
These are recursive definitions: each one reduces until it reaches .
That gives us a mechanical way to compute — apply the rules as rewrite
rules until no more apply. This is the replacement rule.
For example, to compute :
The greatest common divisor gcd(a, b) is the largest natural dividing both a and b. On unary naturals, gcd is defined by Euclid's algorithm:
where is the remainder when is divided by .
Step-by-step (working with peano numerals):
For (i.e. ):
1. : compute .
2. : compute .
3. : compute .
4. : return . So . ✓
Predecessor. To compute we need the predecessor function with . Defined recursively:
-
-
The proof of correctness for gcd uses induction on . Euclid's algorithm always terminates because the second argument strictly decreases.