author | oheimb |
Tue, 23 Apr 1996 16:58:21 +0200 | |
changeset 1672 | 2c109cd2fdd0 |
parent 1372 | 16330e3fa3b7 |
child 2225 | 78a8faae780f |
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 |
|
322 | 12 |
finally esoteric functions. Use the Index when you are looking for the |
13 |
definition of a particular Isabelle function. |
|
104 | 14 |
|
286 | 15 |
A few examples are presented. Many examples files are distributed with |
16 |
Isabelle, however; please experiment interactively. |
|
104 | 17 |
|
18 |
||
19 |
\section{Basic interaction with Isabelle} |
|
322 | 20 |
\index{saving your work|bold} |
104 | 21 |
Isabelle provides no means of storing theorems or proofs on files. |
22 |
Theorems are simply part of the \ML{} state and are named by \ML{} |
|
23 |
identifiers. To save your work between sessions, you must save a copy of |
|
24 |
the \ML{} image. The procedure for doing so is compiler-dependent: |
|
322 | 25 |
\begin{itemize}\index{Poly/{\ML} compiler} |
26 |
\item At the end of a session, Poly/\ML{} saves the state, provided you |
|
27 |
have created a database for your own use. You can create a database by |
|
28 |
copying an existing one, or by calling the Poly/\ML{} function {\tt |
|
29 |
make_database}; the latter course uses much less disc space. A |
|
30 |
Poly/\ML{} database {\em does not\/} save the contents of references, |
|
31 |
such as the current state of a backward proof. |
|
104 | 32 |
|
33 |
\item With New Jersey \ML{} you must save the state explicitly before |
|
149 | 34 |
ending the session. While a Poly/\ML{} database can be small, a New Jersey |
104 | 35 |
image occupies several megabytes. |
36 |
\end{itemize} |
|
37 |
See your \ML{} compiler's documentation for full instructions on saving the |
|
38 |
state. |
|
39 |
||
40 |
Saving the state is not enough. Record, on a file, the top-level commands |
|
41 |
that generate your theories and proofs. Such a record allows you to replay |
|
42 |
the proofs whenever required, for instance after making minor changes to |
|
43 |
the axioms. Ideally, your record will be intelligible to others as a |
|
44 |
formal description of your work. |
|
45 |
||
46 |
Since Isabelle's user interface is the \ML{} top level, some kind of window |
|
47 |
support is essential. One window displays the Isabelle session, while the |
|
322 | 48 |
other displays a file --- your proof record --- being edited. The Emacs |
49 |
editor supports windows and can manage interactive sessions. |
|
104 | 50 |
|
51 |
||
52 |
\section{Ending a session} |
|
53 |
\begin{ttbox} |
|
54 |
quit : unit -> unit |
|
55 |
commit : unit -> unit \hfill{\bf Poly/ML only} |
|
56 |
exportML : string -> bool \hfill{\bf New Jersey ML only} |
|
57 |
\end{ttbox} |
|
322 | 58 |
\begin{ttdescription} |
104 | 59 |
\item[\ttindexbold{quit}();] |
60 |
aborts the Isabelle session, without saving the state. |
|
61 |
||
322 | 62 |
\item[\ttindexbold{commit}();] |
63 |
saves the current state in your Poly/\ML{} database without ending the |
|
64 |
session. The contents of references are lost, so never do this during an |
|
65 |
interactive proof!\index{Poly/{\ML} compiler} |
|
104 | 66 |
|
322 | 67 |
\item[\ttindexbold{exportML} "{\it file}";] saves an |
104 | 68 |
image of your session to the given {\it file}. |
322 | 69 |
\end{ttdescription} |
104 | 70 |
|
71 |
\begin{warn} |
|
72 |
Typing control-D also finishes the session, but its effect is |
|
73 |
compiler-dependent. Poly/\ML{} will then save the state, if you have a |
|
74 |
private database. New Jersey \ML{} will discard the state! |
|
75 |
\end{warn} |
|
76 |
||
77 |
||
322 | 78 |
\section{Reading ML files} |
79 |
\index{files!reading} |
|
104 | 80 |
\begin{ttbox} |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
81 |
cd : string -> unit |
884 | 82 |
pwd : unit -> string |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
83 |
use : string -> unit |
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
84 |
time_use : string -> unit |
104 | 85 |
\end{ttbox} |
322 | 86 |
Section~\ref{LoadingTheories} describes commands for loading theory files. |
87 |
\begin{ttdescription} |
|
88 |
\item[\ttindexbold{cd} "{\it dir}";] |
|
89 |
changes the current directory to {\it dir}. This is the default directory |
|
90 |
for reading files and for writing temporary files. |
|
104 | 91 |
|
884 | 92 |
\item[\ttindexbold{pwd} ();] returns the path of the current directory. |
93 |
||
322 | 94 |
\item[\ttindexbold{use} "$file$";] |
104 | 95 |
reads the given {\it file} as input to the \ML{} session. Reading a file |
96 |
of Isabelle commands is the usual way of replaying a proof. |
|
97 |
||
322 | 98 |
\item[\ttindexbold{time_use} "$file$";] |
104 | 99 |
performs {\tt use~"$file$"} and prints the total execution time. |
322 | 100 |
\end{ttdescription} |
104 | 101 |
|
102 |
||
508 | 103 |
\section{Printing of terms and theorems}\label{sec:printing-control} |
322 | 104 |
\index{printing control|(} |
104 | 105 |
Isabelle's pretty printer is controlled by a number of parameters. |
106 |
||
107 |
\subsection{Printing limits} |
|
108 |
\begin{ttbox} |
|
109 |
Pretty.setdepth : int -> unit |
|
110 |
Pretty.setmargin : int -> unit |
|
111 |
print_depth : int -> unit |
|
112 |
\end{ttbox} |
|
508 | 113 |
These set limits for terminal output. See also {\tt goals_limit}, which |
114 |
limits the number of subgoals printed (page~\pageref{sec:goals-printing}). |
|
104 | 115 |
|
322 | 116 |
\begin{ttdescription} |
117 |
\item[\ttindexbold{Pretty.setdepth} \(d\);] |
|
118 |
tells Isabelle's pretty printer to limit the printing depth to~$d$. This |
|
119 |
affects Isabelle's display of theorems and terms. The default value |
|
120 |
is~0, which permits printing to an arbitrary depth. Useful values for |
|
121 |
$d$ are~10 and~20. |
|
104 | 122 |
|
322 | 123 |
\item[\ttindexbold{Pretty.setmargin} \(m\);] |
124 |
tells Isabelle's pretty printer to assume a right margin (page width) |
|
125 |
of~$m$. The initial margin is~80. |
|
104 | 126 |
|
322 | 127 |
\item[\ttindexbold{print_depth} \(n\);] |
128 |
limits the printing depth of complex \ML{} values, such as theorems and |
|
129 |
terms. This command affects the \ML{} top level and its effect is |
|
130 |
compiler-dependent. Typically $n$ should be less than~10. |
|
131 |
\end{ttdescription} |
|
104 | 132 |
|
133 |
||
508 | 134 |
\subsection{Printing of hypotheses, brackets, types and sorts} |
322 | 135 |
\index{meta-assumptions!printing of} |
136 |
\index{types!printing of}\index{sorts!printing of} |
|
104 | 137 |
\begin{ttbox} |
508 | 138 |
show_hyps : bool ref \hfill{\bf initially true} |
139 |
show_brackets : bool ref \hfill{\bf initially false} |
|
140 |
show_types : bool ref \hfill{\bf initially false} |
|
141 |
show_sorts : bool ref \hfill{\bf initially false} |
|
104 | 142 |
\end{ttbox} |
322 | 143 |
These flags allow you to control how much information is displayed for |
508 | 144 |
terms and theorems. The hypotheses are normally shown; superfluous |
145 |
parentheses are not. Types and sorts are normally hidden. Displaying |
|
146 |
types and sorts may explain why a polymorphic inference rule fails to |
|
147 |
resolve with some goal. |
|
104 | 148 |
|
322 | 149 |
\begin{ttdescription} |
150 |
\item[\ttindexbold{show_hyps} := false;] |
|
332 | 151 |
makes Isabelle show each meta-level hypothesis as a dot. |
104 | 152 |
|
508 | 153 |
\item[\ttindexbold{show_brackets} := true;] |
154 |
makes Isabelle show full bracketing. This reveals the |
|
155 |
grouping of infix operators. |
|
156 |
||
322 | 157 |
\item[\ttindexbold{show_types} := true;] |
104 | 158 |
makes Isabelle show types when printing a term or theorem. |
159 |
||
322 | 160 |
\item[\ttindexbold{show_sorts} := true;] |
1102 | 161 |
makes Isabelle show both types and the sorts of type variables. It does not |
162 |
matter whether {\tt show_types} is also~{\tt true}. |
|
322 | 163 |
\end{ttdescription} |
104 | 164 |
|
165 |
||
166 |
\subsection{$\eta$-contraction before printing} |
|
167 |
\begin{ttbox} |
|
168 |
eta_contract: bool ref \hfill{\bf initially false} |
|
169 |
\end{ttbox} |
|
170 |
The {\bf $\eta$-contraction law} asserts $(\lambda x.f(x))\equiv f$, |
|
171 |
provided $x$ is not free in ~$f$. It asserts {\bf extensionality} of |
|
172 |
functions: $f\equiv g$ if $f(x)\equiv g(x)$ for all~$x$. Higher-order |
|
332 | 173 |
unification frequently puts terms into a fully $\eta$-expanded form. For |
158 | 174 |
example, if $F$ has type $(\tau\To\tau)\To\tau$ then its expanded form is |
175 |
$\lambda h.F(\lambda x.h(x))$. By default, the user sees this expanded |
|
176 |
form. |
|
104 | 177 |
|
322 | 178 |
\begin{ttdescription} |
179 |
\item[\ttindexbold{eta_contract} := true;] |
|
104 | 180 |
makes Isabelle perform $\eta$-contractions before printing, so that |
181 |
$\lambda h.F(\lambda x.h(x))$ appears simply as~$F$. The |
|
182 |
distinction between a term and its $\eta$-expanded form occasionally |
|
183 |
matters. |
|
322 | 184 |
\end{ttdescription} |
185 |
\index{printing control|)} |
|
104 | 186 |
|
187 |
||
188 |
\section{Displaying exceptions as error messages} |
|
322 | 189 |
\index{exceptions!printing of} |
104 | 190 |
\begin{ttbox} |
191 |
print_exn: exn -> 'a |
|
192 |
\end{ttbox} |
|
193 |
Certain Isabelle primitives, such as the forward proof functions {\tt RS} |
|
194 |
and {\tt RSN}, are called both interactively and from programs. They |
|
195 |
indicate errors not by printing messages, but by raising exceptions. For |
|
322 | 196 |
interactive use, \ML's reporting of an uncaught exception is |
197 |
uninformative. The Poly/ML function {\tt exception_trace} can generate a |
|
198 |
backtrace.\index{Poly/{\ML} compiler} |
|
104 | 199 |
|
322 | 200 |
\begin{ttdescription} |
104 | 201 |
\item[\ttindexbold{print_exn} $e$] |
202 |
displays the exception~$e$ in a readable manner, and then re-raises~$e$. |
|
322 | 203 |
Typical usage is~\hbox{\tt $EXP$ handle e => print_exn e;}, where |
204 |
$EXP$ is an expression that may raise an exception. |
|
104 | 205 |
|
206 |
{\tt print_exn} can display the following common exceptions, which concern |
|
207 |
types, terms, theorems and theories, respectively. Each carries a message |
|
208 |
and related information. |
|
209 |
\begin{ttbox} |
|
210 |
exception TYPE of string * typ list * term list |
|
211 |
exception TERM of string * term list |
|
212 |
exception THM of string * int * thm list |
|
213 |
exception THEORY of string * theory list |
|
214 |
\end{ttbox} |
|
322 | 215 |
\end{ttdescription} |
216 |
\begin{warn} |
|
217 |
{\tt print_exn} prints terms by calling \ttindex{prin}, which obtains |
|
218 |
pretty printing information from the proof state last stored in the |
|
219 |
subgoal module. The appearance of the output thus depends upon the |
|
220 |
theory used in the last interactive proof. |
|
221 |
\end{warn} |
|
104 | 222 |
|
1372 | 223 |
\section{Shell scripts}\label{sec:shell-scripts} |
322 | 224 |
\index{shell scripts|bold} The following files are distributed with |
225 |
Isabelle, and work under Unix$^{\rm TM}$. They can be executed as commands |
|
226 |
to the Unix shell. Some of them depend upon shell environment variables. |
|
227 |
\begin{ttdescription} |
|
228 |
\item[make-all $switches$] \index{*make-all shell script} |
|
286 | 229 |
compiles the Isabelle system, when executed on the source directory. |
230 |
Environment variables specify which \ML{} compiler to use. These |
|
231 |
variables, and the {\it switches}, are documented on the file itself. |
|
104 | 232 |
|
322 | 233 |
\item[teeinput $program$] \index{*teeinput shell script} |
234 |
executes the {\it program}, while piping the standard input to a log file |
|
235 |
designated by the \verb|$LISTEN| environment variable. Normally the |
|
236 |
program is Isabelle, and the log file receives a copy of all the Isabelle |
|
237 |
commands. |
|
104 | 238 |
|
322 | 239 |
\item[xlisten $program$] \index{*xlisten shell script} |
104 | 240 |
is a trivial `user interface' for the X Window System. It creates two |
241 |
windows using {\tt xterm}. One executes an interactive session via |
|
242 |
\hbox{\tt teeinput $program$}, while the other displays the log file. To |
|
243 |
make a proof record, simply paste lines from the log file into an editor |
|
244 |
window. |
|
245 |
||
322 | 246 |
\item[expandshort $files$] \index{*expandshort shell script} |
104 | 247 |
reads the {\it files\/} and replaces all occurrences of the shorthand |
286 | 248 |
commands {\tt br}, {\tt be}, {\tt brs}, {\tt bes}, etc., with the |
249 |
corresponding full commands. Shorthand commands should appear one |
|
104 | 250 |
per line. The old versions of the files |
251 |
are renamed to have the suffix~\verb'~~'. |
|
322 | 252 |
\end{ttdescription} |
104 | 253 |
|
254 |
\index{sessions|)} |