| 9722 |      1 | %
 | 
|  |      2 | \begin{isabellebody}%
 | 
| 10267 |      3 | \def\isabellecontext{Tree{\isadigit{2}}}%
 | 
| 17056 |      4 | %
 | 
|  |      5 | \isadelimtheory
 | 
|  |      6 | %
 | 
|  |      7 | \endisadelimtheory
 | 
|  |      8 | %
 | 
|  |      9 | \isatagtheory
 | 
|  |     10 | %
 | 
|  |     11 | \endisatagtheory
 | 
|  |     12 | {\isafoldtheory}%
 | 
|  |     13 | %
 | 
|  |     14 | \isadelimtheory
 | 
|  |     15 | %
 | 
|  |     16 | \endisadelimtheory
 | 
| 9493 |     17 | %
 | 
|  |     18 | \begin{isamarkuptext}%
 | 
|  |     19 | \noindent In Exercise~\ref{ex:Tree} we defined a function
 | 
|  |     20 | \isa{flatten} from trees to lists. The straightforward version of
 | 
| 9792 |     21 | \isa{flatten} is based on \isa{{\isacharat}} and is thus, like \isa{rev},
 | 
|  |     22 | quadratic. A linear time version of \isa{flatten} again reqires an extra
 | 
| 9493 |     23 | argument, the accumulator:%
 | 
|  |     24 | \end{isamarkuptext}%
 | 
| 17175 |     25 | \isamarkuptrue%
 | 
|  |     26 | \isacommand{consts}\isamarkupfalse%
 | 
| 17181 |     27 | \ flatten{\isadigit{2}}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ tree\ {\isasymRightarrow}\ {\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a\ list{\isachardoublequoteclose}%
 | 
| 9493 |     28 | \begin{isamarkuptext}%
 | 
| 10187 |     29 | \noindent Define \isa{flatten{\isadigit{2}}} and prove%
 | 
| 9493 |     30 | \end{isamarkuptext}%
 | 
| 17175 |     31 | \isamarkuptrue%
 | 
| 17056 |     32 | %
 | 
|  |     33 | \isadelimproof
 | 
|  |     34 | %
 | 
|  |     35 | \endisadelimproof
 | 
|  |     36 | %
 | 
|  |     37 | \isatagproof
 | 
|  |     38 | %
 | 
|  |     39 | \endisatagproof
 | 
|  |     40 | {\isafoldproof}%
 | 
|  |     41 | %
 | 
|  |     42 | \isadelimproof
 | 
|  |     43 | %
 | 
|  |     44 | \endisadelimproof
 | 
| 17175 |     45 | \isacommand{lemma}\isamarkupfalse%
 | 
|  |     46 | \ {\isachardoublequoteopen}flatten{\isadigit{2}}\ t\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharequal}\ flatten\ t{\isachardoublequoteclose}%
 | 
| 17056 |     47 | \isadelimproof
 | 
|  |     48 | %
 | 
|  |     49 | \endisadelimproof
 | 
|  |     50 | %
 | 
|  |     51 | \isatagproof
 | 
|  |     52 | %
 | 
|  |     53 | \endisatagproof
 | 
|  |     54 | {\isafoldproof}%
 | 
|  |     55 | %
 | 
|  |     56 | \isadelimproof
 | 
|  |     57 | %
 | 
|  |     58 | \endisadelimproof
 | 
|  |     59 | %
 | 
|  |     60 | \isadelimtheory
 | 
|  |     61 | %
 | 
|  |     62 | \endisadelimtheory
 | 
|  |     63 | %
 | 
|  |     64 | \isatagtheory
 | 
|  |     65 | %
 | 
|  |     66 | \endisatagtheory
 | 
|  |     67 | {\isafoldtheory}%
 | 
|  |     68 | %
 | 
|  |     69 | \isadelimtheory
 | 
|  |     70 | %
 | 
|  |     71 | \endisadelimtheory
 | 
| 11866 |     72 | \end{isabellebody}%
 | 
| 9493 |     73 | %%% Local Variables:
 | 
|  |     74 | %%% mode: latex
 | 
|  |     75 | %%% TeX-master: "root"
 | 
|  |     76 | %%% End:
 |