doc-src/IsarRef/pure.tex
author wenzelm
Wed Jan 02 21:53:50 2002 +0100 (2002-01-02)
changeset 12618 43a97a2155d0
parent 11549 e7265e70fd7c
child 12621 48cafea0684b
permissions -rw-r--r--
first stage of major update;
wenzelm@7046
     1
wenzelm@12618
     2
\chapter{Basic Language Elements}\label{ch:pure-syntax}
wenzelm@7167
     3
wenzelm@8515
     4
Subsequently, we introduce the main part of Pure Isar theory and proof
wenzelm@8547
     5
commands, together with fundamental proof methods and attributes.
wenzelm@8515
     6
Chapter~\ref{ch:gen-tools} describes further Isar elements provided by generic
wenzelm@8515
     7
tools and packages (such as the Simplifier) that are either part of Pure
wenzelm@8515
     8
Isabelle or pre-installed by most object logics.  Chapter~\ref{ch:hol-tools}
wenzelm@8515
     9
refers to actual object-logic specific elements of Isabelle/HOL.
wenzelm@7046
    10
wenzelm@7167
    11
\medskip
wenzelm@7167
    12
wenzelm@7167
    13
Isar commands may be either \emph{proper} document constructors, or
wenzelm@7466
    14
\emph{improper commands}.  Some proof methods and attributes introduced later
wenzelm@7466
    15
are classified as improper as well.  Improper Isar language elements, which
wenzelm@12618
    16
are subsequently marked by ``$^*$'', are often helpful when developing proof
wenzelm@7981
    17
documents, while their use is discouraged for the final outcome.  Typical
wenzelm@7981
    18
examples are diagnostic commands that print terms or theorems according to the
wenzelm@7981
    19
current context; other commands even emulate old-style tactical theorem
wenzelm@8547
    20
proving.
wenzelm@7167
    21
wenzelm@7134
    22
wenzelm@12618
    23
\section{Theory specification commands}
wenzelm@7134
    24
wenzelm@7167
    25
\subsection{Defining theories}\label{sec:begin-thy}
wenzelm@7134
    26
wenzelm@7895
    27
\indexisarcmd{header}\indexisarcmd{theory}\indexisarcmd{end}\indexisarcmd{context}
wenzelm@7134
    28
\begin{matharray}{rcl}
wenzelm@7895
    29
  \isarcmd{header} & : & \isarkeep{toplevel} \\
wenzelm@8510
    30
  \isarcmd{theory} & : & \isartrans{toplevel}{theory} \\
wenzelm@8510
    31
  \isarcmd{context}^* & : & \isartrans{toplevel}{theory} \\
wenzelm@8510
    32
  \isarcmd{end} & : & \isartrans{theory}{toplevel} \\
wenzelm@7134
    33
\end{matharray}
wenzelm@7134
    34
wenzelm@7134
    35
Isabelle/Isar ``new-style'' theories are either defined via theory files or
wenzelm@7981
    36
interactively.  Both theory-level specifications and proofs are handled
wenzelm@7335
    37
uniformly --- occasionally definitional mechanisms even require some explicit
wenzelm@7335
    38
proof as well.  In contrast, ``old-style'' Isabelle theories support batch
wenzelm@7335
    39
processing only, with the proof scripts collected in separate ML files.
wenzelm@7134
    40
wenzelm@7895
    41
The first actual command of any theory has to be $\THEORY$, starting a new
wenzelm@7895
    42
theory based on the merge of existing ones.  Just preceding $\THEORY$, there
wenzelm@7895
    43
may be an optional $\isarkeyword{header}$ declaration, which is relevant to
wenzelm@7895
    44
document preparation only; it acts very much like a special pre-theory markup
wenzelm@7895
    45
command (cf.\ \S\ref{sec:markup-thy} and \S\ref{sec:markup-thy}).  The theory
wenzelm@7895
    46
context may be also changed by $\CONTEXT$ without creating a new theory.  In
wenzelm@7895
    47
both cases, $\END$ concludes the theory development; it has to be the very
wenzelm@8547
    48
last command of any theory file.
wenzelm@7134
    49
wenzelm@7134
    50
\begin{rail}
wenzelm@7895
    51
  'header' text
wenzelm@7895
    52
  ;
wenzelm@7134
    53
  'theory' name '=' (name + '+') filespecs? ':'
wenzelm@7134
    54
  ;
wenzelm@7134
    55
  'context' name
wenzelm@7134
    56
  ;
wenzelm@7134
    57
  'end'
wenzelm@7134
    58
  ;;
wenzelm@7134
    59
wenzelm@7167
    60
  filespecs: 'files' ((name | parname) +);
wenzelm@7134
    61
\end{rail}
wenzelm@7134
    62
wenzelm@7167
    63
\begin{descr}
wenzelm@7895
    64
\item [$\isarkeyword{header}~text$] provides plain text markup just preceding
wenzelm@8547
    65
  the formal beginning of a theory.  In actual document preparation the
wenzelm@7895
    66
  corresponding {\LaTeX} macro \verb,\isamarkupheader, may be redefined to
wenzelm@7895
    67
  produce chapter or section headings.  See also \S\ref{sec:markup-thy} and
wenzelm@7895
    68
  \S\ref{sec:markup-prf} for further markup commands.
wenzelm@7895
    69
  
wenzelm@7981
    70
\item [$\THEORY~A = B@1 + \cdots + B@n\colon$] commences a new theory $A$
wenzelm@7981
    71
  based on existing ones $B@1 + \cdots + B@n$.  Isabelle's theory loader
wenzelm@7981
    72
  system ensures that any of the base theories are properly loaded (and fully
wenzelm@7981
    73
  up-to-date when $\THEORY$ is executed interactively).  The optional
wenzelm@7981
    74
  $\isarkeyword{files}$ specification declares additional dependencies on ML
wenzelm@7981
    75
  files.  Unless put in parentheses, any file will be loaded immediately via
wenzelm@7981
    76
  $\isarcmd{use}$ (see also \S\ref{sec:ML}).  The optional ML file
wenzelm@7981
    77
  \texttt{$A$.ML} that may be associated with any theory should \emph{not} be
wenzelm@7981
    78
  included in $\isarkeyword{files}$, though.
wenzelm@7134
    79
  
wenzelm@7895
    80
\item [$\CONTEXT~B$] enters an existing theory context, basically in read-only
wenzelm@7981
    81
  mode, so only a limited set of commands may be performed without destroying
wenzelm@7981
    82
  the theory.  Just as for $\THEORY$, the theory loader ensures that $B$ is
wenzelm@7981
    83
  loaded and up-to-date.
wenzelm@7175
    84
  
wenzelm@7167
    85
\item [$\END$] concludes the current theory definition or context switch.
wenzelm@7981
    86
Note that this command cannot be undone, but the whole theory definition has
wenzelm@7981
    87
to be retracted.
wenzelm@7167
    88
\end{descr}
wenzelm@7134
    89
wenzelm@7134
    90
wenzelm@7895
    91
\subsection{Theory markup commands}\label{sec:markup-thy}
wenzelm@7134
    92
wenzelm@7895
    93
\indexisarcmd{chapter}\indexisarcmd{section}\indexisarcmd{subsection}
wenzelm@7895
    94
\indexisarcmd{subsubsection}\indexisarcmd{text}\indexisarcmd{text-raw}
wenzelm@7134
    95
\begin{matharray}{rcl}
wenzelm@7134
    96
  \isarcmd{chapter} & : & \isartrans{theory}{theory} \\
wenzelm@7167
    97
  \isarcmd{section} & : & \isartrans{theory}{theory} \\
wenzelm@7134
    98
  \isarcmd{subsection} & : & \isartrans{theory}{theory} \\
wenzelm@7134
    99
  \isarcmd{subsubsection} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   100
  \isarcmd{text} & : & \isartrans{theory}{theory} \\
wenzelm@7895
   101
  \isarcmd{text_raw} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   102
\end{matharray}
wenzelm@7134
   103
wenzelm@7895
   104
Apart from formal comments (see \S\ref{sec:comments}), markup commands provide
wenzelm@7981
   105
a structured way to insert text into the document generated from a theory (see
wenzelm@7895
   106
\cite{isabelle-sys} for more information on Isabelle's document preparation
wenzelm@7895
   107
tools).
wenzelm@7134
   108
wenzelm@7895
   109
\railalias{textraw}{text\_raw}
wenzelm@7895
   110
\railterm{textraw}
wenzelm@7134
   111
wenzelm@7134
   112
\begin{rail}
wenzelm@7895
   113
  ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text' | textraw) text
wenzelm@7134
   114
  ;
wenzelm@7134
   115
\end{rail}
wenzelm@7134
   116
wenzelm@7167
   117
\begin{descr}
wenzelm@7335
   118
\item [$\isarkeyword{chapter}$, $\isarkeyword{section}$,
wenzelm@7335
   119
  $\isarkeyword{subsection}$, and $\isarkeyword{subsubsection}$] mark chapter
wenzelm@7335
   120
  and section headings.
wenzelm@7895
   121
\item [$\TEXT$] specifies paragraphs of plain text, including references to
wenzelm@12618
   122
  formal entities (see also \S\ref{sec:antiq} on ``antiquotations'').
wenzelm@7895
   123
\item [$\isarkeyword{text_raw}$] inserts {\LaTeX} source into the output,
wenzelm@7895
   124
  without additional markup.  Thus the full range of document manipulations
wenzelm@12618
   125
  becomes available.
wenzelm@7167
   126
\end{descr}
wenzelm@7134
   127
wenzelm@8684
   128
Any of these markup elements corresponds to a {\LaTeX} command with the name
wenzelm@8684
   129
prefixed by \verb,\isamarkup,.  For the sectioning commands this is a plain
wenzelm@8684
   130
macro with a single argument, e.g.\ \verb,\isamarkupchapter{,\dots\verb,}, for
wenzelm@8684
   131
$\isarkeyword{chapter}$.  The $\isarkeyword{text}$ markup results in a
wenzelm@8684
   132
{\LaTeX} environment \verb,\begin{isamarkuptext}, {\dots}
wenzelm@8684
   133
  \verb,\end{isamarkuptext},, while $\isarkeyword{text_raw}$ causes the text
wenzelm@8684
   134
to be inserted directly into the {\LaTeX} source.
wenzelm@7895
   135
wenzelm@8485
   136
\medskip
wenzelm@8485
   137
wenzelm@8485
   138
Additional markup commands are available for proofs (see
wenzelm@7895
   139
\S\ref{sec:markup-prf}).  Also note that the $\isarkeyword{header}$
wenzelm@8684
   140
declaration (see \S\ref{sec:begin-thy}) admits to insert section markup just
wenzelm@8684
   141
preceding the actual theory definition.
wenzelm@7895
   142
wenzelm@7134
   143
wenzelm@7135
   144
\subsection{Type classes and sorts}\label{sec:classes}
wenzelm@7134
   145
wenzelm@7134
   146
\indexisarcmd{classes}\indexisarcmd{classrel}\indexisarcmd{defaultsort}
wenzelm@7134
   147
\begin{matharray}{rcl}
wenzelm@7134
   148
  \isarcmd{classes} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   149
  \isarcmd{classrel} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   150
  \isarcmd{defaultsort} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   151
\end{matharray}
wenzelm@7134
   152
wenzelm@7134
   153
\begin{rail}
wenzelm@7167
   154
  'classes' (classdecl comment? +)
wenzelm@7134
   155
  ;
wenzelm@11100
   156
  'classrel' nameref ('<' | subseteq) nameref comment?
wenzelm@7134
   157
  ;
wenzelm@7134
   158
  'defaultsort' sort comment?
wenzelm@7134
   159
  ;
wenzelm@7134
   160
\end{rail}
wenzelm@7134
   161
wenzelm@7167
   162
\begin{descr}
wenzelm@11100
   163
\item [$\isarkeyword{classes}~c \subseteq \vec c$] declares class $c$ to be a
wenzelm@11100
   164
  subclass of existing classes $\vec c$.  Cyclic class structures are ruled
wenzelm@11100
   165
  out.
wenzelm@11100
   166
\item [$\isarkeyword{classrel}~c@1 \subseteq c@2$] states a subclass relation
wenzelm@11100
   167
  between existing classes $c@1$ and $c@2$.  This is done axiomatically!  The
wenzelm@10223
   168
  $\INSTANCE$ command (see \S\ref{sec:axclass}) provides a way to introduce
wenzelm@10223
   169
  proven class relations.
wenzelm@7134
   170
\item [$\isarkeyword{defaultsort}~s$] makes sort $s$ the new default sort for
wenzelm@7895
   171
  any type variables given without sort constraints.  Usually, the default
wenzelm@8547
   172
  sort would be only changed when defining new object-logics.
wenzelm@7167
   173
\end{descr}
wenzelm@7134
   174
wenzelm@7134
   175
wenzelm@7315
   176
\subsection{Primitive types and type abbreviations}\label{sec:types-pure}
wenzelm@7134
   177
wenzelm@7134
   178
\indexisarcmd{typedecl}\indexisarcmd{types}\indexisarcmd{nonterminals}\indexisarcmd{arities}
wenzelm@7134
   179
\begin{matharray}{rcl}
wenzelm@7134
   180
  \isarcmd{types} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   181
  \isarcmd{typedecl} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   182
  \isarcmd{nonterminals} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   183
  \isarcmd{arities} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   184
\end{matharray}
wenzelm@7134
   185
wenzelm@7134
   186
\begin{rail}
wenzelm@7134
   187
  'types' (typespec '=' type infix? comment? +)
wenzelm@7134
   188
  ;
wenzelm@7134
   189
  'typedecl' typespec infix? comment?
wenzelm@7134
   190
  ;
wenzelm@7134
   191
  'nonterminals' (name +) comment?
wenzelm@7134
   192
  ;
wenzelm@7134
   193
  'arities' (nameref '::' arity comment? +)
wenzelm@7134
   194
  ;
wenzelm@7134
   195
\end{rail}
wenzelm@7134
   196
wenzelm@7167
   197
\begin{descr}
wenzelm@7335
   198
\item [$\TYPES~(\vec\alpha)t = \tau$] introduces \emph{type synonym}
wenzelm@7134
   199
  $(\vec\alpha)t$ for existing type $\tau$.  Unlike actual type definitions,
wenzelm@7134
   200
  as are available in Isabelle/HOL for example, type synonyms are just purely
wenzelm@7895
   201
  syntactic abbreviations without any logical significance.  Internally, type
wenzelm@7981
   202
  synonyms are fully expanded.
wenzelm@7134
   203
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] declares a new type constructor
wenzelm@7895
   204
  $t$, intended as an actual logical type.  Note that object-logics such as
wenzelm@7895
   205
  Isabelle/HOL override $\isarkeyword{typedecl}$ by their own version.
wenzelm@7175
   206
\item [$\isarkeyword{nonterminals}~\vec c$] declares $0$-ary type constructors
wenzelm@7175
   207
  $\vec c$ to act as purely syntactic types, i.e.\ nonterminal symbols of
wenzelm@7175
   208
  Isabelle's inner syntax of terms or types.
wenzelm@7335
   209
\item [$\isarkeyword{arities}~t::(\vec s)s$] augments Isabelle's order-sorted
wenzelm@7335
   210
  signature of types by new type constructor arities.  This is done
wenzelm@10223
   211
  axiomatically!  The $\INSTANCE$ command (see \S\ref{sec:axclass}) provides a
wenzelm@10223
   212
  way to introduce proven type arities.
wenzelm@7167
   213
\end{descr}
wenzelm@7134
   214
wenzelm@7134
   215
wenzelm@7981
   216
\subsection{Constants and simple definitions}\label{sec:consts}
wenzelm@7134
   217
wenzelm@7175
   218
\indexisarcmd{consts}\indexisarcmd{defs}\indexisarcmd{constdefs}\indexoutertoken{constdecl}
wenzelm@7134
   219
\begin{matharray}{rcl}
wenzelm@7134
   220
  \isarcmd{consts} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   221
  \isarcmd{defs} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   222
  \isarcmd{constdefs} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   223
\end{matharray}
wenzelm@7134
   224
wenzelm@7134
   225
\begin{rail}
wenzelm@7134
   226
  'consts' (constdecl +)
wenzelm@7134
   227
  ;
wenzelm@9308
   228
  'defs' ('(overloaded)')? (axmdecl prop comment? +)
wenzelm@7134
   229
  ;
wenzelm@7134
   230
  'constdefs' (constdecl prop comment? +)
wenzelm@7134
   231
  ;
wenzelm@7134
   232
wenzelm@7134
   233
  constdecl: name '::' type mixfix? comment?
wenzelm@7134
   234
  ;
wenzelm@7134
   235
\end{rail}
wenzelm@7134
   236
wenzelm@7167
   237
\begin{descr}
wenzelm@7335
   238
\item [$\CONSTS~c::\sigma$] declares constant $c$ to have any instance of type
wenzelm@7335
   239
  scheme $\sigma$.  The optional mixfix annotations may attach concrete syntax
wenzelm@7895
   240
  to the constants declared.
wenzelm@9308
   241
wenzelm@7335
   242
\item [$\DEFS~name: eqn$] introduces $eqn$ as a definitional axiom for some
wenzelm@7335
   243
  existing constant.  See \cite[\S6]{isabelle-ref} for more details on the
wenzelm@7335
   244
  form of equations admitted as constant definitions.
wenzelm@9308
   245
  
wenzelm@9308
   246
  The $overloaded$ option declares definitions to be potentially overloaded.
wenzelm@9308
   247
  Unless this option is given, a warning message would be issued for any
wenzelm@9308
   248
  definitional equation with a more special type than that of the
wenzelm@9308
   249
  corresponding constant declaration.
wenzelm@9308
   250
wenzelm@7335
   251
\item [$\isarkeyword{constdefs}~c::\sigma~eqn$] combines declarations and
wenzelm@8547
   252
  definitions of constants, using the canonical name $c_def$ for the
wenzelm@8547
   253
  definitional axiom.
wenzelm@7167
   254
\end{descr}
wenzelm@7134
   255
wenzelm@7134
   256
wenzelm@7981
   257
\subsection{Syntax and translations}\label{sec:syn-trans}
wenzelm@7134
   258
wenzelm@7134
   259
\indexisarcmd{syntax}\indexisarcmd{translations}
wenzelm@7134
   260
\begin{matharray}{rcl}
wenzelm@7134
   261
  \isarcmd{syntax} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   262
  \isarcmd{translations} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   263
\end{matharray}
wenzelm@7134
   264
wenzelm@10640
   265
\railalias{rightleftharpoons}{\isasymrightleftharpoons}
wenzelm@10640
   266
\railterm{rightleftharpoons}
wenzelm@10640
   267
wenzelm@10640
   268
\railalias{rightharpoonup}{\isasymrightharpoonup}
wenzelm@10640
   269
\railterm{rightharpoonup}
wenzelm@10640
   270
wenzelm@10640
   271
\railalias{leftharpoondown}{\isasymleftharpoondown}
wenzelm@10640
   272
\railterm{leftharpoondown}
wenzelm@10640
   273
wenzelm@7134
   274
\begin{rail}
wenzelm@9727
   275
  'syntax' ('(' ( name | 'output' | name 'output' ) ')')? (constdecl +)
wenzelm@7134
   276
  ;
wenzelm@10640
   277
  'translations' (transpat ('==' | '=>' | '<=' | rightleftharpoons | rightharpoonup | leftharpoondown) transpat comment? +)
wenzelm@7134
   278
  ;
wenzelm@7134
   279
  transpat: ('(' nameref ')')? string
wenzelm@7134
   280
  ;
wenzelm@7134
   281
\end{rail}
wenzelm@7134
   282
wenzelm@7167
   283
\begin{descr}
wenzelm@7175
   284
\item [$\isarkeyword{syntax}~(mode)~decls$] is similar to $\CONSTS~decls$,
wenzelm@7175
   285
  except that the actual logical signature extension is omitted.  Thus the
wenzelm@7175
   286
  context free grammar of Isabelle's inner syntax may be augmented in
wenzelm@7335
   287
  arbitrary ways, independently of the logic.  The $mode$ argument refers to
wenzelm@8547
   288
  the print mode that the grammar rules belong; unless the \texttt{output}
wenzelm@8547
   289
  flag is given, all productions are added both to the input and output
wenzelm@8547
   290
  grammar.
wenzelm@7175
   291
\item [$\isarkeyword{translations}~rules$] specifies syntactic translation
wenzelm@10640
   292
  rules (i.e.\ \emph{macros}): parse~/ print rules (\texttt{==} or
wenzelm@10640
   293
  \isasymrightleftharpoons), parse rules (\texttt{=>} or
wenzelm@10640
   294
  \isasymrightharpoonup), or print rules (\texttt{<=} or
wenzelm@10640
   295
  \isasymleftharpoondown).  Translation patterns may be prefixed by the
wenzelm@10640
   296
  syntactic category to be used for parsing; the default is \texttt{logic}.
wenzelm@7167
   297
\end{descr}
wenzelm@7134
   298
wenzelm@7134
   299
wenzelm@9605
   300
\subsection{Axioms and theorems}\label{sec:axms-thms}
wenzelm@7134
   301
wenzelm@12618
   302
\indexisarcmd{axioms}\indexisarcmd{lemmas}\indexisarcmd{theorems}
wenzelm@7134
   303
\begin{matharray}{rcl}
wenzelm@7134
   304
  \isarcmd{axioms} & : & \isartrans{theory}{theory} \\
wenzelm@12618
   305
  \isarcmd{lemmas} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   306
  \isarcmd{theorems} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   307
\end{matharray}
wenzelm@7134
   308
wenzelm@7134
   309
\begin{rail}
wenzelm@7135
   310
  'axioms' (axmdecl prop comment? +)
wenzelm@7134
   311
  ;
wenzelm@12618
   312
  ('lemmas' | 'theorems') (thmdef? thmrefs comment? + 'and')
wenzelm@7134
   313
  ;
wenzelm@7134
   314
\end{rail}
wenzelm@7134
   315
wenzelm@7167
   316
\begin{descr}
wenzelm@7335
   317
\item [$\isarkeyword{axioms}~a: \phi$] introduces arbitrary statements as
wenzelm@7895
   318
  axioms of the meta-logic.  In fact, axioms are ``axiomatic theorems'', and
wenzelm@7895
   319
  may be referred later just as any other theorem.
wenzelm@7134
   320
  
wenzelm@7134
   321
  Axioms are usually only introduced when declaring new logical systems.
wenzelm@7175
   322
  Everyday work is typically done the hard way, with proper definitions and
wenzelm@8547
   323
  actual proven theorems.
wenzelm@12618
   324
\item [$\isarkeyword{lemmas}~a = \vec b$] stores existing facts.  Typical
wenzelm@12618
   325
  applications would also involve attributes, to declare Simplifier rules, for
wenzelm@12618
   326
  example.
wenzelm@12618
   327
\item [$\isarkeyword{theorems}$] is essentially the same as
wenzelm@12618
   328
  $\isarkeyword{lemmas}$, but marks the result as a different kind of facts.
wenzelm@7167
   329
\end{descr}
wenzelm@7134
   330
wenzelm@7134
   331
wenzelm@7167
   332
\subsection{Name spaces}
wenzelm@7134
   333
wenzelm@8726
   334
\indexisarcmd{global}\indexisarcmd{local}\indexisarcmd{hide}
wenzelm@7134
   335
\begin{matharray}{rcl}
wenzelm@7134
   336
  \isarcmd{global} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   337
  \isarcmd{local} & : & \isartrans{theory}{theory} \\
wenzelm@8726
   338
  \isarcmd{hide} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   339
\end{matharray}
wenzelm@7134
   340
wenzelm@8726
   341
\begin{rail}
wenzelm@8726
   342
  'global' comment?
wenzelm@8726
   343
  ;
wenzelm@8726
   344
  'local' comment?
wenzelm@8726
   345
  ;
wenzelm@8726
   346
  'hide' name (nameref + ) comment?
wenzelm@8726
   347
  ;
wenzelm@8726
   348
\end{rail}
wenzelm@8726
   349
wenzelm@7895
   350
Isabelle organizes any kind of name declarations (of types, constants,
wenzelm@8547
   351
theorems etc.) by separate hierarchically structured name spaces.  Normally
wenzelm@8726
   352
the user does not have to control the behavior of name spaces by hand, yet the
wenzelm@8726
   353
following commands provide some way to do so.
wenzelm@7175
   354
wenzelm@7167
   355
\begin{descr}
wenzelm@7167
   356
\item [$\isarkeyword{global}$ and $\isarkeyword{local}$] change the current
wenzelm@7167
   357
  name declaration mode.  Initially, theories start in $\isarkeyword{local}$
wenzelm@7167
   358
  mode, causing all names to be automatically qualified by the theory name.
wenzelm@7895
   359
  Changing this to $\isarkeyword{global}$ causes all names to be declared
wenzelm@7895
   360
  without the theory prefix, until $\isarkeyword{local}$ is declared again.
wenzelm@8726
   361
  
wenzelm@8726
   362
  Note that global names are prone to get hidden accidently later, when
wenzelm@8726
   363
  qualified names of the same base name are introduced.
wenzelm@8726
   364
  
wenzelm@8726
   365
\item [$\isarkeyword{hide}~space~names$] removes declarations from a given
wenzelm@8726
   366
  name space (which may be $class$, $type$, or $const$).  Hidden objects
wenzelm@8726
   367
  remain valid within the logic, but are inaccessible from user input.  In
wenzelm@8726
   368
  output, the special qualifier ``$\mathord?\mathord?$'' is prefixed to the
wenzelm@8726
   369
  full internal name.
wenzelm@8726
   370
  
wenzelm@8726
   371
  Unqualified (global) names may not be hidden deliberately.
wenzelm@7167
   372
\end{descr}
wenzelm@7134
   373
wenzelm@7134
   374
wenzelm@7167
   375
\subsection{Incorporating ML code}\label{sec:ML}
wenzelm@7134
   376
wenzelm@8682
   377
\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{ML-command}
wenzelm@8682
   378
\indexisarcmd{ML-setup}\indexisarcmd{setup}
wenzelm@9199
   379
\indexisarcmd{method-setup}
wenzelm@7134
   380
\begin{matharray}{rcl}
wenzelm@7134
   381
  \isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\
wenzelm@7134
   382
  \isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\
wenzelm@8682
   383
  \isarcmd{ML_command} & : & \isartrans{\cdot}{\cdot} \\
wenzelm@7895
   384
  \isarcmd{ML_setup} & : & \isartrans{theory}{theory} \\
wenzelm@7175
   385
  \isarcmd{setup} & : & \isartrans{theory}{theory} \\
wenzelm@9199
   386
  \isarcmd{method_setup} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   387
\end{matharray}
wenzelm@7134
   388
wenzelm@7895
   389
\railalias{MLsetup}{ML\_setup}
wenzelm@7895
   390
\railterm{MLsetup}
wenzelm@7895
   391
wenzelm@9199
   392
\railalias{methodsetup}{method\_setup}
wenzelm@9199
   393
\railterm{methodsetup}
wenzelm@9199
   394
wenzelm@8682
   395
\railalias{MLcommand}{ML\_command}
wenzelm@8682
   396
\railterm{MLcommand}
wenzelm@8682
   397
wenzelm@7134
   398
\begin{rail}
wenzelm@9273
   399
  'use' name comment?
wenzelm@7134
   400
  ;
wenzelm@9273
   401
  ('ML' | MLcommand | MLsetup | 'setup') text comment?
wenzelm@7134
   402
  ;
wenzelm@9199
   403
  methodsetup name '=' text text comment?
wenzelm@9199
   404
  ;
wenzelm@7134
   405
\end{rail}
wenzelm@7134
   406
wenzelm@7167
   407
\begin{descr}
wenzelm@7175
   408
\item [$\isarkeyword{use}~file$] reads and executes ML commands from $file$.
wenzelm@7466
   409
  The current theory context (if present) is passed down to the ML session,
wenzelm@7981
   410
  but may not be modified.  Furthermore, the file name is checked with the
wenzelm@7466
   411
  $\isarkeyword{files}$ dependency declaration given in the theory header (see
wenzelm@7466
   412
  also \S\ref{sec:begin-thy}).
wenzelm@7466
   413
  
wenzelm@8682
   414
\item [$\isarkeyword{ML}~text$ and $\isarkeyword{ML_command}~text$] execute ML
wenzelm@8682
   415
  commands from $text$.  The theory context is passed in the same way as for
wenzelm@10858
   416
  $\isarkeyword{use}$, but may not be changed.  Note that the output of
wenzelm@8682
   417
  $\isarkeyword{ML_command}$ is less verbose than plain $\isarkeyword{ML}$.
wenzelm@7895
   418
  
wenzelm@7895
   419
\item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$.  The
wenzelm@7895
   420
  theory context is passed down to the ML session, and fetched back
wenzelm@7895
   421
  afterwards.  Thus $text$ may actually change the theory as a side effect.
wenzelm@7895
   422
  
wenzelm@7167
   423
\item [$\isarkeyword{setup}~text$] changes the current theory context by
wenzelm@8379
   424
  applying $text$, which refers to an ML expression of type
wenzelm@8379
   425
  \texttt{(theory~->~theory)~list}.  The $\isarkeyword{setup}$ command is the
wenzelm@8547
   426
  canonical way to initialize any object-logic specific tools and packages
wenzelm@8547
   427
  written in ML.
wenzelm@9199
   428
  
wenzelm@9199
   429
\item [$\isarkeyword{method_setup}~name = text~description$] defines a proof
wenzelm@9199
   430
  method in the current theory.  The given $text$ has to be an ML expression
wenzelm@9199
   431
  of type \texttt{Args.src -> Proof.context -> Proof.method}.  Parsing
wenzelm@9199
   432
  concrete method syntax from \texttt{Args.src} input can be quite tedious in
wenzelm@9199
   433
  general.  The following simple examples are for methods without any explicit
wenzelm@9199
   434
  arguments, or a list of theorems, respectively.
wenzelm@9199
   435
wenzelm@9199
   436
{\footnotesize
wenzelm@9199
   437
\begin{verbatim}
wenzelm@9605
   438
 Method.no_args (Method.METHOD (fn facts => foobar_tac))
wenzelm@9605
   439
 Method.thms_args (fn thms => Method.METHOD (fn facts => foobar_tac))
wenzelm@10899
   440
 Method.ctxt_args (fn ctxt => Method.METHOD (fn facts => foobar_tac))
wenzelm@12618
   441
 Method.thms_ctxt_args (fn thms => fn ctxt =>
wenzelm@12618
   442
    Method.METHOD (fn facts => foobar_tac))
wenzelm@9199
   443
\end{verbatim}
wenzelm@9199
   444
}
wenzelm@9199
   445
wenzelm@9199
   446
Note that mere tactic emulations may ignore the \texttt{facts} parameter
wenzelm@9199
   447
above.  Proper proof methods would do something ``appropriate'' with the list
wenzelm@9199
   448
of current facts, though.  Single-rule methods usually do strict
wenzelm@9199
   449
forward-chaining (e.g.\ by using \texttt{Method.multi_resolves}), while
wenzelm@9199
   450
automatic ones just insert the facts using \texttt{Method.insert_tac} before
wenzelm@9199
   451
applying the main tactic.
wenzelm@7167
   452
\end{descr}
wenzelm@7134
   453
wenzelm@7134
   454
wenzelm@8250
   455
\subsection{Syntax translation functions}
wenzelm@7134
   456
wenzelm@8250
   457
\indexisarcmd{parse-ast-translation}\indexisarcmd{parse-translation}
wenzelm@8250
   458
\indexisarcmd{print-translation}\indexisarcmd{typed-print-translation}
wenzelm@8250
   459
\indexisarcmd{print-ast-translation}\indexisarcmd{token-translation}
wenzelm@8250
   460
\begin{matharray}{rcl}
wenzelm@8250
   461
  \isarcmd{parse_ast_translation} & : & \isartrans{theory}{theory} \\
wenzelm@8250
   462
  \isarcmd{parse_translation} & : & \isartrans{theory}{theory} \\
wenzelm@8250
   463
  \isarcmd{print_translation} & : & \isartrans{theory}{theory} \\
wenzelm@8250
   464
  \isarcmd{typed_print_translation} & : & \isartrans{theory}{theory} \\
wenzelm@8250
   465
  \isarcmd{print_ast_translation} & : & \isartrans{theory}{theory} \\
wenzelm@8250
   466
  \isarcmd{token_translation} & : & \isartrans{theory}{theory} \\
wenzelm@8250
   467
\end{matharray}
wenzelm@7134
   468
wenzelm@9273
   469
\railalias{parseasttranslation}{parse\_ast\_translation}
wenzelm@9273
   470
\railterm{parseasttranslation}
wenzelm@9273
   471
wenzelm@9273
   472
\railalias{parsetranslation}{parse\_translation}
wenzelm@9273
   473
\railterm{parsetranslation}
wenzelm@9273
   474
wenzelm@9273
   475
\railalias{printtranslation}{print\_translation}
wenzelm@9273
   476
\railterm{printtranslation}
wenzelm@9273
   477
wenzelm@9273
   478
\railalias{typedprinttranslation}{typed\_print\_translation}
wenzelm@9273
   479
\railterm{typedprinttranslation}
wenzelm@9273
   480
wenzelm@9273
   481
\railalias{printasttranslation}{print\_ast\_translation}
wenzelm@9273
   482
\railterm{printasttranslation}
wenzelm@9273
   483
wenzelm@9273
   484
\railalias{tokentranslation}{token\_translation}
wenzelm@9273
   485
\railterm{tokentranslation}
wenzelm@9273
   486
wenzelm@9273
   487
\begin{rail}
wenzelm@9273
   488
  ( parseasttranslation | parsetranslation | printtranslation | typedprinttranslation |
wenzelm@9273
   489
  printasttranslation | tokentranslation ) text comment?
wenzelm@9273
   490
\end{rail}
wenzelm@9273
   491
wenzelm@8250
   492
Syntax translation functions written in ML admit almost arbitrary
wenzelm@8250
   493
manipulations of Isabelle's inner syntax.  Any of the above commands have a
wenzelm@8250
   494
single \railqtoken{text} argument that refers to an ML expression of
wenzelm@8379
   495
appropriate type.
wenzelm@8379
   496
wenzelm@8379
   497
\begin{ttbox}
wenzelm@8379
   498
val parse_ast_translation   : (string * (ast list -> ast)) list
wenzelm@8379
   499
val parse_translation       : (string * (term list -> term)) list
wenzelm@8379
   500
val print_translation       : (string * (term list -> term)) list
wenzelm@8379
   501
val typed_print_translation :
wenzelm@8379
   502
  (string * (bool -> typ -> term list -> term)) list
wenzelm@8379
   503
val print_ast_translation   : (string * (ast list -> ast)) list
wenzelm@8379
   504
val token_translation       :
wenzelm@8379
   505
  (string * string * (string -> string * real)) list
wenzelm@8379
   506
\end{ttbox}
wenzelm@8379
   507
See \cite[\S8]{isabelle-ref} for more information on syntax transformations.
wenzelm@7134
   508
wenzelm@7134
   509
wenzelm@7134
   510
\subsection{Oracles}
wenzelm@7134
   511
wenzelm@7134
   512
\indexisarcmd{oracle}
wenzelm@7134
   513
\begin{matharray}{rcl}
wenzelm@7134
   514
  \isarcmd{oracle} & : & \isartrans{theory}{theory} \\
wenzelm@7134
   515
\end{matharray}
wenzelm@7134
   516
wenzelm@7175
   517
Oracles provide an interface to external reasoning systems, without giving up
wenzelm@7175
   518
control completely --- each theorem carries a derivation object recording any
wenzelm@7175
   519
oracle invocation.  See \cite[\S6]{isabelle-ref} for more information.
wenzelm@7175
   520
wenzelm@7134
   521
\begin{rail}
wenzelm@7134
   522
  'oracle' name '=' text comment?
wenzelm@7134
   523
  ;
wenzelm@7134
   524
\end{rail}
wenzelm@7134
   525
wenzelm@7167
   526
\begin{descr}
wenzelm@7175
   527
\item [$\isarkeyword{oracle}~name=text$] declares oracle $name$ to be ML
wenzelm@8379
   528
  function $text$, which has to be of type
wenzelm@8379
   529
  \texttt{Sign.sg~*~Object.T~->~term}.
wenzelm@7167
   530
\end{descr}
wenzelm@7134
   531
wenzelm@7134
   532
wenzelm@7134
   533
\section{Proof commands}
wenzelm@7134
   534
wenzelm@7987
   535
Proof commands perform transitions of Isar/VM machine configurations, which
wenzelm@7315
   536
are block-structured, consisting of a stack of nodes with three main
wenzelm@7335
   537
components: logical proof context, current facts, and open goals.  Isar/VM
wenzelm@8547
   538
transitions are \emph{typed} according to the following three different modes
wenzelm@8547
   539
of operation:
wenzelm@7167
   540
\begin{descr}
wenzelm@7167
   541
\item [$proof(prove)$] means that a new goal has just been stated that is now
wenzelm@8547
   542
  to be \emph{proven}; the next command may refine it by some proof method,
wenzelm@8547
   543
  and enter a sub-proof to establish the actual result.
wenzelm@10858
   544
\item [$proof(state)$] is like a nested theory mode: the context may be
wenzelm@7987
   545
  augmented by \emph{stating} additional assumptions, intermediate results
wenzelm@7987
   546
  etc.
wenzelm@7895
   547
\item [$proof(chain)$] is intermediate between $proof(state)$ and
wenzelm@7987
   548
  $proof(prove)$: existing facts (i.e.\ the contents of the special ``$this$''
wenzelm@7987
   549
  register) have been just picked up in order to be used when refining the
wenzelm@7987
   550
  goal claimed next.
wenzelm@7167
   551
\end{descr}
wenzelm@7134
   552
wenzelm@12618
   553
%FIXME diagram?
wenzelm@7167
   554
wenzelm@7895
   555
\subsection{Proof markup commands}\label{sec:markup-prf}
wenzelm@7167
   556
wenzelm@7987
   557
\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsubsect}
wenzelm@7895
   558
\indexisarcmd{txt}\indexisarcmd{txt-raw}
wenzelm@7134
   559
\begin{matharray}{rcl}
wenzelm@8101
   560
  \isarcmd{sect} & : & \isartrans{proof}{proof} \\
wenzelm@8101
   561
  \isarcmd{subsect} & : & \isartrans{proof}{proof} \\
wenzelm@8101
   562
  \isarcmd{subsubsect} & : & \isartrans{proof}{proof} \\
wenzelm@8101
   563
  \isarcmd{txt} & : & \isartrans{proof}{proof} \\
wenzelm@8101
   564
  \isarcmd{txt_raw} & : & \isartrans{proof}{proof} \\
wenzelm@7134
   565
\end{matharray}
wenzelm@7134
   566
wenzelm@7895
   567
These markup commands for proof mode closely correspond to the ones of theory
wenzelm@8684
   568
mode (see \S\ref{sec:markup-thy}).
wenzelm@7895
   569
wenzelm@7895
   570
\railalias{txtraw}{txt\_raw}
wenzelm@7895
   571
\railterm{txtraw}
wenzelm@7175
   572
wenzelm@7134
   573
\begin{rail}
wenzelm@7895
   574
  ('sect' | 'subsect' | 'subsubsect' | 'txt' | txtraw) text
wenzelm@7134
   575
  ;
wenzelm@7134
   576
\end{rail}
wenzelm@7134
   577
wenzelm@7134
   578
wenzelm@7315
   579
\subsection{Proof context}\label{sec:proof-context}
wenzelm@7134
   580
wenzelm@7315
   581
\indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def}
wenzelm@7134
   582
\begin{matharray}{rcl}
wenzelm@7134
   583
  \isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7134
   584
  \isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7134
   585
  \isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7134
   586
  \isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7134
   587
\end{matharray}
wenzelm@7134
   588
wenzelm@7315
   589
The logical proof context consists of fixed variables and assumptions.  The
wenzelm@7315
   590
former closely correspond to Skolem constants, or meta-level universal
wenzelm@7315
   591
quantification as provided by the Isabelle/Pure logical framework.
wenzelm@7315
   592
Introducing some \emph{arbitrary, but fixed} variable via $\FIX x$ results in
wenzelm@7987
   593
a local value that may be used in the subsequent proof as any other variable
wenzelm@7895
   594
or constant.  Furthermore, any result $\edrv \phi[x]$ exported from the
wenzelm@7987
   595
context will be universally closed wrt.\ $x$ at the outermost level: $\edrv
wenzelm@7987
   596
\All x \phi$ (this is expressed using Isabelle's meta-variables).
wenzelm@7315
   597
wenzelm@7315
   598
Similarly, introducing some assumption $\chi$ has two effects.  On the one
wenzelm@7315
   599
hand, a local theorem is created that may be used as a fact in subsequent
wenzelm@7895
   600
proof steps.  On the other hand, any result $\chi \drv \phi$ exported from the
wenzelm@7895
   601
context becomes conditional wrt.\ the assumption: $\edrv \chi \Imp \phi$.
wenzelm@7895
   602
Thus, solving an enclosing goal using such a result would basically introduce
wenzelm@7895
   603
a new subgoal stemming from the assumption.  How this situation is handled
wenzelm@7895
   604
depends on the actual version of assumption command used: while $\ASSUMENAME$
wenzelm@7895
   605
insists on solving the subgoal by unification with some premise of the goal,
wenzelm@7895
   606
$\PRESUMENAME$ leaves the subgoal unchanged in order to be proved later by the
wenzelm@7895
   607
user.
wenzelm@7315
   608
wenzelm@7319
   609
Local definitions, introduced by $\DEF{}{x \equiv t}$, are achieved by
wenzelm@7987
   610
combining $\FIX x$ with another version of assumption that causes any
wenzelm@7987
   611
hypothetical equation $x \equiv t$ to be eliminated by the reflexivity rule.
wenzelm@7987
   612
Thus, exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$.
wenzelm@7175
   613
wenzelm@10686
   614
\railalias{equiv}{\isasymequiv}
wenzelm@10686
   615
\railterm{equiv}
wenzelm@10686
   616
wenzelm@7134
   617
\begin{rail}
wenzelm@12618
   618
  'fix' (vars comment? + 'and')
wenzelm@7134
   619
  ;
wenzelm@12618
   620
  ('assume' | 'presume') (props comment? + 'and')
wenzelm@7134
   621
  ;
wenzelm@10686
   622
  'def' thmdecl? \\ name ('==' | equiv) term termpat? comment?
wenzelm@7134
   623
  ;
wenzelm@7134
   624
\end{rail}
wenzelm@7134
   625
wenzelm@7167
   626
\begin{descr}
wenzelm@8547
   627
\item [$\FIX{\vec x}$] introduces local \emph{arbitrary, but fixed} variables
wenzelm@8547
   628
  $\vec x$.
wenzelm@8515
   629
\item [$\ASSUME{a}{\vec\phi}$ and $\PRESUME{a}{\vec\phi}$] introduce local
wenzelm@8515
   630
  theorems $\vec\phi$ by assumption.  Subsequent results applied to an
wenzelm@8515
   631
  enclosing goal (e.g.\ by $\SHOWNAME$) are handled as follows: $\ASSUMENAME$
wenzelm@8515
   632
  expects to be able to unify with existing premises in the goal, while
wenzelm@8515
   633
  $\PRESUMENAME$ leaves $\vec\phi$ as new subgoals.
wenzelm@7335
   634
  
wenzelm@7335
   635
  Several lists of assumptions may be given (separated by
wenzelm@7895
   636
  $\isarkeyword{and}$); the resulting list of current facts consists of all of
wenzelm@7895
   637
  these concatenated.
wenzelm@7315
   638
\item [$\DEF{a}{x \equiv t}$] introduces a local (non-polymorphic) definition.
wenzelm@7315
   639
  In results exported from the context, $x$ is replaced by $t$.  Basically,
wenzelm@7987
   640
  $\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\ASSUME{}{x \equiv t}$, with the
wenzelm@7335
   641
  resulting hypothetical equation solved by reflexivity.
wenzelm@7431
   642
  
wenzelm@7431
   643
  The default name for the definitional equation is $x_def$.
wenzelm@7167
   644
\end{descr}
wenzelm@7167
   645
wenzelm@7895
   646
The special name $prems$\indexisarthm{prems} refers to all assumptions of the
wenzelm@7895
   647
current context as a list of theorems.
wenzelm@7315
   648
wenzelm@7167
   649
wenzelm@7167
   650
\subsection{Facts and forward chaining}
wenzelm@7167
   651
wenzelm@7167
   652
\indexisarcmd{note}\indexisarcmd{then}\indexisarcmd{from}\indexisarcmd{with}
wenzelm@7167
   653
\begin{matharray}{rcl}
wenzelm@7167
   654
  \isarcmd{note} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7167
   655
  \isarcmd{then} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@7167
   656
  \isarcmd{from} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@7167
   657
  \isarcmd{with} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@7167
   658
\end{matharray}
wenzelm@7167
   659
wenzelm@7319
   660
New facts are established either by assumption or proof of local statements.
wenzelm@7335
   661
Any fact will usually be involved in further proofs, either as explicit
wenzelm@8547
   662
arguments of proof methods, or when forward chaining towards the next goal via
wenzelm@7335
   663
$\THEN$ (and variants).  Note that the special theorem name
wenzelm@7987
   664
$this$\indexisarthm{this} refers to the most recently established facts.
wenzelm@7167
   665
\begin{rail}
wenzelm@9199
   666
  'note' (thmdef? thmrefs comment? + 'and')
wenzelm@7167
   667
  ;
wenzelm@7167
   668
  'then' comment?
wenzelm@7167
   669
  ;
wenzelm@9199
   670
  ('from' | 'with') (thmrefs comment? + 'and')
wenzelm@7167
   671
  ;
wenzelm@7167
   672
\end{rail}
wenzelm@7167
   673
wenzelm@7167
   674
\begin{descr}
wenzelm@7175
   675
\item [$\NOTE{a}{\vec b}$] recalls existing facts $\vec b$, binding the result
wenzelm@7175
   676
  as $a$.  Note that attributes may be involved as well, both on the left and
wenzelm@7175
   677
  right hand sides.
wenzelm@7167
   678
\item [$\THEN$] indicates forward chaining by the current facts in order to
wenzelm@7895
   679
  establish the goal to be claimed next.  The initial proof method invoked to
wenzelm@7895
   680
  refine that will be offered the facts to do ``anything appropriate'' (cf.\ 
wenzelm@7895
   681
  also \S\ref{sec:proof-steps}).  For example, method $rule$ (see
wenzelm@8515
   682
  \S\ref{sec:pure-meth-att}) would typically do an elimination rather than an
wenzelm@7895
   683
  introduction.  Automatic methods usually insert the facts into the goal
wenzelm@8547
   684
  state before operation.  This provides a simple scheme to control relevance
wenzelm@8547
   685
  of facts in automated proof search.
wenzelm@7335
   686
\item [$\FROM{\vec b}$] abbreviates $\NOTE{}{\vec b}~\THEN$; thus $\THEN$ is
wenzelm@7458
   687
  equivalent to $\FROM{this}$.
wenzelm@10858
   688
\item [$\WITH{\vec b}$] abbreviates $\FROM{\vec b~this}$; thus the forward
wenzelm@7175
   689
  chaining is from earlier facts together with the current ones.
wenzelm@7167
   690
\end{descr}
wenzelm@7167
   691
wenzelm@8515
   692
Basic proof methods (such as $rule$, see \S\ref{sec:pure-meth-att}) expect
wenzelm@7895
   693
multiple facts to be given in their proper order, corresponding to a prefix of
wenzelm@7895
   694
the premises of the rule involved.  Note that positions may be easily skipped
wenzelm@9695
   695
using something like $\FROM{\Text{\texttt{_}}~a~b}$, for example.  This
wenzelm@8547
   696
involves the trivial rule $\PROP\psi \Imp \PROP\psi$, which happens to be
wenzelm@8547
   697
bound in Isabelle/Pure as ``\texttt{_}''
wenzelm@8547
   698
(underscore).\indexisarthm{_@\texttt{_}}
wenzelm@7389
   699
wenzelm@9238
   700
Forward chaining with an empty list of theorems is the same as not chaining.
wenzelm@9238
   701
Thus $\FROM{nothing}$ has no effect apart from entering $prove(chain)$ mode,
wenzelm@9238
   702
since $nothing$\indexisarthm{nothing} is bound to the empty list of facts.
wenzelm@9238
   703
wenzelm@7167
   704
wenzelm@7167
   705
\subsection{Goal statements}
wenzelm@7167
   706
wenzelm@12618
   707
\indexisarcmd{lemma}\indexisarcmd{theorem}\indexisarcmd{corollary}
wenzelm@7167
   708
\indexisarcmd{have}\indexisarcmd{show}\indexisarcmd{hence}\indexisarcmd{thus}
wenzelm@7167
   709
\begin{matharray}{rcl}
wenzelm@12618
   710
  \isarcmd{lemma} & : & \isartrans{theory}{proof(prove)} \\
wenzelm@7167
   711
  \isarcmd{theorem} & : & \isartrans{theory}{proof(prove)} \\
wenzelm@12618
   712
  \isarcmd{corollary} & : & \isartrans{theory}{proof(prove)} \\
wenzelm@7987
   713
  \isarcmd{have} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
wenzelm@7987
   714
  \isarcmd{show} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
wenzelm@7167
   715
  \isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@7167
   716
  \isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@7167
   717
\end{matharray}
wenzelm@7167
   718
wenzelm@12618
   719
From a theory context, proof mode is entered from theory mode by initial goal
wenzelm@12618
   720
commands $\LEMMANAME$, $\THEOREMNAME$, and $\COROLLARYNAME$.  Within a proof,
wenzelm@12618
   721
new claims may be introduced locally as well; four variants are available,
wenzelm@12618
   722
indicating whether the result is meant to solve some pending goal or whether
wenzelm@12618
   723
forward chaining is indicated.
wenzelm@12618
   724
wenzelm@12618
   725
Goals may consist of multiple statements, resulting in a list of facts
wenzelm@12618
   726
eventually.  A pending multi-goal is internally represented as a meta-level
wenzelm@12618
   727
conjunction (printed as \verb,&&,), which is automatically split into the
wenzelm@12618
   728
corresponding number of sub-goals prior to any initial method application, via
wenzelm@12618
   729
$\PROOFNAME$ (\S\ref{sec:proof-steps}) or $\APPLYNAME$
wenzelm@12618
   730
(\S\ref{sec:tactic-commands}).\footnote{Deviating from the latter principle,
wenzelm@12618
   731
  the $induct$ method covered in \S\ref{sec:cases-induct-meth} acts on
wenzelm@12618
   732
  multiple claims simultaneously.}
wenzelm@12618
   733
wenzelm@12618
   734
%FIXME define locale, context
wenzelm@7175
   735
wenzelm@7167
   736
\begin{rail}
wenzelm@12618
   737
  ('lemma' | 'theorem' | 'corollary') locale context goal
wenzelm@7167
   738
  ;
wenzelm@7167
   739
  ('have' | 'show' | 'hence' | 'thus') goal
wenzelm@7167
   740
  ;
wenzelm@7167
   741
wenzelm@12618
   742
  goal: (props comment? + 'and')
wenzelm@7167
   743
  ;
wenzelm@7167
   744
\end{rail}
wenzelm@7167
   745
wenzelm@7167
   746
\begin{descr}
wenzelm@12618
   747
\item [$\LEMMA{a}{\vec\phi}$] enters proof mode with $\vec\phi$ as main goal,
wenzelm@12618
   748
  eventually resulting in some fact $\turn \vec\phi$ to be put back into the
wenzelm@12618
   749
  theory context, and optionally into the specified locale, cf.\ 
wenzelm@12618
   750
  \S\ref{sec:locale}.  An additional \railnonterm{context} specification may
wenzelm@12618
   751
  build an initial proof context for the subsequent claim; this may include
wenzelm@12618
   752
  local definitions and syntax as well, see \S\ref{sec:locale} for more
wenzelm@12618
   753
  information.
wenzelm@12618
   754
  
wenzelm@12618
   755
\item [$\THEOREM{a}{\vec\phi}$ and $\COROLLARY{a}{\vec\phi}$] are essentially
wenzelm@12618
   756
  the same as $\LEMMA{a}{\vec\phi}$, but the facts are internally marked as
wenzelm@12618
   757
  being of a different kind.  This discrimination acts like a formal comment.
wenzelm@12618
   758
  
wenzelm@12618
   759
\item [$\HAVE{a}{\vec\phi}$] claims a local goal, eventually resulting in a
wenzelm@12618
   760
  fact within the current logical context.  This operation is completely
wenzelm@12618
   761
  independent of any pending sub-goals of an enclosing goal statements, so
wenzelm@12618
   762
  $\HAVENAME$ may be freely used for experimental exploration of potential
wenzelm@12618
   763
  results within a proof body.
wenzelm@12618
   764
  
wenzelm@12618
   765
\item [$\SHOW{a}{\vec\phi}$] is like $\HAVE{a}{\vec\phi}$ plus a second stage
wenzelm@12618
   766
  to refine some pending sub-goal for each one of the finished result, after
wenzelm@12618
   767
  having been exported into the corresponding context (at the head of the
wenzelm@12618
   768
  sub-proof that the $\SHOWNAME$ command belongs to).
wenzelm@12618
   769
  
wenzelm@12618
   770
  To accommodate interactive debugging, resulting rules are printed before
wenzelm@12618
   771
  being applied internally.  Even more, interactive execution of $\SHOWNAME$
wenzelm@12618
   772
  predicts potential failure after finishing its proof, and displays the
wenzelm@12618
   773
  resulting error message as a warning beforehand, adding this header:
wenzelm@12618
   774
wenzelm@12618
   775
  \begin{ttbox}
wenzelm@12618
   776
  Problem! Local statement will fail to solve any pending goal
wenzelm@12618
   777
  \end{ttbox}
wenzelm@12618
   778
wenzelm@7895
   779
\item [$\HENCENAME$] abbreviates $\THEN~\HAVENAME$, i.e.\ claims a local goal
wenzelm@7895
   780
  to be proven by forward chaining the current facts.  Note that $\HENCENAME$
wenzelm@7895
   781
  is also equivalent to $\FROM{this}~\HAVENAME$.
wenzelm@7895
   782
\item [$\THUSNAME$] abbreviates $\THEN~\SHOWNAME$.  Note that $\THUSNAME$ is
wenzelm@7895
   783
  also equivalent to $\FROM{this}~\SHOWNAME$.
wenzelm@7167
   784
\end{descr}
wenzelm@7167
   785
wenzelm@10550
   786
Any goal statement causes some term abbreviations (such as $\Var{thesis}$,
wenzelm@10550
   787
$\dots$) to be bound automatically, see also \S\ref{sec:term-abbrev}.
wenzelm@11549
   788
Furthermore, the local context of a (non-atomic) goal is provided via the
wenzelm@12618
   789
$rule_context$\indexisarcase{rule-context} case, see also
wenzelm@12618
   790
\S\ref{sec:rule-cases}.
wenzelm@10550
   791
wenzelm@10550
   792
\medskip
wenzelm@10550
   793
wenzelm@10550
   794
\begin{warn}
wenzelm@10550
   795
  Isabelle/Isar suffers theory-level goal statements to contain \emph{unbound
wenzelm@10550
   796
    schematic variables}, although this does not conform to the aim of
wenzelm@10550
   797
  human-readable proof documents!  The main problem with schematic goals is
wenzelm@10550
   798
  that the actual outcome is usually hard to predict, depending on the
wenzelm@10550
   799
  behavior of the actual proof methods applied during the reasoning.  Note
wenzelm@10550
   800
  that most semi-automated methods heavily depend on several kinds of implicit
wenzelm@10550
   801
  rule declarations within the current theory context.  As this would also
wenzelm@10550
   802
  result in non-compositional checking of sub-proofs, \emph{local goals} are
wenzelm@12618
   803
  not allowed to be schematic at all.  Nevertheless, schematic goals do have
wenzelm@12618
   804
  their use in Prolog-style interactive synthesis of proven results, usually
wenzelm@12618
   805
  by stepwise refinement via emulation of traditional Isabelle tactic scripts
wenzelm@12618
   806
  (see also \S\ref{sec:tactic-commands}).  In any case, users should know what
wenzelm@12618
   807
  they are doing.
wenzelm@10550
   808
\end{warn}
wenzelm@8991
   809
wenzelm@7167
   810
wenzelm@7167
   811
\subsection{Initial and terminal proof steps}\label{sec:proof-steps}
wenzelm@7167
   812
wenzelm@7175
   813
\indexisarcmd{proof}\indexisarcmd{qed}\indexisarcmd{by}
wenzelm@7175
   814
\indexisarcmd{.}\indexisarcmd{..}\indexisarcmd{sorry}
wenzelm@7175
   815
\begin{matharray}{rcl}
wenzelm@7175
   816
  \isarcmd{proof} & : & \isartrans{proof(prove)}{proof(state)} \\
wenzelm@7175
   817
  \isarcmd{qed} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\
wenzelm@7175
   818
  \isarcmd{by} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@7175
   819
  \isarcmd{.\,.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@7175
   820
  \isarcmd{.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@7175
   821
  \isarcmd{sorry} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@7175
   822
\end{matharray}
wenzelm@7175
   823
wenzelm@8547
   824
Arbitrary goal refinement via tactics is considered harmful.  Properly, the
wenzelm@7335
   825
Isar framework admits proof methods to be invoked in two places only.
wenzelm@7167
   826
\begin{enumerate}
wenzelm@7175
   827
\item An \emph{initial} refinement step $\PROOF{m@1}$ reduces a newly stated
wenzelm@7335
   828
  goal to a number of sub-goals that are to be solved later.  Facts are passed
wenzelm@7895
   829
  to $m@1$ for forward chaining, if so indicated by $proof(chain)$ mode.
wenzelm@7167
   830
  
wenzelm@7987
   831
\item A \emph{terminal} conclusion step $\QED{m@2}$ is intended to solve
wenzelm@7987
   832
  remaining goals.  No facts are passed to $m@2$.
wenzelm@7167
   833
\end{enumerate}
wenzelm@7167
   834
wenzelm@8547
   835
The only other proper way to affect pending goals is by $\SHOWNAME$, which
wenzelm@8547
   836
involves an explicit statement of what is to be solved.
wenzelm@7167
   837
wenzelm@7175
   838
\medskip
wenzelm@7175
   839
wenzelm@7167
   840
Also note that initial proof methods should either solve the goal completely,
wenzelm@7895
   841
or constitute some well-understood reduction to new sub-goals.  Arbitrary
wenzelm@7895
   842
automatic proof tools that are prone leave a large number of badly structured
wenzelm@7895
   843
sub-goals are no help in continuing the proof document in any intelligible
wenzelm@7987
   844
way.
wenzelm@7167
   845
wenzelm@7175
   846
\medskip
wenzelm@7175
   847
wenzelm@8547
   848
Unless given explicitly by the user, the default initial method is ``$rule$'',
wenzelm@8547
   849
which applies a single standard elimination or introduction rule according to
wenzelm@8547
   850
the topmost symbol involved.  There is no separate default terminal method.
wenzelm@8547
   851
Any remaining goals are always solved by assumption in the very last step.
wenzelm@7167
   852
wenzelm@7167
   853
\begin{rail}
wenzelm@7167
   854
  'proof' interest? meth? comment?
wenzelm@7167
   855
  ;
wenzelm@7167
   856
  'qed' meth? comment?
wenzelm@7167
   857
  ;
wenzelm@7167
   858
  'by' meth meth? comment?
wenzelm@7167
   859
  ;
wenzelm@7167
   860
  ('.' | '..' | 'sorry') comment?
wenzelm@7167
   861
  ;
wenzelm@7167
   862
wenzelm@7167
   863
  meth: method interest?
wenzelm@7167
   864
  ;
wenzelm@7167
   865
\end{rail}
wenzelm@7167
   866
wenzelm@7167
   867
\begin{descr}
wenzelm@7335
   868
\item [$\PROOF{m@1}$] refines the goal by proof method $m@1$; facts for
wenzelm@7335
   869
  forward chaining are passed if so indicated by $proof(chain)$ mode.
wenzelm@7335
   870
\item [$\QED{m@2}$] refines any remaining goals by proof method $m@2$ and
wenzelm@7895
   871
  concludes the sub-proof by assumption.  If the goal had been $\SHOWNAME$ (or
wenzelm@7895
   872
  $\THUSNAME$), some pending sub-goal is solved as well by the rule resulting
wenzelm@7895
   873
  from the result \emph{exported} into the enclosing goal context.  Thus
wenzelm@7895
   874
  $\QEDNAME$ may fail for two reasons: either $m@2$ fails, or the resulting
wenzelm@7895
   875
  rule does not fit to any pending goal\footnote{This includes any additional
wenzelm@7895
   876
    ``strong'' assumptions as introduced by $\ASSUMENAME$.} of the enclosing
wenzelm@7895
   877
  context.  Debugging such a situation might involve temporarily changing
wenzelm@7895
   878
  $\SHOWNAME$ into $\HAVENAME$, or weakening the local context by replacing
wenzelm@7895
   879
  some occurrences of $\ASSUMENAME$ by $\PRESUMENAME$.
wenzelm@7895
   880
\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}\index{proof!terminal}; it
wenzelm@7987
   881
  abbreviates $\PROOF{m@1}~\QED{m@2}$, with backtracking across both methods,
wenzelm@7987
   882
  though.  Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done
wenzelm@7895
   883
  by expanding its definition; in many cases $\PROOF{m@1}$ is already
wenzelm@7175
   884
  sufficient to see what is going wrong.
wenzelm@7895
   885
\item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it
wenzelm@8515
   886
  abbreviates $\BY{rule}$.
wenzelm@7895
   887
\item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it
wenzelm@8195
   888
  abbreviates $\BY{this}$.
wenzelm@12618
   889
\item [$\SORRY$] is a \emph{fake proof}\index{proof!fake} pretending to solve
wenzelm@12618
   890
  the pending claim without further ado.  This only works in interactive
wenzelm@12618
   891
  development, or if the \texttt{quick_and_dirty} flag is enabled.  Certainly,
wenzelm@12618
   892
  any facts emerging from fake proofs are not the real thing.  Internally,
wenzelm@12618
   893
  each theorem container is tainted by an oracle invocation, which is
wenzelm@12618
   894
  indicated as ``$[!]$'' in the printed result.
wenzelm@12618
   895
  
wenzelm@12618
   896
  The most important application of $\SORRY$ is to support experimentation and
wenzelm@12618
   897
  top-down proof development in a simple manner.
wenzelm@8515
   898
\end{descr}
wenzelm@8515
   899
wenzelm@8515
   900
wenzelm@8515
   901
\subsection{Fundamental methods and attributes}\label{sec:pure-meth-att}
wenzelm@8515
   902
wenzelm@8547
   903
The following proof methods and attributes refer to basic logical operations
wenzelm@8547
   904
of Isar.  Further methods and attributes are provided by several generic and
wenzelm@8547
   905
object-logic specific tools and packages (see chapters \ref{ch:gen-tools} and
wenzelm@8547
   906
\ref{ch:hol-tools}).
wenzelm@8515
   907
wenzelm@8515
   908
\indexisarmeth{assumption}\indexisarmeth{this}\indexisarmeth{rule}\indexisarmeth{$-$}
wenzelm@9936
   909
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest}\indexisaratt{rule}
wenzelm@8515
   910
\indexisaratt{OF}\indexisaratt{of}
wenzelm@8515
   911
\begin{matharray}{rcl}
wenzelm@8515
   912
  assumption & : & \isarmeth \\
wenzelm@8515
   913
  this & : & \isarmeth \\
wenzelm@8515
   914
  rule & : & \isarmeth \\
wenzelm@8515
   915
  - & : & \isarmeth \\
wenzelm@8515
   916
  OF & : & \isaratt \\
wenzelm@8515
   917
  of & : & \isaratt \\
wenzelm@8515
   918
  intro & : & \isaratt \\
wenzelm@8515
   919
  elim & : & \isaratt \\
wenzelm@8515
   920
  dest & : & \isaratt \\
wenzelm@9936
   921
  rule & : & \isaratt \\
wenzelm@8515
   922
\end{matharray}
wenzelm@8515
   923
wenzelm@8515
   924
\begin{rail}
wenzelm@8547
   925
  'rule' thmrefs?
wenzelm@8515
   926
  ;
wenzelm@8515
   927
  'OF' thmrefs
wenzelm@8515
   928
  ;
wenzelm@8693
   929
  'of' insts ('concl' ':' insts)?
wenzelm@8515
   930
  ;
wenzelm@9936
   931
  'rule' 'del'
wenzelm@9936
   932
  ;
wenzelm@8515
   933
\end{rail}
wenzelm@8515
   934
wenzelm@8515
   935
\begin{descr}
wenzelm@8515
   936
\item [$assumption$] solves some goal by a single assumption step.  Any facts
wenzelm@8515
   937
  given (${} \le 1$) are guaranteed to participate in the refinement.  Recall
wenzelm@8515
   938
  that $\QEDNAME$ (see \S\ref{sec:proof-steps}) already concludes any
wenzelm@8515
   939
  remaining sub-goals by assumption.
wenzelm@8515
   940
\item [$this$] applies all of the current facts directly as rules.  Recall
wenzelm@8515
   941
  that ``$\DOT$'' (dot) abbreviates $\BY{this}$.
wenzelm@8547
   942
\item [$rule~\vec a$] applies some rule given as argument in backward manner;
wenzelm@8515
   943
  facts are used to reduce the rule before applying it to the goal.  Thus
wenzelm@8515
   944
  $rule$ without facts is plain \emph{introduction}, while with facts it
wenzelm@8515
   945
  becomes \emph{elimination}.
wenzelm@8515
   946
  
wenzelm@8547
   947
  When no arguments are given, the $rule$ method tries to pick appropriate
wenzelm@8547
   948
  rules automatically, as declared in the current context using the $intro$,
wenzelm@8547
   949
  $elim$, $dest$ attributes (see below).  This is the default behavior of
wenzelm@8547
   950
  $\PROOFNAME$ and ``$\DDOT$'' (double-dot) steps (see
wenzelm@8515
   951
  \S\ref{sec:proof-steps}).
wenzelm@8515
   952
\item [``$-$''] does nothing but insert the forward chaining facts as premises
wenzelm@8515
   953
  into the goal.  Note that command $\PROOFNAME$ without any method actually
wenzelm@8515
   954
  performs a single reduction step using the $rule$ method; thus a plain
wenzelm@8515
   955
  \emph{do-nothing} proof step would be $\PROOF{-}$ rather than $\PROOFNAME$
wenzelm@8515
   956
  alone.
wenzelm@8547
   957
\item [$OF~\vec a$] applies some theorem to given rules $\vec a$ (in
wenzelm@8547
   958
  parallel).  This corresponds to the \texttt{MRS} operator in ML
wenzelm@8547
   959
  \cite[\S5]{isabelle-ref}, but note the reversed order.  Positions may be
wenzelm@8547
   960
  skipped by including ``$\_$'' (underscore) as argument.
wenzelm@8547
   961
\item [$of~\vec t$] performs positional instantiation.  The terms $\vec t$ are
wenzelm@8515
   962
  substituted for any schematic variables occurring in a theorem from left to
wenzelm@8515
   963
  right; ``\texttt{_}'' (underscore) indicates to skip a position.  Arguments
wenzelm@8515
   964
  following a ``$concl\colon$'' specification refer to positions of the
wenzelm@8515
   965
  conclusion of a rule.
wenzelm@8515
   966
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and
wenzelm@8515
   967
  destruct rules, respectively.  Note that the classical reasoner (see
wenzelm@8515
   968
  \S\ref{sec:classical-basic}) introduces different versions of these
wenzelm@8515
   969
  attributes, and the $rule$ method, too.  In object-logics with classical
wenzelm@8515
   970
  reasoning enabled, the latter version should be used all the time to avoid
wenzelm@8515
   971
  confusion!
wenzelm@9936
   972
\item [$rule~del$] undeclares introduction, elimination, or destruct rules.
wenzelm@7315
   973
\end{descr}
wenzelm@7315
   974
wenzelm@7315
   975
wenzelm@7315
   976
\subsection{Term abbreviations}\label{sec:term-abbrev}
wenzelm@7315
   977
wenzelm@7315
   978
\indexisarcmd{let}
wenzelm@7315
   979
\begin{matharray}{rcl}
wenzelm@7315
   980
  \isarcmd{let} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7315
   981
  \isarkeyword{is} & : & syntax \\
wenzelm@7315
   982
\end{matharray}
wenzelm@7315
   983
wenzelm@7315
   984
Abbreviations may be either bound by explicit $\LET{p \equiv t}$ statements,
wenzelm@7987
   985
or by annotating assumptions or goal statements with a list of patterns
wenzelm@7987
   986
$\ISS{p@1\;\dots}{p@n}$.  In both cases, higher-order matching is invoked to
wenzelm@7987
   987
bind extra-logical term variables, which may be either named schematic
wenzelm@7987
   988
variables of the form $\Var{x}$, or nameless dummies ``\texttt{_}''
wenzelm@7987
   989
(underscore).\indexisarvar{_@\texttt{_}} Note that in the $\LETNAME$ form the
wenzelm@7987
   990
patterns occur on the left-hand side, while the $\ISNAME$ patterns are in
wenzelm@7987
   991
postfix position.
wenzelm@7315
   992
wenzelm@8620
   993
Polymorphism of term bindings is handled in Hindley-Milner style, as in ML.
wenzelm@8620
   994
Type variables referring to local assumptions or open goal statements are
wenzelm@8620
   995
\emph{fixed}, while those of finished results or bound by $\LETNAME$ may occur
wenzelm@8620
   996
in \emph{arbitrary} instances later.  Even though actual polymorphism should
wenzelm@8620
   997
be rarely used in practice, this mechanism is essential to achieve proper
wenzelm@8620
   998
incremental type-inference, as the user proceeds to build up the Isar proof
wenzelm@8620
   999
text.
wenzelm@8620
  1000
wenzelm@8620
  1001
\medskip
wenzelm@8620
  1002
wenzelm@7319
  1003
Term abbreviations are quite different from actual local definitions as
wenzelm@7319
  1004
introduced via $\DEFNAME$ (see \S\ref{sec:proof-context}).  The latter are
wenzelm@7315
  1005
visible within the logic as actual equations, while abbreviations disappear
wenzelm@8620
  1006
during the input process just after type checking.  Also note that $\DEFNAME$
wenzelm@8620
  1007
does not support polymorphism.
wenzelm@7315
  1008
wenzelm@7315
  1009
\begin{rail}
wenzelm@8664
  1010
  'let' ((term + 'and') '=' term comment? + 'and')
wenzelm@7315
  1011
  ;  
wenzelm@7315
  1012
\end{rail}
wenzelm@7315
  1013
wenzelm@7315
  1014
The syntax of $\ISNAME$ patterns follows \railnonterm{termpat} or
wenzelm@12618
  1015
\railnonterm{proppat} (see \S\ref{sec:term-decls}).
wenzelm@7315
  1016
wenzelm@7315
  1017
\begin{descr}
wenzelm@7315
  1018
\item [$\LET{\vec p = \vec t}$] binds any text variables in patters $\vec p$
wenzelm@7315
  1019
  by simultaneous higher-order matching against terms $\vec t$.
wenzelm@7315
  1020
\item [$\IS{\vec p}$] resembles $\LETNAME$, but matches $\vec p$ against the
wenzelm@7315
  1021
  preceding statement.  Also note that $\ISNAME$ is not a separate command,
wenzelm@7315
  1022
  but part of others (such as $\ASSUMENAME$, $\HAVENAME$ etc.).
wenzelm@7315
  1023
\end{descr}
wenzelm@7315
  1024
wenzelm@10160
  1025
Some \emph{automatic} term abbreviations\index{term abbreviations} for goals
wenzelm@7988
  1026
and facts are available as well.  For any open goal,
wenzelm@10160
  1027
$\Var{thesis}$\indexisarvar{thesis} refers to its object-level statement,
wenzelm@10160
  1028
abstracted over any meta-level parameters (if present).  Likewise,
wenzelm@10160
  1029
$\Var{this}$\indexisarvar{this} is bound for fact statements resulting from
wenzelm@10160
  1030
assumptions or finished goals.  In case $\Var{this}$ refers to an object-logic
wenzelm@10160
  1031
statement that is an application $f(t)$, then $t$ is bound to the special text
wenzelm@10160
  1032
variable ``$\dots$''\indexisarvar{\dots} (three dots).  The canonical
wenzelm@10160
  1033
application of the latter are calculational proofs (see
wenzelm@10160
  1034
\S\ref{sec:calculation}).
wenzelm@10160
  1035
wenzelm@7315
  1036
wenzelm@7134
  1037
\subsection{Block structure}
wenzelm@7134
  1038
wenzelm@8896
  1039
\indexisarcmd{next}\indexisarcmd{\{}\indexisarcmd{\}}
wenzelm@7397
  1040
\begin{matharray}{rcl}
wenzelm@8448
  1041
  \NEXT & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7974
  1042
  \BG & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7974
  1043
  \EN & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@7397
  1044
\end{matharray}
wenzelm@7397
  1045
wenzelm@9030
  1046
\railalias{lbrace}{\ttlbrace}
wenzelm@9030
  1047
\railterm{lbrace}
wenzelm@9030
  1048
wenzelm@9030
  1049
\railalias{rbrace}{\ttrbrace}
wenzelm@9030
  1050
\railterm{rbrace}
wenzelm@9030
  1051
wenzelm@9030
  1052
\begin{rail}
wenzelm@9030
  1053
  'next' comment?
wenzelm@9030
  1054
  ;
wenzelm@9030
  1055
  lbrace comment?
wenzelm@9030
  1056
  ;
wenzelm@9030
  1057
  rbrace comment?
wenzelm@9030
  1058
  ;
wenzelm@9030
  1059
\end{rail}
wenzelm@9030
  1060
wenzelm@7167
  1061
While Isar is inherently block-structured, opening and closing blocks is
wenzelm@7167
  1062
mostly handled rather casually, with little explicit user-intervention.  Any
wenzelm@7167
  1063
local goal statement automatically opens \emph{two} blocks, which are closed
wenzelm@7167
  1064
again when concluding the sub-proof (by $\QEDNAME$ etc.).  Sections of
wenzelm@8448
  1065
different context within a sub-proof may be switched via $\NEXT$, which is
wenzelm@8448
  1066
just a single block-close followed by block-open again.  Thus the effect of
wenzelm@8448
  1067
$\NEXT$ to reset the local proof context. There is no goal focus involved
wenzelm@8448
  1068
here!
wenzelm@7167
  1069
wenzelm@7175
  1070
For slightly more advanced applications, there are explicit block parentheses
wenzelm@7895
  1071
as well.  These typically achieve a stronger forward style of reasoning.
wenzelm@7167
  1072
wenzelm@7167
  1073
\begin{descr}
wenzelm@8448
  1074
\item [$\NEXT$] switches to a fresh block within a sub-proof, resetting the
wenzelm@8448
  1075
  local context to the initial one.
wenzelm@8896
  1076
\item [$\BG$ and $\EN$] explicitly open and close blocks.  Any current facts
wenzelm@8896
  1077
  pass through ``$\BG$'' unchanged, while ``$\EN$'' causes any result to be
wenzelm@7895
  1078
  \emph{exported} into the enclosing context.  Thus fixed variables are
wenzelm@7895
  1079
  generalized, assumptions discharged, and local definitions unfolded (cf.\ 
wenzelm@7895
  1080
  \S\ref{sec:proof-context}).  There is no difference of $\ASSUMENAME$ and
wenzelm@7895
  1081
  $\PRESUMENAME$ in this mode of forward reasoning --- in contrast to plain
wenzelm@7895
  1082
  backward reasoning with the result exported at $\SHOWNAME$ time.
wenzelm@7167
  1083
\end{descr}
wenzelm@7134
  1084
wenzelm@7134
  1085
wenzelm@9605
  1086
\subsection{Emulating tactic scripts}\label{sec:tactic-commands}
wenzelm@8515
  1087
wenzelm@9605
  1088
The Isar provides separate commands to accommodate tactic-style proof scripts
wenzelm@9605
  1089
within the same system.  While being outside the orthodox Isar proof language,
wenzelm@9605
  1090
these might come in handy for interactive exploration and debugging, or even
wenzelm@9605
  1091
actual tactical proof within new-style theories (to benefit from document
wenzelm@9605
  1092
preparation, for example).  See also \S\ref{sec:tactics} for actual tactics,
wenzelm@9605
  1093
that have been encapsulated as proof methods.  Proper proof methods may be
wenzelm@9605
  1094
used in scripts, too.
wenzelm@8515
  1095
wenzelm@9605
  1096
\indexisarcmd{apply}\indexisarcmd{apply-end}\indexisarcmd{done}
wenzelm@8515
  1097
\indexisarcmd{defer}\indexisarcmd{prefer}\indexisarcmd{back}
wenzelm@9605
  1098
\indexisarcmd{declare}
wenzelm@8515
  1099
\begin{matharray}{rcl}
wenzelm@8533
  1100
  \isarcmd{apply}^* & : & \isartrans{proof(prove)}{proof(prove)} \\
wenzelm@9605
  1101
  \isarcmd{apply_end}^* & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@8946
  1102
  \isarcmd{done}^* & : & \isartrans{proof(prove)}{proof(state)} \\
wenzelm@8533
  1103
  \isarcmd{defer}^* & : & \isartrans{proof}{proof} \\
wenzelm@8533
  1104
  \isarcmd{prefer}^* & : & \isartrans{proof}{proof} \\
wenzelm@8533
  1105
  \isarcmd{back}^* & : & \isartrans{proof}{proof} \\
wenzelm@9605
  1106
  \isarcmd{declare}^* & : & \isartrans{theory}{theory} \\
wenzelm@8515
  1107
\end{matharray}
wenzelm@8515
  1108
wenzelm@8515
  1109
\railalias{applyend}{apply\_end}
wenzelm@8515
  1110
\railterm{applyend}
wenzelm@8515
  1111
wenzelm@8515
  1112
\begin{rail}
wenzelm@9605
  1113
  ( 'apply' | applyend ) method comment?
wenzelm@8515
  1114
  ;
wenzelm@8946
  1115
  'done' comment?
wenzelm@8946
  1116
  ;
wenzelm@8682
  1117
  'defer' nat? comment?
wenzelm@8515
  1118
  ;
wenzelm@8682
  1119
  'prefer' nat comment?
wenzelm@8515
  1120
  ;
wenzelm@9273
  1121
  'back' comment?
wenzelm@9273
  1122
  ;
wenzelm@9605
  1123
  'declare' thmrefs comment?
wenzelm@9605
  1124
  ;
wenzelm@8515
  1125
\end{rail}
wenzelm@8515
  1126
wenzelm@8515
  1127
\begin{descr}
wenzelm@10223
  1128
\item [$\APPLY{m}$] applies proof method $m$ in initial position, but unlike
wenzelm@10223
  1129
  $\PROOFNAME$ it retains ``$proof(prove)$'' mode.  Thus consecutive method
wenzelm@10223
  1130
  applications may be given just as in tactic scripts.
wenzelm@8515
  1131
  
wenzelm@8881
  1132
  Facts are passed to $m$ as indicated by the goal's forward-chain mode, and
wenzelm@10223
  1133
  are \emph{consumed} afterwards.  Thus any further $\APPLYNAME$ command would
wenzelm@10223
  1134
  always work in a purely backward manner.
wenzelm@8946
  1135
  
wenzelm@8515
  1136
\item [$\isarkeyword{apply_end}~(m)$] applies proof method $m$ as if in
wenzelm@8515
  1137
  terminal position.  Basically, this simulates a multi-step tactic script for
wenzelm@8515
  1138
  $\QEDNAME$, but may be given anywhere within the proof body.
wenzelm@8515
  1139
  
wenzelm@8515
  1140
  No facts are passed to $m$.  Furthermore, the static context is that of the
wenzelm@8515
  1141
  enclosing goal (as for actual $\QEDNAME$).  Thus the proof method may not
wenzelm@8515
  1142
  refer to any assumptions introduced in the current body, for example.
wenzelm@9605
  1143
wenzelm@9605
  1144
\item [$\isarkeyword{done}$] completes a proof script, provided that the
wenzelm@9605
  1145
  current goal state is already solved completely.  Note that actual
wenzelm@9605
  1146
  structured proof commands (e.g.\ ``$\DOT$'' or $\SORRY$) may be used to
wenzelm@9605
  1147
  conclude proof scripts as well.
wenzelm@9605
  1148
wenzelm@8515
  1149
\item [$\isarkeyword{defer}~n$ and $\isarkeyword{prefer}~n$] shuffle the list
wenzelm@8515
  1150
  of pending goals: $defer$ puts off goal $n$ to the end of the list ($n = 1$
wenzelm@8515
  1151
  by default), while $prefer$ brings goal $n$ to the top.
wenzelm@9605
  1152
wenzelm@8515
  1153
\item [$\isarkeyword{back}$] does back-tracking over the result sequence of
wenzelm@8515
  1154
  the latest proof command.\footnote{Unlike the ML function \texttt{back}
wenzelm@8515
  1155
    \cite{isabelle-ref}, the Isar command does not search upwards for further
wenzelm@8515
  1156
    branch points.} Basically, any proof command may return multiple results.
wenzelm@9605
  1157
  
wenzelm@9605
  1158
\item [$\isarkeyword{declare}~thms$] declares theorems to the current theory
wenzelm@9605
  1159
  context.  No theorem binding is involved here, unlike
wenzelm@9605
  1160
  $\isarkeyword{theorems}$ or $\isarkeyword{lemmas}$ (cf.\ 
wenzelm@9605
  1161
  \S\ref{sec:axms-thms}).  So $\isarkeyword{declare}$ only has the effect of
wenzelm@9605
  1162
  applying attributes as included in the theorem specification.
wenzelm@9006
  1163
\end{descr}
wenzelm@9006
  1164
wenzelm@9006
  1165
Any proper Isar proof method may be used with tactic script commands such as
wenzelm@10223
  1166
$\APPLYNAME$.  A few additional emulations of actual tactics are provided as
wenzelm@10223
  1167
well; these would be never used in actual structured proofs, of course.
wenzelm@9006
  1168
wenzelm@8515
  1169
wenzelm@8515
  1170
\subsection{Meta-linguistic features}
wenzelm@8515
  1171
wenzelm@8515
  1172
\indexisarcmd{oops}
wenzelm@8515
  1173
\begin{matharray}{rcl}
wenzelm@8515
  1174
  \isarcmd{oops} & : & \isartrans{proof}{theory} \\
wenzelm@8515
  1175
\end{matharray}
wenzelm@8515
  1176
wenzelm@8515
  1177
The $\OOPS$ command discontinues the current proof attempt, while considering
wenzelm@8515
  1178
the partial proof text as properly processed.  This is conceptually quite
wenzelm@8515
  1179
different from ``faking'' actual proofs via $\SORRY$ (see
wenzelm@8515
  1180
\S\ref{sec:proof-steps}): $\OOPS$ does not observe the proof structure at all,
wenzelm@8515
  1181
but goes back right to the theory level.  Furthermore, $\OOPS$ does not
wenzelm@8515
  1182
produce any result theorem --- there is no claim to be able to complete the
wenzelm@8515
  1183
proof anyhow.
wenzelm@8515
  1184
wenzelm@8515
  1185
A typical application of $\OOPS$ is to explain Isar proofs \emph{within} the
wenzelm@8515
  1186
system itself, in conjunction with the document preparation tools of Isabelle
wenzelm@8515
  1187
described in \cite{isabelle-sys}.  Thus partial or even wrong proof attempts
wenzelm@8515
  1188
can be discussed in a logically sound manner.  Note that the Isabelle {\LaTeX}
wenzelm@8515
  1189
macros can be easily adapted to print something like ``$\dots$'' instead of an
wenzelm@8515
  1190
``$\OOPS$'' keyword.
wenzelm@8515
  1191
wenzelm@12618
  1192
\medskip The $\OOPS$ command is undo-able, unlike $\isarkeyword{kill}$ (see
wenzelm@8547
  1193
\S\ref{sec:history}).  The effect is to get back to the theory \emph{before}
wenzelm@8547
  1194
the opening of the proof.
wenzelm@8515
  1195
wenzelm@8515
  1196
wenzelm@7134
  1197
\section{Other commands}
wenzelm@7134
  1198
wenzelm@9605
  1199
\subsection{Diagnostics}
wenzelm@7134
  1200
wenzelm@10858
  1201
\indexisarcmd{pr}\indexisarcmd{thm}\indexisarcmd{term}
wenzelm@10858
  1202
\indexisarcmd{prop}\indexisarcmd{typ}
wenzelm@7134
  1203
\begin{matharray}{rcl}
wenzelm@8515
  1204
  \isarcmd{pr}^* & : & \isarkeep{\cdot} \\
wenzelm@8515
  1205
  \isarcmd{thm}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@8515
  1206
  \isarcmd{term}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@8515
  1207
  \isarcmd{prop}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@8515
  1208
  \isarcmd{typ}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@7134
  1209
\end{matharray}
wenzelm@7134
  1210
wenzelm@9605
  1211
These diagnostic commands assist interactive development.  Note that $undo$
wenzelm@9605
  1212
does not apply here, the theory or proof configuration is not changed.
wenzelm@7335
  1213
wenzelm@7134
  1214
\begin{rail}
wenzelm@9727
  1215
  'pr' modes? nat? (',' nat)?
wenzelm@7134
  1216
  ;
wenzelm@10584
  1217
  'thm' modes? thmrefs comment?
wenzelm@8485
  1218
  ;
wenzelm@10584
  1219
  'term' modes? term comment?
wenzelm@7134
  1220
  ;
wenzelm@10584
  1221
  'prop' modes? prop comment?
wenzelm@7134
  1222
  ;
wenzelm@10584
  1223
  'typ' modes? type comment?
wenzelm@8485
  1224
  ;
wenzelm@8485
  1225
wenzelm@8485
  1226
  modes: '(' (name + ) ')'
wenzelm@7134
  1227
  ;
wenzelm@7134
  1228
\end{rail}
wenzelm@7134
  1229
wenzelm@7167
  1230
\begin{descr}
wenzelm@9727
  1231
\item [$\isarkeyword{pr}~goals, prems$] prints the current proof state (if
wenzelm@9727
  1232
  present), including the proof context, current facts and goals.  The
wenzelm@9727
  1233
  optional limit arguments affect the number of goals and premises to be
wenzelm@9727
  1234
  displayed, which is initially 10 for both.  Omitting limit values leaves the
wenzelm@9727
  1235
  current setting unchanged.
wenzelm@8547
  1236
\item [$\isarkeyword{thm}~\vec a$] retrieves theorems from the current theory
wenzelm@8547
  1237
  or proof context.  Note that any attributes included in the theorem
wenzelm@7974
  1238
  specifications are applied to a temporary context derived from the current
wenzelm@8547
  1239
  theory or proof; the result is discarded, i.e.\ attributes involved in $\vec
wenzelm@8547
  1240
  a$ do not have any permanent effect.
wenzelm@9727
  1241
\item [$\isarkeyword{term}~t$ and $\isarkeyword{prop}~\phi$] read, type-check
wenzelm@9727
  1242
  and print terms or propositions according to the current theory or proof
wenzelm@7895
  1243
  context; the inferred type of $t$ is output as well.  Note that these
wenzelm@7895
  1244
  commands are also useful in inspecting the current environment of term
wenzelm@7895
  1245
  abbreviations.
wenzelm@7974
  1246
\item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic
wenzelm@7974
  1247
  according to the current theory or proof context.
wenzelm@9605
  1248
\end{descr}
wenzelm@9605
  1249
wenzelm@9605
  1250
All of the diagnostic commands above admit a list of $modes$ to be specified,
wenzelm@9605
  1251
which is appended to the current print mode (see also \cite{isabelle-ref}).
wenzelm@9605
  1252
Thus the output behavior may be modified according particular print mode
wenzelm@9605
  1253
features.  For example, $\isarkeyword{pr}~(latex~xsymbols~symbols)$ would
wenzelm@9605
  1254
print the current proof state with mathematical symbols and special characters
wenzelm@9605
  1255
represented in {\LaTeX} source, according to the Isabelle style
wenzelm@9605
  1256
\cite{isabelle-sys}.
wenzelm@9605
  1257
wenzelm@9605
  1258
Note that antiquotations (cf.\ \S\ref{sec:antiq}) provide a more systematic
wenzelm@9605
  1259
way to include formal items into the printed text document.
wenzelm@9605
  1260
wenzelm@9605
  1261
wenzelm@9605
  1262
\subsection{Inspecting the context}
wenzelm@9605
  1263
wenzelm@9605
  1264
\indexisarcmd{print-facts}\indexisarcmd{print-binds}
wenzelm@9605
  1265
\indexisarcmd{print-commands}\indexisarcmd{print-syntax}
wenzelm@9605
  1266
\indexisarcmd{print-methods}\indexisarcmd{print-attributes}
wenzelm@10858
  1267
\indexisarcmd{thms-containing}\indexisarcmd{thm-deps}
wenzelm@10858
  1268
\indexisarcmd{print-theorems}
wenzelm@9605
  1269
\begin{matharray}{rcl}
wenzelm@9605
  1270
  \isarcmd{print_commands}^* & : & \isarkeep{\cdot} \\
wenzelm@9605
  1271
  \isarcmd{print_syntax}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@9605
  1272
  \isarcmd{print_methods}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@9605
  1273
  \isarcmd{print_attributes}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@10858
  1274
  \isarcmd{print_theorems}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@10858
  1275
  \isarcmd{thms_containing}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@10858
  1276
  \isarcmd{thms_deps}^* & : & \isarkeep{theory~|~proof} \\
wenzelm@9605
  1277
  \isarcmd{print_facts}^* & : & \isarkeep{proof} \\
wenzelm@9605
  1278
  \isarcmd{print_binds}^* & : & \isarkeep{proof} \\
wenzelm@9605
  1279
\end{matharray}
wenzelm@9605
  1280
wenzelm@10858
  1281
\railalias{thmscontaining}{thms\_containing}
wenzelm@10858
  1282
\railterm{thmscontaining}
wenzelm@10858
  1283
wenzelm@10858
  1284
\railalias{thmdeps}{thm\_deps}
wenzelm@10858
  1285
\railterm{thmdeps}
wenzelm@10858
  1286
wenzelm@10858
  1287
\begin{rail}
wenzelm@11017
  1288
  thmscontaining (term * )
wenzelm@10858
  1289
  ;
wenzelm@10858
  1290
  thmdeps thmrefs
wenzelm@10858
  1291
  ;
wenzelm@10858
  1292
\end{rail}
wenzelm@10858
  1293
wenzelm@10858
  1294
These commands print certain parts of the theory and proof context.  Note that
wenzelm@10858
  1295
there are some further ones available, such as for the set of rules declared
wenzelm@10858
  1296
for simplifications.
wenzelm@9605
  1297
wenzelm@9605
  1298
\begin{descr}
wenzelm@9605
  1299
\item [$\isarkeyword{print_commands}$] prints Isabelle's outer theory syntax,
wenzelm@9605
  1300
  including keywords and command.
wenzelm@9605
  1301
\item [$\isarkeyword{print_syntax}$] prints the inner syntax of types and
wenzelm@9605
  1302
  terms, depending on the current context.  The output can be very verbose,
wenzelm@9605
  1303
  including grammar tables and syntax translation rules.  See \cite[\S7,
wenzelm@9605
  1304
  \S8]{isabelle-ref} for further information on Isabelle's inner syntax.
wenzelm@10858
  1305
\item [$\isarkeyword{print_methods}$] prints all proof methods available in
wenzelm@10858
  1306
  the current theory context.
wenzelm@10858
  1307
\item [$\isarkeyword{print_attributes}$] prints all attributes available in
wenzelm@10858
  1308
  the current theory context.
wenzelm@10858
  1309
\item [$\isarkeyword{print_theorems}$] prints theorems available in the
wenzelm@10858
  1310
  current theory context.  In interactive mode this actually refers to the
wenzelm@10858
  1311
  theorems left by the last transaction; this allows to inspect the result of
wenzelm@10858
  1312
  advanced definitional packages, such as $\isarkeyword{datatype}$.
wenzelm@11017
  1313
\item [$\isarkeyword{thms_containing}~\vec t$] retrieves theorems from the
wenzelm@11017
  1314
  theory context containing all of the constants occurring in the terms $\vec
wenzelm@11017
  1315
  t$.  Note that giving the empty list yields \emph{all} theorems of the
wenzelm@11017
  1316
  current theory.
wenzelm@12618
  1317
\item [$\isarkeyword{thm_deps}~\vec a$] visualizes dependencies of facts,
wenzelm@12618
  1318
  using Isabelle's graph browser tool (see also \cite{isabelle-sys}).
wenzelm@8379
  1319
\item [$\isarkeyword{print_facts}$] prints any named facts of the current
wenzelm@8379
  1320
  context, including assumptions and local results.
wenzelm@8379
  1321
\item [$\isarkeyword{print_binds}$] prints all term abbreviations present in
wenzelm@8379
  1322
  the context.
wenzelm@8485
  1323
\end{descr}
wenzelm@8485
  1324
wenzelm@8485
  1325
wenzelm@8485
  1326
\subsection{History commands}\label{sec:history}
wenzelm@8485
  1327
wenzelm@8485
  1328
\indexisarcmd{undo}\indexisarcmd{redo}\indexisarcmd{kill}
wenzelm@8485
  1329
\begin{matharray}{rcl}
wenzelm@8485
  1330
  \isarcmd{undo}^{{*}{*}} & : & \isarkeep{\cdot} \\
wenzelm@8485
  1331
  \isarcmd{redo}^{{*}{*}} & : & \isarkeep{\cdot} \\
wenzelm@8485
  1332
  \isarcmd{kill}^{{*}{*}} & : & \isarkeep{\cdot} \\
wenzelm@8485
  1333
\end{matharray}
wenzelm@8485
  1334
wenzelm@8485
  1335
The Isabelle/Isar top-level maintains a two-stage history, for theory and
wenzelm@8485
  1336
proof state transformation.  Basically, any command can be undone using
wenzelm@8485
  1337
$\isarkeyword{undo}$, excluding mere diagnostic elements.  Its effect may be
wenzelm@10858
  1338
revoked via $\isarkeyword{redo}$, unless the corresponding
wenzelm@8485
  1339
$\isarkeyword{undo}$ step has crossed the beginning of a proof or theory.  The
wenzelm@8485
  1340
$\isarkeyword{kill}$ command aborts the current history node altogether,
wenzelm@8485
  1341
discontinuing a proof or even the whole theory.  This operation is \emph{not}
wenzelm@12618
  1342
undo-able.
wenzelm@8485
  1343
wenzelm@8485
  1344
\begin{warn}
wenzelm@8547
  1345
  History commands should never be used with user interfaces such as
wenzelm@8547
  1346
  Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes care of
wenzelm@8547
  1347
  stepping forth and back itself.  Interfering by manual $\isarkeyword{undo}$,
wenzelm@8510
  1348
  $\isarkeyword{redo}$, or even $\isarkeyword{kill}$ commands would quickly
wenzelm@8510
  1349
  result in utter confusion.
wenzelm@8485
  1350
\end{warn}
wenzelm@8485
  1351
wenzelm@8379
  1352
wenzelm@7134
  1353
\subsection{System operations}
wenzelm@7134
  1354
wenzelm@7167
  1355
\indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{use-thy}\indexisarcmd{use-thy-only}
wenzelm@7167
  1356
\indexisarcmd{update-thy}\indexisarcmd{update-thy-only}
wenzelm@7134
  1357
\begin{matharray}{rcl}
wenzelm@8515
  1358
  \isarcmd{cd}^* & : & \isarkeep{\cdot} \\
wenzelm@8515
  1359
  \isarcmd{pwd}^* & : & \isarkeep{\cdot} \\
wenzelm@8515
  1360
  \isarcmd{use_thy}^* & : & \isarkeep{\cdot} \\
wenzelm@8515
  1361
  \isarcmd{use_thy_only}^* & : & \isarkeep{\cdot} \\
wenzelm@8515
  1362
  \isarcmd{update_thy}^* & : & \isarkeep{\cdot} \\
wenzelm@8515
  1363
  \isarcmd{update_thy_only}^* & : & \isarkeep{\cdot} \\
wenzelm@7134
  1364
\end{matharray}
wenzelm@7134
  1365
wenzelm@7167
  1366
\begin{descr}
wenzelm@7134
  1367
\item [$\isarkeyword{cd}~name$] changes the current directory of the Isabelle
wenzelm@7134
  1368
  process.
wenzelm@7134
  1369
\item [$\isarkeyword{pwd}~$] prints the current working directory.
wenzelm@7175
  1370
\item [$\isarkeyword{use_thy}$, $\isarkeyword{use_thy_only}$,
wenzelm@7987
  1371
  $\isarkeyword{update_thy}$, $\isarkeyword{update_thy_only}$] load some
wenzelm@7895
  1372
  theory given as $name$ argument.  These commands are basically the same as
wenzelm@7987
  1373
  the corresponding ML functions\footnote{The ML versions also change the
wenzelm@7987
  1374
    implicit theory context to that of the theory loaded.}  (see also
wenzelm@7987
  1375
  \cite[\S1,\S6]{isabelle-ref}).  Note that both the ML and Isar versions may
wenzelm@7987
  1376
  load new- and old-style theories alike.
wenzelm@7167
  1377
\end{descr}
wenzelm@7134
  1378
wenzelm@7987
  1379
These system commands are scarcely used when working with the Proof~General
wenzelm@7987
  1380
interface, since loading of theories is done fully transparently.
wenzelm@7134
  1381
wenzelm@8379
  1382
wenzelm@7046
  1383
%%% Local Variables: 
wenzelm@7046
  1384
%%% mode: latex
wenzelm@7046
  1385
%%% TeX-master: "isar-ref"
wenzelm@7046
  1386
%%% End: