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