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