doc-src/IsarRef/generic.tex
author wenzelm
Sat, 15 Oct 2005 00:08:13 +0200
changeset 17864 b039ea8bb965
parent 17274 746bb4c56800
child 18232 bc367912603f
permissions -rw-r--r--
added guess;
wenzelm@7135
     1
wenzelm@13048
     2
\chapter{Generic tools and packages}\label{ch:gen-tools}
wenzelm@7167
     3
wenzelm@12621
     4
\section{Theory specification commands}
wenzelm@12618
     5
wenzelm@12618
     6
\subsection{Axiomatic type classes}\label{sec:axclass}
wenzelm@7167
     7
wenzelm@8517
     8
\indexisarcmd{axclass}\indexisarcmd{instance}\indexisarmeth{intro-classes}
wenzelm@7167
     9
\begin{matharray}{rcl}
wenzelm@8517
    10
  \isarcmd{axclass} & : & \isartrans{theory}{theory} \\
wenzelm@8517
    11
  \isarcmd{instance} & : & \isartrans{theory}{proof(prove)} \\
wenzelm@8517
    12
  intro_classes & : & \isarmeth \\
wenzelm@7167
    13
\end{matharray}
wenzelm@7167
    14
wenzelm@8517
    15
Axiomatic type classes are provided by Isabelle/Pure as a \emph{definitional}
wenzelm@8517
    16
interface to type classes (cf.~\S\ref{sec:classes}).  Thus any object logic
wenzelm@8547
    17
may make use of this light-weight mechanism of abstract theories
wenzelm@8901
    18
\cite{Wenzel:1997:TPHOL}.  There is also a tutorial on using axiomatic type
wenzelm@13024
    19
classes in Isabelle \cite{isabelle-axclass} that is part of the standard
wenzelm@8901
    20
Isabelle documentation.
wenzelm@8517
    21
wenzelm@7167
    22
\begin{rail}
wenzelm@12879
    23
  'axclass' classdecl (axmdecl prop +)
wenzelm@8517
    24
  ;
wenzelm@14605
    25
  'instance' (nameref ('<' | subseteq) nameref | nameref '::' arity)
wenzelm@7167
    26
  ;
wenzelm@7167
    27
\end{rail}
wenzelm@7167
    28
wenzelm@7167
    29
\begin{descr}
wenzelm@17274
    30
  
wenzelm@13024
    31
\item [$\AXCLASS~c \subseteq \vec c~~axms$] defines an axiomatic type class as
wenzelm@11100
    32
  the intersection of existing classes, with additional axioms holding.  Class
wenzelm@10223
    33
  axioms may not contain more than one type variable.  The class axioms (with
wenzelm@10223
    34
  implicit sort constraints added) are bound to the given names.  Furthermore
wenzelm@17274
    35
  a class introduction rule is generated (being bound as
wenzelm@17274
    36
  $c_class{\dtt}intro$); this rule is employed by method $intro_classes$ to
wenzelm@17274
    37
  support instantiation proofs of this class.
wenzelm@17274
    38
  
wenzelm@12976
    39
  The ``axioms'' are stored as theorems according to the given name
wenzelm@13039
    40
  specifications, adding the class name $c$ as name space prefix; the same
wenzelm@17274
    41
  facts are also stored collectively as $c_class{\dtt}axioms$.
wenzelm@14605
    42
  
wenzelm@14605
    43
\item [$\INSTANCE~c@1 \subseteq c@2$ and $\INSTANCE~t :: (\vec s)s$] setup a
wenzelm@11100
    44
  goal stating a class relation or type arity.  The proof would usually
wenzelm@11100
    45
  proceed by $intro_classes$, and then establish the characteristic theorems
wenzelm@11100
    46
  of the type classes involved.  After finishing the proof, the theory will be
wenzelm@11100
    47
  augmented by a type signature declaration corresponding to the resulting
wenzelm@11100
    48
  theorem.
wenzelm@13041
    49
wenzelm@8517
    50
\item [$intro_classes$] repeatedly expands all class introduction rules of
wenzelm@10858
    51
  this theory.  Note that this method usually needs not be named explicitly,
wenzelm@13040
    52
  as it is already included in the default proof step (of $\PROOFNAME$ etc.).
wenzelm@13040
    53
  In particular, instantiation of trivial (syntactic) classes may be performed
wenzelm@13040
    54
  by a single ``$\DDOT$'' proof step.
wenzelm@13027
    55
wenzelm@7167
    56
\end{descr}
wenzelm@7167
    57
wenzelm@7315
    58
wenzelm@12618
    59
\subsection{Locales and local contexts}\label{sec:locale}
wenzelm@12618
    60
wenzelm@13040
    61
Locales are named local contexts, consisting of a list of declaration elements
wenzelm@13041
    62
that are modeled after the Isar proof context commands (cf.\
wenzelm@13040
    63
\S\ref{sec:proof-context}).
wenzelm@12618
    64
wenzelm@13048
    65
wenzelm@12976
    66
\subsubsection{Localized commands}
wenzelm@12967
    67
wenzelm@12976
    68
Existing locales may be augmented later on by adding new facts.  Note that the
wenzelm@12976
    69
actual context definition may not be changed!  Several theory commands that
wenzelm@12976
    70
produce facts in some way are available in ``localized'' versions, referring
wenzelm@12976
    71
to a named locale instead of the global theory context.
wenzelm@12976
    72
wenzelm@12976
    73
\indexouternonterm{locale}
wenzelm@12967
    74
\begin{rail}
wenzelm@12967
    75
  locale: '(' 'in' name ')'
wenzelm@12967
    76
  ;
wenzelm@12976
    77
\end{rail}
wenzelm@12967
    78
wenzelm@12976
    79
Emerging facts of localized commands are stored in two versions, both in the
wenzelm@12976
    80
target locale and the theory (after export).  The latter view produces a
wenzelm@12976
    81
qualified binding, using the locale name as a name space prefix.
wenzelm@12976
    82
wenzelm@12976
    83
For example, ``$\LEMMAS~(\IN~loc)~a = \vec b$'' retrieves facts $\vec b$ from
wenzelm@12976
    84
the locale context of $loc$ and augments its body by an appropriate
wenzelm@12976
    85
``$\isarkeyword{notes}$'' element (see below).  The exported view of $a$,
wenzelm@12976
    86
after discharging the locale context, is stored as $loc{.}a$ within the global
wenzelm@13041
    87
theory.  A localized goal ``$\LEMMANAME~(\IN~loc)~a:~\phi$'' works similarly,
wenzelm@13041
    88
only that the fact emerges through the subsequent proof, which may refer to
wenzelm@13041
    89
the full infrastructure of the locale context (covering local parameters with
wenzelm@13041
    90
typing and concrete syntax, assumptions, definitions etc.).  Most notably,
wenzelm@13411
    91
fact declarations of the locale are active during the proof as well (e.g.\ 
wenzelm@13041
    92
local $simp$ rules).
wenzelm@12976
    93
wenzelm@13411
    94
As a general principle, results exported from a locale context acquire
wenzelm@13411
    95
additional premises according to the specification.  Usually this is only a
wenzelm@13411
    96
single predicate according to the standard ``closed'' view of locale
wenzelm@13411
    97
specifications.
wenzelm@13411
    98
wenzelm@12976
    99
wenzelm@12976
   100
\subsubsection{Locale specifications}
wenzelm@12976
   101
wenzelm@12976
   102
\indexisarcmd{locale}\indexisarcmd{print-locale}\indexisarcmd{print-locales}
wenzelm@12976
   103
\begin{matharray}{rcl}
wenzelm@12976
   104
  \isarcmd{locale} & : & \isarkeep{theory} \\
wenzelm@12976
   105
  \isarcmd{print_locale}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@12976
   106
  \isarcmd{print_locales}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@12976
   107
\end{matharray}
wenzelm@12976
   108
wenzelm@12976
   109
\indexouternonterm{contextexpr}\indexouternonterm{contextelem}
wenzelm@12976
   110
wenzelm@12976
   111
\railalias{printlocale}{print\_locale}
wenzelm@12976
   112
\railterm{printlocale}
wenzelm@12976
   113
wenzelm@12976
   114
\begin{rail}
wenzelm@13411
   115
  'locale' ('(open)')? name ('=' localeexpr)?
wenzelm@12976
   116
  ;
ballarin@17228
   117
  printlocale '!'? localeexpr
wenzelm@12976
   118
  ;
wenzelm@12976
   119
  localeexpr: ((contextexpr '+' (contextelem+)) | contextexpr | (contextelem+))
wenzelm@12976
   120
  ;
wenzelm@12976
   121
wenzelm@12976
   122
  contextexpr: nameref | '(' contextexpr ')' |
ballarin@16102
   123
  (contextexpr (name mixfix? +)) | (contextexpr + '+')
wenzelm@12976
   124
  ;
ballarin@16168
   125
  contextelem: fixes | constrains | assumes | defines | notes | includes
wenzelm@12976
   126
  ;
wenzelm@12976
   127
  fixes: 'fixes' (name ('::' type)? structmixfix? + 'and')
wenzelm@12976
   128
  ;
ballarin@16168
   129
  constrains: 'constrains' (name '::' type + 'and')
ballarin@16168
   130
  ;
wenzelm@12976
   131
  assumes: 'assumes' (thmdecl? props + 'and')
wenzelm@12976
   132
  ;
wenzelm@12976
   133
  defines: 'defines' (thmdecl? prop proppat? + 'and')
wenzelm@12976
   134
  ;
wenzelm@12976
   135
  notes: 'notes' (thmdef? thmrefs + 'and')
wenzelm@12976
   136
  ;
wenzelm@12976
   137
  includes: 'includes' contextexpr
wenzelm@12976
   138
  ;
wenzelm@12967
   139
\end{rail}
wenzelm@12618
   140
wenzelm@12976
   141
\begin{descr}
wenzelm@13411
   142
  
wenzelm@13411
   143
\item [$\LOCALE~loc~=~import~+~body$] defines a new locale $loc$ as a context
wenzelm@12976
   144
  consisting of a certain view of existing locales ($import$) plus some
wenzelm@12976
   145
  additional elements ($body$).  Both $import$ and $body$ are optional; the
wenzelm@13024
   146
  degenerate form $\LOCALE~loc$ defines an empty locale, which may still be
wenzelm@13024
   147
  useful to collect declarations of facts later on.  Type-inference on locale
wenzelm@12976
   148
  expressions automatically takes care of the most general typing that the
wenzelm@12976
   149
  combined context elements may acquire.
wenzelm@13041
   150
wenzelm@12976
   151
  The $import$ consists of a structured context expression, consisting of
wenzelm@12976
   152
  references to existing locales, renamed contexts, or merged contexts.
ballarin@16102
   153
  Renaming uses positional notation: $c~\vec x$ means that (a prefix of) the
wenzelm@12976
   154
  fixed parameters of context $c$ are named according to $\vec x$; a
ballarin@16102
   155
  ``\texttt{_}'' (underscore) \indexisarthm{_@\texttt{_}} means to skip that
ballarin@16102
   156
  position.  Renaming by default deletes existing syntax.  Optionally,
ballarin@16102
   157
  new syntax may by specified with a mixfix annotation.  Note that the
ballarin@16102
   158
  special syntax declared with ``$(structure)$'' (see below) is
ballarin@16102
   159
  neither deleted nor can it be changed.
wenzelm@13041
   160
  Merging proceeds from left-to-right, suppressing any duplicates stemming
wenzelm@13041
   161
  from different paths through the import hierarchy.
wenzelm@13041
   162
wenzelm@12976
   163
  The $body$ consists of basic context elements, further context expressions
wenzelm@12976
   164
  may be included as well.
wenzelm@12976
   165
wenzelm@12976
   166
  \begin{descr}
wenzelm@13041
   167
wenzelm@12976
   168
  \item [$\FIXES{~x::\tau~(mx)}$] declares a local parameter of type $\tau$
wenzelm@12976
   169
    and mixfix annotation $mx$ (both are optional).  The special syntax
wenzelm@13027
   170
    declaration ``$(structure)$'' means that $x$ may be referenced
wenzelm@13027
   171
    implicitly in this context.
wenzelm@13041
   172
ballarin@16168
   173
  \item [$\CONSTRAINS{~x::\tau}$] introduces a type constraint $\tau$
ballarin@16168
   174
    on the local parameter $x$.
ballarin@16168
   175
wenzelm@12976
   176
  \item [$\ASSUMES{a}{\vec\phi}$] introduces local premises, similar to
wenzelm@12976
   177
    $\ASSUMENAME$ within a proof (cf.\ \S\ref{sec:proof-context}).
wenzelm@13041
   178
wenzelm@12976
   179
  \item [$\DEFINES{a}{x \equiv t}$] defines a previously declared parameter.
wenzelm@13041
   180
    This is close to $\DEFNAME$ within a proof (cf.\
wenzelm@12976
   181
    \S\ref{sec:proof-context}), but $\DEFINESNAME$ takes an equational
wenzelm@13041
   182
    proposition instead of variable-term pair.  The left-hand side of the
wenzelm@13041
   183
    equation may have additional arguments, e.g.\ ``$\DEFINES{}{f~\vec x
wenzelm@13041
   184
      \equiv t}$''.
wenzelm@13041
   185
wenzelm@12976
   186
  \item [$\NOTES{a}{\vec b}$] reconsiders facts within a local context.  Most
wenzelm@12976
   187
    notably, this may include arbitrary declarations in any attribute
wenzelm@12976
   188
    specifications included here, e.g.\ a local $simp$ rule.
wenzelm@13041
   189
wenzelm@12976
   190
  \item [$\INCLUDES{c}$] copies the specified context in a statically scoped
ballarin@15763
   191
    manner.  Only available in the long goal format of \S\ref{sec:goals}.
wenzelm@13041
   192
wenzelm@12976
   193
    In contrast, the initial $import$ specification of a locale expression
wenzelm@12976
   194
    maintains a dynamic relation to the locales being referenced (benefiting
wenzelm@12976
   195
    from any later fact declarations in the obvious manner).
wenzelm@12976
   196
  \end{descr}
wenzelm@13411
   197
  
wenzelm@13041
   198
  Note that ``$\IS{p}$'' patterns given in the syntax of $\ASSUMESNAME$ and
wenzelm@13411
   199
  $\DEFINESNAME$ above are illegal in locale definitions.  In the long goal
wenzelm@13411
   200
  format of \S\ref{sec:goals}, term bindings may be included as expected,
wenzelm@13411
   201
  though.
wenzelm@13411
   202
  
wenzelm@13411
   203
  \medskip By default, locale specifications are ``closed up'' by turning the
wenzelm@13411
   204
  given text into a predicate definition $loc_axioms$ and deriving the
wenzelm@13411
   205
  original assumptions as local lemmas (modulo local definitions).  The
wenzelm@13411
   206
  predicate statement covers only the newly specified assumptions, omitting
wenzelm@13411
   207
  the content of included locale expressions.  The full cumulative view is
wenzelm@13411
   208
  only provided on export, involving another predicate $loc$ that refers to
wenzelm@13411
   209
  the complete specification text.
wenzelm@13411
   210
  
wenzelm@13411
   211
  In any case, the predicate arguments are those locale parameters that
wenzelm@13411
   212
  actually occur in the respective piece of text.  Also note that these
wenzelm@13411
   213
  predicates operate at the meta-level in theory, but the locale packages
wenzelm@13411
   214
  attempts to internalize statements according to the object-logic setup
wenzelm@13411
   215
  (e.g.\ replacing $\Forall$ by $\forall$, and $\Imp$ by $\imp$ in HOL; see
wenzelm@13411
   216
  also \S\ref{sec:object-logic}).  Separate introduction rules
wenzelm@13411
   217
  $loc_axioms.intro$ and $loc.intro$ are declared as well.
wenzelm@13411
   218
  
wenzelm@13411
   219
  The $(open)$ option of a locale specification prevents both the current
wenzelm@13411
   220
  $loc_axioms$ and cumulative $loc$ predicate constructions.  Predicates are
wenzelm@13411
   221
  also omitted for empty specification texts.
wenzelm@12976
   222
wenzelm@12976
   223
\item [$\isarkeyword{print_locale}~import~+~body$] prints the specified locale
wenzelm@12976
   224
  expression in a flattened form.  The notable special case
wenzelm@12976
   225
  $\isarkeyword{print_locale}~loc$ just prints the contents of the named
wenzelm@12976
   226
  locale, but keep in mind that type-inference will normalize type variables
ballarin@17228
   227
  according to the usual alphabetical order.  The command omits
ballarin@17228
   228
  $\isarkeyword{notes}$ elements by default.  Use
ballarin@17228
   229
  $\isarkeyword{print_locale}!$ to get them included.
wenzelm@13041
   230
wenzelm@12976
   231
\item [$\isarkeyword{print_locales}$] prints the names of all locales of the
wenzelm@12976
   232
  current theory.
wenzelm@12976
   233
wenzelm@12976
   234
\end{descr}
wenzelm@12976
   235
wenzelm@12618
   236
ballarin@15763
   237
\subsubsection{Interpretation of locales}
ballarin@15763
   238
ballarin@15763
   239
Locale expressions (more precisely, \emph{context expressions}) may be
ballarin@15763
   240
instantiated, and the instantiated facts added to the current context.
ballarin@15763
   241
This requires a proof of the instantiated specification and is called
ballarin@15763
   242
\emph{locale interpretation}.  Interpretation is possible in theories
ballarin@17043
   243
and locales
ballarin@17043
   244
(command $\isarcmd{interpretation}$) and also in proof contexts
ballarin@15763
   245
($\isarcmd{interpret}$).
ballarin@15763
   246
ballarin@15763
   247
\indexisarcmd{interpretation}\indexisarcmd{interpret}
ballarin@15763
   248
\indexisarcmd{print-interps}
ballarin@15763
   249
\begin{matharray}{rcl}
ballarin@15763
   250
  \isarcmd{interpretation} & : & \isartrans{theory}{proof(prove)} \\
ballarin@15763
   251
  \isarcmd{interpret} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
ballarin@15763
   252
  \isarcmd{print_interps}^* & : &  \isarkeep{theory~|~proof} \\
ballarin@15763
   253
\end{matharray}
ballarin@15763
   254
ballarin@15763
   255
\indexouternonterm{interp}
ballarin@15763
   256
ballarin@15763
   257
\railalias{printinterps}{print\_interps}
ballarin@15763
   258
\railterm{printinterps}
ballarin@15763
   259
ballarin@15763
   260
\begin{rail}
ballarin@17043
   261
  'interpretation' (interp | name ('<' | subseteq) contextexp)
ballarin@15763
   262
  ;
ballarin@15763
   263
  'interpret' interp
ballarin@15763
   264
  ;
ballarin@17139
   265
  printinterps '!'? name
ballarin@15763
   266
  ;
ballarin@15763
   267
  interp: thmdecl? contextexpr ('[' (inst+) ']')?
ballarin@15763
   268
  ;
ballarin@15763
   269
\end{rail}
ballarin@15763
   270
ballarin@17043
   271
ballarin@15763
   272
\begin{descr}
ballarin@15763
   273
ballarin@15763
   274
\item [$\isarcmd{interpretation}~expr~insts$]
ballarin@17043
   275
ballarin@17043
   276
  The first form of $\isarcmd{interpretation}$ interprets $expr$
ballarin@17043
   277
  in the theory.  The instantiation is given as a list of
ballarin@17043
   278
  terms $insts$ and is positional.
ballarin@15763
   279
  All parameters must receive an instantiation term --- with the
ballarin@15763
   280
  exception of defined parameters.  These are, if omitted, derived
ballarin@15763
   281
  from the defining equation and other instantiations.  Use ``\_'' to
ballarin@15763
   282
  omit an instantiation term.  Free variables are automatically
ballarin@15763
   283
  generalized.
ballarin@15763
   284
ballarin@17043
   285
  The command generates proof obligations for the instantiated
ballarin@17043
   286
  specifications (assumes and defines elements).  Once these are
ballarin@17043
   287
  discharged by the user, instantiated facts are added to the theory in
ballarin@17043
   288
  a post-processing phase.
ballarin@15763
   289
ballarin@15763
   290
  The command is aware of interpretations already active in the
ballarin@15763
   291
  theory.  No proof obligations are generated for those, neither is
ballarin@15763
   292
  post-processing applied to their facts.  This avoids duplication of
ballarin@15763
   293
  interpreted facts, in particular.  Note that, in the case of a
ballarin@15763
   294
  locale with import, parts of the interpretation may already be
ballarin@15763
   295
  active.  The command will only generate proof obligations and add
ballarin@15763
   296
  facts for new parts.
ballarin@15763
   297
ballarin@17043
   298
  The context expression may be preceded by a name and/or attributes.
ballarin@17043
   299
  These take effect in the post-processing of facts.  The name is used
ballarin@17043
   300
  to prefix fact names, for example to avoid accidental hiding of
ballarin@17043
   301
  other facts.  Attributes are applied after attributes of the
ballarin@17043
   302
  interpreted facts.
ballarin@17043
   303
ballarin@15763
   304
  Adding facts to locales has the
ballarin@15763
   305
  effect of adding interpreted facts to the theory for all active
ballarin@17043
   306
  interpretations also.  That is, interpretations dynamically
ballarin@17043
   307
  participate in any facts added to locales.
ballarin@17043
   308
ballarin@17043
   309
\item [$\isarcmd{interpretation}~name~\subseteq~expr$]
ballarin@17043
   310
ballarin@17043
   311
  This form of the command interprets $expr$ in the locale $name$.  It
ballarin@17043
   312
  requires a proof that the specification of $name$ implies the
ballarin@17043
   313
  specification of $expr$.  As in the localized version of the theorem
ballarin@17043
   314
  command, the proof is in the context of $name$.  After the proof
ballarin@17043
   315
  obligation has been dischared, the facts of $expr$
ballarin@17043
   316
  become part of locale $name$ as \emph{derived} context elements and
ballarin@17043
   317
  are available when the context $name$ is subsequently entered.
ballarin@17043
   318
  Note that, like import, this is dynamic: facts added to a locale
ballarin@17139
   319
  part of $expr$ after interpretation become also available in
ballarin@17043
   320
  $name$.  Like facts
ballarin@17043
   321
  of renamed context elements, facts obtained by interpretation may be
ballarin@17043
   322
  accessed by prefixing with the parameter renaming (where the parameters
ballarin@17043
   323
  are separated by `\_').
ballarin@17043
   324
ballarin@17043
   325
  Unlike interpretation in theories, instantiation is confined to the
ballarin@17043
   326
  renaming of parameters, which may be specified as part of the context
ballarin@17043
   327
  expression $expr$.  Using defined parameters in $name$ one may
ballarin@17043
   328
  achieve an effect similar to instantiation, though.
ballarin@17043
   329
ballarin@17043
   330
  Only specification fragments of $expr$ that are not already part of
ballarin@17043
   331
  $name$ (be it imported, derived or a derived fragment of the import)
ballarin@17043
   332
  are considered by interpretation.  This enables circular
ballarin@17043
   333
  interpretations.
ballarin@17043
   334
ballarin@17139
   335
  If interpretations of $name$ exist in the current theory, the
ballarin@17139
   336
  command adds interpretations for $expr$ as well, with the same
ballarin@17139
   337
  prefix and attributes, although only for fragments of $expr$ that
ballarin@17139
   338
  are not interpreted in the theory already.
ballarin@17139
   339
ballarin@15763
   340
\item [$\isarcmd{interpret}~expr~insts$]
ballarin@15763
   341
  interprets $expr$ in the proof context and is otherwise similar to
ballarin@17043
   342
  interpretation in theories.  Free variables in instantiations are not
ballarin@15763
   343
  generalized, however.
ballarin@15763
   344
ballarin@15763
   345
\item [$\isarcmd{print_interps}~loc$]
ballarin@15763
   346
  prints the interpretations of a particular locale $loc$ that are
ballarin@17139
   347
  active in the current context, either theory or proof context.  The
ballarin@17139
   348
  exclamation point argument causes triggers printing of
ballarin@17139
   349
  \emph{witness} theorems justifying interpretations.  These are
ballarin@17139
   350
  normally omitted from the output.
ballarin@17139
   351
ballarin@15763
   352
  
ballarin@15763
   353
\end{descr}
ballarin@15763
   354
ballarin@15837
   355
\begin{warn}
ballarin@15837
   356
  Since attributes are applied to interpreted theorems, interpretation
ballarin@15837
   357
  may modify the current simpset and claset.  Take this into
ballarin@15837
   358
  account when choosing attributes for local theorems.
ballarin@15837
   359
\end{warn}
ballarin@15837
   360
ballarin@16168
   361
\begin{warn}
ballarin@17043
   362
  An interpretation in a theory may subsume previous interpretations.
ballarin@17043
   363
  This happens if the same specification fragment is interpreted twice
ballarin@17043
   364
  and the instantiation of the second interpretation is more general
ballarin@17043
   365
  than the interpretation of the first.  A warning
ballarin@16168
   366
  is issued, since it is likely that these could have been generalized
ballarin@16168
   367
  in the first place.  The locale package does not attempt to remove
ballarin@16168
   368
  subsumed interpretations.  This situation is normally harmless, but
ballarin@16168
   369
  note that $blast$ gets confused by the presence of multiple axclass
ballarin@17139
   370
  instances of a rule.
ballarin@16168
   371
\end{warn}
ballarin@16168
   372
ballarin@15763
   373
wenzelm@12621
   374
\section{Derived proof schemes}
wenzelm@12621
   375
wenzelm@12621
   376
\subsection{Generalized elimination}\label{sec:obtain}
wenzelm@12621
   377
wenzelm@17864
   378
\indexisarcmd{obtain}\indexisarcmd{guess}
wenzelm@12621
   379
\begin{matharray}{rcl}
wenzelm@12621
   380
  \isarcmd{obtain} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@17864
   381
  \isarcmd{guess}^* & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@12621
   382
\end{matharray}
wenzelm@12621
   383
wenzelm@12621
   384
Generalized elimination means that additional elements with certain properties
wenzelm@13041
   385
may be introduced in the current context, by virtue of a locally proven
wenzelm@12621
   386
``soundness statement''.  Technically speaking, the $\OBTAINNAME$ language
wenzelm@12621
   387
element is like a declaration of $\FIXNAME$ and $\ASSUMENAME$ (see also see
wenzelm@12621
   388
\S\ref{sec:proof-context}), together with a soundness proof of its additional
wenzelm@12621
   389
claim.  According to the nature of existential reasoning, assumptions get
wenzelm@12621
   390
eliminated from any result exported from the context later, provided that the
wenzelm@12621
   391
corresponding parameters do \emph{not} occur in the conclusion.
wenzelm@12621
   392
wenzelm@12621
   393
\begin{rail}
wenzelm@12879
   394
  'obtain' (vars + 'and') 'where' (props + 'and')
wenzelm@12621
   395
  ;
wenzelm@17864
   396
  'guess' (vars + 'and')
wenzelm@17864
   397
  ;
wenzelm@12621
   398
\end{rail}
wenzelm@12621
   399
wenzelm@12621
   400
$\OBTAINNAME$ is defined as a derived Isar command as follows, where $\vec b$
wenzelm@12621
   401
shall refer to (optional) facts indicated for forward chaining.
wenzelm@12621
   402
\begin{matharray}{l}
wenzelm@12621
   403
  \langle facts~\vec b\rangle \\
wenzelm@12621
   404
  \OBTAIN{\vec x}{a}{\vec \phi}~~\langle proof\rangle \equiv {} \\[1ex]
wenzelm@13041
   405
  \quad \HAVE{}{\All{thesis} (\All{\vec x} \vec\phi \Imp thesis) \Imp thesis} \\
wenzelm@13041
   406
  \quad \PROOF{succeed} \\
wenzelm@12621
   407
  \qquad \FIX{thesis} \\
wenzelm@13041
   408
  \qquad \ASSUME{that~[intro?]}{\All{\vec x} \vec\phi \Imp thesis} \\
wenzelm@13042
   409
  \qquad \THUS{}{thesis} \\
wenzelm@13042
   410
  \quad\qquad \APPLY{-} \\
wenzelm@13041
   411
  \quad\qquad \USING{\vec b}~~\langle proof\rangle \\
wenzelm@13041
   412
  \quad \QED{} \\
wenzelm@12621
   413
  \quad \FIX{\vec x}~\ASSUMENAME^\ast~a\colon~\vec\phi \\
wenzelm@12621
   414
\end{matharray}
wenzelm@12621
   415
wenzelm@12621
   416
Typically, the soundness proof is relatively straight-forward, often just by
wenzelm@13048
   417
canonical automated tools such as ``$\BY{simp}$'' or ``$\BY{blast}$''.
wenzelm@13048
   418
Accordingly, the ``$that$'' reduction above is declared as simplification and
wenzelm@13048
   419
introduction rule.
wenzelm@12621
   420
wenzelm@12621
   421
In a sense, $\OBTAINNAME$ represents at the level of Isar proofs what would be
wenzelm@12621
   422
meta-logical existential quantifiers and conjunctions.  This concept has a
wenzelm@13041
   423
broad range of useful applications, ranging from plain elimination (or
wenzelm@17864
   424
introduction) of object-level existential and conjunctions, to elimination
wenzelm@12621
   425
over results of symbolic evaluation of recursive definitions, for example.
wenzelm@12621
   426
Also note that $\OBTAINNAME$ without parameters acts much like $\HAVENAME$,
wenzelm@13041
   427
where the result is treated as a genuine assumption.
wenzelm@12621
   428
wenzelm@17864
   429
\medskip
wenzelm@17864
   430
wenzelm@17864
   431
The improper variant $\isarkeyword{guess}$ is similar to $\OBTAINNAME$, but
wenzelm@17864
   432
derives the obtained statement from the course of reasoning!  The proof starts
wenzelm@17864
   433
with a fixed goal $thesis$.  The subsequent proof may refine this to anything
wenzelm@17864
   434
of the form like $\All{\vec x} \vec\phi \Imp thesis$, but must not introduce
wenzelm@17864
   435
new subgoals.  The final goal state is then used as reduction rule for the
wenzelm@17864
   436
obtain scheme described above.  Obtained parameters $\vec x$ are marked as
wenzelm@17864
   437
internal by default, which prevents the proof context from being polluted by
wenzelm@17864
   438
ad-hoc variables.  The variable names and type constraints given as arguments
wenzelm@17864
   439
for $\isarkeyword{guess}$ specify a prefix of obtained parameters explicitly
wenzelm@17864
   440
in the text.
wenzelm@17864
   441
wenzelm@17864
   442
It is important to note that the facts introduced by $\OBTAINNAME$ and
wenzelm@17864
   443
$\isarkeyword{guess}$ may not be polymorphic: any type-variables occurring
wenzelm@17864
   444
here are fixed in the present context!
wenzelm@17864
   445
wenzelm@12621
   446
wenzelm@12621
   447
\subsection{Calculational reasoning}\label{sec:calculation}
wenzelm@7315
   448
wenzelm@8619
   449
\indexisarcmd{also}\indexisarcmd{finally}
wenzelm@8619
   450
\indexisarcmd{moreover}\indexisarcmd{ultimately}
wenzelm@12976
   451
\indexisarcmd{print-trans-rules}
wenzelm@12976
   452
\indexisaratt{trans}\indexisaratt{sym}\indexisaratt{symmetric}
wenzelm@7315
   453
\begin{matharray}{rcl}
wenzelm@7315
   454
  \isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7315
   455
  \isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@8619
   456
  \isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@8619
   457
  \isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@10154
   458
  \isarcmd{print_trans_rules}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@7315
   459
  trans & : & \isaratt \\
wenzelm@12976
   460
  sym & : & \isaratt \\
wenzelm@12976
   461
  symmetric & : & \isaratt \\
wenzelm@7315
   462
\end{matharray}
wenzelm@7315
   463
wenzelm@7315
   464
Calculational proof is forward reasoning with implicit application of
oheimb@11332
   465
transitivity rules (such those of $=$, $\leq$, $<$).  Isabelle/Isar maintains
wenzelm@7391
   466
an auxiliary register $calculation$\indexisarthm{calculation} for accumulating
wenzelm@7897
   467
results obtained by transitivity composed with the current result.  Command
wenzelm@7897
   468
$\ALSO$ updates $calculation$ involving $this$, while $\FINALLY$ exhibits the
wenzelm@7897
   469
final $calculation$ by forward chaining towards the next goal statement.  Both
wenzelm@7897
   470
commands require valid current facts, i.e.\ may occur only after commands that
wenzelm@7897
   471
produce theorems such as $\ASSUMENAME$, $\NOTENAME$, or some finished proof of
wenzelm@8619
   472
$\HAVENAME$, $\SHOWNAME$ etc.  The $\MOREOVER$ and $\ULTIMATELY$ commands are
wenzelm@8619
   473
similar to $\ALSO$ and $\FINALLY$, but only collect further results in
wenzelm@8619
   474
$calculation$ without applying any rules yet.
wenzelm@7315
   475
wenzelm@13041
   476
Also note that the implicit term abbreviation ``$\dots$'' has its canonical
wenzelm@13041
   477
application with calculational proofs.  It refers to the argument of the
wenzelm@13041
   478
preceding statement. (The argument of a curried infix expression happens to be
wenzelm@13041
   479
its right-hand side.)
wenzelm@7315
   480
wenzelm@7315
   481
Isabelle/Isar calculations are implicitly subject to block structure in the
wenzelm@7315
   482
sense that new threads of calculational reasoning are commenced for any new
wenzelm@7315
   483
block (as opened by a local goal, for example).  This means that, apart from
wenzelm@7315
   484
being able to nest calculations, there is no separate \emph{begin-calculation}
wenzelm@7315
   485
command required.
wenzelm@7315
   486
wenzelm@8619
   487
\medskip
wenzelm@8619
   488
wenzelm@13041
   489
The Isar calculation proof commands may be defined as follows:\footnote{We
wenzelm@13041
   490
  suppress internal bookkeeping such as proper handling of block-structure.}
wenzelm@8619
   491
\begin{matharray}{rcl}
wenzelm@8619
   492
  \ALSO@0 & \equiv & \NOTE{calculation}{this} \\
wenzelm@9606
   493
  \ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\[0.5ex]
wenzelm@8619
   494
  \FINALLY & \equiv & \ALSO~\FROM{calculation} \\
wenzelm@8619
   495
  \MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\
wenzelm@8619
   496
  \ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\
wenzelm@8619
   497
\end{matharray}
wenzelm@8619
   498
wenzelm@7315
   499
\begin{rail}
wenzelm@13024
   500
  ('also' | 'finally') ('(' thmrefs ')')?
wenzelm@8619
   501
  ;
wenzelm@8507
   502
  'trans' (() | 'add' | 'del')
wenzelm@7315
   503
  ;
wenzelm@7315
   504
\end{rail}
wenzelm@7315
   505
wenzelm@7315
   506
\begin{descr}
wenzelm@13041
   507
wenzelm@8547
   508
\item [$\ALSO~(\vec a)$] maintains the auxiliary $calculation$ register as
wenzelm@7315
   509
  follows.  The first occurrence of $\ALSO$ in some calculational thread
wenzelm@7905
   510
  initializes $calculation$ by $this$. Any subsequent $\ALSO$ on the same
wenzelm@7335
   511
  level of block-structure updates $calculation$ by some transitivity rule
wenzelm@7458
   512
  applied to $calculation$ and $this$ (in that order).  Transitivity rules are
wenzelm@11095
   513
  picked from the current context, unless alternative rules are given as
wenzelm@11095
   514
  explicit arguments.
wenzelm@9614
   515
wenzelm@8547
   516
\item [$\FINALLY~(\vec a)$] maintaining $calculation$ in the same way as
wenzelm@7315
   517
  $\ALSO$, and concludes the current calculational thread.  The final result
wenzelm@7315
   518
  is exhibited as fact for forward chaining towards the next goal. Basically,
wenzelm@7987
   519
  $\FINALLY$ just abbreviates $\ALSO~\FROM{calculation}$.  Note that
wenzelm@7987
   520
  ``$\FINALLY~\SHOW{}{\Var{thesis}}~\DOT$'' and
wenzelm@7987
   521
  ``$\FINALLY~\HAVE{}{\phi}~\DOT$'' are typical idioms for concluding
wenzelm@7987
   522
  calculational proofs.
wenzelm@9614
   523
wenzelm@8619
   524
\item [$\MOREOVER$ and $\ULTIMATELY$] are analogous to $\ALSO$ and $\FINALLY$,
wenzelm@8619
   525
  but collect results only, without applying rules.
wenzelm@13041
   526
wenzelm@13024
   527
\item [$\isarkeyword{print_trans_rules}$] prints the list of transitivity
wenzelm@13024
   528
  rules (for calculational commands $\ALSO$ and $\FINALLY$) and symmetry rules
wenzelm@13024
   529
  (for the $symmetric$ operation and single step elimination patters) of the
wenzelm@13024
   530
  current context.
wenzelm@13041
   531
wenzelm@8547
   532
\item [$trans$] declares theorems as transitivity rules.
wenzelm@13041
   533
wenzelm@13024
   534
\item [$sym$] declares symmetry rules.
wenzelm@13041
   535
wenzelm@12976
   536
\item [$symmetric$] resolves a theorem with some rule declared as $sym$ in the
wenzelm@12976
   537
  current context.  For example, ``$\ASSUME{[symmetric]}{x = y}$'' produces a
wenzelm@12976
   538
  swapped fact derived from that assumption.
wenzelm@13041
   539
wenzelm@13024
   540
  In structured proof texts it is often more appropriate to use an explicit
wenzelm@13024
   541
  single-step elimination proof, such as ``$\ASSUME{}{x = y}~\HENCE{}{y =
wenzelm@13041
   542
    x}~\DDOT$''.  The very same rules known to $symmetric$ are declared as
wenzelm@13041
   543
  $elim?$ as well.
wenzelm@13027
   544
wenzelm@7315
   545
\end{descr}
wenzelm@7315
   546
wenzelm@7315
   547
wenzelm@13041
   548
\section{Proof tools}
wenzelm@8517
   549
wenzelm@12618
   550
\subsection{Miscellaneous methods and attributes}\label{sec:misc-meth-att}
wenzelm@8517
   551
wenzelm@9606
   552
\indexisarmeth{unfold}\indexisarmeth{fold}\indexisarmeth{insert}
wenzelm@8517
   553
\indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule}
wenzelm@8517
   554
\indexisarmeth{fail}\indexisarmeth{succeed}
wenzelm@8517
   555
\begin{matharray}{rcl}
wenzelm@8517
   556
  unfold & : & \isarmeth \\
wenzelm@10741
   557
  fold & : & \isarmeth \\
wenzelm@10741
   558
  insert & : & \isarmeth \\[0.5ex]
wenzelm@8517
   559
  erule^* & : & \isarmeth \\
wenzelm@8517
   560
  drule^* & : & \isarmeth \\
wenzelm@13024
   561
  frule^* & : & \isarmeth \\
wenzelm@8517
   562
  succeed & : & \isarmeth \\
wenzelm@8517
   563
  fail & : & \isarmeth \\
wenzelm@8517
   564
\end{matharray}
wenzelm@8517
   565
wenzelm@8517
   566
\begin{rail}
wenzelm@10741
   567
  ('fold' | 'unfold' | 'insert') thmrefs
wenzelm@10741
   568
  ;
wenzelm@10741
   569
  ('erule' | 'drule' | 'frule') ('('nat')')? thmrefs
wenzelm@7135
   570
  ;
wenzelm@7135
   571
\end{rail}
wenzelm@7135
   572
wenzelm@7167
   573
\begin{descr}
wenzelm@13041
   574
wenzelm@13024
   575
\item [$unfold~\vec a$ and $fold~\vec a$] expand (or fold back again) the
wenzelm@13024
   576
  given meta-level definitions throughout all goals; any chained facts
wenzelm@13024
   577
  provided are inserted into the goal and subject to rewriting as well.
wenzelm@13041
   578
wenzelm@10741
   579
\item [$insert~\vec a$] inserts theorems as facts into all goals of the proof
wenzelm@10741
   580
  state.  Note that current facts indicated for forward chaining are ignored.
wenzelm@13024
   581
wenzelm@8547
   582
\item [$erule~\vec a$, $drule~\vec a$, and $frule~\vec a$] are similar to the
wenzelm@8547
   583
  basic $rule$ method (see \S\ref{sec:pure-meth-att}), but apply rules by
wenzelm@8517
   584
  elim-resolution, destruct-resolution, and forward-resolution, respectively
wenzelm@10741
   585
  \cite{isabelle-ref}.  The optional natural number argument (default $0$)
wenzelm@13041
   586
  specifies additional assumption steps to be performed here.
wenzelm@13041
   587
wenzelm@10741
   588
  Note that these methods are improper ones, mainly serving for
wenzelm@10741
   589
  experimentation and tactic script emulation.  Different modes of basic rule
wenzelm@10741
   590
  application are usually expressed in Isar at the proof language level,
wenzelm@10741
   591
  rather than via implicit proof state manipulations.  For example, a proper
wenzelm@13041
   592
  single-step elimination would be done using the plain $rule$ method, with
wenzelm@10741
   593
  forward chaining of current facts.
wenzelm@13024
   594
wenzelm@8517
   595
\item [$succeed$] yields a single (unchanged) result; it is the identity of
wenzelm@8517
   596
  the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:syn-meth}).
wenzelm@13024
   597
wenzelm@8517
   598
\item [$fail$] yields an empty result sequence; it is the identity of the
wenzelm@8517
   599
  ``\texttt{|}'' method combinator (cf.\ \S\ref{sec:syn-meth}).
wenzelm@13024
   600
wenzelm@7167
   601
\end{descr}
wenzelm@7135
   602
wenzelm@10318
   603
\indexisaratt{tagged}\indexisaratt{untagged}
wenzelm@9614
   604
\indexisaratt{THEN}\indexisaratt{COMP}
ballarin@14175
   605
\indexisaratt{unfolded}\indexisaratt{folded}
wenzelm@13027
   606
\indexisaratt{standard}\indexisarattof{Pure}{elim-format}
wenzelm@13024
   607
\indexisaratt{no-vars}
wenzelm@8517
   608
\begin{matharray}{rcl}
wenzelm@9905
   609
  tagged & : & \isaratt \\
wenzelm@9905
   610
  untagged & : & \isaratt \\[0.5ex]
wenzelm@9614
   611
  THEN & : & \isaratt \\
wenzelm@8517
   612
  COMP & : & \isaratt \\[0.5ex]
wenzelm@9905
   613
  unfolded & : & \isaratt \\
wenzelm@9905
   614
  folded & : & \isaratt \\[0.5ex]
wenzelm@9941
   615
  elim_format & : & \isaratt \\
wenzelm@13041
   616
  standard^* & : & \isaratt \\
wenzelm@9936
   617
  no_vars^* & : & \isaratt \\
wenzelm@8517
   618
\end{matharray}
wenzelm@8517
   619
wenzelm@8517
   620
\begin{rail}
wenzelm@9905
   621
  'tagged' (nameref+)
wenzelm@8517
   622
  ;
wenzelm@9905
   623
  'untagged' name
wenzelm@8517
   624
  ;
wenzelm@10154
   625
  ('THEN' | 'COMP') ('[' nat ']')? thmref
wenzelm@8517
   626
  ;
wenzelm@9905
   627
  ('unfolded' | 'folded') thmrefs
wenzelm@8517
   628
  ;
wenzelm@8517
   629
\end{rail}
wenzelm@8517
   630
wenzelm@8517
   631
\begin{descr}
wenzelm@13041
   632
wenzelm@9905
   633
\item [$tagged~name~args$ and $untagged~name$] add and remove $tags$ of some
wenzelm@8517
   634
  theorem.  Tags may be any list of strings that serve as comment for some
wenzelm@8517
   635
  tools (e.g.\ $\LEMMANAME$ causes the tag ``$lemma$'' to be added to the
wenzelm@8517
   636
  result).  The first string is considered the tag name, the rest its
wenzelm@8517
   637
  arguments.  Note that untag removes any tags of the same name.
wenzelm@13041
   638
wenzelm@13041
   639
\item [$THEN~a$ and $COMP~a$] compose rules by resolution.  $THEN$ resolves
wenzelm@13041
   640
  with the first premise of $a$ (an alternative position may be also
wenzelm@13041
   641
  specified); the $COMP$ version skips the automatic lifting process that is
wenzelm@13041
   642
  normally intended (cf.\ \texttt{RS} and \texttt{COMP} in
wenzelm@8547
   643
  \cite[\S5]{isabelle-ref}).
wenzelm@13041
   644
wenzelm@9905
   645
\item [$unfolded~\vec a$ and $folded~\vec a$] expand and fold back again the
wenzelm@9905
   646
  given meta-level definitions throughout a rule.
wenzelm@13041
   647
wenzelm@13027
   648
\item [$elim_format$] turns a destruction rule into elimination rule format,
wenzelm@13027
   649
  by resolving with the rule $\PROP A \Imp (\PROP A \Imp \PROP B) \Imp \PROP
wenzelm@13027
   650
  B$.
wenzelm@13048
   651
  
wenzelm@13048
   652
  Note that the Classical Reasoner (\S\ref{sec:classical}) provides its own
wenzelm@13048
   653
  version of this operation.
wenzelm@13041
   654
wenzelm@13041
   655
\item [$standard$] puts a theorem into the standard form of object-rules at
wenzelm@13041
   656
  the outermost theory level.  Note that this operation violates the local
wenzelm@13041
   657
  proof context (including active locales).
wenzelm@13041
   658
wenzelm@9232
   659
\item [$no_vars$] replaces schematic variables by free ones; this is mainly
wenzelm@9232
   660
  for tuning output of pretty printed theorems.
wenzelm@13027
   661
wenzelm@8517
   662
\end{descr}
wenzelm@7135
   663
wenzelm@7135
   664
wenzelm@12621
   665
\subsection{Further tactic emulations}\label{sec:tactics}
wenzelm@9606
   666
wenzelm@9606
   667
The following improper proof methods emulate traditional tactics.  These admit
wenzelm@9606
   668
direct access to the goal state, which is normally considered harmful!  In
wenzelm@9606
   669
particular, this may involve both numbered goal addressing (default 1), and
wenzelm@9606
   670
dynamic instantiation within the scope of some subgoal.
wenzelm@9606
   671
wenzelm@9606
   672
\begin{warn}
ballarin@14175
   673
  Dynamic instantiations refer to universally quantified parameters of
ballarin@14175
   674
  a subgoal (the dynamic context) rather than fixed variables and term
ballarin@14175
   675
  abbreviations of a (static) Isar context.
wenzelm@9606
   676
\end{warn}
wenzelm@9606
   677
ballarin@14175
   678
Tactic emulation methods, unlike their ML counterparts, admit
ballarin@14175
   679
simultaneous instantiation from both dynamic and static contexts.  If
ballarin@14175
   680
names occur in both contexts goal parameters hide locally fixed
ballarin@14175
   681
variables.  Likewise, schematic variables refer to term abbreviations,
ballarin@14175
   682
if present in the static context.  Otherwise the schematic variable is
ballarin@14175
   683
interpreted as a schematic variable and left to be solved by unification
ballarin@14175
   684
with certain parts of the subgoal.
ballarin@14175
   685
wenzelm@9606
   686
Note that the tactic emulation proof methods in Isabelle/Isar are consistently
ballarin@14175
   687
named $foo_tac$.  Note also that variable names occurring on left hand sides
ballarin@14212
   688
of instantiations must be preceded by a question mark if they coincide with
ballarin@14212
   689
a keyword or contain dots.
ballarin@14175
   690
This is consistent with the attribute $where$ (see \S\ref{sec:pure-meth-att}).
wenzelm@9606
   691
wenzelm@9606
   692
\indexisarmeth{rule-tac}\indexisarmeth{erule-tac}
wenzelm@9606
   693
\indexisarmeth{drule-tac}\indexisarmeth{frule-tac}
wenzelm@9606
   694
\indexisarmeth{cut-tac}\indexisarmeth{thin-tac}
wenzelm@9642
   695
\indexisarmeth{subgoal-tac}\indexisarmeth{rename-tac}
wenzelm@9614
   696
\indexisarmeth{rotate-tac}\indexisarmeth{tactic}
wenzelm@9606
   697
\begin{matharray}{rcl}
wenzelm@9606
   698
  rule_tac^* & : & \isarmeth \\
wenzelm@9606
   699
  erule_tac^* & : & \isarmeth \\
wenzelm@9606
   700
  drule_tac^* & : & \isarmeth \\
wenzelm@9606
   701
  frule_tac^* & : & \isarmeth \\
wenzelm@9606
   702
  cut_tac^* & : & \isarmeth \\
wenzelm@9606
   703
  thin_tac^* & : & \isarmeth \\
wenzelm@9606
   704
  subgoal_tac^* & : & \isarmeth \\
wenzelm@9614
   705
  rename_tac^* & : & \isarmeth \\
wenzelm@9614
   706
  rotate_tac^* & : & \isarmeth \\
wenzelm@9606
   707
  tactic^* & : & \isarmeth \\
wenzelm@9606
   708
\end{matharray}
wenzelm@9606
   709
wenzelm@9606
   710
\railalias{ruletac}{rule\_tac}
wenzelm@9606
   711
\railterm{ruletac}
wenzelm@9606
   712
wenzelm@9606
   713
\railalias{eruletac}{erule\_tac}
wenzelm@9606
   714
\railterm{eruletac}
wenzelm@9606
   715
wenzelm@9606
   716
\railalias{druletac}{drule\_tac}
wenzelm@9606
   717
\railterm{druletac}
wenzelm@9606
   718
wenzelm@9606
   719
\railalias{fruletac}{frule\_tac}
wenzelm@9606
   720
\railterm{fruletac}
wenzelm@9606
   721
wenzelm@9606
   722
\railalias{cuttac}{cut\_tac}
wenzelm@9606
   723
\railterm{cuttac}
wenzelm@9606
   724
wenzelm@9606
   725
\railalias{thintac}{thin\_tac}
wenzelm@9606
   726
\railterm{thintac}
wenzelm@9606
   727
wenzelm@9606
   728
\railalias{subgoaltac}{subgoal\_tac}
wenzelm@9606
   729
\railterm{subgoaltac}
wenzelm@9606
   730
wenzelm@9614
   731
\railalias{renametac}{rename\_tac}
wenzelm@9614
   732
\railterm{renametac}
wenzelm@9614
   733
wenzelm@9614
   734
\railalias{rotatetac}{rotate\_tac}
wenzelm@9614
   735
\railterm{rotatetac}
wenzelm@9614
   736
wenzelm@9606
   737
\begin{rail}
wenzelm@9606
   738
  ( ruletac | eruletac | druletac | fruletac | cuttac | thintac ) goalspec?
wenzelm@9606
   739
  ( insts thmref | thmrefs )
wenzelm@9606
   740
  ;
wenzelm@9606
   741
  subgoaltac goalspec? (prop +)
wenzelm@9606
   742
  ;
wenzelm@9614
   743
  renametac goalspec? (name +)
wenzelm@9614
   744
  ;
wenzelm@9614
   745
  rotatetac goalspec? int?
wenzelm@9614
   746
  ;
wenzelm@9606
   747
  'tactic' text
wenzelm@9606
   748
  ;
wenzelm@9606
   749
wenzelm@9606
   750
  insts: ((name '=' term) + 'and') 'in'
wenzelm@9606
   751
  ;
wenzelm@9606
   752
\end{rail}
wenzelm@9606
   753
wenzelm@9606
   754
\begin{descr}
wenzelm@13041
   755
wenzelm@9606
   756
\item [$rule_tac$ etc.] do resolution of rules with explicit instantiation.
wenzelm@9606
   757
  This works the same way as the ML tactics \texttt{res_inst_tac} etc. (see
wenzelm@9606
   758
  \cite[\S3]{isabelle-ref}).
wenzelm@13041
   759
wenzelm@13041
   760
  Multiple rules may be only given if there is no instantiation; then
wenzelm@9606
   761
  $rule_tac$ is the same as \texttt{resolve_tac} in ML (see
wenzelm@9606
   762
  \cite[\S3]{isabelle-ref}).
wenzelm@13041
   763
wenzelm@9606
   764
\item [$cut_tac$] inserts facts into the proof state as assumption of a
wenzelm@9606
   765
  subgoal, see also \texttt{cut_facts_tac} in \cite[\S3]{isabelle-ref}.  Note
wenzelm@13027
   766
  that the scope of schematic variables is spread over the main goal
wenzelm@13027
   767
  statement.  Instantiations may be given as well, see also ML tactic
wenzelm@9606
   768
  \texttt{cut_inst_tac} in \cite[\S3]{isabelle-ref}.
wenzelm@13041
   769
wenzelm@9606
   770
\item [$thin_tac~\phi$] deletes the specified assumption from a subgoal; note
wenzelm@9606
   771
  that $\phi$ may contain schematic variables.  See also \texttt{thin_tac} in
wenzelm@9606
   772
  \cite[\S3]{isabelle-ref}.
wenzelm@13041
   773
wenzelm@9606
   774
\item [$subgoal_tac~\phi$] adds $\phi$ as an assumption to a subgoal.  See
wenzelm@9606
   775
  also \texttt{subgoal_tac} and \texttt{subgoals_tac} in
wenzelm@9606
   776
  \cite[\S3]{isabelle-ref}.
wenzelm@13041
   777
wenzelm@9614
   778
\item [$rename_tac~\vec x$] renames parameters of a goal according to the list
wenzelm@9614
   779
  $\vec x$, which refers to the \emph{suffix} of variables.
wenzelm@13041
   780
wenzelm@9614
   781
\item [$rotate_tac~n$] rotates the assumptions of a goal by $n$ positions:
wenzelm@9614
   782
  from right to left if $n$ is positive, and from left to right if $n$ is
wenzelm@9614
   783
  negative; the default value is $1$.  See also \texttt{rotate_tac} in
wenzelm@9614
   784
  \cite[\S3]{isabelle-ref}.
wenzelm@13041
   785
wenzelm@9606
   786
\item [$tactic~text$] produces a proof method from any ML text of type
wenzelm@9606
   787
  \texttt{tactic}.  Apart from the usual ML environment and the current
wenzelm@9606
   788
  implicit theory context, the ML code may refer to the following locally
wenzelm@9606
   789
  bound values:
wenzelm@9606
   790
wenzelm@9606
   791
{\footnotesize\begin{verbatim}
wenzelm@9606
   792
val ctxt  : Proof.context
wenzelm@9606
   793
val facts : thm list
wenzelm@9606
   794
val thm   : string -> thm
wenzelm@9606
   795
val thms  : string -> thm list
wenzelm@9606
   796
\end{verbatim}}
wenzelm@9606
   797
  Here \texttt{ctxt} refers to the current proof context, \texttt{facts}
wenzelm@9606
   798
  indicates any current facts for forward-chaining, and
wenzelm@9606
   799
  \texttt{thm}~/~\texttt{thms} retrieve named facts (including global
wenzelm@9606
   800
  theorems) from the context.
wenzelm@9606
   801
\end{descr}
wenzelm@9606
   802
wenzelm@9606
   803
wenzelm@12621
   804
\subsection{The Simplifier}\label{sec:simplifier}
wenzelm@7135
   805
wenzelm@13048
   806
\subsubsection{Simplification methods}
wenzelm@12618
   807
wenzelm@8483
   808
\indexisarmeth{simp}\indexisarmeth{simp-all}
wenzelm@7315
   809
\begin{matharray}{rcl}
wenzelm@7315
   810
  simp & : & \isarmeth \\
wenzelm@8483
   811
  simp_all & : & \isarmeth \\
wenzelm@7315
   812
\end{matharray}
wenzelm@7315
   813
wenzelm@8483
   814
\railalias{simpall}{simp\_all}
wenzelm@8483
   815
\railterm{simpall}
wenzelm@8483
   816
wenzelm@8704
   817
\railalias{noasm}{no\_asm}
wenzelm@8704
   818
\railterm{noasm}
wenzelm@8704
   819
wenzelm@8704
   820
\railalias{noasmsimp}{no\_asm\_simp}
wenzelm@8704
   821
\railterm{noasmsimp}
wenzelm@8704
   822
wenzelm@8704
   823
\railalias{noasmuse}{no\_asm\_use}
wenzelm@8704
   824
\railterm{noasmuse}
wenzelm@8704
   825
berghofe@13617
   826
\railalias{asmlr}{asm\_lr}
berghofe@13617
   827
\railterm{asmlr}
berghofe@13617
   828
wenzelm@11128
   829
\indexouternonterm{simpmod}
wenzelm@7315
   830
\begin{rail}
wenzelm@13027
   831
  ('simp' | simpall) ('!' ?) opt? (simpmod *)
wenzelm@7315
   832
  ;
wenzelm@7315
   833
berghofe@13617
   834
  opt: '(' (noasm | noasmsimp | noasmuse | asmlr) ')'
wenzelm@8704
   835
  ;
wenzelm@9711
   836
  simpmod: ('add' | 'del' | 'only' | 'cong' (() | 'add' | 'del') |
wenzelm@9847
   837
    'split' (() | 'add' | 'del')) ':' thmrefs
wenzelm@7315
   838
  ;
wenzelm@7315
   839
\end{rail}
wenzelm@7315
   840
wenzelm@7321
   841
\begin{descr}
wenzelm@13015
   842
wenzelm@8547
   843
\item [$simp$] invokes Isabelle's simplifier, after declaring additional rules
wenzelm@8594
   844
  according to the arguments given.  Note that the \railtterm{only} modifier
wenzelm@8547
   845
  first removes all other rewrite rules, congruences, and looper tactics
wenzelm@8594
   846
  (including splits), and then behaves like \railtterm{add}.
wenzelm@13041
   847
wenzelm@9711
   848
  \medskip The \railtterm{cong} modifiers add or delete Simplifier congruence
wenzelm@9711
   849
  rules (see also \cite{isabelle-ref}), the default is to add.
wenzelm@13041
   850
wenzelm@9711
   851
  \medskip The \railtterm{split} modifiers add or delete rules for the
wenzelm@9711
   852
  Splitter (see also \cite{isabelle-ref}), the default is to add.  This works
wenzelm@9711
   853
  only if the Simplifier method has been properly setup to include the
wenzelm@9711
   854
  Splitter (all major object logics such HOL, HOLCF, FOL, ZF do this already).
wenzelm@13041
   855
wenzelm@13015
   856
\item [$simp_all$] is similar to $simp$, but acts on all goals (backwards from
wenzelm@13015
   857
  the last to the first one).
wenzelm@13015
   858
wenzelm@7321
   859
\end{descr}
wenzelm@7321
   860
wenzelm@13015
   861
By default the Simplifier methods take local assumptions fully into account,
wenzelm@13015
   862
using equational assumptions in the subsequent normalization process, or
wenzelm@13024
   863
simplifying assumptions themselves (cf.\ \texttt{asm_full_simp_tac} in
wenzelm@13015
   864
\cite[\S10]{isabelle-ref}).  In structured proofs this is usually quite well
wenzelm@13015
   865
behaved in practice: just the local premises of the actual goal are involved,
wenzelm@13041
   866
additional facts may be inserted via explicit forward-chaining (using $\THEN$,
wenzelm@13015
   867
$\FROMNAME$ etc.).  The full context of assumptions is only included if the
wenzelm@13015
   868
``$!$'' (bang) argument is given, which should be used with some care, though.
wenzelm@7321
   869
wenzelm@13015
   870
Additional Simplifier options may be specified to tune the behavior further
wenzelm@13041
   871
(mostly for unstructured scripts with many accidental local facts):
wenzelm@13041
   872
``$(no_asm)$'' means assumptions are ignored completely (cf.\
wenzelm@13041
   873
\texttt{simp_tac}), ``$(no_asm_simp)$'' means assumptions are used in the
wenzelm@13041
   874
simplification of the conclusion but are not themselves simplified (cf.\
wenzelm@13041
   875
\texttt{asm_simp_tac}), and ``$(no_asm_use)$'' means assumptions are
wenzelm@13041
   876
simplified but are not used in the simplification of each other or the
wenzelm@13041
   877
conclusion (cf.\ \texttt{full_simp_tac}).
berghofe@13617
   878
For compatibility reasons, there is also an option ``$(asm_lr)$'',
berghofe@13617
   879
which means that an assumption is only used for simplifying assumptions
berghofe@13617
   880
which are to the right of it (cf.\ \texttt{asm_lr_simp_tac}).
wenzelm@8704
   881
wenzelm@8704
   882
\medskip
wenzelm@8704
   883
wenzelm@8704
   884
The Splitter package is usually configured to work as part of the Simplifier.
wenzelm@9711
   885
The effect of repeatedly applying \texttt{split_tac} can be simulated by
wenzelm@13041
   886
``$(simp~only\colon~split\colon~\vec a)$''.  There is also a separate $split$
wenzelm@13041
   887
method available for single-step case splitting.
wenzelm@8483
   888
wenzelm@8483
   889
wenzelm@12621
   890
\subsubsection{Declaring rules}
wenzelm@8483
   891
wenzelm@8667
   892
\indexisarcmd{print-simpset}
wenzelm@8638
   893
\indexisaratt{simp}\indexisaratt{split}\indexisaratt{cong}
wenzelm@7321
   894
\begin{matharray}{rcl}
wenzelm@13024
   895
  \isarcmd{print_simpset}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@7321
   896
  simp & : & \isaratt \\
wenzelm@9711
   897
  cong & : & \isaratt \\
wenzelm@8483
   898
  split & : & \isaratt \\
wenzelm@7321
   899
\end{matharray}
wenzelm@7321
   900
wenzelm@7321
   901
\begin{rail}
wenzelm@9711
   902
  ('simp' | 'cong' | 'split') (() | 'add' | 'del')
wenzelm@7321
   903
  ;
wenzelm@7321
   904
\end{rail}
wenzelm@7321
   905
wenzelm@7321
   906
\begin{descr}
wenzelm@13024
   907
wenzelm@13024
   908
\item [$\isarcmd{print_simpset}$] prints the collection of rules declared to
wenzelm@13024
   909
  the Simplifier, which is also known as ``simpset'' internally
wenzelm@8667
   910
  \cite{isabelle-ref}.  This is a diagnostic command; $undo$ does not apply.
wenzelm@13024
   911
wenzelm@8547
   912
\item [$simp$] declares simplification rules.
wenzelm@13024
   913
wenzelm@8638
   914
\item [$cong$] declares congruence rules.
wenzelm@13024
   915
wenzelm@9711
   916
\item [$split$] declares case split rules.
wenzelm@13024
   917
wenzelm@7321
   918
\end{descr}
wenzelm@7319
   919
wenzelm@7315
   920
wenzelm@12621
   921
\subsubsection{Forward simplification}
wenzelm@12621
   922
wenzelm@9905
   923
\indexisaratt{simplified}
wenzelm@7315
   924
\begin{matharray}{rcl}
wenzelm@9905
   925
  simplified & : & \isaratt \\
wenzelm@7315
   926
\end{matharray}
wenzelm@7315
   927
wenzelm@9905
   928
\begin{rail}
wenzelm@13015
   929
  'simplified' opt? thmrefs?
wenzelm@9905
   930
  ;
wenzelm@7905
   931
wenzelm@9905
   932
  opt: '(' (noasm | noasmsimp | noasmuse) ')'
wenzelm@9905
   933
  ;
wenzelm@9905
   934
\end{rail}
wenzelm@9905
   935
wenzelm@9905
   936
\begin{descr}
wenzelm@13048
   937
  
wenzelm@13015
   938
\item [$simplified~\vec a$] causes a theorem to be simplified, either by
wenzelm@13015
   939
  exactly the specified rules $\vec a$, or the implicit Simplifier context if
wenzelm@13015
   940
  no arguments are given.  The result is fully simplified by default,
wenzelm@13015
   941
  including assumptions and conclusion; the options $no_asm$ etc.\ tune the
wenzelm@13048
   942
  Simplifier in the same way as the for the $simp$ method.
wenzelm@13041
   943
wenzelm@13015
   944
  Note that forward simplification restricts the simplifier to its most basic
wenzelm@13015
   945
  operation of term rewriting; solver and looper tactics \cite{isabelle-ref}
wenzelm@13015
   946
  are \emph{not} involved here.  The $simplified$ attribute should be only
wenzelm@13015
   947
  rarely required under normal circumstances.
wenzelm@13015
   948
wenzelm@9905
   949
\end{descr}
wenzelm@7315
   950
wenzelm@7315
   951
wenzelm@13048
   952
\subsubsection{Low-level equational reasoning}
wenzelm@9614
   953
wenzelm@12976
   954
\indexisarmeth{subst}\indexisarmeth{hypsubst}\indexisarmeth{split}
wenzelm@9614
   955
\begin{matharray}{rcl}
wenzelm@13015
   956
  subst^* & : & \isarmeth \\
wenzelm@9614
   957
  hypsubst^* & : & \isarmeth \\
wenzelm@13015
   958
  split^* & : & \isarmeth \\
wenzelm@9614
   959
\end{matharray}
wenzelm@9614
   960
wenzelm@9614
   961
\begin{rail}
nipkow@15995
   962
  'subst' ('(' 'asm' ')')? ('(' (nat+) ')')? thmref
wenzelm@9614
   963
  ;
wenzelm@9799
   964
  'split' ('(' 'asm' ')')? thmrefs
wenzelm@9703
   965
  ;
wenzelm@9614
   966
\end{rail}
wenzelm@9614
   967
wenzelm@13015
   968
These methods provide low-level facilities for equational reasoning that are
wenzelm@13015
   969
intended for specialized applications only.  Normally, single step
wenzelm@13015
   970
calculations would be performed in a structured text (see also
wenzelm@13015
   971
\S\ref{sec:calculation}), while the Simplifier methods provide the canonical
wenzelm@13015
   972
way for automated normalization (see \S\ref{sec:simplifier}).
wenzelm@9614
   973
wenzelm@9614
   974
\begin{descr}
wenzelm@13041
   975
nipkow@15995
   976
\item [$subst~eq$] performs a single substitution step using rule $eq$, which
wenzelm@13041
   977
  may be either a meta or object equality.
wenzelm@13041
   978
nipkow@15995
   979
\item [$subst~(asm)~eq$] substitutes in an assumption.
nipkow@15995
   980
nipkow@15995
   981
\item [$subst~(i \dots j)~eq$] performs several substitutions in the
nipkow@15995
   982
conclusion. The numbers $i$ to $j$ indicate the positions to substitute at.
nipkow@15995
   983
Positions are ordered from the top of the term tree moving down from left to
nipkow@15995
   984
right. For example, in $(a+b)+(c+d)$ there are three positions where
nipkow@15995
   985
commutativity of $+$ is applicable: 1 refers to the whole term, 2 to $a+b$
nipkow@15995
   986
and 3 to $c+d$. If the positions in the list $(i \dots j)$ are
nipkow@15995
   987
non-overlapping (e.g. $(2~3)$ in $(a+b)+(c+d)$) you may assume all
nipkow@15995
   988
substitutions are performed simultaneously. Otherwise the behaviour of
nipkow@15995
   989
$subst$ is not specified.
nipkow@15995
   990
nipkow@15995
   991
\item [$subst~(asm)~(i \dots j)~eq$] performs the substitutions in the
nipkow@16010
   992
assumptions. Positions $1 \dots i@1$ refer
nipkow@16010
   993
to assumption 1, positions $i@1+1 \dots i@2$ to assumption 2, and so on.
nipkow@15995
   994
wenzelm@13041
   995
\item [$hypsubst$] performs substitution using some assumption; this only
wenzelm@13041
   996
  works for equations of the form $x = t$ where $x$ is a free or bound
wenzelm@13041
   997
  variable.
wenzelm@13041
   998
wenzelm@13041
   999
\item [$split~\vec a$] performs single-step case splitting using rules $thms$.
wenzelm@9799
  1000
  By default, splitting is performed in the conclusion of a goal; the $asm$
wenzelm@9799
  1001
  option indicates to operate on assumptions instead.
wenzelm@13048
  1002
  
wenzelm@9703
  1003
  Note that the $simp$ method already involves repeated application of split
wenzelm@13048
  1004
  rules as declared in the current context.
wenzelm@9614
  1005
\end{descr}
wenzelm@9614
  1006
wenzelm@9614
  1007
wenzelm@12621
  1008
\subsection{The Classical Reasoner}\label{sec:classical}
wenzelm@7135
  1009
wenzelm@13048
  1010
\subsubsection{Basic methods}
wenzelm@7315
  1011
wenzelm@13024
  1012
\indexisarmeth{rule}\indexisarmeth{default}\indexisarmeth{contradiction}
wenzelm@13024
  1013
\indexisarmeth{intro}\indexisarmeth{elim}
wenzelm@7321
  1014
\begin{matharray}{rcl}
wenzelm@7321
  1015
  rule & : & \isarmeth \\
wenzelm@13024
  1016
  contradiction & : & \isarmeth \\
wenzelm@7321
  1017
  intro & : & \isarmeth \\
wenzelm@7321
  1018
  elim & : & \isarmeth \\
wenzelm@7321
  1019
\end{matharray}
wenzelm@7321
  1020
wenzelm@7321
  1021
\begin{rail}
wenzelm@8547
  1022
  ('rule' | 'intro' | 'elim') thmrefs?
wenzelm@7321
  1023
  ;
wenzelm@7321
  1024
\end{rail}
wenzelm@7321
  1025
wenzelm@7321
  1026
\begin{descr}
wenzelm@13041
  1027
wenzelm@7466
  1028
\item [$rule$] as offered by the classical reasoner is a refinement over the
wenzelm@13024
  1029
  primitive one (see \S\ref{sec:pure-meth-att}).  Both versions essentially
wenzelm@13024
  1030
  work the same, but the classical version observes the classical rule context
wenzelm@13041
  1031
  in addition to that of Isabelle/Pure.
wenzelm@13041
  1032
wenzelm@13041
  1033
  Common object logics (HOL, ZF, etc.) declare a rich collection of classical
wenzelm@13041
  1034
  rules (even if these would qualify as intuitionistic ones), but only few
wenzelm@13041
  1035
  declarations to the rule context of Isabelle/Pure
wenzelm@13041
  1036
  (\S\ref{sec:pure-meth-att}).
wenzelm@13041
  1037
wenzelm@13024
  1038
\item [$contradiction$] solves some goal by contradiction, deriving any result
wenzelm@13041
  1039
  from both $\neg A$ and $A$.  Chained facts, which are guaranteed to
wenzelm@13041
  1040
  participate, may appear in either order.
wenzelm@9614
  1041
wenzelm@7466
  1042
\item [$intro$ and $elim$] repeatedly refine some goal by intro- or
wenzelm@13041
  1043
  elim-resolution, after having inserted any chained facts.  Exactly the rules
wenzelm@13041
  1044
  given as arguments are taken into account; this allows fine-tuned
wenzelm@13041
  1045
  decomposition of a proof problem, in contrast to common automated tools.
wenzelm@13041
  1046
wenzelm@7321
  1047
\end{descr}
wenzelm@7321
  1048
wenzelm@7321
  1049
wenzelm@13048
  1050
\subsubsection{Automated methods}
wenzelm@7321
  1051
wenzelm@9799
  1052
\indexisarmeth{blast}\indexisarmeth{fast}\indexisarmeth{slow}
wenzelm@9799
  1053
\indexisarmeth{best}\indexisarmeth{safe}\indexisarmeth{clarify}
wenzelm@7321
  1054
\begin{matharray}{rcl}
wenzelm@9780
  1055
  blast & : & \isarmeth \\
wenzelm@9780
  1056
  fast & : & \isarmeth \\
wenzelm@9799
  1057
  slow & : & \isarmeth \\
wenzelm@9780
  1058
  best & : & \isarmeth \\
wenzelm@9780
  1059
  safe & : & \isarmeth \\
wenzelm@9780
  1060
  clarify & : & \isarmeth \\
wenzelm@7321
  1061
\end{matharray}
wenzelm@7321
  1062
wenzelm@11128
  1063
\indexouternonterm{clamod}
wenzelm@7321
  1064
\begin{rail}
wenzelm@13027
  1065
  'blast' ('!' ?) nat? (clamod *)
wenzelm@7321
  1066
  ;
wenzelm@13027
  1067
  ('fast' | 'slow' | 'best' | 'safe' | 'clarify') ('!' ?) (clamod *)
wenzelm@7321
  1068
  ;
wenzelm@7321
  1069
wenzelm@9408
  1070
  clamod: (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del') ':' thmrefs
wenzelm@7321
  1071
  ;
wenzelm@7321
  1072
\end{rail}
wenzelm@7321
  1073
wenzelm@7321
  1074
\begin{descr}
wenzelm@7321
  1075
\item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac}
wenzelm@7335
  1076
  in \cite[\S11]{isabelle-ref}).  The optional argument specifies a
wenzelm@10858
  1077
  user-supplied search bound (default 20).
wenzelm@9799
  1078
\item [$fast$, $slow$, $best$, $safe$, and $clarify$] refer to the generic
wenzelm@9799
  1079
  classical reasoner.  See \texttt{fast_tac}, \texttt{slow_tac},
wenzelm@9799
  1080
  \texttt{best_tac}, \texttt{safe_tac}, and \texttt{clarify_tac} in
wenzelm@9799
  1081
  \cite[\S11]{isabelle-ref} for more information.
wenzelm@7321
  1082
\end{descr}
wenzelm@7321
  1083
wenzelm@13041
  1084
Any of the above methods support additional modifiers of the context of
wenzelm@13041
  1085
classical rules.  Their semantics is analogous to the attributes given before.
wenzelm@13041
  1086
Facts provided by forward chaining are inserted into the goal before
wenzelm@13041
  1087
commencing proof search.  The ``!''~argument causes the full context of
wenzelm@13041
  1088
assumptions to be included as well.
wenzelm@7321
  1089
wenzelm@7315
  1090
wenzelm@12621
  1091
\subsubsection{Combined automated methods}\label{sec:clasimp}
wenzelm@7315
  1092
wenzelm@9799
  1093
\indexisarmeth{auto}\indexisarmeth{force}\indexisarmeth{clarsimp}
wenzelm@9799
  1094
\indexisarmeth{fastsimp}\indexisarmeth{slowsimp}\indexisarmeth{bestsimp}
wenzelm@7321
  1095
\begin{matharray}{rcl}
wenzelm@9606
  1096
  auto & : & \isarmeth \\
wenzelm@7321
  1097
  force & : & \isarmeth \\
wenzelm@9438
  1098
  clarsimp & : & \isarmeth \\
wenzelm@9606
  1099
  fastsimp & : & \isarmeth \\
wenzelm@9799
  1100
  slowsimp & : & \isarmeth \\
wenzelm@9799
  1101
  bestsimp & : & \isarmeth \\
wenzelm@7321
  1102
\end{matharray}
wenzelm@7315
  1103
wenzelm@11128
  1104
\indexouternonterm{clasimpmod}
wenzelm@7321
  1105
\begin{rail}
wenzelm@13027
  1106
  'auto' '!'? (nat nat)? (clasimpmod *)
wenzelm@9780
  1107
  ;
wenzelm@13027
  1108
  ('force' | 'clarsimp' | 'fastsimp' | 'slowsimp' | 'bestsimp') '!'? (clasimpmod *)
wenzelm@7321
  1109
  ;
wenzelm@7315
  1110
wenzelm@9711
  1111
  clasimpmod: ('simp' (() | 'add' | 'del' | 'only') |
wenzelm@10031
  1112
    ('cong' | 'split') (() | 'add' | 'del') |
wenzelm@10031
  1113
    'iff' (((() | 'add') '?'?) | 'del') |
wenzelm@9408
  1114
    (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs
wenzelm@7321
  1115
\end{rail}
wenzelm@7135
  1116
wenzelm@7321
  1117
\begin{descr}
wenzelm@9799
  1118
\item [$auto$, $force$, $clarsimp$, $fastsimp$, $slowsimp$, and $bestsimp$]
wenzelm@9799
  1119
  provide access to Isabelle's combined simplification and classical reasoning
wenzelm@9799
  1120
  tactics.  These correspond to \texttt{auto_tac}, \texttt{force_tac},
wenzelm@9799
  1121
  \texttt{clarsimp_tac}, and Classical Reasoner tactics with the Simplifier
wenzelm@9799
  1122
  added as wrapper, see \cite[\S11]{isabelle-ref} for more information.  The
wenzelm@13048
  1123
  modifier arguments correspond to those given in \S\ref{sec:simplifier} and
wenzelm@13048
  1124
  \S\ref{sec:classical}.  Just note that the ones related to the Simplifier
wenzelm@13048
  1125
  are prefixed by \railtterm{simp} here.
wenzelm@9614
  1126
wenzelm@7987
  1127
  Facts provided by forward chaining are inserted into the goal before doing
wenzelm@7987
  1128
  the search.  The ``!''~argument causes the full context of assumptions to be
wenzelm@7987
  1129
  included as well.
wenzelm@7321
  1130
\end{descr}
wenzelm@7135
  1131
wenzelm@7987
  1132
wenzelm@13048
  1133
\subsubsection{Declaring rules}
wenzelm@7135
  1134
wenzelm@8667
  1135
\indexisarcmd{print-claset}
wenzelm@7391
  1136
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest}
wenzelm@9936
  1137
\indexisaratt{iff}\indexisaratt{rule}
wenzelm@7321
  1138
\begin{matharray}{rcl}
wenzelm@13024
  1139
  \isarcmd{print_claset}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@7321
  1140
  intro & : & \isaratt \\
wenzelm@7321
  1141
  elim & : & \isaratt \\
wenzelm@7321
  1142
  dest & : & \isaratt \\
wenzelm@9936
  1143
  rule & : & \isaratt \\
wenzelm@7391
  1144
  iff & : & \isaratt \\
wenzelm@7321
  1145
\end{matharray}
wenzelm@7321
  1146
wenzelm@7321
  1147
\begin{rail}
wenzelm@9408
  1148
  ('intro' | 'elim' | 'dest') ('!' | () | '?')
wenzelm@7321
  1149
  ;
wenzelm@9936
  1150
  'rule' 'del'
wenzelm@9936
  1151
  ;
wenzelm@10031
  1152
  'iff' (((() | 'add') '?'?) | 'del')
wenzelm@9936
  1153
  ;
wenzelm@7321
  1154
\end{rail}
wenzelm@7321
  1155
wenzelm@7321
  1156
\begin{descr}
wenzelm@13024
  1157
wenzelm@13024
  1158
\item [$\isarcmd{print_claset}$] prints the collection of rules declared to
wenzelm@13024
  1159
  the Classical Reasoner, which is also known as ``simpset'' internally
wenzelm@8667
  1160
  \cite{isabelle-ref}.  This is a diagnostic command; $undo$ does not apply.
wenzelm@13024
  1161
wenzelm@8517
  1162
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and
oheimb@11332
  1163
  destruction rules, respectively.  By default, rules are considered as
wenzelm@9408
  1164
  \emph{unsafe} (i.e.\ not applied blindly without backtracking), while a
wenzelm@13041
  1165
  single ``!'' classifies as \emph{safe}.  Rule declarations marked by ``?''
wenzelm@13041
  1166
  coincide with those of Isabelle/Pure, cf.\ \S\ref{sec:pure-meth-att} (i.e.\
wenzelm@13041
  1167
  are only applied in single steps of the $rule$ method).
wenzelm@13024
  1168
oheimb@11332
  1169
\item [$rule~del$] deletes introduction, elimination, or destruction rules from
wenzelm@9936
  1170
  the context.
wenzelm@13041
  1171
wenzelm@13041
  1172
\item [$iff$] declares logical equivalences to the Simplifier and the
wenzelm@13024
  1173
  Classical reasoner at the same time.  Non-conditional rules result in a
wenzelm@13024
  1174
  ``safe'' introduction and elimination pair; conditional ones are considered
wenzelm@13024
  1175
  ``unsafe''.  Rules with negative conclusion are automatically inverted
wenzelm@13041
  1176
  (using $\neg$ elimination internally).
wenzelm@13041
  1177
wenzelm@13041
  1178
  The ``?'' version of $iff$ declares rules to the Isabelle/Pure context only,
wenzelm@13041
  1179
  and omits the Simplifier declaration.
wenzelm@13041
  1180
wenzelm@7321
  1181
\end{descr}
wenzelm@7135
  1182
wenzelm@8203
  1183
wenzelm@13048
  1184
\subsubsection{Classical operations}
wenzelm@13027
  1185
wenzelm@13027
  1186
\indexisaratt{elim-format}\indexisaratt{swapped}
wenzelm@13027
  1187
wenzelm@13027
  1188
\begin{matharray}{rcl}
wenzelm@13027
  1189
  elim_format & : & \isaratt \\
wenzelm@13027
  1190
  swapped & : & \isaratt \\
wenzelm@13027
  1191
\end{matharray}
wenzelm@13027
  1192
wenzelm@13027
  1193
\begin{descr}
wenzelm@13041
  1194
wenzelm@13027
  1195
\item [$elim_format$] turns a destruction rule into elimination rule format;
wenzelm@13027
  1196
  this operation is similar to the the intuitionistic version
wenzelm@13027
  1197
  (\S\ref{sec:misc-meth-att}), but each premise of the resulting rule acquires
wenzelm@13041
  1198
  an additional local fact of the negated main thesis; according to the
wenzelm@13027
  1199
  classical principle $(\neg A \Imp A) \Imp A$.
wenzelm@13041
  1200
wenzelm@13027
  1201
\item [$swapped$] turns an introduction rule into an elimination, by resolving
wenzelm@13027
  1202
  with the classical swap principle $(\neg B \Imp A) \Imp (\neg A \Imp B)$.
wenzelm@13027
  1203
wenzelm@13027
  1204
\end{descr}
wenzelm@13027
  1205
wenzelm@13027
  1206
wenzelm@12621
  1207
\subsection{Proof by cases and induction}\label{sec:cases-induct}
wenzelm@11691
  1208
wenzelm@13048
  1209
\subsubsection{Rule contexts}
wenzelm@12618
  1210
wenzelm@12618
  1211
\indexisarcmd{case}\indexisarcmd{print-cases}
wenzelm@12618
  1212
\indexisaratt{case-names}\indexisaratt{params}\indexisaratt{consumes}
wenzelm@12618
  1213
\begin{matharray}{rcl}
wenzelm@12618
  1214
  \isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@12618
  1215
  \isarcmd{print_cases}^* & : & \isarkeep{proof} \\
wenzelm@12618
  1216
  case_names & : & \isaratt \\
wenzelm@12618
  1217
  params & : & \isaratt \\
wenzelm@12618
  1218
  consumes & : & \isaratt \\
wenzelm@12618
  1219
\end{matharray}
wenzelm@12618
  1220
wenzelm@12618
  1221
Basically, Isar proof contexts are built up explicitly using commands like
wenzelm@12618
  1222
$\FIXNAME$, $\ASSUMENAME$ etc.\ (see \S\ref{sec:proof-context}).  In typical
wenzelm@12618
  1223
verification tasks this can become hard to manage, though.  In particular, a
wenzelm@12618
  1224
large number of local contexts may emerge from case analysis or induction over
wenzelm@12618
  1225
inductive sets and types.
wenzelm@12618
  1226
wenzelm@12618
  1227
\medskip
wenzelm@12618
  1228
wenzelm@12618
  1229
The $\CASENAME$ command provides a shorthand to refer to certain parts of
wenzelm@12618
  1230
logical context symbolically.  Proof methods may provide an environment of
wenzelm@12618
  1231
named ``cases'' of the form $c\colon \vec x, \vec \phi$.  Then the effect of
wenzelm@13041
  1232
``$\CASE{c}$'' is that of ``$\FIX{\vec x}~\ASSUME{c}{\vec\phi}$''.  Term
wenzelm@13041
  1233
bindings may be covered as well, such as $\Var{case}$ for the intended
wenzelm@13041
  1234
conclusion.
wenzelm@12618
  1235
wenzelm@13027
  1236
Normally the ``terminology'' of a case value (i.e.\ the parameters $\vec x$)
wenzelm@13041
  1237
are marked as hidden.  Using the explicit form ``$\CASE{(c~\vec x)}$'' enables
wenzelm@13041
  1238
proof writers to choose their own names for the subsequent proof text.
wenzelm@12618
  1239
wenzelm@12618
  1240
\medskip
wenzelm@12618
  1241
wenzelm@13027
  1242
It is important to note that $\CASENAME$ does \emph{not} provide direct means
wenzelm@13027
  1243
to peek at the current goal state, which is generally considered
wenzelm@13027
  1244
non-observable in Isar.  The text of the cases basically emerge from standard
wenzelm@13027
  1245
elimination or induction rules, which in turn are derived from previous theory
wenzelm@13041
  1246
specifications in a canonical way (say from $\isarkeyword{inductive}$
wenzelm@13041
  1247
definitions).
wenzelm@13027
  1248
wenzelm@12618
  1249
Named cases may be exhibited in the current proof context only if both the
wenzelm@12618
  1250
proof method and the rules involved support this.  Case names and parameters
wenzelm@12618
  1251
of basic rules may be declared by hand as well, by using appropriate
wenzelm@12618
  1252
attributes.  Thus variant versions of rules that have been derived manually
wenzelm@12618
  1253
may be used in advanced case analysis later.
wenzelm@12618
  1254
wenzelm@12618
  1255
\railalias{casenames}{case\_names}
wenzelm@12618
  1256
\railterm{casenames}
wenzelm@12618
  1257
wenzelm@12618
  1258
\begin{rail}
wenzelm@13041
  1259
  'case' (caseref | '(' caseref ((name | underscore) +) ')')
wenzelm@12618
  1260
  ;
wenzelm@13024
  1261
  caseref: nameref attributes?
wenzelm@13024
  1262
  ;
wenzelm@13024
  1263
wenzelm@13027
  1264
  casenames (name +)
wenzelm@12618
  1265
  ;
wenzelm@13027
  1266
  'params' ((name *) + 'and')
wenzelm@12618
  1267
  ;
wenzelm@12618
  1268
  'consumes' nat?
wenzelm@12618
  1269
  ;
wenzelm@12618
  1270
\end{rail}
wenzelm@12618
  1271
wenzelm@12618
  1272
\begin{descr}
wenzelm@13041
  1273
wenzelm@13041
  1274
\item [$\CASE{(c~\vec x)}$] invokes a named local context $c\colon \vec x,
wenzelm@13041
  1275
  \vec \phi$, as provided by an appropriate proof method (such as $cases$ and
wenzelm@13041
  1276
  $induct$, see \S\ref{sec:cases-induct-meth}).  The command ``$\CASE{(c~\vec
wenzelm@13041
  1277
    x)}$'' abbreviates ``$\FIX{\vec x}~\ASSUME{c}{\vec\phi}$''.
wenzelm@13041
  1278
wenzelm@12618
  1279
\item [$\isarkeyword{print_cases}$] prints all local contexts of the current
wenzelm@12618
  1280
  state, using Isar proof language notation.  This is a diagnostic command;
wenzelm@12618
  1281
  $undo$ does not apply.
wenzelm@13041
  1282
wenzelm@12618
  1283
\item [$case_names~\vec c$] declares names for the local contexts of premises
wenzelm@12618
  1284
  of some theorem; $\vec c$ refers to the \emph{suffix} of the list of
wenzelm@12618
  1285
  premises.
wenzelm@13041
  1286
wenzelm@12618
  1287
\item [$params~\vec p@1 \dots \vec p@n$] renames the innermost parameters of
wenzelm@12618
  1288
  premises $1, \dots, n$ of some theorem.  An empty list of names may be given
wenzelm@12618
  1289
  to skip positions, leaving the present parameters unchanged.
wenzelm@13041
  1290
wenzelm@12618
  1291
  Note that the default usage of case rules does \emph{not} directly expose
wenzelm@12618
  1292
  parameters to the proof context (see also \S\ref{sec:cases-induct-meth}).
wenzelm@13041
  1293
wenzelm@12618
  1294
\item [$consumes~n$] declares the number of ``major premises'' of a rule,
wenzelm@12618
  1295
  i.e.\ the number of facts to be consumed when it is applied by an
wenzelm@12618
  1296
  appropriate proof method (cf.\ \S\ref{sec:cases-induct-meth}).  The default
wenzelm@12618
  1297
  value of $consumes$ is $n = 1$, which is appropriate for the usual kind of
wenzelm@13041
  1298
  cases and induction rules for inductive sets (cf.\
wenzelm@12618
  1299
  \S\ref{sec:hol-inductive}).  Rules without any $consumes$ declaration given
wenzelm@12618
  1300
  are treated as if $consumes~0$ had been specified.
wenzelm@13041
  1301
wenzelm@12618
  1302
  Note that explicit $consumes$ declarations are only rarely needed; this is
wenzelm@12618
  1303
  already taken care of automatically by the higher-level $cases$ and $induct$
wenzelm@12618
  1304
  declarations, see also \S\ref{sec:cases-induct-att}.
wenzelm@13027
  1305
wenzelm@12618
  1306
\end{descr}
wenzelm@12618
  1307
wenzelm@12618
  1308
wenzelm@12621
  1309
\subsubsection{Proof methods}\label{sec:cases-induct-meth}
wenzelm@11691
  1310
wenzelm@11691
  1311
\indexisarmeth{cases}\indexisarmeth{induct}
wenzelm@11691
  1312
\begin{matharray}{rcl}
wenzelm@11691
  1313
  cases & : & \isarmeth \\
wenzelm@11691
  1314
  induct & : & \isarmeth \\
wenzelm@11691
  1315
\end{matharray}
wenzelm@11691
  1316
wenzelm@11691
  1317
The $cases$ and $induct$ methods provide a uniform interface to case analysis
wenzelm@11691
  1318
and induction over datatypes, inductive sets, and recursive functions.  The
wenzelm@11691
  1319
corresponding rules may be specified and instantiated in a casual manner.
wenzelm@11691
  1320
Furthermore, these methods provide named local contexts that may be invoked
wenzelm@13048
  1321
via the $\CASENAME$ proof command within the subsequent proof text.  This
wenzelm@13048
  1322
accommodates compact proof texts even when reasoning about large
wenzelm@13048
  1323
specifications.
wenzelm@11691
  1324
wenzelm@11691
  1325
\begin{rail}
wenzelm@11691
  1326
  'cases' spec
wenzelm@11691
  1327
  ;
wenzelm@11691
  1328
  'induct' spec
wenzelm@11691
  1329
  ;
wenzelm@11691
  1330
wenzelm@13041
  1331
  spec: open? args rule?
wenzelm@11691
  1332
  ;
wenzelm@11691
  1333
  open: '(' 'open' ')'
wenzelm@11691
  1334
  ;
wenzelm@13041
  1335
  args: (insts * 'and')
wenzelm@11691
  1336
  ;
wenzelm@11691
  1337
  rule: ('type' | 'set') ':' nameref | 'rule' ':' thmref
wenzelm@11691
  1338
  ;
wenzelm@11691
  1339
\end{rail}
wenzelm@11691
  1340
wenzelm@11691
  1341
\begin{descr}
wenzelm@13041
  1342
wenzelm@13041
  1343
\item [$cases~insts~R$] applies method $rule$ with an appropriate case
wenzelm@11691
  1344
  distinction theorem, instantiated to the subjects $insts$.  Symbolic case
wenzelm@11691
  1345
  names are bound according to the rule's local contexts.
wenzelm@13041
  1346
wenzelm@11691
  1347
  The rule is determined as follows, according to the facts and arguments
wenzelm@11691
  1348
  passed to the $cases$ method:
wenzelm@11691
  1349
  \begin{matharray}{llll}
wenzelm@11691
  1350
    \Text{facts}    &       & \Text{arguments} & \Text{rule} \\\hline
wenzelm@11691
  1351
                    & cases &           & \Text{classical case split} \\
wenzelm@11691
  1352
                    & cases & t         & \Text{datatype exhaustion (type of $t$)} \\
wenzelm@11691
  1353
    \edrv a \in A   & cases & \dots     & \Text{inductive set elimination (of $A$)} \\
wenzelm@11691
  1354
    \dots           & cases & \dots ~ R & \Text{explicit rule $R$} \\
wenzelm@11691
  1355
  \end{matharray}
wenzelm@13041
  1356
wenzelm@11691
  1357
  Several instantiations may be given, referring to the \emph{suffix} of
wenzelm@11691
  1358
  premises of the case rule; within each premise, the \emph{prefix} of
wenzelm@11691
  1359
  variables is instantiated.  In most situations, only a single term needs to
wenzelm@11691
  1360
  be specified; this refers to the first variable of the last premise (it is
wenzelm@11691
  1361
  usually the same for all cases).
wenzelm@13041
  1362
wenzelm@13041
  1363
  The ``$(open)$'' option causes the parameters of the new local contexts to
wenzelm@13041
  1364
  be exposed to the current proof context.  Thus local variables stemming from
wenzelm@11691
  1365
  distant parts of the theory development may be introduced in an implicit
wenzelm@11691
  1366
  manner, which can be quite confusing to the reader.  Furthermore, this
wenzelm@11691
  1367
  option may cause unwanted hiding of existing local variables, resulting in
wenzelm@11691
  1368
  less robust proof texts.
wenzelm@13041
  1369
wenzelm@13041
  1370
\item [$induct~insts~R$] is analogous to the $cases$ method, but refers to
wenzelm@11691
  1371
  induction rules, which are determined as follows:
wenzelm@11691
  1372
  \begin{matharray}{llll}
wenzelm@11691
  1373
    \Text{facts}    &        & \Text{arguments} & \Text{rule} \\\hline
wenzelm@11691
  1374
                    & induct & P ~ x ~ \dots & \Text{datatype induction (type of $x$)} \\
wenzelm@11691
  1375
    \edrv x \in A   & induct & \dots         & \Text{set induction (of $A$)} \\
wenzelm@11691
  1376
    \dots           & induct & \dots ~ R     & \Text{explicit rule $R$} \\
wenzelm@11691
  1377
  \end{matharray}
wenzelm@13041
  1378
wenzelm@11691
  1379
  Several instantiations may be given, each referring to some part of a mutual
wenzelm@11691
  1380
  inductive definition or datatype --- only related partial induction rules
wenzelm@11691
  1381
  may be used together, though.  Any of the lists of terms $P, x, \dots$
wenzelm@11691
  1382
  refers to the \emph{suffix} of variables present in the induction rule.
wenzelm@11691
  1383
  This enables the writer to specify only induction variables, or both
wenzelm@11691
  1384
  predicates and variables, for example.
wenzelm@13041
  1385
wenzelm@13041
  1386
  The ``$(open)$'' option works the same way as for $cases$.
wenzelm@13027
  1387
wenzelm@11691
  1388
\end{descr}
wenzelm@11691
  1389
wenzelm@13048
  1390
Above methods produce named local contexts, as determined by the instantiated
wenzelm@13048
  1391
rule as specified in the text.  Beyond that, the $induct$ method guesses
wenzelm@13048
  1392
further instantiations from the goal specification itself.  Any persisting
wenzelm@13048
  1393
unresolved schematic variables of the resulting rule will render the the
wenzelm@13048
  1394
corresponding case invalid.  The term binding $\Var{case}$\indexisarvar{case}
wenzelm@13048
  1395
for the conclusion will be provided with each case, provided that term is
wenzelm@13048
  1396
fully specified.
wenzelm@11691
  1397
wenzelm@13048
  1398
The $\isarkeyword{print_cases}$ command prints all named cases present in the
wenzelm@13048
  1399
current proof state.
wenzelm@11691
  1400
wenzelm@11691
  1401
\medskip
wenzelm@11691
  1402
wenzelm@11691
  1403
It is important to note that there is a fundamental difference of the $cases$
wenzelm@11691
  1404
and $induct$ methods in handling of non-atomic goal statements: $cases$ just
wenzelm@11691
  1405
applies a certain rule in backward fashion, splitting the result into new
wenzelm@11691
  1406
goals with the local contexts being augmented in a purely monotonic manner.
wenzelm@11691
  1407
nipkow@13622
  1408
In contrast, $induct$ passes the full goal statement through the
nipkow@13622
  1409
``recursive'' course involved in the induction.  Thus the original statement
nipkow@13622
  1410
is basically replaced by separate copies, corresponding to the induction
nipkow@13622
  1411
hypotheses and conclusion; the original goal context is no longer available.
nipkow@13622
  1412
This behavior allows \emph{strengthened induction predicates} to be expressed
nipkow@13622
  1413
concisely as meta-level rule statements, i.e.\ $\All{\vec x} \vec\phi \Imp
nipkow@13622
  1414
\psi$ to indicate ``variable'' parameters $\vec x$ and ``recursive''
nipkow@13622
  1415
assumptions $\vec\phi$. Note that ``$\isarcmd{case}~c$'' already performs
nipkow@13622
  1416
``$\FIX{\vec x}$''.  Also note that local definitions may be expressed as
nipkow@13622
  1417
$\All{\vec x} n \equiv t[\vec x] \Imp \phi[n]$, with induction over $n$.
nipkow@13622
  1418
wenzelm@11691
  1419
wenzelm@13425
  1420
In induction proofs, local assumptions introduced by cases are split into two
wenzelm@13425
  1421
different kinds: $hyps$ stemming from the rule and $prems$ from the goal
wenzelm@13425
  1422
statement.  This is reflected in the extracted cases accordingly, so invoking
wenzelm@13425
  1423
``$\isarcmd{case}~c$'' will provide separate facts $c\mathord.hyps$ and
wenzelm@13425
  1424
$c\mathord.prems$, as well as fact $c$ to hold the all-inclusive list.
wenzelm@13425
  1425
wenzelm@11691
  1426
\medskip
wenzelm@11691
  1427
wenzelm@11691
  1428
Facts presented to either method are consumed according to the number of
wenzelm@12618
  1429
``major premises'' of the rule involved (see also \S\ref{sec:cases-induct}),
wenzelm@13041
  1430
which is usually $0$ for plain cases and induction rules of datatypes etc.\
wenzelm@12618
  1431
and $1$ for rules of inductive sets and the like.  The remaining facts are
wenzelm@12618
  1432
inserted into the goal verbatim before the actual $cases$ or $induct$ rule is
wenzelm@12618
  1433
applied (thus facts may be even passed through an induction).
wenzelm@11691
  1434
wenzelm@11691
  1435
wenzelm@12621
  1436
\subsubsection{Declaring rules}\label{sec:cases-induct-att}
wenzelm@11691
  1437
wenzelm@11691
  1438
\indexisarcmd{print-induct-rules}\indexisaratt{cases}\indexisaratt{induct}
wenzelm@11691
  1439
\begin{matharray}{rcl}
wenzelm@11691
  1440
  \isarcmd{print_induct_rules}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@11691
  1441
  cases & : & \isaratt \\
wenzelm@11691
  1442
  induct & : & \isaratt \\
wenzelm@11691
  1443
\end{matharray}
wenzelm@11691
  1444
wenzelm@11691
  1445
\begin{rail}
wenzelm@11691
  1446
  'cases' spec
wenzelm@11691
  1447
  ;
wenzelm@11691
  1448
  'induct' spec
wenzelm@11691
  1449
  ;
wenzelm@11691
  1450
wenzelm@11691
  1451
  spec: ('type' | 'set') ':' nameref
wenzelm@11691
  1452
  ;
wenzelm@11691
  1453
\end{rail}
wenzelm@11691
  1454
wenzelm@13024
  1455
\begin{descr}
wenzelm@13041
  1456
wenzelm@13024
  1457
\item [$\isarkeyword{print_induct_rules}$] prints cases and induct rules for
wenzelm@13024
  1458
  sets and types of the current context.
wenzelm@13041
  1459
wenzelm@13024
  1460
\item [$cases$ and $induct$] (as attributes) augment the corresponding context
wenzelm@13024
  1461
  of rules for reasoning about inductive sets and types, using the
wenzelm@13024
  1462
  corresponding methods of the same name.  Certain definitional packages of
wenzelm@13024
  1463
  object-logics usually declare emerging cases and induction rules as
wenzelm@13024
  1464
  expected, so users rarely need to intervene.
wenzelm@13048
  1465
  
wenzelm@13024
  1466
  Manual rule declarations usually include the the $case_names$ and $ps$
wenzelm@13024
  1467
  attributes to adjust names of cases and parameters of a rule (see
wenzelm@13048
  1468
  \S\ref{sec:cases-induct}); the $consumes$ declaration is taken care of
wenzelm@13024
  1469
  automatically: $consumes~0$ is specified for ``type'' rules and $consumes~1$
wenzelm@13024
  1470
  for ``set'' rules.
wenzelm@13041
  1471
wenzelm@13024
  1472
\end{descr}
wenzelm@11691
  1473
wenzelm@9614
  1474
%%% Local Variables:
wenzelm@7135
  1475
%%% mode: latex
wenzelm@7135
  1476
%%% TeX-master: "isar-ref"
wenzelm@9614
  1477
%%% End: