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