wenzelm@28224
|
1 |
theory Misc
|
wenzelm@44450
|
2 |
imports Base
|
wenzelm@28224
|
3 |
begin
|
wenzelm@28224
|
4 |
|
wenzelm@28224
|
5 |
chapter {* Miscellaneous tools \label{ch:tools} *}
|
wenzelm@28224
|
6 |
|
wenzelm@28224
|
7 |
text {*
|
wenzelm@28224
|
8 |
Subsequently we describe various Isabelle related utilities, given
|
wenzelm@28224
|
9 |
in alphabetical order.
|
wenzelm@28224
|
10 |
*}
|
wenzelm@28224
|
11 |
|
wenzelm@28224
|
12 |
|
wenzelm@49859
|
13 |
section {* Resolving Isabelle components \label{sec:tool-components} *}
|
wenzelm@49859
|
14 |
|
wenzelm@49859
|
15 |
text {*
|
wenzelm@49859
|
16 |
The @{tool_def components} tool resolves Isabelle components:
|
wenzelm@49859
|
17 |
\begin{ttbox}
|
wenzelm@49859
|
18 |
Usage: isabelle components [OPTIONS] [COMPONENTS ...]
|
wenzelm@49859
|
19 |
|
wenzelm@49859
|
20 |
Options are:
|
wenzelm@51668
|
21 |
-I init user settings
|
wenzelm@49859
|
22 |
-R URL component repository
|
wenzelm@49859
|
23 |
(default $ISABELLE_COMPONENT_REPOSITORY)
|
wenzelm@54572
|
24 |
-a resolve all missing components
|
wenzelm@49859
|
25 |
-l list status
|
wenzelm@49859
|
26 |
|
wenzelm@49859
|
27 |
Resolve Isabelle components via download and installation.
|
wenzelm@49859
|
28 |
COMPONENTS are identified via base name.
|
wenzelm@49859
|
29 |
|
wenzelm@49859
|
30 |
ISABELLE_COMPONENT_REPOSITORY="http://isabelle.in.tum.de/components"
|
wenzelm@49859
|
31 |
\end{ttbox}
|
wenzelm@49859
|
32 |
|
wenzelm@49859
|
33 |
Components are initialized as described in \secref{sec:components}
|
wenzelm@49859
|
34 |
in a permissive manner, which can mark components as ``missing''.
|
wenzelm@49859
|
35 |
This state is amended by letting @{tool "components"} download and
|
wenzelm@49859
|
36 |
unpack components that are published on the default component
|
wenzelm@49859
|
37 |
repository \url{http://isabelle.in.tum.de/components/} in
|
wenzelm@49859
|
38 |
particular.
|
wenzelm@49859
|
39 |
|
wenzelm@49859
|
40 |
Option @{verbatim "-R"} specifies an alternative component
|
wenzelm@49859
|
41 |
repository. Note that @{verbatim "file:///"} URLs can be used for
|
wenzelm@49859
|
42 |
local directories.
|
wenzelm@49859
|
43 |
|
wenzelm@49859
|
44 |
Option @{verbatim "-a"} selects all missing components to be
|
wenzelm@54572
|
45 |
resolved. Explicit components may be named as command
|
wenzelm@49859
|
46 |
line-arguments as well. Note that components are uniquely
|
wenzelm@49859
|
47 |
identified by their base name, while the installation takes place in
|
wenzelm@49859
|
48 |
the location that was specified in the attempt to initialize the
|
wenzelm@49859
|
49 |
component before.
|
wenzelm@49859
|
50 |
|
wenzelm@49859
|
51 |
Option @{verbatim "-l"} lists the current state of available and
|
wenzelm@49859
|
52 |
missing components with their location (full name) within the
|
wenzelm@51668
|
53 |
file-system.
|
wenzelm@51668
|
54 |
|
wenzelm@51668
|
55 |
Option @{verbatim "-I"} initializes the user settings file to
|
wenzelm@51668
|
56 |
subscribe to the standard components specified in the Isabelle
|
wenzelm@51668
|
57 |
repository clone --- this does not make any sense for regular
|
wenzelm@51668
|
58 |
Isabelle releases. If the file already exists, it needs to be
|
wenzelm@51668
|
59 |
edited manually according to the printed explanation.
|
wenzelm@51668
|
60 |
*}
|
wenzelm@49859
|
61 |
|
wenzelm@49859
|
62 |
|
wenzelm@53581
|
63 |
section {* Displaying documents \label{sec:tool-display} *}
|
wenzelm@28224
|
64 |
|
wenzelm@49617
|
65 |
text {* The @{tool_def display} tool displays documents in DVI or PDF
|
wenzelm@28224
|
66 |
format:
|
wenzelm@28224
|
67 |
\begin{ttbox}
|
wenzelm@49617
|
68 |
Usage: isabelle display [OPTIONS] FILE
|
wenzelm@28224
|
69 |
|
wenzelm@28224
|
70 |
Options are:
|
wenzelm@28224
|
71 |
-c cleanup -- remove FILE after use
|
wenzelm@28224
|
72 |
|
wenzelm@53581
|
73 |
Display document FILE (in DVI or PDF format).
|
wenzelm@28224
|
74 |
\end{ttbox}
|
wenzelm@28224
|
75 |
|
wenzelm@28224
|
76 |
\medskip The @{verbatim "-c"} option causes the input file to be
|
wenzelm@53581
|
77 |
removed after use.
|
wenzelm@53581
|
78 |
|
wenzelm@53581
|
79 |
\medskip The settings @{setting DVI_VIEWER} and @{setting
|
wenzelm@53581
|
80 |
PDF_VIEWER} determine the programs for viewing the corresponding
|
wenzelm@53581
|
81 |
file formats.
|
wenzelm@28224
|
82 |
*}
|
wenzelm@28224
|
83 |
|
wenzelm@28224
|
84 |
|
wenzelm@28224
|
85 |
section {* Viewing documentation \label{sec:tool-doc} *}
|
wenzelm@28224
|
86 |
|
wenzelm@28224
|
87 |
text {*
|
wenzelm@53581
|
88 |
The @{tool_def doc} tool displays Isabelle documentation:
|
wenzelm@28224
|
89 |
\begin{ttbox}
|
wenzelm@53581
|
90 |
Usage: isabelle doc [DOC ...]
|
wenzelm@28224
|
91 |
|
wenzelm@53581
|
92 |
View Isabelle documentation.
|
wenzelm@28224
|
93 |
\end{ttbox}
|
wenzelm@28224
|
94 |
If called without arguments, it lists all available documents. Each
|
wenzelm@28224
|
95 |
line starts with an identifier, followed by a short description. Any
|
wenzelm@53581
|
96 |
of these identifiers may be specified as arguments, in order to
|
wenzelm@53581
|
97 |
display the corresponding document (see also
|
wenzelm@53581
|
98 |
\secref{sec:tool-display}).
|
wenzelm@28224
|
99 |
|
wenzelm@28224
|
100 |
\medskip The @{setting ISABELLE_DOCS} setting specifies the list of
|
wenzelm@28224
|
101 |
directories (separated by colons) to be scanned for documentations.
|
wenzelm@28224
|
102 |
*}
|
wenzelm@28224
|
103 |
|
wenzelm@28224
|
104 |
|
wenzelm@48699
|
105 |
section {* Shell commands within the settings environment \label{sec:tool-env} *}
|
wenzelm@48699
|
106 |
|
wenzelm@49617
|
107 |
text {* The @{tool_def env} tool is a direct wrapper for the standard
|
wenzelm@49617
|
108 |
@{verbatim "/usr/bin/env"} command on POSIX systems, running within
|
wenzelm@49617
|
109 |
the Isabelle settings environment (\secref{sec:settings}).
|
wenzelm@48699
|
110 |
|
wenzelm@48699
|
111 |
The command-line arguments are that of the underlying version of
|
wenzelm@48699
|
112 |
@{verbatim env}. For example, the following invokes an instance of
|
wenzelm@48699
|
113 |
the GNU Bash shell within the Isabelle environment:
|
wenzelm@48699
|
114 |
\begin{alltt}
|
wenzelm@48699
|
115 |
isabelle env bash
|
wenzelm@48699
|
116 |
\end{alltt}
|
wenzelm@48699
|
117 |
*}
|
wenzelm@48699
|
118 |
|
wenzelm@48699
|
119 |
|
wenzelm@28224
|
120 |
section {* Getting logic images *}
|
wenzelm@28224
|
121 |
|
wenzelm@49617
|
122 |
text {* The @{tool_def findlogics} tool traverses all directories
|
wenzelm@28224
|
123 |
specified in @{setting ISABELLE_PATH}, looking for Isabelle logic
|
wenzelm@28224
|
124 |
images. Its usage is:
|
wenzelm@28224
|
125 |
\begin{ttbox}
|
wenzelm@49592
|
126 |
Usage: isabelle findlogics
|
wenzelm@28224
|
127 |
|
wenzelm@28224
|
128 |
Collect heap file names from ISABELLE_PATH.
|
wenzelm@28224
|
129 |
\end{ttbox}
|
wenzelm@28224
|
130 |
|
wenzelm@28224
|
131 |
The base names of all files found on the path are printed --- sorted
|
wenzelm@28224
|
132 |
and with duplicates removed. Also note that lookup in @{setting
|
wenzelm@28224
|
133 |
ISABELLE_PATH} includes the current values of @{setting ML_SYSTEM}
|
wenzelm@28224
|
134 |
and @{setting ML_PLATFORM}. Thus switching to another ML compiler
|
wenzelm@28224
|
135 |
may change the set of logic images available.
|
wenzelm@28224
|
136 |
*}
|
wenzelm@28224
|
137 |
|
wenzelm@28224
|
138 |
|
wenzelm@28224
|
139 |
section {* Inspecting the settings environment \label{sec:tool-getenv} *}
|
wenzelm@28224
|
140 |
|
wenzelm@49617
|
141 |
text {* The Isabelle settings environment --- as provided by the
|
wenzelm@28224
|
142 |
site-default and user-specific settings files --- can be inspected
|
wenzelm@49617
|
143 |
with the @{tool_def getenv} tool:
|
wenzelm@28224
|
144 |
\begin{ttbox}
|
wenzelm@49617
|
145 |
Usage: isabelle getenv [OPTIONS] [VARNAMES ...]
|
wenzelm@28224
|
146 |
|
wenzelm@28224
|
147 |
Options are:
|
wenzelm@28224
|
148 |
-a display complete environment
|
wenzelm@28224
|
149 |
-b print values only (doesn't work for -a)
|
wenzelm@31483
|
150 |
-d FILE dump complete environment to FILE
|
wenzelm@31483
|
151 |
(null terminated entries)
|
wenzelm@28224
|
152 |
|
wenzelm@28224
|
153 |
Get value of VARNAMES from the Isabelle settings.
|
wenzelm@28224
|
154 |
\end{ttbox}
|
wenzelm@28224
|
155 |
|
wenzelm@28224
|
156 |
With the @{verbatim "-a"} option, one may inspect the full process
|
wenzelm@28224
|
157 |
environment that Isabelle related programs are run in. This usually
|
wenzelm@28224
|
158 |
contains much more variables than are actually Isabelle settings.
|
wenzelm@28224
|
159 |
Normally, output is a list of lines of the form @{text
|
wenzelm@28224
|
160 |
name}@{verbatim "="}@{text value}. The @{verbatim "-b"} option
|
wenzelm@28224
|
161 |
causes only the values to be printed.
|
wenzelm@31483
|
162 |
|
wenzelm@31483
|
163 |
Option @{verbatim "-d"} produces a dump of the complete environment
|
wenzelm@31483
|
164 |
to the specified file. Entries are terminated by the ASCII null
|
wenzelm@31483
|
165 |
character, i.e.\ the C string terminator.
|
wenzelm@28224
|
166 |
*}
|
wenzelm@28224
|
167 |
|
wenzelm@28224
|
168 |
|
wenzelm@28224
|
169 |
subsubsection {* Examples *}
|
wenzelm@28224
|
170 |
|
wenzelm@49830
|
171 |
text {* Get the location of @{setting ISABELLE_HOME_USER} where
|
wenzelm@49830
|
172 |
user-specific information is stored:
|
wenzelm@28224
|
173 |
\begin{ttbox}
|
wenzelm@49830
|
174 |
isabelle getenv ISABELLE_HOME_USER
|
wenzelm@28224
|
175 |
\end{ttbox}
|
wenzelm@28224
|
176 |
|
wenzelm@49830
|
177 |
\medskip Get the value only of the same settings variable, which is
|
wenzelm@49830
|
178 |
particularly useful in shell scripts:
|
wenzelm@28224
|
179 |
\begin{ttbox}
|
wenzelm@28504
|
180 |
isabelle getenv -b ISABELLE_OUTPUT
|
wenzelm@28224
|
181 |
\end{ttbox}
|
wenzelm@28224
|
182 |
*}
|
wenzelm@28224
|
183 |
|
wenzelm@28224
|
184 |
|
wenzelm@28224
|
185 |
section {* Installing standalone Isabelle executables \label{sec:tool-install} *}
|
wenzelm@28224
|
186 |
|
wenzelm@49617
|
187 |
text {* By default, the main Isabelle binaries (@{executable
|
wenzelm@49617
|
188 |
"isabelle"} etc.) are just run from their location within the
|
wenzelm@49617
|
189 |
distribution directory, probably indirectly by the shell through its
|
wenzelm@49617
|
190 |
@{setting PATH}. Other schemes of installation are supported by the
|
wenzelm@49617
|
191 |
@{tool_def install} tool:
|
wenzelm@28224
|
192 |
\begin{ttbox}
|
wenzelm@51147
|
193 |
Usage: isabelle install [OPTIONS] BINDIR
|
wenzelm@28224
|
194 |
|
wenzelm@28224
|
195 |
Options are:
|
wenzelm@51147
|
196 |
-d DISTDIR refer to DISTDIR as Isabelle distribution
|
wenzelm@28224
|
197 |
(default ISABELLE_HOME)
|
wenzelm@28224
|
198 |
|
wenzelm@51147
|
199 |
Install Isabelle executables with absolute references to the
|
wenzelm@28224
|
200 |
distribution directory.
|
wenzelm@28224
|
201 |
\end{ttbox}
|
wenzelm@28224
|
202 |
|
wenzelm@28224
|
203 |
The @{verbatim "-d"} option overrides the current Isabelle
|
wenzelm@28224
|
204 |
distribution directory as determined by @{setting ISABELLE_HOME}.
|
wenzelm@28224
|
205 |
|
wenzelm@51147
|
206 |
The @{text BINDIR} argument tells where executable wrapper scripts
|
wenzelm@51147
|
207 |
for @{executable "isabelle-process"} and @{executable isabelle}
|
wenzelm@51147
|
208 |
should be placed, which is typically a directory in the shell's
|
wenzelm@51147
|
209 |
@{setting PATH}, such as @{verbatim "$HOME/bin"}.
|
wenzelm@49830
|
210 |
|
wenzelm@51147
|
211 |
\medskip It is also possible to make symbolic links of the main
|
wenzelm@51147
|
212 |
Isabelle executables manually, but making separate copies outside
|
wenzelm@51147
|
213 |
the Isabelle distribution directory will not work! *}
|
wenzelm@28224
|
214 |
|
wenzelm@28224
|
215 |
|
wenzelm@28224
|
216 |
section {* Creating instances of the Isabelle logo *}
|
wenzelm@28224
|
217 |
|
wenzelm@50087
|
218 |
text {* The @{tool_def logo} tool creates instances of the generic
|
wenzelm@50087
|
219 |
Isabelle logo as EPS and PDF, for inclusion in {\LaTeX} documents.
|
wenzelm@28224
|
220 |
\begin{ttbox}
|
wenzelm@50087
|
221 |
Usage: isabelle logo [OPTIONS] XYZ
|
wenzelm@28224
|
222 |
|
wenzelm@50087
|
223 |
Create instance XYZ of the Isabelle logo (as EPS and PDF).
|
wenzelm@28224
|
224 |
|
wenzelm@28224
|
225 |
Options are:
|
wenzelm@50087
|
226 |
-n NAME alternative output base name (default "isabelle_xyx")
|
wenzelm@28224
|
227 |
-q quiet mode
|
wenzelm@28224
|
228 |
\end{ttbox}
|
wenzelm@49951
|
229 |
|
wenzelm@50087
|
230 |
Option @{verbatim "-n"} specifies an altenative (base) name for the
|
wenzelm@50087
|
231 |
generated files. The default is @{verbatim "isabelle_"}@{text xyz}
|
wenzelm@50087
|
232 |
in lower-case.
|
wenzelm@49951
|
233 |
|
wenzelm@49951
|
234 |
Option @{verbatim "-q"} omits printing of the result file name.
|
wenzelm@49951
|
235 |
|
wenzelm@49951
|
236 |
\medskip Implementors of Isabelle tools and applications are
|
wenzelm@49951
|
237 |
encouraged to make derived Isabelle logos for their own projects
|
wenzelm@49951
|
238 |
using this template. *}
|
wenzelm@28224
|
239 |
|
wenzelm@28224
|
240 |
|
wenzelm@28224
|
241 |
section {* Remove awkward symbol names from theory sources *}
|
wenzelm@28224
|
242 |
|
wenzelm@28224
|
243 |
text {*
|
wenzelm@49617
|
244 |
The @{tool_def unsymbolize} tool tunes Isabelle theory sources to
|
wenzelm@28224
|
245 |
improve readability for plain ASCII output (e.g.\ in email
|
wenzelm@28224
|
246 |
communication). Most notably, @{tool unsymbolize} replaces awkward
|
wenzelm@28224
|
247 |
arrow symbols such as @{verbatim "\\"}@{verbatim "<Longrightarrow>"}
|
wenzelm@28224
|
248 |
by @{verbatim "==>"}.
|
wenzelm@28224
|
249 |
\begin{ttbox}
|
wenzelm@49617
|
250 |
Usage: isabelle unsymbolize [FILES|DIRS...]
|
wenzelm@28224
|
251 |
|
wenzelm@28224
|
252 |
Recursively find .thy/.ML files, removing unreadable symbol names.
|
wenzelm@28224
|
253 |
Note: this is an ad-hoc script; there is no systematic way to replace
|
wenzelm@28224
|
254 |
symbols independently of the inner syntax of a theory!
|
wenzelm@28224
|
255 |
|
wenzelm@28224
|
256 |
Renames old versions of FILES by appending "~~".
|
wenzelm@28224
|
257 |
\end{ttbox}
|
wenzelm@28224
|
258 |
*}
|
wenzelm@28224
|
259 |
|
wenzelm@28224
|
260 |
|
wenzelm@28224
|
261 |
section {* Output the version identifier of the Isabelle distribution *}
|
wenzelm@28224
|
262 |
|
wenzelm@28224
|
263 |
text {*
|
wenzelm@49617
|
264 |
The @{tool_def version} tool displays Isabelle version information:
|
wenzelm@41759
|
265 |
\begin{ttbox}
|
wenzelm@41759
|
266 |
Usage: isabelle version [OPTIONS]
|
wenzelm@41759
|
267 |
|
wenzelm@41759
|
268 |
Options are:
|
wenzelm@41759
|
269 |
-i short identification (derived from Mercurial id)
|
wenzelm@41759
|
270 |
|
wenzelm@41759
|
271 |
Display Isabelle version information.
|
wenzelm@41759
|
272 |
\end{ttbox}
|
wenzelm@41759
|
273 |
|
wenzelm@41759
|
274 |
\medskip The default is to output the full version string of the
|
wenzelm@48698
|
275 |
Isabelle distribution, e.g.\ ``@{verbatim "Isabelle2012: May 2012"}.
|
wenzelm@41759
|
276 |
|
wenzelm@41759
|
277 |
The @{verbatim "-i"} option produces a short identification derived
|
wenzelm@41759
|
278 |
from the Mercurial id of the @{setting ISABELLE_HOME} directory.
|
wenzelm@28224
|
279 |
*}
|
wenzelm@28224
|
280 |
|
wenzelm@28224
|
281 |
|
wenzelm@28224
|
282 |
section {* Convert XML to YXML *}
|
wenzelm@28224
|
283 |
|
wenzelm@28224
|
284 |
text {*
|
wenzelm@28224
|
285 |
The @{tool_def yxml} tool converts a standard XML document (stdin)
|
wenzelm@28224
|
286 |
to the much simpler and more efficient YXML format of Isabelle
|
wenzelm@28224
|
287 |
(stdout). The YXML format is defined as follows.
|
wenzelm@28224
|
288 |
|
wenzelm@28224
|
289 |
\begin{enumerate}
|
wenzelm@28224
|
290 |
|
wenzelm@28224
|
291 |
\item The encoding is always UTF-8.
|
wenzelm@28224
|
292 |
|
wenzelm@28224
|
293 |
\item Body text is represented verbatim (no escaping, no special
|
wenzelm@28224
|
294 |
treatment of white space, no named entities, no CDATA chunks, no
|
wenzelm@28224
|
295 |
comments).
|
wenzelm@28224
|
296 |
|
wenzelm@28224
|
297 |
\item Markup elements are represented via ASCII control characters
|
wenzelm@28224
|
298 |
@{text "\<^bold>X = 5"} and @{text "\<^bold>Y = 6"} as follows:
|
wenzelm@28224
|
299 |
|
wenzelm@28224
|
300 |
\begin{tabular}{ll}
|
wenzelm@28224
|
301 |
XML & YXML \\\hline
|
wenzelm@28224
|
302 |
@{verbatim "<"}@{text "name attribute"}@{verbatim "="}@{text "value \<dots>"}@{verbatim ">"} &
|
wenzelm@28224
|
303 |
@{text "\<^bold>X\<^bold>Yname\<^bold>Yattribute"}@{verbatim "="}@{text "value\<dots>\<^bold>X"} \\
|
wenzelm@28224
|
304 |
@{verbatim "</"}@{text name}@{verbatim ">"} & @{text "\<^bold>X\<^bold>Y\<^bold>X"} \\
|
wenzelm@28224
|
305 |
\end{tabular}
|
wenzelm@28224
|
306 |
|
wenzelm@28224
|
307 |
There is no special case for empty body text, i.e.\ @{verbatim
|
wenzelm@28224
|
308 |
"<foo/>"} is treated like @{verbatim "<foo></foo>"}. Also note that
|
wenzelm@28224
|
309 |
@{text "\<^bold>X"} and @{text "\<^bold>Y"} may never occur in
|
wenzelm@28224
|
310 |
well-formed XML documents.
|
wenzelm@28224
|
311 |
|
wenzelm@28224
|
312 |
\end{enumerate}
|
wenzelm@28224
|
313 |
|
wenzelm@28224
|
314 |
Parsing YXML is pretty straight-forward: split the text into chunks
|
wenzelm@28224
|
315 |
separated by @{text "\<^bold>X"}, then split each chunk into
|
wenzelm@28224
|
316 |
sub-chunks separated by @{text "\<^bold>Y"}. Markup chunks start
|
wenzelm@28224
|
317 |
with an empty sub-chunk, and a second empty sub-chunk indicates
|
wenzelm@28224
|
318 |
close of an element. Any other non-empty chunk consists of plain
|
wenzelm@45670
|
319 |
text. For example, see @{file "~~/src/Pure/PIDE/yxml.ML"} or
|
wenzelm@45670
|
320 |
@{file "~~/src/Pure/PIDE/yxml.scala"}.
|
wenzelm@28224
|
321 |
|
wenzelm@28224
|
322 |
YXML documents may be detected quickly by checking that the first
|
wenzelm@28224
|
323 |
two characters are @{text "\<^bold>X\<^bold>Y"}.
|
wenzelm@28224
|
324 |
*}
|
wenzelm@28224
|
325 |
|
wenzelm@28224
|
326 |
end |