next up previous
Next: Problem 4 - Compilation Up: Information Science I Previous: Problem 2 - Operating

Problem 3 - Structural Induction

Let us define a set $ \boldsymbol{L}$ of terms inductively as follows ( $ \mathbb{N}$ is the set of natural numbers):

$\displaystyle nil \in \boldsymbol{L},$

$\displaystyle \forall L \in \boldsymbol{L}. \forall N \in \mathbb{N}.(cons(N,L) \in \boldsymbol{L}).$

Answer the following questions.
1.
Prove that there is exactly one total function $ app \in \boldsymbol{L}\times \boldsymbol{L}
\rightarrow \boldsymbol{L}$ that satisfies the following equations:

$\displaystyle \forall L \in \boldsymbol{L}.(app(nil,L) = L),$

$\displaystyle \forall L_1, L_2 \in \boldsymbol{L}. \forall N \in \mathbb{N}.(app(cons(N,L_1),L_2) = cons(N, app(L_1, L_2))).$

2.
Prove that the above function $ app$ satisfies

$\displaystyle \forall L_1, L_2, L_3 \in \boldsymbol{L}.(app(L_1,app(L_2,L_3))=app(app(L_1, L_2), L_3)).$


1.
Let us suppose that we have two applications $ app_1$ and $ app_2$ described as above. We want to show that $ \forall L_1,L_2 \in \boldsymbol{L}, app_1(L_1) = app_2(L_2)$
2.
We shall prove the property inductively on the length of $ L_1$. Let us first suppose that $ L_1=nil$. Then, we have:
$ app(nil, app(L_2,L_3)) = app(L_2,L_3)$ (according to the definition of $ app$)
$ app(app(nil,L_2), L_3) = app(L_2,L_3)$ (since $ app(nil,L_2)=L_2$)
Thus, the property is true for $ lgh(L_1) = 0$. Let us now suppose that the property is also true for $ lgh(L_1)=k$. Does it hold for $ lgh(L_1)=k+1$?
$ app(L_1, app(L_2, L_3))$
$ =app(cons(N_1',L_1'),app(L_2,L_3))$ with $ L_1 = N_1'L_1'$
$ =cons(N_1',app(L_1',app(L_2,L_3)))$ by the definition of $ app$
$ =cons(N_1',app(app(L_1',L_2),L_3))$ by the inductive hypothesis
$ =app(cons(N_1',app(L_1',L_2)),L_3)$ by the definition of $ app$
$ =app(app(cons(N_1',L_1'),L_2),L_3)$ by the definition of $ app$
$ =app(app(L_1,L_2),L_3)$ by the definition of $ cons$
We have shown the proof by induction.


next up previous
Next: Problem 4 - Compilation Up: Information Science I Previous: Problem 2 - Operating
Reynald AFFELDT
2000-06-08