doc-src/IsarRef/pure.tex
author wenzelm
Sat, 30 Oct 1999 20:13:16 +0200
changeset 7981 5120a2a15d06
parent 7974 34245feb6e82
child 7987 d9aef93c0e32
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
     1
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
     2
\chapter{Basic Isar Language Elements}\label{ch:pure-syntax}
7167
wenzelm
parents: 7141
diff changeset
     3
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     4
Subsequently, we introduce the main part of the basic Isar theory and proof
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
     5
commands as provided by Isabelle/Pure.  Chapter~\ref{ch:gen-tools} describes
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
     6
further Isar elements provided by generic tools and packages (such as the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
     7
Simplifier) that are either part of Pure Isabelle or pre-loaded by most object
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
     8
logics.  Chapter~\ref{ch:hol-tools} refers to actual object-logic specific
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
     9
elements of Isabelle/HOL.
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
7df66ce6508a updated;
wenzelm
parents: 7458
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
wenzelm
parents: 7974
diff changeset
    19
current context; other commands even emulate old-style tactical theorem
wenzelm
parents: 7974
diff changeset
    20
proving, which facilitates porting of legacy proof scripts.
7167
wenzelm
parents: 7141
diff changeset
    21
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    22
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    23
\section{Theory commands}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    24
7167
wenzelm
parents: 7141
diff changeset
    25
\subsection{Defining theories}\label{sec:begin-thy}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    26
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    27
\indexisarcmd{header}\indexisarcmd{theory}\indexisarcmd{end}\indexisarcmd{context}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    28
\begin{matharray}{rcl}
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    29
  \isarcmd{header} & : & \isarkeep{toplevel} \\
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    30
  \isarcmd{theory} & : & \isartrans{\cdot}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    31
  \isarcmd{context}^* & : & \isartrans{\cdot}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    32
  \isarcmd{end} & : & \isartrans{theory}{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    33
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    34
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    35
Isabelle/Isar ``new-style'' theories are either defined via theory files or
7981
wenzelm
parents: 7974
diff changeset
    36
interactively.  Both theory-level specifications and proofs are handled
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
    37
uniformly --- occasionally definitional mechanisms even require some explicit
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
    38
proof as well.  In contrast, ``old-style'' Isabelle theories support batch
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
    39
processing only, with the proof scripts collected in separate ML files.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    40
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    41
The first actual command of any theory has to be $\THEORY$, starting a new
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    42
theory based on the merge of existing ones.  Just preceding $\THEORY$, there
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    43
may be an optional $\isarkeyword{header}$ declaration, which is relevant to
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    44
document preparation only; it acts very much like a special pre-theory markup
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    45
command (cf.\ \S\ref{sec:markup-thy} and \S\ref{sec:markup-thy}).  The theory
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    46
context may be also changed by $\CONTEXT$ without creating a new theory.  In
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    47
both cases, $\END$ concludes the theory development; it has to be the very
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    48
last command in a theory file.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    49
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    50
\begin{rail}
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    51
  'header' text
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    52
  ;
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    53
  'theory' name '=' (name + '+') filespecs? ':'
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    54
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    55
  'context' name
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    56
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    57
  'end'
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    58
  ;;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    59
7167
wenzelm
parents: 7141
diff changeset
    60
  filespecs: 'files' ((name | parname) +);
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    61
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    62
7167
wenzelm
parents: 7141
diff changeset
    63
\begin{descr}
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    64
\item [$\isarkeyword{header}~text$] provides plain text markup just preceding
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    65
  the formal begin of a theory.  In actual document preparation the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    66
  corresponding {\LaTeX} macro \verb,\isamarkupheader, may be redefined to
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    67
  produce chapter or section headings.  See also \S\ref{sec:markup-thy} and
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    68
  \S\ref{sec:markup-prf} for further markup commands.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    69
  
7981
wenzelm
parents: 7974
diff changeset
    70
\item [$\THEORY~A = B@1 + \cdots + B@n\colon$] commences a new theory $A$
wenzelm
parents: 7974
diff changeset
    71
  based on existing ones $B@1 + \cdots + B@n$.  Isabelle's theory loader
wenzelm
parents: 7974
diff changeset
    72
  system ensures that any of the base theories are properly loaded (and fully
wenzelm
parents: 7974
diff changeset
    73
  up-to-date when $\THEORY$ is executed interactively).  The optional
wenzelm
parents: 7974
diff changeset
    74
  $\isarkeyword{files}$ specification declares additional dependencies on ML
wenzelm
parents: 7974
diff changeset
    75
  files.  Unless put in parentheses, any file will be loaded immediately via
wenzelm
parents: 7974
diff changeset
    76
  $\isarcmd{use}$ (see also \S\ref{sec:ML}).  The optional ML file
wenzelm
parents: 7974
diff changeset
    77
  \texttt{$A$.ML} that may be associated with any theory should \emph{not} be
wenzelm
parents: 7974
diff changeset
    78
  included in $\isarkeyword{files}$, though.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    79
  
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    80
\item [$\CONTEXT~B$] enters an existing theory context, basically in read-only
7981
wenzelm
parents: 7974
diff changeset
    81
  mode, so only a limited set of commands may be performed without destroying
wenzelm
parents: 7974
diff changeset
    82
  the theory.  Just as for $\THEORY$, the theory loader ensures that $B$ is
wenzelm
parents: 7974
diff changeset
    83
  loaded and up-to-date.
7175
wenzelm
parents: 7167
diff changeset
    84
  
7167
wenzelm
parents: 7141
diff changeset
    85
\item [$\END$] concludes the current theory definition or context switch.
7981
wenzelm
parents: 7974
diff changeset
    86
Note that this command cannot be undone, but the whole theory definition has
wenzelm
parents: 7974
diff changeset
    87
to be retracted.
7167
wenzelm
parents: 7141
diff changeset
    88
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    89
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    90
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    91
\subsection{Theory markup commands}\label{sec:markup-thy}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    92
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    93
\indexisarcmd{chapter}\indexisarcmd{section}\indexisarcmd{subsection}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
    94
\indexisarcmd{subsubsection}\indexisarcmd{text}\indexisarcmd{text-raw}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    95
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    96
  \isarcmd{chapter} & : & \isartrans{theory}{theory} \\
7167
wenzelm
parents: 7141
diff changeset
    97
  \isarcmd{section} & : & \isartrans{theory}{theory} \\
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    98
  \isarcmd{subsection} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
    99
  \isarcmd{subsubsection} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   100
  \isarcmd{text} & : & \isartrans{theory}{theory} \\
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   101
  \isarcmd{text_raw} & : & \isartrans{theory}{theory} \\
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   102
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   103
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   104
Apart from formal comments (see \S\ref{sec:comments}), markup commands provide
7981
wenzelm
parents: 7974
diff changeset
   105
a structured way to insert text into the document generated from a theory (see
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   106
\cite{isabelle-sys} for more information on Isabelle's document preparation
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   107
tools).
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   108
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   109
\railalias{textraw}{text\_raw}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   110
\railterm{textraw}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   111
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   112
\begin{rail}
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   113
  ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text' | textraw) text
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   114
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   115
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   116
7167
wenzelm
parents: 7141
diff changeset
   117
\begin{descr}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   118
\item [$\isarkeyword{chapter}$, $\isarkeyword{section}$,
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   119
  $\isarkeyword{subsection}$, and $\isarkeyword{subsubsection}$] mark chapter
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   120
  and section headings.
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   121
\item [$\TEXT$] specifies paragraphs of plain text, including references to
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   122
  formal entities.\footnote{The latter feature is not yet supported.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   123
    Nevertheless, any source text of the form
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   124
    ``\texttt{\at\ttlbrace$\dots$\ttrbrace}'' should be considered as reserved
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   125
    for future use.}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   126
\item [$\isarkeyword{text_raw}$] inserts {\LaTeX} source into the output,
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   127
  without additional markup.  Thus the full range of document manipulations
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   128
  becomes available.  A typical application would be to emit
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   129
  \verb,\begin{comment}, and \verb,\end{comment}, commands to exclude certain
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   130
  parts from the final document.\footnote{This requires the \texttt{comment}
7981
wenzelm
parents: 7974
diff changeset
   131
    package to be included in {\LaTeX}.}
7167
wenzelm
parents: 7141
diff changeset
   132
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   133
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   134
Any markup command (except $\isarkeyword{text_raw}$) corresponds to a {\LaTeX}
7981
wenzelm
parents: 7974
diff changeset
   135
macro with the name prefixed by \verb,\isamarkup, (e.g.\ 
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   136
\verb,\isamarkupchapter, for $\isarkeyword{chapter}$). The \railqtoken{text}
7981
wenzelm
parents: 7974
diff changeset
   137
argument is passed to that macro unchanged, i.e.\ further {\LaTeX} commands
wenzelm
parents: 7974
diff changeset
   138
may be included here as well.
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   139
7981
wenzelm
parents: 7974
diff changeset
   140
\medskip Additional markup commands are available for proofs (see
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   141
\S\ref{sec:markup-prf}).  Also note that the $\isarkeyword{header}$
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   142
declaration (see \S\ref{sec:begin-thy}) admits to insert document markup
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   143
elements just preceding the actual theory definition.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   144
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   145
7135
wenzelm
parents: 7134
diff changeset
   146
\subsection{Type classes and sorts}\label{sec:classes}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   147
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   148
\indexisarcmd{classes}\indexisarcmd{classrel}\indexisarcmd{defaultsort}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   149
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   150
  \isarcmd{classes} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   151
  \isarcmd{classrel} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   152
  \isarcmd{defaultsort} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   153
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   154
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   155
\begin{rail}
7167
wenzelm
parents: 7141
diff changeset
   156
  'classes' (classdecl comment? +)
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   157
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   158
  'classrel' nameref '<' nameref comment?
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   159
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   160
  'defaultsort' sort comment?
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   161
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   162
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   163
7167
wenzelm
parents: 7141
diff changeset
   164
\begin{descr}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   165
\item [$\isarkeyword{classes}~c<\vec c$] declares class $c$ to be a subclass
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   166
  of existing classes $\vec c$.  Cyclic class structures are ruled out.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   167
\item [$\isarkeyword{classrel}~c@1<c@2$] states a subclass relation between
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   168
  existing classes $c@1$ and $c@2$.  This is done axiomatically!  The
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   169
  $\isarkeyword{instance}$ command (see \S\ref{sec:axclass}) provides a way to
7175
wenzelm
parents: 7167
diff changeset
   170
  introduce proven class relations.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   171
\item [$\isarkeyword{defaultsort}~s$] makes sort $s$ the new default sort for
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   172
  any type variables given without sort constraints.  Usually, the default
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   173
  sort would be only changed when defining new logics.
7167
wenzelm
parents: 7141
diff changeset
   174
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   175
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   176
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   177
\subsection{Primitive types and type abbreviations}\label{sec:types-pure}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   178
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   179
\indexisarcmd{typedecl}\indexisarcmd{types}\indexisarcmd{nonterminals}\indexisarcmd{arities}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   180
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   181
  \isarcmd{types} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   182
  \isarcmd{typedecl} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   183
  \isarcmd{nonterminals} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   184
  \isarcmd{arities} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   185
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   186
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   187
\begin{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   188
  'types' (typespec '=' type infix? comment? +)
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   189
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   190
  'typedecl' typespec infix? comment?
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   191
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   192
  'nonterminals' (name +) comment?
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   193
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   194
  'arities' (nameref '::' arity comment? +)
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   195
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   196
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   197
7167
wenzelm
parents: 7141
diff changeset
   198
\begin{descr}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   199
\item [$\TYPES~(\vec\alpha)t = \tau$] introduces \emph{type synonym}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   200
  $(\vec\alpha)t$ for existing type $\tau$.  Unlike actual type definitions,
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   201
  as are available in Isabelle/HOL for example, type synonyms are just purely
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   202
  syntactic abbreviations without any logical significance.  Internally, type
7981
wenzelm
parents: 7974
diff changeset
   203
  synonyms are fully expanded.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   204
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] declares a new type constructor
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   205
  $t$, intended as an actual logical type.  Note that object-logics such as
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   206
  Isabelle/HOL override $\isarkeyword{typedecl}$ by their own version.
7175
wenzelm
parents: 7167
diff changeset
   207
\item [$\isarkeyword{nonterminals}~\vec c$] declares $0$-ary type constructors
wenzelm
parents: 7167
diff changeset
   208
  $\vec c$ to act as purely syntactic types, i.e.\ nonterminal symbols of
wenzelm
parents: 7167
diff changeset
   209
  Isabelle's inner syntax of terms or types.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   210
\item [$\isarkeyword{arities}~t::(\vec s)s$] augments Isabelle's order-sorted
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   211
  signature of types by new type constructor arities.  This is done
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   212
  axiomatically!  The $\isarkeyword{instance}$ command (see
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   213
  \S\ref{sec:axclass}) provides a way to introduce proven type arities.
7167
wenzelm
parents: 7141
diff changeset
   214
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   215
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   216
7981
wenzelm
parents: 7974
diff changeset
   217
\subsection{Constants and simple definitions}\label{sec:consts}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   218
7175
wenzelm
parents: 7167
diff changeset
   219
\indexisarcmd{consts}\indexisarcmd{defs}\indexisarcmd{constdefs}\indexoutertoken{constdecl}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   220
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   221
  \isarcmd{consts} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   222
  \isarcmd{defs} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   223
  \isarcmd{constdefs} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   224
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   225
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   226
\begin{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   227
  'consts' (constdecl +)
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   228
  ;
7608
8069542cba82 defs: axmdecl;
wenzelm
parents: 7510
diff changeset
   229
  'defs' (axmdecl prop comment? +)
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   230
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   231
  'constdefs' (constdecl prop comment? +)
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   232
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   233
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   234
  constdecl: name '::' type mixfix? comment?
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   235
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   236
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   237
7167
wenzelm
parents: 7141
diff changeset
   238
\begin{descr}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   239
\item [$\CONSTS~c::\sigma$] declares constant $c$ to have any instance of type
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   240
  scheme $\sigma$.  The optional mixfix annotations may attach concrete syntax
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   241
  to the constants declared.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   242
\item [$\DEFS~name: eqn$] introduces $eqn$ as a definitional axiom for some
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   243
  existing constant.  See \cite[\S6]{isabelle-ref} for more details on the
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   244
  form of equations admitted as constant definitions.
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   245
\item [$\isarkeyword{constdefs}~c::\sigma~eqn$] combines declarations and
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   246
  definitions of constants, using canonical name $c_def$ for the definitional
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   247
  axiom.
7167
wenzelm
parents: 7141
diff changeset
   248
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   249
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   250
7981
wenzelm
parents: 7974
diff changeset
   251
\subsection{Syntax and translations}\label{sec:syn-trans}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   252
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   253
\indexisarcmd{syntax}\indexisarcmd{translations}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   254
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   255
  \isarcmd{syntax} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   256
  \isarcmd{translations} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   257
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   258
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   259
\begin{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   260
  'syntax' ('(' name 'output'? ')')? (constdecl +)
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   261
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   262
  'translations' (transpat ('==' | '=>' | '<=') transpat comment? +)
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   263
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   264
  transpat: ('(' nameref ')')? string
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   265
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   266
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   267
7167
wenzelm
parents: 7141
diff changeset
   268
\begin{descr}
7175
wenzelm
parents: 7167
diff changeset
   269
\item [$\isarkeyword{syntax}~(mode)~decls$] is similar to $\CONSTS~decls$,
wenzelm
parents: 7167
diff changeset
   270
  except that the actual logical signature extension is omitted.  Thus the
wenzelm
parents: 7167
diff changeset
   271
  context free grammar of Isabelle's inner syntax may be augmented in
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   272
  arbitrary ways, independently of the logic.  The $mode$ argument refers to
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   273
  the print mode that the grammar rules belong; unless there is the
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   274
  \texttt{output} flag given, all productions are added both to the input and
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   275
  output grammar.
7175
wenzelm
parents: 7167
diff changeset
   276
\item [$\isarkeyword{translations}~rules$] specifies syntactic translation
7981
wenzelm
parents: 7974
diff changeset
   277
  rules (i.e.\ \emph{macros}): parse~/ print rules (\texttt{==}), parse rules
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   278
  (\texttt{=>}), or print rules (\texttt{<=}).  Translation patterns may be
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   279
  prefixed by the syntactic category to be used for parsing; the default is
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   280
  \texttt{logic}.
7167
wenzelm
parents: 7141
diff changeset
   281
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   282
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   283
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   284
\subsection{Axioms and theorems}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   285
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   286
\indexisarcmd{axioms}\indexisarcmd{theorems}\indexisarcmd{lemmas}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   287
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   288
  \isarcmd{axioms} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   289
  \isarcmd{theorems} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   290
  \isarcmd{lemmas} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   291
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   292
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   293
\begin{rail}
7135
wenzelm
parents: 7134
diff changeset
   294
  'axioms' (axmdecl prop comment? +)
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   295
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   296
  ('theorems' | 'lemmas') thmdef? thmrefs
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   297
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   298
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   299
7167
wenzelm
parents: 7141
diff changeset
   300
\begin{descr}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   301
\item [$\isarkeyword{axioms}~a: \phi$] introduces arbitrary statements as
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   302
  axioms of the meta-logic.  In fact, axioms are ``axiomatic theorems'', and
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   303
  may be referred later just as any other theorem.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   304
  
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   305
  Axioms are usually only introduced when declaring new logical systems.
7175
wenzelm
parents: 7167
diff changeset
   306
  Everyday work is typically done the hard way, with proper definitions and
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   307
  actual theorems.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   308
\item [$\isarkeyword{theorems}~a = \vec b$] stores lists of existing theorems.
7981
wenzelm
parents: 7974
diff changeset
   309
  Typical applications would also involve attributes, to augment the
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   310
  Simplifier context, for example.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   311
\item [$\isarkeyword{lemmas}$] is similar to $\isarkeyword{theorems}$, but
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   312
  tags the results as ``lemma''.
7167
wenzelm
parents: 7141
diff changeset
   313
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   314
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   315
7167
wenzelm
parents: 7141
diff changeset
   316
\subsection{Name spaces}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   317
7167
wenzelm
parents: 7141
diff changeset
   318
\indexisarcmd{global}\indexisarcmd{local}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   319
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   320
  \isarcmd{global} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   321
  \isarcmd{local} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   322
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   323
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   324
Isabelle organizes any kind of name declarations (of types, constants,
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   325
theorems etc.)  by hierarchically structured name spaces.  Normally the user
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   326
never has to control the behavior of name space entry by hand, yet the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   327
following commands provide some way to do so.
7175
wenzelm
parents: 7167
diff changeset
   328
7167
wenzelm
parents: 7141
diff changeset
   329
\begin{descr}
wenzelm
parents: 7141
diff changeset
   330
\item [$\isarkeyword{global}$ and $\isarkeyword{local}$] change the current
wenzelm
parents: 7141
diff changeset
   331
  name declaration mode.  Initially, theories start in $\isarkeyword{local}$
wenzelm
parents: 7141
diff changeset
   332
  mode, causing all names to be automatically qualified by the theory name.
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   333
  Changing this to $\isarkeyword{global}$ causes all names to be declared
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   334
  without the theory prefix, until $\isarkeyword{local}$ is declared again.
7167
wenzelm
parents: 7141
diff changeset
   335
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   336
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   337
7167
wenzelm
parents: 7141
diff changeset
   338
\subsection{Incorporating ML code}\label{sec:ML}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   339
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   340
\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{ML-setup}\indexisarcmd{setup}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   341
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   342
  \isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   343
  \isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   344
  \isarcmd{ML_setup} & : & \isartrans{theory}{theory} \\
7175
wenzelm
parents: 7167
diff changeset
   345
  \isarcmd{setup} & : & \isartrans{theory}{theory} \\
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   346
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   347
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   348
\railalias{MLsetup}{ML\_setup}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   349
\railterm{MLsetup}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   350
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   351
\begin{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   352
  'use' name
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   353
  ;
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   354
  ('ML' | MLsetup | 'setup') text
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   355
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   356
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   357
7167
wenzelm
parents: 7141
diff changeset
   358
\begin{descr}
7175
wenzelm
parents: 7167
diff changeset
   359
\item [$\isarkeyword{use}~file$] reads and executes ML commands from $file$.
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   360
  The current theory context (if present) is passed down to the ML session,
7981
wenzelm
parents: 7974
diff changeset
   361
  but may not be modified.  Furthermore, the file name is checked with the
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   362
  $\isarkeyword{files}$ dependency declaration given in the theory header (see
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   363
  also \S\ref{sec:begin-thy}).
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   364
  
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   365
\item [$\isarkeyword{ML}~text$] executes ML commands from $text$.  The theory
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   366
  context is passed in the same way as for $\isarkeyword{use}$.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   367
  
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   368
\item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$.  The
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   369
  theory context is passed down to the ML session, and fetched back
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   370
  afterwards.  Thus $text$ may actually change the theory as a side effect.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   371
  
7167
wenzelm
parents: 7141
diff changeset
   372
\item [$\isarkeyword{setup}~text$] changes the current theory context by
7981
wenzelm
parents: 7974
diff changeset
   373
  applying setup functions from $text$, which refers to an ML expression of
wenzelm
parents: 7974
diff changeset
   374
  type $(theory \to theory)~list$.  The $\isarkeyword{setup}$ command is the
wenzelm
parents: 7974
diff changeset
   375
  canonical way to initialize object-logic specific tools and packages written
wenzelm
parents: 7974
diff changeset
   376
  in ML.
7167
wenzelm
parents: 7141
diff changeset
   377
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   378
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   379
7981
wenzelm
parents: 7974
diff changeset
   380
%FIXME remove!?
wenzelm
parents: 7974
diff changeset
   381
%\subsection{Syntax translation functions}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   382
7981
wenzelm
parents: 7974
diff changeset
   383
%\indexisarcmd{parse-ast-translation}\indexisarcmd{parse-translation}
wenzelm
parents: 7974
diff changeset
   384
%\indexisarcmd{print-translation}\indexisarcmd{typed-print-translation}
wenzelm
parents: 7974
diff changeset
   385
%\indexisarcmd{print-ast-translation}\indexisarcmd{token-translation}
wenzelm
parents: 7974
diff changeset
   386
%\begin{matharray}{rcl}
wenzelm
parents: 7974
diff changeset
   387
%  \isarcmd{parse_ast_translation} & : & \isartrans{theory}{theory} \\
wenzelm
parents: 7974
diff changeset
   388
%  \isarcmd{parse_translation} & : & \isartrans{theory}{theory} \\
wenzelm
parents: 7974
diff changeset
   389
%  \isarcmd{print_translation} & : & \isartrans{theory}{theory} \\
wenzelm
parents: 7974
diff changeset
   390
%  \isarcmd{typed_print_translation} & : & \isartrans{theory}{theory} \\
wenzelm
parents: 7974
diff changeset
   391
%  \isarcmd{print_ast_translation} & : & \isartrans{theory}{theory} \\
wenzelm
parents: 7974
diff changeset
   392
%  \isarcmd{token_translation} & : & \isartrans{theory}{theory} \\
wenzelm
parents: 7974
diff changeset
   393
%\end{matharray}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   394
7981
wenzelm
parents: 7974
diff changeset
   395
%Syntax translation functions written in ML admit almost arbitrary
wenzelm
parents: 7974
diff changeset
   396
%manipulations of Isabelle's inner syntax.  Any of the above commands have a
wenzelm
parents: 7974
diff changeset
   397
%single \railqtoken{text} argument that refers to an ML expression of
wenzelm
parents: 7974
diff changeset
   398
%appropriate type.  See \cite[\S8]{isabelle-ref} for more information on syntax
wenzelm
parents: 7974
diff changeset
   399
%transformations.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   400
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   401
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   402
\subsection{Oracles}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   403
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   404
\indexisarcmd{oracle}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   405
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   406
  \isarcmd{oracle} & : & \isartrans{theory}{theory} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   407
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   408
7175
wenzelm
parents: 7167
diff changeset
   409
Oracles provide an interface to external reasoning systems, without giving up
wenzelm
parents: 7167
diff changeset
   410
control completely --- each theorem carries a derivation object recording any
wenzelm
parents: 7167
diff changeset
   411
oracle invocation.  See \cite[\S6]{isabelle-ref} for more information.
wenzelm
parents: 7167
diff changeset
   412
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   413
\begin{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   414
  'oracle' name '=' text comment?
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   415
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   416
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   417
7167
wenzelm
parents: 7141
diff changeset
   418
\begin{descr}
7175
wenzelm
parents: 7167
diff changeset
   419
\item [$\isarkeyword{oracle}~name=text$] declares oracle $name$ to be ML
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   420
  function $text$, which has to be of type $Sign\mathord.sg \times
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   421
  Object\mathord.T \to term$.
7167
wenzelm
parents: 7141
diff changeset
   422
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   423
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   424
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   425
\section{Proof commands}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   426
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   427
Proof commands provide transitions of Isar/VM machine configurations, which
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   428
are block-structured, consisting of a stack of nodes with three main
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   429
components: logical proof context, current facts, and open goals.  Isar/VM
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   430
transitions are \emph{typed} according to the following three three different
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   431
modes of operation:
7167
wenzelm
parents: 7141
diff changeset
   432
\begin{descr}
wenzelm
parents: 7141
diff changeset
   433
\item [$proof(prove)$] means that a new goal has just been stated that is now
wenzelm
parents: 7141
diff changeset
   434
  to be \emph{proven}; the next command may refine it by some proof method
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   435
  (read: tactic), and enter a sub-proof to establish the actual result.
7167
wenzelm
parents: 7141
diff changeset
   436
\item [$proof(state)$] is like an internal theory mode: the context may be
7175
wenzelm
parents: 7167
diff changeset
   437
  augmented by \emph{stating} additional assumptions, intermediate result etc.
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   438
\item [$proof(chain)$] is intermediate between $proof(state)$ and
7458
bb282845ca77 updated;
wenzelm
parents: 7431
diff changeset
   439
  $proof(prove)$: existing facts (i.e.\ the contents of $this$) have been just
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   440
  picked up in order to be used when refining the goal claimed next.
7167
wenzelm
parents: 7141
diff changeset
   441
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   442
7167
wenzelm
parents: 7141
diff changeset
   443
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   444
\subsection{Proof markup commands}\label{sec:markup-prf}
7167
wenzelm
parents: 7141
diff changeset
   445
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   446
\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsect}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   447
\indexisarcmd{txt}\indexisarcmd{txt-raw}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   448
\begin{matharray}{rcl}
7167
wenzelm
parents: 7141
diff changeset
   449
  \isarcmd{sect} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm
parents: 7141
diff changeset
   450
  \isarcmd{subsect} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm
parents: 7141
diff changeset
   451
  \isarcmd{subsubsect} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm
parents: 7141
diff changeset
   452
  \isarcmd{txt} & : & \isartrans{proof(state)}{proof(state)} \\
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   453
  \isarcmd{txt_raw} & : & \isartrans{proof(state)}{proof(state)} \\
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   454
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   455
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   456
These markup commands for proof mode closely correspond to the ones of theory
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   457
mode (see \S\ref{sec:markup-thy}).  Note that $\isarkeyword{txt_raw}$ is
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   458
special in the same way as $\isarkeyword{text_raw}$.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   459
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   460
\railalias{txtraw}{txt\_raw}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   461
\railterm{txtraw}
7175
wenzelm
parents: 7167
diff changeset
   462
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   463
\begin{rail}
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   464
  ('sect' | 'subsect' | 'subsubsect' | 'txt' | txtraw) text
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   465
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   466
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   467
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   468
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   469
\subsection{Proof context}\label{sec:proof-context}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   470
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   471
\indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   472
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   473
  \isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   474
  \isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   475
  \isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   476
  \isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   477
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   478
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   479
The logical proof context consists of fixed variables and assumptions.  The
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   480
former closely correspond to Skolem constants, or meta-level universal
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   481
quantification as provided by the Isabelle/Pure logical framework.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   482
Introducing some \emph{arbitrary, but fixed} variable via $\FIX x$ results in
7319
wenzelm
parents: 7315
diff changeset
   483
a local object that may be used in the subsequent proof as any other variable
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   484
or constant.  Furthermore, any result $\edrv \phi[x]$ exported from the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   485
current context will be universally closed wrt.\ $x$ at the outermost level:
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   486
$\edrv \All x \phi$; this is expressed using Isabelle's meta-variables.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   487
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   488
Similarly, introducing some assumption $\chi$ has two effects.  On the one
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   489
hand, a local theorem is created that may be used as a fact in subsequent
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   490
proof steps.  On the other hand, any result $\chi \drv \phi$ exported from the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   491
context becomes conditional wrt.\ the assumption: $\edrv \chi \Imp \phi$.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   492
Thus, solving an enclosing goal using such a result would basically introduce
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   493
a new subgoal stemming from the assumption.  How this situation is handled
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   494
depends on the actual version of assumption command used: while $\ASSUMENAME$
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   495
insists on solving the subgoal by unification with some premise of the goal,
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   496
$\PRESUMENAME$ leaves the subgoal unchanged in order to be proved later by the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   497
user.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   498
7319
wenzelm
parents: 7315
diff changeset
   499
Local definitions, introduced by $\DEF{}{x \equiv t}$, are achieved by
wenzelm
parents: 7315
diff changeset
   500
combining $\FIX x$ with another kind of assumption that causes any
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   501
hypothetical equation $x \equiv t$ to be eliminated by reflexivity.  Thus,
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   502
exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$.
7175
wenzelm
parents: 7167
diff changeset
   503
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   504
\begin{rail}
7431
83e60a678c3a fix: vars;
wenzelm
parents: 7397
diff changeset
   505
  'fix' (vars + 'and') comment?
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   506
  ;
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   507
  ('assume' | 'presume') (assm comment? + 'and')
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   508
  ;
7175
wenzelm
parents: 7167
diff changeset
   509
  'def' thmdecl? \\ var '==' term termpat? comment?
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   510
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   511
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   512
  var: name ('::' type)?
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   513
  ;
7458
bb282845ca77 updated;
wenzelm
parents: 7431
diff changeset
   514
  vars: (name+) ('::' type)?
7431
83e60a678c3a fix: vars;
wenzelm
parents: 7397
diff changeset
   515
  ;
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   516
  assm: thmdecl? (prop proppat? +)
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   517
  ;
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   518
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   519
7167
wenzelm
parents: 7141
diff changeset
   520
\begin{descr}
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   521
\item [$\FIX{x}$] introduces a local \emph{arbitrary, but fixed} variable $x$.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   522
\item [$\ASSUME{a}{\Phi}$ and $\PRESUME{a}{\Phi}$] introduce local theorems
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   523
  $\Phi$ by assumption.  Subsequent results applied to an enclosing goal
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   524
  (e.g.\ by $\SHOWNAME$) are handled as follows: $\ASSUMENAME$ expects to be
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   525
  able to unify with existing premises in the goal, while $\PRESUMENAME$
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   526
  leaves $\Phi$ as new subgoals.
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   527
  
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   528
  Several lists of assumptions may be given (separated by
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   529
  $\isarkeyword{and}$); the resulting list of current facts consists of all of
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   530
  these concatenated.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   531
\item [$\DEF{a}{x \equiv t}$] introduces a local (non-polymorphic) definition.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   532
  In results exported from the context, $x$ is replaced by $t$.  Basically,
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   533
  $\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\PRESUME{}{x \equiv t}$, with the
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   534
  resulting hypothetical equation solved by reflexivity.
7431
83e60a678c3a fix: vars;
wenzelm
parents: 7397
diff changeset
   535
  
83e60a678c3a fix: vars;
wenzelm
parents: 7397
diff changeset
   536
  The default name for the definitional equation is $x_def$.
7167
wenzelm
parents: 7141
diff changeset
   537
\end{descr}
wenzelm
parents: 7141
diff changeset
   538
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   539
The special name $prems$\indexisarthm{prems} refers to all assumptions of the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   540
current context as a list of theorems.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   541
7167
wenzelm
parents: 7141
diff changeset
   542
wenzelm
parents: 7141
diff changeset
   543
\subsection{Facts and forward chaining}
wenzelm
parents: 7141
diff changeset
   544
wenzelm
parents: 7141
diff changeset
   545
\indexisarcmd{note}\indexisarcmd{then}\indexisarcmd{from}\indexisarcmd{with}
wenzelm
parents: 7141
diff changeset
   546
\begin{matharray}{rcl}
wenzelm
parents: 7141
diff changeset
   547
  \isarcmd{note} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm
parents: 7141
diff changeset
   548
  \isarcmd{then} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm
parents: 7141
diff changeset
   549
  \isarcmd{from} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm
parents: 7141
diff changeset
   550
  \isarcmd{with} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm
parents: 7141
diff changeset
   551
\end{matharray}
wenzelm
parents: 7141
diff changeset
   552
7319
wenzelm
parents: 7315
diff changeset
   553
New facts are established either by assumption or proof of local statements.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   554
Any fact will usually be involved in further proofs, either as explicit
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   555
arguments of proof methods or when forward chaining towards the next goal via
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   556
$\THEN$ (and variants).  Note that the special theorem name
7458
bb282845ca77 updated;
wenzelm
parents: 7431
diff changeset
   557
$this$.\indexisarthm{this} refers to the most recently established facts.
7167
wenzelm
parents: 7141
diff changeset
   558
\begin{rail}
wenzelm
parents: 7141
diff changeset
   559
  'note' thmdef? thmrefs comment?
wenzelm
parents: 7141
diff changeset
   560
  ;
wenzelm
parents: 7141
diff changeset
   561
  'then' comment?
wenzelm
parents: 7141
diff changeset
   562
  ;
wenzelm
parents: 7141
diff changeset
   563
  ('from' | 'with') thmrefs comment?
wenzelm
parents: 7141
diff changeset
   564
  ;
wenzelm
parents: 7141
diff changeset
   565
\end{rail}
wenzelm
parents: 7141
diff changeset
   566
wenzelm
parents: 7141
diff changeset
   567
\begin{descr}
7175
wenzelm
parents: 7167
diff changeset
   568
\item [$\NOTE{a}{\vec b}$] recalls existing facts $\vec b$, binding the result
wenzelm
parents: 7167
diff changeset
   569
  as $a$.  Note that attributes may be involved as well, both on the left and
wenzelm
parents: 7167
diff changeset
   570
  right hand sides.
7167
wenzelm
parents: 7141
diff changeset
   571
\item [$\THEN$] indicates forward chaining by the current facts in order to
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   572
  establish the goal to be claimed next.  The initial proof method invoked to
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   573
  refine that will be offered the facts to do ``anything appropriate'' (cf.\ 
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   574
  also \S\ref{sec:proof-steps}).  For example, method $rule$ (see
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   575
  \S\ref{sec:pure-meth}) would typically do an elimination rather than an
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   576
  introduction.  Automatic methods usually insert the facts into the goal
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   577
  state before operation.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   578
\item [$\FROM{\vec b}$] abbreviates $\NOTE{}{\vec b}~\THEN$; thus $\THEN$ is
7458
bb282845ca77 updated;
wenzelm
parents: 7431
diff changeset
   579
  equivalent to $\FROM{this}$.
7175
wenzelm
parents: 7167
diff changeset
   580
\item [$\WITH{\vec b}$] abbreviates $\FROM{\vec b~facts}$; thus the forward
wenzelm
parents: 7167
diff changeset
   581
  chaining is from earlier facts together with the current ones.
7167
wenzelm
parents: 7141
diff changeset
   582
\end{descr}
wenzelm
parents: 7141
diff changeset
   583
7389
f647f463abeb '_' theorem;
wenzelm
parents: 7335
diff changeset
   584
Basic proof methods (such as $rule$, see \S\ref{sec:pure-meth}) expect
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   585
multiple facts to be given in their proper order, corresponding to a prefix of
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   586
the premises of the rule involved.  Note that positions may be easily skipped
7458
bb282845ca77 updated;
wenzelm
parents: 7431
diff changeset
   587
using a form like $\FROM{\text{\texttt{_}}~a~b}$, for example.  This involves
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   588
the trivial rule $\PROP\psi \Imp \PROP\psi$, which is bound in Isabelle/Pure
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   589
as ``\texttt{_}'' (underscore).\indexisarthm{_@\texttt{_}}
7389
f647f463abeb '_' theorem;
wenzelm
parents: 7335
diff changeset
   590
7167
wenzelm
parents: 7141
diff changeset
   591
wenzelm
parents: 7141
diff changeset
   592
\subsection{Goal statements}
wenzelm
parents: 7141
diff changeset
   593
wenzelm
parents: 7141
diff changeset
   594
\indexisarcmd{theorem}\indexisarcmd{lemma}
wenzelm
parents: 7141
diff changeset
   595
\indexisarcmd{have}\indexisarcmd{show}\indexisarcmd{hence}\indexisarcmd{thus}
wenzelm
parents: 7141
diff changeset
   596
\begin{matharray}{rcl}
wenzelm
parents: 7141
diff changeset
   597
  \isarcmd{theorem} & : & \isartrans{theory}{proof(prove)} \\
wenzelm
parents: 7141
diff changeset
   598
  \isarcmd{lemma} & : & \isartrans{theory}{proof(prove)} \\
wenzelm
parents: 7141
diff changeset
   599
  \isarcmd{have} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm
parents: 7141
diff changeset
   600
  \isarcmd{show} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm
parents: 7141
diff changeset
   601
  \isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm
parents: 7141
diff changeset
   602
  \isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm
parents: 7141
diff changeset
   603
\end{matharray}
wenzelm
parents: 7141
diff changeset
   604
7175
wenzelm
parents: 7167
diff changeset
   605
Proof mode is entered from theory mode by initial goal commands $\THEOREMNAME$
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   606
and $\LEMMANAME$.  New local goals may be claimed within proof mode as well.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   607
Four variants are available, indicating whether the result is meant to solve
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   608
some pending goal and whether forward chaining is employed.
7175
wenzelm
parents: 7167
diff changeset
   609
7167
wenzelm
parents: 7141
diff changeset
   610
\begin{rail}
wenzelm
parents: 7141
diff changeset
   611
  ('theorem' | 'lemma') goal
wenzelm
parents: 7141
diff changeset
   612
  ;
wenzelm
parents: 7141
diff changeset
   613
  ('have' | 'show' | 'hence' | 'thus') goal
wenzelm
parents: 7141
diff changeset
   614
  ;
wenzelm
parents: 7141
diff changeset
   615
wenzelm
parents: 7141
diff changeset
   616
  goal: thmdecl? proppat comment?
wenzelm
parents: 7141
diff changeset
   617
  ;
wenzelm
parents: 7141
diff changeset
   618
\end{rail}
wenzelm
parents: 7141
diff changeset
   619
wenzelm
parents: 7141
diff changeset
   620
\begin{descr}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   621
\item [$\THEOREM{a}{\phi}$] enters proof mode with $\phi$ as main goal,
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   622
  eventually resulting in some theorem $\turn \phi$ put back into the theory.
7167
wenzelm
parents: 7141
diff changeset
   623
\item [$\LEMMANAME$] is similar to $\THEOREMNAME$, but tags the result as
wenzelm
parents: 7141
diff changeset
   624
  ``lemma''.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   625
\item [$\HAVE{a}{\phi}$] claims a local goal, eventually resulting in a
7167
wenzelm
parents: 7141
diff changeset
   626
  theorem with the current assumption context as hypotheses.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   627
\item [$\SHOW{a}{\phi}$] is similar to $\HAVE{a}{\phi}$, but solves some
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   628
  pending goal with the result \emph{exported} into the corresponding context
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   629
  (cf.\ \S\ref{sec:proof-context}).
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   630
\item [$\HENCENAME$] abbreviates $\THEN~\HAVENAME$, i.e.\ claims a local goal
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   631
  to be proven by forward chaining the current facts.  Note that $\HENCENAME$
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   632
  is also equivalent to $\FROM{this}~\HAVENAME$.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   633
\item [$\THUSNAME$] abbreviates $\THEN~\SHOWNAME$.  Note that $\THUSNAME$ is
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   634
  also equivalent to $\FROM{this}~\SHOWNAME$.
7167
wenzelm
parents: 7141
diff changeset
   635
\end{descr}
wenzelm
parents: 7141
diff changeset
   636
wenzelm
parents: 7141
diff changeset
   637
wenzelm
parents: 7141
diff changeset
   638
\subsection{Initial and terminal proof steps}\label{sec:proof-steps}
wenzelm
parents: 7141
diff changeset
   639
7175
wenzelm
parents: 7167
diff changeset
   640
\indexisarcmd{proof}\indexisarcmd{qed}\indexisarcmd{by}
wenzelm
parents: 7167
diff changeset
   641
\indexisarcmd{.}\indexisarcmd{..}\indexisarcmd{sorry}
wenzelm
parents: 7167
diff changeset
   642
\begin{matharray}{rcl}
wenzelm
parents: 7167
diff changeset
   643
  \isarcmd{proof} & : & \isartrans{proof(prove)}{proof(state)} \\
wenzelm
parents: 7167
diff changeset
   644
  \isarcmd{qed} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\
wenzelm
parents: 7167
diff changeset
   645
  \isarcmd{by} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm
parents: 7167
diff changeset
   646
  \isarcmd{.\,.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm
parents: 7167
diff changeset
   647
  \isarcmd{.} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm
parents: 7167
diff changeset
   648
  \isarcmd{sorry} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm
parents: 7167
diff changeset
   649
\end{matharray}
wenzelm
parents: 7167
diff changeset
   650
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   651
Arbitrary goal refinement via tactics is considered harmful.  Consequently the
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   652
Isar framework admits proof methods to be invoked in two places only.
7167
wenzelm
parents: 7141
diff changeset
   653
\begin{enumerate}
7175
wenzelm
parents: 7167
diff changeset
   654
\item An \emph{initial} refinement step $\PROOF{m@1}$ reduces a newly stated
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   655
  goal to a number of sub-goals that are to be solved later.  Facts are passed
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   656
  to $m@1$ for forward chaining, if so indicated by $proof(chain)$ mode.
7167
wenzelm
parents: 7141
diff changeset
   657
  
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   658
\item A \emph{terminal} conclusion step $\QED{m@2}$ solves any remaining goals
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   659
  completely.  No facts are passed to $m@2$.
7167
wenzelm
parents: 7141
diff changeset
   660
\end{enumerate}
wenzelm
parents: 7141
diff changeset
   661
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   662
The only other proper way to affect pending goals is by $\SHOWNAME$ (or
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   663
$\THUSNAME$), which involves an explicit statement of what is to be solved.
7167
wenzelm
parents: 7141
diff changeset
   664
7175
wenzelm
parents: 7167
diff changeset
   665
\medskip
wenzelm
parents: 7167
diff changeset
   666
7167
wenzelm
parents: 7141
diff changeset
   667
Also note that initial proof methods should either solve the goal completely,
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   668
or constitute some well-understood reduction to new sub-goals.  Arbitrary
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   669
automatic proof tools that are prone leave a large number of badly structured
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   670
sub-goals are no help in continuing the proof document in any intelligible
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   671
way.  A much better technique would be to $\SHOWNAME$ some non-trivial
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   672
reduction as an explicit rule, which is solved completely by some automated
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   673
method, and then applied to some pending goal.
7167
wenzelm
parents: 7141
diff changeset
   674
7175
wenzelm
parents: 7167
diff changeset
   675
\medskip
wenzelm
parents: 7167
diff changeset
   676
wenzelm
parents: 7167
diff changeset
   677
Unless given explicitly by the user, the default initial method is
wenzelm
parents: 7167
diff changeset
   678
``$default$'', which is usually set up to apply a single standard elimination
7458
bb282845ca77 updated;
wenzelm
parents: 7431
diff changeset
   679
or introduction rule according to the topmost symbol involved.  There is no
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   680
separate default terminal method; in any case the final step is to solve all
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   681
remaining goals by assumption, though.
7167
wenzelm
parents: 7141
diff changeset
   682
wenzelm
parents: 7141
diff changeset
   683
\begin{rail}
wenzelm
parents: 7141
diff changeset
   684
  'proof' interest? meth? comment?
wenzelm
parents: 7141
diff changeset
   685
  ;
wenzelm
parents: 7141
diff changeset
   686
  'qed' meth? comment?
wenzelm
parents: 7141
diff changeset
   687
  ;
wenzelm
parents: 7141
diff changeset
   688
  'by' meth meth? comment?
wenzelm
parents: 7141
diff changeset
   689
  ;
wenzelm
parents: 7141
diff changeset
   690
  ('.' | '..' | 'sorry') comment?
wenzelm
parents: 7141
diff changeset
   691
  ;
wenzelm
parents: 7141
diff changeset
   692
wenzelm
parents: 7141
diff changeset
   693
  meth: method interest?
wenzelm
parents: 7141
diff changeset
   694
  ;
wenzelm
parents: 7141
diff changeset
   695
\end{rail}
wenzelm
parents: 7141
diff changeset
   696
wenzelm
parents: 7141
diff changeset
   697
\begin{descr}
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   698
\item [$\PROOF{m@1}$] refines the goal by proof method $m@1$; facts for
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   699
  forward chaining are passed if so indicated by $proof(chain)$ mode.
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   700
\item [$\QED{m@2}$] refines any remaining goals by proof method $m@2$ and
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   701
  concludes the sub-proof by assumption.  If the goal had been $\SHOWNAME$ (or
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   702
  $\THUSNAME$), some pending sub-goal is solved as well by the rule resulting
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   703
  from the result \emph{exported} into the enclosing goal context.  Thus
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   704
  $\QEDNAME$ may fail for two reasons: either $m@2$ fails, or the resulting
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   705
  rule does not fit to any pending goal\footnote{This includes any additional
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   706
    ``strong'' assumptions as introduced by $\ASSUMENAME$.} of the enclosing
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   707
  context.  Debugging such a situation might involve temporarily changing
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   708
  $\SHOWNAME$ into $\HAVENAME$, or weakening the local context by replacing
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   709
  some occurrences of $\ASSUMENAME$ by $\PRESUMENAME$.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   710
\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}\index{proof!terminal}; it
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   711
  abbreviates $\PROOF{m@1}~\QED{m@2}$, with automatic backtracking across both
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   712
  methods.  Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   713
  by expanding its definition; in many cases $\PROOF{m@1}$ is already
7175
wenzelm
parents: 7167
diff changeset
   714
  sufficient to see what is going wrong.
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   715
\item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   716
  abbreviates $\BY{default}$.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   717
\item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   718
  abbreviates $\BY{assumption}$.
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   719
\item [$\isarkeyword{sorry}$] is a \emph{fake proof}\index{proof!fake};
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   720
  provided that \texttt{quick_and_dirty} is enabled, $\isarkeyword{sorry}$
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   721
  pretends to solve the goal without further ado.  Of course, the result is a
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   722
  fake theorem only, involving some oracle in its internal derivation object
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   723
  (this is indicated as ``$[!]$'' in the printed result).  The main
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   724
  application of $\isarkeyword{sorry}$ is to support experimentation and
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   725
  top-down proof development.
7167
wenzelm
parents: 7141
diff changeset
   726
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   727
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   728
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   729
\subsection{Improper proof steps}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   730
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   731
The following commands emulate unstructured tactic scripts to some extent.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   732
While these are anathema for writing proper Isar proof documents, they might
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   733
come in handy for interactive exploration and debugging.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   734
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   735
\indexisarcmd{apply}\indexisarcmd{then-apply}\indexisarcmd{back}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   736
\begin{matharray}{rcl}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   737
  \isarcmd{apply}^* & : & \isartrans{proof}{proof} \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   738
  \isarcmd{then_apply}^* & : & \isartrans{proof}{proof} \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   739
  \isarcmd{back}^* & : & \isartrans{proof}{proof} \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   740
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   741
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   742
\railalias{thenapply}{then\_apply}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   743
\railterm{thenapply}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   744
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   745
\begin{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   746
  'apply' method
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   747
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   748
  thenapply method
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   749
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   750
  'back'
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   751
  ;
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   752
\end{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   753
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   754
\begin{descr}
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   755
\item [$\isarkeyword{apply}~(m)$] applies proof method $m$ in the plain old
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   756
  tactic sense.  Facts for forward chaining are reset.
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   757
\item [$\isarkeyword{then_apply}~(m)$] is similar to $\isarkeyword{apply}$,
7510
212516006d89 tuned (then_)apply;
wenzelm
parents: 7466
diff changeset
   758
  but keeps the goal's facts.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   759
\item [$\isarkeyword{back}$] does back-tracking over the result sequence of
7389
f647f463abeb '_' theorem;
wenzelm
parents: 7335
diff changeset
   760
  the latest proof command.\footnote{Unlike the ML function \texttt{back}
f647f463abeb '_' theorem;
wenzelm
parents: 7335
diff changeset
   761
    \cite{isabelle-ref}, the Isar command does not search upwards for further
f647f463abeb '_' theorem;
wenzelm
parents: 7335
diff changeset
   762
    branch points.} Basically, any proof command may return multiple results.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   763
\end{descr}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   764
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   765
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   766
\subsection{Term abbreviations}\label{sec:term-abbrev}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   767
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   768
\indexisarcmd{let}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   769
\begin{matharray}{rcl}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   770
  \isarcmd{let} & : & \isartrans{proof(state)}{proof(state)} \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   771
  \isarkeyword{is} & : & syntax \\
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   772
\end{matharray}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   773
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   774
Abbreviations may be either bound by explicit $\LET{p \equiv t}$ statements,
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   775
or by annotating assumptions or goal statements ($\ASSUMENAME$, $\SHOWNAME$
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   776
etc.) with a list of patterns $\ISS{p@1 \dots}{p@n}$.  In both cases,
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   777
higher-order matching is invoked to bind extra-logical term variables, which
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   778
may be either named schematic variables of the form $\Var{x}$, or nameless
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   779
dummies ``\texttt{_}'' (underscore).\indexisarvar{_@\texttt{_}} Note that in
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   780
the $\LETNAME$ form the patterns occur on the left-hand side, while the
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   781
$\ISNAME$ patterns are in postfix position.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   782
7319
wenzelm
parents: 7315
diff changeset
   783
Term abbreviations are quite different from actual local definitions as
wenzelm
parents: 7315
diff changeset
   784
introduced via $\DEFNAME$ (see \S\ref{sec:proof-context}).  The latter are
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   785
visible within the logic as actual equations, while abbreviations disappear
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   786
during the input process just after type checking.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   787
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   788
\begin{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   789
  'let' ((term + 'as') '=' term comment? + 'and')
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   790
  ;  
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   791
\end{rail}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   792
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   793
The syntax of $\ISNAME$ patterns follows \railnonterm{termpat} or
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   794
\railnonterm{proppat} (see \S\ref{sec:term-pats}).
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   795
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   796
\begin{descr}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   797
\item [$\LET{\vec p = \vec t}$] binds any text variables in patters $\vec p$
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   798
  by simultaneous higher-order matching against terms $\vec t$.
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   799
\item [$\IS{\vec p}$] resembles $\LETNAME$, but matches $\vec p$ against the
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   800
  preceding statement.  Also note that $\ISNAME$ is not a separate command,
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   801
  but part of others (such as $\ASSUMENAME$, $\HAVENAME$ etc.).
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   802
\end{descr}
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   803
7319
wenzelm
parents: 7315
diff changeset
   804
A few \emph{automatic} term abbreviations\index{automatic abbreviation} for
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   805
goals and facts are available as well.  For any open goal,
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   806
$\Var{thesis_prop}$\indexisarvar{thesis-prop} refers to the full proposition
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   807
(which may be a rule), $\Var{thesis_concl}$\indexisarvar{thesis-concl} to its
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   808
(atomic) conclusion, and $\Var{thesis}$\indexisarvar{thesis} to its
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   809
object-logical statement.  The latter two abstract over any meta-level
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   810
parameters bound by $\Forall$.
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   811
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   812
Fact statements resulting from assumptions or finished goals are bound as
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   813
$\Var{this_prop}$\indexisarvar{this-prop},
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   814
$\Var{this_concl}$\indexisarvar{this-concl}, and
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   815
$\Var{this}$\indexisarvar{this}, similar to $\Var{thesis}$ above.  In case
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   816
$\Var{this}$ refers to an object-logic statement that is an application
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   817
$f(t)$, then $t$ is bound to the special text variable
7466
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   818
``$\dots$''\indexisarvar{\dots} (three dots).  The canonical application of
7df66ce6508a updated;
wenzelm
parents: 7458
diff changeset
   819
this feature are calculational proofs (see \S\ref{sec:calculation}).
7315
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   820
76a39a3784b5 checkpoint;
wenzelm
parents: 7175
diff changeset
   821
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   822
\subsection{Block structure}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   823
7397
wenzelm
parents: 7389
diff changeset
   824
\indexisarcmd{next}\indexisarcmd{\{\{}\indexisarcmd{\}\}}
wenzelm
parents: 7389
diff changeset
   825
\begin{matharray}{rcl}
wenzelm
parents: 7389
diff changeset
   826
  \isarcmd{next} & : & \isartrans{proof(state)}{proof(state)} \\
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   827
  \BG & : & \isartrans{proof(state)}{proof(state)} \\
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   828
  \EN & : & \isartrans{proof(state)}{proof(state)} \\
7397
wenzelm
parents: 7389
diff changeset
   829
\end{matharray}
wenzelm
parents: 7389
diff changeset
   830
7167
wenzelm
parents: 7141
diff changeset
   831
While Isar is inherently block-structured, opening and closing blocks is
wenzelm
parents: 7141
diff changeset
   832
mostly handled rather casually, with little explicit user-intervention.  Any
wenzelm
parents: 7141
diff changeset
   833
local goal statement automatically opens \emph{two} blocks, which are closed
wenzelm
parents: 7141
diff changeset
   834
again when concluding the sub-proof (by $\QEDNAME$ etc.).  Sections of
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   835
different context within a sub-proof may be switched via $\isarkeyword{next}$,
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   836
which is just a single block-close followed by block-open again.  Thus the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   837
effect of $\isarkeyword{next}$ is a local reset the proof
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   838
context.\footnote{There is no goal focus involved here!}
7167
wenzelm
parents: 7141
diff changeset
   839
7175
wenzelm
parents: 7167
diff changeset
   840
For slightly more advanced applications, there are explicit block parentheses
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   841
as well.  These typically achieve a stronger forward style of reasoning.
7167
wenzelm
parents: 7141
diff changeset
   842
wenzelm
parents: 7141
diff changeset
   843
\begin{descr}
wenzelm
parents: 7141
diff changeset
   844
\item [$\isarkeyword{next}$] switches to a fresh block within a sub-proof,
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   845
  resetting the local context to the initial one.
7167
wenzelm
parents: 7141
diff changeset
   846
\item [$\isarkeyword{\{\{}$ and $\isarkeyword{\}\}}$] explicitly open and
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   847
  close blocks.  Any current facts pass through ``$\isarkeyword{\{\{}$''
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   848
  unchanged, while ``$\isarkeyword{\}\}}$'' causes any result to be
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   849
  \emph{exported} into the enclosing context.  Thus fixed variables are
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   850
  generalized, assumptions discharged, and local definitions unfolded (cf.\ 
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   851
  \S\ref{sec:proof-context}).  There is no difference of $\ASSUMENAME$ and
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   852
  $\PRESUMENAME$ in this mode of forward reasoning --- in contrast to plain
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   853
  backward reasoning with the result exported at $\SHOWNAME$ time.
7167
wenzelm
parents: 7141
diff changeset
   854
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   855
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   856
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   857
\section{Other commands}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   858
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   859
\subsection{Diagnostics}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   860
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   861
\indexisarcmd{thm}\indexisarcmd{term}\indexisarcmd{prop}\indexisarcmd{typ}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   862
\begin{matharray}{rcl}
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   863
  \isarcmd{thm} & : & \isarkeep{theory~|~proof} \\
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   864
  \isarcmd{term} & : & \isarkeep{theory~|~proof} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   865
  \isarcmd{prop} & : & \isarkeep{theory~|~proof} \\
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   866
  \isarcmd{typ} & : & \isarkeep{theory~|~proof} \\
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   867
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   868
7335
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   869
These commands are not part of the actual Isabelle/Isar syntax, but assist
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   870
interactive development.  Also note that $undo$ does not apply here, since the
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   871
theory or proof configuration is not changed.
abba35b98892 draft release;
wenzelm
parents: 7321
diff changeset
   872
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   873
\begin{rail}
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   874
  'thm' thmrefs
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   875
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   876
  'term' term
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   877
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   878
  'prop' prop
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   879
  ;
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   880
  'typ' type
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   881
  ;
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   882
\end{rail}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   883
7167
wenzelm
parents: 7141
diff changeset
   884
\begin{descr}
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   885
\item [$\isarkeyword{thm}~thms$] retrieves lists of theorems from the current
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   886
  theory or proof context.  Note that any attributes included in the theorem
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   887
  specifications are applied to a temporary context derived from the current
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   888
  theory or proof; the result is discarded, i.e.\ attributes involved in
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   889
  $thms$ do not have any permanent effect.
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   890
\item [$\isarkeyword{term}~t$, $\isarkeyword{prop}~\phi$] read, type-checks
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   891
  and print terms or propositions according to the current theory or proof
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   892
  context; the inferred type of $t$ is output as well.  Note that these
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   893
  commands are also useful in inspecting the current environment of term
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   894
  abbreviations.
7974
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   895
\item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic
34245feb6e82 improved;
wenzelm
parents: 7895
diff changeset
   896
  according to the current theory or proof context.
7167
wenzelm
parents: 7141
diff changeset
   897
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   898
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   899
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   900
\subsection{System operations}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   901
7167
wenzelm
parents: 7141
diff changeset
   902
\indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{use-thy}\indexisarcmd{use-thy-only}
wenzelm
parents: 7141
diff changeset
   903
\indexisarcmd{update-thy}\indexisarcmd{update-thy-only}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   904
\begin{matharray}{rcl}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   905
  \isarcmd{cd} & : & \isarkeep{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   906
  \isarcmd{pwd} & : & \isarkeep{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   907
  \isarcmd{use_thy} & : & \isarkeep{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   908
  \isarcmd{use_thy_only} & : & \isarkeep{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   909
  \isarcmd{update_thy} & : & \isarkeep{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   910
  \isarcmd{update_thy_only} & : & \isarkeep{\cdot} \\
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   911
\end{matharray}
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   912
7167
wenzelm
parents: 7141
diff changeset
   913
\begin{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   914
\item [$\isarkeyword{cd}~name$] changes the current directory of the Isabelle
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   915
  process.
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   916
\item [$\isarkeyword{pwd}~$] prints the current working directory.
7175
wenzelm
parents: 7167
diff changeset
   917
\item [$\isarkeyword{use_thy}$, $\isarkeyword{use_thy_only}$,
wenzelm
parents: 7167
diff changeset
   918
  $\isarkeyword{update_thy}$, and $\isarkeyword{update_thy_only}$] load some
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   919
  theory given as $name$ argument.  These commands are basically the same as
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   920
  the corresponding ML functions\footnote{For historic reasons, the original
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   921
    ML versions also change the theory context to that of the theory loaded.}
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   922
  (see also \cite[\S1,\S6]{isabelle-ref}).  Note that both the ML and Isar
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   923
  versions may load new- and old-style theories alike.
7167
wenzelm
parents: 7141
diff changeset
   924
\end{descr}
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   925
7895
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   926
Note that these system commands are scarcely used when working with the
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   927
Proof~General interface, since loading of theories is done fully
7c492d8bc8e3 updated;
wenzelm
parents: 7608
diff changeset
   928
transparently.
7134
320b412e5800 more stuff;
wenzelm
parents: 7046
diff changeset
   929
7046
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   930
%%% Local Variables: 
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   931
%%% mode: latex
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   932
%%% TeX-master: "isar-ref"
9f755ff43cff skeleton only;
wenzelm
parents:
diff changeset
   933
%%% End: