author | Christian Urban <urbanc@in.tum.de> |
Tue, 20 Jul 2010 13:34:44 +0100 | |
changeset 440 | a0b280dd4bc7 |
parent 435 | 524b72520c43 |
child 441 | 520127b708e6 |
permissions | -rw-r--r-- |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory Intro |
75 | 2 |
imports Base |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
346
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
5 |
(*<*) |
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
6 |
setup{* |
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
7 |
open_file_with_prelude |
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
8 |
"Intro_Code.thy" |
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
9 |
["theory Intro", "imports Main", "begin"] |
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
10 |
*} |
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
11 |
(*>*) |
0fea8b7a14a1
tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents:
343
diff
changeset
|
12 |
|
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
chapter {* Introduction *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
text {* |
295
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
16 |
\begin{flushright} |
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
17 |
{\em |
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
18 |
``My thesis is that programming is not at the bottom of the intellectual \\ |
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
19 |
pyramid, but at the top. It's creative design of the highest order. It \\ |
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
20 |
isn't monkey or donkey work; rather, as Edsger Dijkstra famously \\ |
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
21 |
claimed, it's amongst the hardest intellectual tasks ever attempted.''} \\[1ex] |
324
4172c0743cf2
updated foobar_proof example
Christian Urban <urbanc@in.tum.de>
parents:
306
diff
changeset
|
22 |
Richard Bornat, In {\em Defence of Programming}. \cite{Bornat-lecture} |
295
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
23 |
\end{flushright} |
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
24 |
|
24c68350d059
polished the package chapter used FOCUS to explain the subproofs
Christian Urban <urbanc@in.tum.de>
parents:
293
diff
changeset
|
25 |
\medskip |
89 | 26 |
If your next project requires you to program on the ML-level of Isabelle, |
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:
102
diff
changeset
|
27 |
then this tutorial is for you. It will guide you through the first steps of |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
28 |
Isabelle programming, and also explain ``tricks of the trade''. We also hope |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
29 |
the tutorial will encourage students and researchers to play with Isabelle |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
30 |
and implement new ideas. The source code of Isabelle can look intimidating, |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
31 |
but beginners can get by with knowledge of only a small number functions and |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
32 |
a few basic coding conventions. |
356 | 33 |
|
34 |
||
35 |
The best way to get to know the ML-level of Isabelle is by experimenting |
|
36 |
with the many code examples included in the tutorial. The code is as far as |
|
37 |
possible checked against the Isabelle |
|
38 |
distribution.\footnote{\input{version}} If something does not work, then |
|
39 |
please let us know. It is impossible for us to know every environment, |
|
40 |
operating system or editor in which Isabelle is used. If you have comments, |
|
41 |
criticism or like to add to the tutorial, please feel free---you are most |
|
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
42 |
welcome!! The tutorial is meant to be gentle and comprehensive. To achieve |
414 | 43 |
this we need your help and feedback. |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
section {* Intended Audience and Prior Knowledge *} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
text {* |
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:
102
diff
changeset
|
49 |
This tutorial targets readers who already know how to use Isabelle for |
75 | 50 |
writing theories and proofs. We also assume that readers are familiar with |
51 |
the functional programming language ML, the language in which most of |
|
52 |
Isabelle is implemented. If you are unfamiliar with either of these two |
|
329 | 53 |
subjects, then you should first work through the Isabelle/HOL tutorial |
75 | 54 |
\cite{isa-tutorial} or Paulson's book on ML \cite{paulson-ml2}. |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
|
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
57 |
section {* Existing Documentation *} |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
text {* |
43
02f76f1b6e7b
added positions to anti-quotations; removed old antiquotation_setup; tuned the text a bit
Christian Urban <urbanc@in.tum.de>
parents:
42
diff
changeset
|
60 |
The following documentation about Isabelle programming already exists (and is |
02f76f1b6e7b
added positions to anti-quotations; removed old antiquotation_setup; tuned the text a bit
Christian Urban <urbanc@in.tum.de>
parents:
42
diff
changeset
|
61 |
part of the distribution of Isabelle): |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
|
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
\begin{description} |
162
3fb9f820a294
some additions to the simplifier section and general tuning
Christian Urban <urbanc@in.tum.de>
parents:
156
diff
changeset
|
64 |
\item[The Isabelle/Isar Implementation Manual] describes Isabelle |
414 | 65 |
from a high-level perspective, documenting some of the underlying |
66 |
concepts and interfaces. |
|
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
|
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
68 |
\item[The Isabelle Reference Manual] is an older document that used |
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:
43
diff
changeset
|
69 |
to be the main reference of Isabelle at a time when all proof scripts |
89 | 70 |
were written on the ML-level. Many parts of this manual are outdated |
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:
43
diff
changeset
|
71 |
now, but some parts, particularly the chapters on tactics, are still |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
43
diff
changeset
|
72 |
useful. |
dee4b3e66dfe
added a readme chapter for prospective authors; added commands for referring to the Isar Reference Manual
Christian Urban <urbanc@in.tum.de>
parents:
43
diff
changeset
|
73 |
|
153
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
74 |
\item[The Isar Reference Manual] provides specification material (like grammars, |
298 | 75 |
examples and so on) about Isar and its implementation. |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
76 |
\end{description} |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
|
234 | 78 |
Then of course there are: |
5
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
79 |
|
e91f54791e14
minor modifiations to the Intro and FirstSteps chapters
Christian Urban <urbanc@in.tum.de>
parents:
2
diff
changeset
|
80 |
\begin{description} |
234 | 81 |
\item[The Isabelle sources.] They are the ultimate reference for how |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
things really work. Therefore you should not hesitate to look at the |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
way things are actually implemented. More importantly, it is often |
89 | 84 |
good to look at code that does similar things as you want to do and |
329 | 85 |
learn from it. This tutorial contains frequently pointers to the |
86 |
Isabelle sources. Still, the UNIX command \mbox{@{text "grep -R"}} is |
|
414 | 87 |
often your best friend while programming with Isabelle.\footnote{Or |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
88 |
hypersearch if you work with jEdit under MacOSX.} To understand the sources, |
263
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
89 |
it is often also necessary to track the change history of a file or |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
90 |
files. The Mercurial repository\footnote{\url{http://isabelle.in.tum.de/repos/isabelle/}} |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
91 |
for Isabelle provides convenient interfaces to query the history of |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
92 |
files and ``change sets''. |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
\end{description} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
*} |
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
|
252 | 96 |
section {* Typographic Conventions *} |
68
e7519207c2b7
added more to the "new command section" and tuning
Christian Urban <urbanc@in.tum.de>
parents:
66
diff
changeset
|
97 |
|
e7519207c2b7
added more to the "new command section" and tuning
Christian Urban <urbanc@in.tum.de>
parents:
66
diff
changeset
|
98 |
text {* |
181
5baaabe1ab92
updated to new method_setup
Christian Urban <urbanc@in.tum.de>
parents:
180
diff
changeset
|
99 |
All ML-code in this tutorial is typeset in shaded boxes, like the following |
329 | 100 |
simple ML-expression: |
75 | 101 |
|
102 |
\begin{isabelle} |
|
103 |
\begin{graybox} |
|
85
b02904872d6b
better handling of {* and *}
Christian Urban <urbanc@in.tum.de>
parents:
84
diff
changeset
|
104 |
\isacommand{ML}~@{text "\<verbopen>"}\isanewline |
75 | 105 |
\hspace{5mm}@{ML "3 + 4"}\isanewline |
85
b02904872d6b
better handling of {* and *}
Christian Urban <urbanc@in.tum.de>
parents:
84
diff
changeset
|
106 |
@{text "\<verbclose>"} |
75 | 107 |
\end{graybox} |
108 |
\end{isabelle} |
|
109 |
||
195
7305beb69893
corrected typos + some small reformulations
griff@colo2-c703.uibk.ac.at
parents:
192
diff
changeset
|
110 |
These boxes correspond to how code can be processed inside the interactive |
343 | 111 |
environment of Isabelle. It is therefore easy to experiment with the code |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
112 |
that is shown in this tutorial. However, for better readability we will drop |
343 | 113 |
the enclosing \isacommand{ML}~@{text "\<verbopen> \<dots> \<verbclose>"} and just |
114 |
write: |
|
81 | 115 |
|
75 | 116 |
@{ML [display,gray] "3 + 4"} |
117 |
||
89 | 118 |
Whenever appropriate we also show the response the code |
81 | 119 |
generates when evaluated. This response is prefixed with a |
108
8bea3f74889d
added to the tactical chapter; polished; added the tabularstar environment (which is just tabular*)
Christian Urban <urbanc@in.tum.de>
parents:
107
diff
changeset
|
120 |
@{text [quotes] ">"}, like: |
75 | 121 |
|
122 |
@{ML_response [display,gray] "3 + 4" "7"} |
|
123 |
||
195
7305beb69893
corrected typos + some small reformulations
griff@colo2-c703.uibk.ac.at
parents:
192
diff
changeset
|
124 |
The user-level commands of Isabelle (i.e., the non-ML code) are written |
7305beb69893
corrected typos + some small reformulations
griff@colo2-c703.uibk.ac.at
parents:
192
diff
changeset
|
125 |
in \isacommand{bold face} (e.g., \isacommand{lemma}, \isacommand{apply}, |
7305beb69893
corrected typos + some small reformulations
griff@colo2-c703.uibk.ac.at
parents:
192
diff
changeset
|
126 |
\isacommand{foobar} and so on). We use @{text "$ \<dots>"} to indicate that a |
234 | 127 |
command needs to be run in a UNIX-shell, for example: |
75 | 128 |
|
181
5baaabe1ab92
updated to new method_setup
Christian Urban <urbanc@in.tum.de>
parents:
180
diff
changeset
|
129 |
@{text [display] "$ grep -R ThyOutput *"} |
75 | 130 |
|
89 | 131 |
Pointers to further information and Isabelle files are typeset in |
195
7305beb69893
corrected typos + some small reformulations
griff@colo2-c703.uibk.ac.at
parents:
192
diff
changeset
|
132 |
\textit{italic} and highlighted as follows: |
75 | 133 |
|
134 |
\begin{readmore} |
|
102
5e309df58557
general cleaning up; deleted antiquotation ML_text; adjusted pathnames of various files in the distribution
Christian Urban <urbanc@in.tum.de>
parents:
101
diff
changeset
|
135 |
Further information or pointers to files. |
75 | 136 |
\end{readmore} |
137 |
||
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
138 |
Note that pointers to Isabelle files are hyperlinked to the tip of the Mercurial |
414 | 139 |
repository at \href{http://isabelle.in.tum.de/repos/isabelle/} |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
140 |
{http://isabelle.in.tum.de/repos/isabelle/}, not the latest stable release |
414 | 141 |
of Isabelle. |
182
4d0e2edd476d
added hyperlinks for every file pointer
Christian Urban <urbanc@in.tum.de>
parents:
181
diff
changeset
|
142 |
|
177 | 143 |
A few exercises are scattered around the text. Their solutions are given |
156 | 144 |
in Appendix~\ref{ch:solutions}. Of course, you learn most, if you first try |
162
3fb9f820a294
some additions to the simplifier section and general tuning
Christian Urban <urbanc@in.tum.de>
parents:
156
diff
changeset
|
145 |
to solve the exercises on your own, and then look at the solutions. |
233
61085dd44e8c
added a section about naming conventions
Christian Urban <urbanc@in.tum.de>
parents:
228
diff
changeset
|
146 |
*} |
156 | 147 |
|
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
148 |
section {* How To Understand Isabelle Code *} |
421
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
149 |
|
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
150 |
text {* |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
151 |
One of the more difficult aspects of any kind of programming is to understand code |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
152 |
written by somebody else. This is aggravated in Isabelle by the fact that many parts of |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
153 |
the code contain none or only few comments. There is one strategy that might be |
421
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
154 |
helpful to navigate your way: ML is an interactive programming environment, |
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
155 |
which means you can evaluate code on the fly (for example inside an |
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
156 |
\isacommand{ML}~@{text "\<verbopen>\<dots>\<verbclose>"} section). So you can copy |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
157 |
(self-contained) chunks of existing code into a separate theory file and then |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
158 |
study it alongside with examples. You can also install ``probes'' inside the |
421
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
159 |
copied code without having to recompile the whole Isabelle distributions. Such |
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
160 |
probes might be messages or printouts of variables (see chapter |
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
161 |
\ref{chp:firststeps}). Although PolyML also contains a debugger, it seems |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
162 |
probing the code with explicit print statements is the most effective method |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
163 |
for understanding what some piece of code is doing. However do not expect quick |
421
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
164 |
results with this! Depending on the size of the code you are looking at, |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
165 |
you will spend the better part of a quiet afternoon with it. And there |
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
166 |
seems to be no better way for understanding code in Isabelle. |
421
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
167 |
*} |
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
168 |
|
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
169 |
|
263
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
170 |
section {* Aaaaargh! My Code Does not Work Anymore *} |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
171 |
|
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
172 |
text {* |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
173 |
One unpleasant aspect of any code development inside a larger system is that |
440
a0b280dd4bc7
partially moved from string_of_term to pretty_term
Christian Urban <urbanc@in.tum.de>
parents:
435
diff
changeset
|
174 |
one has to aim at a ``moving target''. Isabelle is no exception of this. Every |
263
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
175 |
update lets potentially all hell break loose, because other developers have |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
176 |
changed code you are relying on. Cursing is somewhat helpful in such situations, |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
177 |
but taking the view that incompatible code changes are a fact of life |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
178 |
might be more gratifying. Isabelle is a research project. In most circumstances |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
179 |
it is just impossible to make research backward compatible (imagine Darwin |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
180 |
attempting to make the Theory of Evolution backward compatible). |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
181 |
|
329 | 182 |
However, there are a few steps you can take to mitigate unwanted |
183 |
interferences with code changes from other developers. First, you can base |
|
184 |
your code on the latest stable release of Isabelle (it is aimed to have one |
|
185 |
such release at least once every year). This might cut you off from the |
|
186 |
latest feature implemented in Isabelle, but at least you do not have to |
|
187 |
track side-steps or dead-ends in the Isabelle development. Of course this |
|
188 |
means also you have to synchronise your code at the next stable release. If |
|
189 |
you do not synchronise, be warned that code seems to ``rot'' very |
|
190 |
quickly. Another possibility is to get your code into the Isabelle |
|
191 |
distribution. For this you have to convince other developers that your code |
|
192 |
or project is of general interest. If you managed to do this, then the |
|
193 |
problem of the moving target goes away, because when checking in new code, |
|
194 |
developers are strongly urged to test it against Isabelle's code base. If |
|
195 |
your project is part of that code base, then maintenance is done by |
|
196 |
others. Unfortunately, this might not be a helpful advice for all types of |
|
197 |
projects. A lower threshold for inclusion has the Archive of Formalised |
|
198 |
Proofs, short AFP.\footnote{\url{http://afp.sourceforge.net/}} This archive |
|
199 |
has been created mainly for formalisations that are interesting but not |
|
200 |
necessarily of general interest. If you have ML-code as part of a |
|
201 |
formalisation, then this might be the right place for you. There is no |
|
202 |
problem with updating your code after submission. At the moment developers |
|
203 |
are not as diligent with checking their code against the AFP than with |
|
204 |
checking agains the distribution, but generally problems will be caught and |
|
205 |
the developer, who caused them, is expected to fix them. So also in this |
|
206 |
case code maintenance is done for you. |
|
263
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
207 |
*} |
195c4444dff7
added section about code maintenance and added an example for antiquotations
Christian Urban <urbanc@in.tum.de>
parents:
262
diff
changeset
|
208 |
|
252 | 209 |
section {* Some Naming Conventions in the Isabelle Sources *} |
233
61085dd44e8c
added a section about naming conventions
Christian Urban <urbanc@in.tum.de>
parents:
228
diff
changeset
|
210 |
|
61085dd44e8c
added a section about naming conventions
Christian Urban <urbanc@in.tum.de>
parents:
228
diff
changeset
|
211 |
text {* |
254 | 212 |
There are a few naming conventions in the Isabelle code that might aid reading |
213 |
and writing code. (Remember that code is written once, but read many |
|
233
61085dd44e8c
added a section about naming conventions
Christian Urban <urbanc@in.tum.de>
parents:
228
diff
changeset
|
214 |
times.) The most important conventions are: |
61085dd44e8c
added a section about naming conventions
Christian Urban <urbanc@in.tum.de>
parents:
228
diff
changeset
|
215 |
|
61085dd44e8c
added a section about naming conventions
Christian Urban <urbanc@in.tum.de>
parents:
228
diff
changeset
|
216 |
\begin{itemize} |
302 | 217 |
\item @{text t}, @{text u}, @{text trm} for (raw) terms; ML-type: @{ML_type term} |
234 | 218 |
\item @{text ct}, @{text cu} for certified terms; ML-type: @{ML_type cterm} |
219 |
\item @{text "ty"}, @{text T}, @{text U} for (raw) types; ML-type: @{ML_type typ} |
|
390
8ad407e77ea0
added example by Lukas Bulwahn
Christian Urban <urbanc@in.tum.de>
parents:
358
diff
changeset
|
220 |
\item @{text "S"} for sorts; ML-type: @{ML_type sort} |
234 | 221 |
\item @{text th}, @{text thm} for theorems; ML-type: @{ML_type thm} |
222 |
\item @{text "foo_tac"} for tactics; ML-type: @{ML_type tactic} |
|
223 |
\item @{text thy} for theories; ML-type: @{ML_type theory} |
|
224 |
\item @{text ctxt} for proof contexts; ML-type: @{ML_type Proof.context} |
|
225 |
\item @{text lthy} for local theories; ML-type: @{ML_type local_theory} |
|
226 |
\item @{text context} for generic contexts; ML-type @{ML_type Context.generic} |
|
235
dc955603d813
explained uses and use commands
Christian Urban <urbanc@in.tum.de>
parents:
234
diff
changeset
|
227 |
\item @{text mx} for mixfix syntax annotations; ML-type @{ML_type mixfix} |
248
11851b20fb78
added more to the pretty section and updated the acknowledgements
Christian Urban <urbanc@in.tum.de>
parents:
235
diff
changeset
|
228 |
\item @{text prt} for pretty printing; ML-type @{ML_type Pretty.T} |
425 | 229 |
\item @{text phi} for morphisms; ML-type @{ML_type morphism} |
233
61085dd44e8c
added a section about naming conventions
Christian Urban <urbanc@in.tum.de>
parents:
228
diff
changeset
|
230 |
\end{itemize} |
68
e7519207c2b7
added more to the "new command section" and tuning
Christian Urban <urbanc@in.tum.de>
parents:
66
diff
changeset
|
231 |
*} |
e7519207c2b7
added more to the "new command section" and tuning
Christian Urban <urbanc@in.tum.de>
parents:
66
diff
changeset
|
232 |
|
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
233 |
section {* Acknowledgements *} |
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
234 |
|
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
235 |
text {* |
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
236 |
Financial support for this tutorial was provided by the German |
122 | 237 |
Research Council (DFG) under grant number URB 165/5-1. The following |
156 | 238 |
people contributed to the text: |
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
239 |
|
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
240 |
\begin{itemize} |
122 | 241 |
\item {\bf Stefan Berghofer} wrote nearly all of the ML-code of the |
242 |
\simpleinductive-package and the code for the @{text |
|
414 | 243 |
"chunk"}-antiquotation. He also wrote the first version of chapter |
244 |
\ref{chp:package} describing this package and has been helpful \emph{beyond |
|
245 |
measure} with answering questions about Isabelle. |
|
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
246 |
|
248
11851b20fb78
added more to the pretty section and updated the acknowledgements
Christian Urban <urbanc@in.tum.de>
parents:
235
diff
changeset
|
247 |
\item {\bf Jasmin Blanchette} helped greatly with section \ref{sec:pretty}. |
11851b20fb78
added more to the pretty section and updated the acknowledgements
Christian Urban <urbanc@in.tum.de>
parents:
235
diff
changeset
|
248 |
|
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
249 |
\item {\bf Sascha Böhme} contributed the recipes in \ref{rec:timeout}, |
328
c0cae24b9d46
updated to new Isabelle; more work on the data section
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
250 |
\ref{rec:external} and \ref{rec:oracle}. He also wrote section \ref{sec:conversion} |
329 | 251 |
and helped with recipe \ref{rec:timing}. Parts of section \ref{sec:storing} |
328
c0cae24b9d46
updated to new Isabelle; more work on the data section
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
252 |
are by him. |
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
253 |
|
414 | 254 |
\item {\bf Lukas Bulwahn} made me aware of a problem with recursive |
392
47e5b71c7f6c
modified the typ-pretty-printer and added parser exercise
Christian Urban <urbanc@in.tum.de>
parents:
390
diff
changeset
|
255 |
parsers and contributed exercise \ref{ex:contextfree}. |
390
8ad407e77ea0
added example by Lukas Bulwahn
Christian Urban <urbanc@in.tum.de>
parents:
358
diff
changeset
|
256 |
|
414 | 257 |
\item {\bf Jeremy Dawson} wrote the first version of chapter \ref{chp:parsing} |
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
258 |
about parsing. |
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
259 |
|
180
9c25418db6f0
added a recipy about SAT solvers
Christian Urban <urbanc@in.tum.de>
parents:
177
diff
changeset
|
260 |
\item {\bf Armin Heller} helped with recipe \ref{rec:sat}. |
9c25418db6f0
added a recipy about SAT solvers
Christian Urban <urbanc@in.tum.de>
parents:
177
diff
changeset
|
261 |
|
414 | 262 |
\item {\bf Alexander Krauss} wrote a very early version of the ``first-steps'' |
343 | 263 |
chapter and also contributed the material on @{ML_funct Named_Thms}. |
194 | 264 |
|
427
94538ddcac9b
added example from Tobias and changed the title
Christian Urban <urbanc@in.tum.de>
parents:
425
diff
changeset
|
265 |
\item {\bf Tobias Nipkow} contributed recipe \ref{rec:callml}. |
94538ddcac9b
added example from Tobias and changed the title
Christian Urban <urbanc@in.tum.de>
parents:
425
diff
changeset
|
266 |
|
417
5f00958e3c7b
typos fixed by Michael Norrish
Christian Urban <urbanc@in.tum.de>
parents:
414
diff
changeset
|
267 |
\item {\bf Michael Norrish} proofread parts of the text. |
5f00958e3c7b
typos fixed by Michael Norrish
Christian Urban <urbanc@in.tum.de>
parents:
414
diff
changeset
|
268 |
|
435 | 269 |
\item {\bf Andreas Schropp} improved and corrected section \ref{sec:univ} and |
270 |
contributed towards section \ref{sec:sorts}. |
|
271 |
||
207 | 272 |
\item {\bf Christian Sternagel} proofread the tutorial and made |
293
0a567f923b42
slightly changed exercises about rev_sum
Christian Urban <urbanc@in.tum.de>
parents:
265
diff
changeset
|
273 |
many improvemets to the text. |
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
274 |
\end{itemize} |
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
275 |
|
121 | 276 |
Please let me know of any omissions. Responsibility for any remaining |
153
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
277 |
errors lies with me.\bigskip |
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
278 |
|
421
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
279 |
\newpage |
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
280 |
\mbox{}\\[5cm] |
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
281 |
|
620a24bf954a
added a section to the introduction; described @{make_string}
Christian Urban <urbanc@in.tum.de>
parents:
417
diff
changeset
|
282 |
|
153
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
283 |
{\Large\bf |
335
163ac0662211
reorganised the certified terms section; tuned
Christian Urban <urbanc@in.tum.de>
parents:
329
diff
changeset
|
284 |
This tutorial is still in the process of being written! All of the |
192 | 285 |
text is still under construction. Sections and |
153
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
286 |
chapters that are under \underline{heavy} construction are marked |
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
287 |
with TBD.} |
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
288 |
|
c22b507e1407
general polishing; added versioning to the document
Christian Urban <urbanc@in.tum.de>
parents:
151
diff
changeset
|
289 |
\vfill |
306
fe732e890d87
tuned the section about printing several bits of inormation
Christian Urban <urbanc@in.tum.de>
parents:
303
diff
changeset
|
290 |
|
fe732e890d87
tuned the section about printing several bits of inormation
Christian Urban <urbanc@in.tum.de>
parents:
303
diff
changeset
|
291 |
This document (version \input{tip}\hspace{-0.5ex}) was compiled with:\\ |
228 | 292 |
\input{version}\\ |
293 |
\input{pversion} |
|
119
4536782969fa
added an acknowledgement section
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
294 |
*} |
2
978a3c2ed7ce
split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
|
195
7305beb69893
corrected typos + some small reformulations
griff@colo2-c703.uibk.ac.at
parents:
192
diff
changeset
|
296 |
end |