doc-src/IsarRef/Thy/intro.thy
author wenzelm
Fri, 02 May 2008 16:36:05 +0200
changeset 26767 cc127cc0951b
parent 26760 2de4ba348f06
child 26852 a31203f58b20
permissions -rw-r--r--
converted pure.tex to Thy/pure.thy;
wenzelm@26767
     1
(* $Id$ *)
wenzelm@26741
     2
wenzelm@26741
     3
theory intro
wenzelm@26741
     4
imports CPure
wenzelm@26741
     5
begin
wenzelm@26741
     6
wenzelm@26741
     7
chapter {* Introduction *}
wenzelm@26741
     8
wenzelm@26741
     9
section {* Overview *}
wenzelm@26741
    10
wenzelm@26741
    11
text {*
wenzelm@26741
    12
  The \emph{Isabelle} system essentially provides a generic
wenzelm@26741
    13
  infrastructure for building deductive systems (programmed in
wenzelm@26741
    14
  Standard ML), with a special focus on interactive theorem proving in
wenzelm@26741
    15
  higher-order logics.  In the olden days even end-users would refer
wenzelm@26741
    16
  to certain ML functions (goal commands, tactics, tacticals etc.) to
wenzelm@26741
    17
  pursue their everyday theorem proving tasks
wenzelm@26741
    18
  \cite{isabelle-intro,isabelle-ref}.
wenzelm@26741
    19
  
wenzelm@26741
    20
  In contrast \emph{Isar} provides an interpreted language environment
wenzelm@26741
    21
  of its own, which has been specifically tailored for the needs of
wenzelm@26741
    22
  theory and proof development.  Compared to raw ML, the Isabelle/Isar
wenzelm@26741
    23
  top-level provides a more robust and comfortable development
wenzelm@26741
    24
  platform, with proper support for theory development graphs,
wenzelm@26741
    25
  single-step transactions with unlimited undo, etc.  The
wenzelm@26741
    26
  Isabelle/Isar version of the \emph{Proof~General} user interface
wenzelm@26741
    27
  \cite{proofgeneral,Aspinall:TACAS:2000} provides an adequate
wenzelm@26741
    28
  front-end for interactive theory and proof development in this
wenzelm@26741
    29
  advanced theorem proving environment.
wenzelm@26741
    30
wenzelm@26741
    31
  \medskip Apart from the technical advances over bare-bones ML
wenzelm@26741
    32
  programming, the main purpose of the Isar language is to provide a
wenzelm@26741
    33
  conceptually different view on machine-checked proofs
wenzelm@26741
    34
  \cite{Wenzel:1999:TPHOL,Wenzel-PhD}.  ``Isar'' stands for
wenzelm@26741
    35
  ``Intelligible semi-automated reasoning''.  Drawing from both the
wenzelm@26741
    36
  traditions of informal mathematical proof texts and high-level
wenzelm@26741
    37
  programming languages, Isar offers a versatile environment for
wenzelm@26741
    38
  structured formal proof documents.  Thus properly written Isar
wenzelm@26741
    39
  proofs become accessible to a broader audience than unstructured
wenzelm@26741
    40
  tactic scripts (which typically only provide operational information
wenzelm@26741
    41
  for the machine).  Writing human-readable proof texts certainly
wenzelm@26741
    42
  requires some additional efforts by the writer to achieve a good
wenzelm@26741
    43
  presentation, both of formal and informal parts of the text.  On the
wenzelm@26741
    44
  other hand, human-readable formal texts gain some value in their own
wenzelm@26741
    45
  right, independently of the mechanic proof-checking process.
wenzelm@26741
    46
wenzelm@26741
    47
  Despite its grand design of structured proof texts, Isar is able to
wenzelm@26741
    48
  assimilate the old tactical style as an ``improper'' sub-language.
wenzelm@26741
    49
  This provides an easy upgrade path for existing tactic scripts, as
wenzelm@26741
    50
  well as additional means for interactive experimentation and
wenzelm@26741
    51
  debugging of structured proofs.  Isabelle/Isar supports a broad
wenzelm@26741
    52
  range of proof styles, both readable and unreadable ones.
wenzelm@26741
    53
wenzelm@26741
    54
  \medskip The Isabelle/Isar framework is generic and should work
wenzelm@26741
    55
  reasonably well for any Isabelle object-logic that conforms to the
wenzelm@26741
    56
  natural deduction view of the Isabelle/Pure framework.  Major
wenzelm@26741
    57
  Isabelle logics like HOL \cite{isabelle-HOL}, HOLCF
wenzelm@26741
    58
  \cite{MuellerNvOS99}, FOL \cite{isabelle-logics}, and ZF
wenzelm@26741
    59
  \cite{isabelle-ZF} have already been set up for end-users.
wenzelm@26741
    60
*}
wenzelm@26741
    61
wenzelm@26741
    62
wenzelm@26741
    63
section {* Quick start *}
wenzelm@26741
    64
wenzelm@26741
    65
subsection {* Terminal sessions *}
wenzelm@26741
    66
wenzelm@26741
    67
text {*
wenzelm@26760
    68
  Isar is already part of Isabelle.  The low-level @{verbatim
wenzelm@26760
    69
  isabelle} binary provides option @{verbatim "-I"} to run the
wenzelm@26760
    70
  Isabelle/Isar interaction loop at startup, rather than the raw ML
wenzelm@26760
    71
  top-level.  So the most basic way to do anything with Isabelle/Isar
wenzelm@26760
    72
  is as follows:
wenzelm@26760
    73
\begin{ttbox}  % FIXME update
wenzelm@26741
    74
isabelle -I HOL\medskip
wenzelm@26741
    75
\out{> Welcome to Isabelle/HOL (Isabelle2005)}\medskip
wenzelm@26741
    76
theory Foo imports Main begin;
wenzelm@26741
    77
definition foo :: nat where "foo == 1";
wenzelm@26741
    78
lemma "0 < foo" by (simp add: foo_def);
wenzelm@26741
    79
end;
wenzelm@26741
    80
\end{ttbox}
wenzelm@26741
    81
wenzelm@26760
    82
  Note that any Isabelle/Isar command may be retracted by @{command
wenzelm@26760
    83
  "undo"}.  See the Isabelle/Isar Quick Reference
wenzelm@26760
    84
  (\appref{ap:refcard}) for a comprehensive overview of available
wenzelm@26760
    85
  commands and other language elements.
wenzelm@26741
    86
*}
wenzelm@26741
    87
wenzelm@26741
    88
wenzelm@26741
    89
subsection {* Proof General *}
wenzelm@26741
    90
wenzelm@26741
    91
text {*
wenzelm@26741
    92
  Plain TTY-based interaction as above used to be quite feasible with
wenzelm@26741
    93
  traditional tactic based theorem proving, but developing Isar
wenzelm@26741
    94
  documents really demands some better user-interface support.  The
wenzelm@26741
    95
  Proof~General environment by David Aspinall
wenzelm@26741
    96
  \cite{proofgeneral,Aspinall:TACAS:2000} offers a generic Emacs
wenzelm@26741
    97
  interface for interactive theorem provers that organizes all the
wenzelm@26741
    98
  cut-and-paste and forward-backward walk through the text in a very
wenzelm@26741
    99
  neat way.  In Isabelle/Isar, the current position within a partial
wenzelm@26741
   100
  proof document is equally important than the actual proof state.
wenzelm@26741
   101
  Thus Proof~General provides the canonical working environment for
wenzelm@26741
   102
  Isabelle/Isar, both for getting acquainted (e.g.\ by replaying
wenzelm@26741
   103
  existing Isar documents) and for production work.
wenzelm@26741
   104
*}
wenzelm@26741
   105
wenzelm@26741
   106
wenzelm@26741
   107
subsubsection{* Proof~General as default Isabelle interface *}
wenzelm@26741
   108
wenzelm@26741
   109
text {*
wenzelm@26741
   110
  The Isabelle interface wrapper script provides an easy way to invoke
wenzelm@26741
   111
  Proof~General (including XEmacs or GNU Emacs).  The default
wenzelm@26741
   112
  configuration of Isabelle is smart enough to detect the
wenzelm@26741
   113
  Proof~General distribution in several canonical places (e.g.\
wenzelm@26760
   114
  @{verbatim "$ISABELLE_HOME/contrib/ProofGeneral"}).  Thus the
wenzelm@26760
   115
  capital @{verbatim Isabelle} executable would already refer to the
wenzelm@26760
   116
  @{verbatim "ProofGeneral/isar"} interface without further ado.  The
wenzelm@26760
   117
  Isabelle interface script provides several options; pass @{verbatim
wenzelm@26760
   118
  "-?"}  to see its usage.
wenzelm@26741
   119
wenzelm@26741
   120
  With the proper Isabelle interface setup, Isar documents may now be edited by
wenzelm@26741
   121
  visiting appropriate theory files, e.g.\ 
wenzelm@26741
   122
\begin{ttbox}
wenzelm@26741
   123
Isabelle \({\langle}isabellehome{\rangle}\)/src/HOL/Isar_examples/Summation.thy
wenzelm@26741
   124
\end{ttbox}
wenzelm@26741
   125
  Beginners may note the tool bar for navigating forward and backward
wenzelm@26741
   126
  through the text (this depends on the local Emacs installation).
wenzelm@26741
   127
  Consult the Proof~General documentation \cite{proofgeneral} for
wenzelm@26760
   128
  further basic command sequences, in particular ``@{verbatim "C-c C-return"}''
wenzelm@26760
   129
  and ``@{verbatim "C-c u"}''.
wenzelm@26741
   130
wenzelm@26741
   131
  \medskip Proof~General may be also configured manually by giving
wenzelm@26741
   132
  Isabelle settings like this (see also \cite{isabelle-sys}):
wenzelm@26741
   133
wenzelm@26741
   134
\begin{ttbox}
wenzelm@26741
   135
ISABELLE_INTERFACE=\$ISABELLE_HOME/contrib/ProofGeneral/isar/interface
wenzelm@26741
   136
PROOFGENERAL_OPTIONS=""
wenzelm@26741
   137
\end{ttbox}
wenzelm@26760
   138
  You may have to change @{verbatim
wenzelm@26760
   139
  "$ISABELLE_HOME/contrib/ProofGeneral"} to the actual installation
wenzelm@26760
   140
  directory of Proof~General.
wenzelm@26741
   141
wenzelm@26741
   142
  \medskip Apart from the Isabelle command line, defaults for
wenzelm@26741
   143
  interface options may be given by the \texttt{PROOFGENERAL_OPTIONS}
wenzelm@26741
   144
  setting.  For example, the Emacs executable to be used may be
wenzelm@26741
   145
  configured in Isabelle's settings like this:
wenzelm@26741
   146
\begin{ttbox}
wenzelm@26741
   147
PROOFGENERAL_OPTIONS="-p xemacs-mule"  
wenzelm@26741
   148
\end{ttbox}
wenzelm@26741
   149
wenzelm@26760
   150
  Occasionally, a user's @{verbatim "~/.emacs"} file contains code
wenzelm@26760
   151
  that is incompatible with the (X)Emacs version used by
wenzelm@26760
   152
  Proof~General, causing the interface startup to fail prematurely.
wenzelm@26760
   153
  Here the \texttt{-u false} option helps to get the interface process
wenzelm@26760
   154
  up and running.  Note that additional Lisp customization code may
wenzelm@26760
   155
  reside in \texttt{proofgeneral-settings.el} of @{verbatim
wenzelm@26760
   156
  "$ISABELLE_HOME/etc"} or @{verbatim "$ISABELLE_HOME_USER/etc"}.
wenzelm@26741
   157
*}
wenzelm@26741
   158
wenzelm@26741
   159
wenzelm@26741
   160
subsubsection {* The X-Symbol package *}
wenzelm@26741
   161
wenzelm@26741
   162
text {*
wenzelm@26741
   163
  Proof~General incorporates a version of the Emacs X-Symbol package
wenzelm@26741
   164
  \cite{x-symbol}, which handles proper mathematical symbols displayed
wenzelm@26741
   165
  on screen.  Pass option \texttt{-x true} to the Isabelle interface
wenzelm@26741
   166
  script, or check the appropriate Proof~General menu setting by hand.
wenzelm@26741
   167
  The main challenge of getting X-Symbol to work properly is the
wenzelm@26741
   168
  underlying (semi-automated) X11 font setup.
wenzelm@26741
   169
wenzelm@26741
   170
  \medskip Using proper mathematical symbols in Isabelle theories can
wenzelm@26741
   171
  be very convenient for readability of large formulas.  On the other
wenzelm@26741
   172
  hand, the plain ASCII sources easily become somewhat unintelligible.
wenzelm@26760
   173
  For example, @{text "\<Longrightarrow>"} would appear as @{verbatim "\<Longrightarrow>"} according
wenzelm@26741
   174
  the default set of Isabelle symbols.  Nevertheless, the Isabelle
wenzelm@26760
   175
  document preparation system (see \secref{sec:document-prep}) will be
wenzelm@26741
   176
  happy to print non-ASCII symbols properly.  It is even possible to
wenzelm@26741
   177
  invent additional notation beyond the display capabilities of Emacs
wenzelm@26741
   178
  and X-Symbol.
wenzelm@26741
   179
*}
wenzelm@26741
   180
wenzelm@26741
   181
wenzelm@26741
   182
section {* Isabelle/Isar theories *}
wenzelm@26741
   183
wenzelm@26741
   184
text {*
wenzelm@26741
   185
  Isabelle/Isar offers the following main improvements over classic
wenzelm@26741
   186
  Isabelle.
wenzelm@26741
   187
wenzelm@26741
   188
  \begin{enumerate}
wenzelm@26741
   189
  
wenzelm@26741
   190
  \item A \emph{theory format} that integrates specifications and
wenzelm@26741
   191
  proofs, supporting interactive development and unlimited undo
wenzelm@26741
   192
  operation.
wenzelm@26741
   193
  
wenzelm@26741
   194
  \item A \emph{formal proof document language} designed to support
wenzelm@26741
   195
  intelligible semi-automated reasoning.  Instead of putting together
wenzelm@26741
   196
  unreadable tactic scripts, the author is enabled to express the
wenzelm@26741
   197
  reasoning in way that is close to usual mathematical practice.  The
wenzelm@26741
   198
  old tactical style has been assimilated as ``improper'' language
wenzelm@26741
   199
  elements.
wenzelm@26741
   200
  
wenzelm@26741
   201
  \item A simple document preparation system, for typesetting formal
wenzelm@26741
   202
  developments together with informal text.  The resulting
wenzelm@26741
   203
  hyper-linked PDF documents are equally well suited for WWW
wenzelm@26741
   204
  presentation and as printed copies.
wenzelm@26741
   205
wenzelm@26741
   206
  \end{enumerate}
wenzelm@26741
   207
wenzelm@26741
   208
  The Isar proof language is embedded into the new theory format as a
wenzelm@26741
   209
  proper sub-language.  Proof mode is entered by stating some
wenzelm@26760
   210
  @{command "theorem"} or @{command "lemma"} at the theory level, and
wenzelm@26760
   211
  left again with the final conclusion (e.g.\ via @{command "qed"}).
wenzelm@26760
   212
  A few theory specification mechanisms also require some proof, such
wenzelm@26760
   213
  as HOL's @{command "typedef"} which demands non-emptiness of the
wenzelm@26741
   214
  representing sets.
wenzelm@26741
   215
*}
wenzelm@26741
   216
wenzelm@26741
   217
wenzelm@26741
   218
subsection {* Document preparation \label{sec:document-prep} *}
wenzelm@26741
   219
wenzelm@26741
   220
text {*
wenzelm@26741
   221
  Isabelle/Isar provides a simple document preparation system based on
wenzelm@26741
   222
  existing {PDF-\LaTeX} technology, with full support of hyper-links
wenzelm@26741
   223
  (both local references and URLs), bookmarks, and thumbnails.  Thus
wenzelm@26741
   224
  the results are equally well suited for WWW browsing and as printed
wenzelm@26741
   225
  copies.
wenzelm@26741
   226
wenzelm@26741
   227
  \medskip
wenzelm@26741
   228
wenzelm@26741
   229
  Isabelle generates {\LaTeX} output as part of the run of a
wenzelm@26741
   230
  \emph{logic session} (see also \cite{isabelle-sys}).  Getting
wenzelm@26741
   231
  started with a working configuration for common situations is quite
wenzelm@26760
   232
  easy by using the Isabelle @{verbatim mkdir} and @{verbatim make}
wenzelm@26760
   233
  tools.  First invoke
wenzelm@26741
   234
\begin{ttbox}
wenzelm@26741
   235
  isatool mkdir Foo
wenzelm@26741
   236
\end{ttbox}
wenzelm@26760
   237
  to initialize a separate directory for session @{verbatim Foo} ---
wenzelm@26760
   238
  it is safe to experiment, since \texttt{isatool mkdir} never
wenzelm@26760
   239
  overwrites existing files.  Ensure that @{verbatim "Foo/ROOT.ML"}
wenzelm@26760
   240
  holds ML commands to load all theories required for this session;
wenzelm@26760
   241
  furthermore @{verbatim "Foo/document/root.tex"} should include any
wenzelm@26760
   242
  special {\LaTeX} macro packages required for your document (the
wenzelm@26760
   243
  default is usually sufficient as a start).
wenzelm@26741
   244
wenzelm@26760
   245
  The session is controlled by a separate @{verbatim IsaMakefile}
wenzelm@26760
   246
  (with crude source dependencies by default).  This file is located
wenzelm@26760
   247
  one level up from the @{verbatim Foo} directory location.  Now
wenzelm@26760
   248
  invoke
wenzelm@26741
   249
\begin{ttbox}
wenzelm@26741
   250
  isatool make Foo
wenzelm@26741
   251
\end{ttbox}
wenzelm@26760
   252
  to run the @{verbatim Foo} session, with browser information and
wenzelm@26741
   253
  document preparation enabled.  Unless any errors are reported by
wenzelm@26741
   254
  Isabelle or {\LaTeX}, the output will appear inside the directory
wenzelm@26760
   255
  @{verbatim ISABELLE_BROWSER_INFO}, as reported by the batch job in
wenzelm@26741
   256
  verbose mode.
wenzelm@26741
   257
wenzelm@26760
   258
  \medskip You may also consider to tune the @{verbatim usedir}
wenzelm@26760
   259
  options in @{verbatim IsaMakefile}, for example to change the output
wenzelm@26760
   260
  format from @{verbatim pdf} to @{verbatim dvi}, or activate the
wenzelm@26760
   261
  @{verbatim "-D"} option to retain a second copy of the generated
wenzelm@26760
   262
  {\LaTeX} sources.
wenzelm@26741
   263
wenzelm@26741
   264
  \medskip See \emph{The Isabelle System Manual} \cite{isabelle-sys}
wenzelm@26741
   265
  for further details on Isabelle logic sessions and theory
wenzelm@26741
   266
  presentation.  The Isabelle/HOL tutorial \cite{isabelle-hol-book}
wenzelm@26741
   267
  also covers theory presentation issues.
wenzelm@26741
   268
*}
wenzelm@26741
   269
wenzelm@26741
   270
wenzelm@26741
   271
subsection {* How to write Isar proofs anyway? \label{sec:isar-howto} *}
wenzelm@26741
   272
wenzelm@26741
   273
text {*
wenzelm@26741
   274
  This is one of the key questions, of course.  First of all, the
wenzelm@26741
   275
  tactic script emulation of Isabelle/Isar essentially provides a
wenzelm@26741
   276
  clarified version of the very same unstructured proof style of
wenzelm@26741
   277
  classic Isabelle.  Old-time users should quickly become acquainted
wenzelm@26741
   278
  with that (slightly degenerative) view of Isar.
wenzelm@26741
   279
wenzelm@26741
   280
  Writing \emph{proper} Isar proof texts targeted at human readers is
wenzelm@26741
   281
  quite different, though.  Experienced users of the unstructured
wenzelm@26741
   282
  style may even have to unlearn some of their habits to master proof
wenzelm@26741
   283
  composition in Isar.  In contrast, new users with less experience in
wenzelm@26741
   284
  old-style tactical proving, but a good understanding of mathematical
wenzelm@26741
   285
  proof in general, often get started easier.
wenzelm@26741
   286
wenzelm@26741
   287
  \medskip The present text really is only a reference manual on
wenzelm@26741
   288
  Isabelle/Isar, not a tutorial.  Nevertheless, we will attempt to
wenzelm@26741
   289
  give some clues of how the concepts introduced here may be put into
wenzelm@26760
   290
  practice.  \Appref{ap:refcard} provides a quick reference card of
wenzelm@26760
   291
  the most common Isabelle/Isar language elements.  \Appref{ap:conv}
wenzelm@26760
   292
  offers some practical hints on converting existing Isabelle theories
wenzelm@26760
   293
  and proof scripts to the new format (without restructuring proofs).
wenzelm@26741
   294
wenzelm@26741
   295
  Further issues concerning the Isar concepts are covered in the
wenzelm@26741
   296
  literature
wenzelm@26741
   297
  \cite{Wenzel:1999:TPHOL,Wiedijk:2000:MV,Bauer-Wenzel:2000:HB,Bauer-Wenzel:2001}.
wenzelm@26741
   298
  The author's PhD thesis \cite{Wenzel-PhD} presently provides the
wenzelm@26741
   299
  most complete exposition of Isar foundations, techniques, and
wenzelm@26741
   300
  applications.  A number of example applications are distributed with
wenzelm@26741
   301
  Isabelle, and available via the Isabelle WWW library (e.g.\
wenzelm@26741
   302
  \url{http://isabelle.in.tum.de/library/}).  The ``Archive of Formal
wenzelm@26741
   303
  Proofs'' \url{http://afp.sourceforge.net/} also provides plenty of
wenzelm@26741
   304
  examples, both in proper Isar proof style and unstructured tactic
wenzelm@26741
   305
  scripts.
wenzelm@26741
   306
*}
wenzelm@26741
   307
wenzelm@26741
   308
end