updated;
authorwenzelm
Thu Oct 21 17:42:21 1999 +0200 (1999-10-21)
changeset 78957c492d8bc8e3
parent 7894 2ccfea468b24
child 7896 36865f14e5ce
updated;
doc-src/IsarRef/Makefile
doc-src/IsarRef/basics.tex
doc-src/IsarRef/intro.tex
doc-src/IsarRef/isar-ref.tex
doc-src/IsarRef/pure.tex
doc-src/IsarRef/syntax.tex
     1.1 --- a/doc-src/IsarRef/Makefile	Thu Oct 21 15:57:26 1999 +0200
     1.2 +++ b/doc-src/IsarRef/Makefile	Thu Oct 21 17:42:21 1999 +0200
     1.3 @@ -14,7 +14,7 @@
     1.4  NAME = isar-ref
     1.5  
     1.6  FILES = isar-ref.tex intro.tex basics.tex syntax.tex pure.tex \
     1.7 -	generic.tex hol.tex ../isar.sty \
     1.8 +	generic.tex hol.tex refcard.tex ../isar.sty \
     1.9  	../rail.sty ../railsetup.sty ../proof.sty ../iman.sty ../extra.sty ../manual.bib
    1.10  
    1.11  dvi: $(NAME).dvi
     2.1 --- a/doc-src/IsarRef/basics.tex	Thu Oct 21 15:57:26 1999 +0200
     2.2 +++ b/doc-src/IsarRef/basics.tex	Thu Oct 21 17:42:21 1999 +0200
     2.3 @@ -1,21 +1,22 @@
     2.4  
     2.5  \chapter{Basic Concepts}\label{ch:basics}
     2.6  
     2.7 +\section{Isabelle/Isar theories}
     2.8 +
     2.9  Isabelle/Isar offers two main improvements over classic Isabelle:
    2.10  \begin{enumerate}
    2.11  \item A new \emph{theory format}, occasionally referred to as ``new-style
    2.12 -  theories'', supporting interactive development with unlimited undo
    2.13 -  operation.
    2.14 -\item A \emph{formal proof language} designed to support intelligible
    2.15 -  semi-automated reasoning.  Rather than putting together tactic scripts, the
    2.16 -  author is enabled to express the reasoning in way that is close to
    2.17 -  mathematical practice.
    2.18 +  theories'', supporting interactive development and unlimited undo operation.
    2.19 +\item A \emph{formal proof document language} designed to support intelligible
    2.20 +  semi-automated reasoning.  Instead of putting together unreadable tactic
    2.21 +  scripts, the author is enabled to express the reasoning in way that is close
    2.22 +  to mathematical practice.
    2.23  \end{enumerate}
    2.24  
    2.25  The Isar proof language is embedded into the new theory format as a proper
    2.26  sub-language.  Proof mode is entered by stating some $\THEOREMNAME$ or
    2.27 -$\LEMMANAME$ at the theory level, and left with the conclusion of the proof
    2.28 -(via $\QEDNAME$ etc.).  Some theory extension mechanisms require proof as
    2.29 +$\LEMMANAME$ at the theory level, and left again with the final conclusion
    2.30 +(e.g.\ via $\QEDNAME$).  A few theory extension mechanisms require proof as
    2.31  well, such as the HOL $\isarkeyword{typedef}$ which demands non-emptiness of
    2.32  the representing sets.
    2.33  
    2.34 @@ -29,10 +30,10 @@
    2.35  
    2.36  \begin{warn}
    2.37    Currently Proof~General does \emph{not} support mixed interactive
    2.38 -  development of classic Isabelle theory files and tactic scripts together
    2.39 +  development of classic Isabelle theory files and tactic scripts, together
    2.40    with Isar documents at the same time.  The ``\texttt{isa}'' and
    2.41    ``\texttt{isar}'' versions of Proof~General are handled as two different
    2.42 -  theorem proving systems, only one may be active at the same time.
    2.43 +  theorem proving systems, only one of these may be active.
    2.44  \end{warn}
    2.45  
    2.46  Porting of existing tactic scripts is best done by running two separate
    2.47 @@ -56,7 +57,6 @@
    2.48  
    2.49  \subsection{Attributes}
    2.50  
    2.51 -
    2.52  %%% Local Variables: 
    2.53  %%% mode: latex
    2.54  %%% TeX-master: "isar-ref"
     3.1 --- a/doc-src/IsarRef/intro.tex	Thu Oct 21 15:57:26 1999 +0200
     3.2 +++ b/doc-src/IsarRef/intro.tex	Thu Oct 21 17:42:21 1999 +0200
     3.3 @@ -15,7 +15,8 @@
     3.4  lemma "0 < foo" by (simp add: foo_def);
     3.5  end
     3.6  \end{ttbox}
     3.7 -Note that any Isabelle/Isar command may be retracted by \texttt{undo}.
     3.8 +Note that any Isabelle/Isar command may be retracted by \texttt{undo}; the
     3.9 +\texttt{help} command prints the list of available language elements.
    3.10  
    3.11  Plain TTY-based interaction like this used to be quite feasible with
    3.12  traditional tactic based theorem proving, but developing Isar documents
    3.13 @@ -23,16 +24,17 @@
    3.14    General} of LFCS Edinburgh \cite{proofgeneral} offers a generic Emacs-based
    3.15  environment for interactive theorem provers that does all the cut-and-paste
    3.16  and forward-backward walk through the document in a very neat way.  Note that
    3.17 -in Isabelle/Isar, the current position within a partial proof document is more
    3.18 -informative than the actual proof state.  Thus Proof~General provides the
    3.19 -canonical working environment for Isabelle/Isar, both for getting acquainted
    3.20 -(e.g.\ by replaying existing Isar documents) and serious production work.
    3.21 +in Isabelle/Isar, the current position within a partial proof document is
    3.22 +equally important than the actual proof state.  Thus Proof~General provides
    3.23 +the canonical working environment for Isabelle/Isar, both for getting
    3.24 +acquainted (e.g.\ by replaying existing Isar documents) and real production
    3.25 +work.
    3.26  
    3.27  \medskip
    3.28  
    3.29  The easiest way to use Proof~General is to make it the default Isabelle user
    3.30 -interface.  Just say something like this in your Isabelle settings file (cf.\ 
    3.31 -\cite{isabelle-sys}):
    3.32 +interface.  Just put something like this into your Isabelle settings file (see
    3.33 +also \cite{isabelle-sys}):
    3.34  \begin{ttbox}
    3.35  ISABELLE_INTERFACE=\$ISABELLE_HOME/contrib/ProofGeneral/isar/interface
    3.36  PROOFGENERAL_OPTIONS="-u false"
    3.37 @@ -69,26 +71,28 @@
    3.38  \end{ttbox}
    3.39  Users of XEmacs may note the tool bar for navigating forward and backward
    3.40  through the text.  Consult the Proof~General documentation \cite{proofgeneral}
    3.41 -for further basic commands, like \texttt{c-c return} or \texttt{c-c u}.
    3.42 +for further basic command sequences, like ``\texttt{c-c return}'' or
    3.43 +``\texttt{c-c u}''.
    3.44  
    3.45  \medskip
    3.46  
    3.47 -Occasionally, a user's \texttt{.emacs} contains material that is incompatible
    3.48 -with the version of (X)Emacs that Proof~General prefers.  Then proper startup
    3.49 -may be still achieved by using the \texttt{-u false} option.\footnote{Any
    3.50 -  Emacs lisp file \texttt{proofgeneral-settings.el} occurring in
    3.51 -  \texttt{\$ISABELLE_HOME/etc} or \texttt{\$ISABELLE_HOME_USER/etc} is
    3.52 -  automatically loaded by the Proof~General interface script as well.}
    3.53 +Occasionally, a user's \texttt{.emacs} file contains material that is
    3.54 +incompatible with the version of (X)Emacs that Proof~General prefers.  Then
    3.55 +proper startup may be still achieved by using the \texttt{-u false}
    3.56 +option.\footnote{Any Emacs lisp file \texttt{proofgeneral-settings.el}
    3.57 +  occurring in \texttt{\$ISABELLE_HOME/etc} or
    3.58 +  \texttt{\$ISABELLE_HOME_USER/etc} is automatically loaded by the
    3.59 +  Proof~General interface script as well.}
    3.60  
    3.61  \section{How to write Isar proofs anyway?}
    3.62  
    3.63  This is one of the key questions, of course.  Isar offers a rather different
    3.64  approach to formal proof documents than plain old tactic scripts.  Experienced
    3.65  users of existing interactive theorem proving systems may have to learn
    3.66 -thinking different in order to make effective use of Isabelle/Isar.  On the
    3.67 +thinking differently in order to make effective use of Isabelle/Isar.  On the
    3.68  other hand, Isabelle/Isar comes much closer to existing mathematical practice
    3.69  of formal proof, so users with less experience in old-style tactical proving,
    3.70 -but a good understanding of mathematical proof might cope with Isar even
    3.71 +but a good understanding of mathematical proof, might cope with Isar even
    3.72  better.
    3.73  
    3.74  This document really is a \emph{reference manual}.  Nevertheless, we will give
    3.75 @@ -107,8 +111,8 @@
    3.76    \end{tabular}
    3.77  \end{center}
    3.78  
    3.79 -Apart from browsable HTML sources, both example sessions also provide actual
    3.80 -documents.
    3.81 +Apart from browsable HTML sources, both Isabelle/Isar sessions also provide
    3.82 +actual documents (in PDF).
    3.83  
    3.84  %%% Local Variables: 
    3.85  %%% mode: latex
     4.1 --- a/doc-src/IsarRef/isar-ref.tex	Thu Oct 21 15:57:26 1999 +0200
     4.2 +++ b/doc-src/IsarRef/isar-ref.tex	Thu Oct 21 17:42:21 1999 +0200
     4.3 @@ -20,6 +20,9 @@
     4.4  \railalias{prop}{\railqtoken{prop}}
     4.5  \railalias{atom}{\railqtoken{atom}}
     4.6  
     4.7 +\newcommand{\drv}{\mathrel{\vdash}}
     4.8 +\newcommand{\edrv}{\mathop{\drv}\nolimits}
     4.9 +
    4.10  
    4.11  \setcounter{secnumdepth}{2} \setcounter{tocdepth}{2}
    4.12  
    4.13 @@ -29,6 +32,9 @@
    4.14  
    4.15  \renewcommand{\phi}{\varphi}
    4.16  
    4.17 +%\includeonly{pure}
    4.18 +
    4.19 +
    4.20  
    4.21  \begin{document}
    4.22  
    4.23 @@ -46,15 +52,15 @@
    4.24    immediately ``executable'', by virtue of the \emph{Isar/VM} interpreter.
    4.25    
    4.26    The current version of Isabelle offers Isar as an alternative proof language
    4.27 -  interface layer, beyond traditional tactic scripts.  The Isabelle/Isar
    4.28 -  system provides an interpreter for the Isar formal proof document language.
    4.29 -  Isabelle/Isar input may consist either of \emph{proper document
    4.30 -    constructors}, or \emph{improper auxiliary commands} (for diagnostics,
    4.31 -  exploration etc.).  Proof texts consisting of proper document constructors
    4.32 -  only, admit a purely static reading, thus being intelligible later without
    4.33 -  requiring dynamic replay that is so typical for traditional proof scripts.
    4.34 -  Any of the Isabelle/Isar commands may be executed in single-steps, so
    4.35 -  basically the interpreter has a proof text debugger already built-in.
    4.36 +  interface layer.  The Isabelle/Isar system provides an interpreter for the
    4.37 +  Isar formal proof document language.  The input may consist either of
    4.38 +  \emph{proper document constructors}, or \emph{improper auxiliary commands}
    4.39 +  (for diagnostics, exploration etc.).  Proof texts consisting of proper
    4.40 +  document constructors only, admit a purely static reading, thus being
    4.41 +  intelligible later without requiring dynamic replay that is so typical for
    4.42 +  traditional proof scripts.  Any of the Isabelle/Isar commands may be
    4.43 +  executed in single-steps, so basically the interpreter has a proof text
    4.44 +  debugger already built-in.
    4.45    
    4.46    Employing the Isar instantiation of \emph{Proof~General}, the generic Emacs
    4.47    interface for interactive proof assistants of LFCS Edinburgh, we arrive at a
    4.48 @@ -65,10 +71,10 @@
    4.49    
    4.50    The Isar subsystem is tightly integrated into the Isabelle/Pure meta-logic
    4.51    implementation.  Theories, theorems, proof procedures etc.\ may be used
    4.52 -  interchangeably between Isabelle-classic proof scripts and Isabelle/Isar
    4.53 +  interchangeably between classic Isabelle proof scripts and Isabelle/Isar
    4.54    documents.  Isar is as generic as Isabelle, able to support a wide range of
    4.55 -  object-logics.  The current working environment for end-users is setup
    4.56 -  mainly for Isabelle/HOL.
    4.57 +  object-logics.  Currently, the end-user working environment is most complete
    4.58 +  for Isabelle/HOL.
    4.59  \end{abstract}
    4.60  
    4.61  \pagenumbering{roman} \tableofcontents \clearfirst
    4.62 @@ -89,6 +95,9 @@
    4.63  \include{generic}
    4.64  \include{hol}
    4.65  
    4.66 +\appendix
    4.67 +\include{refcard}
    4.68 +
    4.69  \begingroup
    4.70    \bibliographystyle{plain} \small\raggedright\frenchspacing
    4.71    \bibliography{../manual}
     5.1 --- a/doc-src/IsarRef/pure.tex	Thu Oct 21 15:57:26 1999 +0200
     5.2 +++ b/doc-src/IsarRef/pure.tex	Thu Oct 21 17:42:21 1999 +0200
     5.3 @@ -1,12 +1,12 @@
     5.4  
     5.5 -\chapter{Basic Isar Elements}\label{ch:pure-syntax}
     5.6 +\chapter{Basic Isar Language Elements}\label{ch:pure-syntax}
     5.7  
     5.8  Subsequently, we introduce the main part of the basic Isar theory and proof
     5.9  commands as provided by Isabelle/Pure.  Chapter~\ref{ch:gen-tools} describes
    5.10 -further Isar elements as provided by generic tools and packages (such as the
    5.11 -Simplifier) that are either part of Pure Isabelle, or pre-loaded by most
    5.12 -object logics.  See chapter~\ref{ch:hol-tools} for actual object-logic
    5.13 -specific elements (for Isabelle/HOL).
    5.14 +further Isar elements provided by generic tools and packages (such as the
    5.15 +Simplifier) that are either part of Pure Isabelle or pre-loaded by most object
    5.16 +logics.  Chapter~\ref{ch:hol-tools} refers to actual object-logic specific
    5.17 +elements of Isabelle/HOL.
    5.18  
    5.19  \medskip
    5.20  
    5.21 @@ -24,8 +24,9 @@
    5.22  
    5.23  \subsection{Defining theories}\label{sec:begin-thy}
    5.24  
    5.25 -\indexisarcmd{theory}\indexisarcmd{end}\indexisarcmd{context}
    5.26 +\indexisarcmd{header}\indexisarcmd{theory}\indexisarcmd{end}\indexisarcmd{context}
    5.27  \begin{matharray}{rcl}
    5.28 +  \isarcmd{header} & : & \isarkeep{toplevel} \\
    5.29    \isarcmd{theory} & : & \isartrans{\cdot}{theory} \\
    5.30    \isarcmd{context}^* & : & \isartrans{\cdot}{theory} \\
    5.31    \isarcmd{end} & : & \isartrans{theory}{\cdot} \\
    5.32 @@ -37,13 +38,18 @@
    5.33  proof as well.  In contrast, ``old-style'' Isabelle theories support batch
    5.34  processing only, with the proof scripts collected in separate ML files.
    5.35  
    5.36 -The first command of any theory has to be $\THEORY$, starting a new theory
    5.37 -based on the merge of existing ones.  The theory context may be also changed
    5.38 -by $\CONTEXT$ without creating a new theory.  In both cases, $\END$ concludes
    5.39 -the theory development; it has to be the very last command of any proper
    5.40 -theory file.
    5.41 +The first actual command of any theory has to be $\THEORY$, starting a new
    5.42 +theory based on the merge of existing ones.  Just preceding $\THEORY$, there
    5.43 +may be an optional $\isarkeyword{header}$ declaration, which is relevant to
    5.44 +document preparation only; it acts very much like a special pre-theory markup
    5.45 +command (cf.\ \S\ref{sec:markup-thy} and \S\ref{sec:markup-thy}).  The theory
    5.46 +context may be also changed by $\CONTEXT$ without creating a new theory.  In
    5.47 +both cases, $\END$ concludes the theory development; it has to be the very
    5.48 +last command in a theory file.
    5.49  
    5.50  \begin{rail}
    5.51 +  'header' text
    5.52 +  ;
    5.53    'theory' name '=' (name + '+') filespecs? ':'
    5.54    ;
    5.55    'context' name
    5.56 @@ -55,6 +61,12 @@
    5.57  \end{rail}
    5.58  
    5.59  \begin{descr}
    5.60 +\item [$\isarkeyword{header}~text$] provides plain text markup just preceding
    5.61 +  the formal begin of a theory.  In actual document preparation the
    5.62 +  corresponding {\LaTeX} macro \verb,\isamarkupheader, may be redefined to
    5.63 +  produce chapter or section headings.  See also \S\ref{sec:markup-thy} and
    5.64 +  \S\ref{sec:markup-prf} for further markup commands.
    5.65 +  
    5.66  \item [$\THEORY~A = B@1 + \cdots + B@n$] commences a new theory $A$ based on
    5.67    existing ones $B@1 + \cdots + B@n$.  Isabelle's theory loader system ensures
    5.68    that any of the base theories are properly loaded (and fully up-to-date when
    5.69 @@ -65,64 +77,70 @@
    5.70    associated with any theory should \emph{not} be included in
    5.71    $\isarkeyword{files}$.
    5.72    
    5.73 -\item [$\CONTEXT~B$] enters an existing theory context $B$, basically in
    5.74 -  read-only mode, so only a limited set of commands may be performed.  Just as
    5.75 -  for $\THEORY$, the theory loader ensures that $B$ is loaded and up-to-date.
    5.76 +\item [$\CONTEXT~B$] enters an existing theory context, basically in read-only
    5.77 +  mode, so only a limited set of commands may be performed.  Just as for
    5.78 +  $\THEORY$, the theory loader ensures that $B$ is loaded and up-to-date.
    5.79    
    5.80  \item [$\END$] concludes the current theory definition or context switch.
    5.81 -  Note that this command cannot be undone, instead the theory definition
    5.82 -  itself has to be retracted.
    5.83 +  Note that this command cannot be undone, instead the whole theory definition
    5.84 +  has to be retracted.
    5.85  \end{descr}
    5.86  
    5.87  
    5.88 -\subsection{Formal comments}\label{sec:formal-cmt-thy}
    5.89 +\subsection{Theory markup commands}\label{sec:markup-thy}
    5.90  
    5.91 -\indexisarcmd{title}\indexisarcmd{chapter}\indexisarcmd{section}\indexisarcmd{subsection}
    5.92 -\indexisarcmd{subsubsection}\indexisarcmd{text}
    5.93 +\indexisarcmd{chapter}\indexisarcmd{section}\indexisarcmd{subsection}
    5.94 +\indexisarcmd{subsubsection}\indexisarcmd{text}\indexisarcmd{text-raw}
    5.95  \begin{matharray}{rcl}
    5.96 -  \isarcmd{title} & : & \isartrans{theory}{theory} \\
    5.97    \isarcmd{chapter} & : & \isartrans{theory}{theory} \\
    5.98    \isarcmd{section} & : & \isartrans{theory}{theory} \\
    5.99    \isarcmd{subsection} & : & \isartrans{theory}{theory} \\
   5.100    \isarcmd{subsubsection} & : & \isartrans{theory}{theory} \\
   5.101    \isarcmd{text} & : & \isartrans{theory}{theory} \\
   5.102 +  \isarcmd{text_raw} & : & \isartrans{theory}{theory} \\
   5.103  \end{matharray}
   5.104  
   5.105 -There are several commands to include \emph{formal comments} in theory
   5.106 -specification (a few more are available for proofs, see
   5.107 -\S\ref{sec:formal-cmt-prf}).  In contrast to source-level comments
   5.108 -\verb|(*|\dots\verb|*)|, which are stripped at the lexical level, any text
   5.109 -given as formal comment is meant to be part of the actual document.
   5.110 -Consequently, it would be included in the final printed version.
   5.111 +Apart from formal comments (see \S\ref{sec:comments}), markup commands provide
   5.112 +another way to insert text into the document generated from a theory (see
   5.113 +\cite{isabelle-sys} for more information on Isabelle's document preparation
   5.114 +tools).
   5.115  
   5.116 -Apart from plain prose, formal comments may also refer to logical entities of
   5.117 -the theory context (types, terms, theorems etc.).  Proper processing of the
   5.118 -text would then include some further consistency checks with the items
   5.119 -declared in the current theory, e.g.\ type-checking of included
   5.120 -terms.\footnote{The current version of Isabelle/Isar does not process formal
   5.121 -  comments in any such way.  This will be available as part of the automatic
   5.122 -  theory and proof document preparation system (using (PDF){\LaTeX}) that is
   5.123 -  planned for the near future.}
   5.124 +\railalias{textraw}{text\_raw}
   5.125 +\railterm{textraw}
   5.126  
   5.127  \begin{rail}
   5.128 -  'title' text text? text?
   5.129 -  ;
   5.130 -  ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text') text
   5.131 +  ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text' | textraw) text
   5.132    ;
   5.133  \end{rail}
   5.134  
   5.135  \begin{descr}
   5.136 -\item [$\isarkeyword{title}~title~author~date$] specifies the document title
   5.137 -  just as in typical {\LaTeX} documents.
   5.138  \item [$\isarkeyword{chapter}$, $\isarkeyword{section}$,
   5.139    $\isarkeyword{subsection}$, and $\isarkeyword{subsubsection}$] mark chapter
   5.140    and section headings.
   5.141 -\item [$\TEXT$] specifies an actual body of prose text, including references
   5.142 -  to formal entities.\footnote{The latter feature is not yet exploited.
   5.143 -    Nevertheless, any text of the form \texttt{\at\ttlbrace\dots\ttrbrace}
   5.144 -    should be considered as reserved for future use.}
   5.145 +\item [$\TEXT$] specifies paragraphs of plain text, including references to
   5.146 +  formal entities.\footnote{The latter feature is not yet supported.
   5.147 +    Nevertheless, any source text of the form
   5.148 +    ``\texttt{\at\ttlbrace$\dots$\ttrbrace}'' should be considered as reserved
   5.149 +    for future use.}
   5.150 +\item [$\isarkeyword{text_raw}$] inserts {\LaTeX} source into the output,
   5.151 +  without additional markup.  Thus the full range of document manipulations
   5.152 +  becomes available.  A typical application would be to emit
   5.153 +  \verb,\begin{comment}, and \verb,\end{comment}, commands to exclude certain
   5.154 +  parts from the final document.\footnote{This requires the \texttt{comment}
   5.155 +    {\LaTeX} package to be included}
   5.156  \end{descr}
   5.157  
   5.158 +Any markup command (except $\isarkeyword{text_raw}$) corresponds to a {\LaTeX}
   5.159 +macro with the name derived from \verb,\isamarkup, (e.g.\ 
   5.160 +\verb,\isamarkupchapter, for $\isarkeyword{chapter}$). The \railqtoken{text}
   5.161 +argument is passed to that macro unchanged, i.e.\ any {\LaTeX} commands may be
   5.162 +included here.
   5.163 +
   5.164 +\medskip Further markup commands are available for proofs (see
   5.165 +\S\ref{sec:markup-prf}).  Also note that the $\isarkeyword{header}$
   5.166 +declaration (see \S\ref{sec:begin-thy}) admits to insert document markup
   5.167 +elements just preceding the actual theory definition.
   5.168 +
   5.169  
   5.170  \subsection{Type classes and sorts}\label{sec:classes}
   5.171  
   5.172 @@ -147,10 +165,10 @@
   5.173    of existing classes $\vec c$.  Cyclic class structures are ruled out.
   5.174  \item [$\isarkeyword{classrel}~c@1<c@2$] states a subclass relation between
   5.175    existing classes $c@1$ and $c@2$.  This is done axiomatically!  The
   5.176 -  $\isarkeyword{instance}$ command (see \S\ref{sec:axclass}) provides a way
   5.177 +  $\isarkeyword{instance}$ command (see \S\ref{sec:axclass}) provides a way to
   5.178    introduce proven class relations.
   5.179  \item [$\isarkeyword{defaultsort}~s$] makes sort $s$ the new default sort for
   5.180 -  any type variables input without sort constraints.  Usually, the default
   5.181 +  any type variables given without sort constraints.  Usually, the default
   5.182    sort would be only changed when defining new logics.
   5.183  \end{descr}
   5.184  
   5.185 @@ -180,19 +198,19 @@
   5.186  \item [$\TYPES~(\vec\alpha)t = \tau$] introduces \emph{type synonym}
   5.187    $(\vec\alpha)t$ for existing type $\tau$.  Unlike actual type definitions,
   5.188    as are available in Isabelle/HOL for example, type synonyms are just purely
   5.189 -  syntactic abbreviations, without any logical significance.  Internally, type
   5.190 +  syntactic abbreviations without any logical significance.  Internally, type
   5.191    synonyms are fully expanded, as may be observed when printing terms or
   5.192    theorems.
   5.193  \item [$\isarkeyword{typedecl}~(\vec\alpha)t$] declares a new type constructor
   5.194 -  $t$, intended as an actual logical type.  Note that some logics such as
   5.195 -  Isabelle/HOL provide their own version of $\isarkeyword{typedecl}$.
   5.196 +  $t$, intended as an actual logical type.  Note that object-logics such as
   5.197 +  Isabelle/HOL override $\isarkeyword{typedecl}$ by their own version.
   5.198  \item [$\isarkeyword{nonterminals}~\vec c$] declares $0$-ary type constructors
   5.199    $\vec c$ to act as purely syntactic types, i.e.\ nonterminal symbols of
   5.200    Isabelle's inner syntax of terms or types.
   5.201  \item [$\isarkeyword{arities}~t::(\vec s)s$] augments Isabelle's order-sorted
   5.202    signature of types by new type constructor arities.  This is done
   5.203    axiomatically!  The $\isarkeyword{instance}$ command (see
   5.204 -  \S\ref{sec:axclass}) provides a way introduce proven type arities.
   5.205 +  \S\ref{sec:axclass}) provides a way to introduce proven type arities.
   5.206  \end{descr}
   5.207  
   5.208  
   5.209 @@ -220,7 +238,7 @@
   5.210  \begin{descr}
   5.211  \item [$\CONSTS~c::\sigma$] declares constant $c$ to have any instance of type
   5.212    scheme $\sigma$.  The optional mixfix annotations may attach concrete syntax
   5.213 -  constants.
   5.214 +  to the constants declared.
   5.215  \item [$\DEFS~name: eqn$] introduces $eqn$ as a definitional axiom for some
   5.216    existing constant.  See \cite[\S6]{isabelle-ref} for more details on the
   5.217    form of equations admitted as constant definitions.
   5.218 @@ -256,9 +274,9 @@
   5.219    \texttt{output} flag given, all productions are added both to the input and
   5.220    output grammar.
   5.221  \item [$\isarkeyword{translations}~rules$] specifies syntactic translation
   5.222 -  rules (also known as \emph{macros}): parse/print rules (\texttt{==}), parse
   5.223 -  rules (\texttt{=>}), or print rules (\texttt{<=}).  Translation patterns may
   5.224 -  be prefixed by the syntactic category to be used for parsing; the default is
   5.225 +  rules (i.e.\ \emph{macros}): parse/print rules (\texttt{==}), parse rules
   5.226 +  (\texttt{=>}), or print rules (\texttt{<=}).  Translation patterns may be
   5.227 +  prefixed by the syntactic category to be used for parsing; the default is
   5.228    \texttt{logic}.
   5.229  \end{descr}
   5.230  
   5.231 @@ -281,8 +299,8 @@
   5.232  
   5.233  \begin{descr}
   5.234  \item [$\isarkeyword{axioms}~a: \phi$] introduces arbitrary statements as
   5.235 -  logical axioms.  In fact, axioms are ``axiomatic theorems'', and may be
   5.236 -  referred later just as any other theorem.
   5.237 +  axioms of the meta-logic.  In fact, axioms are ``axiomatic theorems'', and
   5.238 +  may be referred later just as any other theorem.
   5.239    
   5.240    Axioms are usually only introduced when declaring new logical systems.
   5.241    Everyday work is typically done the hard way, with proper definitions and
   5.242 @@ -303,35 +321,37 @@
   5.243    \isarcmd{local} & : & \isartrans{theory}{theory} \\
   5.244  \end{matharray}
   5.245  
   5.246 -Isabelle organizes any kind of names (of types, constants, theorems etc.)  by
   5.247 -hierarchically structured name spaces.  Normally the user never has to control
   5.248 -the behavior of name space entry by hand, yet the following commands provide
   5.249 -some way to do so.
   5.250 +Isabelle organizes any kind of name declarations (of types, constants,
   5.251 +theorems etc.)  by hierarchically structured name spaces.  Normally the user
   5.252 +never has to control the behavior of name space entry by hand, yet the
   5.253 +following commands provide some way to do so.
   5.254  
   5.255  \begin{descr}
   5.256  \item [$\isarkeyword{global}$ and $\isarkeyword{local}$] change the current
   5.257    name declaration mode.  Initially, theories start in $\isarkeyword{local}$
   5.258    mode, causing all names to be automatically qualified by the theory name.
   5.259 -  Changing this to $\isarkeyword{global}$ causes all names to be declared as
   5.260 -  base names only, until $\isarkeyword{local}$ is declared again.
   5.261 +  Changing this to $\isarkeyword{global}$ causes all names to be declared
   5.262 +  without the theory prefix, until $\isarkeyword{local}$ is declared again.
   5.263  \end{descr}
   5.264  
   5.265  
   5.266  \subsection{Incorporating ML code}\label{sec:ML}
   5.267  
   5.268 -\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{setup}
   5.269 +\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{ML-setup}\indexisarcmd{setup}
   5.270  \begin{matharray}{rcl}
   5.271    \isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\
   5.272    \isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\
   5.273 +  \isarcmd{ML_setup} & : & \isartrans{theory}{theory} \\
   5.274    \isarcmd{setup} & : & \isartrans{theory}{theory} \\
   5.275  \end{matharray}
   5.276  
   5.277 +\railalias{MLsetup}{ML\_setup}
   5.278 +\railterm{MLsetup}
   5.279 +
   5.280  \begin{rail}
   5.281    'use' name
   5.282    ;
   5.283 -  'ML' text
   5.284 -  ;
   5.285 -  'setup' text
   5.286 +  ('ML' | MLsetup | 'setup') text
   5.287    ;
   5.288  \end{rail}
   5.289  
   5.290 @@ -342,13 +362,18 @@
   5.291    $\isarkeyword{files}$ dependency declaration given in the theory header (see
   5.292    also \S\ref{sec:begin-thy}).
   5.293    
   5.294 -\item [$\isarkeyword{ML}~text$] reads and executes ML commands from $text$.
   5.295 -  The theory context is passed in the same way as for $\isarkeyword{use}$.
   5.296 -
   5.297 +\item [$\isarkeyword{ML}~text$] executes ML commands from $text$.  The theory
   5.298 +  context is passed in the same way as for $\isarkeyword{use}$.
   5.299 +  
   5.300 +\item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$.  The
   5.301 +  theory context is passed down to the ML session, and fetched back
   5.302 +  afterwards.  Thus $text$ may actually change the theory as a side effect.
   5.303 +  
   5.304  \item [$\isarkeyword{setup}~text$] changes the current theory context by
   5.305 -  applying setup functions $text$, which has to be an ML expression of type
   5.306 -  $(theory \to theory)~list$.  The $\isarkeyword{setup}$ command is the usual
   5.307 -  way to initialize object-logic specific tools and packages written in ML.
   5.308 +  applying setup functions from $text$, which has to refer to an ML expression
   5.309 +  of type $(theory \to theory)~list$.  The $\isarkeyword{setup}$ command is
   5.310 +  the canonical way to initialize object-logic specific tools and packages
   5.311 +  written in ML.
   5.312  \end{descr}
   5.313  
   5.314  
   5.315 @@ -406,30 +431,36 @@
   5.316  \begin{descr}
   5.317  \item [$proof(prove)$] means that a new goal has just been stated that is now
   5.318    to be \emph{proven}; the next command may refine it by some proof method
   5.319 -  ($\approx$ tactic), and enter a sub-proof to establish the final result.
   5.320 +  (read: tactic), and enter a sub-proof to establish the actual result.
   5.321  \item [$proof(state)$] is like an internal theory mode: the context may be
   5.322    augmented by \emph{stating} additional assumptions, intermediate result etc.
   5.323 -\item [$proof(chain)$] is an intermediate mode between $proof(state)$ and
   5.324 +\item [$proof(chain)$] is intermediate between $proof(state)$ and
   5.325    $proof(prove)$: existing facts (i.e.\ the contents of $this$) have been just
   5.326 -  picked up in order to use them when refining the goal claimed next.
   5.327 +  picked up in order to be used when refining the goal claimed next.
   5.328  \end{descr}
   5.329  
   5.330  
   5.331 -\subsection{Formal comments}\label{sec:formal-cmt-prf}
   5.332 +\subsection{Proof markup commands}\label{sec:markup-prf}
   5.333  
   5.334 -\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsect}\indexisarcmd{txt}
   5.335 +\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsect}
   5.336 +\indexisarcmd{txt}\indexisarcmd{txt-raw}
   5.337  \begin{matharray}{rcl}
   5.338    \isarcmd{sect} & : & \isartrans{proof(state)}{proof(state)} \\
   5.339    \isarcmd{subsect} & : & \isartrans{proof(state)}{proof(state)} \\
   5.340    \isarcmd{subsubsect} & : & \isartrans{proof(state)}{proof(state)} \\
   5.341    \isarcmd{txt} & : & \isartrans{proof(state)}{proof(state)} \\
   5.342 +  \isarcmd{txt_raw} & : & \isartrans{proof(state)}{proof(state)} \\
   5.343  \end{matharray}
   5.344  
   5.345 -These formal comments in proof mode closely correspond to the ones of theory
   5.346 -mode (see \S\ref{sec:formal-cmt-thy}).
   5.347 +These markup commands for proof mode closely correspond to the ones of theory
   5.348 +mode (see \S\ref{sec:markup-thy}).  Note that $\isarkeyword{txt_raw}$ is
   5.349 +special in the same way as $\isarkeyword{text_raw}$.
   5.350 +
   5.351 +\railalias{txtraw}{txt\_raw}
   5.352 +\railterm{txtraw}
   5.353  
   5.354  \begin{rail}
   5.355 -  ('sect' | 'subsect' | 'subsubsect' | 'txt') text
   5.356 +  ('sect' | 'subsect' | 'subsubsect' | 'txt' | txtraw) text
   5.357    ;
   5.358  \end{rail}
   5.359  
   5.360 @@ -449,24 +480,25 @@
   5.361  quantification as provided by the Isabelle/Pure logical framework.
   5.362  Introducing some \emph{arbitrary, but fixed} variable via $\FIX x$ results in
   5.363  a local object that may be used in the subsequent proof as any other variable
   5.364 -or constant.  Furthermore, any result $\phi[x]$ exported from the current
   5.365 -context will be universally closed wrt.\ $x$ at the outermost level (this is
   5.366 -expressed using Isabelle's meta-variables).
   5.367 +or constant.  Furthermore, any result $\edrv \phi[x]$ exported from the
   5.368 +current context will be universally closed wrt.\ $x$ at the outermost level:
   5.369 +$\edrv \All x \phi$; this is expressed using Isabelle's meta-variables.
   5.370  
   5.371  Similarly, introducing some assumption $\chi$ has two effects.  On the one
   5.372  hand, a local theorem is created that may be used as a fact in subsequent
   5.373 -proof steps.  On the other hand, any result $\phi$ exported from the context
   5.374 -becomes conditional wrt.\ the assumption.  Thus, solving an enclosing goal
   5.375 -using such a result would basically introduce a new subgoal stemming from the
   5.376 -assumption.  How this situation is handled depends on the actual version of
   5.377 -assumption command used: while $\ASSUMENAME$ solves the subgoal by unifying
   5.378 -with some premise of the goal, $\PRESUMENAME$ leaves the subgoal unchanged to
   5.379 -be proved later by the user.
   5.380 +proof steps.  On the other hand, any result $\chi \drv \phi$ exported from the
   5.381 +context becomes conditional wrt.\ the assumption: $\edrv \chi \Imp \phi$.
   5.382 +Thus, solving an enclosing goal using such a result would basically introduce
   5.383 +a new subgoal stemming from the assumption.  How this situation is handled
   5.384 +depends on the actual version of assumption command used: while $\ASSUMENAME$
   5.385 +insists on solving the subgoal by unification with some premise of the goal,
   5.386 +$\PRESUMENAME$ leaves the subgoal unchanged in order to be proved later by the
   5.387 +user.
   5.388  
   5.389  Local definitions, introduced by $\DEF{}{x \equiv t}$, are achieved by
   5.390  combining $\FIX x$ with another kind of assumption that causes any
   5.391 -hypothetical equation $x = t$ to be eliminated by reflexivity.  Thus,
   5.392 -exporting some result $\phi[x]$ simply yields $\phi[t]$.
   5.393 +hypothetical equation $x \equiv t$ to be eliminated by reflexivity.  Thus,
   5.394 +exporting some result $x \equiv t \drv \phi[x]$ yields $\edrv \phi[t]$.
   5.395  
   5.396  \begin{rail}
   5.397    'fix' (vars + 'and') comment?
   5.398 @@ -488,13 +520,13 @@
   5.399  \item [$\FIX{x}$] introduces a local \emph{arbitrary, but fixed} variable $x$.
   5.400  \item [$\ASSUME{a}{\Phi}$ and $\PRESUME{a}{\Phi}$] introduce local theorems
   5.401    $\Phi$ by assumption.  Subsequent results applied to an enclosing goal
   5.402 -  (e.g.\ via $\SHOWNAME$) are handled as follows: $\ASSUMENAME$ expects to be
   5.403 +  (e.g.\ by $\SHOWNAME$) are handled as follows: $\ASSUMENAME$ expects to be
   5.404    able to unify with existing premises in the goal, while $\PRESUMENAME$
   5.405    leaves $\Phi$ as new subgoals.
   5.406    
   5.407    Several lists of assumptions may be given (separated by
   5.408 -  $\isarkeyword{and}$); the resulting list of facts consists of all of these
   5.409 -  concatenated.
   5.410 +  $\isarkeyword{and}$); the resulting list of current facts consists of all of
   5.411 +  these concatenated.
   5.412  \item [$\DEF{a}{x \equiv t}$] introduces a local (non-polymorphic) definition.
   5.413    In results exported from the context, $x$ is replaced by $t$.  Basically,
   5.414    $\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\PRESUME{}{x \equiv t}$, with the
   5.415 @@ -503,8 +535,8 @@
   5.416    The default name for the definitional equation is $x_def$.
   5.417  \end{descr}
   5.418  
   5.419 -The special theorem name $prems$\indexisarthm{prems} refers to all current
   5.420 -assumptions.
   5.421 +The special name $prems$\indexisarthm{prems} refers to all assumptions of the
   5.422 +current context as a list of theorems.
   5.423  
   5.424  
   5.425  \subsection{Facts and forward chaining}
   5.426 @@ -536,10 +568,12 @@
   5.427    as $a$.  Note that attributes may be involved as well, both on the left and
   5.428    right hand sides.
   5.429  \item [$\THEN$] indicates forward chaining by the current facts in order to
   5.430 -  establish the goal claimed next.  The initial proof method invoked to refine
   5.431 -  that will be offered these facts to do ``anything appropriate'' (see also
   5.432 -  \S\ref{sec:proof-steps}).  For example, method $rule$ (see
   5.433 -  \S\ref{sec:pure-meth}) would do an elimination rather than an introduction.
   5.434 +  establish the goal to be claimed next.  The initial proof method invoked to
   5.435 +  refine that will be offered the facts to do ``anything appropriate'' (cf.\ 
   5.436 +  also \S\ref{sec:proof-steps}).  For example, method $rule$ (see
   5.437 +  \S\ref{sec:pure-meth}) would typically do an elimination rather than an
   5.438 +  introduction.  Automatic methods usually insert the facts into the goal
   5.439 +  state before operation.
   5.440  \item [$\FROM{\vec b}$] abbreviates $\NOTE{}{\vec b}~\THEN$; thus $\THEN$ is
   5.441    equivalent to $\FROM{this}$.
   5.442  \item [$\WITH{\vec b}$] abbreviates $\FROM{\vec b~facts}$; thus the forward
   5.443 @@ -547,11 +581,11 @@
   5.444  \end{descr}
   5.445  
   5.446  Basic proof methods (such as $rule$, see \S\ref{sec:pure-meth}) expect
   5.447 -multiple facts to be given in proper order, corresponding to a prefix of the
   5.448 -premises of the rule involved.  Note that positions may be easily skipped
   5.449 +multiple facts to be given in their proper order, corresponding to a prefix of
   5.450 +the premises of the rule involved.  Note that positions may be easily skipped
   5.451  using a form like $\FROM{\text{\texttt{_}}~a~b}$, for example.  This involves
   5.452 -the rule $\PROP\psi \Imp \PROP\psi$, which is bound in Isabelle/Pure as
   5.453 -``\texttt{_}'' (underscore).\indexisarthm{_@\texttt{_}}
   5.454 +the trivial rule $\PROP\psi \Imp \PROP\psi$, which is bound in Isabelle/Pure
   5.455 +as ``\texttt{_}'' (underscore).\indexisarthm{_@\texttt{_}}
   5.456  
   5.457  
   5.458  \subsection{Goal statements}
   5.459 @@ -568,9 +602,9 @@
   5.460  \end{matharray}
   5.461  
   5.462  Proof mode is entered from theory mode by initial goal commands $\THEOREMNAME$
   5.463 -and $\LEMMANAME$.  New local goals may be claimed within proof mode: four
   5.464 -variants are available, indicating whether the result is meant to solve some
   5.465 -pending goal and whether forward chaining is employed.
   5.466 +and $\LEMMANAME$.  New local goals may be claimed within proof mode as well.
   5.467 +Four variants are available, indicating whether the result is meant to solve
   5.468 +some pending goal and whether forward chaining is employed.
   5.469  
   5.470  \begin{rail}
   5.471    ('theorem' | 'lemma') goal
   5.472 @@ -584,19 +618,19 @@
   5.473  
   5.474  \begin{descr}
   5.475  \item [$\THEOREM{a}{\phi}$] enters proof mode with $\phi$ as main goal,
   5.476 -  eventually resulting in some theorem $\turn \phi$, and put back into the
   5.477 -  theory.
   5.478 +  eventually resulting in some theorem $\turn \phi$ put back into the theory.
   5.479  \item [$\LEMMANAME$] is similar to $\THEOREMNAME$, but tags the result as
   5.480    ``lemma''.
   5.481  \item [$\HAVE{a}{\phi}$] claims a local goal, eventually resulting in a
   5.482    theorem with the current assumption context as hypotheses.
   5.483  \item [$\SHOW{a}{\phi}$] is similar to $\HAVE{a}{\phi}$, but solves some
   5.484 -  pending goal with the result \emph{exported} into the corresponding context.
   5.485 -\item [$\HENCE{a}{\phi}$] abbreviates $\THEN~\HAVE{a}{\phi}$, i.e.\ claims a
   5.486 -  local goal to be proven by forward chaining the current facts.  Note that
   5.487 -  $\HENCENAME$ is equivalent to $\FROM{this}~\HAVENAME$.
   5.488 -\item [$\THUS{a}{\phi}$] abbreviates $\THEN~\SHOW{a}{\phi}$.  Note that
   5.489 -  $\THUSNAME$ is equivalent to $\FROM{this}~\SHOWNAME$.
   5.490 +  pending goal with the result \emph{exported} into the corresponding context
   5.491 +  (cf.\ \S\ref{sec:proof-context}).
   5.492 +\item [$\HENCENAME$] abbreviates $\THEN~\HAVENAME$, i.e.\ claims a local goal
   5.493 +  to be proven by forward chaining the current facts.  Note that $\HENCENAME$
   5.494 +  is also equivalent to $\FROM{this}~\HAVENAME$.
   5.495 +\item [$\THUSNAME$] abbreviates $\THEN~\SHOWNAME$.  Note that $\THUSNAME$ is
   5.496 +  also equivalent to $\FROM{this}~\SHOWNAME$.
   5.497  \end{descr}
   5.498  
   5.499  
   5.500 @@ -618,7 +652,7 @@
   5.501  \begin{enumerate}
   5.502  \item An \emph{initial} refinement step $\PROOF{m@1}$ reduces a newly stated
   5.503    goal to a number of sub-goals that are to be solved later.  Facts are passed
   5.504 -  to $m@1$ for forward chaining if so indicated by $proof(chain)$ mode.
   5.505 +  to $m@1$ for forward chaining, if so indicated by $proof(chain)$ mode.
   5.506    
   5.507  \item A \emph{terminal} conclusion step $\QED{m@2}$ solves any remaining goals
   5.508    completely.  No facts are passed to $m@2$.
   5.509 @@ -630,20 +664,20 @@
   5.510  \medskip
   5.511  
   5.512  Also note that initial proof methods should either solve the goal completely,
   5.513 -or constitute some well-understood deterministic reduction to new sub-goals.
   5.514 -Arbitrary automatic proof tools that are prone leave a large number of badly
   5.515 -structured sub-goals are no help in continuing the proof document in any
   5.516 -intelligible way.  A much better technique would be to $\SHOWNAME$ some
   5.517 -non-trivial reduction as an explicit rule, which is solved completely by some
   5.518 -automated method, and then applied to some pending goal.
   5.519 +or constitute some well-understood reduction to new sub-goals.  Arbitrary
   5.520 +automatic proof tools that are prone leave a large number of badly structured
   5.521 +sub-goals are no help in continuing the proof document in any intelligible
   5.522 +way.  A much better technique would be to $\SHOWNAME$ some non-trivial
   5.523 +reduction as an explicit rule, which is solved completely by some automated
   5.524 +method, and then applied to some pending goal.
   5.525  
   5.526  \medskip
   5.527  
   5.528  Unless given explicitly by the user, the default initial method is
   5.529  ``$default$'', which is usually set up to apply a single standard elimination
   5.530  or introduction rule according to the topmost symbol involved.  There is no
   5.531 -default terminal method; in any case the final step is to solve all remaining
   5.532 -goals by assumption.
   5.533 +separate default terminal method; in any case the final step is to solve all
   5.534 +remaining goals by assumption, though.
   5.535  
   5.536  \begin{rail}
   5.537    'proof' interest? meth? comment?
   5.538 @@ -663,27 +697,31 @@
   5.539  \item [$\PROOF{m@1}$] refines the goal by proof method $m@1$; facts for
   5.540    forward chaining are passed if so indicated by $proof(chain)$ mode.
   5.541  \item [$\QED{m@2}$] refines any remaining goals by proof method $m@2$ and
   5.542 -  concludes the sub-proof.  If the goal had been $\SHOWNAME$ (or $\THUSNAME$),
   5.543 -  some pending sub-goal is solved as well by the rule resulting from the
   5.544 -  result exported to the enclosing goal context.  Thus $\QEDNAME$ may fail for
   5.545 -  two reasons: either $m@2$ fails to solve all remaining goals completely, or
   5.546 -  the resulting rule does not resolve with any enclosing goal.  Debugging such
   5.547 -  a situation might involve temporarily changing $\SHOWNAME$ into $\HAVENAME$,
   5.548 -  or softening the local context by replacing $\ASSUMENAME$ by $\PRESUMENAME$.
   5.549 -\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}; it abbreviates
   5.550 -  $\PROOF{m@1}~\QED{m@2}$, with automatic backtracking across both methods.
   5.551 -  Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done by simply
   5.552 -  expanding the abbreviation by hand; note that $\PROOF{m@1}$ is usually
   5.553 +  concludes the sub-proof by assumption.  If the goal had been $\SHOWNAME$ (or
   5.554 +  $\THUSNAME$), some pending sub-goal is solved as well by the rule resulting
   5.555 +  from the result \emph{exported} into the enclosing goal context.  Thus
   5.556 +  $\QEDNAME$ may fail for two reasons: either $m@2$ fails, or the resulting
   5.557 +  rule does not fit to any pending goal\footnote{This includes any additional
   5.558 +    ``strong'' assumptions as introduced by $\ASSUMENAME$.} of the enclosing
   5.559 +  context.  Debugging such a situation might involve temporarily changing
   5.560 +  $\SHOWNAME$ into $\HAVENAME$, or weakening the local context by replacing
   5.561 +  some occurrences of $\ASSUMENAME$ by $\PRESUMENAME$.
   5.562 +\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}\index{proof!terminal}; it
   5.563 +  abbreviates $\PROOF{m@1}~\QED{m@2}$, with automatic backtracking across both
   5.564 +  methods.  Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done
   5.565 +  by expanding its definition; in many cases $\PROOF{m@1}$ is already
   5.566    sufficient to see what is going wrong.
   5.567 -\item [``$\DDOT$''] is a \emph{default proof}; it abbreviates $\BY{default}$.
   5.568 -\item [``$\DOT$''] is a \emph{trivial proof}; it abbreviates
   5.569 -  $\BY{assumption}$.
   5.570 -\item [$\isarkeyword{sorry}$] is a \emph{fake proof}; provided that
   5.571 -  \texttt{quick_and_dirty} is enabled, $\isarkeyword{sorry}$ pretends to solve
   5.572 -  the goal without further ado.  Of course, the result is a fake theorem only,
   5.573 -  involving some oracle in its internal derivation object (this is indicated
   5.574 -  as $[!]$ in the printed result).  The main application of
   5.575 -  $\isarkeyword{sorry}$ is to support top-down proof development.
   5.576 +\item [``$\DDOT$''] is a \emph{default proof}\index{proof!default}; it
   5.577 +  abbreviates $\BY{default}$.
   5.578 +\item [``$\DOT$''] is a \emph{trivial proof}\index{proof!trivial}; it
   5.579 +  abbreviates $\BY{assumption}$.
   5.580 +\item [$\isarkeyword{sorry}$] is a \emph{fake proof}\index{proof!fake};
   5.581 +  provided that \texttt{quick_and_dirty} is enabled, $\isarkeyword{sorry}$
   5.582 +  pretends to solve the goal without further ado.  Of course, the result is a
   5.583 +  fake theorem only, involving some oracle in its internal derivation object
   5.584 +  (this is indicated as ``$[!]$'' in the printed result).  The main
   5.585 +  application of $\isarkeyword{sorry}$ is to support experimentation and
   5.586 +  top-down proof development.
   5.587  \end{descr}
   5.588  
   5.589  
   5.590 @@ -691,7 +729,7 @@
   5.591  
   5.592  The following commands emulate unstructured tactic scripts to some extent.
   5.593  While these are anathema for writing proper Isar proof documents, they might
   5.594 -come in handy for exploring and debugging.
   5.595 +come in handy for interactive exploration and debugging.
   5.596  
   5.597  \indexisarcmd{apply}\indexisarcmd{then-apply}\indexisarcmd{back}
   5.598  \begin{matharray}{rcl}
   5.599 @@ -713,8 +751,8 @@
   5.600  \end{rail}
   5.601  
   5.602  \begin{descr}
   5.603 -\item [$\isarkeyword{apply}~(m)$] applies proof method $m$ in the
   5.604 -  plain-old-tactic sense.  Facts for forward chaining are reset.
   5.605 +\item [$\isarkeyword{apply}~(m)$] applies proof method $m$ in the plain old
   5.606 +  tactic sense.  Facts for forward chaining are reset.
   5.607  \item [$\isarkeyword{then_apply}~(m)$] is similar to $\isarkeyword{apply}$,
   5.608    but keeps the goal's facts.
   5.609  \item [$\isarkeyword{back}$] does back-tracking over the result sequence of
   5.610 @@ -734,8 +772,8 @@
   5.611  
   5.612  Abbreviations may be either bound by explicit $\LET{p \equiv t}$ statements,
   5.613  or by annotating assumptions or goal statements ($\ASSUMENAME$, $\SHOWNAME$
   5.614 -etc.) with a list of patterns $\IS{p@1 \dots p@n}$.  In both cases,
   5.615 -higher-order matching is applied to bind extra-logical text variables, which
   5.616 +etc.) with a list of patterns $\ISS{p@1 \dots}{p@n}$.  In both cases,
   5.617 +higher-order matching is invoked to bind extra-logical term variables, which
   5.618  may be either named schematic variables of the form $\Var{x}$, or nameless
   5.619  dummies ``\texttt{_}'' (underscore).\indexisarvar{_@\texttt{_}} Note that in
   5.620  the $\LETNAME$ form the patterns occur on the left-hand side, while the
   5.621 @@ -775,7 +813,7 @@
   5.622  $\Var{this_concl}$\indexisarvar{this-concl}, and
   5.623  $\Var{this}$\indexisarvar{this}, similar to $\Var{thesis}$ above.  In case
   5.624  $\Var{this}$ refers to an object-logic statement that is an application
   5.625 -$f(x)$, then $x$ is bound to the special text variable
   5.626 +$f(t)$, then $t$ is bound to the special text variable
   5.627  ``$\dots$''\indexisarvar{\dots} (three dots).  The canonical application of
   5.628  this feature are calculational proofs (see \S\ref{sec:calculation}).
   5.629  
   5.630 @@ -793,24 +831,25 @@
   5.631  mostly handled rather casually, with little explicit user-intervention.  Any
   5.632  local goal statement automatically opens \emph{two} blocks, which are closed
   5.633  again when concluding the sub-proof (by $\QEDNAME$ etc.).  Sections of
   5.634 -different context within a sub-proof are typically switched via
   5.635 -$\isarkeyword{next}$, which is just a single block-close followed by
   5.636 -block-open again.  Thus the effect of $\isarkeyword{next}$ is to reset the
   5.637 -proof context to that of the head of the sub-proof.  Note that there is no
   5.638 -goal focus involved here!
   5.639 +different context within a sub-proof may be switched via $\isarkeyword{next}$,
   5.640 +which is just a single block-close followed by block-open again.  Thus the
   5.641 +effect of $\isarkeyword{next}$ is a local reset the proof
   5.642 +context.\footnote{There is no goal focus involved here!}
   5.643  
   5.644  For slightly more advanced applications, there are explicit block parentheses
   5.645 -as well.  These typically achieve a strong forward style of reasoning.
   5.646 +as well.  These typically achieve a stronger forward style of reasoning.
   5.647  
   5.648  \begin{descr}
   5.649  \item [$\isarkeyword{next}$] switches to a fresh block within a sub-proof,
   5.650 -  resetting the context to the initial one.
   5.651 +  resetting the local context to the initial one.
   5.652  \item [$\isarkeyword{\{\{}$ and $\isarkeyword{\}\}}$] explicitly open and
   5.653 -  close blocks.  Any current facts pass through $\isarkeyword{\{\{}$
   5.654 -  unchanged, while $\isarkeyword{\}\}}$ causes them to be \emph{exported} into
   5.655 -  the enclosing context.  Thus fixed variables are generalized, assumptions
   5.656 -  discharged, and local definitions eliminated.  There is no difference of
   5.657 -  $\ASSUMENAME$ and $\PRESUMENAME$ here.
   5.658 +  close blocks.  Any current facts pass through ``$\isarkeyword{\{\{}$''
   5.659 +  unchanged, while ``$\isarkeyword{\}\}}$'' causes any result to be
   5.660 +  \emph{exported} into the enclosing context.  Thus fixed variables are
   5.661 +  generalized, assumptions discharged, and local definitions unfolded (cf.\ 
   5.662 +  \S\ref{sec:proof-context}).  There is no difference of $\ASSUMENAME$ and
   5.663 +  $\PRESUMENAME$ in this mode of forward reasoning --- in contrast to plain
   5.664 +  backward reasoning with the result exported at $\SHOWNAME$ time.
   5.665  \end{descr}
   5.666  
   5.667  
   5.668 @@ -842,14 +881,18 @@
   5.669  \end{rail}
   5.670  
   5.671  \begin{descr}
   5.672 -\item [$\isarkeyword{typ}~\tau$, $\isarkeyword{term}~t$,
   5.673 -  $\isarkeyword{prop}~\phi$] read and print types / terms / propositions
   5.674 +\item [$\isarkeyword{typ}~\tau$] reads and prints types of the meta-logic
   5.675    according to the current theory or proof context.
   5.676 +\item [$\isarkeyword{term}~t$, $\isarkeyword{prop}~\phi$] read, type-checks
   5.677 +  and print terms or propositions according to the current theory or proof
   5.678 +  context; the inferred type of $t$ is output as well.  Note that these
   5.679 +  commands are also useful in inspecting the current environment of term
   5.680 +  abbreviations.
   5.681  \item [$\isarkeyword{thm}~thms$] retrieves lists of theorems from the current
   5.682    theory or proof context.  Note that any attributes included in the theorem
   5.683    specifications are applied to a temporary context derived from the current
   5.684    theory or proof; the result is discarded, i.e.\ attributes involved in
   5.685 -  $thms$ only have a temporary effect.
   5.686 +  $thms$ do not have any permanent effect.
   5.687  \end{descr}
   5.688  
   5.689  
   5.690 @@ -872,15 +915,16 @@
   5.691  \item [$\isarkeyword{pwd}~$] prints the current working directory.
   5.692  \item [$\isarkeyword{use_thy}$, $\isarkeyword{use_thy_only}$,
   5.693    $\isarkeyword{update_thy}$, and $\isarkeyword{update_thy_only}$] load some
   5.694 -  theory given as $name$ argument.  These commands are exactly the same as the
   5.695 -  corresponding ML functions (see also \cite[\S1,\S6]{isabelle-ref}).  Note
   5.696 -  that both the ML and Isar versions may load new- and old-style theories
   5.697 -  alike.
   5.698 +  theory given as $name$ argument.  These commands are basically the same as
   5.699 +  the corresponding ML functions\footnote{For historic reasons, the original
   5.700 +    ML versions also change the theory context to that of the theory loaded.}
   5.701 +  (see also \cite[\S1,\S6]{isabelle-ref}).  Note that both the ML and Isar
   5.702 +  versions may load new- and old-style theories alike.
   5.703  \end{descr}
   5.704  
   5.705 -Note that these system commands are scarcely used when working with
   5.706 -Proof~General, since loading of theories is done fully automatic.
   5.707 -
   5.708 +Note that these system commands are scarcely used when working with the
   5.709 +Proof~General interface, since loading of theories is done fully
   5.710 +transparently.
   5.711  
   5.712  %%% Local Variables: 
   5.713  %%% mode: latex
     6.1 --- a/doc-src/IsarRef/syntax.tex	Thu Oct 21 15:57:26 1999 +0200
     6.2 +++ b/doc-src/IsarRef/syntax.tex	Thu Oct 21 17:42:21 1999 +0200
     6.3 @@ -1,5 +1,5 @@
     6.4  
     6.5 -\chapter{Isar Document Syntax}
     6.6 +\chapter{Isar Syntax Primitives}
     6.7  
     6.8  We give a complete reference of all basic syntactic entities underlying the
     6.9  Isabelle/Isar document syntax.  Actual theory and proof commands will be
    6.10 @@ -10,16 +10,17 @@
    6.11  In order to get started with writing well-formed Isabelle/Isar documents, the
    6.12  most important aspect to be noted is the difference of \emph{inner} versus
    6.13  \emph{outer} syntax.  Inner syntax is that of Isabelle types and terms of the
    6.14 -logic, while outer syntax is that of Isabelle/Isar theories (and proofs).  As
    6.15 -a general rule, inner syntax entities may occur only as \emph{atomic entities}
    6.16 -within outer syntax.  Thus, string \texttt{"x + y"} and identifier \texttt{z}
    6.17 -are legal term specifications, while \texttt{x + y} is not.
    6.18 +logic, while outer syntax is that of Isabelle/Isar theories (including
    6.19 +proofs).  As a general rule, inner syntax entities may occur only as
    6.20 +\emph{atomic entities} within outer syntax.  For example, the string
    6.21 +\texttt{"x + y"} and identifier \texttt{z} are legal term specifications
    6.22 +within a theory, while \texttt{x + y} is not.
    6.23  
    6.24  \begin{warn}
    6.25 -  Note that Isabelle theories used to fake parts of the inner type syntax,
    6.26 -  with complicated rules when quotes may be omitted.  Despite the minor
    6.27 -  drawback of requiring quotes more often, Isabelle/Isar is simpler and more
    6.28 -  robust in that respect.
    6.29 +  Note that classic Isabelle theories used to fake parts of the inner type
    6.30 +  syntax, with complicated rules when quotes may be omitted.  Despite the
    6.31 +  minor drawback of requiring quotes more often, the syntax of Isabelle/Isar
    6.32 +  is simpler and more robust in that respect.
    6.33  \end{warn}
    6.34  
    6.35  \medskip
    6.36 @@ -27,16 +28,18 @@
    6.37  Another notable point is proper input termination.  Proof~General demands any
    6.38  command to be terminated by ``\texttt{;}''
    6.39  (semicolon)\index{semicolon}\index{*;}.  As far as plain Isabelle/Isar is
    6.40 -concerned, commands may be directly run together.  Thus for better
    6.41 -readability, we usually omit semicolons when discussion Isar proof text here.
    6.42 +concerned, commands may be directly run together, though.  Thus we usually
    6.43 +omit semicolons when presenting Isar proof text here, in order to gain
    6.44 +readability.  Note that the documents which automatically generated from
    6.45 +new-style theories also omit semicolons.
    6.46  
    6.47  
    6.48  \section{Lexical matters}\label{sec:lex-syntax}
    6.49  
    6.50  The Isabelle/Isar outer syntax provides token classes as presented below.
    6.51 -Note that some of these coincide (by full intention) with inner lexical syntax
    6.52 -as given in \cite{isabelle-ref}.  These different levels of syntax should not
    6.53 -be confused, though.
    6.54 +Note that some of these coincide (by full intention) with the inner lexical
    6.55 +syntax as presented in \cite{isabelle-ref}.  These different levels of syntax
    6.56 +should not be confused, though.
    6.57  
    6.58  %FIXME keyword, command
    6.59  \begin{matharray}{rcl}
    6.60 @@ -61,30 +64,31 @@
    6.61  \end{matharray}
    6.62  
    6.63  The syntax of \texttt{string} admits any characters, including newlines;
    6.64 -\verb|"| and \verb|\| have to be escaped by a backslash, though.  Note that
    6.65 -ML-style control character notation is not supported.  The body of
    6.66 -\texttt{verbatim} may consist of any text not containing \verb|*}|.
    6.67 +``\verb|"|'' (double-quote) and ``\verb|\|'' (backslash) have to be escaped by
    6.68 +a backslash, though.  Note that ML-style control character notation is
    6.69 +\emph{not} supported.  The body of \texttt{verbatim} may consist of any text
    6.70 +not containing \verb|*}|.
    6.71  
    6.72 -Comments take the form \texttt{(*~\dots~*)} and may be nested, just as in
    6.73 -ML.\footnote{Proof~General may get confused by nested comments, though.} Note
    6.74 -that these are \emph{source} comments only, which are stripped after lexical
    6.75 -analysis of the input.  The Isar document syntax also provides several
    6.76 -elements of \emph{formal comments} that are actually part of the text (see
    6.77 -\S\ref{sec:comments}, \S\ref{sec:formal-cmt-thy}, \S\ref{sec:formal-cmt-prf}).
    6.78 +Comments take the form \texttt{(*~\dots~*)} and may be
    6.79 +nested\footnote{Proof~General may get confused by nested comments, though.},
    6.80 +just as in ML. Note that these are \emph{source} comments only, which are
    6.81 +stripped after lexical analysis of the input.  The Isar document syntax also
    6.82 +provides of \emph{formal comments} that are actually part of the text (see
    6.83 +\S\ref{sec:comments}).
    6.84  
    6.85  
    6.86  \section{Common syntax entities}
    6.87  
    6.88  Subsequently, we introduce several basic syntactic entities, such as names,
    6.89 -terms, theorem specifications, which have been factored out of the actual Isar
    6.90 -language elements to be described later.
    6.91 +terms, and theorem specifications, which have been factored out of the actual
    6.92 +Isar language elements to be described later.
    6.93  
    6.94 -Note that some of the basic syntactic entities introduced below act much like
    6.95 -tokens rather than nonterminals, especially for the sake of error messages.
    6.96 -E.g.\ syntax elements such as $\CONSTS$ referring to \railqtoken{name} or
    6.97 -\railqtoken{type} would really report a missing name or type rather than any
    6.98 -of the constituent primitive tokens such as \railtoken{ident} or
    6.99 -\railtoken{string}.
   6.100 +Note that some of the basic syntactic entities introduced below (such as
   6.101 +\railqtoken{name}) act much like tokens rather than plain nonterminals (e.g.\ 
   6.102 +\railnonterm{sort}), especially for the sake of error messages.  E.g.\ syntax
   6.103 +elements such as $\CONSTS$ referring to \railqtoken{name} or \railqtoken{type}
   6.104 +would really report a missing name or type rather than any of the constituent
   6.105 +primitive tokens such as \railtoken{ident} or \railtoken{string}.
   6.106  
   6.107  
   6.108  \subsection{Names}
   6.109 @@ -110,12 +114,12 @@
   6.110  \subsection{Comments}\label{sec:comments}
   6.111  
   6.112  Large chunks of plain \railqtoken{text} are usually given
   6.113 -\railtoken{verbatim}, i.e.\ enclosed in \verb|{*|\dots\verb|*}|.  For
   6.114 +\railtoken{verbatim}, i.e.\ enclosed in \verb|{*|~\dots~\verb|*}|.  For
   6.115  convenience, any of the smaller text units conforming to \railqtoken{nameref}
   6.116  are admitted as well.  Almost any of the Isar commands may be annotated by a
   6.117  marginal \railnonterm{comment} of the form \texttt{--} \railqtoken{text}.
   6.118  Note that the latter kind of comment is actually part of the language, while
   6.119 -source level comments \verb|(*|\dots\verb|*)| are stripped at the lexical
   6.120 +source level comments \verb|(*|~\dots~\verb|*)| are stripped at the lexical
   6.121  level.  A few commands such as $\PROOFNAME$ admit additional markup with a
   6.122  ``level of interest'': \texttt{\%} followed by an optional number $n$ (default
   6.123  $n = 1$) indicates that the respective part of the document becomes $n$ levels
   6.124 @@ -155,14 +159,14 @@
   6.125  \subsection{Types and terms}\label{sec:types-terms}
   6.126  
   6.127  The actual inner Isabelle syntax, that of types and terms of the logic, is far
   6.128 -too advanced in order to be modelled explicitly at the outer theory level.
   6.129 -Basically, any such entity has to be quoted here to turn it into a single
   6.130 -token (the parsing and type-checking is performed later).  For convenience, a
   6.131 -slightly more liberal convention is adopted: quotes may be omitted for any
   6.132 -type or term that is already \emph{atomic} at the outer level.  E.g.\ one may
   6.133 -write just \texttt{x} instead of \texttt{"x"}.  Note that symbolic identifiers
   6.134 -such as \texttt{++} are available as well, provided these are not superceded
   6.135 -by commands or keywords (like \texttt{+}).
   6.136 +too sophisticated in order to be modelled explicitly at the outer theory
   6.137 +level.  Basically, any such entity has to be quoted here to turn it into a
   6.138 +single token (the parsing and type-checking is performed later).  For
   6.139 +convenience, a slightly more liberal convention is adopted: quotes may be
   6.140 +omitted for any type or term that is already \emph{atomic} at the outer level.
   6.141 +For example, one may write just \texttt{x} instead of \texttt{"x"}.  Note that
   6.142 +symbolic identifiers such as \texttt{++} are available as well, provided these
   6.143 +are not superseded by commands or keywords (like \texttt{+}).
   6.144  
   6.145  \indexoutertoken{type}\indexoutertoken{term}\indexoutertoken{prop}
   6.146  \begin{rail}
   6.147 @@ -188,8 +192,8 @@
   6.148  
   6.149  \subsection{Term patterns}\label{sec:term-pats}
   6.150  
   6.151 -Assumptions and goal statements usually admit automatic binding of schematic
   6.152 -text variables by giving (optional) patterns of the form $\IS{p@1 \dots p@n}$.
   6.153 +Assumptions and goal statements usually admit casual binding of schematic term
   6.154 +variables by giving (optional) patterns of the form $\ISS{p@1 \dots}{p@n}$.
   6.155  There are separate versions available for \railqtoken{term}s and
   6.156  \railqtoken{prop}s.  The latter provides a $\CONCLNAME$ part with patterns
   6.157  referring the (atomic) conclusion of a rule.
   6.158 @@ -243,7 +247,7 @@
   6.159    ;
   6.160  \end{rail}
   6.161  
   6.162 -Theorem specifications come in several flavours: \railnonterm{axmdecl} and
   6.163 +Theorem specifications come in several flavors: \railnonterm{axmdecl} and
   6.164  \railnonterm{thmdecl} usually refer to axioms, assumptions or results of goal
   6.165  statements, \railnonterm{thmdef} collects lists of existing theorems.
   6.166  Existing theorems are given by \railnonterm{thmref} and \railnonterm{thmrefs}
   6.167 @@ -281,7 +285,7 @@
   6.168  \railqtoken{nameref}~\railnonterm{args} specifications.  Thus the syntax is
   6.169  similar to that of attributes, with plain parentheses instead of square
   6.170  brackets.  Note that parentheses may be dropped for single method
   6.171 -specifications without arguments.
   6.172 +specifications (with no arguments).
   6.173  
   6.174  \indexouternonterm{method}
   6.175  \begin{rail}