Structural induction on recursive function problem

213 Views Asked by At

Getting a bit stuck on the following problem:

Let $B$ be the language over the alphabet {(,)} that is inductively defined as:

$\Lambda$ $\in$ $B$ (where $\Lambda$ represents an empty string)

If $X$ $\in$ $B$ and $Y$ $\in$ $B$, then $XY$ $\in$ $B$

If $X$ $\in$ $B$, then $(X)$ $\in$ $B$

Prove by structural induction that for all $X$ $\in$ $B$, the number of symbols in $X$ is an even number.

It's relatively simple to see why this would be true. I begin my proof like this:

  1. Check for X = $\Lambda$, $\Lambda$ has $0$ symbols, and $0$ is even.

  2. Assume assertion is true for $Z$ $\in$ $B$, meaning $Z$ is even.

  3. Prove $(Z)$ is even and $ZY$ is even.

Proving $(Z)$ being even is easy enough, but how do I prove $ZY$ is even, to finish up my proof?

1

There are 1 best solutions below

3
On BEST ANSWER

For the case of proving that $ZY\in B$, the induction hypothesis holds both for $X$ and for $Y$. This means that you can assume that the length of both $X$ and $Y$ is even. Then the length of $XY$ is even, because adding two even numbers results to an even number.

Generally, when proving a property inductively, you prove it for the base cases (here, the only base case is the one where $\Lambda\in B$) and, for the rest of the cases, you assume that the property holds for all direct substructures of the structure you're working on. So, for the case "$(X)\in B$, assuming $X\in B$", the direct substructure of $(X)$ is $X$. For the case "$XY\in B$, assuming $X\in B$ and $Y\in B$", the direct substructures are $X$ and $Y$. Therefore, the induction hypothesis should hold for both $X$ and $Y$. Otherwise, it's just impossible to prove the statement inductively, as you noticed yourself.