2 \chapter{Isabelle/HOL Tools and Packages}\label{ch:hol-tools}
4 \section{Miscellaneous attributes}\label{sec:rule-format}
6 \indexisaratt{rule-format}
8 rule_format & : & \isaratt \\
11 \railalias{ruleformat}{rule\_format}
15 ruleformat ('(' noasm ')')?
21 \item [$rule_format$] causes a theorem to be put into standard object-rule
22 form, replacing implication and (bounded) universal quantification of HOL by
23 the corresponding meta-logical connectives. By default, the result is fully
24 normalized, including assumptions and conclusions at any depth. The
25 $no_asm$ option restricts the transformation to the conclusion of a rule.
29 \section{Primitive types}
31 \indexisarcmd{typedecl}\indexisarcmd{typedef}
32 \begin{matharray}{rcl}
33 \isarcmd{typedecl} & : & \isartrans{theory}{theory} \\
34 \isarcmd{typedef} & : & \isartrans{theory}{proof(prove)} \\
38 'typedecl' typespec infix? comment?
40 'typedef' parname? typespec infix? \\ '=' term comment?
45 \item [$\isarkeyword{typedecl}~(\vec\alpha)t$] is similar to the original
46 $\isarkeyword{typedecl}$ of Isabelle/Pure (see \S\ref{sec:types-pure}), but
47 also declares type arity $t :: (term, \dots, term) term$, making $t$ an
48 actual HOL type constructor.
49 \item [$\isarkeyword{typedef}~(\vec\alpha)t = A$] sets up a goal stating
50 non-emptiness of the set $A$. After finishing the proof, the theory will be
51 augmented by a Gordon/HOL-style type definition. See \cite{isabelle-HOL}
52 for more information. Note that user-level theories usually do not directly
53 refer to the HOL $\isarkeyword{typedef}$ primitive, but use more advanced
54 packages such as $\isarkeyword{record}$ (see \S\ref{sec:record}) and
55 $\isarkeyword{datatype}$ (see \S\ref{sec:datatype}).
59 \section{Records}\label{sec:record}
62 \begin{matharray}{rcl}
63 \isarcmd{record} & : & \isartrans{theory}{theory} \\
67 'record' typespec '=' (type '+')? (field +)
70 field: name '::' type comment?
75 \item [$\isarkeyword{record}~(\vec\alpha)t = \tau + \vec c :: \vec\sigma$]
76 defines extensible record type $(\vec\alpha)t$, derived from the optional
77 parent record $\tau$ by adding new field components $\vec c :: \vec\sigma$.
78 See \cite{isabelle-HOL,NaraschewskiW-TPHOLs98} for more information only
79 simply-typed extensible records.
83 \section{Datatypes}\label{sec:datatype}
85 \indexisarcmd{datatype}\indexisarcmd{rep-datatype}
86 \begin{matharray}{rcl}
87 \isarcmd{datatype} & : & \isartrans{theory}{theory} \\
88 \isarcmd{rep_datatype} & : & \isartrans{theory}{theory} \\
91 \railalias{repdatatype}{rep\_datatype}
92 \railterm{repdatatype}
95 'datatype' (dtspec + 'and')
97 repdatatype (name * ) dtrules
100 dtspec: parname? typespec infix? '=' (cons + '|')
102 cons: name (type * ) mixfix? comment?
104 dtrules: 'distinct' thmrefs 'inject' thmrefs 'induction' thmrefs
108 \item [$\isarkeyword{datatype}$] defines inductive datatypes in HOL.
109 \item [$\isarkeyword{rep_datatype}$] represents existing types as inductive
110 ones, generating the standard infrastructure of derived concepts (primitive
114 The induction and exhaustion theorems generated provide case names according
115 to the constructors involved, while parameters are named after the types (see
116 also \S\ref{sec:induct-method}).
118 See \cite{isabelle-HOL} for more details on datatypes. Note that the theory
119 syntax above has been slightly simplified over the old version, usually
120 requiring more quotes and less parentheses. Apart from proper proof methods
121 for case-analysis and induction, there are also emulations of ML tactics
122 \texttt{case_tac} and \texttt{induct_tac} available, see
123 \S\ref{sec:induct_tac}.
126 \section{Recursive functions}
128 \indexisarcmd{primrec}\indexisarcmd{recdef}
129 \begin{matharray}{rcl}
130 \isarcmd{primrec} & : & \isartrans{theory}{theory} \\
131 \isarcmd{recdef} & : & \isartrans{theory}{theory} \\
133 % \isarcmd{defer_recdef} & : & \isartrans{theory}{theory} \\
136 \railalias{recdefsimp}{recdef\_simp}
137 \railterm{recdefsimp}
139 \railalias{recdefcong}{recdef\_cong}
140 \railterm{recdefcong}
142 \railalias{recdefwf}{recdef\_wf}
146 'primrec' parname? (equation + )
148 'recdef' name term (eqn + ) hints?
151 equation: thmdecl? eqn
155 hints: '(' 'hints' (recdefmod * ) ')'
157 recdefmod: ((recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del') ':' thmrefs) | clasimpmod
162 \item [$\isarkeyword{primrec}$] defines primitive recursive functions over
163 datatypes, see also \cite{isabelle-HOL}.
164 \item [$\isarkeyword{recdef}$] defines general well-founded recursive
165 functions (using the TFL package), see also \cite{isabelle-HOL}. The
166 $recdef_simp$, $recdef_cong$, and $recdef_wf$ hints refer to auxiliary rules
167 to be used in the internal automated proof process of TFL. Additional
168 $clasimpmod$ declarations (cf.\ \S\ref{sec:clasimp}) may be given to tune
169 the context of the Simplifier (cf.\ \S\ref{sec:simplifier}) and Classical
170 reasoner (cf.\ \S\ref{sec:classical}).
173 Both kinds of recursive definitions accommodate reasoning by induction (cf.\
174 \S\ref{sec:induct-method}): rule $c\mathord{.}induct$ (where $c$ is the name
175 of the function definition) refers to a specific induction rule, with
176 parameters named according to the user-specified equations. Case names of
177 $\isarkeyword{primrec}$ are that of the datatypes involved, while those of
178 $\isarkeyword{recdef}$ are numbered (starting from $1$).
180 The equations provided by these packages may be referred later as theorem list
181 $f\mathord.simps$, where $f$ is the (collective) name of the functions
182 defined. Individual equations may be named explicitly as well; note that for
183 $\isarkeyword{recdef}$ each specification given by the user may result in
186 \medskip Hints for $\isarkeyword{recdef}$ may be also declared globally, using
187 the following attributes.
189 \indexisaratt{recdef-simp}\indexisaratt{recdef-cong}\indexisaratt{recdef-wf}
190 \begin{matharray}{rcl}
191 recdef_simp & : & \isaratt \\
192 recdef_cong & : & \isaratt \\
193 recdef_wf & : & \isaratt \\
196 \railalias{recdefsimp}{recdef\_simp}
197 \railterm{recdefsimp}
199 \railalias{recdefcong}{recdef\_cong}
200 \railterm{recdefcong}
202 \railalias{recdefwf}{recdef\_wf}
206 (recdefsimp | recdefcong | recdefwf) (() | 'add' | 'del')
211 \section{(Co)Inductive sets}
213 \indexisarcmd{inductive}\indexisarcmd{coinductive}\indexisaratt{mono}
214 \begin{matharray}{rcl}
215 \isarcmd{inductive} & : & \isartrans{theory}{theory} \\
216 \isarcmd{coinductive} & : & \isartrans{theory}{theory} \\
217 mono & : & \isaratt \\
220 \railalias{condefs}{con\_defs}
224 ('inductive' | 'coinductive') sets intros monos?
226 'mono' (() | 'add' | 'del')
229 sets: (term comment? +)
231 intros: 'intros' attributes? (thmdecl? prop comment? +)
233 monos: 'monos' thmrefs comment?
238 \item [$\isarkeyword{inductive}$ and $\isarkeyword{coinductive}$] define
239 (co)inductive sets from the given introduction rules.
240 \item [$mono$] declares monotonicity rules. These rule are involved in the
241 automated monotonicity proof of $\isarkeyword{inductive}$.
244 See \cite{isabelle-HOL} for further information on inductive definitions in
248 \section{Proof by cases and induction}\label{sec:induct-method}
250 \subsection{Proof methods}\label{sec:induct-method-proper}
252 \indexisarmeth{cases}\indexisarmeth{induct}
253 \begin{matharray}{rcl}
254 cases & : & \isarmeth \\
255 induct & : & \isarmeth \\
258 The $cases$ and $induct$ methods provide a uniform interface to case analysis
259 and induction over datatypes, inductive sets, and recursive functions. The
260 corresponding rules may be specified and instantiated in a casual manner.
261 Furthermore, these methods provide named local contexts that may be invoked
262 via the $\CASENAME$ proof command within the subsequent proof text (cf.\
263 \S\ref{sec:cases}). This accommodates compact proof texts even when reasoning
264 about large specifications.
267 'cases' simplified? open? args rule?
269 'induct' stripped? open? args rule?
272 simplified: '(' 'simplified' ')'
274 stripped: '(' 'stripped' ')'
278 args: (insts * 'and')
280 rule: ('type' | 'set') ':' nameref | 'rule' ':' thmref
285 \item [$cases~insts~R$] applies method $rule$ with an appropriate case
286 distinction theorem, instantiated to the subjects $insts$. Symbolic case
287 names are bound according to the rule's local contexts.
289 The rule is determined as follows, according to the facts and arguments
290 passed to the $cases$ method:
291 \begin{matharray}{llll}
292 \Text{facts} & & \Text{arguments} & \Text{rule} \\\hline
293 & cases & & \Text{classical case split} \\
294 & cases & t & \Text{datatype exhaustion (type of $t$)} \\
295 \edrv a \in A & cases & \dots & \Text{inductive set elimination (of $A$)} \\
296 \dots & cases & \dots ~ R & \Text{explicit rule $R$} \\
299 Several instantiations may be given, referring to the \emph{suffix} of
300 premises of the case rule; within each premise, the \emph{prefix} of
301 variables is instantiated. In most situations, only a single term needs to
302 be specified; this refers to the first variable of the last premise (it is
303 usually the same for all cases).
305 The $simplified$ option causes ``obvious cases'' of the rule to be solved
306 beforehand, while the others are left unscathed.
308 The $open$ option causes the parameters of the new local contexts to be
309 exposed to the current proof context. Thus local variables stemming from
310 distant parts of the theory development may be introduced in an implicit
311 manner, which can be quite confusing to the reader. Furthermore, this
312 option may cause unwanted hiding of existing local variables, resulting in
313 less robust proof texts.
315 \item [$induct~insts~R$] is analogous to the $cases$ method, but refers to
316 induction rules, which are determined as follows:
317 \begin{matharray}{llll}
318 \Text{facts} & & \Text{arguments} & \Text{rule} \\\hline
319 & induct & P ~ x ~ \dots & \Text{datatype induction (type of $x$)} \\
320 \edrv x \in A & induct & \dots & \Text{set induction (of $A$)} \\
321 \dots & induct & \dots ~ R & \Text{explicit rule $R$} \\
324 Several instantiations may be given, each referring to some part of a mutual
325 inductive definition or datatype --- only related partial induction rules
326 may be used together, though. Any of the lists of terms $P, x, \dots$
327 refers to the \emph{suffix} of variables present in the induction rule.
328 This enables the writer to specify only induction variables, or both
329 predicates and variables, for example.
331 The $stripped$ option causes implications and (bounded) universal
332 quantifiers to be removed from each new subgoal emerging from the
333 application of the induction rule. This accommodates typical
334 ``strengthening of induction'' predicates.
336 The $open$ option has the same effect as for the $cases$ method, see above.
339 Above methods produce named local contexts (cf.\ \S\ref{sec:cases}), as
340 determined by the instantiated rule \emph{before} it has been applied to the
341 internal proof state.\footnote{As a general principle, Isar proof text may
342 never refer to parts of proof states directly.} Thus proper use of symbolic
343 cases usually require the rule to be instantiated fully, as far as the
344 emerging local contexts and subgoals are concerned. In particular, for
345 induction both the predicates and variables have to be specified. Otherwise
346 the $\CASENAME$ command would refuse to invoke cases containing schematic
349 The $\isarkeyword{print_cases}$ command (\S\ref{sec:cases}) prints all named
350 cases present in the current proof state.
353 \subsection{Declaring rules}
355 \indexisaratt{cases}\indexisaratt{induct}
356 \begin{matharray}{rcl}
357 cases & : & \isaratt \\
358 induct & : & \isaratt \\
367 spec: ('type' | 'set') ':' nameref
371 The $cases$ and $induct$ attributes augment the corresponding context of rules
372 for reasoning about inductive sets and types. The standard rules are already
373 declared by HOL definitional packages. For special applications, these may be
374 replaced manually by variant versions.
376 Refer to the $case_names$ and $params$ attributes (see \S\ref{sec:cases}) to
377 adjust names of cases and parameters of a rule.
380 \subsection{Emulating tactic scripts}\label{sec:induct_tac}
382 \indexisarmeth{case-tac}\indexisarmeth{induct-tac}
383 \indexisarmeth{ind-cases}\indexisarcmd{inductive-cases}
384 \begin{matharray}{rcl}
385 case_tac^* & : & \isarmeth \\
386 induct_tac^* & : & \isarmeth \\
387 ind_cases^* & : & \isarmeth \\
388 \isarcmd{inductive_cases} & : & \isartrans{theory}{theory} \\
391 \railalias{casetac}{case\_tac}
394 \railalias{inducttac}{induct\_tac}
397 \railalias{indcases}{ind\_cases}
400 \railalias{inductivecases}{inductive\_cases}
401 \railterm{inductivecases}
404 casetac goalspec? term rule?
406 inducttac goalspec? (insts * 'and') rule?
410 inductivecases thmdecl? (prop +) comment?
413 rule: ('rule' ':' thmref)
418 \item [$case_tac$ and $induct_tac$] admit to reason about inductive datatypes
419 only (unless an alternative rule is given explicitly). Furthermore,
420 $case_tac$ does a classical case split on booleans; $induct_tac$ allows only
421 variables to be given as instantiation. These tactic emulations feature
422 both goal addressing and dynamic instantiation. Note that named local
423 contexts (see \S\ref{sec:cases}) are \emph{not} provided as would be by the
424 proper $induct$ and $cases$ proof methods (see
425 \S\ref{sec:induct-method-proper}).
427 \item [$ind_cases$ and $\isarkeyword{inductive_cases}$] provide an interface
428 to the \texttt{mk_cases} operation. Rules are simplified in an unrestricted
429 forward manner, unlike the proper $cases$ method (see
430 \S\ref{sec:induct-method-proper}) which requires simplified cases to be
433 While $ind_cases$ is a proof method to apply the result immediately as
434 elimination rules, $\isarkeyword{inductive_cases}$ provides case split
435 theorems at the theory level for later use,
441 \indexisarmeth{arith}\indexisaratt{arith-split}
442 \begin{matharray}{rcl}
443 arith & : & \isarmeth \\
444 arith_split & : & \isaratt \\
452 The $arith$ method decides linear arithmetic problems (on types $nat$, $int$,
453 $real$). Any current facts are inserted into the goal before running the
454 procedure. The ``!''~argument causes the full context of assumptions to be
455 included. The $arith_split$ attribute declares case split rules to be
456 expanded before the arithmetic procedure is invoked.
458 Note that a simpler (but faster) version of arithmetic reasoning is already
459 performed by the Simplifier.
464 %%% TeX-master: "isar-ref"