doc-src/Ref/introduction.tex
author paulson
Wed, 02 Jul 1997 16:46:36 +0200
changeset 3485 f27a30a18a17
parent 3200 ea2310ba01da
child 4274 2048e7a79d09
permissions -rw-r--r--
Now there are TWO spaces after each full stop, so that the Emacs sentence primitives work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3200
ea2310ba01da sysman refs;
wenzelm
parents: 3108
diff changeset
     1
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     2
%% $Id$
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     3
286
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
     4
\chapter{Basic Use of Isabelle}\index{sessions|(} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     5
The Reference Manual is a comprehensive description of Isabelle
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     6
proper, including all \ML{} commands, functions and packages.  It
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     7
really is intended for reference, perhaps for browsing, but not for
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     8
reading through.  It is not a tutorial, but assumes familiarity with
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     9
the basic logical concepts of Isabelle.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    10
286
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
    11
When you are looking for a way of performing some task, scan the Table of
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
    12
Contents for a relevant heading.  Functions are organized by their purpose,
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
    13
by their operands (subgoals, tactics, theorems), and by their usefulness.
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
    14
In each section, basic functions appear first, then advanced functions, and
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    15
finally esoteric functions.  Use the Index when you are looking for the
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    16
definition of a particular Isabelle function.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    17
286
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
    18
A few examples are presented.  Many examples files are distributed with
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
    19
Isabelle, however; please experiment interactively.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    20
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    21
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    22
\section{Basic interaction with Isabelle}
2225
78a8faae780f Added instructions on starting up
paulson
parents: 1372
diff changeset
    23
\index{starting up|bold}\nobreak
78a8faae780f Added instructions on starting up
paulson
parents: 1372
diff changeset
    24
%
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    25
We assume that your local Isabelle administrator (this might be you!)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    26
has already installed the \Pure\ system and several object-logics
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    27
properly --- otherwise see the {\tt INSTALL} file in the top-level
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    28
directory of the distribution on how to build it.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    29
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    30
\medskip Let $\langle isabellehome \rangle$ denote the location where
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    31
the distribution has been installed.  To run Isabelle from a the shell
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    32
prompt within an ordinary text terminal session, simply type:
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    33
\begin{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    34
\({\langle}isabellehome{\rangle}\)/bin/isabelle
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    35
\end{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    36
This should start an interactive \ML{} session with the default
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    37
object-logic already preloaded.  All Isabelle commands are bound to
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    38
\ML{} identifiers.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    39
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    40
Subsequently we assume that {\tt \(\langle isabellehome \rangle\)/bin}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    41
has been added to your shell's search path, in order to avoid typing
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    42
full path specifications of the executable files.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    43
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    44
The object-logic image to load may be also specified explicitly as an
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    45
argument to the {\tt isabelle} command, e.g.:
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    46
\begin{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    47
isabelle FOL
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    48
\end{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    49
This should put you into the world of polymorphic first-order logic
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    50
(assuming that {\FOL} has been pre-built).
2225
78a8faae780f Added instructions on starting up
paulson
parents: 1372
diff changeset
    51
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    52
\index{saving your work|bold} Isabelle provides no means of storing
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    53
theorems or proofs on files.  Theorems are simply part of the \ML{}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    54
state and are named by \ML{} identifiers.  To save your work between
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    55
sessions, you must dump the \ML{} system state to a file.  This is done
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    56
automatically when ending the session normally (e.g.\ by typing
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    57
control-D), provided that the image has been opened \emph{writable} in
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    58
the first place.  The standard object-logics are usually read-only, so
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    59
you probably have to create a private working copy first.  For example,
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    60
the following shell command puts you into a writable Isabelle session
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    61
of name \texttt{Foo} that initially contains just \FOL:
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    62
\begin{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    63
isabelle FOL Foo
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    64
\end{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    65
Ending the \texttt{Foo} session with control-D will cause the complete
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    66
\ML{} world to be saved somewhere in your home directory\footnote{The
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    67
  default location is in \texttt{\~\relax/isabelle/heaps}, but this
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    68
  depends on your local configuration.}.  Make sure there is enough
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    69
space available! Then one may later continue at exactly the same point
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    70
by running
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    71
\begin{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    72
isabelle Foo  
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    73
\end{ttbox}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    74
3200
ea2310ba01da sysman refs;
wenzelm
parents: 3108
diff changeset
    75
More details about \texttt{isabelle} may be found in the \emph{System
ea2310ba01da sysman refs;
wenzelm
parents: 3108
diff changeset
    76
  Manual}.
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    77
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    78
\medskip Saving the state is not enough.  Record, on a file, the
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    79
top-level commands that generate your theories and proofs.  Such a
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    80
record allows you to replay the proofs whenever required, for instance
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    81
after making minor changes to the axioms.  Ideally, your record will
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    82
be somewhat intelligible to others as a formal description of your
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    83
work.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    84
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    85
\medskip There are more comfortable user interfaces than the
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    86
bare-bones \ML{} top-level run from a text terminal.  The
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    87
\texttt{Isabelle} executable (note the capital I) runs one such
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    88
interface, depending on your local configuration.  Furthermore there
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
    89
are a number of external utilities available.  These are started
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    90
uniformly via the \texttt{isatool} wrapper.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    91
3200
ea2310ba01da sysman refs;
wenzelm
parents: 3108
diff changeset
    92
Again, see the \emph{System Manual} for more information user
ea2310ba01da sysman refs;
wenzelm
parents: 3108
diff changeset
    93
interfaces and utilities.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    94
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    95
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    96
\section{Ending a session}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    97
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    98
quit    : unit -> unit
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    99
exit    : int -> unit
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   100
commit  : unit -> unit
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   101
\end{ttbox}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   102
\begin{ttdescription}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   103
\item[\ttindexbold{quit}();] ends the Isabelle session, without saving
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   104
  the state.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   105
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   106
\item[\ttindexbold{exit}();] same as {\tt quit}, passing a return code
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   107
  to the operating system.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   108
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   109
\item[\ttindexbold{commit}();] saves the current state without ending
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   110
  the session, provided that the logic image is opened read-write.
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   111
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   112
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   113
Typing control-D also finishes the session in essentially the same way
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   114
as the sequence {\tt commit(); quit();} would.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   115
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   116
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   117
\section{Reading ML files}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   118
\index{files!reading}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   119
\begin{ttbox} 
138
9ba8bff1addc added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents: 104
diff changeset
   120
cd              : string -> unit
884
35c836adf48f added documentation of pwd
clasohm
parents: 508
diff changeset
   121
pwd             : unit -> string
138
9ba8bff1addc added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents: 104
diff changeset
   122
use             : string -> unit
9ba8bff1addc added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents: 104
diff changeset
   123
time_use        : string -> unit
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   124
\end{ttbox}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   125
Section~\ref{LoadingTheories} describes commands for loading theory files.
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   126
\begin{ttdescription}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   127
\item[\ttindexbold{cd} "{\it dir}";]
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   128
  changes the current directory to {\it dir}.  This is the default directory
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   129
  for reading files and for writing temporary files.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   130
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   131
\item[\ttindexbold{pwd}();] returns the path of the current directory.
884
35c836adf48f added documentation of pwd
clasohm
parents: 508
diff changeset
   132
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   133
\item[\ttindexbold{use} "$file$";]  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   134
reads the given {\it file} as input to the \ML{} session.  Reading a file
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   135
of Isabelle commands is the usual way of replaying a proof.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   136
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   137
\item[\ttindexbold{time_use} "$file$";]  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   138
performs {\tt use~"$file$"} and prints the total execution time.
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   139
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   140
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   141
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   142
\section{Setting flags}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   143
\begin{ttbox}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   144
set     : bool ref -> bool
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   145
reset   : bool ref -> bool
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   146
toggle  : bool ref -> bool
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   147
\end{ttbox}\index{*set}\index{*reset}\index{*toggle}
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3200
diff changeset
   148
These are some shorthands for manipulating boolean references.  The new
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   149
value is returned.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   150
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
   151
508
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   152
\section{Printing of terms and theorems}\label{sec:printing-control}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   153
\index{printing control|(}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   154
Isabelle's pretty printer is controlled by a number of parameters.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   155
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   156
\subsection{Printing limits}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   157
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   158
Pretty.setdepth  : int -> unit
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   159
Pretty.setmargin : int -> unit
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   160
print_depth      : int -> unit
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   161
\end{ttbox}
508
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   162
These set limits for terminal output.  See also {\tt goals_limit}, which
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   163
limits the number of subgoals printed (page~\pageref{sec:goals-printing}).
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   164
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   165
\begin{ttdescription}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   166
\item[\ttindexbold{Pretty.setdepth} \(d\);]  
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   167
  tells Isabelle's pretty printer to limit the printing depth to~$d$.  This
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   168
  affects Isabelle's display of theorems and terms.  The default value
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   169
  is~0, which permits printing to an arbitrary depth.  Useful values for
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   170
  $d$ are~10 and~20.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   171
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   172
\item[\ttindexbold{Pretty.setmargin} \(m\);]  
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   173
  tells Isabelle's pretty printer to assume a right margin (page width)
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   174
  of~$m$.  The initial margin is~80.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   175
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   176
\item[\ttindexbold{print_depth} \(n\);]  
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   177
  limits the printing depth of complex \ML{} values, such as theorems and
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   178
  terms.  This command affects the \ML{} top level and its effect is
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   179
  compiler-dependent.  Typically $n$ should be less than~10.
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   180
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   181
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   182
508
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   183
\subsection{Printing of hypotheses, brackets, types and sorts}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   184
\index{meta-assumptions!printing of}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   185
\index{types!printing of}\index{sorts!printing of}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   186
\begin{ttbox} 
508
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   187
show_hyps     : bool ref \hfill{\bf initially true}
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   188
show_brackets : bool ref \hfill{\bf initially false}
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   189
show_types    : bool ref \hfill{\bf initially false}
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   190
show_sorts    : bool ref \hfill{\bf initially false}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   191
\end{ttbox}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   192
These flags allow you to control how much information is displayed for
508
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   193
terms and theorems.  The hypotheses are normally shown; superfluous
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   194
parentheses are not.  Types and sorts are normally hidden.  Displaying
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   195
types and sorts may explain why a polymorphic inference rule fails to
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   196
resolve with some goal.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   197
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   198
\begin{ttdescription}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   199
\item[\ttindexbold{show_hyps} := false;]   
332
01b87a921967 final Springer copy
lcp
parents: 322
diff changeset
   200
makes Isabelle show each meta-level hypothesis as a dot.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   201
508
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   202
\item[\ttindexbold{show_brackets} := true;] 
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   203
  makes Isabelle show full bracketing.  This reveals the
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   204
  grouping of infix operators.
d8b6999ca364 addition of show_brackets
lcp
parents: 332
diff changeset
   205
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   206
\item[\ttindexbold{show_types} := true;]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   207
makes Isabelle show types when printing a term or theorem.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   208
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   209
\item[\ttindexbold{show_sorts} := true;]
1102
a203181678d3 show_sorts:=true forces display of types
lcp
parents: 884
diff changeset
   210
makes Isabelle show both types and the sorts of type variables.  It does not
a203181678d3 show_sorts:=true forces display of types
lcp
parents: 884
diff changeset
   211
matter whether {\tt show_types} is also~{\tt true}. 
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   212
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   213
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   214
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   215
\subsection{$\eta$-contraction before printing}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   216
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   217
eta_contract: bool ref \hfill{\bf initially false}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   218
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   219
The {\bf $\eta$-contraction law} asserts $(\lambda x.f(x))\equiv f$,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   220
provided $x$ is not free in ~$f$.  It asserts {\bf extensionality} of
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   221
functions: $f\equiv g$ if $f(x)\equiv g(x)$ for all~$x$.  Higher-order
332
01b87a921967 final Springer copy
lcp
parents: 322
diff changeset
   222
unification frequently puts terms into a fully $\eta$-expanded form.  For
158
c2fcb6c07689 Correction to eta-contraction; thanks to Markus W.
lcp
parents: 149
diff changeset
   223
example, if $F$ has type $(\tau\To\tau)\To\tau$ then its expanded form is
c2fcb6c07689 Correction to eta-contraction; thanks to Markus W.
lcp
parents: 149
diff changeset
   224
$\lambda h.F(\lambda x.h(x))$.  By default, the user sees this expanded
c2fcb6c07689 Correction to eta-contraction; thanks to Markus W.
lcp
parents: 149
diff changeset
   225
form.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   226
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   227
\begin{ttdescription}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   228
\item[\ttindexbold{eta_contract} := true;]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   229
makes Isabelle perform $\eta$-contractions before printing, so that
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   230
$\lambda h.F(\lambda x.h(x))$ appears simply as~$F$.  The
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   231
distinction between a term and its $\eta$-expanded form occasionally
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   232
matters.
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   233
\end{ttdescription}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   234
\index{printing control|)}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   235
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   236
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   237
\section{Displaying exceptions as error messages}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   238
\index{exceptions!printing of}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   239
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   240
print_exn: exn -> 'a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   241
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   242
Certain Isabelle primitives, such as the forward proof functions {\tt RS}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   243
and {\tt RSN}, are called both interactively and from programs.  They
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   244
indicate errors not by printing messages, but by raising exceptions.  For
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   245
interactive use, \ML's reporting of an uncaught exception is 
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   246
uninformative.  The Poly/ML function {\tt exception_trace} can generate a
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   247
backtrace.\index{Poly/{\ML} compiler}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   248
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   249
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   250
\item[\ttindexbold{print_exn} $e$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   251
displays the exception~$e$ in a readable manner, and then re-raises~$e$.
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   252
Typical usage is~\hbox{\tt $EXP$ handle e => print_exn e;}, where
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   253
$EXP$ is an expression that may raise an exception.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   254
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   255
{\tt print_exn} can display the following common exceptions, which concern
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   256
types, terms, theorems and theories, respectively.  Each carries a message
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   257
and related information.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   258
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   259
exception TYPE   of string * typ list * term list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   260
exception TERM   of string * term list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   261
exception THM    of string * int * thm list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   262
exception THEORY of string * theory list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   263
\end{ttbox}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   264
\end{ttdescription}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   265
\begin{warn}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   266
  {\tt print_exn} prints terms by calling \ttindex{prin}, which obtains
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   267
  pretty printing information from the proof state last stored in the
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   268
  subgoal module.  The appearance of the output thus depends upon the
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   269
  theory used in the last interactive proof.
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   270
\end{warn}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   271
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   272
\index{sessions|)}