author | wenzelm |
Wed, 04 Nov 2015 20:18:46 +0100 | |
changeset 61575 | f18f6e51e901 |
parent 61504 | a7ae3ef886a9 |
child 61656 | cfabbc083977 |
permissions | -rw-r--r-- |
61575 | 1 |
(*:wrap=hard:maxLineLen=78:*) |
2 |
||
28221 | 3 |
theory Presentation |
43564
9864182c6bad
document antiquotations are managed as theory data, with proper name space and entity markup;
wenzelm
parents:
42009
diff
changeset
|
4 |
imports Base |
28221 | 5 |
begin |
6 |
||
58618 | 7 |
chapter \<open>Presenting theories \label{ch:present}\<close> |
28221 | 8 |
|
61575 | 9 |
text \<open> |
10 |
Isabelle provides several ways to present the outcome of formal |
|
11 |
developments, including WWW-based browsable libraries or actual printable |
|
12 |
documents. Presentation is centered around the concept of \<^emph>\<open>sessions\<close> |
|
13 |
(\chref{ch:session}). The global session structure is that of a tree, with |
|
14 |
Isabelle Pure at its root, further object-logics derived (e.g.\ HOLCF from |
|
15 |
HOL, and HOL from Pure), and application sessions further on in the |
|
16 |
hierarchy. |
|
28221 | 17 |
|
61575 | 18 |
The tools @{tool_ref mkroot} and @{tool_ref build} provide the primary means |
19 |
for managing Isabelle sessions, including proper setup for presentation; |
|
20 |
@{tool build} takes care to have @{executable_ref "isabelle_process"} run |
|
21 |
any additional stages required for document preparation, notably the |
|
22 |
@{tool_ref document} and @{tool_ref latex}. The complete tool chain for |
|
23 |
managing batch-mode Isabelle sessions is illustrated in |
|
24 |
\figref{fig:session-tools}. |
|
28221 | 25 |
|
26 |
\begin{figure}[htbp] |
|
27 |
\begin{center} |
|
28 |
\begin{tabular}{lp{0.6\textwidth}} |
|
29 |
||
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
30 |
@{tool_ref mkroot} & invoked once by the user to initialize the |
61503 | 31 |
session \<^verbatim>\<open>ROOT\<close> with optional \<^verbatim>\<open>document\<close> |
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
32 |
directory; \\ |
28221 | 33 |
|
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
34 |
@{tool_ref build} & invoked repeatedly by the user to keep |
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
35 |
session output up-to-date (HTML, documents etc.); \\ |
28221 | 36 |
|
56439
95e2656b3b23
renamed "isabelle-process" to "isabelle_process", with shell function to avoid dynamic path lookups;
wenzelm
parents:
54936
diff
changeset
|
37 |
@{executable "isabelle_process"} & run through @{tool_ref |
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
38 |
build}; \\ |
28221 | 39 |
|
48602 | 40 |
@{tool_ref document} & run by the Isabelle process if document |
41 |
preparation is enabled; \\ |
|
28221 | 42 |
|
48602 | 43 |
@{tool_ref latex} & universal {\LaTeX} tool wrapper invoked |
44 |
multiple times by @{tool_ref document}; also useful for manual |
|
45 |
experiments; \\ |
|
28221 | 46 |
|
47 |
\end{tabular} |
|
48 |
\caption{The tool chain of Isabelle session presentation} \label{fig:session-tools} |
|
49 |
\end{center} |
|
50 |
\end{figure} |
|
58618 | 51 |
\<close> |
28221 | 52 |
|
53 |
||
58618 | 54 |
section \<open>Generating theory browser information \label{sec:info}\<close> |
28221 | 55 |
|
58618 | 56 |
text \<open> |
28221 | 57 |
\index{theory browsing information|bold} |
58 |
||
61575 | 59 |
As a side-effect of building sessions, Isabelle is able to generate theory |
60 |
browsing information, including HTML documents that show the theory sources |
|
61 |
and the relationship with its ancestors and descendants. Besides the HTML |
|
62 |
file that is generated for every theory, Isabelle stores links to all |
|
63 |
theories of a session in an index file. As a second hierarchy, groups of |
|
64 |
sessions are organized as \<^emph>\<open>chapters\<close>, with a separate index. Note that the |
|
65 |
implicit tree structure of the session build hierarchy is \<^emph>\<open>not\<close> relevant |
|
51417 | 66 |
for the presentation. |
28221 | 67 |
|
61575 | 68 |
Isabelle also generates graph files that represent the theory dependencies |
69 |
within a session. There is a graph browser Java applet embedded in the |
|
70 |
generated HTML pages, and also a stand-alone application that allows |
|
71 |
browsing theory graphs without having to start a WWW client first. The |
|
72 |
latter version also includes features such as generating Postscript files, |
|
73 |
which are not available in the applet version. See \secref{sec:browse} for |
|
74 |
further information. |
|
28221 | 75 |
|
61406 | 76 |
\<^medskip> |
61575 | 77 |
The easiest way to let Isabelle generate theory browsing information for |
78 |
existing sessions is to invoke @{tool build} with suitable options: |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
79 |
@{verbatim [display] \<open>isabelle build -o browser_info -v -c FOL\<close>} |
28221 | 80 |
|
61575 | 81 |
The presentation output will appear in \<^verbatim>\<open>$ISABELLE_BROWSER_INFO/FOL/FOL\<close> as |
82 |
reported by the above verbose invocation of the build process. |
|
28221 | 83 |
|
61503 | 84 |
Many Isabelle sessions (such as \<^verbatim>\<open>HOL-Library\<close> in @{file |
61575 | 85 |
"~~/src/HOL/Library"}) also provide actual printable documents. These are |
86 |
prepared automatically as well if enabled like this: |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
87 |
@{verbatim [display] \<open>isabelle build -o browser_info -o document=pdf -v -c HOL-Library\<close>} |
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
88 |
|
61575 | 89 |
Enabling both browser info and document preparation simultaneously causes an |
90 |
appropriate ``document'' link to be included in the HTML index. Documents |
|
91 |
may be generated independently of browser information as well, see |
|
92 |
\secref{sec:tool-document} for further details. |
|
28221 | 93 |
|
61406 | 94 |
\<^bigskip> |
61575 | 95 |
The theory browsing information is stored in a sub-directory directory |
96 |
determined by the @{setting_ref ISABELLE_BROWSER_INFO} setting plus a prefix |
|
97 |
corresponding to the session chapter and identifier. In order to present |
|
98 |
Isabelle applications on the web, the corresponding subdirectory from |
|
99 |
@{setting ISABELLE_BROWSER_INFO} can be put on a WWW server. |
|
100 |
\<close> |
|
28221 | 101 |
|
61406 | 102 |
|
58618 | 103 |
section \<open>Preparing session root directories \label{sec:tool-mkroot}\<close> |
28221 | 104 |
|
61575 | 105 |
text \<open> |
106 |
The @{tool_def mkroot} tool configures a given directory as session root, |
|
107 |
with some \<^verbatim>\<open>ROOT\<close> file and optional document source directory. Its usage is: |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
108 |
@{verbatim [display] |
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
109 |
\<open>Usage: isabelle mkroot [OPTIONS] [DIR] |
28221 | 110 |
|
111 |
Options are: |
|
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
112 |
-d enable document preparation |
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
113 |
-n NAME alternative session name (default: DIR base name) |
28221 | 114 |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
115 |
Prepare session root DIR (default: current directory).\<close>} |
28221 | 116 |
|
61575 | 117 |
The results are placed in the given directory \<open>dir\<close>, which refers to the |
118 |
current directory by default. The @{tool mkroot} tool is conservative in the |
|
119 |
sense that it does not overwrite existing files or directories. Earlier |
|
120 |
attempts to generate a session root need to be deleted manually. |
|
28221 | 121 |
|
61406 | 122 |
\<^medskip> |
61575 | 123 |
Option \<^verbatim>\<open>-d\<close> indicates that the session shall be accompanied by a formal |
124 |
document, with \<open>DIR\<close>\<^verbatim>\<open>/document/root.tex\<close> as its {\LaTeX} entry point (see |
|
125 |
also \chref{ch:present}). |
|
28221 | 126 |
|
61575 | 127 |
Option \<^verbatim>\<open>-n\<close> allows to specify an alternative session name; otherwise the |
128 |
base name of the given directory is used. |
|
28221 | 129 |
|
61406 | 130 |
\<^medskip> |
61575 | 131 |
The implicit Isabelle settings variable @{setting ISABELLE_LOGIC} specifies |
132 |
the parent session, and @{setting ISABELLE_DOCUMENT_FORMAT} the document |
|
133 |
format to be filled filled into the generated \<^verbatim>\<open>ROOT\<close> file. |
|
61503 | 134 |
\<close> |
28221 | 135 |
|
136 |
||
58618 | 137 |
subsubsection \<open>Examples\<close> |
28221 | 138 |
|
61575 | 139 |
text \<open> |
140 |
Produce session \<^verbatim>\<open>Test\<close> (with document preparation) within a separate |
|
141 |
directory of the same name: |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
142 |
@{verbatim [display] \<open>isabelle mkroot -d Test && isabelle build -D Test\<close>} |
28221 | 143 |
|
61406 | 144 |
\<^medskip> |
61575 | 145 |
Upgrade the current directory into a session ROOT with document preparation, |
146 |
and build it: |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
147 |
@{verbatim [display] \<open>isabelle mkroot -d && isabelle build -D .\<close>} |
58618 | 148 |
\<close> |
28221 | 149 |
|
150 |
||
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
151 |
section \<open>Preparing Isabelle session documents \label{sec:tool-document}\<close> |
28221 | 152 |
|
61575 | 153 |
text \<open> |
154 |
The @{tool_def document} tool prepares logic session documents, processing |
|
155 |
the sources as provided by the user and generated by Isabelle. Its usage is: |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
156 |
@{verbatim [display] |
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
157 |
\<open>Usage: isabelle document [OPTIONS] [DIR] |
28221 | 158 |
|
159 |
Options are: |
|
160 |
-c cleanup -- be aggressive in removing old stuff |
|
161 |
-n NAME specify document name (default 'document') |
|
52746 | 162 |
-o FORMAT specify output format: pdf (default), dvi |
28221 | 163 |
-t TAGS specify tagged region markup |
164 |
||
165 |
Prepare the theory session document in DIR (default 'document') |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
166 |
producing the specified output format.\<close>} |
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
167 |
|
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
168 |
This tool is usually run automatically as part of the Isabelle build |
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
169 |
process, provided document preparation has been enabled via suitable |
61575 | 170 |
options. It may be manually invoked on the generated browser information |
171 |
document output as well, e.g.\ in case of errors encountered in the batch |
|
172 |
run. |
|
28221 | 173 |
|
61406 | 174 |
\<^medskip> |
61575 | 175 |
The \<^verbatim>\<open>-c\<close> option tells @{tool document} to dispose the document sources |
176 |
after successful operation! This is the right thing to do for sources |
|
177 |
generated by an Isabelle process, but take care of your files in manual |
|
178 |
document preparation! |
|
28221 | 179 |
|
61406 | 180 |
\<^medskip> |
61575 | 181 |
The \<^verbatim>\<open>-n\<close> and \<^verbatim>\<open>-o\<close> option specify the final output file name and format, |
182 |
the default is ``\<^verbatim>\<open>document.dvi\<close>''. Note that the result will appear in the |
|
183 |
parent of the target \<^verbatim>\<open>DIR\<close>. |
|
28221 | 184 |
|
61406 | 185 |
\<^medskip> |
61575 | 186 |
The \<^verbatim>\<open>-t\<close> option tells {\LaTeX} how to interpret tagged Isabelle command |
187 |
regions. Tags are specified as a comma separated list of modifier/name |
|
188 |
pairs: ``\<^verbatim>\<open>+\<close>\<open>foo\<close>'' (or just ``\<open>foo\<close>'') means to keep, ``\<^verbatim>\<open>-\<close>\<open>foo\<close>'' to |
|
189 |
drop, and ``\<^verbatim>\<open>/\<close>\<open>foo\<close>'' to fold text tagged as \<open>foo\<close>. The builtin default is |
|
190 |
equivalent to the tag specification |
|
191 |
``\<^verbatim>\<open>+theory,+proof,+ML,+visible,-invisible\<close>''; see also the {\LaTeX} macros |
|
192 |
\<^verbatim>\<open>\isakeeptag\<close>, \<^verbatim>\<open>\isadroptag\<close>, and \<^verbatim>\<open>\isafoldtag\<close>, in @{file |
|
193 |
"~~/lib/texinputs/isabelle.sty"}. |
|
28221 | 194 |
|
61406 | 195 |
\<^medskip> |
61575 | 196 |
Document preparation requires a \<^verbatim>\<open>document\<close> directory within the session |
197 |
sources. This directory is supposed to contain all the files needed to |
|
198 |
produce the final document --- apart from the actual theories which are |
|
199 |
generated by Isabelle. |
|
28221 | 200 |
|
61406 | 201 |
\<^medskip> |
61575 | 202 |
For most practical purposes, @{tool document} is smart enough to create any |
203 |
of the specified output formats, taking \<^verbatim>\<open>root.tex\<close> supplied by the user as |
|
204 |
a starting point. This even includes multiple runs of {\LaTeX} to |
|
205 |
accommodate references and bibliographies (the latter assumes \<^verbatim>\<open>root.bib\<close> |
|
206 |
within the same directory). |
|
28221 | 207 |
|
61575 | 208 |
In more complex situations, a separate \<^verbatim>\<open>build\<close> script for the document |
209 |
sources may be given. It is invoked with command-line arguments for the |
|
210 |
document format and the document variant name. The script needs to produce |
|
211 |
corresponding output files, e.g.\ \<^verbatim>\<open>root.pdf\<close> for target format \<^verbatim>\<open>pdf\<close> (and |
|
212 |
default variants). The main work can be again delegated to @{tool latex}, |
|
213 |
but it is also possible to harvest generated {\LaTeX} sources and copy them |
|
214 |
elsewhere. |
|
28221 | 215 |
|
61406 | 216 |
\<^medskip> |
61575 | 217 |
When running the session, Isabelle copies the content of the original |
218 |
\<^verbatim>\<open>document\<close> directory into its proper place within @{setting |
|
219 |
ISABELLE_BROWSER_INFO}, according to the session path and document variant. |
|
220 |
Then, for any processed theory \<open>A\<close> some {\LaTeX} source is generated and put |
|
221 |
there as \<open>A\<close>\<^verbatim>\<open>.tex\<close>. Furthermore, a list of all generated theory files is |
|
222 |
put into \<^verbatim>\<open>session.tex\<close>. Typically, the root {\LaTeX} file provided by the |
|
223 |
user would include \<^verbatim>\<open>session.tex\<close> to get a document containing all the |
|
224 |
theories. |
|
28221 | 225 |
|
61575 | 226 |
The {\LaTeX} versions of the theories require some macros defined in @{file |
227 |
"~~/lib/texinputs/isabelle.sty"}. Doing \<^verbatim>\<open>\usepackage{isabelle}\<close> in |
|
228 |
\<^verbatim>\<open>root.tex\<close> should be fine; the underlying @{tool latex} already includes an |
|
229 |
appropriate path specification for {\TeX} inputs. |
|
28221 | 230 |
|
61575 | 231 |
If the text contains any references to Isabelle symbols (such as \<^verbatim>\<open>\<forall>\<close>) then |
232 |
\<^verbatim>\<open>isabellesym.sty\<close> should be included as well. This package contains a |
|
233 |
standard set of {\LaTeX} macro definitions \<^verbatim>\<open>\isasym\<close>\<open>foo\<close> corresponding to |
|
234 |
\<^verbatim>\<open>\\<close>\<^verbatim>\<open><\<close>\<open>foo\<close>\<^verbatim>\<open>>\<close>, see @{cite "isabelle-implementation"} for a complete list |
|
235 |
of predefined Isabelle symbols. Users may invent further symbols as well, |
|
236 |
just by providing {\LaTeX} macros in a similar fashion as in @{file |
|
237 |
"~~/lib/texinputs/isabellesym.sty"} of the Isabelle distribution. |
|
28221 | 238 |
|
61575 | 239 |
For proper setup of DVI and PDF documents (with hyperlinks and bookmarks), |
240 |
we recommend to include @{file "~~/lib/texinputs/pdfsetup.sty"} as well. |
|
28221 | 241 |
|
61406 | 242 |
\<^medskip> |
61575 | 243 |
As a final step of Isabelle document preparation, @{tool document}~\<^verbatim>\<open>-c\<close> is |
244 |
run on the resulting copy of the \<^verbatim>\<open>document\<close> directory. Thus the actual |
|
245 |
output document is built and installed in its proper place. The generated |
|
246 |
sources are deleted after successful run of {\LaTeX} and friends. |
|
48814
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
247 |
|
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
248 |
Some care is needed if the document output location is configured |
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
249 |
differently, say within a directory whose content is still required |
d488a5f25bf6
some updates of "Presenting theories", using mkroot/build instead of former mkdir/make/usedir (which are still present in "Misc");
wenzelm
parents:
48722
diff
changeset
|
250 |
afterwards! |
58618 | 251 |
\<close> |
28221 | 252 |
|
253 |
||
58618 | 254 |
section \<open>Running {\LaTeX} within the Isabelle environment |
255 |
\label{sec:tool-latex}\<close> |
|
28221 | 256 |
|
61575 | 257 |
text \<open> |
258 |
The @{tool_def latex} tool provides the basic interface for Isabelle |
|
259 |
document preparation. Its usage is: |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
260 |
@{verbatim [display] |
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
261 |
\<open>Usage: isabelle latex [OPTIONS] [FILE] |
28221 | 262 |
|
263 |
Options are: |
|
52746 | 264 |
-o FORMAT specify output format: pdf (default), dvi, |
265 |
bbl, idx, sty, syms |
|
28221 | 266 |
|
267 |
Run LaTeX (and related tools) on FILE (default root.tex), |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
268 |
producing the specified output format.\<close>} |
28221 | 269 |
|
61575 | 270 |
Appropriate {\LaTeX}-related programs are run on the input file, according |
271 |
to the given output format: @{executable latex}, @{executable pdflatex}, |
|
272 |
@{executable dvips}, @{executable bibtex} (for \<^verbatim>\<open>bbl\<close>), and @{executable |
|
273 |
makeindex} (for \<^verbatim>\<open>idx\<close>). The actual commands are determined from the |
|
274 |
settings environment (@{setting ISABELLE_PDFLATEX} etc.). |
|
28221 | 275 |
|
61575 | 276 |
The \<^verbatim>\<open>sty\<close> output format causes the Isabelle style files to be updated from |
277 |
the distribution. This is useful in special situations where the document |
|
278 |
sources are to be processed another time by separate tools. |
|
28221 | 279 |
|
61575 | 280 |
The \<^verbatim>\<open>syms\<close> output is for internal use; it generates lists of symbols that |
281 |
are available without loading additional {\LaTeX} packages. |
|
58618 | 282 |
\<close> |
28221 | 283 |
|
284 |
||
58618 | 285 |
subsubsection \<open>Examples\<close> |
28221 | 286 |
|
61575 | 287 |
text \<open> |
288 |
Invoking @{tool latex} by hand may be occasionally useful when debugging |
|
289 |
failed attempts of the automatic document preparation stage of batch-mode |
|
290 |
Isabelle. The abortive process leaves the sources at a certain place within |
|
291 |
@{setting ISABELLE_BROWSER_INFO}, see the runtime error message for details. |
|
292 |
This enables users to inspect {\LaTeX} runs in further detail, e.g.\ like |
|
293 |
this: |
|
48602 | 294 |
|
61407
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
295 |
@{verbatim [display] |
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
296 |
\<open>cd "$(isabelle getenv -b ISABELLE_BROWSER_INFO)/Unsorted/Test/document" |
7ba7b8103565
@{verbatim [display]} supersedes old alltt/ttbox;
wenzelm
parents:
61406
diff
changeset
|
297 |
isabelle latex -o pdf\<close>} |
58618 | 298 |
\<close> |
28221 | 299 |
|
300 |
end |