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