9722
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
9924
|
3 |
\def\isabellecontext{AdvancedInd}%
|
9670
|
4 |
%
|
|
5 |
\begin{isamarkuptext}%
|
|
6 |
\noindent
|
|
7 |
Now that we have learned about rules and logic, we take another look at the
|
|
8 |
finer points of induction. The two questions we answer are: what to do if the
|
10396
|
9 |
proposition to be proved is not directly amenable to induction
|
|
10 |
(\S\ref{sec:ind-var-in-prems}), and how to utilize (\S\ref{sec:complete-ind})
|
|
11 |
and even derive (\S\ref{sec:derive-ind}) new induction schemas. We conclude
|
|
12 |
with an extended example of induction (\S\ref{sec:CTL-revisited}).%
|
9670
|
13 |
\end{isamarkuptext}%
|
|
14 |
%
|
10878
|
15 |
\isamarkupsubsection{Massaging the Proposition%
|
10397
|
16 |
}
|
9670
|
17 |
%
|
|
18 |
\begin{isamarkuptext}%
|
10217
|
19 |
\label{sec:ind-var-in-prems}
|
10878
|
20 |
Often we have assumed that the theorem we want to prove is already in a form
|
|
21 |
that is amenable to induction, but sometimes it isn't.
|
|
22 |
Here is an example.
|
|
23 |
Since \isa{hd} and \isa{last} return the first and last element of a
|
|
24 |
non-empty list, this lemma looks easy to prove:%
|
9670
|
25 |
\end{isamarkuptext}%
|
9673
|
26 |
\isacommand{lemma}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ hd{\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ last\ xs{\isachardoublequote}\isanewline
|
|
27 |
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ xs{\isacharparenright}%
|
9670
|
28 |
\begin{isamarkuptxt}%
|
|
29 |
\noindent
|
10878
|
30 |
But induction produces the warning
|
9670
|
31 |
\begin{quote}\tt
|
|
32 |
Induction variable occurs also among premises!
|
|
33 |
\end{quote}
|
|
34 |
and leads to the base case
|
10363
|
35 |
\begin{isabelle}%
|
|
36 |
\ {\isadigit{1}}{\isachardot}\ xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ hd\ {\isacharparenleft}rev\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}\ {\isacharequal}\ last\ {\isacharbrackleft}{\isacharbrackright}%
|
9723
|
37 |
\end{isabelle}
|
10878
|
38 |
After simplification, it becomes
|
9723
|
39 |
\begin{isabelle}
|
9670
|
40 |
\ 1.\ xs\ {\isasymnoteq}\ []\ {\isasymLongrightarrow}\ hd\ []\ =\ last\ []
|
9723
|
41 |
\end{isabelle}
|
9670
|
42 |
We cannot prove this equality because we do not know what \isa{hd} and
|
9792
|
43 |
\isa{last} return when applied to \isa{{\isacharbrackleft}{\isacharbrackright}}.
|
9670
|
44 |
|
10878
|
45 |
We should not have ignored the warning. Because the induction
|
|
46 |
formula is only the conclusion, induction does not affect the occurrence of \isa{xs} in the premises.
|
|
47 |
Thus the case that should have been trivial
|
10242
|
48 |
becomes unprovable. Fortunately, the solution is easy:\footnote{A very similar
|
|
49 |
heuristic applies to rule inductions; see \S\ref{sec:rtc}.}
|
9670
|
50 |
\begin{quote}
|
|
51 |
\emph{Pull all occurrences of the induction variable into the conclusion
|
9792
|
52 |
using \isa{{\isasymlongrightarrow}}.}
|
9670
|
53 |
\end{quote}
|
10878
|
54 |
Thus we should state the lemma as an ordinary
|
|
55 |
implication~(\isa{{\isasymlongrightarrow}}), letting
|
|
56 |
\isa{rule{\isacharunderscore}format} (\S\ref{sec:forward}) convert the
|
|
57 |
result to the usual \isa{{\isasymLongrightarrow}} form:%
|
9670
|
58 |
\end{isamarkuptxt}%
|
10878
|
59 |
\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}%
|
10420
|
60 |
\begin{isamarkuptxt}%
|
9670
|
61 |
\noindent
|
10878
|
62 |
This time, induction leaves us with a trivial base case:
|
10420
|
63 |
\begin{isabelle}%
|
|
64 |
\ {\isadigit{1}}{\isachardot}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymlongrightarrow}\ hd\ {\isacharparenleft}rev\ {\isacharbrackleft}{\isacharbrackright}{\isacharparenright}\ {\isacharequal}\ last\ {\isacharbrackleft}{\isacharbrackright}%
|
9723
|
65 |
\end{isabelle}
|
11196
|
66 |
And \isa{auto} completes the proof.
|
|
67 |
|
10878
|
68 |
If there are multiple premises $A@1$, \dots, $A@n$ containing the
|
9670
|
69 |
induction variable, you should turn the conclusion $C$ into
|
|
70 |
\[ A@1 \longrightarrow \cdots A@n \longrightarrow C \]
|
|
71 |
Additionally, you may also have to universally quantify some other variables,
|
10878
|
72 |
which can yield a fairly complex conclusion. However, \isa{rule{\isacharunderscore}format}
|
|
73 |
can remove any number of occurrences of \isa{{\isasymforall}} and
|
11196
|
74 |
\isa{{\isasymlongrightarrow}}.%
|
|
75 |
\end{isamarkuptxt}%
|
|
76 |
%
|
9670
|
77 |
\begin{isamarkuptext}%
|
|
78 |
A second reason why your proposition may not be amenable to induction is that
|
|
79 |
you want to induct on a whole term, rather than an individual variable. In
|
10217
|
80 |
general, when inducting on some term $t$ you must rephrase the conclusion $C$
|
|
81 |
as
|
|
82 |
\[ \forall y@1 \dots y@n.~ x = t \longrightarrow C \]
|
|
83 |
where $y@1 \dots y@n$ are the free variables in $t$ and $x$ is new, and
|
|
84 |
perform induction on $x$ afterwards. An example appears in
|
|
85 |
\S\ref{sec:complete-ind} below.
|
|
86 |
|
|
87 |
The very same problem may occur in connection with rule induction. Remember
|
|
88 |
that it requires a premise of the form $(x@1,\dots,x@k) \in R$, where $R$ is
|
|
89 |
some inductively defined set and the $x@i$ are variables. If instead we have
|
|
90 |
a premise $t \in R$, where $t$ is not just an $n$-tuple of variables, we
|
|
91 |
replace it with $(x@1,\dots,x@k) \in R$, and rephrase the conclusion $C$ as
|
|
92 |
\[ \forall y@1 \dots y@n.~ (x@1,\dots,x@k) = t \longrightarrow C \]
|
10281
|
93 |
For an example see \S\ref{sec:CTL-revisited} below.
|
|
94 |
|
|
95 |
Of course, all premises that share free variables with $t$ need to be pulled into
|
|
96 |
the conclusion as well, under the \isa{{\isasymforall}}, again using \isa{{\isasymlongrightarrow}} as shown above.%
|
9670
|
97 |
\end{isamarkuptext}%
|
|
98 |
%
|
10878
|
99 |
\isamarkupsubsection{Beyond Structural and Recursion Induction%
|
10397
|
100 |
}
|
9670
|
101 |
%
|
|
102 |
\begin{isamarkuptext}%
|
10217
|
103 |
\label{sec:complete-ind}
|
10878
|
104 |
So far, inductive proofs were by structural induction for
|
9670
|
105 |
primitive recursive functions and recursion induction for total recursive
|
|
106 |
functions. But sometimes structural induction is awkward and there is no
|
10878
|
107 |
recursive function that could furnish a more appropriate
|
|
108 |
induction schema. In such cases a general-purpose induction schema can
|
9670
|
109 |
be helpful. We show how to apply such induction schemas by an example.
|
|
110 |
|
|
111 |
Structural induction on \isa{nat} is
|
10878
|
112 |
usually known as mathematical induction. There is also \emph{complete}
|
|
113 |
induction, where you must prove $P(n)$ under the assumption that $P(m)$
|
9924
|
114 |
holds for all $m<n$. In Isabelle, this is the theorem \isa{nat{\isacharunderscore}less{\isacharunderscore}induct}:
|
9670
|
115 |
\begin{isabelle}%
|
9834
|
116 |
\ \ \ \ \ {\isacharparenleft}{\isasymAnd}n{\isachardot}\ {\isasymforall}m{\isachardot}\ m\ {\isacharless}\ n\ {\isasymlongrightarrow}\ P\ m\ {\isasymLongrightarrow}\ P\ n{\isacharparenright}\ {\isasymLongrightarrow}\ P\ n%
|
9924
|
117 |
\end{isabelle}
|
9670
|
118 |
Here is an example of its application.%
|
|
119 |
\end{isamarkuptext}%
|
10281
|
120 |
\isacommand{consts}\ f\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}nat\ {\isasymRightarrow}\ nat{\isachardoublequote}\isanewline
|
9673
|
121 |
\isacommand{axioms}\ f{\isacharunderscore}ax{\isacharcolon}\ {\isachardoublequote}f{\isacharparenleft}f{\isacharparenleft}n{\isacharparenright}{\isacharparenright}\ {\isacharless}\ f{\isacharparenleft}Suc{\isacharparenleft}n{\isacharparenright}{\isacharparenright}{\isachardoublequote}%
|
9670
|
122 |
\begin{isamarkuptext}%
|
11256
|
123 |
\begin{warn}
|
|
124 |
We discourage the use of axioms because of the danger of
|
|
125 |
inconsistencies. Axiom \isa{f{\isacharunderscore}ax} does
|
|
126 |
not introduce an inconsistency because, for example, the identity function
|
|
127 |
satisfies it. Axioms can be useful in exploratory developments, say when
|
|
128 |
you assume some well-known theorems so that you can quickly demonstrate some
|
|
129 |
point about methodology. If your example turns into a substantial proof
|
|
130 |
development, you should replace axioms by theorems.
|
|
131 |
\end{warn}\noindent
|
10878
|
132 |
The axiom for \isa{f} implies \isa{n\ {\isasymle}\ f\ n}, which can
|
11196
|
133 |
be proved by induction on \mbox{\isa{f\ n}}. Following the recipe outlined
|
9670
|
134 |
above, we have to phrase the proposition as follows to allow induction:%
|
|
135 |
\end{isamarkuptext}%
|
9673
|
136 |
\isacommand{lemma}\ f{\isacharunderscore}incr{\isacharunderscore}lem{\isacharcolon}\ {\isachardoublequote}{\isasymforall}i{\isachardot}\ k\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i{\isachardoublequote}%
|
9670
|
137 |
\begin{isamarkuptxt}%
|
|
138 |
\noindent
|
10363
|
139 |
To perform induction on \isa{k} using \isa{nat{\isacharunderscore}less{\isacharunderscore}induct}, we use
|
|
140 |
the same general induction method as for recursion induction (see
|
9670
|
141 |
\S\ref{sec:recdef-induction}):%
|
|
142 |
\end{isamarkuptxt}%
|
9924
|
143 |
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ k\ rule{\isacharcolon}\ nat{\isacharunderscore}less{\isacharunderscore}induct{\isacharparenright}%
|
9670
|
144 |
\begin{isamarkuptxt}%
|
|
145 |
\noindent
|
|
146 |
which leaves us with the following proof state:
|
10363
|
147 |
\begin{isabelle}%
|
|
148 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}n{\isachardot}\ {\isasymforall}m{\isachardot}\ m\ {\isacharless}\ n\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymforall}i{\isachardot}\ m\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i{\isacharparenright}\ {\isasymLongrightarrow}\isanewline
|
10950
|
149 |
\isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}n{\isachardot}\ }{\isasymforall}i{\isachardot}\ n\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i%
|
9723
|
150 |
\end{isabelle}
|
9792
|
151 |
After stripping the \isa{{\isasymforall}i}, the proof continues with a case
|
10187
|
152 |
distinction on \isa{i}. The case \isa{i\ {\isacharequal}\ {\isadigit{0}}} is trivial and we focus on
|
10363
|
153 |
the other case:%
|
|
154 |
\end{isamarkuptxt}%
|
|
155 |
\isacommand{apply}{\isacharparenleft}rule\ allI{\isacharparenright}\isanewline
|
|
156 |
\isacommand{apply}{\isacharparenleft}case{\isacharunderscore}tac\ i{\isacharparenright}\isanewline
|
|
157 |
\ \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}%
|
|
158 |
\begin{isamarkuptxt}%
|
|
159 |
\begin{isabelle}%
|
|
160 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}n\ i\ nat{\isachardot}\isanewline
|
10950
|
161 |
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymlbrakk}{\isasymforall}m{\isachardot}\ m\ {\isacharless}\ n\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymforall}i{\isachardot}\ m\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i{\isacharparenright}{\isacharsemicolon}\ i\ {\isacharequal}\ Suc\ nat{\isasymrbrakk}\isanewline
|
|
162 |
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }{\isasymLongrightarrow}\ n\ {\isacharequal}\ f\ i\ {\isasymlongrightarrow}\ i\ {\isasymle}\ f\ i%
|
9723
|
163 |
\end{isabelle}%
|
9670
|
164 |
\end{isamarkuptxt}%
|
9924
|
165 |
\isacommand{by}{\isacharparenleft}blast\ intro{\isacharbang}{\isacharcolon}\ f{\isacharunderscore}ax\ Suc{\isacharunderscore}leI\ intro{\isacharcolon}\ le{\isacharunderscore}less{\isacharunderscore}trans{\isacharparenright}%
|
9670
|
166 |
\begin{isamarkuptext}%
|
|
167 |
\noindent
|
11196
|
168 |
If you find the last step puzzling, here are the two lemmas it employs:
|
10878
|
169 |
\begin{isabelle}
|
|
170 |
\isa{m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ Suc\ m\ {\isasymle}\ n}
|
|
171 |
\rulename{Suc_leI}\isanewline
|
|
172 |
\isa{{\isasymlbrakk}i\ {\isasymle}\ j{\isacharsemicolon}\ j\ {\isacharless}\ k{\isasymrbrakk}\ {\isasymLongrightarrow}\ i\ {\isacharless}\ k}
|
|
173 |
\rulename{le_less_trans}
|
|
174 |
\end{isabelle}
|
|
175 |
%
|
9670
|
176 |
The proof goes like this (writing \isa{j} instead of \isa{nat}).
|
9792
|
177 |
Since \isa{i\ {\isacharequal}\ Suc\ j} it suffices to show
|
10878
|
178 |
\hbox{\isa{j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}}},
|
|
179 |
by \isa{Suc{\isacharunderscore}leI}\@. This is
|
9792
|
180 |
proved as follows. From \isa{f{\isacharunderscore}ax} we have \isa{f\ {\isacharparenleft}f\ j{\isacharparenright}\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}}
|
10878
|
181 |
(1) which implies \isa{f\ j\ {\isasymle}\ f\ {\isacharparenleft}f\ j{\isacharparenright}} by the induction hypothesis.
|
|
182 |
Using (1) once more we obtain \isa{f\ j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}} (2) by the transitivity
|
|
183 |
rule \isa{le{\isacharunderscore}less{\isacharunderscore}trans}.
|
9792
|
184 |
Using the induction hypothesis once more we obtain \isa{j\ {\isasymle}\ f\ j}
|
|
185 |
which, together with (2) yields \isa{j\ {\isacharless}\ f\ {\isacharparenleft}Suc\ j{\isacharparenright}} (again by
|
|
186 |
\isa{le{\isacharunderscore}less{\isacharunderscore}trans}).
|
9670
|
187 |
|
|
188 |
This last step shows both the power and the danger of automatic proofs: they
|
|
189 |
will usually not tell you how the proof goes, because it can be very hard to
|
|
190 |
translate the internal proof into a human-readable format. Therefore
|
10878
|
191 |
Chapter~\ref{sec:part2?} introduces a language for writing readable
|
9670
|
192 |
proofs.
|
|
193 |
|
11196
|
194 |
We can now derive the desired \isa{i\ {\isasymle}\ f\ i} from \isa{f{\isacharunderscore}incr{\isacharunderscore}lem}:%
|
9670
|
195 |
\end{isamarkuptext}%
|
9958
|
196 |
\isacommand{lemmas}\ f{\isacharunderscore}incr\ {\isacharequal}\ f{\isacharunderscore}incr{\isacharunderscore}lem{\isacharbrackleft}rule{\isacharunderscore}format{\isacharcomma}\ OF\ refl{\isacharbrackright}%
|
9670
|
197 |
\begin{isamarkuptext}%
|
9698
|
198 |
\noindent
|
10878
|
199 |
The final \isa{refl} gets rid of the premise \isa{{\isacharquery}k\ {\isacharequal}\ f\ {\isacharquery}i}.
|
|
200 |
We could have included this derivation in the original statement of the lemma:%
|
9670
|
201 |
\end{isamarkuptext}%
|
9958
|
202 |
\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}%
|
9670
|
203 |
\begin{isamarkuptext}%
|
11256
|
204 |
\begin{exercise}
|
|
205 |
From the axiom and lemma for \isa{f}, show that \isa{f} is the
|
|
206 |
identity function.
|
|
207 |
\end{exercise}
|
9670
|
208 |
|
11256
|
209 |
Method \isa{induct{\isacharunderscore}tac} can be applied with any rule $r$
|
9792
|
210 |
whose conclusion is of the form ${?}P~?x@1 \dots ?x@n$, in which case the
|
9670
|
211 |
format is
|
9792
|
212 |
\begin{quote}
|
|
213 |
\isacommand{apply}\isa{{\isacharparenleft}induct{\isacharunderscore}tac} $y@1 \dots y@n$ \isa{rule{\isacharcolon}} $r$\isa{{\isacharparenright}}
|
|
214 |
\end{quote}\index{*induct_tac}%
|
|
215 |
where $y@1, \dots, y@n$ are variables in the first subgoal.
|
11256
|
216 |
The conclusion of $r$ can even be an (iterated) conjunction of formulae of
|
|
217 |
the above form in which case the application is
|
9792
|
218 |
\begin{quote}
|
|
219 |
\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
|
220 |
\end{quote}
|
|
221 |
|
11256
|
222 |
A further useful induction rule is \isa{length{\isacharunderscore}induct},
|
|
223 |
induction on the length of a list\indexbold{*length_induct}
|
|
224 |
\begin{isabelle}%
|
|
225 |
\ \ \ \ \ {\isacharparenleft}{\isasymAnd}xs{\isachardot}\ {\isasymforall}ys{\isachardot}\ length\ ys\ {\isacharless}\ length\ xs\ {\isasymlongrightarrow}\ P\ ys\ {\isasymLongrightarrow}\ P\ xs{\isacharparenright}\ {\isasymLongrightarrow}\ P\ xs%
|
|
226 |
\end{isabelle}
|
|
227 |
which is a special case of \isa{measure{\isacharunderscore}induct}
|
|
228 |
\begin{isabelle}%
|
|
229 |
\ \ \ \ \ {\isacharparenleft}{\isasymAnd}x{\isachardot}\ {\isasymforall}y{\isachardot}\ f\ y\ {\isacharless}\ f\ x\ {\isasymlongrightarrow}\ P\ y\ {\isasymLongrightarrow}\ P\ x{\isacharparenright}\ {\isasymLongrightarrow}\ P\ a%
|
|
230 |
\end{isabelle}
|
|
231 |
where \isa{f} may be any function into type \isa{nat}.%
|
9698
|
232 |
\end{isamarkuptext}%
|
|
233 |
%
|
10878
|
234 |
\isamarkupsubsection{Derivation of New Induction Schemas%
|
10397
|
235 |
}
|
9698
|
236 |
%
|
|
237 |
\begin{isamarkuptext}%
|
|
238 |
\label{sec:derive-ind}
|
|
239 |
Induction schemas are ordinary theorems and you can derive new ones
|
|
240 |
whenever you wish. This section shows you how to, using the example
|
9924
|
241 |
of \isa{nat{\isacharunderscore}less{\isacharunderscore}induct}. Assume we only have structural induction
|
9698
|
242 |
available for \isa{nat} and want to derive complete induction. This
|
|
243 |
requires us to generalize the statement first:%
|
|
244 |
\end{isamarkuptext}%
|
9792
|
245 |
\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
|
9698
|
246 |
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ n{\isacharparenright}%
|
|
247 |
\begin{isamarkuptxt}%
|
|
248 |
\noindent
|
11196
|
249 |
The base case is vacuously true. For the induction step (\isa{m\ {\isacharless}\ Suc\ n}) we distinguish two cases: case \isa{m\ {\isacharless}\ n} is true by induction
|
9933
|
250 |
hypothesis and case \isa{m\ {\isacharequal}\ n} follows from the assumption, again using
|
9698
|
251 |
the induction hypothesis:%
|
|
252 |
\end{isamarkuptxt}%
|
11196
|
253 |
\ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
|
9933
|
254 |
\isacommand{by}{\isacharparenleft}blast\ elim{\isacharcolon}less{\isacharunderscore}SucE{\isacharparenright}%
|
9698
|
255 |
\begin{isamarkuptext}%
|
|
256 |
\noindent
|
11196
|
257 |
The elimination rule \isa{less{\isacharunderscore}SucE} expresses the case distinction:
|
9698
|
258 |
\begin{isabelle}%
|
10696
|
259 |
\ \ \ \ \ {\isasymlbrakk}m\ {\isacharless}\ Suc\ n{\isacharsemicolon}\ m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ P{\isacharsemicolon}\ m\ {\isacharequal}\ n\ {\isasymLongrightarrow}\ P{\isasymrbrakk}\ {\isasymLongrightarrow}\ P%
|
9924
|
260 |
\end{isabelle}
|
9698
|
261 |
|
|
262 |
Now it is straightforward to derive the original version of
|
11256
|
263 |
\isa{nat{\isacharunderscore}less{\isacharunderscore}induct} by manipulating the conclusion of the above
|
|
264 |
lemma: instantiate \isa{n} by \isa{Suc\ n} and \isa{m} by \isa{n}
|
|
265 |
and remove the trivial condition \isa{n\ {\isacharless}\ Suc\ n}. Fortunately, this
|
9698
|
266 |
happens automatically when we add the lemma as a new premise to the
|
|
267 |
desired goal:%
|
|
268 |
\end{isamarkuptext}%
|
9924
|
269 |
\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
|
9698
|
270 |
\isacommand{by}{\isacharparenleft}insert\ induct{\isacharunderscore}lem{\isacharcomma}\ blast{\isacharparenright}%
|
|
271 |
\begin{isamarkuptext}%
|
10396
|
272 |
Finally we should remind the reader that HOL already provides the mother of
|
|
273 |
all inductions, well-founded induction (see \S\ref{sec:Well-founded}). For
|
10878
|
274 |
example theorem \isa{nat{\isacharunderscore}less{\isacharunderscore}induct} is
|
10396
|
275 |
a special case of \isa{wf{\isacharunderscore}induct} where \isa{r} is \isa{{\isacharless}} on
|
10878
|
276 |
\isa{nat}. The details can be found in theory \isa{Wellfounded_Recursion}.%
|
9670
|
277 |
\end{isamarkuptext}%
|
9722
|
278 |
\end{isabellebody}%
|
9670
|
279 |
%%% Local Variables:
|
|
280 |
%%% mode: latex
|
|
281 |
%%% TeX-master: "root"
|
|
282 |
%%% End:
|