| author | krauss | 
| Sun, 16 Jun 2013 01:39:00 +0200 | |
| changeset 52383 | 71df93ff010d | 
| parent 51287 | 8799eadf61fb | 
| child 53376 | 1d4a46f1fced | 
| permissions | -rw-r--r-- | 
| 15136 | 1 | theory ToyList | 
| 26729 | 2 | imports Datatype | 
| 15136 | 3 | begin | 
| 8745 | 4 | |
| 48966 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 5 | (*<*) | 
| 51287 | 6 | ML {*  (* FIXME somewhat non-standard, fragile *)
 | 
| 48966 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 7 | let | 
| 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 8 | val texts = | 
| 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 9 |       map (File.read o Path.append (Thy_Load.master_directory @{theory}) o Path.explode)
 | 
| 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 10 | ["ToyList1", "ToyList2"]; | 
| 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 11 | val trs = Outer_Syntax.parse Position.start (implode texts); | 
| 51287 | 12 | val end_state = fold (Toplevel.command_exception false) trs Toplevel.toplevel; | 
| 13 |   in @{assert} (Toplevel.is_toplevel end_state) end;
 | |
| 48966 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 14 | *} | 
| 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 15 | (*>*) | 
| 
6e15de7dd871
more standard document preparation within session context: avoid clashes with generated .tex files, even on case-insensible file-system;
 wenzelm parents: 
38432diff
changeset | 16 | |
| 8745 | 17 | text{*\noindent
 | 
| 26729 | 18 | HOL already has a predefined theory of lists called @{text List} ---
 | 
| 19 | @{text ToyList} is merely a small fragment of it chosen as an example. In
 | |
| 8745 | 20 | contrast to what is recommended in \S\ref{sec:Basic:Theories},
 | 
| 26729 | 21 | @{text ToyList} is not based on @{text Main} but on @{text Datatype}, a
 | 
| 8745 | 22 | theory that contains pretty much everything but lists, thus avoiding | 
| 23 | ambiguities caused by defining lists twice. | |
| 24 | *} | |
| 25 | ||
| 26 | datatype 'a list = Nil                          ("[]")
 | |
| 27 | | Cons 'a "'a list" (infixr "#" 65); | |
| 28 | ||
| 29 | text{*\noindent
 | |
| 12327 | 30 | The datatype\index{datatype@\isacommand {datatype} (command)}
 | 
| 31 | \tydx{list} introduces two
 | |
| 11428 | 32 | constructors \cdx{Nil} and \cdx{Cons}, the
 | 
| 9541 | 33 | empty~list and the operator that adds an element to the front of a list. For | 
| 9792 | 34 | example, the term \isa{Cons True (Cons False Nil)} is a value of
 | 
| 35 | type @{typ"bool list"}, namely the list with the elements @{term"True"} and
 | |
| 11450 | 36 | @{term"False"}. Because this notation quickly becomes unwieldy, the
 | 
| 8745 | 37 | datatype declaration is annotated with an alternative syntax: instead of | 
| 9792 | 38 | @{term[source]Nil} and \isa{Cons x xs} we can write
 | 
| 15364 | 39 | @{term"[]"}\index{$HOL2list@\isa{[]}|bold} and
 | 
| 40 | @{term"x # xs"}\index{$HOL2list@\isa{\#}|bold}. In fact, this
 | |
| 11450 | 41 | alternative syntax is the familiar one.  Thus the list \isa{Cons True
 | 
| 9541 | 42 | (Cons False Nil)} becomes @{term"True # False # []"}. The annotation
 | 
| 11428 | 43 | \isacommand{infixr}\index{infixr@\isacommand{infixr} (annotation)} 
 | 
| 44 | means that @{text"#"} associates to
 | |
| 11450 | 45 | the right: the term @{term"x # y # z"} is read as @{text"x # (y # z)"}
 | 
| 9792 | 46 | and not as @{text"(x # y) # z"}.
 | 
| 10971 | 47 | The @{text 65} is the priority of the infix @{text"#"}.
 | 
| 8745 | 48 | |
| 49 | \begin{warn}
 | |
| 13191 | 50 | Syntax annotations can be powerful, but they are difficult to master and | 
| 11456 | 51 | are never necessary. You | 
| 9792 | 52 |   could drop them from theory @{text"ToyList"} and go back to the identifiers
 | 
| 27015 | 53 |   @{term[source]Nil} and @{term[source]Cons}.  Novices should avoid using
 | 
| 10795 | 54 | syntax annotations in their own theories. | 
| 8745 | 55 | \end{warn}
 | 
| 27015 | 56 | Next, two functions @{text"app"} and \cdx{rev} are defined recursively,
 | 
| 57 | in this order, because Isabelle insists on definition before use: | |
| 8745 | 58 | *} | 
| 59 | ||
| 27015 | 60 | primrec app :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infixr "@" 65) where | 
| 61 | "[] @ ys = ys" | | |
| 62 | "(x # xs) @ ys = x # (xs @ ys)" | |
| 63 | ||
| 64 | primrec rev :: "'a list \<Rightarrow> 'a list" where | |
| 65 | "rev [] = []" | | |
| 66 | "rev (x # xs) = (rev xs) @ (x # [])" | |
| 8745 | 67 | |
| 27015 | 68 | text{*\noindent
 | 
| 69 | Each function definition is of the form | |
| 70 | \begin{center}
 | |
| 71 | \isacommand{primrec} \textit{name} @{text"::"} \textit{type} \textit{(optional syntax)} \isakeyword{where} \textit{equations}
 | |
| 72 | \end{center}
 | |
| 73 | The equations must be separated by @{text"|"}.
 | |
| 74 | % | |
| 75 | Function @{text"app"} is annotated with concrete syntax. Instead of the
 | |
| 10790 | 76 | prefix syntax @{text"app xs ys"} the infix
 | 
| 15364 | 77 | @{term"xs @ ys"}\index{$HOL2list@\isa{\at}|bold} becomes the preferred
 | 
| 27015 | 78 | form. | 
| 8745 | 79 | |
| 27015 | 80 | \index{*rev (constant)|(}\index{append function|(}
 | 
| 10790 | 81 | The equations for @{text"app"} and @{term"rev"} hardly need comments:
 | 
| 82 | @{text"app"} appends two lists and @{term"rev"} reverses a list.  The
 | |
| 11428 | 83 | keyword \commdx{primrec} indicates that the recursion is
 | 
| 10790 | 84 | of a particularly primitive kind where each recursive call peels off a datatype | 
| 8771 | 85 | constructor from one of the arguments. Thus the | 
| 10654 | 86 | recursion always terminates, i.e.\ the function is \textbf{total}.
 | 
| 11428 | 87 | \index{functions!total}
 | 
| 8745 | 88 | |
| 89 | The termination requirement is absolutely essential in HOL, a logic of total | |
| 90 | functions. If we were to drop it, inconsistencies would quickly arise: the | |
| 91 | ``definition'' $f(n) = f(n)+1$ immediately leads to $0 = 1$ by subtracting | |
| 92 | $f(n)$ on both sides. | |
| 93 | % However, this is a subtle issue that we cannot discuss here further. | |
| 94 | ||
| 95 | \begin{warn}
 | |
| 11456 | 96 | As we have indicated, the requirement for total functions is an essential characteristic of HOL\@. It is only | 
| 8745 | 97 | because of totality that reasoning in HOL is comparatively easy. More | 
| 11456 | 98 | generally, the philosophy in HOL is to refrain from asserting arbitrary axioms (such as | 
| 8745 | 99 | function definitions whose totality has not been proved) because they | 
| 100 | quickly lead to inconsistencies. Instead, fixed constructs for introducing | |
| 101 |   types and functions are offered (such as \isacommand{datatype} and
 | |
| 102 |   \isacommand{primrec}) which are guaranteed to preserve consistency.
 | |
| 103 | \end{warn}
 | |
| 104 | ||
| 11456 | 105 | \index{syntax}%
 | 
| 8745 | 106 | A remark about syntax. The textual definition of a theory follows a fixed | 
| 10971 | 107 | syntax with keywords like \isacommand{datatype} and \isacommand{end}.
 | 
| 108 | % (see Fig.~\ref{fig:keywords} in Appendix~\ref{sec:Appendix} for a full list).
 | |
| 8745 | 109 | Embedded in this syntax are the types and formulae of HOL, whose syntax is | 
| 12631 | 110 | extensible (see \S\ref{sec:concrete-syntax}), e.g.\ by new user-defined infix operators.
 | 
| 10971 | 111 | To distinguish the two levels, everything | 
| 8745 | 112 | HOL-specific (terms and types) should be enclosed in | 
| 113 | \texttt{"}\dots\texttt{"}. 
 | |
| 114 | To lessen this burden, quotation marks around a single identifier can be | |
| 27015 | 115 | dropped, unless the identifier happens to be a keyword, for example | 
| 116 | \isa{"end"}.
 | |
| 8745 | 117 | When Isabelle prints a syntax error message, it refers to the HOL syntax as | 
| 11456 | 118 | the \textbf{inner syntax} and the enclosing theory language as the \textbf{outer syntax}.
 | 
| 8745 | 119 | |
| 38430 
254a021ed66e
tuned text about "value" and added note on comments.
 nipkow parents: 
27015diff
changeset | 120 | Comments\index{comment} must be in enclosed in \texttt{(* }and\texttt{ *)}.
 | 
| 
254a021ed66e
tuned text about "value" and added note on comments.
 nipkow parents: 
27015diff
changeset | 121 | |
| 25342 | 122 | \section{Evaluation}
 | 
| 123 | \index{evaluation}
 | |
| 124 | ||
| 125 | Assuming you have processed the declarations and definitions of | |
| 126 | \texttt{ToyList} presented so far, you may want to test your
 | |
| 127 | functions by running them. For example, what is the value of | |
| 128 | @{term"rev(True#False#[])"}? Command
 | |
| 129 | *} | |
| 130 | ||
| 131 | value "rev (True # False # [])" | |
| 132 | ||
| 133 | text{* \noindent yields the correct result @{term"False # True # []"}.
 | |
| 134 | But we can go beyond mere functional programming and evaluate terms with | |
| 135 | variables in them, executing functions symbolically: *} | |
| 136 | ||
| 38430 
254a021ed66e
tuned text about "value" and added note on comments.
 nipkow parents: 
27015diff
changeset | 137 | value "rev (a # b # c # [])" | 
| 25342 | 138 | |
| 38432 
439f50a241c1
Using type real does not require a separate logic now.
 nipkow parents: 
38430diff
changeset | 139 | text{*\noindent yields @{term"c # b # a # []"}.
 | 
| 
439f50a241c1
Using type real does not require a separate logic now.
 nipkow parents: 
38430diff
changeset | 140 | |
| 10885 | 141 | \section{An Introductory Proof}
 | 
| 8745 | 142 | \label{sec:intro-proof}
 | 
| 143 | ||
| 25342 | 144 | Having convinced ourselves (as well as one can by testing) that our | 
| 145 | definitions capture our intentions, we are ready to prove a few simple | |
| 16360 | 146 | theorems. This will illustrate not just the basic proof commands but | 
| 147 | also the typical proof process. | |
| 8745 | 148 | |
| 11457 | 149 | \subsubsection*{Main Goal.}
 | 
| 8745 | 150 | |
| 151 | Our goal is to show that reversing a list twice produces the original | |
| 11456 | 152 | list. | 
| 8745 | 153 | *} | 
| 154 | ||
| 155 | theorem rev_rev [simp]: "rev(rev xs) = xs"; | |
| 156 | ||
| 11428 | 157 | txt{*\index{theorem@\isacommand {theorem} (command)|bold}%
 | 
| 10795 | 158 | \noindent | 
| 11456 | 159 | This \isacommand{theorem} command does several things:
 | 
| 8745 | 160 | \begin{itemize}
 | 
| 161 | \item | |
| 11456 | 162 | It establishes a new theorem to be proved, namely @{prop"rev(rev xs) = xs"}.
 | 
| 8745 | 163 | \item | 
| 11456 | 164 | It gives that theorem the name @{text"rev_rev"}, for later reference.
 | 
| 8745 | 165 | \item | 
| 11456 | 166 | It tells Isabelle (via the bracketed attribute \attrdx{simp}) to take the eventual theorem as a simplification rule: future proofs involving
 | 
| 9792 | 167 | simplification will replace occurrences of @{term"rev(rev xs)"} by
 | 
| 168 | @{term"xs"}.
 | |
| 11457 | 169 | \end{itemize}
 | 
| 8745 | 170 | The name and the simplification attribute are optional. | 
| 12332 | 171 | Isabelle's response is to print the initial proof state consisting | 
| 172 | of some header information (like how many subgoals there are) followed by | |
| 13868 | 173 | @{subgoals[display,indent=0]}
 | 
| 12332 | 174 | For compactness reasons we omit the header in this tutorial. | 
| 175 | Until we have finished a proof, the \rmindex{proof state} proper
 | |
| 176 | always looks like this: | |
| 9723 | 177 | \begin{isabelle}
 | 
| 8745 | 178 | ~1.~$G\sb{1}$\isanewline
 | 
| 179 | ~~\vdots~~\isanewline | |
| 180 | ~$n$.~$G\sb{n}$
 | |
| 9723 | 181 | \end{isabelle}
 | 
| 13868 | 182 | The numbered lines contain the subgoals $G\sb{1}$, \dots, $G\sb{n}$
 | 
| 183 | that we need to prove to establish the main goal.\index{subgoals}
 | |
| 184 | Initially there is only one subgoal, which is identical with the | |
| 185 | main goal. (If you always want to see the main goal as well, | |
| 186 | set the flag \isa{Proof.show_main_goal}\index{*show_main_goal (flag)}
 | |
| 187 | --- this flag used to be set by default.) | |
| 8745 | 188 | |
| 9792 | 189 | Let us now get back to @{prop"rev(rev xs) = xs"}. Properties of recursively
 | 
| 8745 | 190 | defined functions are best established by induction. In this case there is | 
| 11428 | 191 | nothing obvious except induction on @{term"xs"}:
 | 
| 8745 | 192 | *} | 
| 193 | ||
| 194 | apply(induct_tac xs); | |
| 195 | ||
| 11428 | 196 | txt{*\noindent\index{*induct_tac (method)}%
 | 
| 9792 | 197 | This tells Isabelle to perform induction on variable @{term"xs"}. The suffix
 | 
| 11428 | 198 | @{term"tac"} stands for \textbf{tactic},\index{tactics}
 | 
| 199 | a synonym for ``theorem proving function''. | |
| 8745 | 200 | By default, induction acts on the first subgoal. The new proof state contains | 
| 9792 | 201 | two subgoals, namely the base case (@{term[source]Nil}) and the induction step
 | 
| 202 | (@{term[source]Cons}):
 | |
| 10971 | 203 | @{subgoals[display,indent=0,margin=65]}
 | 
| 8745 | 204 | |
| 11456 | 205 | The induction step is an example of the general format of a subgoal:\index{subgoals}
 | 
| 9723 | 206 | \begin{isabelle}
 | 
| 12327 | 207 | ~$i$.~{\isasymAnd}$x\sb{1}$~\dots$x\sb{n}$.~{\it assumptions}~{\isasymLongrightarrow}~{\it conclusion}
 | 
| 10328 | 208 | \end{isabelle}\index{$IsaAnd@\isasymAnd|bold}
 | 
| 8745 | 209 | The prefix of bound variables \isasymAnd$x\sb{1}$~\dots~$x\sb{n}$ can be
 | 
| 210 | ignored most of the time, or simply treated as a list of variables local to | |
| 10302 | 211 | this subgoal. Their deeper significance is explained in Chapter~\ref{chap:rules}.
 | 
| 11456 | 212 | The {\it assumptions}\index{assumptions!of subgoal}
 | 
| 213 | are the local assumptions for this subgoal and {\it
 | |
| 214 |   conclusion}\index{conclusion!of subgoal} is the actual proposition to be proved. 
 | |
| 215 | Typical proof steps | |
| 216 | that add new assumptions are induction and case distinction. In our example | |
| 9541 | 217 | the only assumption is the induction hypothesis @{term"rev (rev list) =
 | 
| 9792 | 218 |   list"}, where @{term"list"} is a variable name chosen by Isabelle. If there
 | 
| 8745 | 219 | are multiple assumptions, they are enclosed in the bracket pair | 
| 220 | \indexboldpos{\isasymlbrakk}{$Isabrl} and
 | |
| 221 | \indexboldpos{\isasymrbrakk}{$Isabrr} and separated by semicolons.
 | |
| 222 | ||
| 223 | Let us try to solve both goals automatically: | |
| 224 | *} | |
| 225 | ||
| 226 | apply(auto); | |
| 227 | ||
| 228 | txt{*\noindent
 | |
| 229 | This command tells Isabelle to apply a proof strategy called | |
| 9792 | 230 | @{text"auto"} to all subgoals. Essentially, @{text"auto"} tries to
 | 
| 10978 | 231 | simplify the subgoals. In our case, subgoal~1 is solved completely (thanks | 
| 9792 | 232 | to the equation @{prop"rev [] = []"}) and disappears; the simplified version
 | 
| 8745 | 233 | of subgoal~2 becomes the new subgoal~1: | 
| 10971 | 234 | @{subgoals[display,indent=0,margin=70]}
 | 
| 8745 | 235 | In order to simplify this subgoal further, a lemma suggests itself. | 
| 236 | *} | |
| 237 | (*<*) | |
| 238 | oops | |
| 239 | (*>*) | |
| 240 | ||
| 11428 | 241 | subsubsection{*First Lemma*}
 | 
| 9723 | 242 | |
| 8745 | 243 | text{*
 | 
| 11428 | 244 | \indexbold{abandoning a proof}\indexbold{proofs!abandoning}
 | 
| 245 | After abandoning the above proof attempt (at the shell level type | |
| 246 | \commdx{oops}) we start a new proof:
 | |
| 8745 | 247 | *} | 
| 248 | ||
| 249 | lemma rev_app [simp]: "rev(xs @ ys) = (rev ys) @ (rev xs)"; | |
| 250 | ||
| 11428 | 251 | txt{*\noindent The keywords \commdx{theorem} and
 | 
| 252 | \commdx{lemma} are interchangeable and merely indicate
 | |
| 10971 | 253 | the importance we attach to a proposition. Therefore we use the words | 
| 11428 | 254 | \emph{theorem} and \emph{lemma} pretty much interchangeably, too.
 | 
| 8745 | 255 | |
| 9792 | 256 | There are two variables that we could induct on: @{term"xs"} and
 | 
| 257 | @{term"ys"}. Because @{text"@"} is defined by recursion on
 | |
| 258 | the first argument, @{term"xs"} is the correct one:
 | |
| 8745 | 259 | *} | 
| 260 | ||
| 261 | apply(induct_tac xs); | |
| 262 | ||
| 263 | txt{*\noindent
 | |
| 264 | This time not even the base case is solved automatically: | |
| 265 | *} | |
| 266 | ||
| 267 | apply(auto); | |
| 268 | ||
| 269 | txt{*
 | |
| 10362 | 270 | @{subgoals[display,indent=0,goals_limit=1]}
 | 
| 271 | Again, we need to abandon this proof attempt and prove another simple lemma | |
| 272 | first. In the future the step of abandoning an incomplete proof before | |
| 273 | embarking on the proof of a lemma usually remains implicit. | |
| 8745 | 274 | *} | 
| 275 | (*<*) | |
| 276 | oops | |
| 277 | (*>*) | |
| 278 | ||
| 11428 | 279 | subsubsection{*Second Lemma*}
 | 
| 9723 | 280 | |
| 8745 | 281 | text{*
 | 
| 11456 | 282 | We again try the canonical proof procedure: | 
| 8745 | 283 | *} | 
| 284 | ||
| 285 | lemma app_Nil2 [simp]: "xs @ [] = xs"; | |
| 286 | apply(induct_tac xs); | |
| 287 | apply(auto); | |
| 288 | ||
| 289 | txt{*
 | |
| 290 | \noindent | |
| 11456 | 291 | It works, yielding the desired message @{text"No subgoals!"}:
 | 
| 10362 | 292 | @{goals[display,indent=0]}
 | 
| 8745 | 293 | We still need to confirm that the proof is now finished: | 
| 294 | *} | |
| 295 | ||
| 10171 | 296 | done | 
| 8745 | 297 | |
| 11428 | 298 | text{*\noindent
 | 
| 299 | As a result of that final \commdx{done}, Isabelle associates the lemma just proved
 | |
| 10171 | 300 | with its name. In this tutorial, we sometimes omit to show that final \isacommand{done}
 | 
| 301 | if it is obvious from the context that the proof is finished. | |
| 302 | ||
| 303 | % Instead of \isacommand{apply} followed by a dot, you can simply write
 | |
| 304 | % \isacommand{by}\indexbold{by}, which we do most of the time.
 | |
| 10971 | 305 | Notice that in lemma @{thm[source]app_Nil2},
 | 
| 306 | as printed out after the final \isacommand{done}, the free variable @{term"xs"} has been
 | |
| 9792 | 307 | replaced by the unknown @{text"?xs"}, just as explained in
 | 
| 308 | \S\ref{sec:variables}.
 | |
| 8745 | 309 | |
| 310 | Going back to the proof of the first lemma | |
| 311 | *} | |
| 312 | ||
| 313 | lemma rev_app [simp]: "rev(xs @ ys) = (rev ys) @ (rev xs)"; | |
| 314 | apply(induct_tac xs); | |
| 315 | apply(auto); | |
| 316 | ||
| 317 | txt{*
 | |
| 318 | \noindent | |
| 9792 | 319 | we find that this time @{text"auto"} solves the base case, but the
 | 
| 8745 | 320 | induction step merely simplifies to | 
| 10362 | 321 | @{subgoals[display,indent=0,goals_limit=1]}
 | 
| 9792 | 322 | Now we need to remember that @{text"@"} associates to the right, and that
 | 
| 323 | @{text"#"} and @{text"@"} have the same priority (namely the @{text"65"}
 | |
| 8745 | 324 | in their \isacommand{infixr} annotation). Thus the conclusion really is
 | 
| 9723 | 325 | \begin{isabelle}
 | 
| 9792 | 326 | ~~~~~(rev~ys~@~rev~list)~@~(a~\#~[])~=~rev~ys~@~(rev~list~@~(a~\#~[])) | 
| 9723 | 327 | \end{isabelle}
 | 
| 9792 | 328 | and the missing lemma is associativity of @{text"@"}.
 | 
| 9723 | 329 | *} | 
| 330 | (*<*)oops(*>*) | |
| 8745 | 331 | |
| 11456 | 332 | subsubsection{*Third Lemma*}
 | 
| 8745 | 333 | |
| 9723 | 334 | text{*
 | 
| 11456 | 335 | Abandoning the previous attempt, the canonical proof procedure | 
| 336 | succeeds without further ado. | |
| 8745 | 337 | *} | 
| 338 | ||
| 339 | lemma app_assoc [simp]: "(xs @ ys) @ zs = xs @ (ys @ zs)"; | |
| 340 | apply(induct_tac xs); | |
| 10171 | 341 | apply(auto); | 
| 342 | done | |
| 8745 | 343 | |
| 344 | text{*
 | |
| 345 | \noindent | |
| 11456 | 346 | Now we can prove the first lemma: | 
| 8745 | 347 | *} | 
| 348 | ||
| 349 | lemma rev_app [simp]: "rev(xs @ ys) = (rev ys) @ (rev xs)"; | |
| 350 | apply(induct_tac xs); | |
| 10171 | 351 | apply(auto); | 
| 352 | done | |
| 8745 | 353 | |
| 354 | text{*\noindent
 | |
| 11456 | 355 | Finally, we prove our main theorem: | 
| 8745 | 356 | *} | 
| 357 | ||
| 358 | theorem rev_rev [simp]: "rev(rev xs) = xs"; | |
| 359 | apply(induct_tac xs); | |
| 10171 | 360 | apply(auto); | 
| 361 | done | |
| 8745 | 362 | |
| 363 | text{*\noindent
 | |
| 11456 | 364 | The final \commdx{end} tells Isabelle to close the current theory because
 | 
| 365 | we are finished with its development:% | |
| 366 | \index{*rev (constant)|)}\index{append function|)}
 | |
| 8745 | 367 | *} | 
| 368 | ||
| 369 | end |