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