author | wenzelm |
Wed, 04 Jun 2008 16:44:08 +0200 | |
changeset 27080 | 0ee385433247 |
parent 27079 | 61ac01ff0aa9 |
child 27506 | c99c72458ec5 |
permissions | -rw-r--r-- |
27063 | 1 |
% |
2 |
\begin{isabellebody}% |
|
3 |
\def\isabellecontext{Examples{\isadigit{3}}}% |
|
4 |
% |
|
5 |
\isadelimtheory |
|
27080 | 6 |
\isanewline |
7 |
\isanewline |
|
27063 | 8 |
% |
9 |
\endisadelimtheory |
|
10 |
% |
|
11 |
\isatagtheory |
|
27080 | 12 |
\isacommand{theory}\isamarkupfalse% |
13 |
\ Examples{\isadigit{3}}\isanewline |
|
14 |
\isakeyword{imports}\ Examples\isanewline |
|
15 |
\isakeyword{begin}% |
|
27063 | 16 |
\endisatagtheory |
17 |
{\isafoldtheory}% |
|
18 |
% |
|
19 |
\isadelimtheory |
|
20 |
% |
|
21 |
\endisadelimtheory |
|
22 |
% |
|
23 |
\isamarkupsubsection{Third Version: Local Interpretation% |
|
24 |
} |
|
25 |
\isamarkuptrue% |
|
26 |
% |
|
27 |
\begin{isamarkuptext}% |
|
28 |
In the above example, the fact that \isa{{\isasymle}} is a partial |
|
29 |
order for the natural numbers was used in the proof of the |
|
30 |
second goal. In general, proofs of the equations may involve |
|
31 |
theorems implied by the fact the assumptions of the instantiated |
|
32 |
locale hold for the instantiating structure. If these theorems have |
|
33 |
been shown abstractly in the locale they can be made available |
|
34 |
conveniently in the context through an auxiliary local interpretation (keyword |
|
35 |
\isakeyword{interpret}). This interpretation is inside the proof of the global |
|
36 |
interpretation. The third revision of the example illustrates this.% |
|
37 |
\end{isamarkuptext}% |
|
38 |
\isamarkuptrue% |
|
39 |
% |
|
40 |
\isadelimvisible |
|
41 |
% |
|
42 |
\endisadelimvisible |
|
43 |
% |
|
44 |
\isatagvisible |
|
45 |
\isacommand{interpretation}\isamarkupfalse% |
|
46 |
\ nat{\isacharcolon}\ partial{\isacharunderscore}order\ {\isacharbrackleft}{\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\isanewline |
|
47 |
\ \ \isakeyword{where}\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}less\ {\isacharparenleft}op\ {\isasymle}{\isacharparenright}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
48 |
\isacommand{proof}\isamarkupfalse% |
|
49 |
\ {\isacharminus}\isanewline |
|
50 |
\ \ \isacommand{show}\isamarkupfalse% |
|
51 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order\ {\isacharparenleft}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
52 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
53 |
\ unfold{\isacharunderscore}locales\ auto\isanewline |
|
54 |
\ \ \isacommand{then}\isamarkupfalse% |
|
55 |
\ \isacommand{interpret}\isamarkupfalse% |
|
56 |
\ nat{\isacharcolon}\ partial{\isacharunderscore}order\ {\isacharbrackleft}{\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ {\isacharbrackleft}nat{\isacharcomma}\ nat{\isacharbrackright}\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\ \isacommand{{\isachardot}}\isamarkupfalse% |
|
57 |
\isanewline |
|
58 |
\ \ \isacommand{show}\isamarkupfalse% |
|
59 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}less\ {\isacharparenleft}op\ {\isasymle}{\isacharparenright}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
60 |
\ \ \ \ \isacommand{unfolding}\isamarkupfalse% |
|
61 |
\ nat{\isachardot}less{\isacharunderscore}def\ \isacommand{by}\isamarkupfalse% |
|
62 |
\ auto\isanewline |
|
63 |
\isacommand{qed}\isamarkupfalse% |
|
64 |
% |
|
65 |
\endisatagvisible |
|
66 |
{\isafoldvisible}% |
|
67 |
% |
|
68 |
\isadelimvisible |
|
69 |
% |
|
70 |
\endisadelimvisible |
|
71 |
% |
|
72 |
\begin{isamarkuptext}% |
|
73 |
The inner interpretation does not require an |
|
74 |
elaborate new proof, it is immediate from the preceeding fact and |
|
75 |
proved with ``.''. |
|
76 |
This interpretation enriches the local proof context by |
|
77 |
the very theorems also obtained in the interpretation from |
|
78 |
Section~\ref{sec:po-first}, and \isa{nat{\isachardot}less{\isacharunderscore}def} may directly be |
|
79 |
used to unfold the definition. Theorems from the local |
|
80 |
interpretation disappear after leaving the proof context --- that |
|
81 |
is, after the closing \isakeyword{qed} --- and are |
|
82 |
then replaced by those with the desired substitutions of the strict |
|
83 |
order.% |
|
84 |
\end{isamarkuptext}% |
|
85 |
\isamarkuptrue% |
|
86 |
% |
|
87 |
\isamarkupsubsection{Further Interpretations% |
|
88 |
} |
|
89 |
\isamarkuptrue% |
|
90 |
% |
|
91 |
\begin{isamarkuptext}% |
|
92 |
Further interpretations are necessary to reuse theorems from |
|
93 |
the other locales. In \isa{lattice} the operations \isa{{\isasymsqinter}} and |
|
94 |
\isa{{\isasymsqunion}} are substituted by \isa{min} and |
|
95 |
\isa{max}. The entire proof for the |
|
96 |
interpretation is reproduced in order to give an example of a more |
|
97 |
elaborate interpretation proof.% |
|
98 |
\end{isamarkuptext}% |
|
99 |
\isamarkuptrue% |
|
100 |
% |
|
101 |
\isadelimvisible |
|
102 |
% |
|
103 |
\endisadelimvisible |
|
104 |
% |
|
105 |
\isatagvisible |
|
106 |
\isacommand{interpretation}\isamarkupfalse% |
|
107 |
\ nat{\isacharcolon}\ lattice\ {\isacharbrackleft}{\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\isanewline |
|
108 |
\ \ \isakeyword{where}\ {\isachardoublequoteopen}lattice{\isachardot}meet\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ min\ x\ y{\isachardoublequoteclose}\isanewline |
|
109 |
\ \ \ \ \isakeyword{and}\ {\isachardoublequoteopen}lattice{\isachardot}join\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ max\ x\ y{\isachardoublequoteclose}\isanewline |
|
110 |
\isacommand{proof}\isamarkupfalse% |
|
111 |
\ {\isacharminus}\isanewline |
|
112 |
\ \ \isacommand{show}\isamarkupfalse% |
|
113 |
\ {\isachardoublequoteopen}lattice\ {\isacharparenleft}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isacharparenright}{\isachardoublequoteclose}% |
|
114 |
\begin{isamarkuptxt}% |
|
115 |
We have already shown that this is a partial order,% |
|
116 |
\end{isamarkuptxt}% |
|
117 |
\isamarkuptrue% |
|
118 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
119 |
\ unfold{\isacharunderscore}locales% |
|
120 |
\begin{isamarkuptxt}% |
|
121 |
hence only the lattice axioms remain to be shown: \begin{isabelle}% |
|
122 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ {\isasymexists}inf{\isachardot}\ partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}inf\ op\ {\isasymle}\ x\ y\ inf\isanewline |
|
123 |
\ {\isadigit{2}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ {\isasymexists}sup{\isachardot}\ partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}sup\ op\ {\isasymle}\ x\ y\ sup% |
|
124 |
\end{isabelle} After unfolding \isa{is{\isacharunderscore}inf} and \isa{is{\isacharunderscore}sup},% |
|
125 |
\end{isamarkuptxt}% |
|
126 |
\isamarkuptrue% |
|
127 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
128 |
\ {\isacharparenleft}unfold\ nat{\isachardot}is{\isacharunderscore}inf{\isacharunderscore}def\ nat{\isachardot}is{\isacharunderscore}sup{\isacharunderscore}def{\isacharparenright}% |
|
129 |
\begin{isamarkuptxt}% |
|
130 |
the goals become \begin{isabelle}% |
|
131 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ {\isasymexists}inf{\isasymle}x{\isachardot}\ inf\ {\isasymle}\ y\ {\isasymand}\ {\isacharparenleft}{\isasymforall}z{\isachardot}\ z\ {\isasymle}\ x\ {\isasymand}\ z\ {\isasymle}\ y\ {\isasymlongrightarrow}\ z\ {\isasymle}\ inf{\isacharparenright}\isanewline |
|
132 |
\ {\isadigit{2}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ {\isasymexists}sup{\isasymge}x{\isachardot}\ y\ {\isasymle}\ sup\ {\isasymand}\ {\isacharparenleft}{\isasymforall}z{\isachardot}\ x\ {\isasymle}\ z\ {\isasymand}\ y\ {\isasymle}\ z\ {\isasymlongrightarrow}\ sup\ {\isasymle}\ z{\isacharparenright}% |
|
133 |
\end{isabelle} which can be solved |
|
134 |
by Presburger arithmetic.% |
|
135 |
\end{isamarkuptxt}% |
|
136 |
\isamarkuptrue% |
|
137 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
138 |
\ arith{\isacharplus}% |
|
139 |
\begin{isamarkuptxt}% |
|
140 |
In order to show the equations, we put ourselves in a |
|
141 |
situation where the lattice theorems can be used in a convenient way.% |
|
142 |
\end{isamarkuptxt}% |
|
143 |
\isamarkuptrue% |
|
144 |
\ \ \isacommand{then}\isamarkupfalse% |
|
145 |
\ \isacommand{interpret}\isamarkupfalse% |
|
146 |
\ nat{\isacharcolon}\ lattice\ {\isacharbrackleft}{\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\ \isacommand{{\isachardot}}\isamarkupfalse% |
|
147 |
\isanewline |
|
148 |
\ \ \isacommand{show}\isamarkupfalse% |
|
149 |
\ {\isachardoublequoteopen}lattice{\isachardot}meet\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ min\ x\ y{\isachardoublequoteclose}\isanewline |
|
150 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
151 |
\ {\isacharparenleft}bestsimp\ simp{\isacharcolon}\ nat{\isachardot}meet{\isacharunderscore}def\ nat{\isachardot}is{\isacharunderscore}inf{\isacharunderscore}def{\isacharparenright}\isanewline |
|
152 |
\ \ \isacommand{show}\isamarkupfalse% |
|
153 |
\ {\isachardoublequoteopen}lattice{\isachardot}join\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ max\ x\ y{\isachardoublequoteclose}\isanewline |
|
154 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
155 |
\ {\isacharparenleft}bestsimp\ simp{\isacharcolon}\ nat{\isachardot}join{\isacharunderscore}def\ nat{\isachardot}is{\isacharunderscore}sup{\isacharunderscore}def{\isacharparenright}\isanewline |
|
156 |
\isacommand{qed}\isamarkupfalse% |
|
157 |
% |
|
158 |
\endisatagvisible |
|
159 |
{\isafoldvisible}% |
|
160 |
% |
|
161 |
\isadelimvisible |
|
162 |
% |
|
163 |
\endisadelimvisible |
|
164 |
% |
|
165 |
\begin{isamarkuptext}% |
|
166 |
That the relation \isa{{\isasymle}} is a total order completes this |
|
167 |
sequence of interpretations.% |
|
168 |
\end{isamarkuptext}% |
|
169 |
\isamarkuptrue% |
|
170 |
% |
|
171 |
\isadelimvisible |
|
172 |
% |
|
173 |
\endisadelimvisible |
|
174 |
% |
|
175 |
\isatagvisible |
|
176 |
\isacommand{interpretation}\isamarkupfalse% |
|
177 |
\ nat{\isacharcolon}\ total{\isacharunderscore}order\ {\isacharbrackleft}{\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\isanewline |
|
178 |
\ \ \isacommand{by}\isamarkupfalse% |
|
179 |
\ unfold{\isacharunderscore}locales\ arith% |
|
180 |
\endisatagvisible |
|
181 |
{\isafoldvisible}% |
|
182 |
% |
|
183 |
\isadelimvisible |
|
184 |
% |
|
185 |
\endisadelimvisible |
|
186 |
% |
|
187 |
\begin{isamarkuptext}% |
|
188 |
Theorems that are available in the theory at this point are shown in |
|
189 |
Table~\ref{tab:nat-lattice}. |
|
190 |
||
191 |
\begin{table} |
|
192 |
\hrule |
|
193 |
\vspace{2ex} |
|
194 |
\begin{center} |
|
195 |
\begin{tabular}{l} |
|
196 |
\isa{nat{\isachardot}less{\isacharunderscore}def} from locale \isa{partial{\isacharunderscore}order}: \\ |
|
197 |
\quad \isa{{\isacharparenleft}{\isacharquery}x\ {\isacharless}\ {\isacharquery}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isacharquery}x\ {\isasymle}\ {\isacharquery}y\ {\isasymand}\ {\isacharquery}x\ {\isasymnoteq}\ {\isacharquery}y{\isacharparenright}} \\ |
|
198 |
\isa{nat{\isachardot}meet{\isacharunderscore}left} from locale \isa{lattice}: \\ |
|
199 |
\quad \isa{min\ {\isacharquery}x\ {\isacharquery}y\ {\isasymle}\ {\isacharquery}x} \\ |
|
200 |
\isa{nat{\isachardot}join{\isacharunderscore}distr} from locale \isa{distrib{\isacharunderscore}lattice}: \\ |
|
201 |
\quad \isa{max\ {\isacharquery}x\ {\isacharparenleft}min\ {\isacharquery}y\ {\isacharquery}z{\isacharparenright}\ {\isacharequal}\ min\ {\isacharparenleft}max\ {\isacharquery}x\ {\isacharquery}y{\isacharparenright}\ {\isacharparenleft}max\ {\isacharquery}x\ {\isacharquery}z{\isacharparenright}} \\ |
|
202 |
\isa{nat{\isachardot}less{\isacharunderscore}total} from locale \isa{total{\isacharunderscore}order}: \\ |
|
203 |
\quad \isa{{\isacharquery}x\ {\isacharless}\ {\isacharquery}y\ {\isasymor}\ {\isacharquery}x\ {\isacharequal}\ {\isacharquery}y\ {\isasymor}\ {\isacharquery}y\ {\isacharless}\ {\isacharquery}x} |
|
204 |
\end{tabular} |
|
205 |
\end{center} |
|
206 |
\hrule |
|
207 |
\caption{Interpreted theorems for \isa{{\isasymle}} on the natural numbers.} |
|
208 |
\label{tab:nat-lattice} |
|
209 |
\end{table} |
|
210 |
||
211 |
Note that since the locale hierarchy reflects that total orders are |
|
212 |
distributive lattices, an explicit interpretation of distributive |
|
213 |
lattices for the order relation on natural numbers is not neccessary. |
|
214 |
||
215 |
Why not push this idea further and just give the last interpretation |
|
216 |
as a single interpretation instead of the sequence of three? The |
|
217 |
reasons for this are twofold: |
|
218 |
\begin{itemize} |
|
219 |
\item |
|
220 |
Often it is easier to work in an incremental fashion, because later |
|
221 |
interpretations require theorems provided by earlier |
|
222 |
interpretations. |
|
223 |
\item |
|
224 |
Assume that a definition is made in some locale $l_1$, and that $l_2$ |
|
225 |
imports $l_1$. Let an equation for the definition be |
|
226 |
proved in an interpretation of $l_2$. The equation will be unfolded |
|
227 |
in interpretations of theorems added to $l_2$ or below in the import |
|
228 |
hierarchy, but not for theorems added above $l_2$. |
|
229 |
Hence, an equation interpreting a definition should always be given in |
|
230 |
an interpretation of the locale where the definition is made, not in |
|
231 |
an interpretation of a locale further down the hierarchy. |
|
232 |
\end{itemize}% |
|
233 |
\end{isamarkuptext}% |
|
234 |
\isamarkuptrue% |
|
235 |
% |
|
236 |
\isamarkupsubsection{Lattice \isa{dvd} on \isa{nat}% |
|
237 |
} |
|
238 |
\isamarkuptrue% |
|
239 |
% |
|
240 |
\begin{isamarkuptext}% |
|
241 |
Divisibility on the natural numbers is a distributive lattice |
|
242 |
but not a total order. Interpretation again proceeds |
|
243 |
incrementally.% |
|
244 |
\end{isamarkuptext}% |
|
245 |
\isamarkuptrue% |
|
246 |
\isacommand{interpretation}\isamarkupfalse% |
|
247 |
\ nat{\isacharunderscore}dvd{\isacharcolon}\ partial{\isacharunderscore}order\ {\isacharbrackleft}{\isachardoublequoteopen}op\ dvd\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\isanewline |
|
248 |
\ \ \isakeyword{where}\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}less\ op\ dvd\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ {\isacharparenleft}x\ dvd\ y\ {\isasymand}\ x\ {\isasymnoteq}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
249 |
% |
|
250 |
\isadelimproof |
|
251 |
% |
|
252 |
\endisadelimproof |
|
253 |
% |
|
254 |
\isatagproof |
|
255 |
\isacommand{proof}\isamarkupfalse% |
|
256 |
\ {\isacharminus}\isanewline |
|
257 |
\ \ \isacommand{show}\isamarkupfalse% |
|
258 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order\ {\isacharparenleft}op\ dvd\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
259 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
260 |
\ unfold{\isacharunderscore}locales\ {\isacharparenleft}auto\ simp{\isacharcolon}\ dvd{\isacharunderscore}def{\isacharparenright}\isanewline |
|
261 |
\ \ \isacommand{then}\isamarkupfalse% |
|
262 |
\ \isacommand{interpret}\isamarkupfalse% |
|
263 |
\ nat{\isacharunderscore}dvd{\isacharcolon}\ partial{\isacharunderscore}order\ {\isacharbrackleft}{\isachardoublequoteopen}op\ dvd\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\ \isacommand{{\isachardot}}\isamarkupfalse% |
|
264 |
\isanewline |
|
265 |
\ \ \isacommand{show}\isamarkupfalse% |
|
266 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}less\ op\ dvd\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ {\isacharparenleft}x\ dvd\ y\ {\isasymand}\ x\ {\isasymnoteq}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
267 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
268 |
\ {\isacharparenleft}unfold\ nat{\isacharunderscore}dvd{\isachardot}less{\isacharunderscore}def{\isacharparenright}\isanewline |
|
269 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
270 |
\ auto\isanewline |
|
271 |
\ \ \ \ \isacommand{done}\isamarkupfalse% |
|
272 |
\isanewline |
|
273 |
\isacommand{qed}\isamarkupfalse% |
|
274 |
% |
|
275 |
\endisatagproof |
|
276 |
{\isafoldproof}% |
|
277 |
% |
|
278 |
\isadelimproof |
|
279 |
% |
|
280 |
\endisadelimproof |
|
281 |
% |
|
282 |
\begin{isamarkuptext}% |
|
283 |
Note that there is no symbol for strict divisibility. Instead, |
|
284 |
interpretation substitutes \isa{x\ dvd\ y\ {\isasymand}\ x\ {\isasymnoteq}\ y}.% |
|
285 |
\end{isamarkuptext}% |
|
286 |
\isamarkuptrue% |
|
287 |
\isacommand{interpretation}\isamarkupfalse% |
|
288 |
\ nat{\isacharunderscore}dvd{\isacharcolon}\ lattice\ {\isacharbrackleft}{\isachardoublequoteopen}op\ dvd\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\isanewline |
|
289 |
\ \ \isakeyword{where}\ nat{\isacharunderscore}dvd{\isacharunderscore}meet{\isacharunderscore}eq{\isacharcolon}\isanewline |
|
290 |
\ \ \ \ \ \ {\isachardoublequoteopen}lattice{\isachardot}meet\ op\ dvd\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ gcd\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
291 |
\ \ \ \ \isakeyword{and}\ nat{\isacharunderscore}dvd{\isacharunderscore}join{\isacharunderscore}eq{\isacharcolon}\isanewline |
|
292 |
\ \ \ \ \ \ {\isachardoublequoteopen}lattice{\isachardot}join\ op\ dvd\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ lcm\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
293 |
% |
|
294 |
\isadelimproof |
|
295 |
% |
|
296 |
\endisadelimproof |
|
297 |
% |
|
298 |
\isatagproof |
|
299 |
\isacommand{proof}\isamarkupfalse% |
|
300 |
\ {\isacharminus}\isanewline |
|
301 |
\ \ \isacommand{show}\isamarkupfalse% |
|
302 |
\ {\isachardoublequoteopen}lattice\ {\isacharparenleft}op\ dvd\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
303 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
304 |
\ unfold{\isacharunderscore}locales\isanewline |
|
305 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
306 |
\ {\isacharparenleft}unfold\ nat{\isacharunderscore}dvd{\isachardot}is{\isacharunderscore}inf{\isacharunderscore}def\ nat{\isacharunderscore}dvd{\isachardot}is{\isacharunderscore}sup{\isacharunderscore}def{\isacharparenright}\isanewline |
|
307 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
308 |
\ {\isacharparenleft}rule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequoteopen}gcd\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardoublequoteclose}\ \isakeyword{in}\ exI{\isacharparenright}\isanewline |
|
309 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
310 |
\ auto\ {\isacharbrackleft}{\isadigit{1}}{\isacharbrackright}\isanewline |
|
311 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
312 |
\ {\isacharparenleft}rule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequoteopen}lcm\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardoublequoteclose}\ \isakeyword{in}\ exI{\isacharparenright}\isanewline |
|
313 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
314 |
\ {\isacharparenleft}auto\ intro{\isacharcolon}\ lcm{\isacharunderscore}dvd{\isadigit{1}}\ lcm{\isacharunderscore}dvd{\isadigit{2}}\ lcm{\isacharunderscore}least{\isacharparenright}\isanewline |
|
315 |
\ \ \ \ \isacommand{done}\isamarkupfalse% |
|
316 |
\isanewline |
|
317 |
\ \ \isacommand{then}\isamarkupfalse% |
|
318 |
\ \isacommand{interpret}\isamarkupfalse% |
|
319 |
\ nat{\isacharunderscore}dvd{\isacharcolon}\ lattice\ {\isacharbrackleft}{\isachardoublequoteopen}op\ dvd\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\ \isacommand{{\isachardot}}\isamarkupfalse% |
|
320 |
\isanewline |
|
321 |
\ \ \isacommand{show}\isamarkupfalse% |
|
322 |
\ {\isachardoublequoteopen}lattice{\isachardot}meet\ op\ dvd\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ gcd\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
323 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
324 |
\ {\isacharparenleft}unfold\ nat{\isacharunderscore}dvd{\isachardot}meet{\isacharunderscore}def{\isacharparenright}\isanewline |
|
325 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
326 |
\ {\isacharparenleft}rule\ the{\isacharunderscore}equality{\isacharparenright}\isanewline |
|
327 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
328 |
\ {\isacharparenleft}unfold\ nat{\isacharunderscore}dvd{\isachardot}is{\isacharunderscore}inf{\isacharunderscore}def{\isacharparenright}\isanewline |
|
329 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
330 |
\ auto\isanewline |
|
331 |
\ \ \isacommand{show}\isamarkupfalse% |
|
332 |
\ {\isachardoublequoteopen}lattice{\isachardot}join\ op\ dvd\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}nat{\isacharparenright}\ y\ {\isacharequal}\ lcm\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
333 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
334 |
\ {\isacharparenleft}unfold\ nat{\isacharunderscore}dvd{\isachardot}join{\isacharunderscore}def{\isacharparenright}\isanewline |
|
335 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
336 |
\ {\isacharparenleft}rule\ the{\isacharunderscore}equality{\isacharparenright}\isanewline |
|
337 |
\ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
338 |
\ {\isacharparenleft}unfold\ nat{\isacharunderscore}dvd{\isachardot}is{\isacharunderscore}sup{\isacharunderscore}def{\isacharparenright}\isanewline |
|
339 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
340 |
\ {\isacharparenleft}auto\ intro{\isacharcolon}\ lcm{\isacharunderscore}dvd{\isadigit{1}}\ lcm{\isacharunderscore}dvd{\isadigit{2}}\ lcm{\isacharunderscore}least{\isacharparenright}\isanewline |
|
341 |
\isacommand{qed}\isamarkupfalse% |
|
342 |
% |
|
343 |
\endisatagproof |
|
344 |
{\isafoldproof}% |
|
345 |
% |
|
346 |
\isadelimproof |
|
347 |
% |
|
348 |
\endisadelimproof |
|
349 |
% |
|
350 |
\begin{isamarkuptext}% |
|
351 |
Equations \isa{nat{\isacharunderscore}dvd{\isacharunderscore}meet{\isacharunderscore}eq} and \isa{nat{\isacharunderscore}dvd{\isacharunderscore}join{\isacharunderscore}eq} are named since they are handy in the proof of |
|
352 |
the subsequent interpretation.% |
|
353 |
\end{isamarkuptext}% |
|
354 |
\isamarkuptrue% |
|
355 |
% |
|
356 |
\isadeliminvisible |
|
357 |
% |
|
358 |
\endisadeliminvisible |
|
359 |
% |
|
360 |
\isataginvisible |
|
361 |
\isacommand{ML}\isamarkupfalse% |
|
362 |
\ {\isacharverbatimopen}\ set\ quick{\isacharunderscore}and{\isacharunderscore}dirty\ {\isacharverbatimclose}\isanewline |
|
363 |
\isanewline |
|
364 |
\isanewline |
|
365 |
\isanewline |
|
366 |
\isacommand{lemma}\isamarkupfalse% |
|
367 |
\ gcd{\isacharunderscore}lcm{\isacharunderscore}distr{\isacharcolon}\isanewline |
|
368 |
\ \ {\isachardoublequoteopen}gcd\ {\isacharparenleft}x{\isacharcomma}\ lcm\ {\isacharparenleft}y{\isacharcomma}\ z{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ lcm\ {\isacharparenleft}gcd\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isacharcomma}\ gcd\ {\isacharparenleft}x{\isacharcomma}\ z{\isacharparenright}{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
369 |
\ \ \isacommand{sorry}\isamarkupfalse% |
|
370 |
\isanewline |
|
371 |
\isanewline |
|
372 |
\isacommand{ML}\isamarkupfalse% |
|
373 |
\ {\isacharverbatimopen}\ reset\ quick{\isacharunderscore}and{\isacharunderscore}dirty\ {\isacharverbatimclose}% |
|
374 |
\endisataginvisible |
|
375 |
{\isafoldinvisible}% |
|
376 |
% |
|
377 |
\isadeliminvisible |
|
378 |
% |
|
379 |
\endisadeliminvisible |
|
380 |
\isanewline |
|
381 |
% |
|
382 |
\isadelimvisible |
|
383 |
\ \ \isanewline |
|
384 |
% |
|
385 |
\endisadelimvisible |
|
386 |
% |
|
387 |
\isatagvisible |
|
388 |
\isacommand{interpretation}\isamarkupfalse% |
|
389 |
\ nat{\isacharunderscore}dvd{\isacharcolon}\isanewline |
|
390 |
\ \ distrib{\isacharunderscore}lattice\ {\isacharbrackleft}{\isachardoublequoteopen}op\ dvd\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}{\isacharbrackright}\isanewline |
|
391 |
\ \ \isacommand{apply}\isamarkupfalse% |
|
392 |
\ unfold{\isacharunderscore}locales% |
|
393 |
\begin{isamarkuptxt}% |
|
394 |
\begin{isabelle}% |
|
395 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ y\ z{\isachardot}\isanewline |
|
396 |
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }lattice{\isachardot}meet\ op\ dvd\ x\ {\isacharparenleft}lattice{\isachardot}join\ op\ dvd\ y\ z{\isacharparenright}\ {\isacharequal}\isanewline |
|
397 |
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ }lattice{\isachardot}join\ op\ dvd\ {\isacharparenleft}lattice{\isachardot}meet\ op\ dvd\ x\ y{\isacharparenright}\isanewline |
|
398 |
\isaindent{\ {\isadigit{1}}{\isachardot}\ \ \ \ \ }{\isacharparenleft}lattice{\isachardot}meet\ op\ dvd\ x\ z{\isacharparenright}% |
|
399 |
\end{isabelle}% |
|
400 |
\end{isamarkuptxt}% |
|
401 |
\isamarkuptrue% |
|
402 |
\ \ \isacommand{apply}\isamarkupfalse% |
|
403 |
\ {\isacharparenleft}unfold\ nat{\isacharunderscore}dvd{\isacharunderscore}meet{\isacharunderscore}eq\ nat{\isacharunderscore}dvd{\isacharunderscore}join{\isacharunderscore}eq{\isacharparenright}% |
|
404 |
\begin{isamarkuptxt}% |
|
405 |
\begin{isabelle}% |
|
406 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ y\ z{\isachardot}\ gcd\ {\isacharparenleft}x{\isacharcomma}\ lcm\ {\isacharparenleft}y{\isacharcomma}\ z{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ lcm\ {\isacharparenleft}gcd\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}{\isacharcomma}\ gcd\ {\isacharparenleft}x{\isacharcomma}\ z{\isacharparenright}{\isacharparenright}% |
|
407 |
\end{isabelle}% |
|
408 |
\end{isamarkuptxt}% |
|
409 |
\isamarkuptrue% |
|
410 |
\ \ \isacommand{apply}\isamarkupfalse% |
|
411 |
\ {\isacharparenleft}rule\ gcd{\isacharunderscore}lcm{\isacharunderscore}distr{\isacharparenright}\ \isacommand{done}\isamarkupfalse% |
|
412 |
% |
|
413 |
\endisatagvisible |
|
414 |
{\isafoldvisible}% |
|
415 |
% |
|
416 |
\isadelimvisible |
|
417 |
% |
|
418 |
\endisadelimvisible |
|
419 |
% |
|
420 |
\begin{isamarkuptext}% |
|
421 |
Theorems that are available in the theory after these |
|
422 |
interpretations are shown in Table~\ref{tab:nat-dvd-lattice}. |
|
423 |
||
424 |
\begin{table} |
|
425 |
\hrule |
|
426 |
\vspace{2ex} |
|
427 |
\begin{center} |
|
428 |
\begin{tabular}{l} |
|
429 |
\isa{nat{\isacharunderscore}dvd{\isachardot}less{\isacharunderscore}def} from locale \isa{partial{\isacharunderscore}order}: \\ |
|
430 |
\quad \isa{{\isacharparenleft}{\isacharquery}x\ dvd\ {\isacharquery}y\ {\isasymand}\ {\isacharquery}x\ {\isasymnoteq}\ {\isacharquery}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isacharquery}x\ dvd\ {\isacharquery}y\ {\isasymand}\ {\isacharquery}x\ {\isasymnoteq}\ {\isacharquery}y{\isacharparenright}} \\ |
|
431 |
\isa{nat{\isacharunderscore}dvd{\isachardot}meet{\isacharunderscore}left} from locale \isa{lattice}: \\ |
|
432 |
\quad \isa{gcd\ {\isacharparenleft}{\isacharquery}x{\isacharcomma}\ {\isacharquery}y{\isacharparenright}\ dvd\ {\isacharquery}x} \\ |
|
433 |
\isa{nat{\isacharunderscore}dvd{\isachardot}join{\isacharunderscore}distr} from locale \isa{distrib{\isacharunderscore}lattice}: \\ |
|
434 |
\quad \isa{lcm\ {\isacharparenleft}{\isacharquery}x{\isacharcomma}\ gcd\ {\isacharparenleft}{\isacharquery}y{\isacharcomma}\ {\isacharquery}z{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ gcd\ {\isacharparenleft}lcm\ {\isacharparenleft}{\isacharquery}x{\isacharcomma}\ {\isacharquery}y{\isacharparenright}{\isacharcomma}\ lcm\ {\isacharparenleft}{\isacharquery}x{\isacharcomma}\ {\isacharquery}z{\isacharparenright}{\isacharparenright}} \\ |
|
435 |
\end{tabular} |
|
436 |
\end{center} |
|
437 |
\hrule |
|
438 |
\caption{Interpreted theorems for \isa{dvd} on the natural numbers.} |
|
439 |
\label{tab:nat-dvd-lattice} |
|
440 |
\end{table}% |
|
441 |
\end{isamarkuptext}% |
|
442 |
\isamarkuptrue% |
|
443 |
% |
|
444 |
\begin{isamarkuptext}% |
|
445 |
The full syntax of the interpretation commands is shown in |
|
446 |
Table~\ref{tab:commands}. The grammar refers to |
|
447 |
\textit{expr}, which stands for a \emph{locale} expression. Locale |
|
448 |
expressions are discussed in Section~\ref{sec:expressions}.% |
|
449 |
\end{isamarkuptext}% |
|
450 |
\isamarkuptrue% |
|
451 |
% |
|
27079 | 452 |
\isamarkupsection{Locale Expressions \label{sec:expressions}% |
27063 | 453 |
} |
454 |
\isamarkuptrue% |
|
455 |
% |
|
456 |
\begin{isamarkuptext}% |
|
27079 | 457 |
A map \isa{{\isasymphi}} between partial orders \isa{{\isasymsqsubseteq}} and \isa{{\isasympreceq}} |
27063 | 458 |
is called order preserving if \isa{x\ {\isasymsqsubseteq}\ y} implies \isa{{\isasymphi}\ x\ {\isasympreceq}\ {\isasymphi}\ y}. This situation is more complex than those encountered so |
459 |
far: it involves two partial orders, and it is desirable to use the |
|
460 |
existing locale for both. |
|
461 |
||
462 |
Inspecting the grammar of locale commands in |
|
463 |
Table~\ref{tab:commands} reveals that the import of a locale can be |
|
464 |
more than just a single locale. In general, the import is a |
|
465 |
\emph{locale expression}. Locale expressions enable to combine locales |
|
466 |
and rename parameters. A locale name is a locale expression. If |
|
467 |
$e_1$ and $e_2$ are locale expressions then $e_1 + e_2$ is their |
|
27075
34005fa42128
renamed expression: plain ~ (space) instead of \colon;
wenzelm
parents:
27074
diff
changeset
|
468 |
\emph{merge}. If $e$ is an expression, then $e~q_1 \ldots q_n$ is |
27063 | 469 |
a \emph{renamed expression} where the parameters in $e$ are renamed |
470 |
to $q_1 \ldots q_n$. Using a locale expression, a locale for order |
|
471 |
preserving maps can be declared in the following way.% |
|
472 |
\end{isamarkuptext}% |
|
473 |
\isamarkuptrue% |
|
474 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
475 |
\ order{\isacharunderscore}preserving\ {\isacharequal}\isanewline |
|
476 |
\ \ \ \ partial{\isacharunderscore}order\ {\isacharplus}\ partial{\isacharunderscore}order\ le{\isacharprime}\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasympreceq}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ {\isacharplus}\isanewline |
|
477 |
\ \ \ \ \isakeyword{fixes}\ {\isasymphi}\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}b{\isachardoublequoteclose}\isanewline |
|
478 |
\ \ \ \ \isakeyword{assumes}\ hom{\isacharunderscore}le{\isacharcolon}\ {\isachardoublequoteopen}x\ {\isasymsqsubseteq}\ y\ {\isasymLongrightarrow}\ {\isasymphi}\ x\ {\isasympreceq}\ {\isasymphi}\ y{\isachardoublequoteclose}% |
|
479 |
\begin{isamarkuptext}% |
|
480 |
The second line contains the expression, which is the |
|
481 |
merge of two partial order locales. The parameter of the second one |
|
482 |
is \isa{le{\isacharprime}} with new infix syntax \isa{{\isasympreceq}}. The |
|
483 |
parameters of the entire locale are \isa{le}, \isa{le{\isacharprime}} and |
|
484 |
\isa{{\isasymphi}}. This is their \emph{canonical order}, |
|
485 |
which is obtained by a left-to-right traversal of the expression, |
|
486 |
where only the new parameters are appended to the end of the list. The |
|
487 |
parameters introduced in the locale elements of the declaration |
|
488 |
follow. |
|
489 |
||
490 |
In renamings parameters are referred to by position in the canonical |
|
491 |
order; an underscore is used to skip a parameter position, which is |
|
492 |
then not renamed. Renaming deletes the syntax of a parameter unless |
|
493 |
a new mixfix annotation is given. |
|
494 |
||
495 |
Parameter renamings are morphisms between locales. These can be |
|
496 |
lifted to terms and theorems and thus be applied to assumptions and |
|
497 |
conclusions. The assumption of a merge is the conjunction of the |
|
498 |
assumptions of the merged locale. The conclusions of a merge are |
|
499 |
obtained by appending the conclusions of the left locale and of the |
|
500 |
right locale.% |
|
501 |
\end{isamarkuptext}% |
|
502 |
\isamarkuptrue% |
|
503 |
% |
|
504 |
\begin{isamarkuptext}% |
|
505 |
The locale \isa{order{\isacharunderscore}preserving} contains theorems for both |
|
506 |
orders \isa{{\isasymsqsubseteq}} and \isa{{\isasympreceq}}. How can one refer to a theorem for |
|
507 |
a particular order, \isa{{\isasymsqsubseteq}} or \isa{{\isasympreceq}}? Names in locales are |
|
508 |
qualified by the locale parameters. More precisely, a name is |
|
509 |
qualified by the parameters of the locale in which its declaration |
|
510 |
occurs. Here are examples:% |
|
511 |
\end{isamarkuptext}% |
|
512 |
\isamarkuptrue% |
|
513 |
% |
|
514 |
\isadeliminvisible |
|
515 |
% |
|
516 |
\endisadeliminvisible |
|
517 |
% |
|
518 |
\isataginvisible |
|
519 |
\isacommand{context}\isamarkupfalse% |
|
520 |
\ order{\isacharunderscore}preserving\ \isakeyword{begin}% |
|
521 |
\endisataginvisible |
|
522 |
{\isafoldinvisible}% |
|
523 |
% |
|
524 |
\isadeliminvisible |
|
525 |
% |
|
526 |
\endisadeliminvisible |
|
527 |
% |
|
528 |
\begin{isamarkuptext}% |
|
529 |
\isa{le{\isachardot}less{\isacharunderscore}le{\isacharunderscore}trans}: \isa{{\isasymlbrakk}{\isacharquery}x\ {\isasymsqsubset}\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasymsqsubseteq}\ {\isacharquery}z{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharquery}x\ {\isasymsqsubset}\ {\isacharquery}z} |
|
530 |
||
531 |
\isa{le{\isacharunderscore}le{\isacharprime}{\isacharunderscore}{\isasymphi}{\isachardot}hom{\isacharunderscore}le}: \isa{{\isacharquery}x\ {\isasymsqsubseteq}\ {\isacharquery}y\ {\isasymLongrightarrow}\ {\isasymphi}\ {\isacharquery}x\ {\isasympreceq}\ {\isasymphi}\ {\isacharquery}y}% |
|
532 |
\end{isamarkuptext}% |
|
533 |
\isamarkuptrue% |
|
534 |
% |
|
535 |
\begin{isamarkuptext}% |
|
536 |
When renaming a locale, the morphism is also applied |
|
537 |
to the qualifiers. Hence theorems for the partial order \isa{{\isasympreceq}} |
|
538 |
are qualified by \isa{le{\isacharprime}}. For example, \isa{le{\isacharprime}{\isachardot}less{\isacharunderscore}le{\isacharunderscore}trans}: \begin{isabelle}% |
|
539 |
\ \ {\isasymlbrakk}partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasympreceq}\ {\isacharquery}x\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasympreceq}\ {\isacharquery}z{\isasymrbrakk}\isanewline |
|
540 |
\isaindent{\ \ }{\isasymLongrightarrow}\ partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasympreceq}\ {\isacharquery}x\ {\isacharquery}z% |
|
541 |
\end{isabelle}% |
|
542 |
\end{isamarkuptext}% |
|
543 |
\isamarkuptrue% |
|
544 |
% |
|
545 |
\isadeliminvisible |
|
546 |
% |
|
547 |
\endisadeliminvisible |
|
548 |
% |
|
549 |
\isataginvisible |
|
550 |
\isacommand{end}\isamarkupfalse% |
|
551 |
% |
|
552 |
\endisataginvisible |
|
553 |
{\isafoldinvisible}% |
|
554 |
% |
|
555 |
\isadeliminvisible |
|
556 |
% |
|
557 |
\endisadeliminvisible |
|
558 |
% |
|
559 |
\begin{isamarkuptext}% |
|
560 |
This example reveals that there is no infix syntax for the strict |
|
561 |
version of \isa{{\isasympreceq}}! This can, of course, not be introduced |
|
562 |
automatically, but it can be declared manually through an abbreviation.% |
|
563 |
\end{isamarkuptext}% |
|
564 |
\isamarkuptrue% |
|
565 |
\ \ \isacommand{abbreviation}\isamarkupfalse% |
|
566 |
\ {\isacharparenleft}\isakeyword{in}\ order{\isacharunderscore}preserving{\isacharparenright}\isanewline |
|
567 |
\ \ \ \ less{\isacharprime}\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasymprec}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ \isakeyword{where}\ {\isachardoublequoteopen}less{\isacharprime}\ {\isasymequiv}\ partial{\isacharunderscore}order{\isachardot}less\ le{\isacharprime}{\isachardoublequoteclose}% |
|
568 |
\begin{isamarkuptext}% |
|
569 |
Now the theorem is displayed nicely as |
|
570 |
\isa{{\isasymlbrakk}{\isacharquery}x\ {\isasymprec}\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasympreceq}\ {\isacharquery}z{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharquery}x\ {\isasymprec}\ {\isacharquery}z}.% |
|
571 |
\end{isamarkuptext}% |
|
572 |
\isamarkuptrue% |
|
573 |
% |
|
574 |
\begin{isamarkuptext}% |
|
575 |
Not only names of theorems are qualified. In fact, all names |
|
576 |
are qualified, in particular names introduced by definitions and |
|
577 |
abbreviations. The name of the strict order of \isa{{\isasymsqsubseteq}} is \isa{le{\isachardot}less} and therefore \isa{le{\isacharprime}{\isachardot}less} is the name of the strict |
|
578 |
order of \isa{{\isasympreceq}}. Hence, the equation in the above abbreviation |
|
579 |
could have been written as \isa{less{\isacharprime}\ {\isasymequiv}\ le{\isacharprime}{\isachardot}less}.% |
|
580 |
\end{isamarkuptext}% |
|
581 |
\isamarkuptrue% |
|
582 |
% |
|
583 |
\begin{isamarkuptext}% |
|
584 |
Two more locales illustrate working with locale expressions. |
|
585 |
A map \isa{{\isasymphi}} is a lattice homomorphism if it preserves meet and join.% |
|
586 |
\end{isamarkuptext}% |
|
587 |
\isamarkuptrue% |
|
588 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
589 |
\ lattice{\isacharunderscore}hom\ {\isacharequal}\ lattice\ {\isacharplus}\ lattice\ le{\isacharprime}\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasympreceq}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ {\isacharplus}\isanewline |
|
590 |
\ \ \ \ \isakeyword{fixes}\ {\isasymphi}\isanewline |
|
591 |
\ \ \ \ \isakeyword{assumes}\ hom{\isacharunderscore}meet{\isacharcolon}\isanewline |
|
592 |
\ \ \ \ \ \ \ \ {\isachardoublequoteopen}{\isasymphi}\ {\isacharparenleft}lattice{\isachardot}meet\ le\ x\ y{\isacharparenright}\ {\isacharequal}\ lattice{\isachardot}meet\ le{\isacharprime}\ {\isacharparenleft}{\isasymphi}\ x{\isacharparenright}\ {\isacharparenleft}{\isasymphi}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
593 |
\ \ \ \ \ \ \isakeyword{and}\ hom{\isacharunderscore}join{\isacharcolon}\isanewline |
|
594 |
\ \ \ \ \ \ \ \ {\isachardoublequoteopen}{\isasymphi}\ {\isacharparenleft}lattice{\isachardot}join\ le\ x\ y{\isacharparenright}\ {\isacharequal}\ lattice{\isachardot}join\ le{\isacharprime}\ {\isacharparenleft}{\isasymphi}\ x{\isacharparenright}\ {\isacharparenleft}{\isasymphi}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
595 |
\isanewline |
|
596 |
\ \ \isacommand{abbreviation}\isamarkupfalse% |
|
597 |
\ {\isacharparenleft}\isakeyword{in}\ lattice{\isacharunderscore}hom{\isacharparenright}\isanewline |
|
598 |
\ \ \ \ meet{\isacharprime}\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasymsqinter}{\isacharprime}{\isacharprime}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ \isakeyword{where}\ {\isachardoublequoteopen}meet{\isacharprime}\ {\isasymequiv}\ le{\isacharprime}{\isachardot}meet{\isachardoublequoteclose}\isanewline |
|
599 |
\ \ \isacommand{abbreviation}\isamarkupfalse% |
|
600 |
\ {\isacharparenleft}\isakeyword{in}\ lattice{\isacharunderscore}hom{\isacharparenright}\isanewline |
|
601 |
\ \ \ \ join{\isacharprime}\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasymsqunion}{\isacharprime}{\isacharprime}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ \isakeyword{where}\ {\isachardoublequoteopen}join{\isacharprime}\ {\isasymequiv}\ le{\isacharprime}{\isachardot}join{\isachardoublequoteclose}% |
|
602 |
\begin{isamarkuptext}% |
|
603 |
A homomorphism is an endomorphism if both orders coincide.% |
|
604 |
\end{isamarkuptext}% |
|
605 |
\isamarkuptrue% |
|
606 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
607 |
\ lattice{\isacharunderscore}end\ {\isacharequal}\isanewline |
|
608 |
\ \ \ \ lattice{\isacharunderscore}hom\ le\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasymsqsubseteq}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ le\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasymsqsubseteq}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}% |
|
609 |
\begin{isamarkuptext}% |
|
610 |
The inheritance diagram of the situation we have now is shown |
|
611 |
in Figure~\ref{fig:hom}, where the dashed line depicts an |
|
612 |
interpretation which is introduced below. Renamings are |
|
613 |
indicated by $\sqsubseteq \mapsto \preceq$ etc. The expression |
|
614 |
imported by \isa{lattice{\isacharunderscore}end} identifies the first and second |
|
615 |
parameter of \isa{lattice{\isacharunderscore}hom}. By looking at the inheritance diagram it would seem |
|
616 |
that two identical copies of each of the locales \isa{partial{\isacharunderscore}order} and \isa{lattice} are imported. This is not the |
|
617 |
case! Inheritance paths with identical morphisms are detected and |
|
618 |
the conclusions of the respecitve locales appear only once. |
|
619 |
||
620 |
\begin{figure} |
|
621 |
\hrule \vspace{2ex} |
|
622 |
\begin{center} |
|
623 |
\begin{tikzpicture} |
|
624 |
\node (o) at (0,0) {\isa{partial{\isacharunderscore}order}}; |
|
625 |
\node (oh) at (1.5,-2) {\isa{order{\isacharunderscore}preserving}}; |
|
626 |
\node (oh1) at (1.5,-0.7) {$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; |
|
627 |
\node (oh2) at (0,-1.3) {$\scriptscriptstyle \sqsubseteq \mapsto \preceq$}; |
|
628 |
\node (l) at (-1.5,-2) {\isa{lattice}}; |
|
629 |
\node (lh) at (0,-4) {\isa{lattice{\isacharunderscore}hom}}; |
|
630 |
\node (lh1) at (0,-2.7) {$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; |
|
631 |
\node (lh2) at (-1.5,-3.3) {$\scriptscriptstyle \sqsubseteq \mapsto \preceq$}; |
|
632 |
\node (le) at (0,-6) {\isa{lattice{\isacharunderscore}end}}; |
|
633 |
\node (le1) at (0,-4.8) |
|
634 |
[anchor=west]{$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; |
|
635 |
\node (le2) at (0,-5.2) |
|
636 |
[anchor=west]{$\scriptscriptstyle \preceq \mapsto \sqsubseteq$}; |
|
637 |
\draw (o) -- (l); |
|
638 |
\draw[dashed] (oh) -- (lh); |
|
639 |
\draw (lh) -- (le); |
|
640 |
\draw (o) .. controls (oh1.south west) .. (oh); |
|
641 |
\draw (o) .. controls (oh2.north east) .. (oh); |
|
642 |
\draw (l) .. controls (lh1.south west) .. (lh); |
|
643 |
\draw (l) .. controls (lh2.north east) .. (lh); |
|
644 |
\end{tikzpicture} |
|
645 |
\end{center} |
|
646 |
\hrule |
|
647 |
\caption{Hierarchy of Homomorphism Locales.} |
|
648 |
\label{fig:hom} |
|
649 |
\end{figure}% |
|
650 |
\end{isamarkuptext}% |
|
651 |
\isamarkuptrue% |
|
652 |
% |
|
653 |
\begin{isamarkuptext}% |
|
654 |
It can be shown easily that a lattice homomorphism is order |
|
655 |
preserving. As the final example of this section, a locale |
|
656 |
interpretation is used to assert this.% |
|
657 |
\end{isamarkuptext}% |
|
658 |
\isamarkuptrue% |
|
659 |
\ \ \isacommand{interpretation}\isamarkupfalse% |
|
660 |
\ lattice{\isacharunderscore}hom\ {\isasymsubseteq}\ order{\isacharunderscore}preserving% |
|
661 |
\isadelimproof |
|
662 |
\ % |
|
663 |
\endisadelimproof |
|
664 |
% |
|
665 |
\isatagproof |
|
666 |
\isacommand{proof}\isamarkupfalse% |
|
667 |
\ unfold{\isacharunderscore}locales\isanewline |
|
668 |
\ \ \ \ \isacommand{fix}\isamarkupfalse% |
|
669 |
\ x\ y\isanewline |
|
670 |
\ \ \ \ \isacommand{assume}\isamarkupfalse% |
|
671 |
\ {\isachardoublequoteopen}x\ {\isasymsqsubseteq}\ y{\isachardoublequoteclose}\isanewline |
|
672 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
673 |
\ \isacommand{have}\isamarkupfalse% |
|
674 |
\ {\isachardoublequoteopen}y\ {\isacharequal}\ {\isacharparenleft}x\ {\isasymsqunion}\ y{\isacharparenright}{\isachardoublequoteclose}\ \isacommand{by}\isamarkupfalse% |
|
675 |
\ {\isacharparenleft}simp\ add{\isacharcolon}\ le{\isachardot}join{\isacharunderscore}connection{\isacharparenright}\isanewline |
|
676 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
677 |
\ \isacommand{have}\isamarkupfalse% |
|
678 |
\ {\isachardoublequoteopen}{\isasymphi}\ y\ {\isacharequal}\ {\isacharparenleft}{\isasymphi}\ x\ {\isasymsqunion}{\isacharprime}\ {\isasymphi}\ y{\isacharparenright}{\isachardoublequoteclose}\ \isacommand{by}\isamarkupfalse% |
|
679 |
\ {\isacharparenleft}simp\ add{\isacharcolon}\ hom{\isacharunderscore}join\ {\isacharbrackleft}symmetric{\isacharbrackright}{\isacharparenright}\isanewline |
|
680 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
681 |
\ \isacommand{show}\isamarkupfalse% |
|
682 |
\ {\isachardoublequoteopen}{\isasymphi}\ x\ {\isasympreceq}\ {\isasymphi}\ y{\isachardoublequoteclose}\ \isacommand{by}\isamarkupfalse% |
|
683 |
\ {\isacharparenleft}simp\ add{\isacharcolon}\ le{\isacharprime}{\isachardot}join{\isacharunderscore}connection{\isacharparenright}\isanewline |
|
684 |
\ \ \isacommand{qed}\isamarkupfalse% |
|
685 |
% |
|
686 |
\endisatagproof |
|
687 |
{\isafoldproof}% |
|
688 |
% |
|
689 |
\isadelimproof |
|
690 |
% |
|
691 |
\endisadelimproof |
|
692 |
% |
|
693 |
\begin{isamarkuptext}% |
|
694 |
Theorems and other declarations --- syntax, in particular --- |
|
695 |
from the locale \isa{order{\isacharunderscore}preserving} are now active in \isa{lattice{\isacharunderscore}hom}, for example |
|
696 |
||
697 |
\isa{le{\isacharprime}{\isachardot}less{\isacharunderscore}le{\isacharunderscore}trans}: |
|
698 |
\isa{{\isasymlbrakk}{\isacharquery}x\ {\isasymprec}\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasympreceq}\ {\isacharquery}z{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharquery}x\ {\isasymprec}\ {\isacharquery}z}% |
|
699 |
\end{isamarkuptext}% |
|
700 |
\isamarkuptrue% |
|
701 |
% |
|
702 |
\isamarkupsection{Further Reading% |
|
703 |
} |
|
704 |
\isamarkuptrue% |
|
705 |
% |
|
706 |
\begin{isamarkuptext}% |
|
707 |
More information on locales and their interpretation is |
|
708 |
available. For the locale hierarchy of import and interpretation |
|
709 |
dependencies see \cite{Ballarin2006a}; interpretations in theories |
|
710 |
and proofs are covered in \cite{Ballarin2006b}. In the latter, we |
|
711 |
show how interpretation in proofs enables to reason about families |
|
712 |
of algebraic structures, which cannot be expressed with locales |
|
713 |
directly. |
|
714 |
||
715 |
Haftmann and Wenzel \cite{HaftmannWenzel2007} overcome a restriction |
|
716 |
of axiomatic type classes through a combination with locale |
|
717 |
interpretation. The result is a Haskell-style class system with a |
|
718 |
facility to generate Haskell code. Classes are sufficient for |
|
719 |
simple specifications with a single type parameter. The locales for |
|
720 |
orders and lattices presented in this tutorial fall into this |
|
721 |
category. Order preserving maps, homomorphisms and vector spaces, |
|
722 |
on the other hand, do not. |
|
723 |
||
724 |
The original work of Kamm\"uller on locales \cite{KammullerEtAl1999} |
|
725 |
may be of interest from a historical perspective. The mathematical |
|
726 |
background on orders and lattices is taken from Jacobson's textbook |
|
727 |
on algebra \cite[Chapter~8]{Jacobson1985}.% |
|
728 |
\end{isamarkuptext}% |
|
729 |
\isamarkuptrue% |
|
730 |
% |
|
731 |
\begin{isamarkuptext}% |
|
732 |
\begin{table} |
|
733 |
\hrule |
|
734 |
\vspace{2ex} |
|
735 |
\begin{center} |
|
736 |
\begin{tabular}{l>$c<$l} |
|
737 |
\multicolumn{3}{l}{Miscellaneous} \\ |
|
738 |
||
739 |
\textit{attr-name} & ::= |
|
740 |
& \textit{name} $|$ \textit{attribute} $|$ |
|
741 |
\textit{name} \textit{attribute} \\[2ex] |
|
742 |
||
743 |
\multicolumn{3}{l}{Context Elements} \\ |
|
744 |
||
745 |
\textit{fixes} & ::= |
|
746 |
& \textit{name} [ ``\textbf{::}'' \textit{type} ] |
|
747 |
[ ``\textbf{(}'' \textbf{structure} ``\textbf{)}'' $|$ |
|
748 |
\textit{mixfix} ] \\ |
|
749 |
\begin{comment} |
|
750 |
\textit{constrains} & ::= |
|
751 |
& \textit{name} ``\textbf{::}'' \textit{type} \\ |
|
752 |
\end{comment} |
|
753 |
\textit{assumes} & ::= |
|
754 |
& [ \textit{attr-name} ``\textbf{:}'' ] \textit{proposition} \\ |
|
755 |
\begin{comment} |
|
756 |
\textit{defines} & ::= |
|
757 |
& [ \textit{attr-name} ``\textbf{:}'' ] \textit{proposition} \\ |
|
758 |
\textit{notes} & ::= |
|
759 |
& [ \textit{attr-name} ``\textbf{=}'' ] |
|
760 |
( \textit{qualified-name} [ \textit{attribute} ] )$^+$ \\ |
|
761 |
\end{comment} |
|
762 |
||
763 |
\textit{element} & ::= |
|
764 |
& \textbf{fixes} \textit{fixes} ( \textbf{and} \textit{fixes} )$^*$ \\ |
|
765 |
\begin{comment} |
|
766 |
& | |
|
767 |
& \textbf{constrains} \textit{constrains} |
|
768 |
( \textbf{and} \textit{constrains} )$^*$ \\ |
|
769 |
\end{comment} |
|
770 |
& | |
|
771 |
& \textbf{assumes} \textit{assumes} ( \textbf{and} \textit{assumes} )$^*$ \\[2ex] |
|
772 |
%\begin{comment} |
|
773 |
% & | |
|
774 |
% & \textbf{defines} \textit{defines} ( \textbf{and} \textit{defines} )$^*$ \\ |
|
775 |
% & | |
|
776 |
% & \textbf{notes} \textit{notes} ( \textbf{and} \textit{notes} )$^*$ \\ |
|
777 |
%\end{comment} |
|
778 |
||
779 |
\multicolumn{3}{l}{Locale Expressions} \\ |
|
780 |
||
781 |
\textit{rename} & ::= |
|
782 |
& \textit{name} [ \textit{mixfix} ] $|$ ``\textbf{\_}'' \\ |
|
783 |
\textit{expr} & ::= |
|
784 |
& \textit{renamed-expr} ( ``\textbf{+}'' \textit{renamed-expr} )$^*$ \\ |
|
785 |
\textit{renamed-expr} & ::= |
|
786 |
& ( \textit{qualified-name} $|$ |
|
787 |
``\textbf{(}'' \textit{expr} ``\textbf{)}'' ) \textit{rename}$^*$ \\[2ex] |
|
788 |
||
789 |
\multicolumn{3}{l}{Declaration of Locales} \\ |
|
790 |
||
791 |
\textit{locale} & ::= |
|
792 |
& \textit{element}$^+$ \\ |
|
793 |
& | & \textit{locale-expr} [ ``\textbf{+}'' \textit{element}$^+$ ] \\ |
|
794 |
\textit{toplevel} & ::= |
|
795 |
& \textbf{locale} \textit{name} [ ``\textbf{=}'' |
|
796 |
\textit{locale} ] \\[2ex] |
|
797 |
||
798 |
\multicolumn{3}{l}{Interpretation} \\ |
|
799 |
||
800 |
\textit{equation} & ::= & [ \textit{attr-name} ``\textbf{:}'' ] |
|
801 |
\textit{prop} \\ |
|
802 |
\textit{insts} & ::= & [ ``\textbf{[}'' \textit{term}$^+$ |
|
803 |
``\textbf{]}'' ] \\ |
|
804 |
& & [ \textbf{where} \textit{equation} ( \textbf{and} |
|
805 |
\textit{equation} )$^*$ ] \\ |
|
806 |
\textit{toplevel} & ::= |
|
807 |
& \textbf{interpretation} \textit{name} ( ``$<$'' $|$ |
|
808 |
``$\subseteq$'' ) \textit{expr} \textit{proof} \\ |
|
809 |
& | |
|
810 |
& \textbf{interpretation} [ \textit{attr-name} ``\textbf{:}'' ] |
|
811 |
\textit{expr} \textit{insts} \textit{proof} \\ |
|
812 |
& | |
|
813 |
& \textbf{interpret} [ \textit{attr-name} ``\textbf{:}'' ] |
|
814 |
\textit{expr} \textit{insts} \textit{proof} \\[2ex] |
|
815 |
||
816 |
\multicolumn{3}{l}{Diagnostics} \\ |
|
817 |
||
818 |
\textit{toplevel} & ::= |
|
819 |
& \textbf{print\_locale} [ ``\textbf{!}'' ] \textit{locale} \\ |
|
820 |
& | & \textbf{print\_locales} |
|
821 |
\end{tabular} |
|
822 |
\end{center} |
|
823 |
\hrule |
|
824 |
\caption{Syntax of Locale Commands.} |
|
825 |
\label{tab:commands} |
|
826 |
\end{table}% |
|
827 |
\end{isamarkuptext}% |
|
828 |
\isamarkuptrue% |
|
829 |
% |
|
830 |
\begin{isamarkuptext}% |
|
831 |
\textbf{Acknowledgements.} Alexander Krauss, Tobias Nipkow, |
|
832 |
Christian Sternagel and Makarius Wenzel have made useful comments on |
|
833 |
a draft of this document.% |
|
834 |
\end{isamarkuptext}% |
|
835 |
\isamarkuptrue% |
|
836 |
% |
|
837 |
\isadelimtheory |
|
838 |
% |
|
839 |
\endisadelimtheory |
|
840 |
% |
|
841 |
\isatagtheory |
|
27080 | 842 |
\isacommand{end}\isamarkupfalse% |
27063 | 843 |
% |
844 |
\endisatagtheory |
|
845 |
{\isafoldtheory}% |
|
846 |
% |
|
847 |
\isadelimtheory |
|
848 |
% |
|
849 |
\endisadelimtheory |
|
27080 | 850 |
\isanewline |
27063 | 851 |
\end{isabellebody}% |
852 |
%%% Local Variables: |
|
853 |
%%% mode: latex |
|
854 |
%%% TeX-master: "root" |
|
855 |
%%% End: |