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