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