9722
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
9924
|
3 |
\def\isabellecontext{Tree}%
|
17181
|
4 |
\isamarkupfalse%
|
17056
|
5 |
%
|
|
6 |
\isadelimtheory
|
|
7 |
%
|
|
8 |
\endisadelimtheory
|
|
9 |
%
|
|
10 |
\isatagtheory
|
|
11 |
%
|
|
12 |
\endisatagtheory
|
|
13 |
{\isafoldtheory}%
|
|
14 |
%
|
|
15 |
\isadelimtheory
|
|
16 |
%
|
|
17 |
\endisadelimtheory
|
8749
|
18 |
%
|
|
19 |
\begin{isamarkuptext}%
|
|
20 |
\noindent
|
11456
|
21 |
Define the datatype of \rmindex{binary trees}:%
|
8749
|
22 |
\end{isamarkuptext}%
|
17175
|
23 |
\isamarkuptrue%
|
|
24 |
\isacommand{datatype}\isamarkupfalse%
|
17181
|
25 |
\ {\isacharprime}a\ tree\ {\isacharequal}\ Tip\ {\isacharbar}\ Node\ {\isachardoublequoteopen}{\isacharprime}a\ tree{\isachardoublequoteclose}\ {\isacharprime}a\ {\isachardoublequoteopen}{\isacharprime}a\ tree{\isachardoublequoteclose}%
|
8749
|
26 |
\begin{isamarkuptext}%
|
|
27 |
\noindent
|
11456
|
28 |
Define a function \isa{mirror} that mirrors a binary tree
|
10795
|
29 |
by swapping subtrees recursively. Prove%
|
8749
|
30 |
\end{isamarkuptext}%
|
17175
|
31 |
\isamarkuptrue%
|
|
32 |
\isacommand{lemma}\isamarkupfalse%
|
|
33 |
\ mirror{\isacharunderscore}mirror{\isacharcolon}\ {\isachardoublequoteopen}mirror{\isacharparenleft}mirror\ t{\isacharparenright}\ {\isacharequal}\ t{\isachardoublequoteclose}%
|
17056
|
34 |
\isadelimproof
|
|
35 |
%
|
|
36 |
\endisadelimproof
|
|
37 |
%
|
|
38 |
\isatagproof
|
|
39 |
%
|
|
40 |
\endisatagproof
|
|
41 |
{\isafoldproof}%
|
|
42 |
%
|
|
43 |
\isadelimproof
|
|
44 |
%
|
|
45 |
\endisadelimproof
|
11866
|
46 |
%
|
9493
|
47 |
\begin{isamarkuptext}%
|
|
48 |
\noindent
|
|
49 |
Define a function \isa{flatten} that flattens a tree into a list
|
|
50 |
by traversing it in infix order. Prove%
|
|
51 |
\end{isamarkuptext}%
|
17175
|
52 |
\isamarkuptrue%
|
|
53 |
\isacommand{lemma}\isamarkupfalse%
|
|
54 |
\ {\isachardoublequoteopen}flatten{\isacharparenleft}mirror\ t{\isacharparenright}\ {\isacharequal}\ rev{\isacharparenleft}flatten\ t{\isacharparenright}{\isachardoublequoteclose}%
|
17056
|
55 |
\isadelimproof
|
|
56 |
%
|
|
57 |
\endisadelimproof
|
|
58 |
%
|
|
59 |
\isatagproof
|
|
60 |
%
|
|
61 |
\endisatagproof
|
|
62 |
{\isafoldproof}%
|
|
63 |
%
|
|
64 |
\isadelimproof
|
|
65 |
%
|
|
66 |
\endisadelimproof
|
|
67 |
%
|
|
68 |
\isadelimtheory
|
|
69 |
%
|
|
70 |
\endisadelimtheory
|
|
71 |
%
|
|
72 |
\isatagtheory
|
|
73 |
%
|
|
74 |
\endisatagtheory
|
|
75 |
{\isafoldtheory}%
|
|
76 |
%
|
|
77 |
\isadelimtheory
|
|
78 |
%
|
|
79 |
\endisadelimtheory
|
11866
|
80 |
\end{isabellebody}%
|
9145
|
81 |
%%% Local Variables:
|
|
82 |
%%% mode: latex
|
|
83 |
%%% TeX-master: "root"
|
|
84 |
%%% End:
|