| author | wenzelm |
| Tue, 23 Jun 2009 20:14:40 +0200 | |
| changeset 31778 | eb174cfdef1a |
| parent 31497 | 5333aa739082 |
| child 32088 | 2110fcd86efb |
| permissions | -rw-r--r-- |
| 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) |
|
| 31497 | 88 |
-d FILE dump complete environment to FILE |
89 |
(null terminated entries) |
|
| 28224 | 90 |
|
91 |
Get value of VARNAMES from the Isabelle settings. |
|
92 |
\end{ttbox}
|
|
93 |
||
94 |
With the @{verbatim "-a"} option, one may inspect the full process
|
|
95 |
environment that Isabelle related programs are run in. This usually |
|
96 |
contains much more variables than are actually Isabelle settings. |
|
97 |
Normally, output is a list of lines of the form @{text
|
|
98 |
name}@{verbatim "="}@{text value}. The @{verbatim "-b"} option
|
|
99 |
causes only the values to be printed. |
|
| 31497 | 100 |
|
101 |
Option @{verbatim "-d"} produces a dump of the complete environment
|
|
102 |
to the specified file. Entries are terminated by the ASCII null |
|
103 |
character, i.e.\ the C string terminator. |
|
| 28224 | 104 |
*} |
105 |
||
106 |
||
107 |
subsubsection {* Examples *}
|
|
108 |
||
109 |
text {*
|
|
110 |
Get the ML system name and the location where the compiler binaries |
|
111 |
are supposed to reside as follows: |
|
112 |
\begin{ttbox}
|
|
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
113 |
isabelle getenv ML_SYSTEM ML_HOME |
| 28224 | 114 |
{\out ML_SYSTEM=polyml}
|
115 |
{\out ML_HOME=/usr/share/polyml/x86-linux}
|
|
116 |
\end{ttbox}
|
|
117 |
||
118 |
The next one peeks at the output directory for Isabelle logic |
|
119 |
images: |
|
120 |
\begin{ttbox}
|
|
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
121 |
isabelle getenv -b ISABELLE_OUTPUT |
| 28224 | 122 |
{\out /home/me/isabelle/heaps/polyml_x86-linux}
|
123 |
\end{ttbox}
|
|
124 |
Here we have used the @{verbatim "-b"} option to suppress the
|
|
125 |
@{verbatim "ISABELLE_OUTPUT="} prefix. The value above is what
|
|
126 |
became of the following assignment in the default settings file: |
|
127 |
\begin{ttbox}
|
|
128 |
ISABELLE_OUTPUT="\$ISABELLE_HOME_USER/heaps" |
|
129 |
\end{ttbox}
|
|
130 |
||
131 |
Note how the @{setting ML_IDENTIFIER} value got appended
|
|
132 |
automatically to each path component. This is a special feature of |
|
133 |
@{setting ISABELLE_OUTPUT}.
|
|
134 |
*} |
|
135 |
||
136 |
||
137 |
section {* Installing standalone Isabelle executables \label{sec:tool-install} *}
|
|
138 |
||
139 |
text {*
|
|
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
140 |
By default, the main Isabelle binaries (@{executable "isabelle"}
|
|
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
141 |
etc.) are just run from their location within the distribution |
|
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
142 |
directory, probably indirectly by the shell through its @{setting
|
|
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
143 |
PATH}. Other schemes of installation are supported by the |
|
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
144 |
@{tool_def install} utility:
|
| 28224 | 145 |
\begin{ttbox}
|
146 |
Usage: install [OPTIONS] |
|
147 |
||
148 |
Options are: |
|
149 |
-d DISTDIR use DISTDIR as Isabelle distribution |
|
150 |
(default ISABELLE_HOME) |
|
151 |
-p DIR install standalone binaries in DIR |
|
152 |
||
153 |
Install Isabelle executables with absolute references to the current |
|
154 |
distribution directory. |
|
155 |
\end{ttbox}
|
|
156 |
||
157 |
The @{verbatim "-d"} option overrides the current Isabelle
|
|
158 |
distribution directory as determined by @{setting ISABELLE_HOME}.
|
|
159 |
||
160 |
The @{verbatim "-p"} option installs executable wrapper scripts for
|
|
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
161 |
@{executable "isabelle-process"}, @{executable isabelle},
|
| 28238 | 162 |
@{executable Isabelle}, containing proper absolute references to the
|
163 |
Isabelle distribution directory. A typical @{verbatim DIR}
|
|
164 |
specification would be some directory expected to be in the shell's |
|
165 |
@{setting PATH}, such as @{verbatim "/usr/local/bin"}. It is
|
|
166 |
important to note that a plain manual copy of the original Isabelle |
|
167 |
executables does not work, since it disrupts the integrity of the |
|
168 |
Isabelle distribution. |
|
| 28224 | 169 |
*} |
170 |
||
171 |
||
172 |
section {* Creating instances of the Isabelle logo *}
|
|
173 |
||
174 |
text {*
|
|
175 |
The @{tool_def logo} utility creates any instance of the generic
|
|
176 |
Isabelle logo as an Encapsuled Postscript file (EPS): |
|
177 |
\begin{ttbox}
|
|
178 |
Usage: logo [OPTIONS] NAME |
|
179 |
||
180 |
Create instance NAME of the Isabelle logo (as EPS). |
|
181 |
||
182 |
Options are: |
|
183 |
-o OUTFILE set output file (default determined from NAME) |
|
184 |
-q quiet mode |
|
185 |
\end{ttbox}
|
|
186 |
You are encouraged to use this to create a derived logo for your |
|
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
187 |
Isabelle project. For example, @{verbatim isabelle} @{tool
|
| 28238 | 188 |
logo}~@{verbatim Bali} creates @{verbatim isabelle_bali.eps}.
|
| 28224 | 189 |
*} |
190 |
||
191 |
||
192 |
section {* Isabelle's version of make \label{sec:tool-make} *}
|
|
193 |
||
194 |
text {*
|
|
195 |
The Isabelle @{tool_def make} utility is a very simple wrapper for
|
|
196 |
ordinary Unix @{executable make}:
|
|
197 |
\begin{ttbox}
|
|
198 |
Usage: make [ARGS ...] |
|
199 |
||
200 |
Compile the logic in current directory using IsaMakefile. |
|
201 |
ARGS are directly passed to the system make program. |
|
202 |
\end{ttbox}
|
|
203 |
||
204 |
Note that the Isabelle settings environment is also active. Thus one |
|
205 |
may refer to its values within the @{verbatim IsaMakefile}, e.g.\
|
|
206 |
@{verbatim "$(ISABELLE_OUTPUT)"}. Furthermore, programs started from
|
|
207 |
the make file also inherit this environment. Typically, @{verbatim
|
|
208 |
IsaMakefile}s defer the real work to the @{tool_ref usedir} utility.
|
|
209 |
||
210 |
\medskip The basic @{verbatim IsaMakefile} convention is that the
|
|
211 |
default target builds the actual logic, including its parents if |
|
212 |
appropriate. The @{verbatim images} target is intended to build all
|
|
213 |
local logic images, while the @{verbatim test} target shall build
|
|
214 |
all related examples. The @{verbatim all} target shall do
|
|
215 |
@{verbatim images} and @{verbatim test}.
|
|
216 |
*} |
|
217 |
||
218 |
||
219 |
subsubsection {* Examples *}
|
|
220 |
||
221 |
text {*
|
|
222 |
Refer to the @{verbatim IsaMakefile}s of the Isabelle distribution's
|
|
223 |
object-logics as a model for your own developments. For example, |
|
| 28238 | 224 |
see @{"file" "~~/src/FOL/IsaMakefile"}.
|
| 28224 | 225 |
*} |
226 |
||
227 |
||
228 |
section {* Make all logics *}
|
|
229 |
||
230 |
text {*
|
|
231 |
The @{tool_def makeall} utility applies Isabelle make to all logic
|
|
232 |
directories of the distribution: |
|
233 |
\begin{ttbox}
|
|
234 |
Usage: makeall [ARGS ...] |
|
235 |
||
|
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28253
diff
changeset
|
236 |
Apply isabelle make to all logics (passing ARGS). |
| 28224 | 237 |
\end{ttbox}
|
238 |
||
239 |
The arguments @{verbatim ARGS} are just passed verbatim to each
|
|
240 |
@{tool make} invocation.
|
|
241 |
*} |
|
242 |
||
243 |
||
244 |
section {* Printing documents *}
|
|
245 |
||
246 |
text {*
|
|
247 |
The @{tool_def print} utility prints documents:
|
|
248 |
\begin{ttbox}
|
|
249 |
Usage: print [OPTIONS] FILE |
|
250 |
||
251 |
Options are: |
|
252 |
-c cleanup -- remove FILE after use |
|
253 |
||
254 |
Print document FILE. |
|
255 |
\end{ttbox}
|
|
256 |
||
257 |
The @{verbatim "-c"} option causes the input file to be removed
|
|
258 |
after use. The printer spool command is determined by the @{setting
|
|
259 |
PRINT_COMMAND} setting. |
|
260 |
*} |
|
261 |
||
262 |
||
263 |
section {* Remove awkward symbol names from theory sources *}
|
|
264 |
||
265 |
text {*
|
|
266 |
The @{tool_def unsymbolize} utility tunes Isabelle theory sources to
|
|
267 |
improve readability for plain ASCII output (e.g.\ in email |
|
268 |
communication). Most notably, @{tool unsymbolize} replaces awkward
|
|
269 |
arrow symbols such as @{verbatim "\\"}@{verbatim "<Longrightarrow>"}
|
|
270 |
by @{verbatim "==>"}.
|
|
271 |
\begin{ttbox}
|
|
272 |
Usage: unsymbolize [FILES|DIRS...] |
|
273 |
||
274 |
Recursively find .thy/.ML files, removing unreadable symbol names. |
|
275 |
Note: this is an ad-hoc script; there is no systematic way to replace |
|
276 |
symbols independently of the inner syntax of a theory! |
|
277 |
||
278 |
Renames old versions of FILES by appending "~~". |
|
279 |
\end{ttbox}
|
|
280 |
*} |
|
281 |
||
282 |
||
283 |
section {* Output the version identifier of the Isabelle distribution *}
|
|
284 |
||
285 |
text {*
|
|
286 |
The @{tool_def version} utility outputs the full version string of
|
|
287 |
the Isabelle distribution being used, e.g.\ ``@{verbatim
|
|
288 |
"Isabelle2008: June 2008"}. There are no options nor arguments. |
|
289 |
*} |
|
290 |
||
291 |
||
292 |
section {* Convert XML to YXML *}
|
|
293 |
||
294 |
text {*
|
|
295 |
The @{tool_def yxml} tool converts a standard XML document (stdin)
|
|
296 |
to the much simpler and more efficient YXML format of Isabelle |
|
297 |
(stdout). The YXML format is defined as follows. |
|
298 |
||
299 |
\begin{enumerate}
|
|
300 |
||
301 |
\item The encoding is always UTF-8. |
|
302 |
||
303 |
\item Body text is represented verbatim (no escaping, no special |
|
304 |
treatment of white space, no named entities, no CDATA chunks, no |
|
305 |
comments). |
|
306 |
||
307 |
\item Markup elements are represented via ASCII control characters |
|
308 |
@{text "\<^bold>X = 5"} and @{text "\<^bold>Y = 6"} as follows:
|
|
309 |
||
310 |
\begin{tabular}{ll}
|
|
311 |
XML & YXML \\\hline |
|
312 |
@{verbatim "<"}@{text "name attribute"}@{verbatim "="}@{text "value \<dots>"}@{verbatim ">"} &
|
|
313 |
@{text "\<^bold>X\<^bold>Yname\<^bold>Yattribute"}@{verbatim "="}@{text "value\<dots>\<^bold>X"} \\
|
|
314 |
@{verbatim "</"}@{text name}@{verbatim ">"} & @{text "\<^bold>X\<^bold>Y\<^bold>X"} \\
|
|
315 |
\end{tabular}
|
|
316 |
||
317 |
There is no special case for empty body text, i.e.\ @{verbatim
|
|
318 |
"<foo/>"} is treated like @{verbatim "<foo></foo>"}. Also note that
|
|
319 |
@{text "\<^bold>X"} and @{text "\<^bold>Y"} may never occur in
|
|
320 |
well-formed XML documents. |
|
321 |
||
322 |
\end{enumerate}
|
|
323 |
||
324 |
Parsing YXML is pretty straight-forward: split the text into chunks |
|
325 |
separated by @{text "\<^bold>X"}, then split each chunk into
|
|
326 |
sub-chunks separated by @{text "\<^bold>Y"}. Markup chunks start
|
|
327 |
with an empty sub-chunk, and a second empty sub-chunk indicates |
|
328 |
close of an element. Any other non-empty chunk consists of plain |
|
| 28238 | 329 |
text. For example, see @{"file" "~~/src/Pure/General/yxml.ML"} or
|
330 |
@{"file" "~~/src/Pure/General/yxml.scala"}.
|
|
| 28224 | 331 |
|
332 |
YXML documents may be detected quickly by checking that the first |
|
333 |
two characters are @{text "\<^bold>X\<^bold>Y"}.
|
|
334 |
*} |
|
335 |
||
336 |
end |