104
|
1 |
%% $Id$
|
|
2 |
\maketitle
|
|
3 |
\pagenumbering{roman} \tableofcontents \clearfirst
|
|
4 |
|
|
5 |
\chapter{Introduction}
|
|
6 |
\index{sessions|(}
|
|
7 |
This manual is a comprehensive description of Isabelle, including all
|
|
8 |
commands, functions and packages. Please do not read it: it is intended
|
|
9 |
for reference. It is not a tutorial! The manual assumes
|
|
10 |
familiarity with the basic concepts explained in {\em Introduction to
|
|
11 |
Isabelle}.
|
|
12 |
|
|
13 |
Functions are organized by their purpose, by their operands (subgoals,
|
|
14 |
tactics, theorems), and by their usefulness. In each section, basic
|
|
15 |
functions appear first, then advanced functions, and finally esoteric
|
|
16 |
functions. When you are looking for a way of performing some task, scan
|
|
17 |
the Table of Contents for a relevant heading.
|
|
18 |
|
|
19 |
The Index provides an alphabetical listing. Page numbers of definitions
|
|
20 |
are printed in {\bf bold}, passing references in Roman type. Use the Index
|
|
21 |
when you are looking for the definition of a particular Isabelle function.
|
|
22 |
|
|
23 |
This manual contains few examples. Many files of examples are distributed
|
|
24 |
with Isabelle, however; please experiment interactively.
|
|
25 |
|
|
26 |
|
|
27 |
\section{Basic interaction with Isabelle}
|
|
28 |
\index{sessions!saving|bold}\index{saving your work|bold}
|
|
29 |
Isabelle provides no means of storing theorems or proofs on files.
|
|
30 |
Theorems are simply part of the \ML{} state and are named by \ML{}
|
|
31 |
identifiers. To save your work between sessions, you must save a copy of
|
|
32 |
the \ML{} image. The procedure for doing so is compiler-dependent:
|
|
33 |
\begin{itemize}
|
|
34 |
\item At the end of a session, Poly/\ML{} saves the state, provided you have
|
|
35 |
created a database for your own use. You can create a database by copying
|
|
36 |
an existing one, or by calling the Poly/\ML{} function {\tt make_database};
|
|
37 |
the latter course uses much less disc space. Note that a Poly/\ML{}
|
|
38 |
database {\bf does not} save the contents of references, such as the
|
|
39 |
current state of a backward proof.
|
|
40 |
|
|
41 |
\item With New Jersey \ML{} you must save the state explicitly before
|
|
42 |
ending the session. While Poly/\ML{} database can be small, a New Jersey
|
|
43 |
image occupies several megabytes.
|
|
44 |
\end{itemize}
|
|
45 |
See your \ML{} compiler's documentation for full instructions on saving the
|
|
46 |
state.
|
|
47 |
|
|
48 |
Saving the state is not enough. Record, on a file, the top-level commands
|
|
49 |
that generate your theories and proofs. Such a record allows you to replay
|
|
50 |
the proofs whenever required, for instance after making minor changes to
|
|
51 |
the axioms. Ideally, your record will be intelligible to others as a
|
|
52 |
formal description of your work.
|
|
53 |
|
|
54 |
Since Isabelle's user interface is the \ML{} top level, some kind of window
|
|
55 |
support is essential. One window displays the Isabelle session, while the
|
|
56 |
other displays a file --- your proof record --- being edited. Some people
|
|
57 |
use a screen editor such as Emacs, which supports windows and can manage
|
|
58 |
interactive sessions. Others prefer to use a workstation running the X Window
|
|
59 |
System.
|
|
60 |
|
|
61 |
|
|
62 |
\section{Ending a session}
|
|
63 |
\index{sessions!ending|bold}
|
|
64 |
\begin{ttbox}
|
|
65 |
quit : unit -> unit
|
|
66 |
commit : unit -> unit \hfill{\bf Poly/ML only}
|
|
67 |
exportML : string -> bool \hfill{\bf New Jersey ML only}
|
|
68 |
\end{ttbox}
|
|
69 |
\begin{description}
|
|
70 |
\item[\ttindexbold{quit}();]
|
|
71 |
aborts the Isabelle session, without saving the state.
|
|
72 |
|
|
73 |
\item[\ttindexbold{commit}();] saves the current state in your
|
|
74 |
Poly/\ML{} database without finishing the session. Values of reference
|
|
75 |
variables are lost, so never do this during an interactive proof!
|
|
76 |
|
|
77 |
\item[\ttindexbold{exportML} \tt"{\it file}";] saves an
|
|
78 |
image of your session to the given {\it file}.
|
|
79 |
\end{description}
|
|
80 |
|
|
81 |
\begin{warn}
|
|
82 |
Typing control-D also finishes the session, but its effect is
|
|
83 |
compiler-dependent. Poly/\ML{} will then save the state, if you have a
|
|
84 |
private database. New Jersey \ML{} will discard the state!
|
|
85 |
\end{warn}
|
|
86 |
|
|
87 |
|
|
88 |
\section{Reading files of proofs and theories}
|
|
89 |
\index{files, reading|bold}
|
|
90 |
\begin{ttbox}
|
|
91 |
cd : string -> unit
|
|
92 |
use : string -> unit
|
|
93 |
use_thy : string -> unit
|
|
94 |
time_use : string -> unit
|
|
95 |
time_use_thy : string -> unit
|
|
96 |
\end{ttbox}
|
|
97 |
\begin{description}
|
|
98 |
\item[\ttindexbold{cd} \tt"{\it dir}";] changes to {\it dir\/} the default
|
|
99 |
directory for reading files.
|
|
100 |
|
|
101 |
\item[\ttindexbold{use} \tt"$file$";]
|
|
102 |
reads the given {\it file} as input to the \ML{} session. Reading a file
|
|
103 |
of Isabelle commands is the usual way of replaying a proof.
|
|
104 |
|
|
105 |
\item[\ttindexbold{use_thy} \tt"$tname$";]
|
|
106 |
reads a theory definition from file {\it tname}{\tt.thy} and also reads
|
|
107 |
{\ML} commands from the file {\it tname}{\tt.ML}, if it exists. See
|
|
108 |
Chapter~\ref{theories} for details.
|
|
109 |
|
|
110 |
\item[\ttindexbold{time_use} \tt"$file$";]
|
|
111 |
performs {\tt use~"$file$"} and prints the total execution time.
|
|
112 |
|
|
113 |
\item[\ttindexbold{time_use_thy} \tt"$tname$";]
|
|
114 |
performs {\tt use_thy "$tname$"} and prints the total execution time.
|
|
115 |
\end{description}
|
|
116 |
|
|
117 |
|
|
118 |
\section{Printing of terms and theorems}
|
|
119 |
\index{printing!flags|bold}
|
|
120 |
Isabelle's pretty printer is controlled by a number of parameters.
|
|
121 |
|
|
122 |
\subsection{Printing limits}
|
|
123 |
\begin{ttbox}
|
|
124 |
Pretty.setdepth : int -> unit
|
|
125 |
Pretty.setmargin : int -> unit
|
|
126 |
print_depth : int -> unit
|
|
127 |
\end{ttbox}
|
|
128 |
These set limits for terminal output.
|
|
129 |
|
|
130 |
\begin{description}
|
|
131 |
\item[\ttindexbold{Pretty.setdepth} \(d\);] tells
|
|
132 |
Isabelle's pretty printer to limit the printing depth to~$d$. This affects
|
|
133 |
Isabelle's display of theorems and terms. The default value is~0, which
|
|
134 |
permits printing to an arbitrary depth. Useful values for $d$ are~10 and~20.
|
|
135 |
|
|
136 |
\item[\ttindexbold{Pretty.setmargin} \(m\);] tells
|
|
137 |
Isabelle's pretty printer to assume a right margin (page width) of~$m$.
|
|
138 |
The initial margin is~80.
|
|
139 |
|
|
140 |
\item[\ttindexbold{print_depth} \(n\);] limits
|
|
141 |
the printing depth of complex \ML{} values, such as theorems and terms.
|
|
142 |
This command affects the \ML{} top level and its effect is
|
|
143 |
compiler-dependent. Typically $n$ should be less than~10.
|
|
144 |
\end{description}
|
|
145 |
|
|
146 |
|
|
147 |
\subsection{Printing of meta-level hypotheses}
|
|
148 |
\index{hypotheses!meta-level!printing of|bold}
|
|
149 |
\begin{ttbox}
|
|
150 |
show_hyps: bool ref \hfill{\bf initially true}
|
|
151 |
\end{ttbox}
|
|
152 |
A theorem's hypotheses are normally displayed, since such dependence is
|
|
153 |
important. If this information becomes too verbose, however, it can be
|
|
154 |
switched off; each hypothesis is then displayed as a dot.
|
|
155 |
\begin{description}
|
|
156 |
\item[\ttindexbold{show_hyps} \tt:= true;]
|
|
157 |
makes Isabelle show meta-level hypotheses when printing a theorem; setting
|
|
158 |
it to {\tt false} suppresses them.
|
|
159 |
\end{description}
|
|
160 |
|
|
161 |
|
|
162 |
\subsection{Printing of types and sorts}
|
|
163 |
\begin{ttbox}
|
|
164 |
show_types: bool ref \hfill{\bf initially false}
|
|
165 |
show_sorts: bool ref \hfill{\bf initially false}
|
|
166 |
\end{ttbox}
|
|
167 |
These control Isabelle's display of types and sorts. Normally terms are
|
|
168 |
printed without type and sorts because they are verbose. Occasionally you
|
|
169 |
may require this information, say to discover why a polymorphic inference rule
|
|
170 |
fails to resolve with some goal.
|
|
171 |
|
|
172 |
\begin{description}
|
|
173 |
\item[\ttindexbold{show_types} \tt:= true;]\index{types}
|
|
174 |
makes Isabelle show types when printing a term or theorem.
|
|
175 |
|
|
176 |
\item[\ttindexbold{show_sorts} \tt:= true;]\index{sorts}
|
|
177 |
makes Isabelle show the sorts of type variables. It has no effect unless
|
|
178 |
{\tt show_types} is~{\tt true}.
|
|
179 |
\end{description}
|
|
180 |
|
|
181 |
|
|
182 |
\subsection{$\eta$-contraction before printing}
|
|
183 |
\begin{ttbox}
|
|
184 |
eta_contract: bool ref \hfill{\bf initially false}
|
|
185 |
\end{ttbox}
|
|
186 |
The {\bf $\eta$-contraction law} asserts $(\lambda x.f(x))\equiv f$,
|
|
187 |
provided $x$ is not free in ~$f$. It asserts {\bf extensionality} of
|
|
188 |
functions: $f\equiv g$ if $f(x)\equiv g(x)$ for all~$x$. Higher-order
|
|
189 |
unification puts terms into a fully $\eta$-expanded form. For example, if
|
|
190 |
$F$ has type $(\tau\To\tau)\To\tau$ then its expanded form is $\lambda
|
|
191 |
h.F(\lambda x.h(x))$. By default, the user sees this expanded form.
|
|
192 |
|
|
193 |
\begin{description}
|
|
194 |
\item[\ttindexbold{eta_contract} \tt:= true;]
|
|
195 |
makes Isabelle perform $\eta$-contractions before printing, so that
|
|
196 |
$\lambda h.F(\lambda x.h(x))$ appears simply as~$F$. The
|
|
197 |
distinction between a term and its $\eta$-expanded form occasionally
|
|
198 |
matters.
|
|
199 |
\end{description}
|
|
200 |
|
|
201 |
|
|
202 |
\section{Displaying exceptions as error messages}
|
|
203 |
\index{printing!exceptions|bold}\index{exceptions|bold}
|
|
204 |
\begin{ttbox}
|
|
205 |
print_exn: exn -> 'a
|
|
206 |
\end{ttbox}
|
|
207 |
Certain Isabelle primitives, such as the forward proof functions {\tt RS}
|
|
208 |
and {\tt RSN}, are called both interactively and from programs. They
|
|
209 |
indicate errors not by printing messages, but by raising exceptions. For
|
|
210 |
interactive use, \ML's reporting of an uncaught exception is most
|
|
211 |
uninformative.
|
|
212 |
|
|
213 |
\begin{description}
|
|
214 |
\item[\ttindexbold{print_exn} $e$]
|
|
215 |
displays the exception~$e$ in a readable manner, and then re-raises~$e$.
|
|
216 |
Typical usage is~\hbox{\tt \ldots{} handle e => print_exn e;}, where
|
|
217 |
\ldots{} is an expression that may raise an exception.
|
|
218 |
|
|
219 |
{\tt print_exn} can display the following common exceptions, which concern
|
|
220 |
types, terms, theorems and theories, respectively. Each carries a message
|
|
221 |
and related information.
|
|
222 |
\begin{ttbox}
|
|
223 |
exception TYPE of string * typ list * term list
|
|
224 |
exception TERM of string * term list
|
|
225 |
exception THM of string * int * thm list
|
|
226 |
exception THEORY of string * theory list
|
|
227 |
\end{ttbox}
|
|
228 |
{\tt print_exn} calls \ttindex{prin} to print terms. This obtains pretty
|
|
229 |
printing information from the proof state last stored in the subgoal
|
|
230 |
module, and will fail if no interactive proof has begun in the current
|
|
231 |
session.
|
|
232 |
\end{description}
|
|
233 |
|
|
234 |
|
|
235 |
\section{Shell scripts}
|
|
236 |
\index{shell scripts|bold}
|
|
237 |
The following files are distributed with Isabelle, and work under
|
|
238 |
Unix$^{\rm TM}$. They can be executed as commands to the Unix shell. Some
|
|
239 |
of them depend upon shell environment variables.
|
|
240 |
\begin{description}
|
|
241 |
\item[\ttindexbold{make-all} $switches$]
|
|
242 |
compiles the Isabelle system, when executed on the source directory.
|
|
243 |
Environment variables specify which \ML{} compiler (and {\tt Makefile}s) to
|
|
244 |
use. These variables, and the {\it switches}, are documented on the file
|
|
245 |
itself.
|
|
246 |
|
|
247 |
\item[\ttindexbold{teeinput} $program$]
|
|
248 |
executes the {\it program}, while piping the standard input to a log file
|
|
249 |
designated by the \verb|$LISTEN| environment variable. Normally the
|
|
250 |
program is Isabelle, and the log file receives a copy of all the Isabelle
|
|
251 |
commands.
|
|
252 |
|
|
253 |
\item[\ttindexbold{xlisten} $program$]
|
|
254 |
is a trivial `user interface' for the X Window System. It creates two
|
|
255 |
windows using {\tt xterm}. One executes an interactive session via
|
|
256 |
\hbox{\tt teeinput $program$}, while the other displays the log file. To
|
|
257 |
make a proof record, simply paste lines from the log file into an editor
|
|
258 |
window.
|
|
259 |
|
|
260 |
\item[\ttindexbold{expandshort} $files$]
|
|
261 |
reads the {\it files\/} and replaces all occurrences of the shorthand
|
|
262 |
commands {\tt br}, {\tt be}, {\tt brs}, {\tt bes}, etc., with commands
|
|
263 |
like \hbox{\tt by (resolve_tac \ldots)}. The commands should appear one
|
|
264 |
per line. The old versions of the files
|
|
265 |
are renamed to have the suffix~\verb'~~'.
|
|
266 |
\end{description}
|
|
267 |
|
|
268 |
\index{sessions|)}
|