2 \chapter{Basic Use of Isabelle}\index{sessions|(}
4 \section{Basic interaction with Isabelle}
5 \index{starting up|bold}\nobreak
7 We assume that your local Isabelle administrator (this might be you!) has
8 already installed the Isabelle system together with appropriate object-logics.
10 \medskip Let $\langle isabellehome \rangle$ denote the location where
11 the distribution has been installed. To run Isabelle from a the shell
12 prompt within an ordinary text terminal session, simply type
14 \({\langle}isabellehome{\rangle}\)/bin/isabelle
16 This should start an interactive \ML{} session with the default object-logic
17 (usually HOL) already pre-loaded.
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,
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
24 \rangle\)/bin/isabelle}, though! See \texttt{isabelle install} in
25 \emph{The Isabelle System Manual} of how to do this properly.}
29 The object-logic image to load may be also specified explicitly as an argument
30 to the {\tt isabelle} command, e.g.
34 This should put you into the world of polymorphic first-order logic (assuming
35 that an image of FOL has been pre-built).
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
45 of name \texttt{Foo} that initially contains just plain HOL:
49 Ending the \texttt{Foo} session with control-D will cause the complete
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
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
61 minor changes to the axioms. Ideally, these sources will be somewhat
62 intelligible to others as a formal description of your work.
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
69 \texttt{isabelle usedir} utility provides some more options to manage Isabelle
70 sessions, such as automatic generation of theory browsing information.
72 \medskip More details about the \texttt{isabelle} and \texttt{isabelle}
73 commands may be found in \emph{The Isabelle System Manual}.
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.
81 \section{Ending a session}
88 \item[\ttindexbold{quit}();] ends the Isabelle session, without saving
91 \item[\ttindexbold{exit} \(i\);] similar to {\tt quit}, passing return
92 code \(i\) to the operating system.
94 \item[\ttindexbold{commit}();] saves the current state without ending
95 the session, provided that the logic image is opened read-write;
96 return value {\tt false} indicates an error.
99 Typing control-D also finishes the session in essentially the same way
100 as the sequence {\tt commit(); quit();} would.
103 \section{Reading ML files}
104 \index{files!reading}
109 time_use : string -> unit
111 \begin{ttdescription}
112 \item[\ttindexbold{cd} "{\it dir}";] changes the current directory to
113 {\it dir}. This is the default directory for reading files.
115 \item[\ttindexbold{pwd}();] returns the full path of the current
118 \item[\ttindexbold{use} "$file$";]
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.
122 \item[\ttindexbold{time_use} "$file$";]
123 performs {\tt use~"$file$"} and prints the total execution time.
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
130 \texttt{\$ISABELLE_HOME}\index{*\$ISABELLE_HOME}. The syntax for path
131 specifications follows Unix conventions.
134 \section{Reading theories}\label{sec:intro-theories}
135 \index{theories!reading}
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.
147 context : theory -> unit
148 the_context : unit -> theory
149 theory : string -> theory
150 use_thy : string -> unit
151 time_use_thy : string -> unit
152 update_thy : string -> unit
155 \begin{ttdescription}
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.
161 \item[\ttindexbold{the_context}();] obtains the current theory context, or
162 raises an error if absent.
164 \item[\ttindexbold{theory} "$name$";] retrieves the theory called $name$ from
165 the internal data\-base of loaded theories, raising an error if absent.
167 \item[\ttindexbold{use_thy} "$name$";] reads theory $name$ from the file
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.
174 \item[\ttindexbold{time_use_thy} "$name$";] same as \texttt{use_thy}, but
175 reports the time taken to process the actual theory parts and {\ML} files
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
180 system --- apart from theory $name$ itself, any of its ancestors may be
185 Note that theories of pre-built logic images (e.g.\ HOL) are marked as
186 \emph{finished} and cannot be updated any more. See \S\ref{sec:more-theories}
187 for further information on Isabelle's theory loader.
190 \section{Setting flags}
192 set : bool ref -> bool
193 reset : bool ref -> bool
194 toggle : bool ref -> bool
195 \end{ttbox}\index{*set}\index{*reset}\index{*toggle}
196 These are some shorthands for manipulating boolean references. The new
200 \section{Diagnostic messages}
201 \index{error messages}
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.
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:
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!
219 \texttt{ML} programs may output diagnostic messages using the
222 writeln : string -> unit
223 warning : string -> unit
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.
232 \index{timing statistics}\index{proofs!timing}
234 timing: bool ref \hfill{\bf initially false}
237 \begin{ttdescription}
238 \item[set \ttindexbold{timing};] enables global timing in Isabelle.
239 This information is compiler-dependent.
247 %%% TeX-master: "ref"