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