doc-src/IsarRef/Thy/Document_Preparation.thy
author wenzelm
Tue, 03 Jun 2008 00:03:52 +0200
changeset 27053 d58b0fd31b59
parent 27049 5072d6c77baa
child 27453 eecd9d84e41b
permissions -rw-r--r--
tuned;
wenzelm@27043
     1
(* $Id$ *)
wenzelm@27043
     2
wenzelm@27043
     3
theory Document_Preparation
wenzelm@27043
     4
imports Main
wenzelm@27043
     5
begin
wenzelm@27043
     6
wenzelm@27043
     7
chapter {* Document preparation \label{ch:document-prep} *}
wenzelm@27043
     8
wenzelm@27043
     9
text {*
wenzelm@27043
    10
  Isabelle/Isar provides a simple document preparation system based on
wenzelm@27043
    11
  existing {PDF-\LaTeX} technology, with full support of hyper-links
wenzelm@27043
    12
  (both local references and URLs) and bookmarks.  Thus the results
wenzelm@27043
    13
  are equally well suited for WWW browsing and as printed copies.
wenzelm@27043
    14
wenzelm@27043
    15
  \medskip Isabelle generates {\LaTeX} output as part of the run of a
wenzelm@27043
    16
  \emph{logic session} (see also \cite{isabelle-sys}).  Getting
wenzelm@27043
    17
  started with a working configuration for common situations is quite
wenzelm@27043
    18
  easy by using the Isabelle @{verbatim mkdir} and @{verbatim make}
wenzelm@27043
    19
  tools.  First invoke
wenzelm@27043
    20
\begin{ttbox}
wenzelm@27043
    21
  isatool mkdir Foo
wenzelm@27043
    22
\end{ttbox}
wenzelm@27043
    23
  to initialize a separate directory for session @{verbatim Foo} ---
wenzelm@27043
    24
  it is safe to experiment, since @{verbatim "isatool mkdir"} never
wenzelm@27043
    25
  overwrites existing files.  Ensure that @{verbatim "Foo/ROOT.ML"}
wenzelm@27043
    26
  holds ML commands to load all theories required for this session;
wenzelm@27043
    27
  furthermore @{verbatim "Foo/document/root.tex"} should include any
wenzelm@27043
    28
  special {\LaTeX} macro packages required for your document (the
wenzelm@27043
    29
  default is usually sufficient as a start).
wenzelm@27043
    30
wenzelm@27043
    31
  The session is controlled by a separate @{verbatim IsaMakefile}
wenzelm@27043
    32
  (with crude source dependencies by default).  This file is located
wenzelm@27043
    33
  one level up from the @{verbatim Foo} directory location.  Now
wenzelm@27043
    34
  invoke
wenzelm@27043
    35
\begin{ttbox}
wenzelm@27043
    36
  isatool make Foo
wenzelm@27043
    37
\end{ttbox}
wenzelm@27043
    38
  to run the @{verbatim Foo} session, with browser information and
wenzelm@27043
    39
  document preparation enabled.  Unless any errors are reported by
wenzelm@27043
    40
  Isabelle or {\LaTeX}, the output will appear inside the directory
wenzelm@27043
    41
  @{verbatim ISABELLE_BROWSER_INFO}, as reported by the batch job in
wenzelm@27043
    42
  verbose mode.
wenzelm@27043
    43
wenzelm@27043
    44
  \medskip You may also consider to tune the @{verbatim usedir}
wenzelm@27043
    45
  options in @{verbatim IsaMakefile}, for example to change the output
wenzelm@27043
    46
  format from @{verbatim pdf} to @{verbatim dvi}, or activate the
wenzelm@27043
    47
  @{verbatim "-D"} option to retain a second copy of the generated
wenzelm@27043
    48
  {\LaTeX} sources.
wenzelm@27043
    49
wenzelm@27043
    50
  \medskip See \emph{The Isabelle System Manual} \cite{isabelle-sys}
wenzelm@27043
    51
  for further details on Isabelle logic sessions and theory
wenzelm@27043
    52
  presentation.  The Isabelle/HOL tutorial \cite{isabelle-hol-book}
wenzelm@27043
    53
  also covers theory presentation issues.
wenzelm@27043
    54
*}
wenzelm@27043
    55
wenzelm@27043
    56
wenzelm@27043
    57
section {* Markup commands \label{sec:markup} *}
wenzelm@27043
    58
wenzelm@27043
    59
text {*
wenzelm@27043
    60
  \begin{matharray}{rcl}
wenzelm@27049
    61
    @{command_def "header"} & : & \isarkeep{toplevel} \\[0.5ex]
wenzelm@27043
    62
    @{command_def "chapter"} & : & \isarkeep{local{\dsh}theory} \\
wenzelm@27043
    63
    @{command_def "section"} & : & \isarkeep{local{\dsh}theory} \\
wenzelm@27043
    64
    @{command_def "subsection"} & : & \isarkeep{local{\dsh}theory} \\
wenzelm@27043
    65
    @{command_def "subsubsection"} & : & \isarkeep{local{\dsh}theory} \\
wenzelm@27043
    66
    @{command_def "text"} & : & \isarkeep{local{\dsh}theory} \\
wenzelm@27043
    67
    @{command_def "text_raw"} & : & \isarkeep{local{\dsh}theory} \\[0.5ex]
wenzelm@27043
    68
    @{command_def "sect"} & : & \isartrans{proof}{proof} \\
wenzelm@27043
    69
    @{command_def "subsect"} & : & \isartrans{proof}{proof} \\
wenzelm@27043
    70
    @{command_def "subsubsect"} & : & \isartrans{proof}{proof} \\
wenzelm@27043
    71
    @{command_def "txt"} & : & \isartrans{proof}{proof} \\
wenzelm@27043
    72
    @{command_def "txt_raw"} & : & \isartrans{proof}{proof} \\
wenzelm@27043
    73
  \end{matharray}
wenzelm@27043
    74
wenzelm@27043
    75
  Apart from formal comments (see \secref{sec:comments}), markup
wenzelm@27043
    76
  commands provide a structured way to insert text into the document
wenzelm@27043
    77
  generated from a theory (see \cite{isabelle-sys} for more
wenzelm@27043
    78
  information on Isabelle's document preparation tools).
wenzelm@27043
    79
wenzelm@27043
    80
  \begin{rail}
wenzelm@27043
    81
    ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text') target? text
wenzelm@27043
    82
    ;
wenzelm@27049
    83
    ('header' | 'text\_raw' | 'sect' | 'subsect' | 'subsubsect' | 'txt' | 'txt\_raw') text
wenzelm@27043
    84
    ;
wenzelm@27043
    85
  \end{rail}
wenzelm@27043
    86
wenzelm@27043
    87
  \begin{descr}
wenzelm@27043
    88
wenzelm@27049
    89
  \item [@{command "header"}~@{text "text"}] provides plain text
wenzelm@27049
    90
  markup just preceding the formal beginning of a theory.  In actual
wenzelm@27049
    91
  document preparation the corresponding {\LaTeX} macro @{verbatim
wenzelm@27049
    92
  "\\isamarkupheader"} may be redefined to produce chapter or section
wenzelm@27053
    93
  headings.
wenzelm@27049
    94
  
wenzelm@27043
    95
  \item [@{command "chapter"}, @{command "section"}, @{command
wenzelm@27043
    96
  "subsection"}, and @{command "subsubsection"}] mark chapter and
wenzelm@27053
    97
  section headings.  The corresponding {\LaTeX} macros are @{verbatim
wenzelm@27053
    98
  "\\isamarkupchapter"}, @{verbatim "\\isamarkupsection"} etc.
wenzelm@27043
    99
wenzelm@27043
   100
  \item [@{command "text"} and @{command "txt"}] specify paragraphs of
wenzelm@27043
   101
  plain text.
wenzelm@27043
   102
wenzelm@27043
   103
  \item [@{command "text_raw"} and @{command "txt_raw"}] insert
wenzelm@27043
   104
  {\LaTeX} source into the output, without additional markup.  Thus
wenzelm@27043
   105
  the full range of document manipulations becomes available.
wenzelm@27043
   106
wenzelm@27043
   107
  \end{descr}
wenzelm@27043
   108
wenzelm@27043
   109
  The @{text "text"} argument of these markup commands (except for
wenzelm@27043
   110
  @{command "text_raw"}) may contain references to formal entities
wenzelm@27043
   111
  (``antiquotations'', see also \secref{sec:antiq}).  These are
wenzelm@27043
   112
  interpreted in the present theory context, or the named @{text
wenzelm@27043
   113
  "target"}.
wenzelm@27043
   114
wenzelm@27043
   115
  Any of these markup elements corresponds to a {\LaTeX} command with
wenzelm@27043
   116
  the name prefixed by @{verbatim "\\isamarkup"}.  For the sectioning
wenzelm@27043
   117
  commands this is a plain macro with a single argument, e.g.\
wenzelm@27043
   118
  @{verbatim "\\isamarkupchapter{"}@{text "\<dots>"}@{verbatim "}"} for
wenzelm@27043
   119
  @{command "chapter"}.  The @{command "text"} markup results in a
wenzelm@27043
   120
  {\LaTeX} environment @{verbatim "\\begin{isamarkuptext}"} @{text
wenzelm@27043
   121
  "\<dots>"} @{verbatim "\\end{isamarkuptext}"}, while @{command "text_raw"}
wenzelm@27043
   122
  causes the text to be inserted directly into the {\LaTeX} source.
wenzelm@27043
   123
wenzelm@27043
   124
  \medskip The proof markup commands closely resemble those for theory
wenzelm@27043
   125
  specifications, but have a different formal status and produce
wenzelm@27043
   126
  different {\LaTeX} macros.  Also note that the @{command_ref
wenzelm@27043
   127
  "header"} declaration (see \secref{sec:begin-thy}) admits to insert
wenzelm@27043
   128
  section markup just preceding the actual theory definition.
wenzelm@27043
   129
*}
wenzelm@27043
   130
wenzelm@27043
   131
wenzelm@27043
   132
section {* Antiquotations \label{sec:antiq} *}
wenzelm@27043
   133
wenzelm@27043
   134
text {*
wenzelm@27043
   135
  \begin{matharray}{rcl}
wenzelm@27043
   136
    @{antiquotation_def "theory"} & : & \isarantiq \\
wenzelm@27043
   137
    @{antiquotation_def "thm"} & : & \isarantiq \\
wenzelm@27043
   138
    @{antiquotation_def "prop"} & : & \isarantiq \\
wenzelm@27043
   139
    @{antiquotation_def "term"} & : & \isarantiq \\
wenzelm@27043
   140
    @{antiquotation_def const} & : & \isarantiq \\
wenzelm@27043
   141
    @{antiquotation_def abbrev} & : & \isarantiq \\
wenzelm@27043
   142
    @{antiquotation_def typeof} & : & \isarantiq \\
wenzelm@27043
   143
    @{antiquotation_def typ} & : & \isarantiq \\
wenzelm@27043
   144
    @{antiquotation_def thm_style} & : & \isarantiq \\
wenzelm@27043
   145
    @{antiquotation_def term_style} & : & \isarantiq \\
wenzelm@27043
   146
    @{antiquotation_def "text"} & : & \isarantiq \\
wenzelm@27043
   147
    @{antiquotation_def goals} & : & \isarantiq \\
wenzelm@27043
   148
    @{antiquotation_def subgoals} & : & \isarantiq \\
wenzelm@27043
   149
    @{antiquotation_def prf} & : & \isarantiq \\
wenzelm@27043
   150
    @{antiquotation_def full_prf} & : & \isarantiq \\
wenzelm@27043
   151
    @{antiquotation_def ML} & : & \isarantiq \\
wenzelm@27043
   152
    @{antiquotation_def ML_type} & : & \isarantiq \\
wenzelm@27043
   153
    @{antiquotation_def ML_struct} & : & \isarantiq \\
wenzelm@27043
   154
  \end{matharray}
wenzelm@27043
   155
wenzelm@27043
   156
  The text body of formal comments (see also \secref{sec:comments})
wenzelm@27043
   157
  may contain antiquotations of logical entities, such as theorems,
wenzelm@27043
   158
  terms and types, which are to be presented in the final output
wenzelm@27053
   159
  produced by the Isabelle document preparation system.
wenzelm@27043
   160
wenzelm@27043
   161
  Thus embedding of ``@{text "@{term [show_types] \"f x = a + x\"}"}''
wenzelm@27043
   162
  within a text block would cause
wenzelm@27043
   163
  \isa{{\isacharparenleft}f{\isasymColon}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharplus}\ x} to appear in the final {\LaTeX} document.  Also note that theorem
wenzelm@27043
   164
  antiquotations may involve attributes as well.  For example,
wenzelm@27043
   165
  @{text "@{thm sym [no_vars]}"} would print the theorem's
wenzelm@27043
   166
  statement where all schematic variables have been replaced by fixed
wenzelm@27043
   167
  ones, which are easier to read.
wenzelm@27043
   168
wenzelm@27043
   169
  \begin{rail}
wenzelm@27043
   170
    atsign lbrace antiquotation rbrace
wenzelm@27043
   171
    ;
wenzelm@27043
   172
wenzelm@27043
   173
    antiquotation:
wenzelm@27043
   174
      'theory' options name |
wenzelm@27043
   175
      'thm' options thmrefs |
wenzelm@27043
   176
      'prop' options prop |
wenzelm@27043
   177
      'term' options term |
wenzelm@27043
   178
      'const' options term |
wenzelm@27043
   179
      'abbrev' options term |
wenzelm@27043
   180
      'typeof' options term |
wenzelm@27043
   181
      'typ' options type |
wenzelm@27043
   182
      'thm\_style' options name thmref |
wenzelm@27043
   183
      'term\_style' options name term |
wenzelm@27043
   184
      'text' options name |
wenzelm@27043
   185
      'goals' options |
wenzelm@27043
   186
      'subgoals' options |
wenzelm@27043
   187
      'prf' options thmrefs |
wenzelm@27043
   188
      'full\_prf' options thmrefs |
wenzelm@27043
   189
      'ML' options name |
wenzelm@27043
   190
      'ML\_type' options name |
wenzelm@27043
   191
      'ML\_struct' options name
wenzelm@27043
   192
    ;
wenzelm@27043
   193
    options: '[' (option * ',') ']'
wenzelm@27043
   194
    ;
wenzelm@27043
   195
    option: name | name '=' name
wenzelm@27043
   196
    ;
wenzelm@27043
   197
  \end{rail}
wenzelm@27043
   198
wenzelm@27043
   199
  Note that the syntax of antiquotations may \emph{not} include source
wenzelm@27043
   200
  comments @{verbatim "(*"}~@{text "\<dots>"}~@{verbatim "*)"} or verbatim
wenzelm@27043
   201
  text @{verbatim "{"}@{verbatim "*"}~@{text "\<dots>"}~@{verbatim
wenzelm@27043
   202
  "*"}@{verbatim "}"}.
wenzelm@27043
   203
wenzelm@27043
   204
  \begin{descr}
wenzelm@27043
   205
  
wenzelm@27043
   206
  \item [@{text "@{theory A}"}] prints the name @{text "A"}, which is
wenzelm@27043
   207
  guaranteed to refer to a valid ancestor theory in the current
wenzelm@27043
   208
  context.
wenzelm@27043
   209
wenzelm@27043
   210
  \item [@{text "@{thm a\<^sub>1 \<dots> a\<^sub>n}"}] prints theorems
wenzelm@27043
   211
  @{text "a\<^sub>1 \<dots> a\<^sub>n"}.  Note that attribute specifications
wenzelm@27043
   212
  may be included as well (see also \secref{sec:syn-att}); the
wenzelm@27043
   213
  @{attribute_ref no_vars} rule (see \secref{sec:misc-meth-att}) would
wenzelm@27043
   214
  be particularly useful to suppress printing of schematic variables.
wenzelm@27043
   215
wenzelm@27043
   216
  \item [@{text "@{prop \<phi>}"}] prints a well-typed proposition @{text
wenzelm@27043
   217
  "\<phi>"}.
wenzelm@27043
   218
wenzelm@27043
   219
  \item [@{text "@{term t}"}] prints a well-typed term @{text "t"}.
wenzelm@27043
   220
wenzelm@27043
   221
  \item [@{text "@{const c}"}] prints a logical or syntactic constant
wenzelm@27043
   222
  @{text "c"}.
wenzelm@27043
   223
  
wenzelm@27043
   224
  \item [@{text "@{abbrev c x\<^sub>1 \<dots> x\<^sub>n}"}] prints a constant
wenzelm@27043
   225
  abbreviation @{text "c x\<^sub>1 \<dots> x\<^sub>n \<equiv> rhs"} as defined in
wenzelm@27043
   226
  the current context.
wenzelm@27043
   227
wenzelm@27043
   228
  \item [@{text "@{typeof t}"}] prints the type of a well-typed term
wenzelm@27043
   229
  @{text "t"}.
wenzelm@27043
   230
wenzelm@27043
   231
  \item [@{text "@{typ \<tau>}"}] prints a well-formed type @{text "\<tau>"}.
wenzelm@27043
   232
  
wenzelm@27043
   233
  \item [@{text "@{thm_style s a}"}] prints theorem @{text a},
wenzelm@27043
   234
  previously applying a style @{text s} to it (see below).
wenzelm@27043
   235
  
wenzelm@27043
   236
  \item [@{text "@{term_style s t}"}] prints a well-typed term @{text
wenzelm@27043
   237
  t} after applying a style @{text s} to it (see below).
wenzelm@27043
   238
wenzelm@27043
   239
  \item [@{text "@{text s}"}] prints uninterpreted source text @{text
wenzelm@27043
   240
  s}.  This is particularly useful to print portions of text according
wenzelm@27043
   241
  to the Isabelle {\LaTeX} output style, without demanding
wenzelm@27043
   242
  well-formedness (e.g.\ small pieces of terms that should not be
wenzelm@27043
   243
  parsed or type-checked yet).
wenzelm@27043
   244
wenzelm@27043
   245
  \item [@{text "@{goals}"}] prints the current \emph{dynamic} goal
wenzelm@27043
   246
  state.  This is mainly for support of tactic-emulation scripts
wenzelm@27043
   247
  within Isar --- presentation of goal states does not conform to
wenzelm@27043
   248
  actual human-readable proof documents.
wenzelm@27043
   249
wenzelm@27043
   250
  Please do not include goal states into document output unless you
wenzelm@27043
   251
  really know what you are doing!
wenzelm@27043
   252
  
wenzelm@27043
   253
  \item [@{text "@{subgoals}"}] is similar to @{text "@{goals}"}, but
wenzelm@27043
   254
  does not print the main goal.
wenzelm@27043
   255
  
wenzelm@27043
   256
  \item [@{text "@{prf a\<^sub>1 \<dots> a\<^sub>n}"}] prints the (compact)
wenzelm@27043
   257
  proof terms corresponding to the theorems @{text "a\<^sub>1 \<dots>
wenzelm@27043
   258
  a\<^sub>n"}. Note that this requires proof terms to be switched on
wenzelm@27043
   259
  for the current object logic (see the ``Proof terms'' section of the
wenzelm@27043
   260
  Isabelle reference manual for information on how to do this).
wenzelm@27043
   261
  
wenzelm@27043
   262
  \item [@{text "@{full_prf a\<^sub>1 \<dots> a\<^sub>n}"}] is like @{text
wenzelm@27043
   263
  "@{prf a\<^sub>1 \<dots> a\<^sub>n}"}, but displays the full proof terms,
wenzelm@27043
   264
  i.e.\ also displays information omitted in the compact proof term,
wenzelm@27043
   265
  which is denoted by ``@{text _}'' placeholders there.
wenzelm@27043
   266
  
wenzelm@27043
   267
  \item [@{text "@{ML s}"}, @{text "@{ML_type s}"}, and @{text
wenzelm@27043
   268
  "@{ML_struct s}"}] check text @{text s} as ML value, type, and
wenzelm@27043
   269
  structure, respectively.  The source is displayed verbatim.
wenzelm@27043
   270
wenzelm@27043
   271
  \end{descr}
wenzelm@27043
   272
wenzelm@27043
   273
  \medskip The following standard styles for use with @{text
wenzelm@27043
   274
  thm_style} and @{text term_style} are available:
wenzelm@27043
   275
wenzelm@27043
   276
  \begin{descr}
wenzelm@27043
   277
  
wenzelm@27043
   278
  \item [@{text lhs}] extracts the first argument of any application
wenzelm@27043
   279
  form with at least two arguments -- typically meta-level or
wenzelm@27043
   280
  object-level equality, or any other binary relation.
wenzelm@27043
   281
  
wenzelm@27043
   282
  \item [@{text rhs}] is like @{text lhs}, but extracts the second
wenzelm@27043
   283
  argument.
wenzelm@27043
   284
  
wenzelm@27043
   285
  \item [@{text "concl"}] extracts the conclusion @{text C} from a rule
wenzelm@27043
   286
  in Horn-clause normal form @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C"}.
wenzelm@27043
   287
  
wenzelm@27043
   288
  \item [@{text "prem1"}, \dots, @{text "prem9"}] extract premise
wenzelm@27043
   289
  number @{text "1, \<dots>, 9"}, respectively, from from a rule in
wenzelm@27043
   290
  Horn-clause normal form @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C"}
wenzelm@27043
   291
wenzelm@27043
   292
  \end{descr}
wenzelm@27043
   293
wenzelm@27043
   294
  \medskip
wenzelm@27043
   295
  The following options are available to tune the output.  Note that most of
wenzelm@27043
   296
  these coincide with ML flags of the same names (see also \cite{isabelle-ref}).
wenzelm@27043
   297
wenzelm@27043
   298
  \begin{descr}
wenzelm@27043
   299
wenzelm@27043
   300
  \item[@{text "show_types = bool"} and @{text "show_sorts = bool"}]
wenzelm@27043
   301
  control printing of explicit type and sort constraints.
wenzelm@27043
   302
wenzelm@27043
   303
  \item[@{text "show_structs = bool"}] controls printing of implicit
wenzelm@27043
   304
  structures.
wenzelm@27043
   305
wenzelm@27043
   306
  \item[@{text "long_names = bool"}] forces names of types and
wenzelm@27043
   307
  constants etc.\ to be printed in their fully qualified internal
wenzelm@27043
   308
  form.
wenzelm@27043
   309
wenzelm@27043
   310
  \item[@{text "short_names = bool"}] forces names of types and
wenzelm@27043
   311
  constants etc.\ to be printed unqualified.  Note that internalizing
wenzelm@27043
   312
  the output again in the current context may well yield a different
wenzelm@27043
   313
  result.
wenzelm@27043
   314
wenzelm@27043
   315
  \item[@{text "unique_names = bool"}] determines whether the printed
wenzelm@27043
   316
  version of qualified names should be made sufficiently long to avoid
wenzelm@27043
   317
  overlap with names declared further back.  Set to @{text false} for
wenzelm@27043
   318
  more concise output.
wenzelm@27043
   319
wenzelm@27043
   320
  \item[@{text "eta_contract = bool"}] prints terms in @{text
wenzelm@27043
   321
  \<eta>}-contracted form.
wenzelm@27043
   322
wenzelm@27043
   323
  \item[@{text "display = bool"}] indicates if the text is to be
wenzelm@27043
   324
  output as multi-line ``display material'', rather than a small piece
wenzelm@27043
   325
  of text without line breaks (which is the default).
wenzelm@27043
   326
wenzelm@27043
   327
  \item[@{text "break = bool"}] controls line breaks in non-display
wenzelm@27043
   328
  material.
wenzelm@27043
   329
wenzelm@27043
   330
  \item[@{text "quotes = bool"}] indicates if the output should be
wenzelm@27043
   331
  enclosed in double quotes.
wenzelm@27043
   332
wenzelm@27043
   333
  \item[@{text "mode = name"}] adds @{text name} to the print mode to
wenzelm@27043
   334
  be used for presentation (see also \cite{isabelle-ref}).  Note that
wenzelm@27043
   335
  the standard setup for {\LaTeX} output is already present by
wenzelm@27043
   336
  default, including the modes @{text latex} and @{text xsymbols}.
wenzelm@27043
   337
wenzelm@27043
   338
  \item[@{text "margin = nat"} and @{text "indent = nat"}] change the
wenzelm@27043
   339
  margin or indentation for pretty printing of display material.
wenzelm@27043
   340
wenzelm@27043
   341
  \item[@{text "source = bool"}] prints the source text of the
wenzelm@27043
   342
  antiquotation arguments, rather than the actual value.  Note that
wenzelm@27043
   343
  this does not affect well-formedness checks of @{antiquotation
wenzelm@27043
   344
  "thm"}, @{antiquotation "term"}, etc. (only the @{antiquotation
wenzelm@27043
   345
  "text"} antiquotation admits arbitrary output).
wenzelm@27043
   346
wenzelm@27043
   347
  \item[@{text "goals_limit = nat"}] determines the maximum number of
wenzelm@27043
   348
  goals to be printed.
wenzelm@27043
   349
wenzelm@27043
   350
  \item[@{text "locale = name"}] specifies an alternative locale
wenzelm@27043
   351
  context used for evaluating and printing the subsequent argument.
wenzelm@27043
   352
wenzelm@27043
   353
  \end{descr}
wenzelm@27043
   354
wenzelm@27043
   355
  For boolean flags, ``@{text "name = true"}'' may be abbreviated as
wenzelm@27043
   356
  ``@{text name}''.  All of the above flags are disabled by default,
wenzelm@27043
   357
  unless changed from ML.
wenzelm@27043
   358
wenzelm@27043
   359
  \medskip Note that antiquotations do not only spare the author from
wenzelm@27043
   360
  tedious typing of logical entities, but also achieve some degree of
wenzelm@27043
   361
  consistency-checking of informal explanations with formal
wenzelm@27043
   362
  developments: well-formedness of terms and types with respect to the
wenzelm@27043
   363
  current theory or proof context is ensured here.
wenzelm@27043
   364
*}
wenzelm@27043
   365
wenzelm@27043
   366
wenzelm@27043
   367
section {* Tagged commands \label{sec:tags} *}
wenzelm@27043
   368
wenzelm@27043
   369
text {*
wenzelm@27043
   370
  Each Isabelle/Isar command may be decorated by presentation tags:
wenzelm@27043
   371
wenzelm@27043
   372
  \indexouternonterm{tags}
wenzelm@27043
   373
  \begin{rail}
wenzelm@27043
   374
    tags: ( tag * )
wenzelm@27043
   375
    ;
wenzelm@27043
   376
    tag: '\%' (ident | string)
wenzelm@27043
   377
  \end{rail}
wenzelm@27043
   378
wenzelm@27043
   379
  The tags @{text "theory"}, @{text "proof"}, @{text "ML"} are already
wenzelm@27043
   380
  pre-declared for certain classes of commands:
wenzelm@27043
   381
wenzelm@27043
   382
 \medskip
wenzelm@27043
   383
wenzelm@27043
   384
  \begin{tabular}{ll}
wenzelm@27043
   385
    @{text "theory"} & theory begin/end \\
wenzelm@27043
   386
    @{text "proof"} & all proof commands \\
wenzelm@27043
   387
    @{text "ML"} & all commands involving ML code \\
wenzelm@27043
   388
  \end{tabular}
wenzelm@27043
   389
wenzelm@27043
   390
  \medskip The Isabelle document preparation system (see also
wenzelm@27043
   391
  \cite{isabelle-sys}) allows tagged command regions to be presented
wenzelm@27043
   392
  specifically, e.g.\ to fold proof texts, or drop parts of the text
wenzelm@27043
   393
  completely.
wenzelm@27043
   394
wenzelm@27043
   395
  For example ``@{command "by"}~@{text "%invisible auto"}'' would
wenzelm@27043
   396
  cause that piece of proof to be treated as @{text invisible} instead
wenzelm@27043
   397
  of @{text "proof"} (the default), which may be either show or hidden
wenzelm@27043
   398
  depending on the document setup.  In contrast, ``@{command
wenzelm@27043
   399
  "by"}~@{text "%visible auto"}'' would force this text to be shown
wenzelm@27043
   400
  invariably.
wenzelm@27043
   401
wenzelm@27043
   402
  Explicit tag specifications within a proof apply to all subsequent
wenzelm@27043
   403
  commands of the same level of nesting.  For example, ``@{command
wenzelm@27043
   404
  "proof"}~@{text "%visible \<dots>"}~@{command "qed"}'' would force the
wenzelm@27043
   405
  whole sub-proof to be typeset as @{text visible} (unless some of its
wenzelm@27043
   406
  parts are tagged differently).
wenzelm@27043
   407
*}
wenzelm@27043
   408
wenzelm@27043
   409
wenzelm@27043
   410
section {* Draft presentation *}
wenzelm@27043
   411
wenzelm@27043
   412
text {*
wenzelm@27043
   413
  \begin{matharray}{rcl}
wenzelm@27043
   414
    @{command_def "display_drafts"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
wenzelm@27043
   415
    @{command_def "print_drafts"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
wenzelm@27043
   416
  \end{matharray}
wenzelm@27043
   417
wenzelm@27043
   418
  \begin{rail}
wenzelm@27043
   419
    ('display\_drafts' | 'print\_drafts') (name +)
wenzelm@27043
   420
    ;
wenzelm@27043
   421
  \end{rail}
wenzelm@27043
   422
wenzelm@27043
   423
  \begin{descr}
wenzelm@27043
   424
wenzelm@27043
   425
  \item [@{command "display_drafts"}~@{text paths} and @{command
wenzelm@27043
   426
  "print_drafts"}~@{text paths}] perform simple output of a given list
wenzelm@27043
   427
  of raw source files.  Only those symbols that do not require
wenzelm@27043
   428
  additional {\LaTeX} packages are displayed properly, everything else
wenzelm@27043
   429
  is left verbatim.
wenzelm@27043
   430
wenzelm@27043
   431
  \end{descr}
wenzelm@27043
   432
*}
wenzelm@27043
   433
wenzelm@27043
   434
end