9722
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
9924
|
3 |
\def\isabellecontext{Tree}%
|
11866
|
4 |
\isamarkupfalse%
|
8749
|
5 |
%
|
|
6 |
\begin{isamarkuptext}%
|
|
7 |
\noindent
|
11456
|
8 |
Define the datatype of \rmindex{binary trees}:%
|
8749
|
9 |
\end{isamarkuptext}%
|
11866
|
10 |
\isamarkuptrue%
|
|
11 |
\isacommand{datatype}\ {\isacharprime}a\ tree\ {\isacharequal}\ Tip\ {\isacharbar}\ Node\ {\isachardoublequote}{\isacharprime}a\ tree{\isachardoublequote}\ {\isacharprime}a\ {\isachardoublequote}{\isacharprime}a\ tree{\isachardoublequote}\isamarkupfalse%
|
|
12 |
\isamarkupfalse%
|
|
13 |
\isamarkupfalse%
|
|
14 |
%
|
8749
|
15 |
\begin{isamarkuptext}%
|
|
16 |
\noindent
|
11456
|
17 |
Define a function \isa{mirror} that mirrors a binary tree
|
10795
|
18 |
by swapping subtrees recursively. Prove%
|
8749
|
19 |
\end{isamarkuptext}%
|
11866
|
20 |
\isamarkuptrue%
|
|
21 |
\isacommand{lemma}\ mirror{\isacharunderscore}mirror{\isacharcolon}\ {\isachardoublequote}mirror{\isacharparenleft}mirror\ t{\isacharparenright}\ {\isacharequal}\ t{\isachardoublequote}\isamarkupfalse%
|
|
22 |
\isamarkupfalse%
|
|
23 |
\isamarkupfalse%
|
|
24 |
\isamarkupfalse%
|
|
25 |
\isamarkupfalse%
|
|
26 |
%
|
9493
|
27 |
\begin{isamarkuptext}%
|
|
28 |
\noindent
|
|
29 |
Define a function \isa{flatten} that flattens a tree into a list
|
|
30 |
by traversing it in infix order. Prove%
|
|
31 |
\end{isamarkuptext}%
|
11866
|
32 |
\isamarkuptrue%
|
|
33 |
\isacommand{lemma}\ {\isachardoublequote}flatten{\isacharparenleft}mirror\ t{\isacharparenright}\ {\isacharequal}\ rev{\isacharparenleft}flatten\ t{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
|
|
34 |
\isamarkupfalse%
|
|
35 |
\isamarkupfalse%
|
|
36 |
\isamarkupfalse%
|
|
37 |
\end{isabellebody}%
|
9145
|
38 |
%%% Local Variables:
|
|
39 |
%%% mode: latex
|
|
40 |
%%% TeX-master: "root"
|
|
41 |
%%% End:
|