99 |
99 |
100 \item [@{command chapter}, @{command section}, @{command |
100 \item [@{command chapter}, @{command section}, @{command |
101 subsection}, and @{command subsubsection}] mark chapter and section |
101 subsection}, and @{command subsubsection}] mark chapter and section |
102 headings within the main theory body or local theory targets. The |
102 headings within the main theory body or local theory targets. The |
103 corresponding {\LaTeX} macros are @{verbatim "\\isamarkupchapter"}, |
103 corresponding {\LaTeX} macros are @{verbatim "\\isamarkupchapter"}, |
104 @{verbatim "\\isamarkupsection"} etc. |
104 @{verbatim "\\isamarkupsection"}, @{verbatim |
|
105 "\\isamarkupsubsection"} etc. |
105 |
106 |
106 \item [@{command sect}, @{command subsect}, and @{command |
107 \item [@{command sect}, @{command subsect}, and @{command |
107 subsubsect}] mark section headings within proofs. The corresponding |
108 subsubsect}] mark section headings within proofs. The corresponding |
108 {\LaTeX} macros are @{verbatim "\\isamarkupsect"} etc. |
109 {\LaTeX} macros are @{verbatim "\\isamarkupsect"}, @{verbatim |
|
110 "\\isamarkupsubsect"} etc. |
109 |
111 |
110 \item [@{command text} and @{command txt}] specify paragraphs of |
112 \item [@{command text} and @{command txt}] specify paragraphs of |
111 plain text. This corresponds to a {\LaTeX} environment @{verbatim |
113 plain text. This corresponds to a {\LaTeX} environment @{verbatim |
112 "\\begin{isamarkuptext}"} @{text "\<dots>"} @{verbatim |
114 "\\begin{isamarkuptext}"} @{text "\<dots>"} @{verbatim |
113 "\\end{isamarkuptext}"} etc. |
115 "\\end{isamarkuptext}"} etc. |
119 |
121 |
120 \end{descr} |
122 \end{descr} |
121 |
123 |
122 Except for @{command "text_raw"} and @{command "txt_raw"}, the text |
124 Except for @{command "text_raw"} and @{command "txt_raw"}, the text |
123 passed to any of the above markup commands may refer to formal |
125 passed to any of the above markup commands may refer to formal |
124 entities via \emph{antiquotations}, see also \secref{sec:antiq}. |
126 entities via \emph{document antiquotations}, see also |
125 These are interpreted in the present theory or proof context, or the |
127 \secref{sec:antiq}. These are interpreted in the present theory or |
126 named @{text "target"}. |
128 proof context, or the named @{text "target"}. |
127 |
129 |
128 \medskip The proof markup commands closely resemble those for theory |
130 \medskip The proof markup commands closely resemble those for theory |
129 specifications, but have a different formal status and produce |
131 specifications, but have a different formal status and produce |
130 different {\LaTeX} macros (although the default definitions coincide |
132 different {\LaTeX} macros. The default definitions coincide for |
131 for analogous commands such as @{command section} and @{command |
133 analogous commands such as @{command section} and @{command sect}. |
132 sect}). |
134 *} |
133 *} |
135 |
134 |
136 |
135 |
137 section {* Document Antiquotations \label{sec:antiq} *} |
136 section {* Antiquotations \label{sec:antiq} *} |
|
137 |
138 |
138 text {* |
139 text {* |
139 \begin{matharray}{rcl} |
140 \begin{matharray}{rcl} |
140 @{antiquotation_def "theory"} & : & \isarantiq \\ |
141 @{antiquotation_def "theory"} & : & \isarantiq \\ |
141 @{antiquotation_def "thm"} & : & \isarantiq \\ |
142 @{antiquotation_def "thm"} & : & \isarantiq \\ |
156 @{antiquotation_def ML} & : & \isarantiq \\ |
157 @{antiquotation_def ML} & : & \isarantiq \\ |
157 @{antiquotation_def ML_type} & : & \isarantiq \\ |
158 @{antiquotation_def ML_type} & : & \isarantiq \\ |
158 @{antiquotation_def ML_struct} & : & \isarantiq \\ |
159 @{antiquotation_def ML_struct} & : & \isarantiq \\ |
159 \end{matharray} |
160 \end{matharray} |
160 |
161 |
161 The text body of formal comments (see also \secref{sec:comments}) |
162 The overall content of an Isabelle/Isar theory may alternate between |
162 may contain antiquotations of logical entities, such as theorems, |
163 formal and informal text. The main body consists of formal |
163 terms and types, which are to be presented in the final output |
164 specification and proof commands, interspersed with markup commands |
164 produced by the Isabelle document preparation system. |
165 (\secref{sec:markup}) or document comments (\secref{sec:comments}). |
165 |
166 The argument of markup commands quotes informal text to be printed |
166 Thus embedding of ``@{text [source=false] "@{term [show_types] \"f x = a + x\"}"}'' |
167 in the resulting document, but may again refer to formal entities |
167 within a text block would cause |
168 via \emph{document antiquotations}. |
168 \isa{{\isacharparenleft}f{\isasymColon}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharplus}\ x} to appear in the final {\LaTeX} document. Also note that theorem |
169 |
169 antiquotations may involve attributes as well. For example, |
170 For example, embedding of ``@{text [source=false] "@{term [show_types] \"f x = a + x\"}"}'' |
170 @{text "@{thm sym [no_vars]}"} would print the theorem's |
171 within a text block makes |
171 statement where all schematic variables have been replaced by fixed |
172 \isa{{\isacharparenleft}f{\isasymColon}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isacharparenleft}x{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}a{\isasymColon}{\isacharprime}a{\isacharparenright}\ {\isacharplus}\ x} appear in the final {\LaTeX} document. |
172 ones, which are easier to read. |
173 |
|
174 Antiquotations usually spare the author tedious typing of logical |
|
175 entities in full detail. Even more importantly, some degree of |
|
176 consistency-checking between the main body of formal text and its |
|
177 informal explanation is achieved, since terms and types appearing in |
|
178 antiquotations are checked within the current theory or proof |
|
179 context. |
173 |
180 |
174 \begin{rail} |
181 \begin{rail} |
175 atsign lbrace antiquotation rbrace |
182 atsign lbrace antiquotation rbrace |
176 ; |
183 ; |
177 |
184 |
201 option: name | name '=' name |
208 option: name | name '=' name |
202 ; |
209 ; |
203 \end{rail} |
210 \end{rail} |
204 |
211 |
205 Note that the syntax of antiquotations may \emph{not} include source |
212 Note that the syntax of antiquotations may \emph{not} include source |
206 comments @{verbatim "(*"}~@{text "\<dots>"}~@{verbatim "*)"} or verbatim |
213 comments @{verbatim "(*"}~@{text "\<dots>"}~@{verbatim "*)"} nor verbatim |
207 text @{verbatim "{"}@{verbatim "*"}~@{text "\<dots>"}~@{verbatim |
214 text @{verbatim "{"}@{verbatim "*"}~@{text "\<dots>"}~@{verbatim |
208 "*"}@{verbatim "}"}. |
215 "*"}@{verbatim "}"}. |
209 |
216 |
210 \begin{descr} |
217 \begin{descr} |
211 |
218 |
212 \item [@{text "@{theory A}"}] prints the name @{text "A"}, which is |
219 \item [@{text "@{theory A}"}] prints the name @{text "A"}, which is |
213 guaranteed to refer to a valid ancestor theory in the current |
220 guaranteed to refer to a valid ancestor theory in the current |
214 context. |
221 context. |
215 |
222 |
216 \item [@{text "@{thm a\<^sub>1 \<dots> a\<^sub>n}"}] prints theorems |
223 \item [@{text "@{thm a\<^sub>1 \<dots> a\<^sub>n}"}] prints theorems @{text "a\<^sub>1 \<dots> a\<^sub>n"}. |
217 @{text "a\<^sub>1 \<dots> a\<^sub>n"}. Note that attribute specifications |
224 Full fact expressions are allowed here, including attributes |
218 may be included as well (see also \secref{sec:syn-att}); the |
225 (\secref{sec:syn-att}). |
219 @{attribute_ref no_vars} rule (see \secref{sec:misc-meth-att}) would |
|
220 be particularly useful to suppress printing of schematic variables. |
|
221 |
226 |
222 \item [@{text "@{prop \<phi>}"}] prints a well-typed proposition @{text |
227 \item [@{text "@{prop \<phi>}"}] prints a well-typed proposition @{text |
223 "\<phi>"}. |
228 "\<phi>"}. |
224 |
229 |
225 \item [@{text "@{lemma \<phi> by m}"}] asserts a well-typed proposition @{text |
230 \item [@{text "@{lemma \<phi> by m}"}] proves a well-typed proposition |
226 "\<phi>"} to be provable by method @{text m} and prints @{text "\<phi>"}. |
231 @{text "\<phi>"} by method @{text m} and prints the original @{text "\<phi>"}. |
227 |
232 |
228 \item [@{text "@{term t}"}] prints a well-typed term @{text "t"}. |
233 \item [@{text "@{term t}"}] prints a well-typed term @{text "t"}. |
229 |
234 |
230 \item [@{text "@{const c}"}] prints a logical or syntactic constant |
235 \item [@{text "@{const c}"}] prints a logical or syntactic constant |
231 @{text "c"}. |
236 @{text "c"}. |
245 \item [@{text "@{term_style s t}"}] prints a well-typed term @{text |
250 \item [@{text "@{term_style s t}"}] prints a well-typed term @{text |
246 t} after applying a style @{text s} to it (see below). |
251 t} after applying a style @{text s} to it (see below). |
247 |
252 |
248 \item [@{text "@{text s}"}] prints uninterpreted source text @{text |
253 \item [@{text "@{text s}"}] prints uninterpreted source text @{text |
249 s}. This is particularly useful to print portions of text according |
254 s}. This is particularly useful to print portions of text according |
250 to the Isabelle {\LaTeX} output style, without demanding |
255 to the Isabelle document style, without demanding well-formedness, |
251 well-formedness (e.g.\ small pieces of terms that should not be |
256 e.g.\ small pieces of terms that should not be parsed or |
252 parsed or type-checked yet). |
257 type-checked yet. |
253 |
258 |
254 \item [@{text "@{goals}"}] prints the current \emph{dynamic} goal |
259 \item [@{text "@{goals}"}] prints the current \emph{dynamic} goal |
255 state. This is mainly for support of tactic-emulation scripts |
260 state. This is mainly for support of tactic-emulation scripts |
256 within Isar --- presentation of goal states does not conform to |
261 within Isar. Presentation of goal states does not conform to the |
257 actual human-readable proof documents. |
262 idea of human-readable proof documents! |
258 |
263 |
259 Please do not include goal states into document output unless you |
264 When explaining proofs in detail it is usually better to spell out |
260 really know what you are doing! |
265 the reasoning via proper Isar proof commands, instead of peeking at |
|
266 the internal machine configuration. |
261 |
267 |
262 \item [@{text "@{subgoals}"}] is similar to @{text "@{goals}"}, but |
268 \item [@{text "@{subgoals}"}] is similar to @{text "@{goals}"}, but |
263 does not print the main goal. |
269 does not print the main goal. |
264 |
270 |
265 \item [@{text "@{prf a\<^sub>1 \<dots> a\<^sub>n}"}] prints the (compact) |
271 \item [@{text "@{prf a\<^sub>1 \<dots> a\<^sub>n}"}] prints the (compact) proof terms |
266 proof terms corresponding to the theorems @{text "a\<^sub>1 \<dots> |
272 corresponding to the theorems @{text "a\<^sub>1 \<dots> a\<^sub>n"}. Note that this |
267 a\<^sub>n"}. Note that this requires proof terms to be switched on |
273 requires proof terms to be switched on for the current logic |
268 for the current object logic (see the ``Proof terms'' section of the |
274 session. |
269 Isabelle reference manual for information on how to do this). |
|
270 |
275 |
271 \item [@{text "@{full_prf a\<^sub>1 \<dots> a\<^sub>n}"}] is like @{text |
276 \item [@{text "@{full_prf a\<^sub>1 \<dots> a\<^sub>n}"}] is like @{text |
272 "@{prf a\<^sub>1 \<dots> a\<^sub>n}"}, but displays the full proof terms, |
277 "@{prf a\<^sub>1 \<dots> a\<^sub>n}"}, but prints the full proof terms, i.e.\ also |
273 i.e.\ also displays information omitted in the compact proof term, |
278 displays information omitted in the compact proof term, which is |
274 which is denoted by ``@{text _}'' placeholders there. |
279 denoted by ``@{text _}'' placeholders there. |
275 |
280 |
276 \item [@{text "@{ML s}"}, @{text "@{ML_type s}"}, and @{text |
281 \item [@{text "@{ML s}"}, @{text "@{ML_type s}"}, and @{text |
277 "@{ML_struct s}"}] check text @{text s} as ML value, type, and |
282 "@{ML_struct s}"}] check text @{text s} as ML value, type, and |
278 structure, respectively. The source is displayed verbatim. |
283 structure, respectively. The source is printed verbatim. |
279 |
284 |
280 \end{descr} |
285 \end{descr} |
281 |
286 *} |
282 \medskip The following standard styles for use with @{text |
287 |
283 thm_style} and @{text term_style} are available: |
288 |
|
289 subsubsection {* Styled antiquotations *} |
|
290 |
|
291 text {* Some antiquotations like @{text thm_style} and @{text |
|
292 term_style} admit an extra \emph{style} specification to modify the |
|
293 printed result. The following standard styles are available: |
284 |
294 |
285 \begin{descr} |
295 \begin{descr} |
286 |
296 |
287 \item [@{text lhs}] extracts the first argument of any application |
297 \item [@{text lhs}] extracts the first argument of any application |
288 form with at least two arguments -- typically meta-level or |
298 form with at least two arguments --- typically meta-level or |
289 object-level equality, or any other binary relation. |
299 object-level equality, or any other binary relation. |
290 |
300 |
291 \item [@{text rhs}] is like @{text lhs}, but extracts the second |
301 \item [@{text rhs}] is like @{text lhs}, but extracts the second |
292 argument. |
302 argument. |
293 |
303 |
297 \item [@{text "prem1"}, \dots, @{text "prem9"}] extract premise |
307 \item [@{text "prem1"}, \dots, @{text "prem9"}] extract premise |
298 number @{text "1, \<dots>, 9"}, respectively, from from a rule in |
308 number @{text "1, \<dots>, 9"}, respectively, from from a rule in |
299 Horn-clause normal form @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C"} |
309 Horn-clause normal form @{text "A\<^sub>1 \<Longrightarrow> \<dots> A\<^sub>n \<Longrightarrow> C"} |
300 |
310 |
301 \end{descr} |
311 \end{descr} |
302 |
312 *} |
303 \medskip |
313 |
304 The following options are available to tune the output. Note that most of |
314 |
305 these coincide with ML flags of the same names (see also \cite{isabelle-ref}). |
315 subsubsection {* General options *} |
|
316 |
|
317 text {* The following options are available to tune the printed output |
|
318 of antiquotations. Note that many of these coincide with global ML |
|
319 flags of the same names. |
306 |
320 |
307 \begin{descr} |
321 \begin{descr} |
308 |
322 |
309 \item[@{text "show_types = bool"} and @{text "show_sorts = bool"}] |
323 \item[@{text "show_types = bool"} and @{text "show_sorts = bool"}] |
310 control printing of explicit type and sort constraints. |
324 control printing of explicit type and sort constraints. |
345 default, including the modes @{text latex} and @{text xsymbols}. |
362 default, including the modes @{text latex} and @{text xsymbols}. |
346 |
363 |
347 \item[@{text "margin = nat"} and @{text "indent = nat"}] change the |
364 \item[@{text "margin = nat"} and @{text "indent = nat"}] change the |
348 margin or indentation for pretty printing of display material. |
365 margin or indentation for pretty printing of display material. |
349 |
366 |
350 \item[@{text "source = bool"}] prints the source text of the |
|
351 antiquotation arguments, rather than the actual value. Note that |
|
352 this does not affect well-formedness checks of @{antiquotation |
|
353 "thm"}, @{antiquotation "term"}, etc. (only the @{antiquotation |
|
354 "text"} antiquotation admits arbitrary output). |
|
355 |
|
356 \item[@{text "goals_limit = nat"}] determines the maximum number of |
367 \item[@{text "goals_limit = nat"}] determines the maximum number of |
357 goals to be printed. |
368 goals to be printed (for goal-based antiquotation). |
358 |
369 |
359 \item[@{text "locale = name"}] specifies an alternative locale |
370 \item[@{text "locale = name"}] specifies an alternative locale |
360 context used for evaluating and printing the subsequent argument. |
371 context used for evaluating and printing the subsequent argument. |
361 |
372 |
|
373 \item[@{text "source = bool"}] prints the original source text of |
|
374 the antiquotation arguments, rather than its internal |
|
375 representation. Note that formal checking of @{antiquotation |
|
376 "thm"}, @{antiquotation "term"}, etc. is still enabled; use the |
|
377 @{antiquotation "text"} antiquotation for unchecked output. |
|
378 |
|
379 Regular @{text "term"} and @{text "typ"} antiquotations with @{text |
|
380 "source = false"} involve a full round-trip from the original source |
|
381 to an internalized logical entity back to a source form, according |
|
382 to the syntax of the current context. Thus the printed output is |
|
383 not under direct control of the author, it may even fluctuate a bit |
|
384 as the underlying theory is changed later on. |
|
385 |
|
386 In contrast, @{text "source = true"} admits direct printing of the |
|
387 given source text, with the desirable well-formedness check in the |
|
388 background, but without modification of the printed text. |
|
389 |
362 \end{descr} |
390 \end{descr} |
363 |
391 |
364 For boolean flags, ``@{text "name = true"}'' may be abbreviated as |
392 For boolean flags, ``@{text "name = true"}'' may be abbreviated as |
365 ``@{text name}''. All of the above flags are disabled by default, |
393 ``@{text name}''. All of the above flags are disabled by default, |
366 unless changed from ML. |
394 unless changed from ML, say in the @{verbatim "ROOT.ML"} of the |
367 |
395 logic session. |
368 \medskip Note that antiquotations do not only spare the author from |
|
369 tedious typing of logical entities, but also achieve some degree of |
|
370 consistency-checking of informal explanations with formal |
|
371 developments: well-formedness of terms and types with respect to the |
|
372 current theory or proof context is ensured here. |
|
373 *} |
396 *} |
374 |
397 |
375 |
398 |
376 section {* Tagged commands \label{sec:tags} *} |
399 section {* Tagged commands \label{sec:tags} *} |
377 |
400 |