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