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