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