108. Functions of several variables

Functions $F\colon \mathrm{N}^{2} \to \mathrm{N}$ can be defined by induction, too. One technique is to define a function of two variables for all values of one variable by induction on the other variable.

108.1.1 Example Multiplication in $\mathrm{N}$, which is a function $\mathrm{N}^{2} \to \mathrm{N}$, can be defined by

$$\begin{cases} m\cdot 0 = 0 \\ m\cdot (n + 1) =m\cdot n +m \end{cases} \tag{108.1}$$

This defines $m\cdot n$ for each $m \in \mathrm{N}$ by induction on $n$. The definition shows how to define multiplication in terms of adding one.

108.1.2 Exercise The successor function $s\colon \mathrm{N} \to \mathrm{N}$ is the function which takes each natural number to the next one: $s (n ) =n+ 1$. Show how to define addition inductively in terms of the successor function.

108.1.3 Exercise Show how to define the operation $(m,n )\mapsto m^{n}$ inductively in terms of the successor function and multiplication (defined inductively in Example 108.1.1).

108.1.4 Example Theorem 65.1, page 92, gives a recursive definition of the GCD function. It translates directly into the Pascal function in Program 108.1.

FUNCTION GCD(M,N:INTEGER);
BEGIN
  IF M=0 THEN GCD := N
  ELSE
    IF N=0 THEN GCD := M
    ELSE
      GCD := GCD(N,M MOD N)
END;

Program 108.1: Program to compute the GCD

108.1.5 Exercise Define the function $A\colon \mathrm{N} \times\mathrm{N} \to \mathrm{N}$ by

$$\begin{cases} A (0,y) = 1 \\ A (1,0) = 2 \\ A (x, 0) =x+ 2 & \text{for } x \geq 2 \\ A (x,y ) =A (A (x- 1,y ),y -1) \end{cases}$$

a) Prove by induction that $A (x, 1) = 2x$ for all $x \geq 1$.

b) Prove by induction that $A (x, 2) = 2^{x}$ for all $x \geq 0$.

c) Prove by induction that $A (x, 3) = 2^{A(x-1,3)}$ for all $x \geq 0$.

d) Calculate $A (4,4)$.

Pages 163–164 of the book (PDF).