Structural Induction Explained
August 31, 2024
Mathematical induction is a fundamental concept in computer science and
mathematics, often used to prove properties of structures such as natural
numbers and binary trees. This article provides an introduction to induction,
focusing on how it applies to natural numbers and binary trees, and demonstrates
the process through examples. Unfortunately, most other sources that explain
structural induction don’t do a clear enough job explaining why induction
works for an inductive set. This blog post outlines the process and relates it
to induction over
A Recap of Induction over
#
Induction over
It works by allowing you to prove just two cases:
- base case:
holds. - inductive case: If we know that
holds for some , then also holds.
The reason why this works is that every natural number can be written in the form
for example,
for a finite1 number of
- Equal to
, or - Equal to
for some smaller natural .
So knowing that the base case holds tells us that
and therefore, that
Trees and Inductive Sets #
Structural induction can only be done over a certain kind of set called an
inductive set. These are sets that can be represented as different kinds of
trees. We start out by defining an inductive set of binary trees
The statements above the horizontal line are the premises, and the statement
below is called the conclusion.
The
The
We define
As an example, we can construct the tree
by building it ‘upside down’:
which can be represented grapically as follows:
The Natural Numbers as ‘Unary Trees’ #
Now we’ve got an example to think about, I’d like to take a different view of natural numbers by constructing them as ‘Unary trees’, that is trees where each fork only has one child.
Define
The intuition here is that
Then we can recursively map from
This is recursive because in the second case, we are using
It turns out that this map from unary trees and the natural numbers associates every natural number with a unique unary tree. 2 Intuitively this is because a tally and a unary tree are more or less the same thing. Each starts off with a single value and extends it in a unique way 3.
Structural Induction on Biary Trees #
We will now take a look at an example of induction on binary trees, to demonstrate structural induction.
Consider the hypothesis
We then extend this to apply to a set
The reason why we have to use this as our hypothesis, rather than just having
To make this more concrete we define
Let’s prove this step by step.
Case
#
We already know that
Thus
We’ve now shown that H(\text{Leaf}) holds, so we know that at least
Case
#
Given
We want to show that
Hence
This completes the
Summary #
Structural induction is a powerful tool for proving properties of recursively defined structures like natural numbers and binary trees. By proving that the set of elements satisfying a hypothesis also must satsify every construction rule, we can conclude that this set must be equal to the whole inductive set.
This method is not only foundational in mathematics but also crucial in computer science for reasoning about algorithms and data structures
-
The fact that there are a finite number of
’s is very important. In fact, if you go on to study set theory, then you’ll learn that induction is used to define , and is used to define the concept of finite sets themselves. So this would make our declaration that is made up of finite sums of ’s circular. To learn more about this, Dr Padraic Bartlett’s lecture notes from his Intro to Math course is a very good introduction to axiomatic set theory. ↩︎ -
The jargon for this is
is a bijection. ↩︎ -
Because
= in all cases, as does n + 1 = n + 1 ↩︎