doc-src/LaTeXsugar/Sugar/Sugar.thy
author kleing
Wed May 25 11:14:59 2005 +0200 (2005-05-25)
changeset 16076 03e8a88c0b54
parent 16075 8852058ecf8d
child 16153 999ca183b4c7
permissions -rw-r--r--
tuned thm_style section
nipkow@15337
     1
(*<*)
nipkow@15337
     2
theory Sugar
kleing@15366
     3
imports LaTeXsugar OptionalSugar
nipkow@15337
     4
begin
nipkow@15337
     5
(*>*)
nipkow@15337
     6
nipkow@15337
     7
section "Introduction"
nipkow@15337
     8
kleing@15385
     9
text{* This document is for those Isabelle users who have mastered
nipkow@15337
    10
the art of mixing \LaTeX\ text and Isabelle theories and never want to
nipkow@15337
    11
typeset a theorem by hand anymore because they have experienced the
nipkow@15337
    12
bliss of writing \verb!@!\verb!{thm[display]setsum_cartesian_product[no_vars]}!
nipkow@15337
    13
and seeing Isabelle typeset it for them:
nipkow@15337
    14
@{thm[display,eta_contract=false] setsum_cartesian_product[no_vars]}
nipkow@15342
    15
No typos, no omissions, no sweat.
nipkow@15342
    16
If you have not experienced that joy, read Chapter 4, \emph{Presenting
nipkow@15342
    17
Theories}, \cite{LNCS2283} first.
nipkow@15337
    18
nipkow@15337
    19
If you have mastered the art of Isabelle's \emph{antiquotations},
nipkow@15337
    20
i.e.\ things like the above \verb!@!\verb!{thm...}!, beware: in your vanity
nipkow@15337
    21
you may be tempted to think that all readers of the stunning ps or pdf
nipkow@15337
    22
documents you can now produce at the drop of a hat will be struck with
nipkow@15337
    23
awe at the beauty unfolding in front of their eyes. Until one day you
nipkow@15337
    24
come across that very critical of readers known as the ``common referee''.
nipkow@15337
    25
He has the nasty habit of refusing to understand unfamiliar notation
nipkow@15337
    26
like Isabelle's infamous @{text"\<lbrakk> \<rbrakk> \<Longrightarrow>"} no matter how many times you
nipkow@15337
    27
explain it in your paper. Even worse, he thinks that using @{text"\<lbrakk>
nipkow@15337
    28
\<rbrakk>"} for anything other than denotational semantics is a cardinal sin
nipkow@15342
    29
that must be punished by instant rejection.
nipkow@15337
    30
nipkow@15337
    31
nipkow@15337
    32
This document shows you how to make Isabelle and \LaTeX\ cooperate to
nipkow@15337
    33
produce ordinary looking mathematics that hides the fact that it was
nipkow@15471
    34
typeset by a machine. You merely need to load the right files:
nipkow@15471
    35
\begin{itemize}
nipkow@15471
    36
\item Import theory \texttt{LaTeXsugar} in the header of your own
nipkow@15471
    37
theory.  You may also want bits of \texttt{OptionalSugar}, which you can
nipkow@15471
    38
copy selectively into your own theory or import as a whole.  Both
nipkow@15471
    39
theories live in \texttt{HOL/Library} and are found automatically.
kleing@15378
    40
nipkow@15471
    41
\item Should you need additional \LaTeX\ packages (the text will tell
nipkow@15471
    42
you so), you include them at the beginning of your \LaTeX\ document,
nipkow@15471
    43
typically in \texttt{root.tex}.
nipkow@15471
    44
\end{itemize}
nipkow@15342
    45
*}
nipkow@15342
    46
nipkow@15342
    47
section{* HOL syntax*}
nipkow@15342
    48
nipkow@15342
    49
subsection{* Logic *}
nipkow@15342
    50
nipkow@15342
    51
text{* The predefined constructs @{text"if"}, @{text"let"} and
nipkow@15342
    52
@{text"case"} are set in sans serif font to distinguish them from
nipkow@15342
    53
other functions. This improves readability:
nipkow@15342
    54
\begin{itemize}
nipkow@15342
    55
\item @{term"if b then e\<^isub>1 else e\<^isub>2"} instead of @{text"if b then e\<^isub>1 else e\<^isub>2"}.
nipkow@15342
    56
\item @{term"let x = e\<^isub>1 in e\<^isub>2"} instead of @{text"let x = e\<^isub>1 in e\<^isub>2"}.
nipkow@15342
    57
\item @{term"case x of True \<Rightarrow> e\<^isub>1 | False \<Rightarrow> e\<^isub>2"} instead of\\
nipkow@15342
    58
      @{text"case x of True \<Rightarrow> e\<^isub>1 | False \<Rightarrow> e\<^isub>2"}.
nipkow@15342
    59
\end{itemize}
nipkow@15342
    60
*}
nipkow@15342
    61
nipkow@15342
    62
subsection{* Sets *}
nipkow@15337
    63
nipkow@15342
    64
text{* Although set syntax in HOL is already close to
nipkow@15342
    65
standard, we provide a few further improvements:
nipkow@15342
    66
\begin{itemize}
nipkow@15342
    67
\item @{term"{x. P}"} instead of @{text"{x. P}"}.
nipkow@15342
    68
\item @{term"{}"} instead of @{text"{}"}.
nipkow@15342
    69
\item @{term"insert a (insert b (insert c M))"} instead of @{text"insert a (insert b (insert c M))"}.
nipkow@15342
    70
\end{itemize}
nipkow@15342
    71
*}
nipkow@15342
    72
nipkow@15342
    73
subsection{* Lists *}
nipkow@15342
    74
nipkow@15342
    75
text{* If lists are used heavily, the following notations increase readability:
nipkow@15342
    76
\begin{itemize}
nipkow@15342
    77
\item @{term"x # xs"} instead of @{text"x # xs"}.
nipkow@15342
    78
      Exceptionally, @{term"x # xs"} is also input syntax.
nipkow@15342
    79
If you prefer more space around the $\cdot$ you have to redefine
nipkow@15342
    80
\verb!\isasymcdot! in \LaTeX:
nipkow@15342
    81
\verb!\renewcommand{\isasymcdot}{\isamath{\,\cdot\,}}!
nipkow@15342
    82
nipkow@15342
    83
\item @{term"length xs"} instead of @{text"length xs"}.
kleing@15385
    84
\item @{term"nth xs n"} instead of @{text"nth xs n"},
nipkow@15342
    85
      the $n$th element of @{text xs}.
nipkow@15342
    86
kleing@15366
    87
\item The @{text"@"} operation associates implicitly to the right,
kleing@15366
    88
which leads to unpleasant line breaks if the term is too long for one
kleing@15366
    89
line. To avoid this, \texttt{OptionalSugar} contains syntax to group
kleing@15366
    90
@{text"@"}-terms to the left before printing, which leads to better
kleing@15366
    91
line breaking behaviour:
wenzelm@15673
    92
@{term[display]"term\<^isub>0 @ term\<^isub>1 @ term\<^isub>2 @ term\<^isub>3 @ term\<^isub>4 @ term\<^isub>5 @ term\<^isub>6 @ term\<^isub>7 @ term\<^isub>8 @ term\<^isub>9 @ term\<^isub>1\<^isub>0"}
kleing@15366
    93
nipkow@15342
    94
\end{itemize}
nipkow@15337
    95
*}
nipkow@15337
    96
nipkow@15337
    97
section "Printing theorems"
nipkow@15337
    98
nipkow@15689
    99
subsection "Question marks"
nipkow@15689
   100
nipkow@15689
   101
text{* If you print anything, especially theorems, containing
nipkow@15689
   102
schematic variables they are prefixed with a question mark:
nipkow@15689
   103
\verb!@!\verb!{thm conjI}! results in @{thm conjI}. Most of the time
nipkow@15689
   104
you would rather not see the question marks. There is an attribute
nipkow@15689
   105
\verb!no_vars! that you can attach to the theorem that turns its
nipkow@15689
   106
schematic into ordinary free variables: \verb!@!\verb!{thm conjI[no_vars]}!
nipkow@15689
   107
results in @{thm conjI[no_vars]}.
nipkow@15689
   108
nipkow@15689
   109
This \verb!no_vars! business can become a bit tedious.
nipkow@15689
   110
If you would rather never see question marks, simply put
nipkow@15689
   111
\begin{verbatim}
wenzelm@15983
   112
reset show_question_marks;
nipkow@15689
   113
\end{verbatim}
nipkow@15689
   114
at the beginning of your file \texttt{ROOT.ML}.
nipkow@15689
   115
The rest of this document is produced with this flag reset.
nipkow@16075
   116
nipkow@16075
   117
Hint: Resetting \verb!show_question_marks! only supresses question
nipkow@16075
   118
marks; variables that end in digits, e.g. @{text"x1"}, are still
nipkow@16075
   119
printed with a trailing @{text".0"}, e.g. @{text"x1.0"}, their
nipkow@16075
   120
internal index. This can be avoided by turning the last digit into a
nipkow@16075
   121
subscript: write \verb!x\<^isub>1! and obtain the much nicer @{text"x\<^isub>1"}. *}
nipkow@15689
   122
wenzelm@15983
   123
(*<*)ML"reset show_question_marks"(*>*)
nipkow@15689
   124
nipkow@15337
   125
subsection "Inference rules"
nipkow@15337
   126
nipkow@15342
   127
text{* To print theorems as inference rules you need to include Didier
nipkow@15342
   128
R\'emy's \texttt{mathpartir} package~\cite{mathpartir}
nipkow@15342
   129
for typesetting inference rules in your \LaTeX\ file.
nipkow@15337
   130
nipkow@15689
   131
Writing \verb!@!\verb!{thm[mode=Rule] conjI}! produces
nipkow@15689
   132
@{thm[mode=Rule] conjI}, even in the middle of a sentence.
nipkow@15342
   133
If you prefer your inference rule on a separate line, maybe with a name,
nipkow@15342
   134
\begin{center}
nipkow@15689
   135
@{thm[mode=Rule] conjI} {\sc conjI}
nipkow@15342
   136
\end{center}
nipkow@15342
   137
is produced by
nipkow@15337
   138
\begin{quote}
nipkow@15337
   139
\verb!\begin{center}!\\
nipkow@15689
   140
\verb!@!\verb!{thm[mode=Rule] conjI} {\sc conjI}!\\
nipkow@15337
   141
\verb!\end{center}!
nipkow@15337
   142
\end{quote}
nipkow@15342
   143
It is not recommended to use the standard \texttt{display} attribute
nipkow@15342
   144
together with \texttt{Rule} because centering does not work and because
nipkow@15342
   145
the line breaking mechanisms of \texttt{display} and \texttt{mathpartir} can
nipkow@15342
   146
clash.
nipkow@15342
   147
nipkow@15337
   148
Of course you can display multiple rules in this fashion:
nipkow@15337
   149
\begin{quote}
nipkow@15337
   150
\verb!\begin{center}\isastyle!\\
nipkow@15689
   151
\verb!@!\verb!{thm[mode=Rule] conjI} {\sc conjI} \\[1ex]!\\
nipkow@15689
   152
\verb!@!\verb!{thm[mode=Rule] conjE} {\sc disjI$_1$} \qquad!\\
nipkow@15689
   153
\verb!@!\verb!{thm[mode=Rule] disjE} {\sc disjI$_2$}!\\
nipkow@15337
   154
\verb!\end{center}!
nipkow@15337
   155
\end{quote}
nipkow@15337
   156
yields
nipkow@15337
   157
\begin{center}\isastyle
nipkow@15689
   158
@{thm[mode=Rule] conjI} {\sc conjI} \\[1ex]
nipkow@15689
   159
@{thm[mode=Rule] disjI1} {\sc disjI$_1$} \qquad
nipkow@15689
   160
@{thm[mode=Rule] disjI2} {\sc disjI$_2$}
nipkow@15337
   161
\end{center}
nipkow@15337
   162
Note that we included \verb!\isastyle! to obtain
nipkow@15337
   163
the smaller font that otherwise comes only with \texttt{display}.
nipkow@15337
   164
nipkow@15342
   165
The \texttt{mathpartir} package copes well if there are too many
nipkow@15342
   166
premises for one line:
nipkow@15342
   167
\begin{center}
nipkow@15342
   168
@{prop[mode=Rule] "\<lbrakk> A \<longrightarrow> B; B \<longrightarrow> C; C \<longrightarrow> D; D \<longrightarrow> E; E \<longrightarrow> F; F \<longrightarrow> G;
nipkow@15342
   169
 G \<longrightarrow> H; H \<longrightarrow> I; I \<longrightarrow> J; J \<longrightarrow> K \<rbrakk> \<Longrightarrow> A \<longrightarrow> K"}
nipkow@15342
   170
\end{center}
nipkow@15342
   171
nipkow@15471
   172
Limitations: 1. Premises and conclusion must each not be longer than
nipkow@15471
   173
the line.  2. Premises that are @{text"\<Longrightarrow>"}-implications are again
nipkow@15471
   174
displayed with a horizontal line, which looks at least unusual.
nipkow@15471
   175
nipkow@15337
   176
*}
nipkow@15342
   177
nipkow@15342
   178
subsection{*If-then*}
nipkow@15342
   179
nipkow@15342
   180
text{* If you prefer a fake ``natural language'' style you can produce
nipkow@15342
   181
the body of
nipkow@15342
   182
\newtheorem{theorem}{Theorem}
nipkow@15342
   183
\begin{theorem}
nipkow@15689
   184
@{thm[mode=IfThen] le_trans}
nipkow@15342
   185
\end{theorem}
nipkow@15342
   186
by typing
nipkow@15342
   187
\begin{quote}
nipkow@15689
   188
\verb!@!\verb!{thm[mode=IfThen] le_trans}!
nipkow@15342
   189
\end{quote}
nipkow@15342
   190
nipkow@15342
   191
In order to prevent odd line breaks, the premises are put into boxes.
nipkow@15342
   192
At times this is too drastic:
nipkow@15342
   193
\begin{theorem}
nipkow@15342
   194
@{prop[mode=IfThen] "longpremise \<Longrightarrow> longerpremise \<Longrightarrow> P(f(f(f(f(f(f(f(f(f(x)))))))))) \<Longrightarrow> longestpremise \<Longrightarrow> conclusion"}
nipkow@15342
   195
\end{theorem}
nipkow@15342
   196
In which case you should use \texttt{mode=IfThenNoBox} instead of
nipkow@15342
   197
\texttt{mode=IfThen}:
nipkow@15342
   198
\begin{theorem}
nipkow@15342
   199
@{prop[mode=IfThenNoBox] "longpremise \<Longrightarrow> longerpremise \<Longrightarrow> P(f(f(f(f(f(f(f(f(f(x)))))))))) \<Longrightarrow> longestpremise \<Longrightarrow> conclusion"}
nipkow@15342
   200
\end{theorem}
kleing@15366
   201
*}
nipkow@15342
   202
kleing@15366
   203
subsection "Patterns"
kleing@15366
   204
kleing@15366
   205
text {*
kleing@15366
   206
  Sometimes functions ignore one or more of their
kleing@15366
   207
  arguments and some functional languages have nice 
nipkow@15689
   208
  syntax for that as in @{thm hd.simps [where xs=DUMMY]}.
kleing@15366
   209
kleing@15366
   210
  You can simulate this in Isabelle by instantiating the @{term xs} in
nipkow@15689
   211
  definition \mbox{@{thm hd.simps}} with a constant @{text DUMMY} that
kleing@15366
   212
  is printed as @{term DUMMY}. The code for the pattern above is 
nipkow@15689
   213
  \verb!@!\verb!{thm hd.simps [where xs=DUMMY]}!.
kleing@15366
   214
kleing@15366
   215
  You can drive this game even further and extend the syntax of let
kleing@15366
   216
  bindings such that certain functions like @{term fst}, @{term hd}, 
kleing@15368
   217
  etc.\ are printed as patterns. \texttt{OptionalSugar} provides the
kleing@15368
   218
  following:
kleing@15366
   219
  
kleing@15366
   220
  \begin{center}
kleing@15366
   221
  \begin{tabular}{l@ {~~produced by~~}l}
kleing@15366
   222
  @{term "let x = fst p in t"} & \verb!@!\verb!{term "let x = fst p in t"}!\\
kleing@15366
   223
  @{term "let x = snd p in t"} & \verb!@!\verb!{term "let x = snd p in t"}!\\
kleing@15366
   224
  @{term "let x = hd xs in t"} & \verb!@!\verb!{term "let x = hd xs in t"}!\\
kleing@15366
   225
  @{term "let x = tl xs in t"} & \verb!@!\verb!{term "let x = tl xs in t"}!\\
kleing@15366
   226
  @{term "let x = the y in t"} & \verb!@!\verb!{term "let x = the y in t"}!\\
kleing@15366
   227
  \end{tabular}
kleing@15366
   228
  \end{center}
kleing@15366
   229
*}
kleing@15366
   230
kleing@15366
   231
subsection "Proofs"
kleing@15366
   232
kleing@15366
   233
text {*
kleing@15367
   234
  Full proofs, even if written in beautiful Isar style, are likely to
kleing@15366
   235
  be too long and detailed to be included in conference papers, but
kleing@15366
   236
  some key lemmas might be of interest.
kleing@15366
   237
kleing@15366
   238
  It is usually easiest to put them in figures like the one in Fig.\
kleing@15366
   239
  \ref{fig:proof}. This was achieved with the \isakeyword{text\_raw}
kleing@15366
   240
  command:
kleing@15366
   241
*}
kleing@15366
   242
text_raw {*
kleing@15366
   243
  \begin{figure}
kleing@15366
   244
  \begin{center}\begin{minipage}{0.6\textwidth}  
kleing@15428
   245
  \isastyle\isamarkuptrue
kleing@15366
   246
*}
kleing@15366
   247
lemma True
kleing@15366
   248
proof -
kleing@15366
   249
  -- "pretty trivial"
kleing@15366
   250
  show True by force
kleing@15366
   251
qed
kleing@15428
   252
text_raw {*    
kleing@15366
   253
  \end{minipage}\end{center}
kleing@15366
   254
  \caption{Example proof in a figure.}\label{fig:proof}
kleing@15366
   255
  \end{figure}
kleing@15366
   256
*}
kleing@15366
   257
text {*
kleing@15366
   258
kleing@15366
   259
\begin{quote}
kleing@15366
   260
\small
kleing@15366
   261
\verb!text_raw {!\verb!*!\\
kleing@15366
   262
\verb!  \begin{figure}!\\
kleing@15366
   263
\verb!  \begin{center}\begin{minipage}{0.6\textwidth}!\\
kleing@15428
   264
\verb!  \isastyle\isamarkuptrue!\\
kleing@15366
   265
\verb!*!\verb!}!\\
kleing@15366
   266
\verb!lemma True!\\
kleing@15366
   267
\verb!proof -!\\
kleing@15366
   268
\verb!  -- "pretty trivial"!\\
kleing@15366
   269
\verb!  show True by force!\\
kleing@15366
   270
\verb!qed!\\
kleing@15366
   271
\verb!text_raw {!\verb!*!\\
kleing@15366
   272
\verb!  \end{minipage}\end{center}!\\
kleing@15366
   273
\verb!  \caption{Example proof in a figure.}\label{fig:proof}!\\
kleing@15366
   274
\verb!  \end{figure}!\\
kleing@15366
   275
\verb!*!\verb!}!
kleing@15366
   276
\end{quote}
kleing@15366
   277
  
nipkow@15342
   278
*}
nipkow@15342
   279
haftmann@15917
   280
subsection "Styles"
haftmann@15917
   281
haftmann@15917
   282
text {*
nipkow@15953
   283
  The \verb!thm! antiquotation works nicely for single theorems, but
haftmann@15917
   284
  sets of equations as used in definitions are more difficult to
haftmann@16040
   285
  typeset nicely: people tend to prefer aligned @{text "="} signs.
haftmann@15917
   286
haftmann@15917
   287
  To deal with such cases where it is desirable to dive into the structure
haftmann@16040
   288
  of terms and theorems, Isabelle offers antiquotations featuring
haftmann@15917
   289
  ``styles'':
haftmann@15917
   290
haftmann@15917
   291
    \begin{quote}
haftmann@15917
   292
    \verb!@!\verb!{thm_style stylename thm}!\\
haftmann@15917
   293
    \verb!@!\verb!{term_style stylename term}!
haftmann@15917
   294
    \end{quote}
haftmann@15917
   295
haftmann@16040
   296
  A ``style'' is a transformation of propositions. There are predefined
kleing@16076
   297
  styles, namly \verb!lhs!, \verb!rhs! and \verb!conclusion!. For example, 
kleing@16076
   298
  the output
haftmann@15917
   299
  \begin{center}
haftmann@15917
   300
  \begin{tabular}{l@ {~~@{text "="}~~}l}
haftmann@15917
   301
  @{thm_style lhs foldl_Nil} & @{thm_style rhs foldl_Nil}\\
haftmann@15917
   302
  @{thm_style lhs foldl_Cons} & @{thm_style rhs foldl_Cons}
haftmann@15917
   303
  \end{tabular}
haftmann@15917
   304
  \end{center}
haftmann@15917
   305
  is produced by the following code:
haftmann@15917
   306
  \begin{quote}
haftmann@15917
   307
    \verb!\begin{center}!\\
haftmann@15917
   308
    \verb!\begin{tabular}{l@ {~~!\verb!@!\verb!{text "="}~~}l}!\\
haftmann@15917
   309
    \verb!@!\verb!{thm_style lhs foldl_Nil} & @!\verb!{thm_style rhs foldl_Nil}!\\
haftmann@15917
   310
    \verb!@!\verb!{thm_style lhs foldl_Cons} & @!\verb!{thm_style rhs foldl_Cons}!\\
haftmann@15917
   311
    \verb!\end{tabular}!\\
haftmann@15917
   312
    \verb!\end{center}!
haftmann@15917
   313
  \end{quote}
haftmann@15917
   314
  Note the space between \verb!@! and \verb!{! in the tabular argument.
haftmann@15917
   315
  It prevents Isabelle from interpreting \verb!@ {~~...~~}! 
kleing@16076
   316
  as an antiquotation. The styles \verb!lhs! and \verb!rhs!
haftmann@16040
   317
  extract the left hand side (or right hand side respectivly) from the
kleing@16076
   318
  conclusion of propositions consisting of a binary operator
haftmann@16040
   319
  (e.~g.~@{text "="}, @{text "\<equiv>"}, @{text "<"}).
haftmann@15917
   320
kleing@16076
   321
  Likewise, \verb!conclusion! may be used as a style to show just the
kleing@16076
   322
  conclusion of a proposition. For example, take \verb!hd_Cons_tl!:
haftmann@16040
   323
  \begin{center}
haftmann@16040
   324
    @{thm hd_Cons_tl}
haftmann@16040
   325
  \end{center}
haftmann@16040
   326
  To print just the conclusion,
haftmann@15917
   327
  \begin{center}
haftmann@15917
   328
    @{thm_style conclusion hd_Cons_tl}
haftmann@15917
   329
  \end{center}
haftmann@16040
   330
  type
haftmann@15917
   331
  \begin{quote}
haftmann@15917
   332
    \verb!\begin{center}!\\
haftmann@15917
   333
    \verb!@!\verb!{thm_style conclusion hd_Cons_tl}!\\
haftmann@15917
   334
    \verb!\end{center}!
haftmann@15917
   335
  \end{quote}
haftmann@15917
   336
nipkow@15953
   337
  If you are not afraid of ML, you may also define your own styles.
haftmann@15960
   338
  A style is implemented by an ML function of type
haftmann@15960
   339
  \verb!Proof.context -> term -> term!.
haftmann@15960
   340
  Have a look at the following example:
haftmann@15960
   341
haftmann@16040
   342
*}
nipkow@16075
   343
(*<*)
haftmann@16040
   344
setup {*
haftmann@16040
   345
let
haftmann@16040
   346
  fun my_concl ctxt = Logic.strip_imp_concl
haftmann@16040
   347
  in [TermStyle.add_style "my_concl" my_concl]
haftmann@16040
   348
end;
haftmann@16040
   349
*}
nipkow@16075
   350
(*>*)
haftmann@16040
   351
text {*
haftmann@16040
   352
haftmann@15917
   353
  \begin{quote}
haftmann@15917
   354
    \verb!setup {!\verb!*!\\
haftmann@15917
   355
    \verb!let!\\
haftmann@16040
   356
    \verb!  fun my_concl ctxt = Logic.strip_imp_concl!\\
haftmann@16040
   357
    \verb!  in [TermStyle.add_style "my_concl" my_concl]!\\
haftmann@15917
   358
    \verb!end;!\\
haftmann@15917
   359
    \verb!*!\verb!}!\\
haftmann@15917
   360
  \end{quote}
haftmann@15960
   361
kleing@16076
   362
  \noindent
kleing@16076
   363
  This example shows how the \verb!conclusion! style could have been implemented
kleing@16076
   364
  and may be used as as a ``copy-and-paste'' pattern to write your own styles.
kleing@16076
   365
  (The real implementation of \verb!conclusion! is a bit more sophisticated).
haftmann@15960
   366
kleing@16076
   367
  The code should go into your theory file, separate from the \LaTeX\ text.
haftmann@16040
   368
  The \verb!let! expression avoids polluting the
haftmann@15960
   369
  ML global namespace. Each style receives the current proof context
kleing@16076
   370
  as first argument; this is helpful in situations where the
kleing@16076
   371
  style has some object-logic specific behaviour for example.
haftmann@15960
   372
haftmann@15960
   373
  The mapping from identifier name to the style function
haftmann@16064
   374
  is done by the @{ML_idf TermStyle.add_style} expression which expects the desired
haftmann@15960
   375
  style name and the style function as arguments.
haftmann@15960
   376
  
haftmann@15960
   377
  After this \verb!setup!,
haftmann@16040
   378
  there will be a new style available named \verb!my_concl!, thus allowing
haftmann@16040
   379
  antiquoations like \verb!@!\verb!{thm_style my_concl hd_Cons_tl}!
haftmann@16040
   380
  yielding @{thm_style my_concl hd_Cons_tl}.
haftmann@15917
   381
haftmann@15917
   382
*}
haftmann@15917
   383
nipkow@15337
   384
(*<*)
nipkow@15337
   385
end
nipkow@15337
   386
(*>*)