src/Doc/Isar_Ref/Document_Preparation.thy
author wenzelm
Fri, 12 Apr 2019 22:57:17 +0200
changeset 70140 d13865c21e36
parent 70122 a0b21b4b7a4a
child 71146 f7a9889068ff
permissions -rw-r--r--
updated documentation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61656
cfabbc083977 more uniform jEdit properties;
wenzelm
parents: 61624
diff changeset
     1
(*:maxLineLen=78:*)
cfabbc083977 more uniform jEdit properties;
wenzelm
parents: 61624
diff changeset
     2
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
     3
theory Document_Preparation
63531
847eefdca90d clarified imports;
wenzelm
parents: 63138
diff changeset
     4
  imports Main Base
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
     5
begin
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
     6
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
     7
chapter \<open>Document preparation \label{ch:document-prep}\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
     8
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
     9
text \<open>
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    10
  Isabelle/Isar provides a simple document preparation system based on
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    11
  {PDF-\LaTeX}, with support for hyperlinks and bookmarks within that format.
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    12
  This allows to produce papers, books, theses etc.\ from Isabelle theory
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    13
  sources.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    14
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    15
  {\LaTeX} output is generated while processing a \<^emph>\<open>session\<close> in batch mode, as
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    16
  explained in the \<^emph>\<open>The Isabelle System Manual\<close> @{cite "isabelle-system"}.
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    17
  The main Isabelle tools to get started with document preparation are
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    18
  @{tool_ref mkroot} and @{tool_ref build}.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    19
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    20
  The classic Isabelle/HOL tutorial @{cite "isabelle-hol-book"} also explains
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    21
  some aspects of theory presentation.
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    22
\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    23
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    24
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
    25
section \<open>Markup commands \label{sec:markup}\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    26
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
    27
text \<open>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    28
  \begin{matharray}{rcl}
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    29
    @{command_def "chapter"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    30
    @{command_def "section"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    31
    @{command_def "subsection"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    32
    @{command_def "subsubsection"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    33
    @{command_def "paragraph"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    34
    @{command_def "subparagraph"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    35
    @{command_def "text"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    36
    @{command_def "txt"} & : & \<open>any \<rightarrow> any\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    37
    @{command_def "text_raw"} & : & \<open>any \<rightarrow> any\<close> \\
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    38
  \end{matharray}
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    39
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    40
  Markup commands provide a structured way to insert text into the document
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    41
  generated from a theory. Each markup command takes a single @{syntax text}
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    42
  argument, which is passed as argument to a corresponding {\LaTeX} macro. The
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 63672
diff changeset
    43
  default macros provided by \<^file>\<open>~~/lib/texinputs/isabelle.sty\<close> can be
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    44
  redefined according to the needs of the underlying document and {\LaTeX}
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    45
  styles.
28747
ec3424dd17bc tuned "Markup commands";
wenzelm
parents: 28746
diff changeset
    46
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    47
  Note that formal comments (\secref{sec:comments}) are similar to markup
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    48
  commands, but have a different status within Isabelle/Isar syntax.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    49
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
    50
  \<^rail>\<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
    51
    (@@{command chapter} | @@{command section} | @@{command subsection} |
62912
745d31e63c21 section headings for ROOT.ML;
wenzelm
parents: 62274
diff changeset
    52
      @@{command subsubsection} | @@{command paragraph} | @@{command subparagraph})
745d31e63c21 section headings for ROOT.ML;
wenzelm
parents: 62274
diff changeset
    53
      @{syntax text} ';'? |
745d31e63c21 section headings for ROOT.ML;
wenzelm
parents: 62274
diff changeset
    54
    (@@{command text} | @@{command txt} | @@{command text_raw}) @{syntax text}
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
    55
  \<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    56
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    57
    \<^descr> @{command chapter}, @{command section}, @{command subsection} etc.\ mark
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    58
    section headings within the theory source. This works in any context, even
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    59
    before the initial @{command theory} command. The corresponding {\LaTeX}
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    60
    macros are \<^verbatim>\<open>\isamarkupchapter\<close>, \<^verbatim>\<open>\isamarkupsection\<close>,
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    61
    \<^verbatim>\<open>\isamarkupsubsection\<close> etc.\
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    62
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    63
    \<^descr> @{command text} and @{command txt} specify paragraphs of plain text.
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    64
    This corresponds to a {\LaTeX} environment \<^verbatim>\<open>\begin{isamarkuptext}\<close> \<open>\<dots>\<close>
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    65
    \<^verbatim>\<open>\end{isamarkuptext}\<close> etc.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    66
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    67
    \<^descr> @{command text_raw} is similar to @{command text}, but without any
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    68
    surrounding markup environment. This allows to inject arbitrary {\LaTeX}
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    69
    source into the generated document.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    70
61463
8e46cea6a45a added 'paragraph', 'subparagraph';
wenzelm
parents: 61458
diff changeset
    71
  All text passed to any of the above markup commands may refer to formal
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    72
  entities via \<^emph>\<open>document antiquotations\<close>, see also \secref{sec:antiq}. These
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    73
  are interpreted in the present theory or proof context.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    74
61421
e0825405d398 more symbols;
wenzelm
parents: 60286
diff changeset
    75
  \<^medskip>
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    76
  The proof markup commands closely resemble those for theory specifications,
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
    77
  but have a different formal status and produce different {\LaTeX} macros.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
    78
\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    79
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    80
60286
wenzelm
parents: 60270
diff changeset
    81
section \<open>Document antiquotations \label{sec:antiq}\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    82
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
    83
text \<open>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
    84
  \begin{matharray}{rcl}
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    85
    @{antiquotation_def "theory"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    86
    @{antiquotation_def "thm"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    87
    @{antiquotation_def "lemma"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    88
    @{antiquotation_def "prop"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    89
    @{antiquotation_def "term"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    90
    @{antiquotation_def term_type} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    91
    @{antiquotation_def typeof} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    92
    @{antiquotation_def const} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    93
    @{antiquotation_def abbrev} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    94
    @{antiquotation_def typ} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    95
    @{antiquotation_def type} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    96
    @{antiquotation_def class} & : & \<open>antiquotation\<close> \\
68809
f6c88cb715db more uniform cartouche syntax;
wenzelm
parents: 68484
diff changeset
    97
    @{antiquotation_def locale} & : & \<open>antiquotation\<close> \\
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    98
    @{antiquotation_def "text"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
    99
    @{antiquotation_def goals} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   100
    @{antiquotation_def subgoals} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   101
    @{antiquotation_def prf} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   102
    @{antiquotation_def full_prf} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   103
    @{antiquotation_def ML} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   104
    @{antiquotation_def ML_op} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   105
    @{antiquotation_def ML_type} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   106
    @{antiquotation_def ML_structure} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   107
    @{antiquotation_def ML_functor} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   108
    @{antiquotation_def emph} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   109
    @{antiquotation_def bold} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   110
    @{antiquotation_def verbatim} & : & \<open>antiquotation\<close> \\
67219
81e9804b2014 added document antiquotation @{session name};
wenzelm
parents: 67139
diff changeset
   111
    @{antiquotation_def session} & : & \<open>antiquotation\<close> \\
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   112
    @{antiquotation_def "file"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   113
    @{antiquotation_def "url"} & : & \<open>antiquotation\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   114
    @{antiquotation_def "cite"} & : & \<open>antiquotation\<close> \\
61494
63b18f758874 proper spaces around @{text};
wenzelm
parents: 61493
diff changeset
   115
    @{command_def "print_antiquotations"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   116
  \end{matharray}
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   117
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   118
  The overall content of an Isabelle/Isar theory may alternate between formal
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   119
  and informal text. The main body consists of formal specification and proof
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   120
  commands, interspersed with markup commands (\secref{sec:markup}) or
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   121
  document comments (\secref{sec:comments}). The argument of markup commands
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   122
  quotes informal text to be printed in the resulting document, but may again
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   123
  refer to formal entities via \<^emph>\<open>document antiquotations\<close>.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   124
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   125
  For example, embedding \<^verbatim>\<open>@{term [show_types] "f x = a + x"}\<close>
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   126
  within a text block makes
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   127
  \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.
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   128
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   129
  Antiquotations usually spare the author tedious typing of logical entities
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   130
  in full detail. Even more importantly, some degree of consistency-checking
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   131
  between the main body of formal text and its informal explanation is
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   132
  achieved, since terms and types appearing in antiquotations are checked
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   133
  within the current theory or proof context.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   134
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   135
  \<^medskip>
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   136
  Antiquotations are in general written as
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   137
  \<^verbatim>\<open>@{\<close>\<open>name\<close>~\<^verbatim>\<open>[\<close>\<open>options\<close>\<^verbatim>\<open>]\<close>~\<open>arguments\<close>\<^verbatim>\<open>}\<close>. The short form
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   138
  \<^verbatim>\<open>\\<close>\<^verbatim>\<open><^\<close>\<open>name\<close>\<^verbatim>\<open>>\<close>\<open>\<open>argument_content\<close>\<close> (without surrounding \<^verbatim>\<open>@{\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close>)
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   139
  works for a single argument that is a cartouche. A cartouche without special
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   140
  decoration is equivalent to \<^verbatim>\<open>\<^cartouche>\<close>\<open>\<open>argument_content\<close>\<close>, which is
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   141
  equivalent to \<^verbatim>\<open>@{cartouche\<close>~\<open>\<open>argument_content\<close>\<close>\<^verbatim>\<open>}\<close>. The special name
61595
3591274c607e more formal treatment of control symbols;
wenzelm
parents: 61504
diff changeset
   142
  @{antiquotation_def cartouche} is defined in the context: Isabelle/Pure
3591274c607e more formal treatment of control symbols;
wenzelm
parents: 61504
diff changeset
   143
  introduces that as an alias to @{antiquotation_ref text} (see below).
3591274c607e more formal treatment of control symbols;
wenzelm
parents: 61504
diff changeset
   144
  Consequently, \<open>\<open>foo_bar + baz \<le> bazar\<close>\<close> prints literal quasi-formal text
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   145
  (unchecked). A control symbol \<^verbatim>\<open>\\<close>\<^verbatim>\<open><^\<close>\<open>name\<close>\<^verbatim>\<open>>\<close> within the body text, but
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   146
  without a subsequent cartouche, is equivalent to \<^verbatim>\<open>@{\<close>\<open>name\<close>\<^verbatim>\<open>}\<close>.
61472
6458760261ca more documentation;
wenzelm
parents: 61463
diff changeset
   147
61474
6cc07122ca14 clarified;
wenzelm
parents: 61473
diff changeset
   148
  \begingroup
6cc07122ca14 clarified;
wenzelm
parents: 61473
diff changeset
   149
  \def\isasymcontrolstart{\isatt{\isacharbackslash\isacharless\isacharcircum}}
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   150
  \<^rail>\<open>
61472
6458760261ca more documentation;
wenzelm
parents: 61463
diff changeset
   151
    @{syntax_def antiquotation}:
61474
6cc07122ca14 clarified;
wenzelm
parents: 61473
diff changeset
   152
      '@{' antiquotation_body '}' |
61491
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   153
      '\<controlstart>' @{syntax_ref name} '>' @{syntax_ref cartouche} |
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   154
      @{syntax_ref cartouche}
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   155
    ;
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   156
    options: '[' (option * ',') ']'
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   157
    ;
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   158
    option: @{syntax name} | @{syntax name} '=' @{syntax name}
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   159
    ;
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   160
  \<close>
61474
6cc07122ca14 clarified;
wenzelm
parents: 61473
diff changeset
   161
  \endgroup
59917
9830c944670f more uniform "verbose" option to print name space;
wenzelm
parents: 59783
diff changeset
   162
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   163
  Note that the syntax of antiquotations may \<^emph>\<open>not\<close> include source comments
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   164
  \<^verbatim>\<open>(*\<close>~\<open>\<dots>\<close>~\<^verbatim>\<open>*)\<close> nor verbatim text \<^verbatim>\<open>{*\<close>~\<open>\<dots>\<close>~\<^verbatim>\<open>*}\<close>.
61491
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   165
43618
wenzelm
parents: 43613
diff changeset
   166
  %% FIXME less monolithic presentation, move to individual sections!?
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   167
  \<^rail>\<open>
61472
6458760261ca more documentation;
wenzelm
parents: 61463
diff changeset
   168
    @{syntax_def antiquotation_body}:
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   169
      (@@{antiquotation text} | @@{antiquotation cartouche} | @@{antiquotation theory_text})
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   170
        options @{syntax text} |
68481
fb6afa538b04 more uniform syntax;
wenzelm
parents: 67297
diff changeset
   171
      @@{antiquotation theory} options @{syntax embedded} |
62969
9f394a16c557 eliminated "xname" and variants;
wenzelm
parents: 62965
diff changeset
   172
      @@{antiquotation thm} options styles @{syntax thms} |
42617
77d239840285 more precise rail diagrams;
wenzelm
parents: 42596
diff changeset
   173
      @@{antiquotation lemma} options @{syntax prop} @'by' @{syntax method} @{syntax method}? |
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   174
      @@{antiquotation prop} options styles @{syntax prop} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   175
      @@{antiquotation term} options styles @{syntax term} |
43618
wenzelm
parents: 43613
diff changeset
   176
      @@{antiquotation (HOL) value} options styles @{syntax term} |
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   177
      @@{antiquotation term_type} options styles @{syntax term} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   178
      @@{antiquotation typeof} options styles @{syntax term} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   179
      @@{antiquotation const} options @{syntax term} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   180
      @@{antiquotation abbrev} options @{syntax term} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   181
      @@{antiquotation typ} options @{syntax type} |
63120
629a4c5e953e embedded content may be delimited via cartouches;
wenzelm
parents: 62969
diff changeset
   182
      @@{antiquotation type} options @{syntax embedded} |
629a4c5e953e embedded content may be delimited via cartouches;
wenzelm
parents: 62969
diff changeset
   183
      @@{antiquotation class} options @{syntax embedded} |
68809
f6c88cb715db more uniform cartouche syntax;
wenzelm
parents: 68484
diff changeset
   184
      @@{antiquotation locale} options @{syntax embedded} |
61623
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61614
diff changeset
   185
      (@@{antiquotation command} | @@{antiquotation method} | @@{antiquotation attribute})
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61614
diff changeset
   186
        options @{syntax name}
46261
b03897da3c90 document antiquotations for ML infix operators;
wenzelm
parents: 43618
diff changeset
   187
    ;
b03897da3c90 document antiquotations for ML infix operators;
wenzelm
parents: 43618
diff changeset
   188
    @{syntax antiquotation}:
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   189
      @@{antiquotation goals} options |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   190
      @@{antiquotation subgoals} options |
62969
9f394a16c557 eliminated "xname" and variants;
wenzelm
parents: 62965
diff changeset
   191
      @@{antiquotation prf} options @{syntax thms} |
9f394a16c557 eliminated "xname" and variants;
wenzelm
parents: 62965
diff changeset
   192
      @@{antiquotation full_prf} options @{syntax thms} |
58069
0255436b3d85 more liberal embedded "text", which includes cartouches;
wenzelm
parents: 56594
diff changeset
   193
      @@{antiquotation ML} options @{syntax text} |
0255436b3d85 more liberal embedded "text", which includes cartouches;
wenzelm
parents: 56594
diff changeset
   194
      @@{antiquotation ML_op} options @{syntax text} |
0255436b3d85 more liberal embedded "text", which includes cartouches;
wenzelm
parents: 56594
diff changeset
   195
      @@{antiquotation ML_type} options @{syntax text} |
0255436b3d85 more liberal embedded "text", which includes cartouches;
wenzelm
parents: 56594
diff changeset
   196
      @@{antiquotation ML_structure} options @{syntax text} |
0255436b3d85 more liberal embedded "text", which includes cartouches;
wenzelm
parents: 56594
diff changeset
   197
      @@{antiquotation ML_functor} options @{syntax text} |
61473
34d1913f0b20 clarified control antiquotations: decode control symbol to get name;
wenzelm
parents: 61472
diff changeset
   198
      @@{antiquotation emph} options @{syntax text} |
34d1913f0b20 clarified control antiquotations: decode control symbol to get name;
wenzelm
parents: 61472
diff changeset
   199
      @@{antiquotation bold} options @{syntax text} |
58716
23a380cc45f4 official support for "tt" style variants, avoid fragile \verb in LaTeX;
wenzelm
parents: 58618
diff changeset
   200
      @@{antiquotation verbatim} options @{syntax text} |
67219
81e9804b2014 added document antiquotation @{session name};
wenzelm
parents: 67139
diff changeset
   201
      @@{antiquotation session} options @{syntax embedded} |
63672
5a7c919a4ada more uniform path syntax (like url);
wenzelm
parents: 63669
diff changeset
   202
      @@{antiquotation path} options @{syntax embedded} |
62969
9f394a16c557 eliminated "xname" and variants;
wenzelm
parents: 62965
diff changeset
   203
      @@{antiquotation "file"} options @{syntax name} |
63669
256fc20716f2 clarified antiquotations;
wenzelm
parents: 63531
diff changeset
   204
      @@{antiquotation dir} options @{syntax name} |
63120
629a4c5e953e embedded content may be delimited via cartouches;
wenzelm
parents: 62969
diff changeset
   205
      @@{antiquotation url} options @{syntax embedded} |
58593
51adee3ace7b documentation of @{cite} and cite_macro;
wenzelm
parents: 58552
diff changeset
   206
      @@{antiquotation cite} options @{syntax cartouche}? (@{syntax name} + @'and')
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   207
    ;
32892
9742f6130f10 corrected syntax diagrams for styles
haftmann
parents: 32891
diff changeset
   208
    styles: '(' (style + ',') ')'
32891
d403b99287ff new generalized concept for term styles
haftmann
parents: 30397
diff changeset
   209
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40879
diff changeset
   210
    style: (@{syntax name} +)
61473
34d1913f0b20 clarified control antiquotations: decode control symbol to get name;
wenzelm
parents: 61472
diff changeset
   211
    ;
34d1913f0b20 clarified control antiquotations: decode control symbol to get name;
wenzelm
parents: 61472
diff changeset
   212
    @@{command print_antiquotations} ('!'?)
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   213
  \<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   214
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   215
  \<^descr> \<open>@{text s}\<close> prints uninterpreted source text \<open>s\<close>, i.e.\ inner syntax. This
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   216
  is particularly useful to print portions of text according to the Isabelle
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   217
  document style, without demanding well-formedness, e.g.\ small pieces of
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   218
  terms that should not be parsed or type-checked yet.
61491
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   219
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   220
  It is also possible to write this in the short form \<open>\<open>s\<close>\<close> without any
97261e6c1d42 another antiquotation short form: undecorated cartouche as alias for @{text};
wenzelm
parents: 61479
diff changeset
   221
  further decoration.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   222
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   223
  \<^descr> \<open>@{theory_text s}\<close> prints uninterpreted theory source text \<open>s\<close>, i.e.\
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   224
  outer syntax with command keywords and other tokens.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   225
68484
59793df7f853 clarified document antiquotation @{theory};
wenzelm
parents: 68481
diff changeset
   226
  \<^descr> \<open>@{theory A}\<close> prints the session-qualified theory name \<open>A\<close>, which is
59793df7f853 clarified document antiquotation @{theory};
wenzelm
parents: 68481
diff changeset
   227
  guaranteed to refer to a valid ancestor theory in the current context.
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   228
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   229
  \<^descr> \<open>@{thm a\<^sub>1 \<dots> a\<^sub>n}\<close> prints theorems \<open>a\<^sub>1 \<dots> a\<^sub>n\<close>. Full fact expressions are
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   230
  allowed here, including attributes (\secref{sec:syn-att}).
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   231
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   232
  \<^descr> \<open>@{prop \<phi>}\<close> prints a well-typed proposition \<open>\<phi>\<close>.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   233
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   234
  \<^descr> \<open>@{lemma \<phi> by m}\<close> proves a well-typed proposition \<open>\<phi>\<close> by method \<open>m\<close> and
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   235
  prints the original \<open>\<phi>\<close>.
27453
eecd9d84e41b added lemma antiquotation
haftmann
parents: 27053
diff changeset
   236
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   237
  \<^descr> \<open>@{term t}\<close> prints a well-typed term \<open>t\<close>.
43613
7afbaf5a406b adding a minimalistic documentation of the value antiquotation in the Isar reference manual
bulwahn
parents: 42936
diff changeset
   238
  
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   239
  \<^descr> \<open>@{value t}\<close> evaluates a term \<open>t\<close> and prints its result, see also
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   240
  @{command_ref (HOL) value}.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   241
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   242
  \<^descr> \<open>@{term_type t}\<close> prints a well-typed term \<open>t\<close> annotated with its type.
32898
e871d897969c term styles also cover antiquotations term_type and typeof
haftmann
parents: 32892
diff changeset
   243
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   244
  \<^descr> \<open>@{typeof t}\<close> prints the type of a well-typed term \<open>t\<close>.
32898
e871d897969c term styles also cover antiquotations term_type and typeof
haftmann
parents: 32892
diff changeset
   245
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   246
  \<^descr> \<open>@{const c}\<close> prints a logical or syntactic constant \<open>c\<close>.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   247
  
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   248
  \<^descr> \<open>@{abbrev c x\<^sub>1 \<dots> x\<^sub>n}\<close> prints a constant abbreviation \<open>c x\<^sub>1 \<dots> x\<^sub>n \<equiv> rhs\<close>
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   249
  as defined in the current context.
39305
d4fa19eb0822 'class' and 'type' are now antiquoations by default
haftmann
parents: 32898
diff changeset
   250
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   251
  \<^descr> \<open>@{typ \<tau>}\<close> prints a well-formed type \<open>\<tau>\<close>.
39305
d4fa19eb0822 'class' and 'type' are now antiquoations by default
haftmann
parents: 32898
diff changeset
   252
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   253
  \<^descr> \<open>@{type \<kappa>}\<close> prints a (logical or syntactic) type constructor \<open>\<kappa>\<close>.
39305
d4fa19eb0822 'class' and 'type' are now antiquoations by default
haftmann
parents: 32898
diff changeset
   254
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   255
  \<^descr> \<open>@{class c}\<close> prints a class \<open>c\<close>.
39305
d4fa19eb0822 'class' and 'type' are now antiquoations by default
haftmann
parents: 32898
diff changeset
   256
68809
f6c88cb715db more uniform cartouche syntax;
wenzelm
parents: 68484
diff changeset
   257
  \<^descr> \<open>@{locale c}\<close> prints a locale \<open>c\<close>.
f6c88cb715db more uniform cartouche syntax;
wenzelm
parents: 68484
diff changeset
   258
61623
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61614
diff changeset
   259
  \<^descr> \<open>@{command name}\<close>, \<open>@{method name}\<close>, \<open>@{attribute name}\<close> print checked
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61614
diff changeset
   260
  entities of the Isar language.
2f89f0b13e08 added @{command}, @{method}, @{attribute};
wenzelm
parents: 61614
diff changeset
   261
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   262
  \<^descr> \<open>@{goals}\<close> prints the current \<^emph>\<open>dynamic\<close> goal state. This is mainly for
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   263
  support of tactic-emulation scripts within Isar. Presentation of goal states
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   264
  does not conform to the idea of human-readable proof documents!
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   265
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   266
  When explaining proofs in detail it is usually better to spell out the
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   267
  reasoning via proper Isar proof commands, instead of peeking at the internal
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   268
  machine configuration.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   269
  
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   270
  \<^descr> \<open>@{subgoals}\<close> is similar to \<open>@{goals}\<close>, but does not print the main goal.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   271
  
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   272
  \<^descr> \<open>@{prf a\<^sub>1 \<dots> a\<^sub>n}\<close> prints the (compact) proof terms corresponding to the
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   273
  theorems \<open>a\<^sub>1 \<dots> a\<^sub>n\<close>. Note that this requires proof terms to be switched on
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   274
  for the current logic session.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   275
  
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   276
  \<^descr> \<open>@{full_prf a\<^sub>1 \<dots> a\<^sub>n}\<close> is like \<open>@{prf a\<^sub>1 \<dots> a\<^sub>n}\<close>, but prints the full
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   277
  proof terms, i.e.\ also displays information omitted in the compact proof
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   278
  term, which is denoted by ``\<open>_\<close>'' placeholders there.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   279
  
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   280
  \<^descr> \<open>@{ML s}\<close>, \<open>@{ML_op s}\<close>, \<open>@{ML_type s}\<close>, \<open>@{ML_structure s}\<close>, and
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   281
  \<open>@{ML_functor s}\<close> check text \<open>s\<close> as ML value, infix operator, type,
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   282
  structure, and functor respectively. The source is printed verbatim.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   283
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   284
  \<^descr> \<open>@{emph s}\<close> prints document source recursively, with {\LaTeX} markup
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   285
  \<^verbatim>\<open>\emph{\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close>.
61473
34d1913f0b20 clarified control antiquotations: decode control symbol to get name;
wenzelm
parents: 61472
diff changeset
   286
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   287
  \<^descr> \<open>@{bold s}\<close> prints document source recursively, with {\LaTeX} markup
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   288
  \<^verbatim>\<open>\textbf{\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close>.
61473
34d1913f0b20 clarified control antiquotations: decode control symbol to get name;
wenzelm
parents: 61472
diff changeset
   289
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   290
  \<^descr> \<open>@{verbatim s}\<close> prints uninterpreted source text literally as ASCII
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   291
  characters, using some type-writer font style.
58716
23a380cc45f4 official support for "tt" style variants, avoid fragile \verb in LaTeX;
wenzelm
parents: 58618
diff changeset
   292
67219
81e9804b2014 added document antiquotation @{session name};
wenzelm
parents: 67139
diff changeset
   293
  \<^descr> \<open>@{session name}\<close> prints given session name verbatim. The name is checked
81e9804b2014 added document antiquotation @{session name};
wenzelm
parents: 67139
diff changeset
   294
  wrt.\ the dependencies of the current session.
81e9804b2014 added document antiquotation @{session name};
wenzelm
parents: 67139
diff changeset
   295
63669
256fc20716f2 clarified antiquotations;
wenzelm
parents: 63531
diff changeset
   296
  \<^descr> \<open>@{path name}\<close> prints the file-system path name verbatim.
40801
6cfacec435e6 added document antiquotation @{file};
wenzelm
parents: 40800
diff changeset
   297
63669
256fc20716f2 clarified antiquotations;
wenzelm
parents: 63531
diff changeset
   298
  \<^descr> \<open>@{file name}\<close> is like \<open>@{path name}\<close>, but ensures that \<open>name\<close> refers to a
256fc20716f2 clarified antiquotations;
wenzelm
parents: 63531
diff changeset
   299
  plain file.
256fc20716f2 clarified antiquotations;
wenzelm
parents: 63531
diff changeset
   300
256fc20716f2 clarified antiquotations;
wenzelm
parents: 63531
diff changeset
   301
  \<^descr> \<open>@{dir name}\<close> is like \<open>@{path name}\<close>, but ensures that \<open>name\<close> refers to a
256fc20716f2 clarified antiquotations;
wenzelm
parents: 63531
diff changeset
   302
  directory.
54705
0dff3326d12a provide @{file_unchecked} in Isabelle/Pure;
wenzelm
parents: 54702
diff changeset
   303
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   304
  \<^descr> \<open>@{url name}\<close> produces markup for the given URL, which results in an
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   305
  active hyperlink within the text.
54702
3daeba5130f0 added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents: 54346
diff changeset
   306
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   307
  \<^descr> \<open>@{cite name}\<close> produces a citation \<^verbatim>\<open>\cite{name}\<close> in {\LaTeX}, where the
67297
86a099f896fc formal check of @{cite} bibtex entries -- only in batch-mode session builds;
wenzelm
parents: 67263
diff changeset
   308
  name refers to some Bib{\TeX} database entry. This is only checked in
86a099f896fc formal check of @{cite} bibtex entries -- only in batch-mode session builds;
wenzelm
parents: 67263
diff changeset
   309
  batch-mode session builds.
58593
51adee3ace7b documentation of @{cite} and cite_macro;
wenzelm
parents: 58552
diff changeset
   310
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   311
  The variant \<open>@{cite \<open>opt\<close> name}\<close> produces \<^verbatim>\<open>\cite[opt]{name}\<close> with some
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   312
  free-form optional argument. Multiple names are output with commas, e.g.
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   313
  \<open>@{cite foo \<AND> bar}\<close> becomes \<^verbatim>\<open>\cite{foo,bar}\<close>.
58593
51adee3ace7b documentation of @{cite} and cite_macro;
wenzelm
parents: 58552
diff changeset
   314
51adee3ace7b documentation of @{cite} and cite_macro;
wenzelm
parents: 58552
diff changeset
   315
  The {\LaTeX} macro name is determined by the antiquotation option
51adee3ace7b documentation of @{cite} and cite_macro;
wenzelm
parents: 58552
diff changeset
   316
  @{antiquotation_option_def cite_macro}, or the configuration option
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   317
  @{attribute cite_macro} in the context. For example, \<open>@{cite [cite_macro =
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   318
  nocite] foobar}\<close> produces \<^verbatim>\<open>\nocite{foobar}\<close>.
61473
34d1913f0b20 clarified control antiquotations: decode control symbol to get name;
wenzelm
parents: 61472
diff changeset
   319
61614
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   320
  \<^descr> @{command "print_antiquotations"} prints all document antiquotations that
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   321
  are defined in the current context; the ``\<open>!\<close>'' option indicates extra
34978e1b234f added document antiquotation @{theory_text};
wenzelm
parents: 61595
diff changeset
   322
  verbosity.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   323
\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   324
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   325
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   326
subsection \<open>Styled antiquotations\<close>
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   327
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   328
text \<open>
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   329
  The antiquotations \<open>thm\<close>, \<open>prop\<close> and \<open>term\<close> admit an extra \<^emph>\<open>style\<close>
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   330
  specification to modify the printed result. A style is specified by a name
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   331
  with a possibly empty number of arguments; multiple styles can be sequenced
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   332
  with commas. The following standard styles are available:
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   333
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   334
  \<^descr> \<open>lhs\<close> extracts the first argument of any application form with at least
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   335
  two arguments --- typically meta-level or object-level equality, or any
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   336
  other binary relation.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   337
  
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   338
  \<^descr> \<open>rhs\<close> is like \<open>lhs\<close>, but extracts the second argument.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   339
  
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   340
  \<^descr> \<open>concl\<close> extracts the conclusion \<open>C\<close> from a rule in Horn-clause normal form
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   341
  \<open>A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C\<close>.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   342
  
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   343
  \<^descr> \<open>prem\<close> \<open>n\<close> extract premise number \<open>n\<close> from from a rule in Horn-clause
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   344
  normal form \<open>A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C\<close>.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   345
\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   346
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   347
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   348
subsection \<open>General options\<close>
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   349
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   350
text \<open>
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   351
  The following options are available to tune the printed output of
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   352
  antiquotations. Note that many of these coincide with system and
54346
wenzelm
parents: 53982
diff changeset
   353
  configuration options of the same names.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   354
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   355
    \<^descr> @{antiquotation_option_def show_types}~\<open>= bool\<close> and
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   356
    @{antiquotation_option_def show_sorts}~\<open>= bool\<close> control printing of
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   357
    explicit type and sort constraints.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   358
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   359
    \<^descr> @{antiquotation_option_def show_structs}~\<open>= bool\<close> controls printing of
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   360
    implicit structures.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   361
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   362
    \<^descr> @{antiquotation_option_def show_abbrevs}~\<open>= bool\<close> controls folding of
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   363
    abbreviations.
40879
ca132ef44944 configuration option "show_abbrevs" supersedes print mode "no_abbrevs", with inverted meaning;
wenzelm
parents: 40801
diff changeset
   364
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   365
    \<^descr> @{antiquotation_option_def names_long}~\<open>= bool\<close> forces names of types
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   366
    and constants etc.\ to be printed in their fully qualified internal form.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   367
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   368
    \<^descr> @{antiquotation_option_def names_short}~\<open>= bool\<close> forces names of types
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   369
    and constants etc.\ to be printed unqualified. Note that internalizing the
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   370
    output again in the current context may well yield a different result.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   371
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   372
    \<^descr> @{antiquotation_option_def names_unique}~\<open>= bool\<close> determines whether the
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   373
    printed version of qualified names should be made sufficiently long to
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   374
    avoid overlap with names declared further back. Set to \<open>false\<close> for more
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   375
    concise output.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   376
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   377
    \<^descr> @{antiquotation_option_def eta_contract}~\<open>= bool\<close> prints terms in
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   378
    \<open>\<eta>\<close>-contracted form.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   379
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   380
    \<^descr> @{antiquotation_option_def display}~\<open>= bool\<close> indicates if the text is to
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   381
    be output as multi-line ``display material'', rather than a small piece of
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   382
    text without line breaks (which is the default).
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   383
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   384
    In this mode the embedded entities are printed in the same style as the
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   385
    main theory text.
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   386
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   387
    \<^descr> @{antiquotation_option_def break}~\<open>= bool\<close> controls line breaks in
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   388
    non-display material.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   389
70121
61e26527480e added document antiquotation option "cartouche";
wenzelm
parents: 69962
diff changeset
   390
    \<^descr> @{antiquotation_option_def cartouche}~\<open>= bool\<close> indicates if the output
61e26527480e added document antiquotation option "cartouche";
wenzelm
parents: 69962
diff changeset
   391
    should be delimited as cartouche.
61e26527480e added document antiquotation option "cartouche";
wenzelm
parents: 69962
diff changeset
   392
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   393
    \<^descr> @{antiquotation_option_def quotes}~\<open>= bool\<close> indicates if the output
70121
61e26527480e added document antiquotation option "cartouche";
wenzelm
parents: 69962
diff changeset
   394
    should be delimited via double quotes (option @{antiquotation_option
61e26527480e added document antiquotation option "cartouche";
wenzelm
parents: 69962
diff changeset
   395
    cartouche} takes precedence). Note that the Isabelle {\LaTeX} styles may
61e26527480e added document antiquotation option "cartouche";
wenzelm
parents: 69962
diff changeset
   396
    suppress quotes on their own account.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   397
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   398
    \<^descr> @{antiquotation_option_def mode}~\<open>= name\<close> adds \<open>name\<close> to the print mode
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   399
    to be used for presentation. Note that the standard setup for {\LaTeX}
61997
4d9518c3d031 updated print modes;
wenzelm
parents: 61656
diff changeset
   400
    output is already present by default, with mode ``\<open>latex\<close>''.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   401
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   402
    \<^descr> @{antiquotation_option_def margin}~\<open>= nat\<close> and
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   403
    @{antiquotation_option_def indent}~\<open>= nat\<close> change the margin or
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   404
    indentation for pretty printing of display material.
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   405
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   406
    \<^descr> @{antiquotation_option_def goals_limit}~\<open>= nat\<close> determines the maximum
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   407
    number of subgoals to be printed (for goal-based antiquotation).
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   408
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   409
    \<^descr> @{antiquotation_option_def source}~\<open>= bool\<close> prints the original source
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   410
    text of the antiquotation arguments, rather than its internal
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   411
    representation. Note that formal checking of @{antiquotation "thm"},
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   412
    @{antiquotation "term"}, etc. is still enabled; use the @{antiquotation
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   413
    "text"} antiquotation for unchecked output.
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   414
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   415
    Regular \<open>term\<close> and \<open>typ\<close> antiquotations with \<open>source = false\<close> involve a
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   416
    full round-trip from the original source to an internalized logical entity
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   417
    back to a source form, according to the syntax of the current context.
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   418
    Thus the printed output is not under direct control of the author, it may
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   419
    even fluctuate a bit as the underlying theory is changed later on.
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   420
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   421
    In contrast, @{antiquotation_option source}~\<open>= true\<close> admits direct
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   422
    printing of the given source text, with the desirable well-formedness
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   423
    check in the background, but without modification of the printed text.
28749
99f6da3bbbf7 renamed "formal comments" to "document comments";
wenzelm
parents: 28747
diff changeset
   424
70122
a0b21b4b7a4a strip cartouches from arguments of "embedded" document antiquotations, corresponding to automated update via "isabelle update -u control_cartouches" -- e.g. relevant for documents with thy_output_source (e.g. doc "isar-ref", "jedit", "system");
wenzelm
parents: 70121
diff changeset
   425
    Cartouche delimiters of the argument are stripped for antiquotations that
a0b21b4b7a4a strip cartouches from arguments of "embedded" document antiquotations, corresponding to automated update via "isabelle update -u control_cartouches" -- e.g. relevant for documents with thy_output_source (e.g. doc "isar-ref", "jedit", "system");
wenzelm
parents: 70121
diff changeset
   426
    are internally categorized as ``embedded''.
a0b21b4b7a4a strip cartouches from arguments of "embedded" document antiquotations, corresponding to automated update via "isabelle update -u control_cartouches" -- e.g. relevant for documents with thy_output_source (e.g. doc "isar-ref", "jedit", "system");
wenzelm
parents: 70121
diff changeset
   427
a0b21b4b7a4a strip cartouches from arguments of "embedded" document antiquotations, corresponding to automated update via "isabelle update -u control_cartouches" -- e.g. relevant for documents with thy_output_source (e.g. doc "isar-ref", "jedit", "system");
wenzelm
parents: 70121
diff changeset
   428
    \<^descr> @{antiquotation_option_def source_cartouche} is like
a0b21b4b7a4a strip cartouches from arguments of "embedded" document antiquotations, corresponding to automated update via "isabelle update -u control_cartouches" -- e.g. relevant for documents with thy_output_source (e.g. doc "isar-ref", "jedit", "system");
wenzelm
parents: 70121
diff changeset
   429
    @{antiquotation_option source}, but cartouche delimiters are always
a0b21b4b7a4a strip cartouches from arguments of "embedded" document antiquotations, corresponding to automated update via "isabelle update -u control_cartouches" -- e.g. relevant for documents with thy_output_source (e.g. doc "isar-ref", "jedit", "system");
wenzelm
parents: 70121
diff changeset
   430
    preserved in the output.
a0b21b4b7a4a strip cartouches from arguments of "embedded" document antiquotations, corresponding to automated update via "isabelle update -u control_cartouches" -- e.g. relevant for documents with thy_output_source (e.g. doc "isar-ref", "jedit", "system");
wenzelm
parents: 70121
diff changeset
   431
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   432
  For Boolean flags, ``\<open>name = true\<close>'' may be abbreviated as ``\<open>name\<close>''. All
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   433
  of the above flags are disabled by default, unless changed specifically for
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   434
  a logic session in the corresponding \<^verbatim>\<open>ROOT\<close> file.
61458
987533262fc2 Markdown support in document text;
wenzelm
parents: 61439
diff changeset
   435
\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   436
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   437
62274
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   438
section \<open>Markdown-like text structure\<close>
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   439
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   440
text \<open>
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   441
  The markup commands @{command_ref text}, @{command_ref txt}, @{command_ref
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   442
  text_raw} (\secref{sec:markup}) consist of plain text. Its internal
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   443
  structure consists of paragraphs and (nested) lists, using special Isabelle
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   444
  symbols and some rules for indentation and blank lines. This quasi-visual
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 63672
diff changeset
   445
  format resembles \<^emph>\<open>Markdown\<close>\<^footnote>\<open>\<^url>\<open>http://commonmark.org\<close>\<close>, but the full
6e1e8b5abbfa more symbols;
wenzelm
parents: 63672
diff changeset
   446
  complexity of that notation is avoided.
62274
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   447
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   448
  This is a summary of the main principles of minimal Markdown in Isabelle:
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   449
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   450
    \<^item> List items start with the following markers
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   451
      \<^descr>[itemize:] \<^verbatim>\<open>\<^item>\<close>
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   452
      \<^descr>[enumerate:] \<^verbatim>\<open>\<^enum>\<close>
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   453
      \<^descr>[description:] \<^verbatim>\<open>\<^descr>\<close>
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   454
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   455
    \<^item> Adjacent list items with same indentation and same marker are grouped
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   456
    into a single list.
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   457
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   458
    \<^item> Singleton blank lines separate paragraphs.
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   459
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   460
    \<^item> Multiple blank lines escape from the current list hierarchy.
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   461
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   462
  Notable differences to official Markdown:
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   463
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   464
    \<^item> Indentation of list items needs to match exactly.
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   465
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   466
    \<^item> Indentation is unlimited (official Markdown interprets four spaces as
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   467
    block quote).
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   468
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   469
    \<^item> List items always consist of paragraphs --- there is no notion of
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   470
    ``tight'' list.
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   471
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   472
    \<^item> Section headings are expressed via Isar document markup commands
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   473
    (\secref{sec:markup}).
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   474
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   475
    \<^item> URLs, font styles, other special content is expressed via antiquotations
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   476
    (\secref{sec:antiq}), usually with proper nesting of sub-languages via
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   477
    text cartouches.
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   478
\<close>
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   479
199f4d6dab0a more on "Markdown-like text structure";
wenzelm
parents: 61997
diff changeset
   480
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   481
section \<open>Document markers and command tags \label{sec:document-markers}\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   482
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   483
text \<open>
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   484
  \emph{Document markers} are formal comments of the form \<open>\<^marker>\<open>marker_body\<close>\<close>
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   485
  (using the control symbol \<^verbatim>\<open>\<^marker>\<close>) and may occur anywhere within the
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   486
  outer syntax of a command: the inner syntax of a marker body resembles that
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   487
  for attributes (\secref{sec:syn-att}). In contrast, \emph{Command tags} may
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   488
  only occur after a command keyword and are treated as special markers as
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   489
  explained below.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   490
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   491
  \<^rail>\<open>
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   492
    @{syntax_def marker}: '\<^marker>' @{syntax cartouche}
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   493
    ;
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   494
    @{syntax_def marker_body}: (@{syntax name} @{syntax args} * ',')
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   495
    ;
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   496
    @{syntax_def tags}: tag*
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   497
    ;
63138
70f4d67235a0 clarified syntax category names according to Isabelle/ML/Scala;
wenzelm
parents: 63120
diff changeset
   498
    tag: '%' (@{syntax short_ident} | @{syntax string})
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   499
  \<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   500
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   501
  Document markers are stripped from the document output, but surrounding
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   502
  white-space is preserved: e.g.\ a marker at the end of a line does not
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   503
  affect the subsequent line break. Markers operate within the semantic
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   504
  presentation context of a command, and may modify it to change the overall
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   505
  appearance of a command span (e.g.\ by adding tags).
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   506
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   507
  Each document marker has its own syntax defined in the theory context; the
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   508
  following markers are predefined in Isabelle/Pure:
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   509
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   510
  \<^rail>\<open>
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   511
    (@@{document_marker_def title} |
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   512
     @@{document_marker_def creator} |
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   513
     @@{document_marker_def contributor} |
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   514
     @@{document_marker_def date} |
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   515
     @@{document_marker_def license} |
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   516
     @@{document_marker_def description}) @{syntax embedded}
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   517
    ;
70140
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   518
    @@{document_marker_def tag} (scope?) @{syntax name}
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   519
    ;
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   520
    scope: '(' ('proof' | 'command') ')'
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   521
  \<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   522
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   523
    \<^descr> \<open>\<^marker>\<open>title arg\<close>\<close>, \<open>\<^marker>\<open>creator arg\<close>\<close>, \<open>\<^marker>\<open>contributor arg\<close>\<close>, \<open>\<^marker>\<open>date arg\<close>\<close>,
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   524
    \<open>\<^marker>\<open>license arg\<close>\<close>, and \<open>\<^marker>\<open>description arg\<close>\<close> produce markup in the PIDE
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   525
    document, without any immediate effect on typesetting. This vocabulary is
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   526
    taken from the Dublin Core Metadata
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   527
    Initiative\<^footnote>\<open>\<^url>\<open>https://www.dublincore.org/specifications/dublin-core/dcmi-terms\<close>\<close>.
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   528
    The argument is an uninterpreted string, except for @{document_marker
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   529
    description}, which consists of words that are subject to spell-checking.
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   530
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   531
    \<^descr> \<open>\<^marker>\<open>tag name\<close>\<close> updates the list of command tags in the presentation
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   532
    context: later declarations take precedence, so \<open>\<^marker>\<open>tag a, tag b, tag c\<close>\<close>
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   533
    produces a reversed list. The default tags are given by the original
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   534
    \<^theory_text>\<open>keywords\<close> declaration of a command, and the system option
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   535
    @{system_option_ref document_tags}.
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   536
70140
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   537
    The optional \<open>scope\<close> tells how far the tagging is applied to subsequent
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   538
    proof structure: ``\<^theory_text>\<open>("proof")\<close>'' means it applies to the following proof
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   539
    text, and ``\<^theory_text>\<open>(command)\<close>'' means it only applies to the current command.
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   540
    The default within a proof body is ``\<^theory_text>\<open>("proof")\<close>'', but for toplevel goal
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   541
    statements it is ``\<^theory_text>\<open>(command)\<close>''. Thus a \<open>tag\<close> marker for \<^theory_text>\<open>theorem\<close>,
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   542
    \<^theory_text>\<open>lemma\<close> etc. does \emph{not} affect its proof by default.
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   543
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   544
    An old-style command tag \<^verbatim>\<open>%\<close>\<open>name\<close> is treated like a document marker
70140
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   545
    \<open>\<^marker>\<open>tag (proof) name\<close>\<close>: the list of command tags precedes the list of
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   546
    document markers. The head of the resulting tags in the presentation
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   547
    context is turned into {\LaTeX} environments to modify the type-setting.
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   548
    The following tags are pre-declared for certain classes of commands, and
d13865c21e36 updated documentation;
wenzelm
parents: 70122
diff changeset
   549
    serve as default markup for certain kinds of commands:
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   550
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   551
    \<^medskip>
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   552
    \begin{tabular}{ll}
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   553
      \<open>document\<close> & document markup commands \\
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   554
      \<open>theory\<close> & theory begin/end \\
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   555
      \<open>proof\<close> & all proof commands \\
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   556
      \<open>ML\<close> & all commands involving ML code \\
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   557
    \end{tabular}
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   558
    \<^medskip>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   559
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   560
  The Isabelle document preparation system @{cite "isabelle-system"} allows
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   561
  tagged command regions to be presented specifically, e.g.\ to fold proof
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   562
  texts, or drop parts of the text completely.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   563
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   564
  For example ``\<^theory_text>\<open>by auto\<close>~\<open>\<^marker>\<open>tag invisible\<close>\<close>'' causes that piece of proof to
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   565
  be treated as \<open>invisible\<close> instead of \<open>proof\<close> (the default), which may be
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   566
  shown or hidden depending on the document setup. In contrast, ``\<^theory_text>\<open>by
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   567
  auto\<close>~\<open>\<^marker>\<open>tag visible\<close>\<close>'' forces this text to be shown invariably.
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   568
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   569
  Explicit tag specifications within a proof apply to all subsequent commands
69962
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   570
  of the same level of nesting. For example, ``\<^theory_text>\<open>proof\<close>~\<open>\<^marker>\<open>tag invisible\<close>
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   571
  \<dots>\<close>~\<^theory_text>\<open>qed\<close>'' forces the whole sub-proof to be typeset as \<open>visible\<close> (unless
82e945d472d5 documentation of document markers and re-interpreted command tags;
wenzelm
parents: 69597
diff changeset
   572
  some of its parts are tagged differently).
28750
1ff7fff6a170 updated section "Markup via command tags";
wenzelm
parents: 28749
diff changeset
   573
61421
e0825405d398 more symbols;
wenzelm
parents: 60286
diff changeset
   574
  \<^medskip>
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   575
  Command tags merely produce certain markup environments for type-setting.
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 63672
diff changeset
   576
  The meaning of these is determined by {\LaTeX} macros, as defined in
6e1e8b5abbfa more symbols;
wenzelm
parents: 63672
diff changeset
   577
  \<^file>\<open>~~/lib/texinputs/isabelle.sty\<close> or by the document author. The Isabelle
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   578
  document preparation tools also provide some high-level options to specify
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   579
  the meaning of arbitrary tags to ``keep'', ``drop'', or ``fold'' the
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   580
  corresponding parts of the text. Logic sessions may also specify ``document
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   581
  versions'', where given tags are interpreted in some particular way. Again
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   582
  see @{cite "isabelle-system"} for further details.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   583
\<close>
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   584
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   585
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   586
section \<open>Railroad diagrams\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   587
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   588
text \<open>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   589
  \begin{matharray}{rcl}
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61491
diff changeset
   590
    @{antiquotation_def "rail"} & : & \<open>antiquotation\<close> \\
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   591
  \end{matharray}
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   592
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   593
  \<^rail>\<open>
59937
6eccb133d4e6 clarified rail syntax;
wenzelm
parents: 59917
diff changeset
   594
    'rail' @{syntax text}
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   595
  \<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   596
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   597
  The @{antiquotation rail} antiquotation allows to include syntax diagrams
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 63672
diff changeset
   598
  into Isabelle documents. {\LaTeX} requires the style file
6e1e8b5abbfa more symbols;
wenzelm
parents: 63672
diff changeset
   599
  \<^file>\<open>~~/lib/texinputs/railsetup.sty\<close>, which can be used via
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   600
  \<^verbatim>\<open>\usepackage{railsetup}\<close> in \<^verbatim>\<open>root.tex\<close>, for example.
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   601
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   602
  The rail specification language is quoted here as Isabelle @{syntax string}
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   603
  or text @{syntax "cartouche"}; it has its own grammar given below.
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   604
55120
wenzelm
parents: 55113
diff changeset
   605
  \begingroup
61474
6cc07122ca14 clarified;
wenzelm
parents: 61473
diff changeset
   606
  \def\isasymnewline{\isatt{\isacharbackslash\isacharless newline\isachargreater}}
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   607
  \<^rail>\<open>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   608
  rule? + ';'
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   609
  ;
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   610
  rule: ((identifier | @{syntax antiquotation}) ':')? body
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   611
  ;
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   612
  body: concatenation + '|'
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   613
  ;
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   614
  concatenation: ((atom '?'?) +) (('*' | '+') atom?)?
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   615
  ;
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   616
  atom: '(' body? ')' | identifier |
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   617
    '@'? (string | @{syntax antiquotation}) |
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55029
diff changeset
   618
    '\<newline>'
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   619
  \<close>
55120
wenzelm
parents: 55113
diff changeset
   620
  \endgroup
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   621
63138
70f4d67235a0 clarified syntax category names according to Isabelle/ML/Scala;
wenzelm
parents: 63120
diff changeset
   622
  The lexical syntax of \<open>identifier\<close> coincides with that of @{syntax
70f4d67235a0 clarified syntax category names according to Isabelle/ML/Scala;
wenzelm
parents: 63120
diff changeset
   623
  short_ident} in regular Isabelle syntax, but \<open>string\<close> uses single quotes
70f4d67235a0 clarified syntax category names according to Isabelle/ML/Scala;
wenzelm
parents: 63120
diff changeset
   624
  instead of double quotes of the standard @{syntax string} category.
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   625
61624
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   626
  Each \<open>rule\<close> defines a formal language (with optional name), using a notation
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   627
  that is similar to EBNF or regular expressions with recursion. The meaning
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   628
  and visual appearance of these rail language elements is illustrated by the
b98b237969c0 tuned whitespace;
wenzelm
parents: 61623
diff changeset
   629
  following representative examples.
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   630
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   631
  \<^item> Empty \<^verbatim>\<open>()\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   632
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   633
  \<^rail>\<open>()\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   634
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   635
  \<^item> Nonterminal \<^verbatim>\<open>A\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   636
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   637
  \<^rail>\<open>A\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   638
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   639
  \<^item> Nonterminal via Isabelle antiquotation \<^verbatim>\<open>@{syntax method}\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   640
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   641
  \<^rail>\<open>@{syntax method}\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   642
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   643
  \<^item> Terminal \<^verbatim>\<open>'xyz'\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   644
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   645
  \<^rail>\<open>'xyz'\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   646
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   647
  \<^item> Terminal in keyword style \<^verbatim>\<open>@'xyz'\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   648
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   649
  \<^rail>\<open>@'xyz'\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   650
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   651
  \<^item> Terminal via Isabelle antiquotation \<^verbatim>\<open>@@{method rule}\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   652
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   653
  \<^rail>\<open>@@{method rule}\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   654
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   655
  \<^item> Concatenation \<^verbatim>\<open>A B C\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   656
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   657
  \<^rail>\<open>A B C\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   658
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   659
  \<^item> Newline inside concatenation \<^verbatim>\<open>A B C \<newline> D E F\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   660
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   661
  \<^rail>\<open>A B C \<newline> D E F\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   662
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   663
  \<^item> Variants \<^verbatim>\<open>A | B | C\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   664
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   665
  \<^rail>\<open>A | B | C\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   666
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   667
  \<^item> Option \<^verbatim>\<open>A ?\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   668
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   669
  \<^rail>\<open>A ?\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   670
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   671
  \<^item> Repetition \<^verbatim>\<open>A *\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   672
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   673
  \<^rail>\<open>A *\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   674
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   675
  \<^item> Repetition with separator \<^verbatim>\<open>A * sep\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   676
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   677
  \<^rail>\<open>A * sep\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   678
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   679
  \<^item> Strict repetition \<^verbatim>\<open>A +\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   680
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   681
  \<^rail>\<open>A +\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   682
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   683
  \<^item> Strict repetition with separator \<^verbatim>\<open>A + sep\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   684
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68809
diff changeset
   685
  \<^rail>\<open>A + sep\<close>
58618
782f0b662cae more cartouches;
wenzelm
parents: 58593
diff changeset
   686
\<close>
42658
8f5d5d71add0 some documentation of @{rail} antiquotation;
wenzelm
parents: 42651
diff changeset
   687
27043
3ff111ed85a1 added Document_Preparation;
wenzelm
parents:
diff changeset
   688
end