9717
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
9493
|
3 |
%
|
|
4 |
\begin{isamarkuptext}%
|
|
5 |
\noindent In Exercise~\ref{ex:Tree} we defined a function
|
|
6 |
\isa{flatten} from trees to lists. The straightforward version of
|
|
7 |
\isa{flatten} is based on \isa{\at} and is thus, like \isa{rev}, quadratic.
|
|
8 |
A linear time version of \isa{flatten} again reqires an extra
|
|
9 |
argument, the accumulator:%
|
|
10 |
\end{isamarkuptext}%
|
9673
|
11 |
\isacommand{consts}\ flatten\isadigit{2}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ tree\ {\isacharequal}{\isachargreater}\ {\isacharprime}a\ list\ {\isacharequal}{\isachargreater}\ {\isacharprime}a\ list{\isachardoublequote}%
|
9493
|
12 |
\begin{isamarkuptext}%
|
|
13 |
\noindent Define \isa{flatten2} and prove%
|
|
14 |
\end{isamarkuptext}%
|
9717
|
15 |
\isacommand{lemma}\ {\isachardoublequote}flatten\isadigit{2}\ t\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharequal}\ flatten\ t{\isachardoublequote}\end{isabellebody}%
|
9493
|
16 |
%%% Local Variables:
|
|
17 |
%%% mode: latex
|
|
18 |
%%% TeX-master: "root"
|
|
19 |
%%% End:
|