src/Doc/IsarRef/Document_Preparation.thy
author wenzelm
Mon Dec 09 20:16:12 2013 +0100 (2013-12-09)
changeset 54705 0dff3326d12a
parent 54702 3daeba5130f0
child 55029 61a6bf7d4b02
permissions -rw-r--r--
provide @{file_unchecked} in Isabelle/Pure;
wenzelm@27043
     1
theory Document_Preparation
wenzelm@42651
     2
imports Base Main
wenzelm@27043
     3
begin
wenzelm@27043
     4
wenzelm@27043
     5
chapter {* Document preparation \label{ch:document-prep} *}
wenzelm@27043
     6
wenzelm@28746
     7
text {* Isabelle/Isar provides a simple document preparation system
wenzelm@54346
     8
  based on {PDF-\LaTeX}, with support for hyperlinks and bookmarks
wenzelm@54346
     9
  within that format.  This allows to produce papers, books, theses
wenzelm@54346
    10
  etc.\ from Isabelle theory sources.
wenzelm@27043
    11
wenzelm@51057
    12
  {\LaTeX} output is generated while processing a \emph{session} in
wenzelm@51057
    13
  batch mode, as explained in the \emph{The Isabelle System Manual}
wenzelm@51057
    14
  \cite{isabelle-sys}.  The main Isabelle tools to get started with
wenzelm@54346
    15
  document preparation are @{tool_ref mkroot} and @{tool_ref build}.
wenzelm@27043
    16
wenzelm@54346
    17
  The classic Isabelle/HOL tutorial \cite{isabelle-hol-book} also
wenzelm@54346
    18
  explains some aspects of theory presentation.  *}
wenzelm@27043
    19
wenzelm@27043
    20
wenzelm@27043
    21
section {* Markup commands \label{sec:markup} *}
wenzelm@27043
    22
wenzelm@27043
    23
text {*
wenzelm@27043
    24
  \begin{matharray}{rcl}
wenzelm@28761
    25
    @{command_def "header"} & : & @{text "toplevel \<rightarrow> toplevel"} \\[0.5ex]
wenzelm@28761
    26
    @{command_def "chapter"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
wenzelm@28761
    27
    @{command_def "section"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
wenzelm@28761
    28
    @{command_def "subsection"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
wenzelm@28761
    29
    @{command_def "subsubsection"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
wenzelm@28761
    30
    @{command_def "text"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
wenzelm@28761
    31
    @{command_def "text_raw"} & : & @{text "local_theory \<rightarrow> local_theory"} \\[0.5ex]
wenzelm@28761
    32
    @{command_def "sect"} & : & @{text "proof \<rightarrow> proof"} \\
wenzelm@28761
    33
    @{command_def "subsect"} & : & @{text "proof \<rightarrow> proof"} \\
wenzelm@28761
    34
    @{command_def "subsubsect"} & : & @{text "proof \<rightarrow> proof"} \\
wenzelm@28761
    35
    @{command_def "txt"} & : & @{text "proof \<rightarrow> proof"} \\
wenzelm@28761
    36
    @{command_def "txt_raw"} & : & @{text "proof \<rightarrow> proof"} \\
wenzelm@27043
    37
  \end{matharray}
wenzelm@27043
    38
wenzelm@28747
    39
  Markup commands provide a structured way to insert text into the
wenzelm@28747
    40
  document generated from a theory.  Each markup command takes a
wenzelm@28747
    41
  single @{syntax text} argument, which is passed as argument to a
wenzelm@28747
    42
  corresponding {\LaTeX} macro.  The default macros provided by
wenzelm@40800
    43
  @{file "~~/lib/texinputs/isabelle.sty"} can be redefined according
wenzelm@28747
    44
  to the needs of the underlying document and {\LaTeX} styles.
wenzelm@28747
    45
wenzelm@28747
    46
  Note that formal comments (\secref{sec:comments}) are similar to
wenzelm@28747
    47
  markup commands, but have a different status within Isabelle/Isar
wenzelm@28747
    48
  syntax.
wenzelm@27043
    49
wenzelm@42596
    50
  @{rail "
wenzelm@42596
    51
    (@@{command chapter} | @@{command section} | @@{command subsection} |
wenzelm@42596
    52
      @@{command subsubsection} | @@{command text}) @{syntax target}? @{syntax text}
wenzelm@27043
    53
    ;
wenzelm@42596
    54
    (@@{command header} | @@{command text_raw} | @@{command sect} | @@{command subsect} |
wenzelm@42596
    55
      @@{command subsubsect} | @@{command txt} | @@{command txt_raw}) @{syntax text}
wenzelm@42596
    56
  "}
wenzelm@27043
    57
wenzelm@28760
    58
  \begin{description}
wenzelm@27043
    59
wenzelm@28760
    60
  \item @{command header} provides plain text markup just preceding
wenzelm@28747
    61
  the formal beginning of a theory.  The corresponding {\LaTeX} macro
wenzelm@28747
    62
  is @{verbatim "\\isamarkupheader"}, which acts like @{command
wenzelm@28747
    63
  section} by default.
wenzelm@27049
    64
  
wenzelm@28760
    65
  \item @{command chapter}, @{command section}, @{command subsection},
wenzelm@28760
    66
  and @{command subsubsection} mark chapter and section headings
wenzelm@28760
    67
  within the main theory body or local theory targets.  The
wenzelm@28747
    68
  corresponding {\LaTeX} macros are @{verbatim "\\isamarkupchapter"},
wenzelm@28749
    69
  @{verbatim "\\isamarkupsection"}, @{verbatim
wenzelm@28749
    70
  "\\isamarkupsubsection"} etc.
wenzelm@28747
    71
wenzelm@28760
    72
  \item @{command sect}, @{command subsect}, and @{command subsubsect}
wenzelm@28760
    73
  mark section headings within proofs.  The corresponding {\LaTeX}
wenzelm@28760
    74
  macros are @{verbatim "\\isamarkupsect"}, @{verbatim
wenzelm@28749
    75
  "\\isamarkupsubsect"} etc.
wenzelm@27043
    76
wenzelm@28760
    77
  \item @{command text} and @{command txt} specify paragraphs of plain
wenzelm@28760
    78
  text.  This corresponds to a {\LaTeX} environment @{verbatim
wenzelm@28747
    79
  "\\begin{isamarkuptext}"} @{text "\<dots>"} @{verbatim
wenzelm@28747
    80
  "\\end{isamarkuptext}"} etc.
wenzelm@27043
    81
wenzelm@28760
    82
  \item @{command text_raw} and @{command txt_raw} insert {\LaTeX}
wenzelm@28747
    83
  source into the output, without additional markup.  Thus the full
wenzelm@28747
    84
  range of document manipulations becomes available, at the risk of
wenzelm@28747
    85
  messing up document output.
wenzelm@27043
    86
wenzelm@28760
    87
  \end{description}
wenzelm@27043
    88
wenzelm@28747
    89
  Except for @{command "text_raw"} and @{command "txt_raw"}, the text
wenzelm@28747
    90
  passed to any of the above markup commands may refer to formal
wenzelm@28749
    91
  entities via \emph{document antiquotations}, see also
wenzelm@28749
    92
  \secref{sec:antiq}.  These are interpreted in the present theory or
wenzelm@28749
    93
  proof context, or the named @{text "target"}.
wenzelm@27043
    94
wenzelm@27043
    95
  \medskip The proof markup commands closely resemble those for theory
wenzelm@27043
    96
  specifications, but have a different formal status and produce
wenzelm@28749
    97
  different {\LaTeX} macros.  The default definitions coincide for
wenzelm@28749
    98
  analogous commands such as @{command section} and @{command sect}.
wenzelm@27043
    99
*}
wenzelm@27043
   100
wenzelm@27043
   101
wenzelm@28749
   102
section {* Document Antiquotations \label{sec:antiq} *}
wenzelm@27043
   103
wenzelm@27043
   104
text {*
wenzelm@27043
   105
  \begin{matharray}{rcl}
wenzelm@28761
   106
    @{antiquotation_def "theory"} & : & @{text antiquotation} \\
wenzelm@28761
   107
    @{antiquotation_def "thm"} & : & @{text antiquotation} \\
wenzelm@28761
   108
    @{antiquotation_def "lemma"} & : & @{text antiquotation} \\
wenzelm@28761
   109
    @{antiquotation_def "prop"} & : & @{text antiquotation} \\
wenzelm@28761
   110
    @{antiquotation_def "term"} & : & @{text antiquotation} \\
haftmann@32898
   111
    @{antiquotation_def term_type} & : & @{text antiquotation} \\
haftmann@32898
   112
    @{antiquotation_def typeof} & : & @{text antiquotation} \\
wenzelm@28761
   113
    @{antiquotation_def const} & : & @{text antiquotation} \\
wenzelm@28761
   114
    @{antiquotation_def abbrev} & : & @{text antiquotation} \\
wenzelm@28761
   115
    @{antiquotation_def typ} & : & @{text antiquotation} \\
haftmann@39305
   116
    @{antiquotation_def type} & : & @{text antiquotation} \\
haftmann@39305
   117
    @{antiquotation_def class} & : & @{text antiquotation} \\
wenzelm@28761
   118
    @{antiquotation_def "text"} & : & @{text antiquotation} \\
wenzelm@28761
   119
    @{antiquotation_def goals} & : & @{text antiquotation} \\
wenzelm@28761
   120
    @{antiquotation_def subgoals} & : & @{text antiquotation} \\
wenzelm@28761
   121
    @{antiquotation_def prf} & : & @{text antiquotation} \\
wenzelm@28761
   122
    @{antiquotation_def full_prf} & : & @{text antiquotation} \\
wenzelm@28761
   123
    @{antiquotation_def ML} & : & @{text antiquotation} \\
wenzelm@46261
   124
    @{antiquotation_def ML_op} & : & @{text antiquotation} \\
wenzelm@28761
   125
    @{antiquotation_def ML_type} & : & @{text antiquotation} \\
wenzelm@28761
   126
    @{antiquotation_def ML_struct} & : & @{text antiquotation} \\
wenzelm@40801
   127
    @{antiquotation_def "file"} & : & @{text antiquotation} \\
wenzelm@54702
   128
    @{antiquotation_def "url"} & : & @{text antiquotation} \\
wenzelm@27043
   129
  \end{matharray}
wenzelm@27043
   130
wenzelm@28749
   131
  The overall content of an Isabelle/Isar theory may alternate between
wenzelm@28749
   132
  formal and informal text.  The main body consists of formal
wenzelm@28749
   133
  specification and proof commands, interspersed with markup commands
wenzelm@28749
   134
  (\secref{sec:markup}) or document comments (\secref{sec:comments}).
wenzelm@28749
   135
  The argument of markup commands quotes informal text to be printed
wenzelm@28749
   136
  in the resulting document, but may again refer to formal entities
wenzelm@28749
   137
  via \emph{document antiquotations}.
wenzelm@27043
   138
wenzelm@28749
   139
  For example, embedding of ``@{text [source=false] "@{term [show_types] \"f x = a + x\"}"}''
wenzelm@28749
   140
  within a text block makes
wenzelm@28749
   141
  \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} appear in the final {\LaTeX} document.
wenzelm@28749
   142
wenzelm@28749
   143
  Antiquotations usually spare the author tedious typing of logical
wenzelm@28749
   144
  entities in full detail.  Even more importantly, some degree of
wenzelm@28749
   145
  consistency-checking between the main body of formal text and its
wenzelm@28749
   146
  informal explanation is achieved, since terms and types appearing in
wenzelm@28749
   147
  antiquotations are checked within the current theory or proof
wenzelm@28749
   148
  context.
wenzelm@27043
   149
wenzelm@43618
   150
  %% FIXME less monolithic presentation, move to individual sections!?
wenzelm@42596
   151
  @{rail "
wenzelm@42596
   152
    '@{' antiquotation '}'
wenzelm@27043
   153
    ;
wenzelm@42596
   154
    @{syntax_def antiquotation}:
wenzelm@42596
   155
      @@{antiquotation theory} options @{syntax name} |
wenzelm@42596
   156
      @@{antiquotation thm} options styles @{syntax thmrefs} |
wenzelm@42617
   157
      @@{antiquotation lemma} options @{syntax prop} @'by' @{syntax method} @{syntax method}? |
wenzelm@42596
   158
      @@{antiquotation prop} options styles @{syntax prop} |
wenzelm@42596
   159
      @@{antiquotation term} options styles @{syntax term} |
wenzelm@43618
   160
      @@{antiquotation (HOL) value} options styles @{syntax term} |
wenzelm@42596
   161
      @@{antiquotation term_type} options styles @{syntax term} |
wenzelm@42596
   162
      @@{antiquotation typeof} options styles @{syntax term} |
wenzelm@42596
   163
      @@{antiquotation const} options @{syntax term} |
wenzelm@42596
   164
      @@{antiquotation abbrev} options @{syntax term} |
wenzelm@42596
   165
      @@{antiquotation typ} options @{syntax type} |
wenzelm@42596
   166
      @@{antiquotation type} options @{syntax name} |
wenzelm@42596
   167
      @@{antiquotation class} options @{syntax name} |
wenzelm@46261
   168
      @@{antiquotation text} options @{syntax name}
wenzelm@46261
   169
    ;
wenzelm@46261
   170
    @{syntax antiquotation}:
wenzelm@42596
   171
      @@{antiquotation goals} options |
wenzelm@42596
   172
      @@{antiquotation subgoals} options |
wenzelm@42596
   173
      @@{antiquotation prf} options @{syntax thmrefs} |
wenzelm@42596
   174
      @@{antiquotation full_prf} options @{syntax thmrefs} |
wenzelm@42596
   175
      @@{antiquotation ML} options @{syntax name} |
wenzelm@46261
   176
      @@{antiquotation ML_op} options @{syntax name} |
wenzelm@42596
   177
      @@{antiquotation ML_type} options @{syntax name} |
wenzelm@42596
   178
      @@{antiquotation ML_struct} options @{syntax name} |
wenzelm@54702
   179
      @@{antiquotation \"file\"} options @{syntax name} |
wenzelm@54705
   180
      @@{antiquotation file_unchecked} options @{syntax name} |
wenzelm@54702
   181
      @@{antiquotation url} options @{syntax name}
wenzelm@27043
   182
    ;
wenzelm@27043
   183
    options: '[' (option * ',') ']'
wenzelm@27043
   184
    ;
wenzelm@42596
   185
    option: @{syntax name} | @{syntax name} '=' @{syntax name}
wenzelm@27043
   186
    ;
haftmann@32892
   187
    styles: '(' (style + ',') ')'
haftmann@32891
   188
    ;
wenzelm@42596
   189
    style: (@{syntax name} +)
wenzelm@42617
   190
  "}
wenzelm@27043
   191
wenzelm@27043
   192
  Note that the syntax of antiquotations may \emph{not} include source
wenzelm@28749
   193
  comments @{verbatim "(*"}~@{text "\<dots>"}~@{verbatim "*)"} nor verbatim
wenzelm@27043
   194
  text @{verbatim "{"}@{verbatim "*"}~@{text "\<dots>"}~@{verbatim
wenzelm@27043
   195
  "*"}@{verbatim "}"}.
wenzelm@27043
   196
wenzelm@28760
   197
  \begin{description}
wenzelm@27043
   198
  
wenzelm@28760
   199
  \item @{text "@{theory A}"} prints the name @{text "A"}, which is
wenzelm@27043
   200
  guaranteed to refer to a valid ancestor theory in the current
wenzelm@27043
   201
  context.
wenzelm@27043
   202
wenzelm@28760
   203
  \item @{text "@{thm a\<^sub>1 \<dots> a\<^sub>n}"} prints theorems @{text "a\<^sub>1 \<dots> a\<^sub>n"}.
wenzelm@28749
   204
  Full fact expressions are allowed here, including attributes
wenzelm@28749
   205
  (\secref{sec:syn-att}).
wenzelm@27043
   206
wenzelm@28760
   207
  \item @{text "@{prop \<phi>}"} prints a well-typed proposition @{text
wenzelm@27043
   208
  "\<phi>"}.
wenzelm@27043
   209
wenzelm@28760
   210
  \item @{text "@{lemma \<phi> by m}"} proves a well-typed proposition
wenzelm@28749
   211
  @{text "\<phi>"} by method @{text m} and prints the original @{text "\<phi>"}.
haftmann@27453
   212
wenzelm@28760
   213
  \item @{text "@{term t}"} prints a well-typed term @{text "t"}.
bulwahn@43613
   214
  
wenzelm@43618
   215
  \item @{text "@{value t}"} evaluates a term @{text "t"} and prints
wenzelm@43618
   216
  its result, see also @{command_ref (HOL) value}.
wenzelm@27043
   217
haftmann@32898
   218
  \item @{text "@{term_type t}"} prints a well-typed term @{text "t"}
haftmann@32898
   219
  annotated with its type.
haftmann@32898
   220
haftmann@32898
   221
  \item @{text "@{typeof t}"} prints the type of a well-typed term
haftmann@32898
   222
  @{text "t"}.
haftmann@32898
   223
wenzelm@28760
   224
  \item @{text "@{const c}"} prints a logical or syntactic constant
wenzelm@27043
   225
  @{text "c"}.
wenzelm@27043
   226
  
wenzelm@28760
   227
  \item @{text "@{abbrev c x\<^sub>1 \<dots> x\<^sub>n}"} prints a constant abbreviation
wenzelm@28760
   228
  @{text "c x\<^sub>1 \<dots> x\<^sub>n \<equiv> rhs"} as defined in the current context.
haftmann@39305
   229
wenzelm@28760
   230
  \item @{text "@{typ \<tau>}"} prints a well-formed type @{text "\<tau>"}.
haftmann@39305
   231
wenzelm@39689
   232
  \item @{text "@{type \<kappa>}"} prints a (logical or syntactic) type
wenzelm@39689
   233
    constructor @{text "\<kappa>"}.
haftmann@39305
   234
haftmann@39305
   235
  \item @{text "@{class c}"} prints a class @{text c}.
haftmann@39305
   236
wenzelm@28760
   237
  \item @{text "@{text s}"} prints uninterpreted source text @{text
wenzelm@27043
   238
  s}.  This is particularly useful to print portions of text according
wenzelm@28749
   239
  to the Isabelle document style, without demanding well-formedness,
wenzelm@28749
   240
  e.g.\ small pieces of terms that should not be parsed or
wenzelm@28749
   241
  type-checked yet.
wenzelm@27043
   242
wenzelm@28760
   243
  \item @{text "@{goals}"} prints the current \emph{dynamic} goal
wenzelm@27043
   244
  state.  This is mainly for support of tactic-emulation scripts
wenzelm@28749
   245
  within Isar.  Presentation of goal states does not conform to the
wenzelm@28749
   246
  idea of human-readable proof documents!
wenzelm@27043
   247
wenzelm@28749
   248
  When explaining proofs in detail it is usually better to spell out
wenzelm@28749
   249
  the reasoning via proper Isar proof commands, instead of peeking at
wenzelm@28749
   250
  the internal machine configuration.
wenzelm@27043
   251
  
wenzelm@28760
   252
  \item @{text "@{subgoals}"} is similar to @{text "@{goals}"}, but
wenzelm@27043
   253
  does not print the main goal.
wenzelm@27043
   254
  
wenzelm@28760
   255
  \item @{text "@{prf a\<^sub>1 \<dots> a\<^sub>n}"} prints the (compact) proof terms
wenzelm@28749
   256
  corresponding to the theorems @{text "a\<^sub>1 \<dots> a\<^sub>n"}. Note that this
wenzelm@28749
   257
  requires proof terms to be switched on for the current logic
wenzelm@28749
   258
  session.
wenzelm@27043
   259
  
wenzelm@28760
   260
  \item @{text "@{full_prf a\<^sub>1 \<dots> a\<^sub>n}"} is like @{text "@{prf a\<^sub>1 \<dots>
wenzelm@28760
   261
  a\<^sub>n}"}, but prints the full proof terms, i.e.\ also displays
wenzelm@28760
   262
  information omitted in the compact proof term, which is denoted by
wenzelm@28760
   263
  ``@{text _}'' placeholders there.
wenzelm@27043
   264
  
wenzelm@46261
   265
  \item @{text "@{ML s}"}, @{text "@{ML_op s}"}, @{text "@{ML_type
wenzelm@46261
   266
  s}"}, and @{text "@{ML_struct s}"} check text @{text s} as ML value,
wenzelm@46261
   267
  infix operator, type, and structure, respectively.  The source is
wenzelm@46261
   268
  printed verbatim.
wenzelm@27043
   269
wenzelm@40801
   270
  \item @{text "@{file path}"} checks that @{text "path"} refers to a
wenzelm@40801
   271
  file (or directory) and prints it verbatim.
wenzelm@40801
   272
wenzelm@54705
   273
  \item @{text "@{file_unchecked path}"} is like @{text "@{file
wenzelm@54705
   274
  path}"}, but does not check the existence of the @{text "path"}
wenzelm@54705
   275
  within the file-system.
wenzelm@54705
   276
wenzelm@54702
   277
  \item @{text "@{url name}"} produces markup for the given URL, which
wenzelm@54702
   278
  results in an active hyperlink within the text.
wenzelm@54702
   279
wenzelm@28760
   280
  \end{description}
wenzelm@28749
   281
*}
wenzelm@27043
   282
wenzelm@28749
   283
wenzelm@42936
   284
subsection {* Styled antiquotations *}
wenzelm@28749
   285
haftmann@32891
   286
text {* The antiquotations @{text thm}, @{text prop} and @{text
haftmann@32891
   287
  term} admit an extra \emph{style} specification to modify the
haftmann@32891
   288
  printed result.  A style is specified by a name with a possibly
haftmann@32891
   289
  empty number of arguments;  multiple styles can be sequenced with
haftmann@32891
   290
  commas.  The following standard styles are available:
wenzelm@27043
   291
wenzelm@28760
   292
  \begin{description}
wenzelm@27043
   293
  
wenzelm@28760
   294
  \item @{text lhs} extracts the first argument of any application
wenzelm@28749
   295
  form with at least two arguments --- typically meta-level or
wenzelm@27043
   296
  object-level equality, or any other binary relation.
wenzelm@27043
   297
  
wenzelm@28760
   298
  \item @{text rhs} is like @{text lhs}, but extracts the second
wenzelm@27043
   299
  argument.
wenzelm@27043
   300
  
wenzelm@28760
   301
  \item @{text "concl"} extracts the conclusion @{text C} from a rule
wenzelm@27043
   302
  in Horn-clause normal form @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C"}.
wenzelm@27043
   303
  
haftmann@32891
   304
  \item @{text "prem"} @{text n} extract premise number
haftmann@32891
   305
  @{text "n"} from from a rule in Horn-clause
wenzelm@28760
   306
  normal form @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C"}
wenzelm@27043
   307
wenzelm@28760
   308
  \end{description}
wenzelm@28749
   309
*}
wenzelm@27043
   310
wenzelm@28749
   311
wenzelm@42936
   312
subsection {* General options *}
wenzelm@28749
   313
wenzelm@28749
   314
text {* The following options are available to tune the printed output
wenzelm@54346
   315
  of antiquotations.  Note that many of these coincide with system and
wenzelm@54346
   316
  configuration options of the same names.
wenzelm@27043
   317
wenzelm@28760
   318
  \begin{description}
wenzelm@27043
   319
wenzelm@30397
   320
  \item @{antiquotation_option_def show_types}~@{text "= bool"} and
wenzelm@30397
   321
  @{antiquotation_option_def show_sorts}~@{text "= bool"} control
wenzelm@30397
   322
  printing of explicit type and sort constraints.
wenzelm@27043
   323
wenzelm@30397
   324
  \item @{antiquotation_option_def show_structs}~@{text "= bool"}
wenzelm@30397
   325
  controls printing of implicit structures.
wenzelm@27043
   326
wenzelm@40879
   327
  \item @{antiquotation_option_def show_abbrevs}~@{text "= bool"}
wenzelm@40879
   328
  controls folding of abbreviations.
wenzelm@40879
   329
wenzelm@42669
   330
  \item @{antiquotation_option_def names_long}~@{text "= bool"} forces
wenzelm@30397
   331
  names of types and constants etc.\ to be printed in their fully
wenzelm@30397
   332
  qualified internal form.
wenzelm@27043
   333
wenzelm@42669
   334
  \item @{antiquotation_option_def names_short}~@{text "= bool"}
wenzelm@30397
   335
  forces names of types and constants etc.\ to be printed unqualified.
wenzelm@30397
   336
  Note that internalizing the output again in the current context may
wenzelm@30397
   337
  well yield a different result.
wenzelm@27043
   338
wenzelm@42669
   339
  \item @{antiquotation_option_def names_unique}~@{text "= bool"}
wenzelm@30397
   340
  determines whether the printed version of qualified names should be
wenzelm@30397
   341
  made sufficiently long to avoid overlap with names declared further
wenzelm@30397
   342
  back.  Set to @{text false} for more concise output.
wenzelm@27043
   343
wenzelm@30397
   344
  \item @{antiquotation_option_def eta_contract}~@{text "= bool"}
wenzelm@30397
   345
  prints terms in @{text \<eta>}-contracted form.
wenzelm@27043
   346
wenzelm@30397
   347
  \item @{antiquotation_option_def display}~@{text "= bool"} indicates
wenzelm@30397
   348
  if the text is to be output as multi-line ``display material'',
wenzelm@30397
   349
  rather than a small piece of text without line breaks (which is the
wenzelm@30397
   350
  default).
wenzelm@27043
   351
wenzelm@28749
   352
  In this mode the embedded entities are printed in the same style as
wenzelm@28749
   353
  the main theory text.
wenzelm@28749
   354
wenzelm@30397
   355
  \item @{antiquotation_option_def break}~@{text "= bool"} controls
wenzelm@30397
   356
  line breaks in non-display material.
wenzelm@27043
   357
wenzelm@30397
   358
  \item @{antiquotation_option_def quotes}~@{text "= bool"} indicates
wenzelm@30397
   359
  if the output should be enclosed in double quotes.
wenzelm@27043
   360
wenzelm@30397
   361
  \item @{antiquotation_option_def mode}~@{text "= name"} adds @{text
wenzelm@30397
   362
  name} to the print mode to be used for presentation.  Note that the
wenzelm@30397
   363
  standard setup for {\LaTeX} output is already present by default,
wenzelm@30397
   364
  including the modes @{text latex} and @{text xsymbols}.
wenzelm@27043
   365
wenzelm@30397
   366
  \item @{antiquotation_option_def margin}~@{text "= nat"} and
wenzelm@30397
   367
  @{antiquotation_option_def indent}~@{text "= nat"} change the margin
wenzelm@30397
   368
  or indentation for pretty printing of display material.
wenzelm@27043
   369
wenzelm@30397
   370
  \item @{antiquotation_option_def goals_limit}~@{text "= nat"}
wenzelm@51960
   371
  determines the maximum number of subgoals to be printed (for goal-based
wenzelm@30397
   372
  antiquotation).
wenzelm@27043
   373
wenzelm@30397
   374
  \item @{antiquotation_option_def source}~@{text "= bool"} prints the
wenzelm@30397
   375
  original source text of the antiquotation arguments, rather than its
wenzelm@30397
   376
  internal representation.  Note that formal checking of
wenzelm@30397
   377
  @{antiquotation "thm"}, @{antiquotation "term"}, etc. is still
wenzelm@30397
   378
  enabled; use the @{antiquotation "text"} antiquotation for unchecked
wenzelm@30397
   379
  output.
wenzelm@28749
   380
wenzelm@28749
   381
  Regular @{text "term"} and @{text "typ"} antiquotations with @{text
wenzelm@28749
   382
  "source = false"} involve a full round-trip from the original source
wenzelm@28749
   383
  to an internalized logical entity back to a source form, according
wenzelm@28749
   384
  to the syntax of the current context.  Thus the printed output is
wenzelm@28749
   385
  not under direct control of the author, it may even fluctuate a bit
wenzelm@28749
   386
  as the underlying theory is changed later on.
wenzelm@28749
   387
wenzelm@42626
   388
  In contrast, @{antiquotation_option source}~@{text "= true"}
wenzelm@30397
   389
  admits direct printing of the given source text, with the desirable
wenzelm@30397
   390
  well-formedness check in the background, but without modification of
wenzelm@30397
   391
  the printed text.
wenzelm@28749
   392
wenzelm@28760
   393
  \end{description}
wenzelm@27043
   394
wenzelm@27043
   395
  For boolean flags, ``@{text "name = true"}'' may be abbreviated as
wenzelm@27043
   396
  ``@{text name}''.  All of the above flags are disabled by default,
wenzelm@51057
   397
  unless changed specifically for a logic session in the corresponding
wenzelm@51057
   398
  @{verbatim "ROOT"} file.  *}
wenzelm@27043
   399
wenzelm@27043
   400
wenzelm@28750
   401
section {* Markup via command tags \label{sec:tags} *}
wenzelm@27043
   402
wenzelm@28750
   403
text {* Each Isabelle/Isar command may be decorated by additional
wenzelm@28750
   404
  presentation tags, to indicate some modification in the way it is
wenzelm@28750
   405
  printed in the document.
wenzelm@27043
   406
wenzelm@42596
   407
  @{rail "
wenzelm@42596
   408
    @{syntax_def tags}: ( tag * )
wenzelm@27043
   409
    ;
wenzelm@42596
   410
    tag: '%' (@{syntax ident} | @{syntax string})
wenzelm@42596
   411
  "}
wenzelm@27043
   412
wenzelm@28750
   413
  Some tags are pre-declared for certain classes of commands, serving
wenzelm@28750
   414
  as default markup if no tags are given in the text:
wenzelm@27043
   415
wenzelm@28750
   416
  \medskip
wenzelm@27043
   417
  \begin{tabular}{ll}
wenzelm@27043
   418
    @{text "theory"} & theory begin/end \\
wenzelm@27043
   419
    @{text "proof"} & all proof commands \\
wenzelm@27043
   420
    @{text "ML"} & all commands involving ML code \\
wenzelm@27043
   421
  \end{tabular}
wenzelm@27043
   422
wenzelm@28750
   423
  \medskip The Isabelle document preparation system
wenzelm@28750
   424
  \cite{isabelle-sys} allows tagged command regions to be presented
wenzelm@27043
   425
  specifically, e.g.\ to fold proof texts, or drop parts of the text
wenzelm@27043
   426
  completely.
wenzelm@27043
   427
wenzelm@28750
   428
  For example ``@{command "by"}~@{text "%invisible auto"}'' causes
wenzelm@28750
   429
  that piece of proof to be treated as @{text invisible} instead of
wenzelm@28750
   430
  @{text "proof"} (the default), which may be shown or hidden
wenzelm@27043
   431
  depending on the document setup.  In contrast, ``@{command
wenzelm@28750
   432
  "by"}~@{text "%visible auto"}'' forces this text to be shown
wenzelm@27043
   433
  invariably.
wenzelm@27043
   434
wenzelm@27043
   435
  Explicit tag specifications within a proof apply to all subsequent
wenzelm@27043
   436
  commands of the same level of nesting.  For example, ``@{command
wenzelm@28750
   437
  "proof"}~@{text "%visible \<dots>"}~@{command "qed"}'' forces the whole
wenzelm@28750
   438
  sub-proof to be typeset as @{text visible} (unless some of its parts
wenzelm@28750
   439
  are tagged differently).
wenzelm@28750
   440
wenzelm@28750
   441
  \medskip Command tags merely produce certain markup environments for
wenzelm@28750
   442
  type-setting.  The meaning of these is determined by {\LaTeX}
wenzelm@40800
   443
  macros, as defined in @{file "~~/lib/texinputs/isabelle.sty"} or
wenzelm@28750
   444
  by the document author.  The Isabelle document preparation tools
wenzelm@28750
   445
  also provide some high-level options to specify the meaning of
wenzelm@28750
   446
  arbitrary tags to ``keep'', ``drop'', or ``fold'' the corresponding
wenzelm@28750
   447
  parts of the text.  Logic sessions may also specify ``document
wenzelm@28750
   448
  versions'', where given tags are interpreted in some particular way.
wenzelm@28750
   449
  Again see \cite{isabelle-sys} for further details.
wenzelm@27043
   450
*}
wenzelm@27043
   451
wenzelm@27043
   452
wenzelm@42658
   453
section {* Railroad diagrams *}
wenzelm@42658
   454
wenzelm@42658
   455
text {*
wenzelm@42658
   456
  \begin{matharray}{rcl}
wenzelm@42658
   457
    @{antiquotation_def "rail"} & : & @{text antiquotation} \\
wenzelm@42658
   458
  \end{matharray}
wenzelm@42658
   459
wenzelm@42658
   460
  @{rail "'rail' string"}
wenzelm@42658
   461
wenzelm@42658
   462
  The @{antiquotation rail} antiquotation allows to include syntax
wenzelm@42658
   463
  diagrams into Isabelle documents.  {\LaTeX} requires the style file
wenzelm@53982
   464
  @{file "~~/lib/texinputs/pdfsetup.sty"}, which can be used via
wenzelm@42658
   465
  @{verbatim "\\usepackage{pdfsetup}"} in @{verbatim "root.tex"}, for
wenzelm@42658
   466
  example.
wenzelm@42658
   467
wenzelm@42658
   468
  The rail specification language is quoted here as Isabelle @{syntax
wenzelm@42658
   469
  string}; it has its own grammar given below.
wenzelm@42658
   470
wenzelm@42658
   471
  @{rail "
wenzelm@42658
   472
  rule? + ';'
wenzelm@42658
   473
  ;
wenzelm@42658
   474
  rule: ((identifier | @{syntax antiquotation}) ':')? body
wenzelm@42658
   475
  ;
wenzelm@42658
   476
  body: concatenation + '|'
wenzelm@42658
   477
  ;
wenzelm@42658
   478
  concatenation: ((atom '?'?) +) (('*' | '+') atom?)?
wenzelm@42658
   479
  ;
wenzelm@42658
   480
  atom: '(' body? ')' | identifier |
wenzelm@42658
   481
    '@'? (string | @{syntax antiquotation}) |
wenzelm@42658
   482
    '\\\\\\\\'
wenzelm@42658
   483
  "}
wenzelm@42658
   484
wenzelm@42658
   485
  The lexical syntax of @{text "identifier"} coincides with that of
wenzelm@42658
   486
  @{syntax ident} in regular Isabelle syntax, but @{text string} uses
wenzelm@42658
   487
  single quotes instead of double quotes of the standard @{syntax
wenzelm@42658
   488
  string} category, to avoid extra escapes.
wenzelm@42658
   489
wenzelm@42658
   490
  Each @{text rule} defines a formal language (with optional name),
wenzelm@42658
   491
  using a notation that is similar to EBNF or regular expressions with
wenzelm@42658
   492
  recursion.  The meaning and visual appearance of these rail language
wenzelm@42658
   493
  elements is illustrated by the following representative examples.
wenzelm@42658
   494
wenzelm@42658
   495
  \begin{itemize}
wenzelm@42658
   496
wenzelm@42658
   497
  \item Empty @{verbatim "()"}
wenzelm@42658
   498
wenzelm@42658
   499
  @{rail "()"}
wenzelm@42658
   500
wenzelm@42658
   501
  \item Nonterminal @{verbatim "A"}
wenzelm@42658
   502
wenzelm@42658
   503
  @{rail "A"}
wenzelm@42658
   504
wenzelm@42658
   505
  \item Nonterminal via Isabelle antiquotation
wenzelm@42658
   506
  @{verbatim "@{syntax method}"}
wenzelm@42658
   507
wenzelm@42658
   508
  @{rail "@{syntax method}"}
wenzelm@42658
   509
wenzelm@42658
   510
  \item Terminal @{verbatim "'xyz'"}
wenzelm@42658
   511
wenzelm@42658
   512
  @{rail "'xyz'"}
wenzelm@42658
   513
wenzelm@42658
   514
  \item Terminal in keyword style @{verbatim "@'xyz'"}
wenzelm@42658
   515
wenzelm@42658
   516
  @{rail "@'xyz'"}
wenzelm@42658
   517
wenzelm@42658
   518
  \item Terminal via Isabelle antiquotation
wenzelm@42658
   519
  @{verbatim "@@{method rule}"}
wenzelm@42658
   520
wenzelm@42658
   521
  @{rail "@@{method rule}"}
wenzelm@42658
   522
wenzelm@42658
   523
  \item Concatenation @{verbatim "A B C"}
wenzelm@42658
   524
wenzelm@42658
   525
  @{rail "A B C"}
wenzelm@42658
   526
wenzelm@42658
   527
  \item Linebreak @{verbatim "\\\\"} inside
wenzelm@42658
   528
  concatenation\footnote{Strictly speaking, this is only a single
wenzelm@42658
   529
  backslash, but the enclosing @{syntax string} syntax requires a
wenzelm@42658
   530
  second one for escaping.} @{verbatim "A B C \\\\ D E F"}
wenzelm@42658
   531
wenzelm@42658
   532
  @{rail "A B C \\ D E F"}
wenzelm@42658
   533
wenzelm@42658
   534
  \item Variants @{verbatim "A | B | C"}
wenzelm@42658
   535
wenzelm@42658
   536
  @{rail "A | B | C"}
wenzelm@42658
   537
wenzelm@42658
   538
  \item Option @{verbatim "A ?"}
wenzelm@42658
   539
wenzelm@42658
   540
  @{rail "A ?"}
wenzelm@42658
   541
wenzelm@42658
   542
  \item Repetition @{verbatim "A *"}
wenzelm@42658
   543
wenzelm@42658
   544
  @{rail "A *"}
wenzelm@42658
   545
wenzelm@42658
   546
  \item Repetition with separator @{verbatim "A * sep"}
wenzelm@42658
   547
wenzelm@42658
   548
  @{rail "A * sep"}
wenzelm@42658
   549
wenzelm@42658
   550
  \item Strict repetition @{verbatim "A +"}
wenzelm@42658
   551
wenzelm@42658
   552
  @{rail "A +"}
wenzelm@42658
   553
wenzelm@42658
   554
  \item Strict repetition with separator @{verbatim "A + sep"}
wenzelm@42658
   555
wenzelm@42658
   556
  @{rail "A + sep"}
wenzelm@42658
   557
wenzelm@42658
   558
  \end{itemize}
wenzelm@42658
   559
*}
wenzelm@42658
   560
wenzelm@42658
   561
wenzelm@27043
   562
section {* Draft presentation *}
wenzelm@27043
   563
wenzelm@27043
   564
text {*
wenzelm@27043
   565
  \begin{matharray}{rcl}
wenzelm@28761
   566
    @{command_def "display_drafts"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
wenzelm@27043
   567
  \end{matharray}
wenzelm@27043
   568
wenzelm@42596
   569
  @{rail "
wenzelm@52549
   570
    @@{command display_drafts} (@{syntax name} +)
wenzelm@42596
   571
wenzelm@42596
   572
  "}
wenzelm@27043
   573
wenzelm@28760
   574
  \begin{description}
wenzelm@27043
   575
wenzelm@52549
   576
  \item @{command "display_drafts"}~@{text paths} performs simple output of a
wenzelm@52549
   577
  given list of raw source files. Only those symbols that do not require
wenzelm@52549
   578
  additional {\LaTeX} packages are displayed properly, everything else is left
wenzelm@52549
   579
  verbatim.
wenzelm@27043
   580
wenzelm@28760
   581
  \end{description}
wenzelm@27043
   582
*}
wenzelm@27043
   583
wenzelm@27043
   584
end