doc-src/TutorialI/Misc/document/AdvancedInd.tex
author paulson
Fri, 18 Mar 2005 14:31:50 +0100
changeset 15614 b098158a3f39
parent 15481 fc075ae929e4
child 16069 3f2a9f400168
permissions -rw-r--r--
auto update
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: 9834
diff changeset
     3
\def\isabellecontext{AdvancedInd}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
     4
\isamarkupfalse%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
     5
%
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
     6
\begin{isamarkuptext}%
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
     7
\noindent
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
     8
Now that we have learned about rules and logic, we take another look at the
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
     9
finer points of induction.  We consider two questions: what to do if the
10396
5ab08609e6c8 *** empty log message ***
nipkow
parents: 10395
diff changeset
    10
proposition to be proved is not directly amenable to induction
5ab08609e6c8 *** empty log message ***
nipkow
parents: 10395
diff changeset
    11
(\S\ref{sec:ind-var-in-prems}), and how to utilize (\S\ref{sec:complete-ind})
5ab08609e6c8 *** empty log message ***
nipkow
parents: 10395
diff changeset
    12
and even derive (\S\ref{sec:derive-ind}) new induction schemas. We conclude
5ab08609e6c8 *** empty log message ***
nipkow
parents: 10395
diff changeset
    13
with an extended example of induction (\S\ref{sec:CTL-revisited}).%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    14
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    15
\isamarkuptrue%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    16
%
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    17
\isamarkupsubsection{Massaging the Proposition%
10397
e2d0dda41f2c auto update
paulson
parents: 10396
diff changeset
    18
}
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    19
\isamarkuptrue%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    20
%
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    21
\begin{isamarkuptext}%
10217
e61e7e1eacaf *** empty log message ***
nipkow
parents: 10187
diff changeset
    22
\label{sec:ind-var-in-prems}
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    23
Often we have assumed that the theorem to be proved is already in a form
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    24
that is amenable to induction, but sometimes it isn't.
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    25
Here is an example.
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    26
Since \isa{hd} and \isa{last} return the first and last element of a
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    27
non-empty list, this lemma looks easy to prove:%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    28
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    29
\isamarkuptrue%
9673
1b2d4f995b13 updated;
wenzelm
parents: 9670
diff changeset
    30
\isacommand{lemma}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ hd{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ last\ xs{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    31
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
    32
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    33
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    34
\isamarkupfalse%
13791
3b6ff7ceaf27 *** empty log message ***
nipkow
parents: 13778
diff changeset
    35
\isacommand{lemma}\ hd{\isacharunderscore}rev\ {\isacharbrackleft}rule{\isacharunderscore}format{\isacharbrackright}{\isacharcolon}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymlongrightarrow}\ hd{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ last\ xs{\isachardoublequote}\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    36
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    37
\isamarkuptrue%
12492
a4dd02e744e0 *** empty log message ***
nipkow
parents: 11866
diff changeset
    38
\isamarkupfalse%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    39
%
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    40
\isamarkupsubsection{Beyond Structural and Recursion Induction%
10397
e2d0dda41f2c auto update
paulson
parents: 10396
diff changeset
    41
}
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    42
\isamarkuptrue%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    43
%
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    44
\begin{isamarkuptext}%
10217
e61e7e1eacaf *** empty log message ***
nipkow
parents: 10187
diff changeset
    45
\label{sec:complete-ind}
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    46
So far, inductive proofs were by structural induction for
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    47
primitive recursive functions and recursion induction for total recursive
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    48
functions. But sometimes structural induction is awkward and there is no
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    49
recursive function that could furnish a more appropriate
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    50
induction schema. In such cases a general-purpose induction schema can
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    51
be helpful. We show how to apply such induction schemas by an example.
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    52
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    53
Structural induction on \isa{nat} is
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    54
usually known as mathematical induction. There is also \textbf{complete}
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    55
\index{induction!complete}%
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    56
induction, where you prove $P(n)$ under the assumption that $P(m)$
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    57
holds for all $m<n$. In Isabelle, this is the theorem \tdx{nat_less_induct}:
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    58
\begin{isabelle}%
14379
ea10a8c3e9cf updated links to the old ftp site
paulson
parents: 13791
diff changeset
    59
\ \ \ \ \ {\isacharparenleft}{\isasymAnd}n{\isachardot}\ {\isasymforall}m{\isacharless}n{\isachardot}\ P\ m\ {\isasymLongrightarrow}\ P\ n{\isacharparenright}\ {\isasymLongrightarrow}\ P\ n%
9924
3370f6aa3200 updated;
wenzelm
parents: 9834
diff changeset
    60
\end{isabelle}
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
    61
As an application, we prove a property of the following
11278
9710486b886b *** empty log message ***
nipkow
parents: 11277
diff changeset
    62
function:%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    63
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    64
\isamarkuptrue%
10281
9554ce1c2e54 *** empty log message ***
nipkow
parents: 10242
diff changeset
    65
\isacommand{consts}\ f\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat\ {\isasymRightarrow}\ nat{\isachardoublequote}\isanewline
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    66
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    67
\isacommand{axioms}\ f{\isacharunderscore}ax{\isacharcolon}\ {\isachardoublequote}f{\isacharparenleft}f{\isacharparenleft}n{\isacharparenright}{\isacharparenright}\ {\isacharless}\ f{\isacharparenleft}Suc{\isacharparenleft}n{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    68
%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    69
\begin{isamarkuptext}%
11256
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    70
\begin{warn}
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    71
We discourage the use of axioms because of the danger of
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    72
inconsistencies.  Axiom \isa{f{\isacharunderscore}ax} does
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    73
not introduce an inconsistency because, for example, the identity function
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    74
satisfies it.  Axioms can be useful in exploratory developments, say when 
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    75
you assume some well-known theorems so that you can quickly demonstrate some
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    76
point about methodology.  If your example turns into a substantial proof
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    77
development, you should replace axioms by theorems.
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
    78
\end{warn}\noindent
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    79
The axiom for \isa{f} implies \isa{n\ {\isasymle}\ f\ n}, which can
11196
bb4ede27fcb7 *** empty log message ***
nipkow
parents: 10950
diff changeset
    80
be proved by induction on \mbox{\isa{f\ n}}. Following the recipe outlined
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    81
above, we have to phrase the proposition as follows to allow induction:%
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    82
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    83
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    84
\isacommand{lemma}\ f{\isacharunderscore}incr{\isacharunderscore}lem{\isacharcolon}\ {\isachardoublequote}{\isasymforall}i{\isachardot}\ k\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i{\isachardoublequote}\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
    85
\isamarkuptrue%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
    86
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    87
\isamarkuptrue%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
    88
\isamarkupfalse%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
    89
\isamarkupfalse%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
    90
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    91
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    92
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
    93
%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    94
\begin{isamarkuptext}%
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
    95
\noindent
11196
bb4ede27fcb7 *** empty log message ***
nipkow
parents: 10950
diff changeset
    96
If you find the last step puzzling, here are the two lemmas it employs:
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    97
\begin{isabelle}
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    98
\isa{m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ Suc\ m\ {\isasymle}\ n}
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
    99
\rulename{Suc_leI}\isanewline
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   100
\isa{{\isasymlbrakk}i\ {\isasymle}\ j{\isacharsemicolon}\ j\ {\isacharless}\ k{\isasymrbrakk}\ {\isasymLongrightarrow}\ i\ {\isacharless}\ k}
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   101
\rulename{le_less_trans}
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   102
\end{isabelle}
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   103
%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   104
The proof goes like this (writing \isa{j} instead of \isa{nat}).
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   105
Since \isa{i\ {\isacharequal}\ Suc\ j} it suffices to show
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   106
\hbox{\isa{j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}}},
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   107
by \isa{Suc{\isacharunderscore}leI}\@.  This is
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   108
proved as follows. From \isa{f{\isacharunderscore}ax} we have \isa{f\ {\isacharparenleft}f\ j{\isacharparenright}\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}}
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   109
(1) which implies \isa{f\ j\ {\isasymle}\ f\ {\isacharparenleft}f\ j{\isacharparenright}} by the induction hypothesis.
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   110
Using (1) once more we obtain \isa{f\ j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}} (2) by the transitivity
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   111
rule \isa{le{\isacharunderscore}less{\isacharunderscore}trans}.
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   112
Using the induction hypothesis once more we obtain \isa{j\ {\isasymle}\ f\ j}
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   113
which, together with (2) yields \isa{j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}} (again by
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   114
\isa{le{\isacharunderscore}less{\isacharunderscore}trans}).
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   115
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   116
This last step shows both the power and the danger of automatic proofs.  They
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   117
will usually not tell you how the proof goes, because it can be hard to
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   118
translate the internal proof into a human-readable format.  Automatic
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   119
proofs are easy to write but hard to read and understand.
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   120
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   121
The desired result, \isa{i\ {\isasymle}\ f\ i}, follows from \isa{f{\isacharunderscore}incr{\isacharunderscore}lem}:%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   122
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   123
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   124
\isacommand{lemmas}\ f{\isacharunderscore}incr\ {\isacharequal}\ f{\isacharunderscore}incr{\isacharunderscore}lem{\isacharbrackleft}rule{\isacharunderscore}format{\isacharcomma}\ OF\ refl{\isacharbrackright}\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   125
%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   126
\begin{isamarkuptext}%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   127
\noindent
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   128
The final \isa{refl} gets rid of the premise \isa{{\isacharquery}k\ {\isacharequal}\ f\ {\isacharquery}i}. 
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   129
We could have included this derivation in the original statement of the lemma:%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   130
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   131
\isamarkuptrue%
13791
3b6ff7ceaf27 *** empty log message ***
nipkow
parents: 13778
diff changeset
   132
\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}\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   133
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   134
%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   135
\begin{isamarkuptext}%
11256
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   136
\begin{exercise}
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   137
From the axiom and lemma for \isa{f}, show that \isa{f} is the
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   138
identity function.
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   139
\end{exercise}
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   140
11428
332347b9b942 tidying the index
paulson
parents: 11278
diff changeset
   141
Method \methdx{induct_tac} can be applied with any rule $r$
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   142
whose conclusion is of the form ${?}P~?x@1 \dots ?x@n$, in which case the
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   143
format is
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   144
\begin{quote}
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   145
\isacommand{apply}\isa{{\isacharparenleft}induct{\isacharunderscore}tac} $y@1 \dots y@n$ \isa{rule{\isacharcolon}} $r$\isa{{\isacharparenright}}
11428
332347b9b942 tidying the index
paulson
parents: 11278
diff changeset
   146
\end{quote}
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   147
where $y@1, \dots, y@n$ are variables in the first subgoal.
11256
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   148
The conclusion of $r$ can even be an (iterated) conjunction of formulae of
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   149
the above form in which case the application is
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   150
\begin{quote}
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   151
\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}}
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   152
\end{quote}
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   153
11256
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   154
A further useful induction rule is \isa{length{\isacharunderscore}induct},
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   155
induction on the length of a list\indexbold{*length_induct}
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   156
\begin{isabelle}%
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   157
\ \ \ \ \ {\isacharparenleft}{\isasymAnd}xs{\isachardot}\ {\isasymforall}ys{\isachardot}\ length\ ys\ {\isacharless}\ length\ xs\ {\isasymlongrightarrow}\ P\ ys\ {\isasymLongrightarrow}\ P\ xs{\isacharparenright}\ {\isasymLongrightarrow}\ P\ xs%
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   158
\end{isabelle}
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   159
which is a special case of \isa{measure{\isacharunderscore}induct}
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   160
\begin{isabelle}%
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   161
\ \ \ \ \ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ {\isasymforall}y{\isachardot}\ f\ y\ {\isacharless}\ f\ x\ {\isasymlongrightarrow}\ P\ y\ {\isasymLongrightarrow}\ P\ x{\isacharparenright}\ {\isasymLongrightarrow}\ P\ a%
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   162
\end{isabelle}
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   163
where \isa{f} may be any function into type \isa{nat}.%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   164
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   165
\isamarkuptrue%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   166
%
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   167
\isamarkupsubsection{Derivation of New Induction Schemas%
10397
e2d0dda41f2c auto update
paulson
parents: 10396
diff changeset
   168
}
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   169
\isamarkuptrue%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   170
%
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   171
\begin{isamarkuptext}%
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   172
\label{sec:derive-ind}
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   173
\index{induction!deriving new schemas}%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   174
Induction schemas are ordinary theorems and you can derive new ones
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   175
whenever you wish.  This section shows you how, using the example
9924
3370f6aa3200 updated;
wenzelm
parents: 9834
diff changeset
   176
of \isa{nat{\isacharunderscore}less{\isacharunderscore}induct}. Assume we only have structural induction
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   177
available for \isa{nat} and want to derive complete induction.  We
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   178
must generalize the statement as shown:%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   179
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   180
\isamarkuptrue%
9792
bbefb6ce5cb2 *** empty log message ***
nipkow
parents: 9723
diff changeset
   181
\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
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   182
\isamarkupfalse%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   183
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
   184
\isamarkuptrue%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
   185
\isamarkupfalse%
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
   186
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   187
%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   188
\begin{isamarkuptext}%
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   189
\noindent
11196
bb4ede27fcb7 *** empty log message ***
nipkow
parents: 10950
diff changeset
   190
The elimination rule \isa{less{\isacharunderscore}SucE} expresses the case distinction:
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   191
\begin{isabelle}%
10696
76d7f6c9a14c *** empty log message ***
nipkow
parents: 10668
diff changeset
   192
\ \ \ \ \ {\isasymlbrakk}m\ {\isacharless}\ Suc\ n{\isacharsemicolon}\ m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ P{\isacharsemicolon}\ m\ {\isacharequal}\ n\ {\isasymLongrightarrow}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ P%
9924
3370f6aa3200 updated;
wenzelm
parents: 9834
diff changeset
   193
\end{isabelle}
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   194
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   195
Now it is straightforward to derive the original version of
11256
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   196
\isa{nat{\isacharunderscore}less{\isacharunderscore}induct} by manipulating the conclusion of the above
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   197
lemma: instantiate \isa{n} by \isa{Suc\ n} and \isa{m} by \isa{n}
49afcce3bada *** empty log message ***
nipkow
parents: 11196
diff changeset
   198
and remove the trivial condition \isa{n\ {\isacharless}\ Suc\ n}. Fortunately, this
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   199
happens automatically when we add the lemma as a new premise to the
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   200
desired goal:%
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   201
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   202
\isamarkuptrue%
9924
3370f6aa3200 updated;
wenzelm
parents: 9834
diff changeset
   203
\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
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   204
\isamarkupfalse%
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14379
diff changeset
   205
\isamarkupfalse%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   206
%
9698
f0740137a65d updated;
wenzelm
parents: 9673
diff changeset
   207
\begin{isamarkuptext}%
11494
23a118849801 revisions and indexing
paulson
parents: 11428
diff changeset
   208
HOL already provides the mother of
10396
5ab08609e6c8 *** empty log message ***
nipkow
parents: 10395
diff changeset
   209
all inductions, well-founded induction (see \S\ref{sec:Well-founded}).  For
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   210
example theorem \isa{nat{\isacharunderscore}less{\isacharunderscore}induct} is
10396
5ab08609e6c8 *** empty log message ***
nipkow
parents: 10395
diff changeset
   211
a special case of \isa{wf{\isacharunderscore}induct} where \isa{r} is \isa{{\isacharless}} on
10878
b254d5ad6dd4 auto update
paulson
parents: 10696
diff changeset
   212
\isa{nat}. The details can be found in theory \isa{Wellfounded_Recursion}.%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   213
\end{isamarkuptext}%
11866
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   214
\isamarkuptrue%
fbd097aec213 updated;
wenzelm
parents: 11708
diff changeset
   215
\isamarkupfalse%
9722
a5f86aed785b *** empty log message ***
nipkow
parents: 9721
diff changeset
   216
\end{isabellebody}%
9670
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   217
%%% Local Variables:
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   218
%%% mode: latex
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   219
%%% TeX-master: "root"
820cca8573f8 *** empty log message ***
nipkow
parents:
diff changeset
   220
%%% End: