28224
|
1 |
(* $Id$ *)
|
|
2 |
|
|
3 |
theory Misc
|
|
4 |
imports Pure
|
|
5 |
begin
|
|
6 |
|
|
7 |
chapter {* Miscellaneous tools \label{ch:tools} *}
|
|
8 |
|
|
9 |
text {*
|
|
10 |
Subsequently we describe various Isabelle related utilities, given
|
|
11 |
in alphabetical order.
|
|
12 |
*}
|
|
13 |
|
|
14 |
|
|
15 |
section {* Displaying documents *}
|
|
16 |
|
|
17 |
text {*
|
|
18 |
The @{tool_def display} utility displays documents in DVI or PDF
|
|
19 |
format:
|
|
20 |
\begin{ttbox}
|
|
21 |
Usage: display [OPTIONS] FILE
|
|
22 |
|
|
23 |
Options are:
|
|
24 |
-c cleanup -- remove FILE after use
|
|
25 |
|
|
26 |
Display document FILE (in DVI format).
|
|
27 |
\end{ttbox}
|
|
28 |
|
|
29 |
\medskip The @{verbatim "-c"} option causes the input file to be
|
|
30 |
removed after use. The program for viewing @{verbatim dvi} files is
|
|
31 |
determined by the @{setting DVI_VIEWER} setting.
|
|
32 |
*}
|
|
33 |
|
|
34 |
|
|
35 |
section {* Viewing documentation \label{sec:tool-doc} *}
|
|
36 |
|
|
37 |
text {*
|
|
38 |
The @{tool_def doc} utility displays online documentation:
|
|
39 |
\begin{ttbox}
|
|
40 |
Usage: doc [DOC]
|
|
41 |
|
|
42 |
View Isabelle documentation DOC, or show list of available documents.
|
|
43 |
\end{ttbox}
|
|
44 |
If called without arguments, it lists all available documents. Each
|
|
45 |
line starts with an identifier, followed by a short description. Any
|
|
46 |
of these identifiers may be specified as the first argument in order
|
|
47 |
to have the corresponding document displayed.
|
|
48 |
|
|
49 |
\medskip The @{setting ISABELLE_DOCS} setting specifies the list of
|
|
50 |
directories (separated by colons) to be scanned for documentations.
|
|
51 |
The program for viewing @{verbatim dvi} files is determined by the
|
|
52 |
@{setting DVI_VIEWER} setting.
|
|
53 |
*}
|
|
54 |
|
|
55 |
|
|
56 |
section {* Getting logic images *}
|
|
57 |
|
|
58 |
text {*
|
|
59 |
The @{tool_def findlogics} utility traverses all directories
|
|
60 |
specified in @{setting ISABELLE_PATH}, looking for Isabelle logic
|
|
61 |
images. Its usage is:
|
|
62 |
\begin{ttbox}
|
|
63 |
Usage: findlogics
|
|
64 |
|
|
65 |
Collect heap file names from ISABELLE_PATH.
|
|
66 |
\end{ttbox}
|
|
67 |
|
|
68 |
The base names of all files found on the path are printed --- sorted
|
|
69 |
and with duplicates removed. Also note that lookup in @{setting
|
|
70 |
ISABELLE_PATH} includes the current values of @{setting ML_SYSTEM}
|
|
71 |
and @{setting ML_PLATFORM}. Thus switching to another ML compiler
|
|
72 |
may change the set of logic images available.
|
|
73 |
*}
|
|
74 |
|
|
75 |
|
|
76 |
section {* Inspecting the settings environment \label{sec:tool-getenv} *}
|
|
77 |
|
|
78 |
text {*
|
|
79 |
The Isabelle settings environment --- as provided by the
|
|
80 |
site-default and user-specific settings files --- can be inspected
|
|
81 |
with the @{tool_def getenv} utility:
|
|
82 |
\begin{ttbox}
|
|
83 |
Usage: getenv [OPTIONS] [VARNAMES ...]
|
|
84 |
|
|
85 |
Options are:
|
|
86 |
-a display complete environment
|
|
87 |
-b print values only (doesn't work for -a)
|
|
88 |
|
|
89 |
Get value of VARNAMES from the Isabelle settings.
|
|
90 |
\end{ttbox}
|
|
91 |
|
|
92 |
With the @{verbatim "-a"} option, one may inspect the full process
|
|
93 |
environment that Isabelle related programs are run in. This usually
|
|
94 |
contains much more variables than are actually Isabelle settings.
|
|
95 |
Normally, output is a list of lines of the form @{text
|
|
96 |
name}@{verbatim "="}@{text value}. The @{verbatim "-b"} option
|
|
97 |
causes only the values to be printed.
|
|
98 |
*}
|
|
99 |
|
|
100 |
|
|
101 |
subsubsection {* Examples *}
|
|
102 |
|
|
103 |
text {*
|
|
104 |
Get the ML system name and the location where the compiler binaries
|
|
105 |
are supposed to reside as follows:
|
|
106 |
\begin{ttbox}
|
|
107 |
isatool getenv ML_SYSTEM ML_HOME
|
|
108 |
{\out ML_SYSTEM=polyml}
|
|
109 |
{\out ML_HOME=/usr/share/polyml/x86-linux}
|
|
110 |
\end{ttbox}
|
|
111 |
|
|
112 |
The next one peeks at the output directory for Isabelle logic
|
|
113 |
images:
|
|
114 |
\begin{ttbox}
|
|
115 |
isatool getenv -b ISABELLE_OUTPUT
|
|
116 |
{\out /home/me/isabelle/heaps/polyml_x86-linux}
|
|
117 |
\end{ttbox}
|
|
118 |
Here we have used the @{verbatim "-b"} option to suppress the
|
|
119 |
@{verbatim "ISABELLE_OUTPUT="} prefix. The value above is what
|
|
120 |
became of the following assignment in the default settings file:
|
|
121 |
\begin{ttbox}
|
|
122 |
ISABELLE_OUTPUT="\$ISABELLE_HOME_USER/heaps"
|
|
123 |
\end{ttbox}
|
|
124 |
|
|
125 |
Note how the @{setting ML_IDENTIFIER} value got appended
|
|
126 |
automatically to each path component. This is a special feature of
|
|
127 |
@{setting ISABELLE_OUTPUT}.
|
|
128 |
*}
|
|
129 |
|
|
130 |
|
|
131 |
section {* Installing standalone Isabelle executables \label{sec:tool-install} *}
|
|
132 |
|
|
133 |
text {*
|
|
134 |
By default, the Isabelle binaries (@{executable isabelle},
|
|
135 |
@{executable isatool} etc.) are just run from their location within
|
|
136 |
the distribution directory, probably indirectly by the shell through
|
|
137 |
its @{verbatim PATH}. Other schemes of installation are supported
|
|
138 |
by the @{tool_def install} utility:
|
|
139 |
\begin{ttbox}
|
|
140 |
Usage: install [OPTIONS]
|
|
141 |
|
|
142 |
Options are:
|
|
143 |
-d DISTDIR use DISTDIR as Isabelle distribution
|
|
144 |
(default ISABELLE_HOME)
|
|
145 |
-p DIR install standalone binaries in DIR
|
|
146 |
|
|
147 |
Install Isabelle executables with absolute references to the current
|
|
148 |
distribution directory.
|
|
149 |
\end{ttbox}
|
|
150 |
|
|
151 |
The @{verbatim "-d"} option overrides the current Isabelle
|
|
152 |
distribution directory as determined by @{setting ISABELLE_HOME}.
|
|
153 |
|
|
154 |
The @{verbatim "-p"} option installs executable wrapper scripts for
|
|
155 |
@{executable isabelle}, @{executable isatool}, @{executable
|
|
156 |
Isabelle}, containing proper absolute references to the Isabelle
|
|
157 |
distribution directory. A typical @{verbatim DIR} specification
|
|
158 |
would be some directory expected to be in the shell's @{verbatim
|
|
159 |
PATH}, such as @{verbatim "/usr/local/bin"}. It is important to
|
|
160 |
note that a plain manual copy of the original Isabelle executables
|
|
161 |
does not work, since it disrupts the integrity of the Isabelle
|
|
162 |
distribution.
|
|
163 |
*}
|
|
164 |
|
|
165 |
|
|
166 |
section {* Creating instances of the Isabelle logo *}
|
|
167 |
|
|
168 |
text {*
|
|
169 |
The @{tool_def logo} utility creates any instance of the generic
|
|
170 |
Isabelle logo as an Encapsuled Postscript file (EPS):
|
|
171 |
\begin{ttbox}
|
|
172 |
Usage: logo [OPTIONS] NAME
|
|
173 |
|
|
174 |
Create instance NAME of the Isabelle logo (as EPS).
|
|
175 |
|
|
176 |
Options are:
|
|
177 |
-o OUTFILE set output file (default determined from NAME)
|
|
178 |
-q quiet mode
|
|
179 |
\end{ttbox}
|
|
180 |
You are encouraged to use this to create a derived logo for your
|
|
181 |
Isabelle project. For example, @{verbatim "isatool logo Bali"}
|
|
182 |
creates @{verbatim isabelle_bali.eps}.
|
|
183 |
*}
|
|
184 |
|
|
185 |
|
|
186 |
section {* Isabelle's version of make \label{sec:tool-make} *}
|
|
187 |
|
|
188 |
text {*
|
|
189 |
The Isabelle @{tool_def make} utility is a very simple wrapper for
|
|
190 |
ordinary Unix @{executable make}:
|
|
191 |
\begin{ttbox}
|
|
192 |
Usage: make [ARGS ...]
|
|
193 |
|
|
194 |
Compile the logic in current directory using IsaMakefile.
|
|
195 |
ARGS are directly passed to the system make program.
|
|
196 |
\end{ttbox}
|
|
197 |
|
|
198 |
Note that the Isabelle settings environment is also active. Thus one
|
|
199 |
may refer to its values within the @{verbatim IsaMakefile}, e.g.\
|
|
200 |
@{verbatim "$(ISABELLE_OUTPUT)"}. Furthermore, programs started from
|
|
201 |
the make file also inherit this environment. Typically, @{verbatim
|
|
202 |
IsaMakefile}s defer the real work to the @{tool_ref usedir} utility.
|
|
203 |
|
|
204 |
\medskip The basic @{verbatim IsaMakefile} convention is that the
|
|
205 |
default target builds the actual logic, including its parents if
|
|
206 |
appropriate. The @{verbatim images} target is intended to build all
|
|
207 |
local logic images, while the @{verbatim test} target shall build
|
|
208 |
all related examples. The @{verbatim all} target shall do
|
|
209 |
@{verbatim images} and @{verbatim test}.
|
|
210 |
*}
|
|
211 |
|
|
212 |
|
|
213 |
subsubsection {* Examples *}
|
|
214 |
|
|
215 |
text {*
|
|
216 |
Refer to the @{verbatim IsaMakefile}s of the Isabelle distribution's
|
|
217 |
object-logics as a model for your own developments. For example,
|
|
218 |
see @{verbatim "src/FOL/IsaMakefile"}.
|
|
219 |
*}
|
|
220 |
|
|
221 |
|
|
222 |
section {* Make all logics *}
|
|
223 |
|
|
224 |
text {*
|
|
225 |
The @{tool_def makeall} utility applies Isabelle make to all logic
|
|
226 |
directories of the distribution:
|
|
227 |
\begin{ttbox}
|
|
228 |
Usage: makeall [ARGS ...]
|
|
229 |
|
|
230 |
Apply isatool make to all logics (passing ARGS).
|
|
231 |
\end{ttbox}
|
|
232 |
|
|
233 |
The arguments @{verbatim ARGS} are just passed verbatim to each
|
|
234 |
@{tool make} invocation.
|
|
235 |
*}
|
|
236 |
|
|
237 |
|
|
238 |
section {* Printing documents *}
|
|
239 |
|
|
240 |
text {*
|
|
241 |
The @{tool_def print} utility prints documents:
|
|
242 |
\begin{ttbox}
|
|
243 |
Usage: print [OPTIONS] FILE
|
|
244 |
|
|
245 |
Options are:
|
|
246 |
-c cleanup -- remove FILE after use
|
|
247 |
|
|
248 |
Print document FILE.
|
|
249 |
\end{ttbox}
|
|
250 |
|
|
251 |
The @{verbatim "-c"} option causes the input file to be removed
|
|
252 |
after use. The printer spool command is determined by the @{setting
|
|
253 |
PRINT_COMMAND} setting.
|
|
254 |
*}
|
|
255 |
|
|
256 |
|
|
257 |
section {* Run Isabelle with plain tty interaction \label{sec:tool-tty} *}
|
|
258 |
|
|
259 |
text {*
|
|
260 |
The @{tool_def tty} utility runs the Isabelle process interactively
|
|
261 |
within a plain terminal session:
|
|
262 |
\begin{ttbox}
|
|
263 |
Usage: tty [OPTIONS]
|
|
264 |
|
|
265 |
Options are:
|
|
266 |
-l NAME logic image name (default ISABELLE_LOGIC)
|
|
267 |
-m MODE add print mode for output
|
|
268 |
-p NAME line editor program name (default ISABELLE_LINE_EDITOR)
|
|
269 |
|
|
270 |
Run Isabelle process with plain tty interaction, and optional line editor.
|
|
271 |
\end{ttbox}
|
|
272 |
|
|
273 |
The @{verbatim "-l"} option specifies the logic image. The
|
|
274 |
@{verbatim "-m"} option specifies additional print modes. The The
|
|
275 |
@{verbatim "-p"} option specifies an alternative line editor (such
|
|
276 |
as the @{executable rlwrap} wrapper for GNU readline); the fall-back
|
|
277 |
is to use raw standard input.
|
|
278 |
*}
|
|
279 |
|
|
280 |
|
|
281 |
section {* Remove awkward symbol names from theory sources *}
|
|
282 |
|
|
283 |
text {*
|
|
284 |
The @{tool_def unsymbolize} utility tunes Isabelle theory sources to
|
|
285 |
improve readability for plain ASCII output (e.g.\ in email
|
|
286 |
communication). Most notably, @{tool unsymbolize} replaces awkward
|
|
287 |
arrow symbols such as @{verbatim "\\"}@{verbatim "<Longrightarrow>"}
|
|
288 |
by @{verbatim "==>"}.
|
|
289 |
\begin{ttbox}
|
|
290 |
Usage: unsymbolize [FILES|DIRS...]
|
|
291 |
|
|
292 |
Recursively find .thy/.ML files, removing unreadable symbol names.
|
|
293 |
Note: this is an ad-hoc script; there is no systematic way to replace
|
|
294 |
symbols independently of the inner syntax of a theory!
|
|
295 |
|
|
296 |
Renames old versions of FILES by appending "~~".
|
|
297 |
\end{ttbox}
|
|
298 |
*}
|
|
299 |
|
|
300 |
|
|
301 |
section {* Output the version identifier of the Isabelle distribution *}
|
|
302 |
|
|
303 |
text {*
|
|
304 |
The @{tool_def version} utility outputs the full version string of
|
|
305 |
the Isabelle distribution being used, e.g.\ ``@{verbatim
|
|
306 |
"Isabelle2008: June 2008"}. There are no options nor arguments.
|
|
307 |
*}
|
|
308 |
|
|
309 |
|
|
310 |
section {* Convert XML to YXML *}
|
|
311 |
|
|
312 |
text {*
|
|
313 |
The @{tool_def yxml} tool converts a standard XML document (stdin)
|
|
314 |
to the much simpler and more efficient YXML format of Isabelle
|
|
315 |
(stdout). The YXML format is defined as follows.
|
|
316 |
|
|
317 |
\begin{enumerate}
|
|
318 |
|
|
319 |
\item The encoding is always UTF-8.
|
|
320 |
|
|
321 |
\item Body text is represented verbatim (no escaping, no special
|
|
322 |
treatment of white space, no named entities, no CDATA chunks, no
|
|
323 |
comments).
|
|
324 |
|
|
325 |
\item Markup elements are represented via ASCII control characters
|
|
326 |
@{text "\<^bold>X = 5"} and @{text "\<^bold>Y = 6"} as follows:
|
|
327 |
|
|
328 |
\begin{tabular}{ll}
|
|
329 |
XML & YXML \\\hline
|
|
330 |
@{verbatim "<"}@{text "name attribute"}@{verbatim "="}@{text "value \<dots>"}@{verbatim ">"} &
|
|
331 |
@{text "\<^bold>X\<^bold>Yname\<^bold>Yattribute"}@{verbatim "="}@{text "value\<dots>\<^bold>X"} \\
|
|
332 |
@{verbatim "</"}@{text name}@{verbatim ">"} & @{text "\<^bold>X\<^bold>Y\<^bold>X"} \\
|
|
333 |
\end{tabular}
|
|
334 |
|
|
335 |
There is no special case for empty body text, i.e.\ @{verbatim
|
|
336 |
"<foo/>"} is treated like @{verbatim "<foo></foo>"}. Also note that
|
|
337 |
@{text "\<^bold>X"} and @{text "\<^bold>Y"} may never occur in
|
|
338 |
well-formed XML documents.
|
|
339 |
|
|
340 |
\end{enumerate}
|
|
341 |
|
|
342 |
Parsing YXML is pretty straight-forward: split the text into chunks
|
|
343 |
separated by @{text "\<^bold>X"}, then split each chunk into
|
|
344 |
sub-chunks separated by @{text "\<^bold>Y"}. Markup chunks start
|
|
345 |
with an empty sub-chunk, and a second empty sub-chunk indicates
|
|
346 |
close of an element. Any other non-empty chunk consists of plain
|
|
347 |
text.
|
|
348 |
|
|
349 |
YXML documents may be detected quickly by checking that the first
|
|
350 |
two characters are @{text "\<^bold>X\<^bold>Y"}.
|
|
351 |
*}
|
|
352 |
|
|
353 |
end |