Structural induction is a technique that can be used to prove properties of the form "for all phrases p in a programming language L, the property P holds".

To prove that a property P holds for all phrases p, prove that, for all p, if P holds for all proper subphrases of p, then P holds for p.

The case where no proper subphrases exist is known as the base case, and the case where proper subphrases do exist is known as the inductive step. The assumption "P holds for all proper subphrases of p" is known as the induction hypothesis. We can think of structural induction as ordinary mathematical induction on the depth of syntax trees.

Here we will prove the claim that for
the SMC machine,
for all `⟨S, M, C⟩`

and `e`

there exists a `c`

and `M'`

such that
`⟨S, M, e:C⟩⇒`

.
^{*}⟨c:S, M', C⟩

The proof is by structural induction on the expression to be evaluated. Any such expression has three possible forms:

Expression Type | Example |
---|---|

Variable | `x` |

Constant | `c` |

Composite | `e` |

Let us consider them in turn:

*Base case variable:*

Our start state is `⟨S, M, x`

for some _{i}:C⟩`S`

, `M`

and `C`

.
From the rules of the SMC machine we have:

` ``⟨S, M, x`_{i}:C⟩⇒⟨c_{i}:S, M, C⟩

where `M=c`

.
So the result holds in this case.
_{0},c_{1},c_{2},...

*Base case constant:*

Our start state is `⟨S, M, c:C⟩`

for some `S`

, `M`

and `C`

.
From the rules of the SMC machine we have:

` ``⟨S, M, c:C⟩⇒⟨c:S, M, C⟩`

So the result holds in this case.

*Inductive step composite:*

Our start state is `⟨S, M, (e`

for some _{1} op e_{2}):C⟩`S`

, `M`

and `C`

.
From the rules of the SMC machine we have:

` ``⟨S, M, (e`_{1} op e_{2}):C⟩⇒⟨S, M, e_{1}:e_{2}:op:C⟩

By the induction hypothesis we can assume the following:

`⟨S, M, e`

_{1}:e_{2}:op:C⟩⇒^{*}⟨c_{1}:S, M'', e_{2}:op:C⟩`⟨c`

_{1}:S, M'', e_{2}:op:C⟩⇒^{*}⟨c_{2}:c_{1}:S, M', op:C⟩

And from SMC rule for the operator we have

` ``⟨c`_{1}:c_{2}:S, M', op:C⟩⇒⟨c_{3}:S, M', C⟩

So the result holds in this case.

Hence the result is established by structural induction.

Here we will prove the claim that the evaluation of expression on the SMC machine does not alter the memory.

The proof is by structural induction on the expression to be evaluated. Any such expression has three possible forms:

Expression Type | Example |
---|---|

Variable | `x` |

Constant | `c` |

Composite | `e` |

Let us consider them in turn:

*Base case variable:*

Our start state is `⟨S, M, x`

for some _{i}:C⟩`S`

, `M`

and `C`

.
From the rules of the SMC machine we have:

`⟨S, M, x`

where_{i}:C⟩⇒⟨c_{i}:S, M, C⟩`M=c`

_{0},c_{1},c_{2},...

As `M`

is not altered, the result holds in this case.

*Base case constant:*

Our start state is `⟨S, M, c:C⟩`

for some `S`

, `M`

and `C`

.
From the rules of the SMC machine we have:

` ``⟨S, M, c:C⟩⇒⟨c:S, M, C⟩`

As `M`

is not altered, the result holds in this case.

*Inductive step composite:*

Our start state is `⟨S, M, (e`

for some _{1} op e_{2}):C⟩`S`

, `M`

and `C`

.
From the rules of the SMC machine we have:

` ``⟨S, M, (e`_{1} op e_{2}):C⟩⇒⟨S, M, e_{1}:e_{2}:op:C⟩

By the induction hypothesis we can assume that the evaluation of
`e`

and _{1}`e`

does not alter the memory.
We also know from the proof in the previous example that _{2}`e`

and _{1}`e`

will
evaluate to some constants, say _{1}`c`

and _{1}`c`

.
From this we have:
_{2}

` ``⟨S, M, e`_{1}:e_{2}:op:C⟩⇒^{*}⟨c:_{2}:c_{1}:S, M, op:C⟩

.

And from SMC rule for the operator we have

` ``⟨c`_{1}:c_{2}:S, M, op:C⟩⇒⟨c_{3}:S, M, C⟩

As `M`

is not altered, the result holds in this case.

Hence the result is established by structural induction.

R. Burstall. *Language Semantics and Implementation. Course Notes.* 1994.

Copyright © 2014 Barry Watson. All rights reserved.