| 13999 |      1 | %
 | 
|  |      2 | \begin{isabellebody}%
 | 
|  |      3 | \def\isabellecontext{Induction}%
 | 
|  |      4 | \isamarkupfalse%
 | 
|  |      5 | %
 | 
|  |      6 | \isamarkupsection{Case distinction and induction \label{sec:Induct}%
 | 
|  |      7 | }
 | 
|  |      8 | \isamarkuptrue%
 | 
|  |      9 | %
 | 
|  |     10 | \begin{isamarkuptext}%
 | 
|  |     11 | Computer science applications abound with inductively defined
 | 
|  |     12 | structures, which is why we treat them in more detail. HOL already
 | 
|  |     13 | comes with a datatype of lists with the two constructors \isa{Nil}
 | 
|  |     14 | and \isa{Cons}. \isa{Nil} is written \isa{{\isacharbrackleft}{\isacharbrackright}} and \isa{Cons\ x\ xs} is written \isa{x\ {\isacharhash}\ xs}.%
 | 
|  |     15 | \end{isamarkuptext}%
 | 
|  |     16 | \isamarkuptrue%
 | 
|  |     17 | %
 | 
|  |     18 | \isamarkupsubsection{Case distinction\label{sec:CaseDistinction}%
 | 
|  |     19 | }
 | 
|  |     20 | \isamarkuptrue%
 | 
|  |     21 | %
 | 
|  |     22 | \begin{isamarkuptext}%
 | 
|  |     23 | We have already met the \isa{cases} method for performing
 | 
|  |     24 | binary case splits. Here is another example:%
 | 
|  |     25 | \end{isamarkuptext}%
 | 
|  |     26 | \isamarkuptrue%
 | 
|  |     27 | \isacommand{lemma}\ {\isachardoublequote}{\isasymnot}\ A\ {\isasymor}\ A{\isachardoublequote}\isanewline
 | 
|  |     28 | \isamarkupfalse%
 | 
| 16459 |     29 | \isacommand{proof}\ cases\isanewline
 | 
|  |     30 | \ \ \isamarkupfalse%
 | 
|  |     31 | \isacommand{assume}\ {\isachardoublequote}A{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |     32 | \isacommand{thus}\ {\isacharquery}thesis\ \isamarkupfalse%
 | 
|  |     33 | \isacommand{{\isachardot}{\isachardot}}\isanewline
 | 
| 13999 |     34 | \isamarkupfalse%
 | 
| 16459 |     35 | \isacommand{next}\isanewline
 | 
|  |     36 | \ \ \isamarkupfalse%
 | 
|  |     37 | \isacommand{assume}\ {\isachardoublequote}{\isasymnot}\ A{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |     38 | \isacommand{thus}\ {\isacharquery}thesis\ \isamarkupfalse%
 | 
|  |     39 | \isacommand{{\isachardot}{\isachardot}}\isanewline
 | 
| 13999 |     40 | \isamarkupfalse%
 | 
| 16459 |     41 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |     42 | %
 | 
|  |     43 | \begin{isamarkuptext}%
 | 
|  |     44 | \noindent The two cases must come in this order because \isa{cases} merely abbreviates \isa{{\isacharparenleft}rule\ case{\isacharunderscore}split{\isacharunderscore}thm{\isacharparenright}} where
 | 
|  |     45 | \isa{case{\isacharunderscore}split{\isacharunderscore}thm} is \isa{{\isasymlbrakk}{\isacharquery}P\ {\isasymLongrightarrow}\ {\isacharquery}Q{\isacharsemicolon}\ {\isasymnot}\ {\isacharquery}P\ {\isasymLongrightarrow}\ {\isacharquery}Q{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharquery}Q}. If we reverse
 | 
|  |     46 | the order of the two cases in the proof, the first case would prove
 | 
|  |     47 | \isa{{\isasymnot}\ A\ {\isasymLongrightarrow}\ {\isasymnot}\ A\ {\isasymor}\ A} which would solve the first premise of
 | 
|  |     48 | \isa{case{\isacharunderscore}split{\isacharunderscore}thm}, instantiating \isa{{\isacharquery}P} with \isa{{\isasymnot}\ A}, thus making the second premise \isa{{\isasymnot}\ {\isasymnot}\ A\ {\isasymLongrightarrow}\ {\isasymnot}\ A\ {\isasymor}\ A}.
 | 
|  |     49 | Therefore the order of subgoals is not always completely arbitrary.
 | 
|  |     50 | 
 | 
|  |     51 | The above proof is appropriate if \isa{A} is textually small.
 | 
|  |     52 | However, if \isa{A} is large, we do not want to repeat it. This can
 | 
|  |     53 | be avoided by the following idiom%
 | 
|  |     54 | \end{isamarkuptext}%
 | 
|  |     55 | \isamarkuptrue%
 | 
|  |     56 | \isacommand{lemma}\ {\isachardoublequote}{\isasymnot}\ A\ {\isasymor}\ A{\isachardoublequote}\isanewline
 | 
|  |     57 | \isamarkupfalse%
 | 
| 16459 |     58 | \isacommand{proof}\ {\isacharparenleft}cases\ {\isachardoublequote}A{\isachardoublequote}{\isacharparenright}\isanewline
 | 
|  |     59 | \ \ \isamarkupfalse%
 | 
|  |     60 | \isacommand{case}\ True\ \isamarkupfalse%
 | 
|  |     61 | \isacommand{thus}\ {\isacharquery}thesis\ \isamarkupfalse%
 | 
|  |     62 | \isacommand{{\isachardot}{\isachardot}}\isanewline
 | 
| 13999 |     63 | \isamarkupfalse%
 | 
| 16459 |     64 | \isacommand{next}\isanewline
 | 
|  |     65 | \ \ \isamarkupfalse%
 | 
|  |     66 | \isacommand{case}\ False\ \isamarkupfalse%
 | 
|  |     67 | \isacommand{thus}\ {\isacharquery}thesis\ \isamarkupfalse%
 | 
|  |     68 | \isacommand{{\isachardot}{\isachardot}}\isanewline
 | 
| 13999 |     69 | \isamarkupfalse%
 | 
| 16459 |     70 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |     71 | %
 | 
|  |     72 | \begin{isamarkuptext}%
 | 
|  |     73 | \noindent which is like the previous proof but instantiates
 | 
|  |     74 | \isa{{\isacharquery}P} right away with \isa{A}. Thus we could prove the two
 | 
|  |     75 | cases in any order. The phrase `\isakeyword{case}~\isa{True}'
 | 
|  |     76 | abbreviates `\isakeyword{assume}~\isa{True{\isacharcolon}\ A}' and analogously for
 | 
|  |     77 | \isa{False} and \isa{{\isasymnot}\ A}.
 | 
|  |     78 | 
 | 
|  |     79 | The same game can be played with other datatypes, for example lists,
 | 
|  |     80 | where \isa{tl} is the tail of a list, and \isa{length} returns a
 | 
|  |     81 | natural number (remember: $0-1=0$):%
 | 
|  |     82 | \end{isamarkuptext}%
 | 
|  |     83 | \isamarkuptrue%
 | 
|  |     84 | \isamarkupfalse%
 | 
|  |     85 | \isacommand{lemma}\ {\isachardoublequote}length{\isacharparenleft}tl\ xs{\isacharparenright}\ {\isacharequal}\ length\ xs\ {\isacharminus}\ {\isadigit{1}}{\isachardoublequote}\isanewline
 | 
|  |     86 | \isamarkupfalse%
 | 
| 16459 |     87 | \isacommand{proof}\ {\isacharparenleft}cases\ xs{\isacharparenright}\isanewline
 | 
|  |     88 | \ \ \isamarkupfalse%
 | 
|  |     89 | \isacommand{case}\ Nil\ \isamarkupfalse%
 | 
|  |     90 | \isacommand{thus}\ {\isacharquery}thesis\ \isamarkupfalse%
 | 
|  |     91 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |     92 | \isamarkupfalse%
 | 
| 16459 |     93 | \isacommand{next}\isanewline
 | 
|  |     94 | \ \ \isamarkupfalse%
 | 
|  |     95 | \isacommand{case}\ Cons\ \isamarkupfalse%
 | 
|  |     96 | \isacommand{thus}\ {\isacharquery}thesis\ \isamarkupfalse%
 | 
|  |     97 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |     98 | \isamarkupfalse%
 | 
| 16459 |     99 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    100 | %
 | 
|  |    101 | \begin{isamarkuptext}%
 | 
|  |    102 | \noindent Here `\isakeyword{case}~\isa{Nil}' abbreviates
 | 
|  |    103 | `\isakeyword{assume}~\isa{Nil{\isacharcolon}}~\isa{xs\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}}' and
 | 
|  |    104 | `\isakeyword{case}~\isa{Cons}'
 | 
|  |    105 | abbreviates `\isakeyword{fix}~\isa{{\isacharquery}\ {\isacharquery}{\isacharquery}}
 | 
|  |    106 | \isakeyword{assume}~\isa{Cons{\isacharcolon}}~\isa{xs\ {\isacharequal}\ {\isacharquery}\ {\isacharhash}\ {\isacharquery}{\isacharquery}}'
 | 
|  |    107 | where \isa{{\isacharquery}} and \isa{{\isacharquery}{\isacharquery}}
 | 
|  |    108 | stand for variable names that have been chosen by the system.
 | 
|  |    109 | Therefore we cannot refer to them.
 | 
|  |    110 | Luckily, this proof is simple enough we do not need to refer to them.
 | 
|  |    111 | However, sometimes one may have to. Hence Isar offers a simple scheme for
 | 
|  |    112 | naming those variables: replace the anonymous \isa{Cons} by
 | 
|  |    113 | \isa{{\isacharparenleft}Cons\ y\ ys{\isacharparenright}}, which abbreviates `\isakeyword{fix}~\isa{y\ ys}
 | 
|  |    114 | \isakeyword{assume}~\isa{Cons{\isacharcolon}}~\isa{xs\ {\isacharequal}\ y\ {\isacharhash}\ ys}'.
 | 
|  |    115 | In each \isakeyword{case} the assumption can be
 | 
|  |    116 | referred to inside the proof by the name of the constructor. In
 | 
|  |    117 | Section~\ref{sec:full-Ind} below we will come across an example
 | 
|  |    118 | of this.%
 | 
|  |    119 | \end{isamarkuptext}%
 | 
|  |    120 | \isamarkuptrue%
 | 
|  |    121 | %
 | 
|  |    122 | \isamarkupsubsection{Structural induction%
 | 
|  |    123 | }
 | 
|  |    124 | \isamarkuptrue%
 | 
|  |    125 | %
 | 
|  |    126 | \begin{isamarkuptext}%
 | 
|  |    127 | We start with an inductive proof where both cases are proved automatically:%
 | 
|  |    128 | \end{isamarkuptext}%
 | 
|  |    129 | \isamarkuptrue%
 | 
| 16522 |    130 | \isacommand{lemma}\ {\isachardoublequote}{\isadigit{2}}\ {\isacharasterisk}\ {\isacharparenleft}{\isasymSum}i{\isacharcolon}{\isacharcolon}nat{\isasymle}n{\isachardot}\ i{\isacharparenright}\ {\isacharequal}\ n{\isacharasterisk}{\isacharparenleft}n{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isachardoublequote}\isanewline
 | 
| 13999 |    131 | \isamarkupfalse%
 | 
| 16459 |    132 | \isacommand{by}\ {\isacharparenleft}induct\ n{\isacharcomma}\ simp{\isacharunderscore}all{\isacharparenright}\isamarkupfalse%
 | 
| 13999 |    133 | %
 | 
|  |    134 | \begin{isamarkuptext}%
 | 
| 15909 |    135 | \noindent The constraint \isa{{\isacharcolon}{\isacharcolon}nat} is needed because all of
 | 
|  |    136 | the operations involved are overloaded.
 | 
|  |    137 | 
 | 
|  |    138 | If we want to expose more of the structure of the
 | 
| 13999 |    139 | proof, we can use pattern matching to avoid having to repeat the goal
 | 
|  |    140 | statement:%
 | 
|  |    141 | \end{isamarkuptext}%
 | 
|  |    142 | \isamarkuptrue%
 | 
| 16522 |    143 | \isacommand{lemma}\ {\isachardoublequote}{\isadigit{2}}\ {\isacharasterisk}\ {\isacharparenleft}{\isasymSum}i{\isacharcolon}{\isacharcolon}nat{\isasymle}n{\isachardot}\ i{\isacharparenright}\ {\isacharequal}\ n{\isacharasterisk}{\isacharparenleft}n{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isachardoublequote}\ {\isacharparenleft}\isakeyword{is}\ {\isachardoublequote}{\isacharquery}P\ n{\isachardoublequote}{\isacharparenright}\isanewline
 | 
| 15909 |    144 | \isamarkupfalse%
 | 
| 16459 |    145 | \isacommand{proof}\ {\isacharparenleft}induct\ n{\isacharparenright}\isanewline
 | 
|  |    146 | \ \ \isamarkupfalse%
 | 
|  |    147 | \isacommand{show}\ {\isachardoublequote}{\isacharquery}P\ {\isadigit{0}}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    148 | \isacommand{by}\ simp\isanewline
 | 
| 15909 |    149 | \isamarkupfalse%
 | 
| 16459 |    150 | \isacommand{next}\isanewline
 | 
|  |    151 | \ \ \isamarkupfalse%
 | 
|  |    152 | \isacommand{fix}\ n\ \isamarkupfalse%
 | 
|  |    153 | \isacommand{assume}\ {\isachardoublequote}{\isacharquery}P\ n{\isachardoublequote}\isanewline
 | 
|  |    154 | \ \ \isamarkupfalse%
 | 
|  |    155 | \isacommand{thus}\ {\isachardoublequote}{\isacharquery}P{\isacharparenleft}Suc\ n{\isacharparenright}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    156 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |    157 | \isamarkupfalse%
 | 
| 16459 |    158 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    159 | %
 | 
|  |    160 | \begin{isamarkuptext}%
 | 
|  |    161 | \noindent We could refine this further to show more of the equational
 | 
|  |    162 | proof. Instead we explore the same avenue as for case distinctions:
 | 
|  |    163 | introducing context via the \isakeyword{case} command:%
 | 
|  |    164 | \end{isamarkuptext}%
 | 
|  |    165 | \isamarkuptrue%
 | 
| 16522 |    166 | \isacommand{lemma}\ {\isachardoublequote}{\isadigit{2}}\ {\isacharasterisk}\ {\isacharparenleft}{\isasymSum}i{\isacharcolon}{\isacharcolon}nat\ {\isasymle}\ n{\isachardot}\ i{\isacharparenright}\ {\isacharequal}\ n{\isacharasterisk}{\isacharparenleft}n{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isachardoublequote}\isanewline
 | 
| 15909 |    167 | \isamarkupfalse%
 | 
| 16459 |    168 | \isacommand{proof}\ {\isacharparenleft}induct\ n{\isacharparenright}\isanewline
 | 
|  |    169 | \ \ \isamarkupfalse%
 | 
|  |    170 | \isacommand{case}\ {\isadigit{0}}\ \isamarkupfalse%
 | 
|  |    171 | \isacommand{show}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    172 | \isacommand{by}\ simp\isanewline
 | 
| 15909 |    173 | \isamarkupfalse%
 | 
| 16459 |    174 | \isacommand{next}\isanewline
 | 
|  |    175 | \ \ \isamarkupfalse%
 | 
|  |    176 | \isacommand{case}\ Suc\ \isamarkupfalse%
 | 
|  |    177 | \isacommand{thus}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    178 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |    179 | \isamarkupfalse%
 | 
| 16459 |    180 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    181 | %
 | 
|  |    182 | \begin{isamarkuptext}%
 | 
|  |    183 | \noindent The implicitly defined \isa{{\isacharquery}case} refers to the
 | 
|  |    184 | corresponding case to be proved, i.e.\ \isa{{\isacharquery}P\ {\isadigit{0}}} in the first case and
 | 
|  |    185 | \isa{{\isacharquery}P{\isacharparenleft}Suc\ n{\isacharparenright}} in the second case. Context \isakeyword{case}~\isa{{\isadigit{0}}} is
 | 
|  |    186 | empty whereas \isakeyword{case}~\isa{Suc} assumes \isa{{\isacharquery}P\ n}. Again we
 | 
|  |    187 | have the same problem as with case distinctions: we cannot refer to an anonymous \isa{n}
 | 
|  |    188 | in the induction step because it has not been introduced via \isakeyword{fix}
 | 
|  |    189 | (in contrast to the previous proof). The solution is the one outlined for
 | 
|  |    190 | \isa{Cons} above: replace \isa{Suc} by \isa{{\isacharparenleft}Suc\ i{\isacharparenright}}:%
 | 
|  |    191 | \end{isamarkuptext}%
 | 
|  |    192 | \isamarkuptrue%
 | 
|  |    193 | \isacommand{lemma}\ \isakeyword{fixes}\ n{\isacharcolon}{\isacharcolon}nat\ \isakeyword{shows}\ {\isachardoublequote}n\ {\isacharless}\ n{\isacharasterisk}n\ {\isacharplus}\ {\isadigit{1}}{\isachardoublequote}\isanewline
 | 
|  |    194 | \isamarkupfalse%
 | 
| 16459 |    195 | \isacommand{proof}\ {\isacharparenleft}induct\ n{\isacharparenright}\isanewline
 | 
|  |    196 | \ \ \isamarkupfalse%
 | 
|  |    197 | \isacommand{case}\ {\isadigit{0}}\ \isamarkupfalse%
 | 
|  |    198 | \isacommand{show}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    199 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |    200 | \isamarkupfalse%
 | 
| 16459 |    201 | \isacommand{next}\isanewline
 | 
|  |    202 | \ \ \isamarkupfalse%
 | 
|  |    203 | \isacommand{case}\ {\isacharparenleft}Suc\ i{\isacharparenright}\ \isamarkupfalse%
 | 
|  |    204 | \isacommand{thus}\ {\isachardoublequote}Suc\ i\ {\isacharless}\ Suc\ i\ {\isacharasterisk}\ Suc\ i\ {\isacharplus}\ {\isadigit{1}}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    205 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |    206 | \isamarkupfalse%
 | 
| 16459 |    207 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    208 | %
 | 
|  |    209 | \begin{isamarkuptext}%
 | 
|  |    210 | \noindent Of course we could again have written
 | 
|  |    211 | \isakeyword{thus}~\isa{{\isacharquery}case} instead of giving the term explicitly
 | 
|  |    212 | but we wanted to use \isa{i} somewhere.%
 | 
|  |    213 | \end{isamarkuptext}%
 | 
|  |    214 | \isamarkuptrue%
 | 
|  |    215 | %
 | 
|  |    216 | \isamarkupsubsection{Induction formulae involving \isa{{\isasymAnd}} or \isa{{\isasymLongrightarrow}}\label{sec:full-Ind}%
 | 
|  |    217 | }
 | 
|  |    218 | \isamarkuptrue%
 | 
|  |    219 | %
 | 
|  |    220 | \begin{isamarkuptext}%
 | 
|  |    221 | Let us now consider the situation where the goal to be proved contains
 | 
|  |    222 | \isa{{\isasymAnd}} or \isa{{\isasymLongrightarrow}}, say \isa{{\isasymAnd}x{\isachardot}\ P\ x\ {\isasymLongrightarrow}\ Q\ x} --- motivation and a
 | 
|  |    223 | real example follow shortly.  This means that in each case of the induction,
 | 
|  |    224 | \isa{{\isacharquery}case} would be of the form \isa{{\isasymAnd}x{\isachardot}\ P{\isacharprime}\ x\ {\isasymLongrightarrow}\ Q{\isacharprime}\ x}.  Thus the
 | 
|  |    225 | first proof steps will be the canonical ones, fixing \isa{x} and assuming
 | 
|  |    226 | \isa{P{\isacharprime}\ x}. To avoid this tedium, induction performs these steps
 | 
|  |    227 | automatically: for example in case \isa{{\isacharparenleft}Suc\ n{\isacharparenright}}, \isa{{\isacharquery}case} is only
 | 
|  |    228 | \isa{Q{\isacharprime}\ x} whereas the assumptions (named \isa{Suc}!) contain both the
 | 
|  |    229 | usual induction hypothesis \emph{and} \isa{P{\isacharprime}\ x}.
 | 
|  |    230 | It should be clear how this generalises to more complex formulae.
 | 
|  |    231 | 
 | 
|  |    232 | As an example we will now prove complete induction via
 | 
|  |    233 | structural induction.%
 | 
|  |    234 | \end{isamarkuptext}%
 | 
|  |    235 | \isamarkuptrue%
 | 
|  |    236 | \isacommand{lemma}\ \isakeyword{assumes}\ A{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isasymAnd}n{\isachardot}\ {\isacharparenleft}{\isasymAnd}m{\isachardot}\ m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ P\ m{\isacharparenright}\ {\isasymLongrightarrow}\ P\ n{\isacharparenright}{\isachardoublequote}\isanewline
 | 
|  |    237 | \ \ \isakeyword{shows}\ {\isachardoublequote}P{\isacharparenleft}n{\isacharcolon}{\isacharcolon}nat{\isacharparenright}{\isachardoublequote}\isanewline
 | 
|  |    238 | \isamarkupfalse%
 | 
| 16459 |    239 | \isacommand{proof}\ {\isacharparenleft}rule\ A{\isacharparenright}\isanewline
 | 
|  |    240 | \ \ \isamarkupfalse%
 | 
|  |    241 | \isacommand{show}\ {\isachardoublequote}{\isasymAnd}m{\isachardot}\ m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ P\ m{\isachardoublequote}\isanewline
 | 
|  |    242 | \ \ \isamarkupfalse%
 | 
|  |    243 | \isacommand{proof}\ {\isacharparenleft}induct\ n{\isacharparenright}\isanewline
 | 
|  |    244 | \ \ \ \ \isamarkupfalse%
 | 
|  |    245 | \isacommand{case}\ {\isadigit{0}}\ \isamarkupfalse%
 | 
|  |    246 | \isacommand{thus}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    247 | \isacommand{by}\ simp\isanewline
 | 
|  |    248 | \ \ \isamarkupfalse%
 | 
|  |    249 | \isacommand{next}\isanewline
 | 
|  |    250 | \ \ \ \ \isamarkupfalse%
 | 
|  |    251 | \isacommand{case}\ {\isacharparenleft}Suc\ n{\isacharparenright}\ \ \ %
 | 
|  |    252 | \isamarkupcmt{\isakeyword{fix} \isa{m} \isakeyword{assume} \isa{Suc}: \isa{{\isachardoublequote}{\isacharquery}m\ {\isacharless}\ n\ {\isasymLongrightarrow}\ P\ {\isacharquery}m{\isachardoublequote}} \isa{{\isachardoublequote}m\ {\isacharless}\ Suc\ n{\isachardoublequote}}%
 | 
|  |    253 | }
 | 
|  |    254 | \isanewline
 | 
|  |    255 | \ \ \ \ \isamarkupfalse%
 | 
|  |    256 | \isacommand{show}\ {\isacharquery}case\ \ \ \ %
 | 
|  |    257 | \isamarkupcmt{\isa{P\ m}%
 | 
|  |    258 | }
 | 
|  |    259 | \isanewline
 | 
|  |    260 | \ \ \ \ \isamarkupfalse%
 | 
|  |    261 | \isacommand{proof}\ cases\isanewline
 | 
|  |    262 | \ \ \ \ \ \ \isamarkupfalse%
 | 
|  |    263 | \isacommand{assume}\ eq{\isacharcolon}\ {\isachardoublequote}m\ {\isacharequal}\ n{\isachardoublequote}\isanewline
 | 
|  |    264 | \ \ \ \ \ \ \isamarkupfalse%
 | 
|  |    265 | \isacommand{from}\ Suc\ \isakeyword{and}\ A\ \isamarkupfalse%
 | 
|  |    266 | \isacommand{have}\ {\isachardoublequote}P\ n{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    267 | \isacommand{by}\ blast\isanewline
 | 
|  |    268 | \ \ \ \ \ \ \isamarkupfalse%
 | 
|  |    269 | \isacommand{with}\ eq\ \isamarkupfalse%
 | 
|  |    270 | \isacommand{show}\ {\isachardoublequote}P\ m{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    271 | \isacommand{by}\ simp\isanewline
 | 
|  |    272 | \ \ \ \ \isamarkupfalse%
 | 
|  |    273 | \isacommand{next}\isanewline
 | 
|  |    274 | \ \ \ \ \ \ \isamarkupfalse%
 | 
|  |    275 | \isacommand{assume}\ {\isachardoublequote}m\ {\isasymnoteq}\ n{\isachardoublequote}\isanewline
 | 
|  |    276 | \ \ \ \ \ \ \isamarkupfalse%
 | 
|  |    277 | \isacommand{with}\ Suc\ \isamarkupfalse%
 | 
|  |    278 | \isacommand{have}\ {\isachardoublequote}m\ {\isacharless}\ n{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    279 | \isacommand{by}\ arith\isanewline
 | 
|  |    280 | \ \ \ \ \ \ \isamarkupfalse%
 | 
|  |    281 | \isacommand{thus}\ {\isachardoublequote}P\ m{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    282 | \isacommand{by}{\isacharparenleft}rule\ Suc{\isacharparenright}\isanewline
 | 
|  |    283 | \ \ \ \ \isamarkupfalse%
 | 
|  |    284 | \isacommand{qed}\isanewline
 | 
|  |    285 | \ \ \isamarkupfalse%
 | 
|  |    286 | \isacommand{qed}\isanewline
 | 
| 13999 |    287 | \isamarkupfalse%
 | 
| 16459 |    288 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    289 | %
 | 
|  |    290 | \begin{isamarkuptext}%
 | 
|  |    291 | \noindent Given the explanations above and the comments in the
 | 
|  |    292 | proof text (only necessary for novices), the proof should be quite
 | 
|  |    293 | readable.
 | 
|  |    294 | 
 | 
|  |    295 | The statement of the lemma is interesting because it deviates from the style in
 | 
|  |    296 | the Tutorial~\cite{LNCS2283}, which suggests to introduce \isa{{\isasymforall}} or
 | 
|  |    297 | \isa{{\isasymlongrightarrow}} into a theorem to strengthen it for induction. In Isar
 | 
|  |    298 | proofs we can use \isa{{\isasymAnd}} and \isa{{\isasymLongrightarrow}} instead. This simplifies the
 | 
|  |    299 | proof and means we do not have to convert between the two kinds of
 | 
|  |    300 | connectives.
 | 
|  |    301 | 
 | 
|  |    302 | Note that in a nested induction over the same data type, the inner
 | 
|  |    303 | case labels hide the outer ones of the same name. If you want to refer
 | 
|  |    304 | to the outer ones inside, you need to name them on the outside, e.g.\
 | 
|  |    305 | \isakeyword{note}~\isa{outer{\isacharunderscore}IH\ {\isacharequal}\ Suc}.%
 | 
|  |    306 | \end{isamarkuptext}%
 | 
|  |    307 | \isamarkuptrue%
 | 
|  |    308 | %
 | 
|  |    309 | \isamarkupsubsection{Rule induction%
 | 
|  |    310 | }
 | 
|  |    311 | \isamarkuptrue%
 | 
|  |    312 | %
 | 
|  |    313 | \begin{isamarkuptext}%
 | 
|  |    314 | HOL also supports inductively defined sets. See \cite{LNCS2283}
 | 
|  |    315 | for details. As an example we define our own version of the reflexive
 | 
|  |    316 | transitive closure of a relation --- HOL provides a predefined one as well.%
 | 
|  |    317 | \end{isamarkuptext}%
 | 
|  |    318 | \isamarkuptrue%
 | 
|  |    319 | \isacommand{consts}\ rtc\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}a{\isacharparenright}set\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isasymtimes}\ {\isacharprime}a{\isacharparenright}set{\isachardoublequote}\ \ \ {\isacharparenleft}{\isachardoublequote}{\isacharunderscore}{\isacharasterisk}{\isachardoublequote}\ {\isacharbrackleft}{\isadigit{1}}{\isadigit{0}}{\isadigit{0}}{\isadigit{0}}{\isacharbrackright}\ {\isadigit{9}}{\isadigit{9}}{\isadigit{9}}{\isacharparenright}\isanewline
 | 
|  |    320 | \isamarkupfalse%
 | 
|  |    321 | \isacommand{inductive}\ {\isachardoublequote}r{\isacharasterisk}{\isachardoublequote}\isanewline
 | 
|  |    322 | \isakeyword{intros}\isanewline
 | 
|  |    323 | refl{\isacharcolon}\ \ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}x{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\isanewline
 | 
|  |    324 | step{\isacharcolon}\ \ {\isachardoublequote}{\isasymlbrakk}\ {\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isasymin}\ r{\isacharsemicolon}\ {\isacharparenleft}y{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharparenleft}x{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\isamarkupfalse%
 | 
|  |    325 | %
 | 
|  |    326 | \begin{isamarkuptext}%
 | 
|  |    327 | \noindent
 | 
|  |    328 | First the constant is declared as a function on binary
 | 
|  |    329 | relations (with concrete syntax \isa{r{\isacharasterisk}} instead of \isa{rtc\ r}), then the defining clauses are given. We will now prove that
 | 
|  |    330 | \isa{r{\isacharasterisk}} is indeed transitive:%
 | 
|  |    331 | \end{isamarkuptext}%
 | 
|  |    332 | \isamarkuptrue%
 | 
|  |    333 | \isacommand{lemma}\ \isakeyword{assumes}\ A{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\ \isakeyword{shows}\ {\isachardoublequote}{\isacharparenleft}y{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}\ {\isasymLongrightarrow}\ {\isacharparenleft}x{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\isanewline
 | 
|  |    334 | \isamarkupfalse%
 | 
| 16459 |    335 | \isacommand{using}\ A\isanewline
 | 
| 13999 |    336 | \isamarkupfalse%
 | 
| 16459 |    337 | \isacommand{proof}\ induct\isanewline
 | 
|  |    338 | \ \ \isamarkupfalse%
 | 
|  |    339 | \isacommand{case}\ refl\ \isamarkupfalse%
 | 
|  |    340 | \isacommand{thus}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    341 | \isacommand{{\isachardot}}\isanewline
 | 
| 13999 |    342 | \isamarkupfalse%
 | 
| 16459 |    343 | \isacommand{next}\isanewline
 | 
|  |    344 | \ \ \isamarkupfalse%
 | 
|  |    345 | \isacommand{case}\ step\ \isamarkupfalse%
 | 
|  |    346 | \isacommand{thus}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    347 | \isacommand{by}{\isacharparenleft}blast\ intro{\isacharcolon}\ rtc{\isachardot}step{\isacharparenright}\isanewline
 | 
| 13999 |    348 | \isamarkupfalse%
 | 
| 16459 |    349 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    350 | %
 | 
|  |    351 | \begin{isamarkuptext}%
 | 
|  |    352 | \noindent Rule induction is triggered by a fact $(x_1,\dots,x_n)
 | 
|  |    353 | \in R$ piped into the proof, here \isakeyword{using}~\isa{A}. The
 | 
|  |    354 | proof itself follows the inductive definition very
 | 
|  |    355 | closely: there is one case for each rule, and it has the same name as
 | 
|  |    356 | the rule, analogous to structural induction.
 | 
|  |    357 | 
 | 
|  |    358 | However, this proof is rather terse. Here is a more readable version:%
 | 
|  |    359 | \end{isamarkuptext}%
 | 
|  |    360 | \isamarkuptrue%
 | 
|  |    361 | \isacommand{lemma}\ \isakeyword{assumes}\ A{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\ \isakeyword{and}\ B{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}y{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\isanewline
 | 
|  |    362 | \ \ \isakeyword{shows}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\isanewline
 | 
|  |    363 | \isamarkupfalse%
 | 
| 16459 |    364 | \isacommand{proof}\ {\isacharminus}\isanewline
 | 
|  |    365 | \ \ \isamarkupfalse%
 | 
|  |    366 | \isacommand{from}\ A\ B\ \isamarkupfalse%
 | 
|  |    367 | \isacommand{show}\ {\isacharquery}thesis\isanewline
 | 
|  |    368 | \ \ \isamarkupfalse%
 | 
|  |    369 | \isacommand{proof}\ induct\isanewline
 | 
|  |    370 | \ \ \ \ \isamarkupfalse%
 | 
|  |    371 | \isacommand{fix}\ x\ \isamarkupfalse%
 | 
|  |    372 | \isacommand{assume}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\ \ %
 | 
|  |    373 | \isamarkupcmt{\isa{B}[\isa{y} := \isa{x}]%
 | 
|  |    374 | }
 | 
|  |    375 | \isanewline
 | 
|  |    376 | \ \ \ \ \isamarkupfalse%
 | 
|  |    377 | \isacommand{thus}\ {\isachardoublequote}{\isacharparenleft}x{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    378 | \isacommand{{\isachardot}}\isanewline
 | 
|  |    379 | \ \ \isamarkupfalse%
 | 
|  |    380 | \isacommand{next}\isanewline
 | 
|  |    381 | \ \ \ \ \isamarkupfalse%
 | 
|  |    382 | \isacommand{fix}\ x{\isacharprime}\ x\ y\isanewline
 | 
|  |    383 | \ \ \ \ \isamarkupfalse%
 | 
|  |    384 | \isacommand{assume}\ {\isadigit{1}}{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}x{\isacharprime}{\isacharcomma}x{\isacharparenright}\ {\isasymin}\ r{\isachardoublequote}\ \isakeyword{and}\isanewline
 | 
|  |    385 | \ \ \ \ \ \ \ \ \ \ \ IH{\isacharcolon}\ {\isachardoublequote}{\isacharparenleft}y{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}\ {\isasymLongrightarrow}\ {\isacharparenleft}x{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\ \isakeyword{and}\isanewline
 | 
|  |    386 | \ \ \ \ \ \ \ \ \ \ \ B{\isacharcolon}\ \ {\isachardoublequote}{\isacharparenleft}y{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\isanewline
 | 
|  |    387 | \ \ \ \ \isamarkupfalse%
 | 
|  |    388 | \isacommand{from}\ {\isadigit{1}}\ IH{\isacharbrackleft}OF\ B{\isacharbrackright}\ \isamarkupfalse%
 | 
|  |    389 | \isacommand{show}\ {\isachardoublequote}{\isacharparenleft}x{\isacharprime}{\isacharcomma}z{\isacharparenright}\ {\isasymin}\ r{\isacharasterisk}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    390 | \isacommand{by}{\isacharparenleft}rule\ rtc{\isachardot}step{\isacharparenright}\isanewline
 | 
|  |    391 | \ \ \isamarkupfalse%
 | 
|  |    392 | \isacommand{qed}\isanewline
 | 
| 13999 |    393 | \isamarkupfalse%
 | 
| 16459 |    394 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    395 | %
 | 
|  |    396 | \begin{isamarkuptext}%
 | 
|  |    397 | \noindent We start the proof with \isakeyword{from}~\isa{A\ B}. Only \isa{A} is ``consumed'' by the induction step.
 | 
|  |    398 | Since \isa{B} is left over we don't just prove \isa{{\isacharquery}thesis} but \isa{B\ {\isasymLongrightarrow}\ {\isacharquery}thesis}, just as in the previous proof. The
 | 
|  |    399 | base case is trivial. In the assumptions for the induction step we can
 | 
|  |    400 | see very clearly how things fit together and permit ourselves the
 | 
|  |    401 | obvious forward step \isa{IH{\isacharbrackleft}OF\ B{\isacharbrackright}}.
 | 
|  |    402 | 
 | 
|  |    403 | The notation `\isakeyword{case}~\isa{(}\emph{constructor} \emph{vars}\isa{)}'
 | 
|  |    404 | is also supported for inductive definitions. The \emph{constructor} is (the
 | 
|  |    405 | name of) the rule and the \emph{vars} fix the free variables in the
 | 
|  |    406 | rule; the order of the \emph{vars} must correspond to the
 | 
|  |    407 | \emph{alphabetical order} of the variables as they appear in the rule.
 | 
|  |    408 | For example, we could start the above detailed proof of the induction
 | 
|  |    409 | with \isakeyword{case}~\isa{(step x' x y)}. However, we can then only
 | 
|  |    410 | refer to the assumptions named \isa{step} collectively and not
 | 
|  |    411 | individually, as the above proof requires.%
 | 
|  |    412 | \end{isamarkuptext}%
 | 
|  |    413 | \isamarkuptrue%
 | 
|  |    414 | %
 | 
|  |    415 | \isamarkupsubsection{More induction%
 | 
|  |    416 | }
 | 
|  |    417 | \isamarkuptrue%
 | 
|  |    418 | %
 | 
|  |    419 | \begin{isamarkuptext}%
 | 
|  |    420 | We close the section by demonstrating how arbitrary induction
 | 
|  |    421 | rules are applied. As a simple example we have chosen recursion
 | 
|  |    422 | induction, i.e.\ induction based on a recursive function
 | 
|  |    423 | definition. However, most of what we show works for induction in
 | 
|  |    424 | general.
 | 
|  |    425 | 
 | 
|  |    426 | The example is an unusual definition of rotation:%
 | 
|  |    427 | \end{isamarkuptext}%
 | 
|  |    428 | \isamarkuptrue%
 | 
|  |    429 | \isacommand{consts}\ rot\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}{\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a\ list{\isachardoublequote}\isanewline
 | 
|  |    430 | \isamarkupfalse%
 | 
|  |    431 | \isacommand{recdef}\ rot\ {\isachardoublequote}measure\ length{\isachardoublequote}\ \ %
 | 
|  |    432 | \isamarkupcmt{for the internal termination proof%
 | 
|  |    433 | }
 | 
|  |    434 | \isanewline
 | 
|  |    435 | {\isachardoublequote}rot\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequote}\isanewline
 | 
|  |    436 | {\isachardoublequote}rot\ {\isacharbrackleft}x{\isacharbrackright}\ {\isacharequal}\ {\isacharbrackleft}x{\isacharbrackright}{\isachardoublequote}\isanewline
 | 
|  |    437 | {\isachardoublequote}rot\ {\isacharparenleft}x{\isacharhash}y{\isacharhash}zs{\isacharparenright}\ {\isacharequal}\ y\ {\isacharhash}\ rot{\isacharparenleft}x{\isacharhash}zs{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
 | 
|  |    438 | %
 | 
|  |    439 | \begin{isamarkuptext}%
 | 
|  |    440 | \noindent This yields, among other things, the induction rule
 | 
|  |    441 | \isa{rot{\isachardot}induct}: \begin{isabelle}%
 | 
|  |    442 | {\isasymlbrakk}P\ {\isacharbrackleft}{\isacharbrackright}{\isacharsemicolon}\ {\isasymAnd}x{\isachardot}\ P\ {\isacharbrackleft}x{\isacharbrackright}{\isacharsemicolon}\ {\isasymAnd}x\ y\ zs{\isachardot}\ P\ {\isacharparenleft}x\ {\isacharhash}\ zs{\isacharparenright}\ {\isasymLongrightarrow}\ P\ {\isacharparenleft}x\ {\isacharhash}\ y\ {\isacharhash}\ zs{\isacharparenright}{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ x%
 | 
|  |    443 | \end{isabelle}
 | 
|  |    444 | In the following proof we rely on a default naming scheme for cases: they are
 | 
|  |    445 | called 1, 2, etc, unless they have been named explicitly. The latter happens
 | 
|  |    446 | only with datatypes and inductively defined sets, but not with recursive
 | 
|  |    447 | functions.%
 | 
|  |    448 | \end{isamarkuptext}%
 | 
|  |    449 | \isamarkuptrue%
 | 
|  |    450 | \isacommand{lemma}\ {\isachardoublequote}xs\ {\isasymnoteq}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymLongrightarrow}\ rot\ xs\ {\isacharequal}\ tl\ xs\ {\isacharat}\ {\isacharbrackleft}hd\ xs{\isacharbrackright}{\isachardoublequote}\isanewline
 | 
|  |    451 | \isamarkupfalse%
 | 
| 16459 |    452 | \isacommand{proof}\ {\isacharparenleft}induct\ xs\ rule{\isacharcolon}\ rot{\isachardot}induct{\isacharparenright}\isanewline
 | 
|  |    453 | \ \ \isamarkupfalse%
 | 
|  |    454 | \isacommand{case}\ {\isadigit{1}}\ \isamarkupfalse%
 | 
|  |    455 | \isacommand{thus}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    456 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |    457 | \isamarkupfalse%
 | 
| 16459 |    458 | \isacommand{next}\isanewline
 | 
|  |    459 | \ \ \isamarkupfalse%
 | 
|  |    460 | \isacommand{case}\ {\isadigit{2}}\ \isamarkupfalse%
 | 
|  |    461 | \isacommand{show}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    462 | \isacommand{by}\ simp\isanewline
 | 
| 13999 |    463 | \isamarkupfalse%
 | 
| 16459 |    464 | \isacommand{next}\isanewline
 | 
|  |    465 | \ \ \isamarkupfalse%
 | 
|  |    466 | \isacommand{case}\ {\isacharparenleft}{\isadigit{3}}\ a\ b\ cs{\isacharparenright}\isanewline
 | 
|  |    467 | \ \ \isamarkupfalse%
 | 
|  |    468 | \isacommand{have}\ {\isachardoublequote}rot\ {\isacharparenleft}a\ {\isacharhash}\ b\ {\isacharhash}\ cs{\isacharparenright}\ {\isacharequal}\ b\ {\isacharhash}\ rot{\isacharparenleft}a\ {\isacharhash}\ cs{\isacharparenright}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    469 | \isacommand{by}\ simp\isanewline
 | 
|  |    470 | \ \ \isamarkupfalse%
 | 
|  |    471 | \isacommand{also}\ \isamarkupfalse%
 | 
|  |    472 | \isacommand{have}\ {\isachardoublequote}{\isasymdots}\ {\isacharequal}\ b\ {\isacharhash}\ tl{\isacharparenleft}a\ {\isacharhash}\ cs{\isacharparenright}\ {\isacharat}\ {\isacharbrackleft}hd{\isacharparenleft}a\ {\isacharhash}\ cs{\isacharparenright}{\isacharbrackright}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    473 | \isacommand{by}{\isacharparenleft}simp\ add{\isacharcolon}{\isadigit{3}}{\isacharparenright}\isanewline
 | 
|  |    474 | \ \ \isamarkupfalse%
 | 
|  |    475 | \isacommand{also}\ \isamarkupfalse%
 | 
|  |    476 | \isacommand{have}\ {\isachardoublequote}{\isasymdots}\ {\isacharequal}\ tl\ {\isacharparenleft}a\ {\isacharhash}\ b\ {\isacharhash}\ cs{\isacharparenright}\ {\isacharat}\ {\isacharbrackleft}hd\ {\isacharparenleft}a\ {\isacharhash}\ b\ {\isacharhash}\ cs{\isacharparenright}{\isacharbrackright}{\isachardoublequote}\ \isamarkupfalse%
 | 
|  |    477 | \isacommand{by}\ simp\isanewline
 | 
|  |    478 | \ \ \isamarkupfalse%
 | 
|  |    479 | \isacommand{finally}\ \isamarkupfalse%
 | 
|  |    480 | \isacommand{show}\ {\isacharquery}case\ \isamarkupfalse%
 | 
|  |    481 | \isacommand{{\isachardot}}\isanewline
 | 
| 13999 |    482 | \isamarkupfalse%
 | 
| 16459 |    483 | \isacommand{qed}\isamarkupfalse%
 | 
| 13999 |    484 | %
 | 
|  |    485 | \begin{isamarkuptext}%
 | 
|  |    486 | \noindent
 | 
|  |    487 | The third case is only shown in gory detail (see \cite{BauerW-TPHOLs01}
 | 
|  |    488 | for how to reason with chains of equations) to demonstrate that the
 | 
|  |    489 | `\isakeyword{case}~\isa{(}\emph{constructor} \emph{vars}\isa{)}' notation also
 | 
|  |    490 | works for arbitrary induction theorems with numbered cases. The order
 | 
|  |    491 | of the \emph{vars} corresponds to the order of the
 | 
|  |    492 | \isa{{\isasymAnd}}-quantified variables in each case of the induction
 | 
|  |    493 | theorem. For induction theorems produced by \isakeyword{recdef} it is
 | 
|  |    494 | the order in which the variables appear on the left-hand side of the
 | 
|  |    495 | equation.
 | 
|  |    496 | 
 | 
|  |    497 | The proof is so simple that it can be condensed to%
 | 
|  |    498 | \end{isamarkuptext}%
 | 
|  |    499 | \isamarkuptrue%
 | 
|  |    500 | \isamarkupfalse%
 | 
| 16459 |    501 | \isacommand{by}\ {\isacharparenleft}induct\ xs\ rule{\isacharcolon}\ rot{\isachardot}induct{\isacharcomma}\ simp{\isacharunderscore}all{\isacharparenright}\isanewline
 | 
| 13999 |    502 | \isamarkupfalse%
 | 
|  |    503 | \isamarkupfalse%
 | 
|  |    504 | \end{isabellebody}%
 | 
|  |    505 | %%% Local Variables:
 | 
|  |    506 | %%% mode: latex
 | 
|  |    507 | %%% TeX-master: "root"
 | 
|  |    508 | %%% End:
 |