Example. Informal examples of inductively defined functions [00KL]
An inductive definition on the naturals defines a structure for each number n:\mathbb {N} by first defining it for n=0 and then specifying how to augment a structure for n=m to a structure for n=m+1. From the point of view of computer programming, inductive definitions proceed by structural recursion. For example, addition of natural numbers can be defined by induction on the second argument (or the first, if you prefer!):
\begin {aligned} \mathsf {add} &\colon \mathbb {N}^2\to \mathbb {N} \\ \mathsf {add}{\mathopen {}\left (m,0\right )\mathclose {}} &= m \\ \mathsf {add}{\mathopen {}\left (m,n+1\right )\mathclose {}} &= \mathsf {add}{\mathopen {}\left (m,n\right )\mathclose {}}+1 \end {aligned}Likewise, the function \Sigma \colon \mathbb {N}\to \mathbb {N} that takes n:\mathbb {N} to the sum \sum _{0\leq i < n}i can be defined inductively:
\begin {aligned} \Sigma &\colon \mathbb {N}\to \mathbb {N}\\ \Sigma {\mathopen {}\left (0\right )\mathclose {}} &= 0\\ \Sigma {\mathopen {}\left (n+1\right )\mathclose {}} &= \mathsf {add}{\mathopen {}\left (n,\Sigma {\mathopen {}\left (n\right )\mathclose {}}\right )\mathclose {}} \end {aligned}