doc-src/TutorialI/Misc/document/AdvancedInd.tex
author nipkow
Thu Sep 14 17:46:00 2000 +0200 (2000-09-14)
changeset 9958 67f2920862c7
parent 9933 9feb1e0c4cb3
child 10186 499637e8f2c6
permissions -rw-r--r--
*** empty log message ***
nipkow@9722
     1
%
nipkow@9722
     2
\begin{isabellebody}%
wenzelm@9924
     3
\def\isabellecontext{AdvancedInd}%
nipkow@9670
     4
%
nipkow@9670
     5
\begin{isamarkuptext}%
nipkow@9670
     6
\noindent
nipkow@9670
     7
Now that we have learned about rules and logic, we take another look at the
nipkow@9670
     8
finer points of induction. The two questions we answer are: what to do if the
nipkow@9670
     9
proposition to be proved is not directly amenable to induction, and how to
nipkow@9670
    10
utilize and even derive new induction schemas.%
nipkow@9670
    11
\end{isamarkuptext}%
nipkow@9670
    12
%
nipkow@9670
    13
\isamarkupsubsection{Massaging the proposition\label{sec:ind-var-in-prems}}
nipkow@9670
    14
%
nipkow@9670
    15
\begin{isamarkuptext}%
nipkow@9670
    16
\noindent
nipkow@9670
    17
So far we have assumed that the theorem we want to prove is already in a form
nipkow@9670
    18
that is amenable to induction, but this is not always the case:%
nipkow@9670
    19
\end{isamarkuptext}%
wenzelm@9673
    20
\isacommand{lemma}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ hd{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ last\ xs{\isachardoublequote}\isanewline
wenzelm@9673
    21
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ xs{\isacharparenright}%
nipkow@9670
    22
\begin{isamarkuptxt}%
nipkow@9670
    23
\noindent
nipkow@9670
    24
(where \isa{hd} and \isa{last} return the first and last element of a
nipkow@9670
    25
non-empty list)
nipkow@9670
    26
produces the warning
nipkow@9670
    27
\begin{quote}\tt
nipkow@9670
    28
Induction variable occurs also among premises!
nipkow@9670
    29
\end{quote}
nipkow@9670
    30
and leads to the base case
nipkow@9723
    31
\begin{isabelle}
nipkow@9670
    32
\ 1.\ xs\ {\isasymnoteq}\ []\ {\isasymLongrightarrow}\ hd\ (rev\ [])\ =\ last\ []
nipkow@9723
    33
\end{isabelle}
nipkow@9670
    34
which, after simplification, becomes
nipkow@9723
    35
\begin{isabelle}
nipkow@9670
    36
\ 1.\ xs\ {\isasymnoteq}\ []\ {\isasymLongrightarrow}\ hd\ []\ =\ last\ []
nipkow@9723
    37
\end{isabelle}
nipkow@9670
    38
We cannot prove this equality because we do not know what \isa{hd} and
nipkow@9792
    39
\isa{last} return when applied to \isa{{\isacharbrackleft}{\isacharbrackright}}.
nipkow@9670
    40
nipkow@9670
    41
The point is that we have violated the above warning. Because the induction
nipkow@9670
    42
formula is only the conclusion, the occurrence of \isa{xs} in the premises is
nipkow@9670
    43
not modified by induction. Thus the case that should have been trivial
nipkow@9670
    44
becomes unprovable. Fortunately, the solution is easy:
nipkow@9670
    45
\begin{quote}
nipkow@9670
    46
\emph{Pull all occurrences of the induction variable into the conclusion
nipkow@9792
    47
using \isa{{\isasymlongrightarrow}}.}
nipkow@9670
    48
\end{quote}
nipkow@9670
    49
This means we should prove%
nipkow@9670
    50
\end{isamarkuptxt}%
wenzelm@9673
    51
\isacommand{lemma}\ hd{\isacharunderscore}rev{\isacharcolon}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymlongrightarrow}\ hd{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ last\ xs{\isachardoublequote}%
nipkow@9670
    52
\begin{isamarkuptext}%
nipkow@9670
    53
\noindent
nipkow@9670
    54
This time, induction leaves us with the following base case
nipkow@9723
    55
\begin{isabelle}
nipkow@9670
    56
\ 1.\ []\ {\isasymnoteq}\ []\ {\isasymlongrightarrow}\ hd\ (rev\ [])\ =\ last\ []
nipkow@9723
    57
\end{isabelle}
nipkow@9670
    58
which is trivial, and \isa{auto} finishes the whole proof.
nipkow@9670
    59
nipkow@9792
    60
If \isa{hd{\isacharunderscore}rev} is meant to be a simplification rule, you are
nipkow@9792
    61
done. But if you really need the \isa{{\isasymLongrightarrow}}-version of
nipkow@9792
    62
\isa{hd{\isacharunderscore}rev}, for example because you want to apply it as an
nipkow@9792
    63
introduction rule, you need to derive it separately, by combining it with
nipkow@9792
    64
modus ponens:%
nipkow@9670
    65
\end{isamarkuptext}%
wenzelm@9673
    66
\isacommand{lemmas}\ hd{\isacharunderscore}revI\ {\isacharequal}\ hd{\isacharunderscore}rev{\isacharbrackleft}THEN\ mp{\isacharbrackright}%
nipkow@9670
    67
\begin{isamarkuptext}%
nipkow@9670
    68
\noindent
nipkow@9670
    69
which yields the lemma we originally set out to prove.
nipkow@9670
    70
nipkow@9670
    71
In case there are multiple premises $A@1$, \dots, $A@n$ containing the
nipkow@9670
    72
induction variable, you should turn the conclusion $C$ into
nipkow@9670
    73
\[ A@1 \longrightarrow \cdots A@n \longrightarrow C \]
nipkow@9670
    74
(see the remark?? in \S\ref{??}).
nipkow@9670
    75
Additionally, you may also have to universally quantify some other variables,
nipkow@9670
    76
which can yield a fairly complex conclusion.
nipkow@9670
    77
Here is a simple example (which is proved by \isa{blast}):%
nipkow@9670
    78
\end{isamarkuptext}%
wenzelm@9698
    79
\isacommand{lemma}\ simple{\isacharcolon}\ {\isachardoublequote}{\isasymforall}y{\isachardot}\ A\ y\ {\isasymlongrightarrow}\ B\ y\ {\isasymlongrightarrow}\ B\ y\ {\isacharampersand}\ A\ y{\isachardoublequote}%
nipkow@9670
    80
\begin{isamarkuptext}%
nipkow@9670
    81
\noindent
nipkow@9670
    82
You can get the desired lemma by explicit
nipkow@9670
    83
application of modus ponens and \isa{spec}:%
nipkow@9670
    84
\end{isamarkuptext}%
wenzelm@9673
    85
\isacommand{lemmas}\ myrule\ {\isacharequal}\ simple{\isacharbrackleft}THEN\ spec{\isacharcomma}\ THEN\ mp{\isacharcomma}\ THEN\ mp{\isacharbrackright}%
nipkow@9670
    86
\begin{isamarkuptext}%
nipkow@9670
    87
\noindent
nipkow@9792
    88
or the wholesale stripping of \isa{{\isasymforall}} and
nipkow@9958
    89
\isa{{\isasymlongrightarrow}} in the conclusion via \isa{rule{\isacharunderscore}format}%
nipkow@9670
    90
\end{isamarkuptext}%
nipkow@9958
    91
\isacommand{lemmas}\ myrule\ {\isacharequal}\ simple{\isacharbrackleft}rule{\isacharunderscore}format{\isacharbrackright}%
nipkow@9670
    92
\begin{isamarkuptext}%
nipkow@9670
    93
\noindent
nipkow@9792
    94
yielding \isa{{\isasymlbrakk}A\ y{\isacharsemicolon}\ B\ y{\isasymrbrakk}\ {\isasymLongrightarrow}\ B\ y\ {\isasymand}\ A\ y}.
nipkow@9670
    95
You can go one step further and include these derivations already in the
nipkow@9670
    96
statement of your original lemma, thus avoiding the intermediate step:%
nipkow@9670
    97
\end{isamarkuptext}%
nipkow@9958
    98
\isacommand{lemma}\ myrule{\isacharbrackleft}rule{\isacharunderscore}format{\isacharbrackright}{\isacharcolon}\ \ {\isachardoublequote}{\isasymforall}y{\isachardot}\ A\ y\ {\isasymlongrightarrow}\ B\ y\ {\isasymlongrightarrow}\ B\ y\ {\isacharampersand}\ A\ y{\isachardoublequote}%
nipkow@9670
    99
\begin{isamarkuptext}%
nipkow@9670
   100
\bigskip
nipkow@9670
   101
nipkow@9670
   102
A second reason why your proposition may not be amenable to induction is that
nipkow@9670
   103
you want to induct on a whole term, rather than an individual variable. In
nipkow@9670
   104
general, when inducting on some term $t$ you must rephrase the conclusion as
nipkow@9670
   105
\[ \forall y@1 \dots y@n.~ x = t \longrightarrow C \] where $y@1 \dots y@n$
nipkow@9670
   106
are the free variables in $t$ and $x$ is new, and perform induction on $x$
nipkow@9670
   107
afterwards. An example appears below.%
nipkow@9670
   108
\end{isamarkuptext}%
nipkow@9670
   109
%
wenzelm@9698
   110
\isamarkupsubsection{Beyond structural and recursion induction}
nipkow@9670
   111
%
nipkow@9670
   112
\begin{isamarkuptext}%
nipkow@9670
   113
So far, inductive proofs where by structural induction for
nipkow@9670
   114
primitive recursive functions and recursion induction for total recursive
nipkow@9670
   115
functions. But sometimes structural induction is awkward and there is no
nipkow@9670
   116
recursive function in sight either that could furnish a more appropriate
nipkow@9670
   117
induction schema. In such cases some existing standard induction schema can
nipkow@9670
   118
be helpful. We show how to apply such induction schemas by an example.
nipkow@9670
   119
nipkow@9670
   120
Structural induction on \isa{nat} is
nipkow@9670
   121
usually known as ``mathematical induction''. There is also ``complete
nipkow@9670
   122
induction'', where you must prove $P(n)$ under the assumption that $P(m)$
wenzelm@9924
   123
holds for all $m<n$. In Isabelle, this is the theorem \isa{nat{\isacharunderscore}less{\isacharunderscore}induct}:
nipkow@9670
   124
\begin{isabelle}%
nipkow@9834
   125
\ \ \ \ \ {\isacharparenleft}{\isasymAnd}n{\isachardot}\ {\isasymforall}m{\isachardot}\ m\ {\isacharless}\ n\ {\isasymlongrightarrow}\ P\ m\ {\isasymLongrightarrow}\ P\ n{\isacharparenright}\ {\isasymLongrightarrow}\ P\ n%
wenzelm@9924
   126
\end{isabelle}
nipkow@9670
   127
Here is an example of its application.%
nipkow@9670
   128
\end{isamarkuptext}%
wenzelm@9673
   129
\isacommand{consts}\ f\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat\ {\isacharequal}{\isachargreater}\ nat{\isachardoublequote}\isanewline
wenzelm@9673
   130
\isacommand{axioms}\ f{\isacharunderscore}ax{\isacharcolon}\ {\isachardoublequote}f{\isacharparenleft}f{\isacharparenleft}n{\isacharparenright}{\isacharparenright}\ {\isacharless}\ f{\isacharparenleft}Suc{\isacharparenleft}n{\isacharparenright}{\isacharparenright}{\isachardoublequote}%
nipkow@9670
   131
\begin{isamarkuptext}%
nipkow@9670
   132
\noindent
nipkow@9670
   133
From the above axiom\footnote{In general, the use of axioms is strongly
nipkow@9670
   134
discouraged, because of the danger of inconsistencies. The above axiom does
nipkow@9670
   135
not introduce an inconsistency because, for example, the identity function
nipkow@9670
   136
satisfies it.}
nipkow@9792
   137
for \isa{f} it follows that \isa{n\ {\isasymle}\ f\ n}, which can
nipkow@9792
   138
be proved by induction on \isa{f\ n}. Following the recipy outlined
nipkow@9670
   139
above, we have to phrase the proposition as follows to allow induction:%
nipkow@9670
   140
\end{isamarkuptext}%
wenzelm@9673
   141
\isacommand{lemma}\ f{\isacharunderscore}incr{\isacharunderscore}lem{\isacharcolon}\ {\isachardoublequote}{\isasymforall}i{\isachardot}\ k\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i{\isachardoublequote}%
nipkow@9670
   142
\begin{isamarkuptxt}%
nipkow@9670
   143
\noindent
wenzelm@9924
   144
To perform induction on \isa{k} using \isa{nat{\isacharunderscore}less{\isacharunderscore}induct}, we use the same
nipkow@9670
   145
general induction method as for recursion induction (see
nipkow@9670
   146
\S\ref{sec:recdef-induction}):%
nipkow@9670
   147
\end{isamarkuptxt}%
wenzelm@9924
   148
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ k\ rule{\isacharcolon}\ nat{\isacharunderscore}less{\isacharunderscore}induct{\isacharparenright}%
nipkow@9670
   149
\begin{isamarkuptxt}%
nipkow@9670
   150
\noindent
nipkow@9670
   151
which leaves us with the following proof state:
nipkow@9723
   152
\begin{isabelle}
nipkow@9670
   153
\ 1.\ {\isasymAnd}\mbox{n}.\ {\isasymforall}\mbox{m}.\ \mbox{m}\ <\ \mbox{n}\ {\isasymlongrightarrow}\ ({\isasymforall}\mbox{i}.\ \mbox{m}\ =\ f\ \mbox{i}\ {\isasymlongrightarrow}\ \mbox{i}\ {\isasymle}\ f\ \mbox{i})\isanewline
nipkow@9670
   154
\ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isasymforall}\mbox{i}.\ \mbox{n}\ =\ f\ \mbox{i}\ {\isasymlongrightarrow}\ \mbox{i}\ {\isasymle}\ f\ \mbox{i}
nipkow@9723
   155
\end{isabelle}
nipkow@9792
   156
After stripping the \isa{{\isasymforall}i}, the proof continues with a case
nipkow@9792
   157
distinction on \isa{i}. The case \isa{i\ {\isacharequal}\ \isadigit{0}} is trivial and we focus on
nipkow@9792
   158
the other case:
nipkow@9723
   159
\begin{isabelle}
nipkow@9670
   160
\ 1.\ {\isasymAnd}\mbox{n}\ \mbox{i}\ \mbox{nat}.\isanewline
nipkow@9670
   161
\ \ \ \ \ \ \ {\isasymlbrakk}{\isasymforall}\mbox{m}.\ \mbox{m}\ <\ \mbox{n}\ {\isasymlongrightarrow}\ ({\isasymforall}\mbox{i}.\ \mbox{m}\ =\ f\ \mbox{i}\ {\isasymlongrightarrow}\ \mbox{i}\ {\isasymle}\ f\ \mbox{i});\ \mbox{i}\ =\ Suc\ \mbox{nat}{\isasymrbrakk}\isanewline
nipkow@9670
   162
\ \ \ \ \ \ \ {\isasymLongrightarrow}\ \mbox{n}\ =\ f\ \mbox{i}\ {\isasymlongrightarrow}\ \mbox{i}\ {\isasymle}\ f\ \mbox{i}
nipkow@9723
   163
\end{isabelle}%
nipkow@9670
   164
\end{isamarkuptxt}%
wenzelm@9924
   165
\isacommand{by}{\isacharparenleft}blast\ intro{\isacharbang}{\isacharcolon}\ f{\isacharunderscore}ax\ Suc{\isacharunderscore}leI\ intro{\isacharcolon}\ le{\isacharunderscore}less{\isacharunderscore}trans{\isacharparenright}%
nipkow@9670
   166
\begin{isamarkuptext}%
nipkow@9670
   167
\noindent
nipkow@9670
   168
It is not surprising if you find the last step puzzling.
nipkow@9670
   169
The proof goes like this (writing \isa{j} instead of \isa{nat}).
nipkow@9792
   170
Since \isa{i\ {\isacharequal}\ Suc\ j} it suffices to show
nipkow@9792
   171
\isa{j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}} (by \isa{Suc{\isacharunderscore}leI}: \isa{m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ Suc\ m\ {\isasymle}\ n}). This is
nipkow@9792
   172
proved as follows. From \isa{f{\isacharunderscore}ax} we have \isa{f\ {\isacharparenleft}f\ j{\isacharparenright}\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}}
nipkow@9792
   173
(1) which implies \isa{f\ j\ {\isasymle}\ f\ {\isacharparenleft}f\ j{\isacharparenright}} (by the induction hypothesis).
nipkow@9792
   174
Using (1) once more we obtain \isa{f\ j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}} (2) by transitivity
nipkow@9792
   175
(\isa{le{\isacharunderscore}less{\isacharunderscore}trans}: \isa{{\isasymlbrakk}i\ {\isasymle}\ j{\isacharsemicolon}\ j\ {\isacharless}\ k{\isasymrbrakk}\ {\isasymLongrightarrow}\ i\ {\isacharless}\ k}).
nipkow@9792
   176
Using the induction hypothesis once more we obtain \isa{j\ {\isasymle}\ f\ j}
nipkow@9792
   177
which, together with (2) yields \isa{j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}} (again by
nipkow@9792
   178
\isa{le{\isacharunderscore}less{\isacharunderscore}trans}).
nipkow@9670
   179
nipkow@9670
   180
This last step shows both the power and the danger of automatic proofs: they
nipkow@9670
   181
will usually not tell you how the proof goes, because it can be very hard to
nipkow@9670
   182
translate the internal proof into a human-readable format. Therefore
nipkow@9670
   183
\S\ref{sec:part2?} introduces a language for writing readable yet concise
nipkow@9670
   184
proofs.
nipkow@9670
   185
nipkow@9792
   186
We can now derive the desired \isa{i\ {\isasymle}\ f\ i} from \isa{f{\isacharunderscore}incr}:%
nipkow@9670
   187
\end{isamarkuptext}%
nipkow@9958
   188
\isacommand{lemmas}\ f{\isacharunderscore}incr\ {\isacharequal}\ f{\isacharunderscore}incr{\isacharunderscore}lem{\isacharbrackleft}rule{\isacharunderscore}format{\isacharcomma}\ OF\ refl{\isacharbrackright}%
nipkow@9670
   189
\begin{isamarkuptext}%
wenzelm@9698
   190
\noindent
nipkow@9792
   191
The final \isa{refl} gets rid of the premise \isa{{\isacharquery}k\ {\isacharequal}\ f\ {\isacharquery}i}. Again,
nipkow@9792
   192
we could have included this derivation in the original statement of the lemma:%
nipkow@9670
   193
\end{isamarkuptext}%
nipkow@9958
   194
\isacommand{lemma}\ f{\isacharunderscore}incr{\isacharbrackleft}rule{\isacharunderscore}format{\isacharcomma}\ OF\ refl{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}{\isasymforall}i{\isachardot}\ k\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i{\isachardoublequote}%
nipkow@9670
   195
\begin{isamarkuptext}%
nipkow@9670
   196
\begin{exercise}
nipkow@9792
   197
From the above axiom and lemma for \isa{f} show that \isa{f} is the
nipkow@9792
   198
identity.
nipkow@9670
   199
\end{exercise}
nipkow@9670
   200
nipkow@9792
   201
In general, \isa{induct{\isacharunderscore}tac} can be applied with any rule $r$
nipkow@9792
   202
whose conclusion is of the form ${?}P~?x@1 \dots ?x@n$, in which case the
nipkow@9670
   203
format is
nipkow@9792
   204
\begin{quote}
nipkow@9792
   205
\isacommand{apply}\isa{{\isacharparenleft}induct{\isacharunderscore}tac} $y@1 \dots y@n$ \isa{rule{\isacharcolon}} $r$\isa{{\isacharparenright}}
nipkow@9792
   206
\end{quote}\index{*induct_tac}%
nipkow@9792
   207
where $y@1, \dots, y@n$ are variables in the first subgoal.
nipkow@9792
   208
In fact, \isa{induct{\isacharunderscore}tac} even allows the conclusion of
nipkow@9792
   209
$r$ to be an (iterated) conjunction of formulae of the above form, in
nipkow@9670
   210
which case the application is
nipkow@9792
   211
\begin{quote}
nipkow@9792
   212
\isacommand{apply}\isa{{\isacharparenleft}induct{\isacharunderscore}tac} $y@1 \dots y@n$ \isa{and} \dots\ \isa{and} $z@1 \dots z@m$ \isa{rule{\isacharcolon}} $r$\isa{{\isacharparenright}}
nipkow@9792
   213
\end{quote}%
wenzelm@9698
   214
\end{isamarkuptext}%
wenzelm@9698
   215
%
wenzelm@9698
   216
\isamarkupsubsection{Derivation of new induction schemas}
wenzelm@9698
   217
%
wenzelm@9698
   218
\begin{isamarkuptext}%
wenzelm@9698
   219
\label{sec:derive-ind}
wenzelm@9698
   220
Induction schemas are ordinary theorems and you can derive new ones
wenzelm@9698
   221
whenever you wish.  This section shows you how to, using the example
wenzelm@9924
   222
of \isa{nat{\isacharunderscore}less{\isacharunderscore}induct}. Assume we only have structural induction
wenzelm@9698
   223
available for \isa{nat} and want to derive complete induction. This
wenzelm@9698
   224
requires us to generalize the statement first:%
wenzelm@9698
   225
\end{isamarkuptext}%
nipkow@9792
   226
\isacommand{lemma}\ induct{\isacharunderscore}lem{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isasymAnd}n{\isacharcolon}{\isacharcolon}nat{\isachardot}\ {\isasymforall}m{\isacharless}n{\isachardot}\ P\ m\ {\isasymLongrightarrow}\ P\ n{\isacharparenright}\ {\isasymLongrightarrow}\ {\isasymforall}m{\isacharless}n{\isachardot}\ P\ m{\isachardoublequote}\isanewline
wenzelm@9698
   227
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ n{\isacharparenright}%
wenzelm@9698
   228
\begin{isamarkuptxt}%
wenzelm@9698
   229
\noindent
nipkow@9933
   230
The base case is trivially true. For the induction step (\isa{m\ {\isacharless}\ Suc\ n}) we distinguish two cases: case \isa{m\ {\isacharless}\ n} is true by induction
nipkow@9933
   231
hypothesis and case \isa{m\ {\isacharequal}\ n} follows from the assumption, again using
wenzelm@9698
   232
the induction hypothesis:%
wenzelm@9698
   233
\end{isamarkuptxt}%
wenzelm@9698
   234
\isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
nipkow@9933
   235
\isacommand{by}{\isacharparenleft}blast\ elim{\isacharcolon}less{\isacharunderscore}SucE{\isacharparenright}%
wenzelm@9698
   236
\begin{isamarkuptext}%
wenzelm@9698
   237
\noindent
nipkow@9792
   238
The elimination rule \isa{less{\isacharunderscore}SucE} expresses the case distinction:
wenzelm@9698
   239
\begin{isabelle}%
nipkow@9834
   240
\ \ \ \ \ {\isasymlbrakk}m\ {\isacharless}\ Suc\ n{\isacharsemicolon}\ m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ P{\isacharsemicolon}\ m\ {\isacharequal}\ n\ {\isasymLongrightarrow}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ P%
wenzelm@9924
   241
\end{isabelle}
wenzelm@9698
   242
wenzelm@9698
   243
Now it is straightforward to derive the original version of
wenzelm@9924
   244
\isa{nat{\isacharunderscore}less{\isacharunderscore}induct} by manipulting the conclusion of the above lemma:
nipkow@9792
   245
instantiate \isa{n} by \isa{Suc\ n} and \isa{m} by \isa{n} and
nipkow@9792
   246
remove the trivial condition \isa{n\ {\isacharless}\ Sc\ n}. Fortunately, this
wenzelm@9698
   247
happens automatically when we add the lemma as a new premise to the
wenzelm@9698
   248
desired goal:%
wenzelm@9698
   249
\end{isamarkuptext}%
wenzelm@9924
   250
\isacommand{theorem}\ nat{\isacharunderscore}less{\isacharunderscore}induct{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isasymAnd}n{\isacharcolon}{\isacharcolon}nat{\isachardot}\ {\isasymforall}m{\isacharless}n{\isachardot}\ P\ m\ {\isasymLongrightarrow}\ P\ n{\isacharparenright}\ {\isasymLongrightarrow}\ P\ n{\isachardoublequote}\isanewline
wenzelm@9698
   251
\isacommand{by}{\isacharparenleft}insert\ induct{\isacharunderscore}lem{\isacharcomma}\ blast{\isacharparenright}%
wenzelm@9698
   252
\begin{isamarkuptext}%
nipkow@9670
   253
Finally we should mention that HOL already provides the mother of all
nipkow@9792
   254
inductions, \emph{wellfounded induction} (\isa{wf{\isacharunderscore}induct}):
nipkow@9670
   255
\begin{isabelle}%
nipkow@9834
   256
\ \ \ \ \ {\isasymlbrakk}wf\ r{\isacharsemicolon}\ {\isasymAnd}x{\isachardot}\ {\isasymforall}y{\isachardot}\ {\isacharparenleft}y{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ r\ {\isasymlongrightarrow}\ P\ y\ {\isasymLongrightarrow}\ P\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ a%
wenzelm@9924
   257
\end{isabelle}
nipkow@9792
   258
where \isa{wf\ r} means that the relation \isa{r} is wellfounded.
nipkow@9933
   259
For example, theorem \isa{nat{\isacharunderscore}less{\isacharunderscore}induct} can be viewed (and
nipkow@9933
   260
derived) as a special case of \isa{wf{\isacharunderscore}induct} where 
nipkow@9933
   261
\isa{r} is \isa{{\isacharless}} on \isa{nat}. For details see the library.%
nipkow@9670
   262
\end{isamarkuptext}%
nipkow@9722
   263
\end{isabellebody}%
nipkow@9670
   264
%%% Local Variables:
nipkow@9670
   265
%%% mode: latex
nipkow@9670
   266
%%% TeX-master: "root"
nipkow@9670
   267
%%% End: