author | wenzelm |
Mon, 23 Aug 2010 17:45:06 +0200 | |
changeset 38641 | 7ab0ae836f74 |
parent 37368 | 1c816f2abb0e |
child 39834 | b5d688221d1b |
permissions | -rw-r--r-- |
3108 | 1 |
|
286 | 2 |
\chapter{Basic Use of Isabelle}\index{sessions|(} |
104 | 3 |
|
4 |
\section{Basic interaction with Isabelle} |
|
2225 | 5 |
\index{starting up|bold}\nobreak |
6 |
% |
|
6568 | 7 |
We assume that your local Isabelle administrator (this might be you!) has |
37368 | 8 |
already installed the Isabelle system together with appropriate object-logics. |
3108 | 9 |
|
10 |
\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
|
11 |
the distribution has been installed. To run Isabelle from a the shell |
4317 | 12 |
prompt within an ordinary text terminal session, simply type |
3108 | 13 |
\begin{ttbox} |
14 |
\({\langle}isabellehome{\rangle}\)/bin/isabelle |
|
15 |
\end{ttbox} |
|
6568 | 16 |
This should start an interactive \ML{} session with the default object-logic |
9695 | 17 |
(usually HOL) already pre-loaded. |
3108 | 18 |
|
6568 | 19 |
Subsequently, we assume that the \texttt{isabelle} executable is determined |
20 |
automatically by the shell, e.g.\ by adding {\tt \(\langle isabellehome |
|
21 |
\rangle\)/bin} to your search path.\footnote{Depending on your installation, |
|
7990 | 22 |
there may be stand-alone binaries located in some global directory such as |
23 |
\texttt{/usr/bin}. Do not attempt to copy {\tt \(\langle isabellehome |
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
12831
diff
changeset
|
24 |
\rangle\)/bin/isabelle}, though! See \texttt{isabelle install} in |
7990 | 25 |
\emph{The Isabelle System Manual} of how to do this properly.} |
3108 | 26 |
|
6571 | 27 |
\medskip |
28 |
||
6568 | 29 |
The object-logic image to load may be also specified explicitly as an argument |
30 |
to the {\tt isabelle} command, e.g. |
|
3108 | 31 |
\begin{ttbox} |
32 |
isabelle FOL |
|
33 |
\end{ttbox} |
|
6568 | 34 |
This should put you into the world of polymorphic first-order logic (assuming |
9695 | 35 |
that an image of FOL has been pre-built). |
2225 | 36 |
|
6568 | 37 |
\index{saving your session|bold} Isabelle provides no means of storing |
38 |
theorems or internal proof objects on files. Theorems are simply part of the |
|
39 |
\ML{} state. To save your work between sessions, you may dump the \ML{} |
|
40 |
system state to a file. This is done automatically when ending the session |
|
41 |
normally (e.g.\ by typing control-D), provided that the image has been opened |
|
42 |
\emph{writable} in the first place. The standard object-logic images are |
|
43 |
usually read-only, so you have to create a private working copy first. For |
|
44 |
example, the following shell command puts you into a writable Isabelle session |
|
9695 | 45 |
of name \texttt{Foo} that initially contains just plain HOL: |
3108 | 46 |
\begin{ttbox} |
6568 | 47 |
isabelle HOL Foo |
3108 | 48 |
\end{ttbox} |
49 |
Ending the \texttt{Foo} session with control-D will cause the complete |
|
6568 | 50 |
\ML-world to be saved somewhere in your home directory\footnote{The default |
51 |
location is in \texttt{\~\relax/isabelle/heaps}, but this depends on your |
|
52 |
local configuration.}. Make sure there is enough space available! Then one |
|
53 |
may later continue at exactly the same point by running |
|
3108 | 54 |
\begin{ttbox} |
55 |
isabelle Foo |
|
56 |
\end{ttbox} |
|
104 | 57 |
|
6568 | 58 |
\medskip Saving the {\ML} state is not enough. Record, on a file, the |
59 |
top-level commands that generate your theories and proofs. Such a record |
|
60 |
allows you to replay the proofs whenever required, for instance after making |
|
6571 | 61 |
minor changes to the axioms. Ideally, these sources will be somewhat |
6568 | 62 |
intelligible to others as a formal description of your work. |
3108 | 63 |
|
6568 | 64 |
It is good practice to put all source files that constitute a separate |
65 |
Isabelle session into an individual directory, together with an {\ML} file |
|
66 |
called \texttt{ROOT.ML} that contains appropriate commands to load all other |
|
67 |
files required. Running \texttt{isabelle} with option \texttt{-u} |
|
68 |
automatically loads \texttt{ROOT.ML} on entering the session. The |
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
12831
diff
changeset
|
69 |
\texttt{isabelle usedir} utility provides some more options to manage Isabelle |
6568 | 70 |
sessions, such as automatic generation of theory browsing information. |
104 | 71 |
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
12831
diff
changeset
|
72 |
\medskip More details about the \texttt{isabelle} and \texttt{isabelle} |
6568 | 73 |
commands may be found in \emph{The Isabelle System Manual}. |
74 |
||
75 |
\medskip There are more comfortable user interfaces than the bare-bones \ML{} |
|
76 |
top-level run from a text terminal. The \texttt{Isabelle} executable (note |
|
77 |
the capital I) runs one such interface, depending on your local configuration. |
|
78 |
Again, see \emph{The Isabelle System Manual} for more information. |
|
104 | 79 |
|
80 |
||
81 |
\section{Ending a session} |
|
82 |
\begin{ttbox} |
|
3108 | 83 |
quit : unit -> unit |
84 |
exit : int -> unit |
|
6067 | 85 |
commit : unit -> bool |
104 | 86 |
\end{ttbox} |
322 | 87 |
\begin{ttdescription} |
3108 | 88 |
\item[\ttindexbold{quit}();] ends the Isabelle session, without saving |
89 |
the state. |
|
4317 | 90 |
|
91 |
\item[\ttindexbold{exit} \(i\);] similar to {\tt quit}, passing return |
|
92 |
code \(i\) to the operating system. |
|
104 | 93 |
|
3108 | 94 |
\item[\ttindexbold{commit}();] saves the current state without ending |
6067 | 95 |
the session, provided that the logic image is opened read-write; |
96 |
return value {\tt false} indicates an error. |
|
322 | 97 |
\end{ttdescription} |
104 | 98 |
|
3108 | 99 |
Typing control-D also finishes the session in essentially the same way |
100 |
as the sequence {\tt commit(); quit();} would. |
|
104 | 101 |
|
102 |
||
322 | 103 |
\section{Reading ML files} |
104 |
\index{files!reading} |
|
104 | 105 |
\begin{ttbox} |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
106 |
cd : string -> unit |
884 | 107 |
pwd : unit -> string |
138
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
108 |
use : string -> unit |
9ba8bff1addc
added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents:
104
diff
changeset
|
109 |
time_use : string -> unit |
104 | 110 |
\end{ttbox} |
322 | 111 |
\begin{ttdescription} |
4317 | 112 |
\item[\ttindexbold{cd} "{\it dir}";] changes the current directory to |
113 |
{\it dir}. This is the default directory for reading files. |
|
114 |
||
115 |
\item[\ttindexbold{pwd}();] returns the full path of the current |
|
116 |
directory. |
|
884 | 117 |
|
322 | 118 |
\item[\ttindexbold{use} "$file$";] |
104 | 119 |
reads the given {\it file} as input to the \ML{} session. Reading a file |
120 |
of Isabelle commands is the usual way of replaying a proof. |
|
121 |
||
322 | 122 |
\item[\ttindexbold{time_use} "$file$";] |
104 | 123 |
performs {\tt use~"$file$"} and prints the total execution time. |
322 | 124 |
\end{ttdescription} |
104 | 125 |
|
6343 | 126 |
The $dir$ and $file$ specifications of the \texttt{cd} and \texttt{use} |
127 |
commands may contain path variables (e.g.\ \texttt{\$ISABELLE_HOME}) that are |
|
128 |
expanded appropriately. Note that \texttt{\~\relax} abbreviates |
|
129 |
\texttt{\$HOME}, and \texttt{\~\relax\~\relax} abbreviates |
|
6571 | 130 |
\texttt{\$ISABELLE_HOME}\index{*\$ISABELLE_HOME}. The syntax for path |
131 |
specifications follows Unix conventions. |
|
6568 | 132 |
|
133 |
||
134 |
\section{Reading theories}\label{sec:intro-theories} |
|
135 |
\index{theories!reading} |
|
136 |
||
137 |
In Isabelle, any kind of declarations, definitions, etc.\ are organized around |
|
138 |
named \emph{theory} objects. Logical reasoning always takes place within a |
|
139 |
certain theory context, which may be switched at any time. Theory $name$ is |
|
140 |
defined by a theory file $name$\texttt{.thy}, containing declarations of |
|
141 |
\texttt{consts}, \texttt{types}, \texttt{defs}, etc.\ (see |
|
142 |
\S\ref{sec:ref-defining-theories} for more details on concrete syntax). |
|
143 |
Furthermore, there may be an associated {\ML} file $name$\texttt{.ML} with |
|
144 |
proof scripts that are to be run in the context of the theory. |
|
145 |
||
146 |
\begin{ttbox} |
|
147 |
context : theory -> unit |
|
148 |
the_context : unit -> theory |
|
149 |
theory : string -> theory |
|
150 |
use_thy : string -> unit |
|
151 |
time_use_thy : string -> unit |
|
7136 | 152 |
update_thy : string -> unit |
6568 | 153 |
\end{ttbox} |
154 |
||
155 |
\begin{ttdescription} |
|
156 |
||
157 |
\item[\ttindexbold{context} $thy$;] switches the current theory context. Any |
|
158 |
subsequent command with ``implicit theory argument'' (e.g.\ \texttt{Goal}) |
|
159 |
will refer to $thy$ as its theory. |
|
160 |
||
161 |
\item[\ttindexbold{the_context}();] obtains the current theory context, or |
|
162 |
raises an error if absent. |
|
163 |
||
6569 | 164 |
\item[\ttindexbold{theory} "$name$";] retrieves the theory called $name$ from |
8136 | 165 |
the internal data\-base of loaded theories, raising an error if absent. |
6568 | 166 |
|
6569 | 167 |
\item[\ttindexbold{use_thy} "$name$";] reads theory $name$ from the file |
6571 | 168 |
system, looking for $name$\texttt{.thy} and $name$\texttt{.ML} (the latter |
169 |
being optional). It also ensures that all parent theories are loaded as |
|
170 |
well. In case some older versions have already been present, |
|
171 |
\texttt{use_thy} only tries to reload $name$ itself, but is content with any |
|
172 |
version of its ancestors. |
|
6568 | 173 |
|
6569 | 174 |
\item[\ttindexbold{time_use_thy} "$name$";] same as \texttt{use_thy}, but |
6568 | 175 |
reports the time taken to process the actual theory parts and {\ML} files |
176 |
separately. |
|
7592 | 177 |
|
7136 | 178 |
\item[\ttindexbold{update_thy} "$name$";] is similar to \texttt{use_thy}, but |
179 |
ensures that theory $name$ is fully up-to-date with respect to the file |
|
7592 | 180 |
system --- apart from theory $name$ itself, any of its ancestors may be |
181 |
reloaded as well. |
|
6568 | 182 |
|
183 |
\end{ttdescription} |
|
184 |
||
9695 | 185 |
Note that theories of pre-built logic images (e.g.\ HOL) are marked as |
7282 | 186 |
\emph{finished} and cannot be updated any more. See \S\ref{sec:more-theories} |
187 |
for further information on Isabelle's theory loader. |
|
4274 | 188 |
|
104 | 189 |
|
3108 | 190 |
\section{Setting flags} |
191 |
\begin{ttbox} |
|
192 |
set : bool ref -> bool |
|
193 |
reset : bool ref -> bool |
|
194 |
toggle : bool ref -> bool |
|
195 |
\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
|
196 |
These are some shorthands for manipulating boolean references. The new |
3108 | 197 |
value is returned. |
198 |
||
199 |
||
4317 | 200 |
\section{Diagnostic messages} |
201 |
\index{error messages} |
|
202 |
\index{warnings} |
|
203 |
||
6568 | 204 |
Isabelle conceptually provides three output channels for different kinds of |
205 |
messages: ordinary text, warnings, errors. Depending on the user interface |
|
206 |
involved, these messages may appear in different text styles or colours. |
|
4317 | 207 |
|
208 |
The default setup of an \texttt{isabelle} terminal session is as |
|
209 |
follows: plain output of ordinary text, warnings prefixed by |
|
210 |
\texttt{\#\#\#}'s, errors prefixed by \texttt{***}'s. For example, a |
|
211 |
typical warning would look like this: |
|
212 |
\begin{ttbox} |
|
213 |
\#\#\# Beware the Jabberwock, my son! |
|
214 |
\#\#\# The jaws that bite, the claws that catch! |
|
215 |
\#\#\# Beware the Jubjub Bird, and shun |
|
216 |
\#\#\# The frumious Bandersnatch! |
|
217 |
\end{ttbox} |
|
218 |
||
219 |
\texttt{ML} programs may output diagnostic messages using the |
|
220 |
following functions: |
|
221 |
\begin{ttbox} |
|
222 |
writeln : string -> unit |
|
223 |
warning : string -> unit |
|
224 |
error : string -> 'a |
|
225 |
\end{ttbox} |
|
226 |
Note that \ttindex{error} fails by raising exception \ttindex{ERROR} |
|
227 |
after having output the text, while \ttindex{writeln} and |
|
228 |
\ttindex{warning} resume normal program execution. |
|
229 |
||
104 | 230 |
|
30184
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
28504
diff
changeset
|
231 |
\section{Timing} |
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
28504
diff
changeset
|
232 |
\index{timing statistics}\index{proofs!timing} |
104 | 233 |
\begin{ttbox} |
30184
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
28504
diff
changeset
|
234 |
timing: bool ref \hfill{\bf initially false} |
104 | 235 |
\end{ttbox} |
236 |
||
322 | 237 |
\begin{ttdescription} |
30184
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
28504
diff
changeset
|
238 |
\item[set \ttindexbold{timing};] enables global timing in Isabelle. |
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
28504
diff
changeset
|
239 |
This information is compiler-dependent. |
322 | 240 |
\end{ttdescription} |
104 | 241 |
|
242 |
\index{sessions|)} |
|
5371 | 243 |
|
244 |
||
245 |
%%% Local Variables: |
|
246 |
%%% mode: latex |
|
247 |
%%% TeX-master: "ref" |
|
248 |
%%% End: |