doc-src/IsarRef/Thy/intro.thy
author wenzelm
Thu, 15 May 2008 20:02:37 +0200
changeset 26908 25fb7241f32e
parent 26860 7c749112261c
child 26957 e3f04fdd994d
permissions -rw-r--r--
removed obsolete thumbpdf;
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@26860
   143
  interface options may be given by the @{verbatim 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@26860
   153
  Here the @{verbatim "-u false"} option helps to get the interface
wenzelm@26860
   154
  process up and running.  Note that additional Lisp customization
wenzelm@26860
   155
  code may reside in @{verbatim "proofgeneral-settings.el"} of
wenzelm@26860
   156
  @{verbatim "$ISABELLE_HOME/etc"} or @{verbatim
wenzelm@26860
   157
  "$ISABELLE_HOME_USER/etc"}.
wenzelm@26741
   158
*}
wenzelm@26741
   159
wenzelm@26741
   160
wenzelm@26741
   161
subsubsection {* The X-Symbol package *}
wenzelm@26741
   162
wenzelm@26741
   163
text {*
wenzelm@26741
   164
  Proof~General incorporates a version of the Emacs X-Symbol package
wenzelm@26741
   165
  \cite{x-symbol}, which handles proper mathematical symbols displayed
wenzelm@26860
   166
  on screen.  Pass option @{verbatim "-x true"} to the Isabelle
wenzelm@26860
   167
  interface script, or check the appropriate Proof~General menu
wenzelm@26860
   168
  setting by hand.  The main challenge of getting X-Symbol to work
wenzelm@26860
   169
  properly is the underlying (semi-automated) X11 font setup.
wenzelm@26741
   170
wenzelm@26741
   171
  \medskip Using proper mathematical symbols in Isabelle theories can
wenzelm@26741
   172
  be very convenient for readability of large formulas.  On the other
wenzelm@26741
   173
  hand, the plain ASCII sources easily become somewhat unintelligible.
wenzelm@26760
   174
  For example, @{text "\<Longrightarrow>"} would appear as @{verbatim "\<Longrightarrow>"} according
wenzelm@26741
   175
  the default set of Isabelle symbols.  Nevertheless, the Isabelle
wenzelm@26760
   176
  document preparation system (see \secref{sec:document-prep}) will be
wenzelm@26741
   177
  happy to print non-ASCII symbols properly.  It is even possible to
wenzelm@26741
   178
  invent additional notation beyond the display capabilities of Emacs
wenzelm@26741
   179
  and X-Symbol.
wenzelm@26741
   180
*}
wenzelm@26741
   181
wenzelm@26741
   182
wenzelm@26741
   183
section {* Isabelle/Isar theories *}
wenzelm@26741
   184
wenzelm@26741
   185
text {*
wenzelm@26741
   186
  Isabelle/Isar offers the following main improvements over classic
wenzelm@26741
   187
  Isabelle.
wenzelm@26741
   188
wenzelm@26741
   189
  \begin{enumerate}
wenzelm@26741
   190
  
wenzelm@26741
   191
  \item A \emph{theory format} that integrates specifications and
wenzelm@26741
   192
  proofs, supporting interactive development and unlimited undo
wenzelm@26741
   193
  operation.
wenzelm@26741
   194
  
wenzelm@26741
   195
  \item A \emph{formal proof document language} designed to support
wenzelm@26741
   196
  intelligible semi-automated reasoning.  Instead of putting together
wenzelm@26741
   197
  unreadable tactic scripts, the author is enabled to express the
wenzelm@26741
   198
  reasoning in way that is close to usual mathematical practice.  The
wenzelm@26741
   199
  old tactical style has been assimilated as ``improper'' language
wenzelm@26741
   200
  elements.
wenzelm@26741
   201
  
wenzelm@26741
   202
  \item A simple document preparation system, for typesetting formal
wenzelm@26741
   203
  developments together with informal text.  The resulting
wenzelm@26741
   204
  hyper-linked PDF documents are equally well suited for WWW
wenzelm@26741
   205
  presentation and as printed copies.
wenzelm@26741
   206
wenzelm@26741
   207
  \end{enumerate}
wenzelm@26741
   208
wenzelm@26741
   209
  The Isar proof language is embedded into the new theory format as a
wenzelm@26741
   210
  proper sub-language.  Proof mode is entered by stating some
wenzelm@26760
   211
  @{command "theorem"} or @{command "lemma"} at the theory level, and
wenzelm@26760
   212
  left again with the final conclusion (e.g.\ via @{command "qed"}).
wenzelm@26760
   213
  A few theory specification mechanisms also require some proof, such
wenzelm@26760
   214
  as HOL's @{command "typedef"} which demands non-emptiness of the
wenzelm@26741
   215
  representing sets.
wenzelm@26741
   216
*}
wenzelm@26741
   217
wenzelm@26741
   218
wenzelm@26741
   219
subsection {* Document preparation \label{sec:document-prep} *}
wenzelm@26741
   220
wenzelm@26741
   221
text {*
wenzelm@26741
   222
  Isabelle/Isar provides a simple document preparation system based on
wenzelm@26741
   223
  existing {PDF-\LaTeX} technology, with full support of hyper-links
wenzelm@26908
   224
  (both local references and URLs) and bookmarks.  Thus the results
wenzelm@26908
   225
  are equally well suited for WWW browsing and as printed copies.
wenzelm@26741
   226
wenzelm@26908
   227
  \medskip Isabelle generates {\LaTeX} output as part of the run of a
wenzelm@26741
   228
  \emph{logic session} (see also \cite{isabelle-sys}).  Getting
wenzelm@26741
   229
  started with a working configuration for common situations is quite
wenzelm@26760
   230
  easy by using the Isabelle @{verbatim mkdir} and @{verbatim make}
wenzelm@26760
   231
  tools.  First invoke
wenzelm@26741
   232
\begin{ttbox}
wenzelm@26741
   233
  isatool mkdir Foo
wenzelm@26741
   234
\end{ttbox}
wenzelm@26760
   235
  to initialize a separate directory for session @{verbatim Foo} ---
wenzelm@26860
   236
  it is safe to experiment, since @{verbatim "isatool mkdir"} never
wenzelm@26760
   237
  overwrites existing files.  Ensure that @{verbatim "Foo/ROOT.ML"}
wenzelm@26760
   238
  holds ML commands to load all theories required for this session;
wenzelm@26760
   239
  furthermore @{verbatim "Foo/document/root.tex"} should include any
wenzelm@26760
   240
  special {\LaTeX} macro packages required for your document (the
wenzelm@26760
   241
  default is usually sufficient as a start).
wenzelm@26741
   242
wenzelm@26760
   243
  The session is controlled by a separate @{verbatim IsaMakefile}
wenzelm@26760
   244
  (with crude source dependencies by default).  This file is located
wenzelm@26760
   245
  one level up from the @{verbatim Foo} directory location.  Now
wenzelm@26760
   246
  invoke
wenzelm@26741
   247
\begin{ttbox}
wenzelm@26741
   248
  isatool make Foo
wenzelm@26741
   249
\end{ttbox}
wenzelm@26760
   250
  to run the @{verbatim Foo} session, with browser information and
wenzelm@26741
   251
  document preparation enabled.  Unless any errors are reported by
wenzelm@26741
   252
  Isabelle or {\LaTeX}, the output will appear inside the directory
wenzelm@26760
   253
  @{verbatim ISABELLE_BROWSER_INFO}, as reported by the batch job in
wenzelm@26741
   254
  verbose mode.
wenzelm@26741
   255
wenzelm@26760
   256
  \medskip You may also consider to tune the @{verbatim usedir}
wenzelm@26760
   257
  options in @{verbatim IsaMakefile}, for example to change the output
wenzelm@26760
   258
  format from @{verbatim pdf} to @{verbatim dvi}, or activate the
wenzelm@26760
   259
  @{verbatim "-D"} option to retain a second copy of the generated
wenzelm@26760
   260
  {\LaTeX} sources.
wenzelm@26741
   261
wenzelm@26741
   262
  \medskip See \emph{The Isabelle System Manual} \cite{isabelle-sys}
wenzelm@26741
   263
  for further details on Isabelle logic sessions and theory
wenzelm@26741
   264
  presentation.  The Isabelle/HOL tutorial \cite{isabelle-hol-book}
wenzelm@26741
   265
  also covers theory presentation issues.
wenzelm@26741
   266
*}
wenzelm@26741
   267
wenzelm@26741
   268
wenzelm@26741
   269
subsection {* How to write Isar proofs anyway? \label{sec:isar-howto} *}
wenzelm@26741
   270
wenzelm@26741
   271
text {*
wenzelm@26741
   272
  This is one of the key questions, of course.  First of all, the
wenzelm@26741
   273
  tactic script emulation of Isabelle/Isar essentially provides a
wenzelm@26741
   274
  clarified version of the very same unstructured proof style of
wenzelm@26741
   275
  classic Isabelle.  Old-time users should quickly become acquainted
wenzelm@26741
   276
  with that (slightly degenerative) view of Isar.
wenzelm@26741
   277
wenzelm@26741
   278
  Writing \emph{proper} Isar proof texts targeted at human readers is
wenzelm@26741
   279
  quite different, though.  Experienced users of the unstructured
wenzelm@26741
   280
  style may even have to unlearn some of their habits to master proof
wenzelm@26741
   281
  composition in Isar.  In contrast, new users with less experience in
wenzelm@26741
   282
  old-style tactical proving, but a good understanding of mathematical
wenzelm@26741
   283
  proof in general, often get started easier.
wenzelm@26741
   284
wenzelm@26741
   285
  \medskip The present text really is only a reference manual on
wenzelm@26741
   286
  Isabelle/Isar, not a tutorial.  Nevertheless, we will attempt to
wenzelm@26741
   287
  give some clues of how the concepts introduced here may be put into
wenzelm@26852
   288
  practice.  Especially note that \appref{ap:refcard} provides a quick
wenzelm@26852
   289
  reference card of the most common Isabelle/Isar language elements.
wenzelm@26741
   290
wenzelm@26741
   291
  Further issues concerning the Isar concepts are covered in the
wenzelm@26741
   292
  literature
wenzelm@26741
   293
  \cite{Wenzel:1999:TPHOL,Wiedijk:2000:MV,Bauer-Wenzel:2000:HB,Bauer-Wenzel:2001}.
wenzelm@26741
   294
  The author's PhD thesis \cite{Wenzel-PhD} presently provides the
wenzelm@26741
   295
  most complete exposition of Isar foundations, techniques, and
wenzelm@26741
   296
  applications.  A number of example applications are distributed with
wenzelm@26741
   297
  Isabelle, and available via the Isabelle WWW library (e.g.\
wenzelm@26741
   298
  \url{http://isabelle.in.tum.de/library/}).  The ``Archive of Formal
wenzelm@26741
   299
  Proofs'' \url{http://afp.sourceforge.net/} also provides plenty of
wenzelm@26741
   300
  examples, both in proper Isar proof style and unstructured tactic
wenzelm@26741
   301
  scripts.
wenzelm@26741
   302
*}
wenzelm@26741
   303
wenzelm@26741
   304
end