author | Norbert Schirmer <norbert.schirmer@web.de> |
Tue, 14 May 2019 17:10:47 +0200 | |
changeset 565 | cecd7a941885 |
parent 189 | 069d525f8f1d |
child 567 | f7c97e64cc2a |
permissions | -rw-r--r-- |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory Readme |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports Base |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
5 |
chapter \<open>Comments for Authors\<close> |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
7 |
text \<open> |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
|
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
\begin{itemize} |
106
bdd82350cf22
renamed in the pdf all instances of cookbook to tutorial (in order to sound more serious)
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
10 |
\item This tutorial can be compiled on the command-line with: |
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
11 |
|
65
c8e9a4f97916
tuned and added a section about creating keyword files
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
12 |
@{text [display] "$ isabelle make"} |
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
13 |
|
59 | 14 |
You very likely need a recent snapshot of Isabelle in order to compile |
106
bdd82350cf22
renamed in the pdf all instances of cookbook to tutorial (in order to sound more serious)
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
15 |
the tutorial. Some parts of the tutorial also rely on compilation with |
64
9a6e5e0c4906
deleted old files and added code to give a special tag to the command ML
Christian Urban <urbanc@in.tum.de>
parents:
60
diff
changeset
|
16 |
PolyML. |
59 | 17 |
|
49 | 18 |
\item You can include references to other Isabelle manuals using the |
47
4daf913fdbe1
hakked latex so that it does not display ML {* *}; general tuning
Christian Urban <urbanc@in.tum.de>
parents:
44
diff
changeset
|
19 |
reference names from those manuals. To do this the following |
54
1783211b3494
tuned; added document antiquotation ML_response_fake_both
Christian Urban <urbanc@in.tum.de>
parents:
53
diff
changeset
|
20 |
four \LaTeX{} commands are defined: |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
|
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
\begin{center} |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
\begin{tabular}{l|c|c} |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
& Chapters & Sections\\\hline |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
25 |
Implementation Manual & \<open>\ichcite{\<dots>}\<close> & \<open>\isccite{\<dots>}\<close>\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
26 |
Isar Reference Manual & \<open>\rchcite{\<dots>}\<close> & \<open>\rsccite{\<dots>}\<close>\\ |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
\end{tabular} |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
\end{center} |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
30 |
So \<open>\ichcite{ch:logic}\<close> yields a reference for the chapter about logic |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
in the implementation manual, namely \ichcite{ch:logic}. |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
|
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
\item There are various document antiquotations defined for the |
106
bdd82350cf22
renamed in the pdf all instances of cookbook to tutorial (in order to sound more serious)
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
34 |
tutorial. They allow to check the written text against the current |
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
35 |
Isabelle code and also allow to show responses of the ML-compiler. |
52 | 36 |
Therefore authors are strongly encouraged to use antiquotations wherever |
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
37 |
appropriate. |
52 | 38 |
|
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
39 |
The following antiquotations are defined: |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
|
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
\begin{itemize} |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
42 |
\item[$\bullet$] \<open>@{ML "expr" for vars in structs}\<close> should be used |
58 | 43 |
for displaying any ML-ex\-pression, because the antiquotation checks whether |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
44 |
the expression is valid ML-code. The \<open>for\<close>- and \<open>in\<close>-arguments are optional. The former is used for evaluating open |
58 | 45 |
expressions by giving a list of free variables. The latter is used to |
46 |
indicate in which structure or structures the ML-expression should be |
|
47 |
evaluated. Examples are: |
|
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
48 |
|
54
1783211b3494
tuned; added document antiquotation ML_response_fake_both
Christian Urban <urbanc@in.tum.de>
parents:
53
diff
changeset
|
49 |
\begin{center}\small |
58 | 50 |
\begin{tabular}{lll} |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
51 |
\<open>@{ML "1 + 3"}\<close> & & @{ML "1 + 3"}\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
52 |
\<open>@{ML "a + b" for a b}\<close> & \;\;produce\;\; & @{ML "a + b" for a b}\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
53 |
\<open>@{ML Ident in OuterLex}\<close> & & @{ML Ident in OuterLex}\\ |
58 | 54 |
\end{tabular} |
55 |
\end{center} |
|
56 |
||
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
57 |
\item[$\bullet$] \<open>@{ML_response "expr" "pat"}\<close> should be used to |
58 | 58 |
display ML-expressions and their response. The first expression is checked |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
59 |
like in the antiquotation \<open>@{ML "expr"}\<close>; the second is a pattern |
58 | 60 |
that specifies the result the first expression produces. This pattern can |
59 | 61 |
contain @{text [quotes] "\<dots>"} for parts that you like to omit. The response of the |
58 | 62 |
first expression will be checked against this pattern. Examples are: |
63 |
||
64 |
\begin{center}\small |
|
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
65 |
\begin{tabular}{l} |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
66 |
\<open>@{ML_response "1+2" "3"}\<close>\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
67 |
\<open>@{ML_response "(1+2,3)" "(3,\<dots>)"}\<close> |
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
68 |
\end{tabular} |
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
69 |
\end{center} |
52 | 70 |
|
58 | 71 |
which produce respectively |
72 |
||
73 |
\begin{center}\small |
|
74 |
\begin{tabular}{p{3cm}p{3cm}} |
|
75 |
@{ML_response "1+2" "3"} & |
|
76 |
@{ML_response "(1+2,3)" "(3,\<dots>)"} |
|
77 |
\end{tabular} |
|
78 |
\end{center} |
|
79 |
||
80 |
Note that this antiquotation can only be used when the result can be |
|
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
81 |
constructed: it does not work when the code produces an exception or returns |
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
82 |
an abstract datatype (like @{ML_type thm} or @{ML_type cterm}). |
49 | 83 |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
84 |
\item[$\bullet$] \<open>@{ML_response_fake "expr" "pat"}\<close> works just |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
85 |
like the antiquotation \<open>@{ML_response "expr" "pat"}\<close> above, |
58 | 86 |
except that the result-specification is not checked. Use this antiquotation |
87 |
when the result cannot be constructed or the code generates an |
|
88 |
exception. Examples are: |
|
89 |
||
90 |
\begin{center}\small |
|
91 |
\begin{tabular}{ll} |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
92 |
\<open>@{ML_response_fake\<close> & \<open>"cterm_of @{theory} @{term \"a + b = c\"}"}\<close>\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
93 |
& \<open>"a + b = c"}\<close>\smallskip\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
94 |
\<open>@{ML_response_fake\<close> & \<open>"($$ \"x\") (explode \"world\")"\<close>\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
95 |
& \<open>"Exception FAIL raised"}\<close> |
58 | 96 |
\end{tabular} |
97 |
\end{center} |
|
98 |
||
59 | 99 |
which produce respectively |
100 |
||
101 |
\begin{center}\small |
|
102 |
\begin{tabular}{p{7.2cm}} |
|
103 |
@{ML_response_fake "cterm_of @{theory} @{term \"a + b = c\"}" "a + b = c"}\smallskip\\ |
|
104 |
@{ML_response_fake "($$ \"x\") (explode \"world\")" "Exception FAIL raised"} |
|
105 |
\end{tabular} |
|
106 |
\end{center} |
|
54
1783211b3494
tuned; added document antiquotation ML_response_fake_both
Christian Urban <urbanc@in.tum.de>
parents:
53
diff
changeset
|
107 |
|
59 | 108 |
This output mimics to some extend what the user sees when running the |
109 |
code. |
|
110 |
||
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
111 |
\item[$\bullet$] \<open>@{ML_response_fake_both "expr" "pat"}\<close> can be |
54
1783211b3494
tuned; added document antiquotation ML_response_fake_both
Christian Urban <urbanc@in.tum.de>
parents:
53
diff
changeset
|
112 |
used to show erroneous code. Neither the code nor the response will be |
58 | 113 |
checked. An example is: |
52 | 114 |
|
58 | 115 |
\begin{center}\small |
116 |
\begin{tabular}{ll} |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
117 |
\<open>@{ML_response_fake_both\<close> & \<open>"@{cterm \"1 + True\"}"\<close>\\ |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
118 |
& \<open>"Type unification failed \<dots>"}\<close> |
58 | 119 |
\end{tabular} |
120 |
\end{center} |
|
121 |
||
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
122 |
\item[$\bullet$] \<open>@{ML_file "name"}\<close> should be used when |
59 | 123 |
referring to a file. It checks whether the file exists. An example |
124 |
is |
|
125 |
||
126 |
@{text [display] "@{ML_file \"Pure/General/basics.ML\"}"} |
|
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
\end{itemize} |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
129 |
The listed antiquotations honour options including \<open>[display]\<close> and |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
130 |
\<open>[quotes]\<close>. For example |
58 | 131 |
|
132 |
\begin{center}\small |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
133 |
\<open>@{ML [quotes] "\"foo\" ^ \"bar\""}\<close> \;\;produces\;\; @{text [quotes] "foobar"} |
58 | 134 |
\end{center} |
135 |
||
59 | 136 |
whereas |
58 | 137 |
|
138 |
\begin{center}\small |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
139 |
\<open>@{ML "\"foo\" ^ \"bar\""}\<close> \;\;produces only\;\; \<open>foobar\<close> |
58 | 140 |
\end{center} |
141 |
||
49 | 142 |
\item Functions and value bindings cannot be defined inside antiquotations; they need |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
143 |
to be included inside \isacommand{ML}~\<open>\<verbopen> \<dots> \<verbclose>\<close> |
58 | 144 |
environments. In this way they are also checked by the compiler. Some \LaTeX-hack in |
106
bdd82350cf22
renamed in the pdf all instances of cookbook to tutorial (in order to sound more serious)
Christian Urban <urbanc@in.tum.de>
parents:
104
diff
changeset
|
145 |
the tutorial, however, ensures that the environment markers are not printed. |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
|
53
0c3580c831a4
removed the @{ML ...} antiquotation in favour of @{ML_open ...x}
Christian Urban <urbanc@in.tum.de>
parents:
52
diff
changeset
|
147 |
\item Line numbers can be printed using |
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
148 |
\isacommand{ML} \isa{\%linenos}~\<open>\<verbopen> \<dots> \<verbclose>\<close> |
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
149 |
for ML-code or \isacommand{lemma} \isa{\%linenos} \<open>...\<close> for proofs. The |
114
13fd0a83d3c3
properly handled linenumbers in ML-text and Isar-proofs
Christian Urban <urbanc@in.tum.de>
parents:
106
diff
changeset
|
150 |
tag is \isa{\%linenosgray} when the numbered text should be gray. |
52 | 151 |
|
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
\end{itemize} |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
|
565
cecd7a941885
isabelle update_cartouches -t
Norbert Schirmer <norbert.schirmer@web.de>
parents:
189
diff
changeset
|
154 |
\<close> |
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
|
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
|
49 | 157 |
|
44
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
end |