doc-src/IsarRef/Thy/document/Introduction.tex
changeset 30072 533c27b43ee1
parent 30043 51ed69c9422b
child 30242 aea5d7fa7ef5
equal deleted inserted replaced
30071:fe221f1d8976 30072:533c27b43ee1
    28 %
    28 %
    29 \begin{isamarkuptext}%
    29 \begin{isamarkuptext}%
    30 The \emph{Isabelle} system essentially provides a generic
    30 The \emph{Isabelle} system essentially provides a generic
    31   infrastructure for building deductive systems (programmed in
    31   infrastructure for building deductive systems (programmed in
    32   Standard ML), with a special focus on interactive theorem proving in
    32   Standard ML), with a special focus on interactive theorem proving in
    33   higher-order logics.  In the olden days even end-users would refer
    33   higher-order logics.  Many years ago, even end-users would refer to
    34   to certain ML functions (goal commands, tactics, tacticals etc.) to
    34   certain ML functions (goal commands, tactics, tacticals etc.) to
    35   pursue their everyday theorem proving tasks
    35   pursue their everyday theorem proving tasks.
    36   \cite{isabelle-intro,isabelle-ref}.
       
    37   
    36   
    38   In contrast \emph{Isar} provides an interpreted language environment
    37   In contrast \emph{Isar} provides an interpreted language environment
    39   of its own, which has been specifically tailored for the needs of
    38   of its own, which has been specifically tailored for the needs of
    40   theory and proof development.  Compared to raw ML, the Isabelle/Isar
    39   theory and proof development.  Compared to raw ML, the Isabelle/Isar
    41   top-level provides a more robust and comfortable development
    40   top-level provides a more robust and comfortable development
    42   platform, with proper support for theory development graphs,
    41   platform, with proper support for theory development graphs, managed
    43   single-step transactions with unlimited undo, etc.  The
    42   transactions with unlimited undo etc.  The Isabelle/Isar version of
    44   Isabelle/Isar version of the \emph{Proof~General} user interface
    43   the \emph{Proof~General} user interface
    45   \cite{proofgeneral,Aspinall:TACAS:2000} provides an adequate
    44   \cite{proofgeneral,Aspinall:TACAS:2000} provides a decent front-end
    46   front-end for interactive theory and proof development in this
    45   for interactive theory and proof development in this advanced
    47   advanced theorem proving environment.
    46   theorem proving environment, even though it is somewhat biased
       
    47   towards old-style proof scripts.
    48 
    48 
    49   \medskip Apart from the technical advances over bare-bones ML
    49   \medskip Apart from the technical advances over bare-bones ML
    50   programming, the main purpose of the Isar language is to provide a
    50   programming, the main purpose of the Isar language is to provide a
    51   conceptually different view on machine-checked proofs
    51   conceptually different view on machine-checked proofs
    52   \cite{Wenzel:1999:TPHOL,Wenzel-PhD}.  ``Isar'' stands for
    52   \cite{Wenzel:1999:TPHOL,Wenzel-PhD}.  \emph{Isar} stands for
    53   ``Intelligible semi-automated reasoning''.  Drawing from both the
    53   \emph{Intelligible semi-automated reasoning}.  Drawing from both the
    54   traditions of informal mathematical proof texts and high-level
    54   traditions of informal mathematical proof texts and high-level
    55   programming languages, Isar offers a versatile environment for
    55   programming languages, Isar offers a versatile environment for
    56   structured formal proof documents.  Thus properly written Isar
    56   structured formal proof documents.  Thus properly written Isar
    57   proofs become accessible to a broader audience than unstructured
    57   proofs become accessible to a broader audience than unstructured
    58   tactic scripts (which typically only provide operational information
    58   tactic scripts (which typically only provide operational information
    63   right, independently of the mechanic proof-checking process.
    63   right, independently of the mechanic proof-checking process.
    64 
    64 
    65   Despite its grand design of structured proof texts, Isar is able to
    65   Despite its grand design of structured proof texts, Isar is able to
    66   assimilate the old tactical style as an ``improper'' sub-language.
    66   assimilate the old tactical style as an ``improper'' sub-language.
    67   This provides an easy upgrade path for existing tactic scripts, as
    67   This provides an easy upgrade path for existing tactic scripts, as
    68   well as additional means for interactive experimentation and
    68   well as some means for interactive experimentation and debugging of
    69   debugging of structured proofs.  Isabelle/Isar supports a broad
    69   structured proofs.  Isabelle/Isar supports a broad range of proof
    70   range of proof styles, both readable and unreadable ones.
    70   styles, both readable and unreadable ones.
    71 
    71 
    72   \medskip The generic Isabelle/Isar framework (see
    72   \medskip The generic Isabelle/Isar framework (see
    73   \chref{ch:isar-framework}) should work reasonably well for any
    73   \chref{ch:isar-framework}) works reasonably well for any Isabelle
    74   Isabelle object-logic that conforms to the natural deduction view of
    74   object-logic that conforms to the natural deduction view of the
    75   the Isabelle/Pure framework.  Specific language elements introduced
    75   Isabelle/Pure framework.  Specific language elements introduced by
    76   by the major object-logics are described in \chref{ch:hol}
    76   the major object-logics are described in \chref{ch:hol}
    77   (Isabelle/HOL), \chref{ch:holcf} (Isabelle/HOLCF), and \chref{ch:zf}
    77   (Isabelle/HOL), \chref{ch:holcf} (Isabelle/HOLCF), and \chref{ch:zf}
    78   (Isabelle/ZF).  The main language elements are already provided by
    78   (Isabelle/ZF).  The main language elements are already provided by
    79   the Isabelle/Pure framework. Nevertheless, examples given in the
    79   the Isabelle/Pure framework. Nevertheless, examples given in the
    80   generic parts will usually refer to Isabelle/HOL as well.
    80   generic parts will usually refer to Isabelle/HOL as well.
    81 
    81 
    85   Improper Isar language elements, which are marked by ``\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}}'' in the subsequent chapters; they are often helpful
    85   Improper Isar language elements, which are marked by ``\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}}'' in the subsequent chapters; they are often helpful
    86   when developing proof documents, but their use is discouraged for
    86   when developing proof documents, but their use is discouraged for
    87   the final human-readable outcome.  Typical examples are diagnostic
    87   the final human-readable outcome.  Typical examples are diagnostic
    88   commands that print terms or theorems according to the current
    88   commands that print terms or theorems according to the current
    89   context; other commands emulate old-style tactical theorem proving.%
    89   context; other commands emulate old-style tactical theorem proving.%
    90 \end{isamarkuptext}%
       
    91 \isamarkuptrue%
       
    92 %
       
    93 \isamarkupsection{User interfaces%
       
    94 }
       
    95 \isamarkuptrue%
       
    96 %
       
    97 \isamarkupsubsection{Terminal sessions%
       
    98 }
       
    99 \isamarkuptrue%
       
   100 %
       
   101 \begin{isamarkuptext}%
       
   102 The Isabelle \texttt{tty} tool provides a very interface for running
       
   103   the Isar interaction loop, with some support for command line
       
   104   editing.  For example:
       
   105 \begin{ttbox}
       
   106 isabelle tty\medskip
       
   107 {\out Welcome to Isabelle/HOL (Isabelle2008)}\medskip
       
   108 theory Foo imports Main begin;
       
   109 definition foo :: nat where "foo == 1";
       
   110 lemma "0 < foo" by (simp add: foo_def);
       
   111 end;
       
   112 \end{ttbox}
       
   113 
       
   114   Any Isabelle/Isar command may be retracted by \hyperlink{command.undo}{\mbox{\isa{\isacommand{undo}}}}.
       
   115   See the Isabelle/Isar Quick Reference (\appref{ap:refcard}) for a
       
   116   comprehensive overview of available commands and other language
       
   117   elements.%
       
   118 \end{isamarkuptext}%
       
   119 \isamarkuptrue%
       
   120 %
       
   121 \isamarkupsubsection{Emacs Proof General%
       
   122 }
       
   123 \isamarkuptrue%
       
   124 %
       
   125 \begin{isamarkuptext}%
       
   126 Plain TTY-based interaction as above used to be quite feasible with
       
   127   traditional tactic based theorem proving, but developing Isar
       
   128   documents really demands some better user-interface support.  The
       
   129   Proof~General environment by David Aspinall
       
   130   \cite{proofgeneral,Aspinall:TACAS:2000} offers a generic Emacs
       
   131   interface for interactive theorem provers that organizes all the
       
   132   cut-and-paste and forward-backward walk through the text in a very
       
   133   neat way.  In Isabelle/Isar, the current position within a partial
       
   134   proof document is equally important than the actual proof state.
       
   135   Thus Proof~General provides the canonical working environment for
       
   136   Isabelle/Isar, both for getting acquainted (e.g.\ by replaying
       
   137   existing Isar documents) and for production work.%
       
   138 \end{isamarkuptext}%
       
   139 \isamarkuptrue%
       
   140 %
       
   141 \isamarkupsubsubsection{Proof~General as default Isabelle interface%
       
   142 }
       
   143 \isamarkuptrue%
       
   144 %
       
   145 \begin{isamarkuptext}%
       
   146 The Isabelle interface wrapper script provides an easy way to invoke
       
   147   Proof~General (including XEmacs or GNU Emacs).  The default
       
   148   configuration of Isabelle is smart enough to detect the
       
   149   Proof~General distribution in several canonical places (e.g.\
       
   150   \verb|$ISABELLE_HOME/contrib/ProofGeneral|).  Thus the
       
   151   capital \verb|Isabelle| executable would already refer to the
       
   152   \verb|ProofGeneral/isar| interface without further ado.  The
       
   153   Isabelle interface script provides several options; pass \verb|-?|  to see its usage.
       
   154 
       
   155   With the proper Isabelle interface setup, Isar documents may now be edited by
       
   156   visiting appropriate theory files, e.g.\ 
       
   157 \begin{ttbox}
       
   158 Isabelle \({\langle}isabellehome{\rangle}\)/src/HOL/Isar_examples/Summation.thy
       
   159 \end{ttbox}
       
   160   Beginners may note the tool bar for navigating forward and backward
       
   161   through the text (this depends on the local Emacs installation).
       
   162   Consult the Proof~General documentation \cite{proofgeneral} for
       
   163   further basic command sequences, in particular ``\verb|C-c C-return|''
       
   164   and ``\verb|C-c u|''.
       
   165 
       
   166   \medskip Proof~General may be also configured manually by giving
       
   167   Isabelle settings like this (see also \cite{isabelle-sys}):
       
   168 
       
   169 \begin{ttbox}
       
   170 ISABELLE_INTERFACE=\$ISABELLE_HOME/contrib/ProofGeneral/isar/interface
       
   171 PROOFGENERAL_OPTIONS=""
       
   172 \end{ttbox}
       
   173   You may have to change \verb|$ISABELLE_HOME/contrib/ProofGeneral| to the actual installation
       
   174   directory of Proof~General.
       
   175 
       
   176   \medskip Apart from the Isabelle command line, defaults for
       
   177   interface options may be given by the \verb|PROOFGENERAL_OPTIONS|
       
   178   setting.  For example, the Emacs executable to be used may be
       
   179   configured in Isabelle's settings like this:
       
   180 \begin{ttbox}
       
   181 PROOFGENERAL_OPTIONS="-p xemacs-mule"  
       
   182 \end{ttbox}
       
   183 
       
   184   Occasionally, a user's \verb|~/.emacs| file contains code
       
   185   that is incompatible with the (X)Emacs version used by
       
   186   Proof~General, causing the interface startup to fail prematurely.
       
   187   Here the \verb|-u false| option helps to get the interface
       
   188   process up and running.  Note that additional Lisp customization
       
   189   code may reside in \verb|proofgeneral-settings.el| of
       
   190   \verb|$ISABELLE_HOME/etc| or \verb|$ISABELLE_HOME_USER/etc|.%
       
   191 \end{isamarkuptext}%
       
   192 \isamarkuptrue%
       
   193 %
       
   194 \isamarkupsubsubsection{The X-Symbol package%
       
   195 }
       
   196 \isamarkuptrue%
       
   197 %
       
   198 \begin{isamarkuptext}%
       
   199 Proof~General incorporates a version of the Emacs X-Symbol package
       
   200   \cite{x-symbol}, which handles proper mathematical symbols displayed
       
   201   on screen.  Pass option \verb|-x true| to the Isabelle
       
   202   interface script, or check the appropriate Proof~General menu
       
   203   setting by hand.  The main challenge of getting X-Symbol to work
       
   204   properly is the underlying (semi-automated) X11 font setup.
       
   205 
       
   206   \medskip Using proper mathematical symbols in Isabelle theories can
       
   207   be very convenient for readability of large formulas.  On the other
       
   208   hand, the plain ASCII sources easily become somewhat unintelligible.
       
   209   For example, \isa{{\isachardoublequote}{\isasymLongrightarrow}{\isachardoublequote}} would appear as \verb|\<Longrightarrow>| according
       
   210   the default set of Isabelle symbols.  Nevertheless, the Isabelle
       
   211   document preparation system (see \chref{ch:document-prep}) will be
       
   212   happy to print non-ASCII symbols properly.  It is even possible to
       
   213   invent additional notation beyond the display capabilities of Emacs
       
   214   and X-Symbol.%
       
   215 \end{isamarkuptext}%
       
   216 \isamarkuptrue%
       
   217 %
       
   218 \isamarkupsection{Isabelle/Isar theories%
       
   219 }
       
   220 \isamarkuptrue%
       
   221 %
       
   222 \begin{isamarkuptext}%
       
   223 Isabelle/Isar offers the following main improvements over classic
       
   224   Isabelle.
       
   225 
       
   226   \begin{enumerate}
       
   227   
       
   228   \item A \emph{theory format} that integrates specifications and
       
   229   proofs, supporting interactive development and unlimited undo
       
   230   operation.
       
   231   
       
   232   \item A \emph{formal proof document language} designed to support
       
   233   intelligible semi-automated reasoning.  Instead of putting together
       
   234   unreadable tactic scripts, the author is enabled to express the
       
   235   reasoning in way that is close to usual mathematical practice.  The
       
   236   old tactical style has been assimilated as ``improper'' language
       
   237   elements.
       
   238   
       
   239   \item A simple document preparation system, for typesetting formal
       
   240   developments together with informal text.  The resulting
       
   241   hyper-linked PDF documents are equally well suited for WWW
       
   242   presentation and as printed copies.
       
   243 
       
   244   \end{enumerate}
       
   245 
       
   246   The Isar proof language is embedded into the new theory format as a
       
   247   proper sub-language.  Proof mode is entered by stating some
       
   248   \hyperlink{command.theorem}{\mbox{\isa{\isacommand{theorem}}}} or \hyperlink{command.lemma}{\mbox{\isa{\isacommand{lemma}}}} at the theory level, and
       
   249   left again with the final conclusion (e.g.\ via \hyperlink{command.qed}{\mbox{\isa{\isacommand{qed}}}}).
       
   250   A few theory specification mechanisms also require some proof, such
       
   251   as HOL's \hyperlink{command.typedef}{\mbox{\isa{\isacommand{typedef}}}} which demands non-emptiness of the
       
   252   representing sets.%
       
   253 \end{isamarkuptext}%
       
   254 \isamarkuptrue%
       
   255 %
       
   256 \isamarkupsection{How to write Isar proofs anyway? \label{sec:isar-howto}%
       
   257 }
       
   258 \isamarkuptrue%
       
   259 %
       
   260 \begin{isamarkuptext}%
       
   261 This is one of the key questions, of course.  First of all, the
       
   262   tactic script emulation of Isabelle/Isar essentially provides a
       
   263   clarified version of the very same unstructured proof style of
       
   264   classic Isabelle.  Old-time users should quickly become acquainted
       
   265   with that (slightly degenerative) view of Isar.
       
   266 
       
   267   Writing \emph{proper} Isar proof texts targeted at human readers is
       
   268   quite different, though.  Experienced users of the unstructured
       
   269   style may even have to unlearn some of their habits to master proof
       
   270   composition in Isar.  In contrast, new users with less experience in
       
   271   old-style tactical proving, but a good understanding of mathematical
       
   272   proof in general, often get started easier.
       
   273 
       
   274   \medskip The present text really is only a reference manual on
       
   275   Isabelle/Isar, not a tutorial.  Nevertheless, we will attempt to
       
   276   give some clues of how the concepts introduced here may be put into
       
   277   practice.  Especially note that \appref{ap:refcard} provides a quick
       
   278   reference card of the most common Isabelle/Isar language elements.
       
   279 
       
   280   Further issues concerning the Isar concepts are covered in the
       
   281   literature
       
   282   \cite{Wenzel:1999:TPHOL,Wiedijk:2000:MV,Bauer-Wenzel:2000:HB,Bauer-Wenzel:2001}.
       
   283   The author's PhD thesis \cite{Wenzel-PhD} presently provides the
       
   284   most complete exposition of Isar foundations, techniques, and
       
   285   applications.  A number of example applications are distributed with
       
   286   Isabelle, and available via the Isabelle WWW library (e.g.\
       
   287   \url{http://isabelle.in.tum.de/library/}).  The ``Archive of Formal
       
   288   Proofs'' \url{http://afp.sourceforge.net/} also provides plenty of
       
   289   examples, both in proper Isar proof style and unstructured tactic
       
   290   scripts.%
       
   291 \end{isamarkuptext}%
    90 \end{isamarkuptext}%
   292 \isamarkuptrue%
    91 \isamarkuptrue%
   293 %
    92 %
   294 \isadelimtheory
    93 \isadelimtheory
   295 %
    94 %