doc-src/TutorialI/ToyList/document/ToyList.tex
author wenzelm
Sun, 17 Apr 2005 19:39:11 +0200
changeset 15759 144c9f9a8ade
parent 15614 b098158a3f39
child 16069 3f2a9f400168
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9722
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
     1
%
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
     2
\begin{isabellebody}%
9924
3370f6aa3200 updated;
wenzelm
parents: 9792
diff changeset
     3
\def\isabellecontext{ToyList}%
15136
1275417e3930 Adapted text to new theory header syntax.
nipkow
parents: 13978
diff changeset
     4
\isacommand{theory}\ ToyList\isanewline
15141
a95c2ff210ba import -> imports
nipkow
parents: 15136
diff changeset
     5
\isakeyword{imports}\ PreList\isanewline
15136
1275417e3930 Adapted text to new theory header syntax.
nipkow
parents: 13978
diff changeset
     6
\isakeyword{begin}\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
     7
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
     8
\begin{isamarkuptext}%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
     9
\noindent
8771
026f37a86ea7 *** empty log message ***
nipkow
parents: 8749
diff changeset
    10
HOL already has a predefined theory of lists called \isa{List} ---
026f37a86ea7 *** empty log message ***
nipkow
parents: 8749
diff changeset
    11
\isa{ToyList} is merely a small fragment of it chosen as an example. In
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    12
contrast to what is recommended in \S\ref{sec:Basic:Theories},
8771
026f37a86ea7 *** empty log message ***
nipkow
parents: 8749
diff changeset
    13
\isa{ToyList} is not based on \isa{Main} but on \isa{PreList}, a
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    14
theory that contains pretty much everything but lists, thus avoiding
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    15
ambiguities caused by defining lists twice.%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    16
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    17
\isamarkuptrue%
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
    18
\isacommand{datatype}\ {\isacharprime}a\ list\ {\isacharequal}\ Nil\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isachardoublequote}{\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}{\isacharparenright}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    19
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ Cons\ {\isacharprime}a\ {\isachardoublequote}{\isacharprime}a\ list{\isachardoublequote}\ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}\isakeyword{infixr}\ {\isachardoublequote}{\isacharhash}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{5}}{\isacharparenright}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    20
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    21
\begin{isamarkuptext}%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    22
\noindent
12327
5a4d78204492 *** empty log message ***
nipkow
parents: 11866
diff changeset
    23
The datatype\index{datatype@\isacommand {datatype} (command)}
5a4d78204492 *** empty log message ***
nipkow
parents: 11866
diff changeset
    24
\tydx{list} introduces two
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
    25
constructors \cdx{Nil} and \cdx{Cons}, the
9541
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9494
diff changeset
    26
empty~list and the operator that adds an element to the front of a list. For
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
    27
example, the term \isa{Cons True (Cons False Nil)} is a value of
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
    28
type \isa{bool\ list}, namely the list with the elements \isa{True} and
11450
1b02a6c4032f tweaks and indexing
paulson
parents: 11428
diff changeset
    29
\isa{False}. Because this notation quickly becomes unwieldy, the
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    30
datatype declaration is annotated with an alternative syntax: instead of
9541
d17c0b34d5c8 *** empty log message ***
nipkow
parents: 9494
diff changeset
    31
\isa{Nil} and \isa{Cons x xs} we can write
15364
0c3891c3528f *** empty log message ***
nipkow
parents: 15141
diff changeset
    32
\isa{{\isacharbrackleft}{\isacharbrackright}}\index{$HOL2list@\isa{[]}|bold} and
0c3891c3528f *** empty log message ***
nipkow
parents: 15141
diff changeset
    33
\isa{x\ {\isacharhash}\ xs}\index{$HOL2list@\isa{\#}|bold}. In fact, this
11450
1b02a6c4032f tweaks and indexing
paulson
parents: 11428
diff changeset
    34
alternative syntax is the familiar one.  Thus the list \isa{Cons True
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
    35
(Cons False Nil)} becomes \isa{True\ {\isacharhash}\ False\ {\isacharhash}\ {\isacharbrackleft}{\isacharbrackright}}. The annotation
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
    36
\isacommand{infixr}\index{infixr@\isacommand{infixr} (annotation)} 
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
    37
means that \isa{{\isacharhash}} associates to
11450
1b02a6c4032f tweaks and indexing
paulson
parents: 11428
diff changeset
    38
the right: the term \isa{x\ {\isacharhash}\ y\ {\isacharhash}\ z} is read as \isa{x\ {\isacharhash}\ {\isacharparenleft}y\ {\isacharhash}\ z{\isacharparenright}}
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
    39
and not as \isa{{\isacharparenleft}x\ {\isacharhash}\ y{\isacharparenright}\ {\isacharhash}\ z}.
10971
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
    40
The \isa{{\isadigit{6}}{\isadigit{5}}} is the priority of the infix \isa{{\isacharhash}}.
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    41
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    42
\begin{warn}
13191
05a9929ee10e *** empty log message ***
nipkow
parents: 12627
diff changeset
    43
  Syntax annotations can be powerful, but they are difficult to master and 
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
    44
  are never necessary.  You
8771
026f37a86ea7 *** empty log message ***
nipkow
parents: 8749
diff changeset
    45
  could drop them from theory \isa{ToyList} and go back to the identifiers
10795
9e888d60d3e5 minor edits to Chapters 1-3
paulson
parents: 10790
diff changeset
    46
  \isa{Nil} and \isa{Cons}.
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
    47
  Novices should avoid using
10795
9e888d60d3e5 minor edits to Chapters 1-3
paulson
parents: 10790
diff changeset
    48
  syntax annotations in their own theories.
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    49
\end{warn}
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
    50
Next, two functions \isa{app} and \cdx{rev} are declared:%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    51
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    52
\isamarkuptrue%
10187
0376cccd9118 *** empty log message ***
nipkow
parents: 10171
diff changeset
    53
\isacommand{consts}\ app\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a\ list{\isachardoublequote}\ \ \ {\isacharparenleft}\isakeyword{infixr}\ {\isachardoublequote}{\isacharat}{\isachardoublequote}\ {\isadigit{6}}{\isadigit{5}}{\isacharparenright}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    54
\ \ \ \ \ \ \ rev\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a\ list{\isachardoublequote}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    55
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    56
\begin{isamarkuptext}%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    57
\noindent
10971
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
    58
In contrast to many functional programming languages,
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
    59
Isabelle insists on explicit declarations of all functions
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
    60
(keyword \commdx{consts}).  Apart from the declaration-before-use
10971
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
    61
restriction, the order of items in a theory file is unconstrained. Function
10790
520dd8696927 *** empty log message ***
nipkow
parents: 10654
diff changeset
    62
\isa{app} is annotated with concrete syntax too. Instead of the
520dd8696927 *** empty log message ***
nipkow
parents: 10654
diff changeset
    63
prefix syntax \isa{app\ xs\ ys} the infix
15364
0c3891c3528f *** empty log message ***
nipkow
parents: 15141
diff changeset
    64
\isa{xs\ {\isacharat}\ ys}\index{$HOL2list@\isa{\at}|bold} becomes the preferred
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    65
form. Both functions are defined recursively:%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    66
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    67
\isamarkuptrue%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    68
\isacommand{primrec}\isanewline
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
    69
{\isachardoublequote}{\isacharbrackleft}{\isacharbrackright}\ {\isacharat}\ ys\ \ \ \ \ \ \ {\isacharequal}\ ys{\isachardoublequote}\isanewline
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
    70
{\isachardoublequote}{\isacharparenleft}x\ {\isacharhash}\ xs{\isacharparenright}\ {\isacharat}\ ys\ {\isacharequal}\ x\ {\isacharhash}\ {\isacharparenleft}xs\ {\isacharat}\ ys{\isacharparenright}{\isachardoublequote}\isanewline
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    71
\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    72
\isamarkupfalse%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    73
\isacommand{primrec}\isanewline
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
    74
{\isachardoublequote}rev\ {\isacharbrackleft}{\isacharbrackright}\ \ \ \ \ \ \ \ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    75
{\isachardoublequote}rev\ {\isacharparenleft}x\ {\isacharhash}\ xs{\isacharparenright}\ \ {\isacharequal}\ {\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharat}\ {\isacharparenleft}x\ {\isacharhash}\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
    76
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    77
\begin{isamarkuptext}%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
    78
\noindent\index{*rev (constant)|(}\index{append function|(}
10790
520dd8696927 *** empty log message ***
nipkow
parents: 10654
diff changeset
    79
The equations for \isa{app} and \isa{rev} hardly need comments:
520dd8696927 *** empty log message ***
nipkow
parents: 10654
diff changeset
    80
\isa{app} appends two lists and \isa{rev} reverses a list.  The
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
    81
keyword \commdx{primrec} indicates that the recursion is
10790
520dd8696927 *** empty log message ***
nipkow
parents: 10654
diff changeset
    82
of a particularly primitive kind where each recursive call peels off a datatype
8771
026f37a86ea7 *** empty log message ***
nipkow
parents: 8749
diff changeset
    83
constructor from one of the arguments.  Thus the
10654
458068404143 *** empty log message ***
nipkow
parents: 10395
diff changeset
    84
recursion always terminates, i.e.\ the function is \textbf{total}.
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
    85
\index{functions!total}
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    86
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    87
The termination requirement is absolutely essential in HOL, a logic of total
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    88
functions. If we were to drop it, inconsistencies would quickly arise: the
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    89
``definition'' $f(n) = f(n)+1$ immediately leads to $0 = 1$ by subtracting
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    90
$f(n)$ on both sides.
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    91
% However, this is a subtle issue that we cannot discuss here further.
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    92
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    93
\begin{warn}
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
    94
  As we have indicated, the requirement for total functions is an essential characteristic of HOL\@. It is only
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    95
  because of totality that reasoning in HOL is comparatively easy.  More
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
    96
  generally, the philosophy in HOL is to refrain from asserting arbitrary axioms (such as
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    97
  function definitions whose totality has not been proved) because they
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    98
  quickly lead to inconsistencies. Instead, fixed constructs for introducing
2665170f104a Adding generated files
nipkow
parents:
diff changeset
    99
  types and functions are offered (such as \isacommand{datatype} and
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   100
  \isacommand{primrec}) which are guaranteed to preserve consistency.
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   101
\end{warn}
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   102
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   103
\index{syntax}%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   104
A remark about syntax.  The textual definition of a theory follows a fixed
10971
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
   105
syntax with keywords like \isacommand{datatype} and \isacommand{end}.
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
   106
% (see Fig.~\ref{fig:keywords} in Appendix~\ref{sec:Appendix} for a full list).
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   107
Embedded in this syntax are the types and formulae of HOL, whose syntax is
12627
08eee994bf99 updated;
wenzelm
parents: 12332
diff changeset
   108
extensible (see \S\ref{sec:concrete-syntax}), e.g.\ by new user-defined infix operators.
10971
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
   109
To distinguish the two levels, everything
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   110
HOL-specific (terms and types) should be enclosed in
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   111
\texttt{"}\dots\texttt{"}. 
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   112
To lessen this burden, quotation marks around a single identifier can be
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   113
dropped, unless the identifier happens to be a keyword, as in%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   114
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   115
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   116
\isacommand{consts}\ {\isachardoublequote}end{\isachardoublequote}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequote}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   117
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   118
\begin{isamarkuptext}%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   119
\noindent
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   120
When Isabelle prints a syntax error message, it refers to the HOL syntax as
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   121
the \textbf{inner syntax} and the enclosing theory language as the \textbf{outer syntax}.
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   122
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   123
10878
b254d5ad6dd4 auto update
paulson
parents: 10795
diff changeset
   124
\section{An Introductory Proof}
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   125
\label{sec:intro-proof}
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   126
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   127
Assuming you have input the declarations and definitions of \texttt{ToyList}
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   128
presented so far, we are ready to prove a few simple theorems. This will
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   129
illustrate not just the basic proof commands but also the typical proof
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   130
process.
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   131
11457
279da0358aa9 additional revisions to chapters 1, 2
paulson
parents: 11456
diff changeset
   132
\subsubsection*{Main Goal.}
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   133
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   134
Our goal is to show that reversing a list twice produces the original
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   135
list.%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   136
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   137
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   138
\isacommand{theorem}\ rev{\isacharunderscore}rev\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}rev{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ xs{\isachardoublequote}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   139
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   140
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   141
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   142
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   143
\isamarkuptrue%
15614
b098158a3f39 auto update
paulson
parents: 15481
diff changeset
   144
\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   145
\isamarkupfalse%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   146
%
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
   147
\isamarkupsubsubsection{First Lemma%
10395
7ef380745743 updated;
wenzelm
parents: 10362
diff changeset
   148
}
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   149
\isamarkuptrue%
9723
a977245dfc8a *** empty log message ***
nipkow
parents: 9722
diff changeset
   150
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   151
\begin{isamarkuptext}%
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
   152
\indexbold{abandoning a proof}\indexbold{proofs!abandoning}
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
   153
After abandoning the above proof attempt (at the shell level type
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
   154
\commdx{oops}) we start a new proof:%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   155
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   156
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   157
\isacommand{lemma}\ rev{\isacharunderscore}app\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}rev{\isacharparenleft}xs\ {\isacharat}\ ys{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}rev\ ys{\isacharparenright}\ {\isacharat}\ {\isacharparenleft}rev\ xs{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   158
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   159
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   160
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   161
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   162
\isamarkuptrue%
15614
b098158a3f39 auto update
paulson
parents: 15481
diff changeset
   163
\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   164
\isamarkupfalse%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   165
%
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
   166
\isamarkupsubsubsection{Second Lemma%
10395
7ef380745743 updated;
wenzelm
parents: 10362
diff changeset
   167
}
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   168
\isamarkuptrue%
9723
a977245dfc8a *** empty log message ***
nipkow
parents: 9722
diff changeset
   169
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   170
\begin{isamarkuptext}%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   171
We again try the canonical proof procedure:%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   172
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   173
\isamarkuptrue%
10187
0376cccd9118 *** empty log message ***
nipkow
parents: 10171
diff changeset
   174
\isacommand{lemma}\ app{\isacharunderscore}Nil{\isadigit{2}}\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}xs\ {\isacharat}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharequal}\ xs{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   175
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   176
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   177
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   178
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   179
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   180
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   181
\begin{isamarkuptext}%
11428
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
   182
\noindent
332347b9b942 tidying the index
paulson
parents: 11216
diff changeset
   183
As a result of that final \commdx{done}, Isabelle associates the lemma just proved
10171
59d6633835fa *** empty log message ***
nipkow
parents: 9924
diff changeset
   184
with its name. In this tutorial, we sometimes omit to show that final \isacommand{done}
59d6633835fa *** empty log message ***
nipkow
parents: 9924
diff changeset
   185
if it is obvious from the context that the proof is finished.
59d6633835fa *** empty log message ***
nipkow
parents: 9924
diff changeset
   186
59d6633835fa *** empty log message ***
nipkow
parents: 9924
diff changeset
   187
% Instead of \isacommand{apply} followed by a dot, you can simply write
59d6633835fa *** empty log message ***
nipkow
parents: 9924
diff changeset
   188
% \isacommand{by}\indexbold{by}, which we do most of the time.
10971
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
   189
Notice that in lemma \isa{app{\isacharunderscore}Nil{\isadigit{2}}},
6852682eaf16 *** empty log message ***
nipkow
parents: 10950
diff changeset
   190
as printed out after the final \isacommand{done}, the free variable \isa{xs} has been
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   191
replaced by the unknown \isa{{\isacharquery}xs}, just as explained in
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   192
\S\ref{sec:variables}.
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   193
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   194
Going back to the proof of the first lemma%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   195
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   196
\isamarkuptrue%
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
   197
\isacommand{lemma}\ rev{\isacharunderscore}app\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}rev{\isacharparenleft}xs\ {\isacharat}\ ys{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}rev\ ys{\isacharparenright}\ {\isacharat}\ {\isacharparenleft}rev\ xs{\isacharparenright}{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   198
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   199
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   200
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   201
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   202
\isamarkupfalse%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   203
%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   204
\isamarkupsubsubsection{Third Lemma%
10395
7ef380745743 updated;
wenzelm
parents: 10362
diff changeset
   205
}
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   206
\isamarkuptrue%
9723
a977245dfc8a *** empty log message ***
nipkow
parents: 9722
diff changeset
   207
%
a977245dfc8a *** empty log message ***
nipkow
parents: 9722
diff changeset
   208
\begin{isamarkuptext}%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   209
Abandoning the previous attempt, the canonical proof procedure
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   210
succeeds without further ado.%
9723
a977245dfc8a *** empty log message ***
nipkow
parents: 9722
diff changeset
   211
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   212
\isamarkuptrue%
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
   213
\isacommand{lemma}\ app{\isacharunderscore}assoc\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}xs\ {\isacharat}\ ys{\isacharparenright}\ {\isacharat}\ zs\ {\isacharequal}\ xs\ {\isacharat}\ {\isacharparenleft}ys\ {\isacharat}\ zs{\isacharparenright}{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   214
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   215
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   216
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   217
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   218
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   219
\begin{isamarkuptext}%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   220
\noindent
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   221
Now we can prove the first lemma:%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   222
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   223
\isamarkuptrue%
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
   224
\isacommand{lemma}\ rev{\isacharunderscore}app\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}rev{\isacharparenleft}xs\ {\isacharat}\ ys{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}rev\ ys{\isacharparenright}\ {\isacharat}\ {\isacharparenleft}rev\ xs{\isacharparenright}{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   225
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   226
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   227
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   228
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   229
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   230
\begin{isamarkuptext}%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   231
\noindent
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   232
Finally, we prove our main theorem:%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   233
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   234
\isamarkuptrue%
9674
f789d2490669 updated;
wenzelm
parents: 9644
diff changeset
   235
\isacommand{theorem}\ rev{\isacharunderscore}rev\ {\isacharbrackleft}simp{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}rev{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ xs{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   236
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15364
diff changeset
   237
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   238
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   239
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   240
%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   241
\begin{isamarkuptext}%
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   242
\noindent
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   243
The final \commdx{end} tells Isabelle to close the current theory because
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   244
we are finished with its development:%
11456
7eb63f63e6c6 revisions and indexing
paulson
parents: 11450
diff changeset
   245
\index{*rev (constant)|)}\index{append function|)}%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   246
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   247
\isamarkuptrue%
8749
2665170f104a Adding generated files
nipkow
parents:
diff changeset
   248
\isacommand{end}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11457
diff changeset
   249
\isamarkupfalse%
9722
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
   250
\end{isabellebody}%
9145
9f7b8de5bfaf updated;
wenzelm
parents: 8771
diff changeset
   251
%%% Local Variables:
9f7b8de5bfaf updated;
wenzelm
parents: 8771
diff changeset
   252
%%% mode: latex
9f7b8de5bfaf updated;
wenzelm
parents: 8771
diff changeset
   253
%%% TeX-master: "root"
9f7b8de5bfaf updated;
wenzelm
parents: 8771
diff changeset
   254
%%% End: