author | ballarin |
Sun, 30 May 2010 21:29:37 +0200 | |
changeset 37206 | 7f2a6f3143ad |
parent 35423 | 6ef9525a5727 |
child 40406 | 313a24b66a8d |
permissions | -rw-r--r-- |
27063 | 1 |
% |
2 |
\begin{isabellebody}% |
|
3 |
\def\isabellecontext{Examples{\isadigit{3}}}% |
|
4 |
% |
|
5 |
\isadelimtheory |
|
6 |
% |
|
7 |
\endisadelimtheory |
|
8 |
% |
|
9 |
\isatagtheory |
|
27080 | 10 |
\isacommand{theory}\isamarkupfalse% |
11 |
\ Examples{\isadigit{3}}\isanewline |
|
32983 | 12 |
\isakeyword{imports}\ Examples\isanewline |
27080 | 13 |
\isakeyword{begin}% |
27063 | 14 |
\endisatagtheory |
15 |
{\isafoldtheory}% |
|
16 |
% |
|
17 |
\isadelimtheory |
|
18 |
% |
|
19 |
\endisadelimtheory |
|
20 |
% |
|
32981 | 21 |
\begin{isamarkuptext}% |
22 |
\vspace{-5ex}% |
|
23 |
\end{isamarkuptext}% |
|
24 |
\isamarkuptrue% |
|
25 |
% |
|
26 |
\isamarkupsubsection{Third Version: Local Interpretation |
|
27 |
\label{sec:local-interpretation}% |
|
27063 | 28 |
} |
29 |
\isamarkuptrue% |
|
30 |
% |
|
31 |
\begin{isamarkuptext}% |
|
32981 | 32 |
In the above example, the fact that \isa{op\ {\isasymle}} is a partial |
32982 | 33 |
order for the integers was used in the second goal to |
32981 | 34 |
discharge the premise in the definition of \isa{op\ {\isasymsqsubset}}. In |
35 |
general, proofs of the equations not only may involve definitions |
|
32983 | 36 |
from the interpreted locale but arbitrarily complex arguments in the |
32981 | 37 |
context of the locale. Therefore is would be convenient to have the |
38 |
interpreted locale conclusions temporary available in the proof. |
|
39 |
This can be achieved by a locale interpretation in the proof body. |
|
40 |
The command for local interpretations is \isakeyword{interpret}. We |
|
41 |
repeat the example from the previous section to illustrate this.% |
|
27063 | 42 |
\end{isamarkuptext}% |
43 |
\isamarkuptrue% |
|
44 |
% |
|
45 |
\isadelimvisible |
|
32981 | 46 |
\ \ % |
27063 | 47 |
\endisadelimvisible |
48 |
% |
|
49 |
\isatagvisible |
|
50 |
\isacommand{interpretation}\isamarkupfalse% |
|
32982 | 51 |
\ int{\isacharcolon}\ partial{\isacharunderscore}order\ {\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\isanewline |
52 |
\ \ \ \ \isakeyword{where}\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ y\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
32981 | 53 |
\ \ \isacommand{proof}\isamarkupfalse% |
27063 | 54 |
\ {\isacharminus}\isanewline |
32981 | 55 |
\ \ \ \ \isacommand{show}\isamarkupfalse% |
32982 | 56 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order\ {\isacharparenleft}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isacharparenright}{\isachardoublequoteclose}\isanewline |
32981 | 57 |
\ \ \ \ \ \ \isacommand{by}\isamarkupfalse% |
27063 | 58 |
\ unfold{\isacharunderscore}locales\ auto\isanewline |
32981 | 59 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
27063 | 60 |
\ \isacommand{interpret}\isamarkupfalse% |
32982 | 61 |
\ int{\isacharcolon}\ partial{\isacharunderscore}order\ {\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ {\isacharbrackleft}int{\isacharcomma}\ int{\isacharbrackright}\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\ \isacommand{{\isachardot}}\isamarkupfalse% |
27063 | 62 |
\isanewline |
32981 | 63 |
\ \ \ \ \isacommand{show}\isamarkupfalse% |
32982 | 64 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ y\ {\isacharequal}\ {\isacharparenleft}x\ {\isacharless}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
32981 | 65 |
\ \ \ \ \ \ \isacommand{unfolding}\isamarkupfalse% |
32982 | 66 |
\ int{\isachardot}less{\isacharunderscore}def\ \isacommand{by}\isamarkupfalse% |
27063 | 67 |
\ auto\isanewline |
32981 | 68 |
\ \ \isacommand{qed}\isamarkupfalse% |
27063 | 69 |
% |
70 |
\endisatagvisible |
|
71 |
{\isafoldvisible}% |
|
72 |
% |
|
73 |
\isadelimvisible |
|
74 |
% |
|
75 |
\endisadelimvisible |
|
76 |
% |
|
77 |
\begin{isamarkuptext}% |
|
32981 | 78 |
The inner interpretation is immediate from the preceding fact |
79 |
and proved by assumption (Isar short hand ``.''). It enriches the |
|
80 |
local proof context by the theorems |
|
30826 | 81 |
also obtained in the interpretation from Section~\ref{sec:po-first}, |
32982 | 82 |
and \isa{int{\isachardot}less{\isacharunderscore}def} may directly be used to unfold the |
30826 | 83 |
definition. Theorems from the local interpretation disappear after |
32983 | 84 |
leaving the proof context --- that is, after the succeeding |
32981 | 85 |
\isakeyword{next} or \isakeyword{qed} statement.% |
27063 | 86 |
\end{isamarkuptext}% |
87 |
\isamarkuptrue% |
|
88 |
% |
|
89 |
\isamarkupsubsection{Further Interpretations% |
|
90 |
} |
|
91 |
\isamarkuptrue% |
|
92 |
% |
|
93 |
\begin{isamarkuptext}% |
|
32981 | 94 |
Further interpretations are necessary for |
32983 | 95 |
the other locales. In \isa{lattice} the operations~\isa{{\isasymsqinter}} |
96 |
and~\isa{{\isasymsqunion}} are substituted by \isa{min} |
|
97 |
and \isa{max}. The entire proof for the |
|
32981 | 98 |
interpretation is reproduced to give an example of a more |
32983 | 99 |
elaborate interpretation proof. Note that the equations are named |
100 |
so they can be used in a later example.% |
|
27063 | 101 |
\end{isamarkuptext}% |
102 |
\isamarkuptrue% |
|
103 |
% |
|
104 |
\isadelimvisible |
|
32981 | 105 |
\ \ % |
27063 | 106 |
\endisadelimvisible |
107 |
% |
|
108 |
\isatagvisible |
|
109 |
\isacommand{interpretation}\isamarkupfalse% |
|
32982 | 110 |
\ int{\isacharcolon}\ lattice\ {\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\isanewline |
32983 | 111 |
\ \ \ \ \isakeyword{where}\ int{\isacharunderscore}min{\isacharunderscore}eq{\isacharcolon}\ {\isachardoublequoteopen}lattice{\isachardot}meet\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ y\ {\isacharequal}\ min\ x\ y{\isachardoublequoteclose}\isanewline |
112 |
\ \ \ \ \ \ \isakeyword{and}\ int{\isacharunderscore}max{\isacharunderscore}eq{\isacharcolon}\ {\isachardoublequoteopen}lattice{\isachardot}join\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ y\ {\isacharequal}\ max\ x\ y{\isachardoublequoteclose}\isanewline |
|
32981 | 113 |
\ \ \isacommand{proof}\isamarkupfalse% |
27063 | 114 |
\ {\isacharminus}\isanewline |
32981 | 115 |
\ \ \ \ \isacommand{show}\isamarkupfalse% |
32982 | 116 |
\ {\isachardoublequoteopen}lattice\ {\isacharparenleft}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isacharparenright}{\isachardoublequoteclose}% |
27063 | 117 |
\begin{isamarkuptxt}% |
32981 | 118 |
\normalsize We have already shown that this is a partial |
119 |
order,% |
|
27063 | 120 |
\end{isamarkuptxt}% |
121 |
\isamarkuptrue% |
|
32981 | 122 |
\ \ \ \ \ \ \isacommand{apply}\isamarkupfalse% |
123 |
\ unfold{\isacharunderscore}locales% |
|
124 |
\begin{isamarkuptxt}% |
|
125 |
\normalsize hence only the lattice axioms remain to be |
|
32983 | 126 |
shown. |
127 |
\begin{isabelle}% |
|
32981 | 128 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ {\isasymexists}inf{\isachardot}\ partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}inf\ op\ {\isasymle}\ x\ y\ inf\isanewline |
129 |
\ {\isadigit{2}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ {\isasymexists}sup{\isachardot}\ partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}sup\ op\ {\isasymle}\ x\ y\ sup% |
|
32983 | 130 |
\end{isabelle} |
131 |
By \isa{is{\isacharunderscore}inf} and \isa{is{\isacharunderscore}sup},% |
|
32981 | 132 |
\end{isamarkuptxt}% |
133 |
\isamarkuptrue% |
|
134 |
\ \ \ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
32982 | 135 |
\ {\isacharparenleft}unfold\ int{\isachardot}is{\isacharunderscore}inf{\isacharunderscore}def\ int{\isachardot}is{\isacharunderscore}sup{\isacharunderscore}def{\isacharparenright}% |
27063 | 136 |
\begin{isamarkuptxt}% |
32983 | 137 |
\normalsize the goals are transformed to these |
138 |
statements: |
|
139 |
\begin{isabelle}% |
|
27063 | 140 |
\ {\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 |
141 |
\ {\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}% |
|
32981 | 142 |
\end{isabelle} |
32983 | 143 |
This is Presburger arithmetic, which can be solved by the |
35423 | 144 |
method \isa{arith}.% |
27063 | 145 |
\end{isamarkuptxt}% |
146 |
\isamarkuptrue% |
|
32981 | 147 |
\ \ \ \ \ \ \isacommand{by}\isamarkupfalse% |
27063 | 148 |
\ arith{\isacharplus}% |
149 |
\begin{isamarkuptxt}% |
|
32981 | 150 |
\normalsize In order to show the equations, we put ourselves |
151 |
in a situation where the lattice theorems can be used in a |
|
152 |
convenient way.% |
|
27063 | 153 |
\end{isamarkuptxt}% |
154 |
\isamarkuptrue% |
|
32981 | 155 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
32836 | 156 |
\ \isacommand{interpret}\isamarkupfalse% |
32982 | 157 |
\ int{\isacharcolon}\ lattice\ {\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\ \isacommand{{\isachardot}}\isamarkupfalse% |
27063 | 158 |
\isanewline |
32981 | 159 |
\ \ \ \ \isacommand{show}\isamarkupfalse% |
32982 | 160 |
\ {\isachardoublequoteopen}lattice{\isachardot}meet\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ y\ {\isacharequal}\ min\ x\ y{\isachardoublequoteclose}\isanewline |
32981 | 161 |
\ \ \ \ \ \ \isacommand{by}\isamarkupfalse% |
32982 | 162 |
\ {\isacharparenleft}bestsimp\ simp{\isacharcolon}\ int{\isachardot}meet{\isacharunderscore}def\ int{\isachardot}is{\isacharunderscore}inf{\isacharunderscore}def{\isacharparenright}\isanewline |
32981 | 163 |
\ \ \ \ \isacommand{show}\isamarkupfalse% |
32982 | 164 |
\ {\isachardoublequoteopen}lattice{\isachardot}join\ op\ {\isasymle}\ {\isacharparenleft}x{\isacharcolon}{\isacharcolon}int{\isacharparenright}\ y\ {\isacharequal}\ max\ x\ y{\isachardoublequoteclose}\isanewline |
32981 | 165 |
\ \ \ \ \ \ \isacommand{by}\isamarkupfalse% |
32982 | 166 |
\ {\isacharparenleft}bestsimp\ simp{\isacharcolon}\ int{\isachardot}join{\isacharunderscore}def\ int{\isachardot}is{\isacharunderscore}sup{\isacharunderscore}def{\isacharparenright}\isanewline |
32981 | 167 |
\ \ \isacommand{qed}\isamarkupfalse% |
27063 | 168 |
% |
169 |
\endisatagvisible |
|
170 |
{\isafoldvisible}% |
|
171 |
% |
|
172 |
\isadelimvisible |
|
173 |
% |
|
174 |
\endisadelimvisible |
|
175 |
% |
|
176 |
\begin{isamarkuptext}% |
|
32981 | 177 |
Next follows that \isa{op\ {\isasymle}} is a total order, again for |
32982 | 178 |
the integers.% |
27063 | 179 |
\end{isamarkuptext}% |
180 |
\isamarkuptrue% |
|
181 |
% |
|
182 |
\isadelimvisible |
|
32981 | 183 |
\ \ % |
27063 | 184 |
\endisadelimvisible |
185 |
% |
|
186 |
\isatagvisible |
|
187 |
\isacommand{interpretation}\isamarkupfalse% |
|
32982 | 188 |
\ int{\isacharcolon}\ total{\isacharunderscore}order\ {\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\isanewline |
32981 | 189 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
32836 | 190 |
\ unfold{\isacharunderscore}locales\ arith% |
27063 | 191 |
\endisatagvisible |
192 |
{\isafoldvisible}% |
|
193 |
% |
|
194 |
\isadelimvisible |
|
195 |
% |
|
196 |
\endisadelimvisible |
|
197 |
% |
|
198 |
\begin{isamarkuptext}% |
|
199 |
Theorems that are available in the theory at this point are shown in |
|
32982 | 200 |
Table~\ref{tab:int-lattice}. Two points are worth noting: |
27063 | 201 |
|
202 |
\begin{table} |
|
203 |
\hrule |
|
204 |
\vspace{2ex} |
|
205 |
\begin{center} |
|
206 |
\begin{tabular}{l} |
|
32982 | 207 |
\isa{int{\isachardot}less{\isacharunderscore}def} from locale \isa{partial{\isacharunderscore}order}: \\ |
27063 | 208 |
\quad \isa{{\isacharparenleft}{\isacharquery}x\ {\isacharless}\ {\isacharquery}y{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}{\isacharquery}x\ {\isasymle}\ {\isacharquery}y\ {\isasymand}\ {\isacharquery}x\ {\isasymnoteq}\ {\isacharquery}y{\isacharparenright}} \\ |
32982 | 209 |
\isa{int{\isachardot}meet{\isacharunderscore}left} from locale \isa{lattice}: \\ |
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
210 |
\quad \isa{min\ {\isacharquery}x\ {\isacharquery}y\ {\isasymle}\ {\isacharquery}x} \\ |
32982 | 211 |
\isa{int{\isachardot}join{\isacharunderscore}distr} from locale \isa{distrib{\isacharunderscore}lattice}: \\ |
30782
38e477e8524f
In interpretation: equations are not propagated through the hierarchy automatically.
ballarin
parents:
30780
diff
changeset
|
212 |
\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}} \\ |
32982 | 213 |
\isa{int{\isachardot}less{\isacharunderscore}total} from locale \isa{total{\isacharunderscore}order}: \\ |
30782
38e477e8524f
In interpretation: equations are not propagated through the hierarchy automatically.
ballarin
parents:
30780
diff
changeset
|
214 |
\quad \isa{{\isacharquery}x\ {\isacharless}\ {\isacharquery}y\ {\isasymor}\ {\isacharquery}x\ {\isacharequal}\ {\isacharquery}y\ {\isasymor}\ {\isacharquery}y\ {\isacharless}\ {\isacharquery}x} |
27063 | 215 |
\end{tabular} |
216 |
\end{center} |
|
217 |
\hrule |
|
32983 | 218 |
\caption{Interpreted theorems for~\isa{{\isasymle}} on the integers.} |
32982 | 219 |
\label{tab:int-lattice} |
32836 | 220 |
\end{table} |
221 |
||
222 |
\begin{itemize} |
|
223 |
\item |
|
32981 | 224 |
Locale \isa{distrib{\isacharunderscore}lattice} was also interpreted. Since the |
32983 | 225 |
locale hierarchy reflects that total orders are distributive |
32981 | 226 |
lattices, the interpretation of the latter was inserted |
227 |
automatically with the interpretation of the former. In general, |
|
32983 | 228 |
interpretation traverses the locale hierarchy upwards and interprets |
229 |
all encountered locales, regardless whether imported or proved via |
|
230 |
the \isakeyword{sublocale} command. Existing interpretations are |
|
231 |
skipped avoiding duplicate work. |
|
32836 | 232 |
\item |
32983 | 233 |
The predicate \isa{op\ {\isacharless}} appears in theorem \isa{int{\isachardot}less{\isacharunderscore}total} |
32981 | 234 |
although an equation for the replacement of \isa{op\ {\isasymsqsubset}} was only |
32983 | 235 |
given in the interpretation of \isa{partial{\isacharunderscore}order}. The |
236 |
interpretation equations are pushed downwards the hierarchy for |
|
237 |
related interpretations --- that is, for interpretations that share |
|
238 |
the instances of parameters they have in common. |
|
239 |
\end{itemize}% |
|
27063 | 240 |
\end{isamarkuptext}% |
241 |
\isamarkuptrue% |
|
32981 | 242 |
% |
27063 | 243 |
\begin{isamarkuptext}% |
32981 | 244 |
The interpretations for a locale $n$ within the current |
245 |
theory may be inspected with \isakeyword{print\_interps}~$n$. This |
|
246 |
prints the list of instances of $n$, for which interpretations exist. |
|
247 |
For example, \isakeyword{print\_interps} \isa{partial{\isacharunderscore}order} |
|
248 |
outputs the following: |
|
32983 | 249 |
\begin{small} |
32981 | 250 |
\begin{alltt} |
32982 | 251 |
int! : partial_order "op \(\le\)" |
32981 | 252 |
\end{alltt} |
32983 | 253 |
\end{small} |
254 |
Of course, there is only one interpretation. |
|
255 |
The interpretation qualifier on the left is decorated with an |
|
256 |
exclamation point. This means that it is mandatory. Qualifiers |
|
32981 | 257 |
can either be \emph{mandatory} or \emph{optional}, designated by |
258 |
``!'' or ``?'' respectively. Mandatory qualifiers must occur in a |
|
259 |
name reference while optional ones need not. Mandatory qualifiers |
|
32983 | 260 |
prevent accidental hiding of names, while optional qualifiers can be |
32981 | 261 |
more convenient to use. For \isakeyword{interpretation}, the |
32983 | 262 |
default is ``!''.% |
27063 | 263 |
\end{isamarkuptext}% |
264 |
\isamarkuptrue% |
|
265 |
% |
|
27079 | 266 |
\isamarkupsection{Locale Expressions \label{sec:expressions}% |
27063 | 267 |
} |
268 |
\isamarkuptrue% |
|
269 |
% |
|
270 |
\begin{isamarkuptext}% |
|
32983 | 271 |
A map~\isa{{\isasymphi}} between partial orders~\isa{{\isasymsqsubseteq}} and~\isa{{\isasympreceq}} |
27063 | 272 |
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 |
273 |
far: it involves two partial orders, and it is desirable to use the |
|
274 |
existing locale for both. |
|
275 |
||
32983 | 276 |
A locale for order preserving maps requires three parameters: \isa{le}~(\isakeyword{infixl}~\isa{{\isasymsqsubseteq}}) and \isa{le{\isacharprime}}~(\isakeyword{infixl}~\isa{{\isasympreceq}}) for the orders and~\isa{{\isasymphi}} |
277 |
for the map. |
|
32981 | 278 |
|
279 |
In order to reuse the existing locale for partial orders, which has |
|
32983 | 280 |
the single parameter~\isa{le}, it must be imported twice, once |
281 |
mapping its parameter to~\isa{le} from the new locale and once |
|
282 |
to~\isa{le{\isacharprime}}. This can be achieved with a compound locale |
|
32981 | 283 |
expression. |
284 |
||
32983 | 285 |
In general, a locale expression is a sequence of \emph{locale instances} |
286 |
separated by~``$\textbf{+}$'' and followed by a \isakeyword{for} |
|
32981 | 287 |
clause. |
32983 | 288 |
An instance has the following format: |
32981 | 289 |
\begin{quote} |
290 |
\textit{qualifier} \textbf{:} \textit{locale-name} |
|
291 |
\textit{parameter-instantiation} |
|
292 |
\end{quote} |
|
293 |
We have already seen locale instances as arguments to |
|
294 |
\isakeyword{interpretation} in Section~\ref{sec:interpretation}. |
|
32983 | 295 |
As before, the qualifier serves to disambiguate names from |
296 |
different instances of the same locale. While in |
|
297 |
\isakeyword{interpretation} qualifiers default to mandatory, in |
|
298 |
import and in the \isakeyword{sublocale} command, they default to |
|
299 |
optional. |
|
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
300 |
|
32983 | 301 |
Since the parameters~\isa{le} and~\isa{le{\isacharprime}} are to be partial |
32981 | 302 |
orders, our locale for order preserving maps will import the these |
303 |
instances: |
|
32983 | 304 |
\begin{small} |
32981 | 305 |
\begin{alltt} |
306 |
le: partial_order le |
|
307 |
le': partial_order le' |
|
308 |
\end{alltt} |
|
32983 | 309 |
\end{small} |
310 |
For matter of convenience we choose to name parameter names and |
|
311 |
qualifiers alike. This is an arbitrary decision. Technically, qualifiers |
|
32981 | 312 |
and parameters are unrelated. |
313 |
||
314 |
Having determined the instances, let us turn to the \isakeyword{for} |
|
315 |
clause. It serves to declare locale parameters in the same way as |
|
316 |
the context element \isakeyword{fixes} does. Context elements can |
|
317 |
only occur after the import section, and therefore the parameters |
|
32983 | 318 |
referred to in the instances must be declared in the \isakeyword{for} |
319 |
clause. The \isakeyword{for} clause is also where the syntax of these |
|
32981 | 320 |
parameters is declared. |
321 |
||
32983 | 322 |
Two context elements for the map parameter~\isa{{\isasymphi}} and the |
323 |
assumptions that it is order preserving complete the locale |
|
32981 | 324 |
declaration.% |
27063 | 325 |
\end{isamarkuptext}% |
326 |
\isamarkuptrue% |
|
327 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
328 |
\ order{\isacharunderscore}preserving\ {\isacharequal}\isanewline |
|
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
329 |
\ \ \ \ le{\isacharcolon}\ partial{\isacharunderscore}order\ le\ {\isacharplus}\ le{\isacharprime}{\isacharcolon}\ partial{\isacharunderscore}order\ le{\isacharprime}\isanewline |
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
330 |
\ \ \ \ \ \ \isakeyword{for}\ le\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasymsqsubseteq}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ \isakeyword{and}\ le{\isacharprime}\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasympreceq}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ {\isacharplus}\isanewline |
32981 | 331 |
\ \ \ \ \isakeyword{fixes}\ {\isasymphi}\isanewline |
27063 | 332 |
\ \ \ \ \isakeyword{assumes}\ hom{\isacharunderscore}le{\isacharcolon}\ {\isachardoublequoteopen}x\ {\isasymsqsubseteq}\ y\ {\isasymLongrightarrow}\ {\isasymphi}\ x\ {\isasympreceq}\ {\isasymphi}\ y{\isachardoublequoteclose}% |
333 |
\begin{isamarkuptext}% |
|
32981 | 334 |
Here are examples of theorems that are |
335 |
available in the locale: |
|
27063 | 336 |
|
32983 | 337 |
\hspace*{1em}\isa{hom{\isacharunderscore}le}: \isa{{\isacharquery}x\ {\isasymsqsubseteq}\ {\isacharquery}y\ {\isasymLongrightarrow}\ {\isasymphi}\ {\isacharquery}x\ {\isasympreceq}\ {\isasymphi}\ {\isacharquery}y} |
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
338 |
|
32983 | 339 |
\hspace*{1em}\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} |
27063 | 340 |
|
32983 | 341 |
\hspace*{1em}\isa{le{\isacharprime}{\isachardot}less{\isacharunderscore}le{\isacharunderscore}trans}: |
32981 | 342 |
\begin{isabelle}% |
32983 | 343 |
\ \ \ \ {\isasymlbrakk}partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasympreceq}\ {\isacharquery}x\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasympreceq}\ {\isacharquery}z{\isasymrbrakk}\isanewline |
344 |
\isaindent{\ \ \ \ }{\isasymLongrightarrow}\ partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasympreceq}\ {\isacharquery}x\ {\isacharquery}z% |
|
32981 | 345 |
\end{isabelle} |
346 |
While there is infix syntax for the strict operation associated to |
|
347 |
\isa{op\ {\isasymsqsubseteq}}, there is none for the strict version of \isa{op\ {\isasympreceq}}. The abbreviation \isa{less} with its infix syntax is only |
|
348 |
available for the original instance it was declared for. We may |
|
32983 | 349 |
introduce the abbreviation \isa{less{\isacharprime}} with infix syntax~\isa{{\isasymprec}} |
350 |
with the following declaration:% |
|
27063 | 351 |
\end{isamarkuptext}% |
352 |
\isamarkuptrue% |
|
353 |
\ \ \isacommand{abbreviation}\isamarkupfalse% |
|
354 |
\ {\isacharparenleft}\isakeyword{in}\ order{\isacharunderscore}preserving{\isacharparenright}\isanewline |
|
355 |
\ \ \ \ 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}% |
|
356 |
\begin{isamarkuptext}% |
|
357 |
Now the theorem is displayed nicely as |
|
30826 | 358 |
\isa{le{\isacharprime}{\isachardot}less{\isacharunderscore}le{\isacharunderscore}trans}: |
359 |
\begin{isabelle}% |
|
360 |
\ \ {\isasymlbrakk}{\isacharquery}x\ {\isasymprec}\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasympreceq}\ {\isacharquery}z{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharquery}x\ {\isasymprec}\ {\isacharquery}z% |
|
361 |
\end{isabelle}% |
|
27063 | 362 |
\end{isamarkuptext}% |
363 |
\isamarkuptrue% |
|
364 |
% |
|
32983 | 365 |
\begin{isamarkuptext}% |
366 |
There are short notations for locale expressions. These are |
|
367 |
discussed in the following.% |
|
368 |
\end{isamarkuptext}% |
|
369 |
\isamarkuptrue% |
|
370 |
% |
|
371 |
\isamarkupsubsection{Default Instantiations% |
|
32981 | 372 |
} |
373 |
\isamarkuptrue% |
|
374 |
% |
|
27063 | 375 |
\begin{isamarkuptext}% |
32983 | 376 |
It is possible to omit parameter instantiations. The |
377 |
instantiation then defaults to the name of |
|
378 |
the parameter itself. For example, the locale expression \isa{partial{\isacharunderscore}order} is short for \isa{partial{\isacharunderscore}order\ le}, since the |
|
379 |
locale's single parameter is~\isa{le}. We took advantage of this |
|
380 |
in the \isakeyword{sublocale} declarations of |
|
32981 | 381 |
Section~\ref{sec:changing-the-hierarchy}.% |
27063 | 382 |
\end{isamarkuptext}% |
383 |
\isamarkuptrue% |
|
384 |
% |
|
32983 | 385 |
\isamarkupsubsection{Implicit Parameters \label{sec:implicit-parameters}% |
386 |
} |
|
387 |
\isamarkuptrue% |
|
388 |
% |
|
27063 | 389 |
\begin{isamarkuptext}% |
32981 | 390 |
In a locale expression that occurs within a locale |
391 |
declaration, omitted parameters additionally extend the (possibly |
|
392 |
empty) \isakeyword{for} clause. |
|
393 |
||
32983 | 394 |
The \isakeyword{for} clause is a general construct of Isabelle/Isar |
395 |
to mark names occurring in the preceding declaration as ``arbitrary |
|
396 |
but fixed''. This is necessary for example, if the name is already |
|
397 |
bound in a surrounding context. In a locale expression, names |
|
398 |
occurring in parameter instantiations should be bound by a |
|
399 |
\isakeyword{for} clause whenever these names are not introduced |
|
400 |
elsewhere in the context --- for example, on the left hand side of a |
|
401 |
\isakeyword{sublocale} declaration. |
|
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
402 |
|
32981 | 403 |
There is an exception to this rule in locale declarations, where the |
32983 | 404 |
\isakeyword{for} clause serves to declare locale parameters. Here, |
32981 | 405 |
locale parameters for which no parameter instantiation is given are |
406 |
implicitly added, with their mixfix syntax, at the beginning of the |
|
407 |
\isakeyword{for} clause. For example, in a locale declaration, the |
|
408 |
expression \isa{partial{\isacharunderscore}order} is short for |
|
32983 | 409 |
\begin{small} |
32981 | 410 |
\begin{alltt} |
411 |
partial_order le \isakeyword{for} le (\isakeyword{infixl} "\(\sqsubseteq\)" 50)\textrm{.} |
|
412 |
\end{alltt} |
|
32983 | 413 |
\end{small} |
414 |
This short hand was used in the locale declarations throughout |
|
32981 | 415 |
Section~\ref{sec:import}.% |
416 |
\end{isamarkuptext}% |
|
417 |
\isamarkuptrue% |
|
418 |
% |
|
419 |
\begin{isamarkuptext}% |
|
32983 | 420 |
The following locale declarations provide more examples. A |
421 |
map~\isa{{\isasymphi}} is a lattice homomorphism if it preserves meet and |
|
32981 | 422 |
join.% |
27063 | 423 |
\end{isamarkuptext}% |
424 |
\isamarkuptrue% |
|
425 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
426 |
\ lattice{\isacharunderscore}hom\ {\isacharequal}\isanewline |
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
427 |
\ \ \ \ le{\isacharcolon}\ lattice\ {\isacharplus}\ le{\isacharprime}{\isacharcolon}\ lattice\ le{\isacharprime}\ \isakeyword{for}\ le{\isacharprime}\ {\isacharparenleft}\isakeyword{infixl}\ {\isachardoublequoteopen}{\isasympreceq}{\isachardoublequoteclose}\ {\isadigit{5}}{\isadigit{0}}{\isacharparenright}\ {\isacharplus}\isanewline |
27063 | 428 |
\ \ \ \ \isakeyword{fixes}\ {\isasymphi}\isanewline |
30826 | 429 |
\ \ \ \ \isakeyword{assumes}\ hom{\isacharunderscore}meet{\isacharcolon}\ {\isachardoublequoteopen}{\isasymphi}\ {\isacharparenleft}x\ {\isasymsqinter}\ y{\isacharparenright}\ {\isacharequal}\ le{\isacharprime}{\isachardot}meet\ {\isacharparenleft}{\isasymphi}\ x{\isacharparenright}\ {\isacharparenleft}{\isasymphi}\ y{\isacharparenright}{\isachardoublequoteclose}\isanewline |
32981 | 430 |
\ \ \ \ \ \ \isakeyword{and}\ hom{\isacharunderscore}join{\isacharcolon}\ {\isachardoublequoteopen}{\isasymphi}\ {\isacharparenleft}x\ {\isasymsqunion}\ y{\isacharparenright}\ {\isacharequal}\ le{\isacharprime}{\isachardot}join\ {\isacharparenleft}{\isasymphi}\ x{\isacharparenright}\ {\isacharparenleft}{\isasymphi}\ y{\isacharparenright}{\isachardoublequoteclose}% |
431 |
\begin{isamarkuptext}% |
|
32983 | 432 |
The parameter instantiation in the first instance of \isa{lattice} is omitted. This causes the parameter~\isa{le} to be |
433 |
added to the \isakeyword{for} clause, and the locale has |
|
434 |
parameters~\isa{le},~\isa{le{\isacharprime}} and, of course,~\isa{{\isasymphi}}. |
|
32981 | 435 |
|
436 |
Before turning to the second example, we complete the locale by |
|
32983 | 437 |
providing infix syntax for the meet and join operations of the |
32981 | 438 |
second lattice.% |
439 |
\end{isamarkuptext}% |
|
440 |
\isamarkuptrue% |
|
441 |
\ \ \isacommand{context}\isamarkupfalse% |
|
442 |
\ lattice{\isacharunderscore}hom\ \isakeyword{begin}\isanewline |
|
27063 | 443 |
\ \ \isacommand{abbreviation}\isamarkupfalse% |
32981 | 444 |
\ 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 |
27063 | 445 |
\ \ \isacommand{abbreviation}\isamarkupfalse% |
32981 | 446 |
\ 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}\isanewline |
447 |
\ \ \isacommand{end}\isamarkupfalse% |
|
448 |
% |
|
27063 | 449 |
\begin{isamarkuptext}% |
32983 | 450 |
The next example makes radical use of the short hand |
451 |
facilities. A homomorphism is an endomorphism if both orders |
|
452 |
coincide.% |
|
27063 | 453 |
\end{isamarkuptext}% |
454 |
\isamarkuptrue% |
|
455 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
456 |
\ lattice{\isacharunderscore}end\ {\isacharequal}\ lattice{\isacharunderscore}hom\ {\isacharunderscore}\ le% |
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
457 |
\begin{isamarkuptext}% |
32983 | 458 |
The notation~\isa{{\isacharunderscore}} enables to omit a parameter in a |
459 |
positional instantiation. The omitted parameter,~\isa{le} becomes |
|
32981 | 460 |
the parameter of the declared locale and is, in the following |
32983 | 461 |
position, used to instantiate the second parameter of \isa{lattice{\isacharunderscore}hom}. The effect is that of identifying the first in second |
32981 | 462 |
parameter of the homomorphism locale.% |
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
463 |
\end{isamarkuptext}% |
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
464 |
\isamarkuptrue% |
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
465 |
% |
27063 | 466 |
\begin{isamarkuptext}% |
467 |
The inheritance diagram of the situation we have now is shown |
|
468 |
in Figure~\ref{fig:hom}, where the dashed line depicts an |
|
32983 | 469 |
interpretation which is introduced below. Parameter instantiations |
470 |
are indicated by $\sqsubseteq \mapsto \preceq$ etc. By looking at |
|
471 |
the inheritance diagram it would seem |
|
32981 | 472 |
that two identical copies of each of the locales \isa{partial{\isacharunderscore}order} and \isa{lattice} are imported by \isa{lattice{\isacharunderscore}end}. This is not the case! Inheritance paths with |
473 |
identical morphisms are automatically detected and |
|
27506 | 474 |
the conclusions of the respective locales appear only once. |
27063 | 475 |
|
476 |
\begin{figure} |
|
477 |
\hrule \vspace{2ex} |
|
478 |
\begin{center} |
|
479 |
\begin{tikzpicture} |
|
480 |
\node (o) at (0,0) {\isa{partial{\isacharunderscore}order}}; |
|
481 |
\node (oh) at (1.5,-2) {\isa{order{\isacharunderscore}preserving}}; |
|
482 |
\node (oh1) at (1.5,-0.7) {$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; |
|
483 |
\node (oh2) at (0,-1.3) {$\scriptscriptstyle \sqsubseteq \mapsto \preceq$}; |
|
484 |
\node (l) at (-1.5,-2) {\isa{lattice}}; |
|
485 |
\node (lh) at (0,-4) {\isa{lattice{\isacharunderscore}hom}}; |
|
486 |
\node (lh1) at (0,-2.7) {$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; |
|
487 |
\node (lh2) at (-1.5,-3.3) {$\scriptscriptstyle \sqsubseteq \mapsto \preceq$}; |
|
488 |
\node (le) at (0,-6) {\isa{lattice{\isacharunderscore}end}}; |
|
489 |
\node (le1) at (0,-4.8) |
|
490 |
[anchor=west]{$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; |
|
491 |
\node (le2) at (0,-5.2) |
|
492 |
[anchor=west]{$\scriptscriptstyle \preceq \mapsto \sqsubseteq$}; |
|
493 |
\draw (o) -- (l); |
|
494 |
\draw[dashed] (oh) -- (lh); |
|
495 |
\draw (lh) -- (le); |
|
496 |
\draw (o) .. controls (oh1.south west) .. (oh); |
|
497 |
\draw (o) .. controls (oh2.north east) .. (oh); |
|
498 |
\draw (l) .. controls (lh1.south west) .. (lh); |
|
499 |
\draw (l) .. controls (lh2.north east) .. (lh); |
|
500 |
\end{tikzpicture} |
|
501 |
\end{center} |
|
502 |
\hrule |
|
503 |
\caption{Hierarchy of Homomorphism Locales.} |
|
504 |
\label{fig:hom} |
|
505 |
\end{figure}% |
|
506 |
\end{isamarkuptext}% |
|
507 |
\isamarkuptrue% |
|
508 |
% |
|
509 |
\begin{isamarkuptext}% |
|
510 |
It can be shown easily that a lattice homomorphism is order |
|
511 |
preserving. As the final example of this section, a locale |
|
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
512 |
interpretation is used to assert this:% |
27063 | 513 |
\end{isamarkuptext}% |
514 |
\isamarkuptrue% |
|
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
515 |
\ \ \isacommand{sublocale}\isamarkupfalse% |
27063 | 516 |
\ lattice{\isacharunderscore}hom\ {\isasymsubseteq}\ order{\isacharunderscore}preserving% |
517 |
\isadelimproof |
|
518 |
\ % |
|
519 |
\endisadelimproof |
|
520 |
% |
|
521 |
\isatagproof |
|
522 |
\isacommand{proof}\isamarkupfalse% |
|
523 |
\ unfold{\isacharunderscore}locales\isanewline |
|
524 |
\ \ \ \ \isacommand{fix}\isamarkupfalse% |
|
525 |
\ x\ y\isanewline |
|
526 |
\ \ \ \ \isacommand{assume}\isamarkupfalse% |
|
527 |
\ {\isachardoublequoteopen}x\ {\isasymsqsubseteq}\ y{\isachardoublequoteclose}\isanewline |
|
528 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
529 |
\ \isacommand{have}\isamarkupfalse% |
|
530 |
\ {\isachardoublequoteopen}y\ {\isacharequal}\ {\isacharparenleft}x\ {\isasymsqunion}\ y{\isacharparenright}{\isachardoublequoteclose}\ \isacommand{by}\isamarkupfalse% |
|
531 |
\ {\isacharparenleft}simp\ add{\isacharcolon}\ le{\isachardot}join{\isacharunderscore}connection{\isacharparenright}\isanewline |
|
532 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
533 |
\ \isacommand{have}\isamarkupfalse% |
|
534 |
\ {\isachardoublequoteopen}{\isasymphi}\ y\ {\isacharequal}\ {\isacharparenleft}{\isasymphi}\ x\ {\isasymsqunion}{\isacharprime}\ {\isasymphi}\ y{\isacharparenright}{\isachardoublequoteclose}\ \isacommand{by}\isamarkupfalse% |
|
535 |
\ {\isacharparenleft}simp\ add{\isacharcolon}\ hom{\isacharunderscore}join\ {\isacharbrackleft}symmetric{\isacharbrackright}{\isacharparenright}\isanewline |
|
536 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
537 |
\ \isacommand{show}\isamarkupfalse% |
|
538 |
\ {\isachardoublequoteopen}{\isasymphi}\ x\ {\isasympreceq}\ {\isasymphi}\ y{\isachardoublequoteclose}\ \isacommand{by}\isamarkupfalse% |
|
539 |
\ {\isacharparenleft}simp\ add{\isacharcolon}\ le{\isacharprime}{\isachardot}join{\isacharunderscore}connection{\isacharparenright}\isanewline |
|
540 |
\ \ \isacommand{qed}\isamarkupfalse% |
|
541 |
% |
|
542 |
\endisatagproof |
|
543 |
{\isafoldproof}% |
|
544 |
% |
|
545 |
\isadelimproof |
|
546 |
% |
|
547 |
\endisadelimproof |
|
548 |
% |
|
549 |
\begin{isamarkuptext}% |
|
30393
aa6f42252bf6
replaced old locale option by proper "text (in locale)";
wenzelm
parents:
29568
diff
changeset
|
550 |
Theorems and other declarations --- syntax, in particular --- from |
aa6f42252bf6
replaced old locale option by proper "text (in locale)";
wenzelm
parents:
29568
diff
changeset
|
551 |
the locale \isa{order{\isacharunderscore}preserving} are now active in \isa{lattice{\isacharunderscore}hom}, for example |
30826 | 552 |
\isa{hom{\isacharunderscore}le}: |
553 |
\begin{isabelle}% |
|
554 |
\ \ {\isacharquery}x\ {\isasymsqsubseteq}\ {\isacharquery}y\ {\isasymLongrightarrow}\ {\isasymphi}\ {\isacharquery}x\ {\isasympreceq}\ {\isasymphi}\ {\isacharquery}y% |
|
32983 | 555 |
\end{isabelle} |
556 |
This theorem will be useful in the following section.% |
|
557 |
\end{isamarkuptext}% |
|
558 |
\isamarkuptrue% |
|
559 |
% |
|
560 |
\isamarkupsection{Conditional Interpretation% |
|
561 |
} |
|
562 |
\isamarkuptrue% |
|
563 |
% |
|
564 |
\begin{isamarkuptext}% |
|
565 |
There are situations where an interpretation is not possible |
|
566 |
in the general case since the desired property is only valid if |
|
567 |
certain conditions are fulfilled. Take, for example, the function |
|
568 |
\isa{{\isasymlambda}i{\isachardot}\ n\ {\isacharasterisk}\ i} that scales its argument by a constant factor. |
|
569 |
This function is order preserving (and even a lattice endomorphism) |
|
570 |
with respect to \isa{op\ {\isasymle}} provided \isa{n\ {\isasymge}\ {\isadigit{0}}}. |
|
571 |
||
572 |
It is not possible to express this using a global interpretation, |
|
573 |
because it is in general unspecified whether~\isa{n} is |
|
574 |
non-negative, but one may make an interpretation in an inner context |
|
575 |
of a proof where full information is available. |
|
576 |
This is not fully satisfactory either, since potentially |
|
577 |
interpretations may be required to make interpretations in many |
|
578 |
contexts. What is |
|
579 |
required is an interpretation that depends on the condition --- and |
|
580 |
this can be done with the \isakeyword{sublocale} command. For this |
|
581 |
purpose, we introduce a locale for the condition.% |
|
582 |
\end{isamarkuptext}% |
|
583 |
\isamarkuptrue% |
|
584 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
585 |
\ non{\isacharunderscore}negative\ {\isacharequal}\isanewline |
|
586 |
\ \ \ \ \isakeyword{fixes}\ n\ {\isacharcolon}{\isacharcolon}\ int\isanewline |
|
587 |
\ \ \ \ \isakeyword{assumes}\ non{\isacharunderscore}neg{\isacharcolon}\ {\isachardoublequoteopen}{\isadigit{0}}\ {\isasymle}\ n{\isachardoublequoteclose}% |
|
588 |
\begin{isamarkuptext}% |
|
589 |
It is again convenient to make the interpretation in an |
|
590 |
incremental fashion, first for order preserving maps, the for |
|
591 |
lattice endomorphisms.% |
|
592 |
\end{isamarkuptext}% |
|
593 |
\isamarkuptrue% |
|
594 |
\ \ \isacommand{sublocale}\isamarkupfalse% |
|
595 |
\ non{\isacharunderscore}negative\ {\isasymsubseteq}\isanewline |
|
596 |
\ \ \ \ \ \ order{\isacharunderscore}preserving\ {\isachardoublequoteopen}op\ {\isasymle}{\isachardoublequoteclose}\ {\isachardoublequoteopen}op\ {\isasymle}{\isachardoublequoteclose}\ {\isachardoublequoteopen}{\isasymlambda}i{\isachardot}\ n\ {\isacharasterisk}\ i{\isachardoublequoteclose}\isanewline |
|
597 |
% |
|
598 |
\isadelimproof |
|
599 |
\ \ \ \ % |
|
600 |
\endisadelimproof |
|
601 |
% |
|
602 |
\isatagproof |
|
603 |
\isacommand{using}\isamarkupfalse% |
|
604 |
\ non{\isacharunderscore}neg\ \isacommand{by}\isamarkupfalse% |
|
605 |
\ unfold{\isacharunderscore}locales\ {\isacharparenleft}rule\ mult{\isacharunderscore}left{\isacharunderscore}mono{\isacharparenright}% |
|
606 |
\endisatagproof |
|
607 |
{\isafoldproof}% |
|
608 |
% |
|
609 |
\isadelimproof |
|
610 |
% |
|
611 |
\endisadelimproof |
|
612 |
% |
|
613 |
\begin{isamarkuptext}% |
|
614 |
While the proof of the previous interpretation |
|
615 |
is straightforward from monotonicity lemmas for~\isa{op\ {\isacharasterisk}}, the |
|
616 |
second proof follows a useful pattern.% |
|
617 |
\end{isamarkuptext}% |
|
618 |
\isamarkuptrue% |
|
619 |
% |
|
620 |
\isadelimvisible |
|
621 |
\ \ % |
|
622 |
\endisadelimvisible |
|
623 |
% |
|
624 |
\isatagvisible |
|
625 |
\isacommand{sublocale}\isamarkupfalse% |
|
626 |
\ non{\isacharunderscore}negative\ {\isasymsubseteq}\ lattice{\isacharunderscore}end\ {\isachardoublequoteopen}op\ {\isasymle}{\isachardoublequoteclose}\ {\isachardoublequoteopen}{\isasymlambda}i{\isachardot}\ n\ {\isacharasterisk}\ i{\isachardoublequoteclose}\isanewline |
|
627 |
\ \ \isacommand{proof}\isamarkupfalse% |
|
628 |
\ {\isacharparenleft}unfold{\isacharunderscore}locales{\isacharcomma}\ unfold\ int{\isacharunderscore}min{\isacharunderscore}eq\ int{\isacharunderscore}max{\isacharunderscore}eq{\isacharparenright}% |
|
629 |
\begin{isamarkuptxt}% |
|
630 |
\normalsize Unfolding the locale predicates \emph{and} the |
|
631 |
interpretation equations immediately yields two subgoals that |
|
632 |
reflect the core conjecture. |
|
633 |
\begin{isabelle}% |
|
634 |
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ n\ {\isacharasterisk}\ min\ x\ y\ {\isacharequal}\ min\ {\isacharparenleft}n\ {\isacharasterisk}\ x{\isacharparenright}\ {\isacharparenleft}n\ {\isacharasterisk}\ y{\isacharparenright}\isanewline |
|
635 |
\ {\isadigit{2}}{\isachardot}\ {\isasymAnd}x\ y{\isachardot}\ n\ {\isacharasterisk}\ max\ x\ y\ {\isacharequal}\ max\ {\isacharparenleft}n\ {\isacharasterisk}\ x{\isacharparenright}\ {\isacharparenleft}n\ {\isacharasterisk}\ y{\isacharparenright}% |
|
636 |
\end{isabelle} |
|
637 |
It is now necessary to show, in the context of \isa{non{\isacharunderscore}negative}, that multiplication by~\isa{n} commutes with |
|
638 |
\isa{min} and \isa{max}.% |
|
639 |
\end{isamarkuptxt}% |
|
640 |
\isamarkuptrue% |
|
641 |
\ \ \isacommand{qed}\isamarkupfalse% |
|
642 |
\ {\isacharparenleft}auto\ simp{\isacharcolon}\ hom{\isacharunderscore}le{\isacharparenright}% |
|
643 |
\endisatagvisible |
|
644 |
{\isafoldvisible}% |
|
645 |
% |
|
646 |
\isadelimvisible |
|
647 |
% |
|
648 |
\endisadelimvisible |
|
649 |
% |
|
650 |
\begin{isamarkuptext}% |
|
651 |
The lemma \isa{hom{\isacharunderscore}le} |
|
652 |
simplifies a proof that would have otherwise been lengthy and we may |
|
653 |
consider making it a default rule for the simplifier:% |
|
27063 | 654 |
\end{isamarkuptext}% |
655 |
\isamarkuptrue% |
|
32983 | 656 |
\ \ \isacommand{lemmas}\isamarkupfalse% |
657 |
\ {\isacharparenleft}\isakeyword{in}\ order{\isacharunderscore}preserving{\isacharparenright}\ hom{\isacharunderscore}le\ {\isacharbrackleft}simp{\isacharbrackright}% |
|
658 |
\isamarkupsubsection{Avoiding Infinite Chains of Interpretations |
|
659 |
\label{sec:infinite-chains}% |
|
660 |
} |
|
661 |
\isamarkuptrue% |
|
662 |
% |
|
663 |
\begin{isamarkuptext}% |
|
664 |
Similar situations arise frequently in formalisations of |
|
665 |
abstract algebra where it is desirable to express that certain |
|
666 |
constructions preserve certain properties. For example, polynomials |
|
667 |
over rings are rings, or --- an example from the domain where the |
|
668 |
illustrations of this tutorial are taken from --- a partial order |
|
669 |
may be obtained for a function space by point-wise lifting of the |
|
670 |
partial order of the co-domain. This corresponds to the following |
|
671 |
interpretation:% |
|
672 |
\end{isamarkuptext}% |
|
673 |
\isamarkuptrue% |
|
674 |
% |
|
675 |
\isadelimvisible |
|
676 |
\ \ % |
|
677 |
\endisadelimvisible |
|
678 |
% |
|
679 |
\isatagvisible |
|
680 |
\isacommand{sublocale}\isamarkupfalse% |
|
681 |
\ partial{\isacharunderscore}order\ {\isasymsubseteq}\ f{\isacharcolon}\ partial{\isacharunderscore}order\ {\isachardoublequoteopen}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isachardoublequoteclose}\isanewline |
|
682 |
\ \ \ \ \isacommand{oops}\isamarkupfalse% |
|
683 |
% |
|
684 |
\endisatagvisible |
|
685 |
{\isafoldvisible}% |
|
686 |
% |
|
687 |
\isadelimvisible |
|
688 |
% |
|
689 |
\endisadelimvisible |
|
690 |
% |
|
691 |
\begin{isamarkuptext}% |
|
692 |
Unfortunately this is a cyclic interpretation that leads to an |
|
693 |
infinite chain, namely |
|
694 |
\begin{isabelle}% |
|
695 |
\ \ partial{\isacharunderscore}order\ {\isasymsubseteq}\ partial{\isacharunderscore}order\ {\isacharparenleft}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isacharparenright}\ {\isasymsubseteq}\isanewline |
|
696 |
\isaindent{\ \ }\ \ partial{\isacharunderscore}order\ {\isacharparenleft}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x\ y{\isachardot}\ f\ x\ y\ {\isasymsqsubseteq}\ g\ x\ y{\isacharparenright}\ {\isasymsubseteq}\ \ {\isasymdots}% |
|
697 |
\end{isabelle} |
|
698 |
and the interpretation is rejected. |
|
699 |
||
700 |
Instead it is necessary to declare a locale that is logically |
|
701 |
equivalent to \isa{partial{\isacharunderscore}order} but serves to collect facts |
|
702 |
about functions spaces where the co-domain is a partial order, and |
|
703 |
to make the interpretation in its context:% |
|
704 |
\end{isamarkuptext}% |
|
705 |
\isamarkuptrue% |
|
706 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
707 |
\ fun{\isacharunderscore}partial{\isacharunderscore}order\ {\isacharequal}\ partial{\isacharunderscore}order\isanewline |
|
708 |
\isanewline |
|
709 |
\ \ \isacommand{sublocale}\isamarkupfalse% |
|
710 |
\ fun{\isacharunderscore}partial{\isacharunderscore}order\ {\isasymsubseteq}\isanewline |
|
711 |
\ \ \ \ \ \ f{\isacharcolon}\ partial{\isacharunderscore}order\ {\isachardoublequoteopen}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isachardoublequoteclose}\isanewline |
|
712 |
% |
|
713 |
\isadelimproof |
|
714 |
\ \ \ \ % |
|
715 |
\endisadelimproof |
|
716 |
% |
|
717 |
\isatagproof |
|
718 |
\isacommand{by}\isamarkupfalse% |
|
719 |
\ unfold{\isacharunderscore}locales\ {\isacharparenleft}fast{\isacharcomma}rule{\isacharcomma}fast{\isacharcomma}blast\ intro{\isacharcolon}\ trans{\isacharparenright}% |
|
720 |
\endisatagproof |
|
721 |
{\isafoldproof}% |
|
722 |
% |
|
723 |
\isadelimproof |
|
724 |
% |
|
725 |
\endisadelimproof |
|
726 |
% |
|
727 |
\begin{isamarkuptext}% |
|
728 |
It is quite common in abstract algebra that such a construction |
|
729 |
maps a hierarchy of algebraic structures (or specifications) to a |
|
730 |
related hierarchy. By means of the same lifting, a function space |
|
731 |
is a lattice if its co-domain is a lattice:% |
|
732 |
\end{isamarkuptext}% |
|
733 |
\isamarkuptrue% |
|
734 |
\ \ \isacommand{locale}\isamarkupfalse% |
|
735 |
\ fun{\isacharunderscore}lattice\ {\isacharequal}\ fun{\isacharunderscore}partial{\isacharunderscore}order\ {\isacharplus}\ lattice\isanewline |
|
736 |
\isanewline |
|
737 |
\ \ \isacommand{sublocale}\isamarkupfalse% |
|
738 |
\ fun{\isacharunderscore}lattice\ {\isasymsubseteq}\ f{\isacharcolon}\ lattice\ {\isachardoublequoteopen}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isachardoublequoteclose}\isanewline |
|
739 |
% |
|
740 |
\isadelimproof |
|
741 |
\ \ \ \ % |
|
742 |
\endisadelimproof |
|
743 |
% |
|
744 |
\isatagproof |
|
745 |
\isacommand{proof}\isamarkupfalse% |
|
746 |
\ unfold{\isacharunderscore}locales\isanewline |
|
747 |
\ \ \ \ \isacommand{fix}\isamarkupfalse% |
|
748 |
\ f\ g\isanewline |
|
749 |
\ \ \ \ \isacommand{have}\isamarkupfalse% |
|
750 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}inf\ {\isacharparenleft}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isacharparenright}\ f\ g\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ f\ x\ {\isasymsqinter}\ g\ x{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
751 |
\ \ \ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
752 |
\ {\isacharparenleft}rule\ is{\isacharunderscore}infI{\isacharparenright}\ \isacommand{apply}\isamarkupfalse% |
|
753 |
\ rule{\isacharplus}\ \isacommand{apply}\isamarkupfalse% |
|
754 |
\ {\isacharparenleft}drule\ spec{\isacharcomma}\ assumption{\isacharparenright}{\isacharplus}\ \isacommand{done}\isamarkupfalse% |
|
755 |
\isanewline |
|
756 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
757 |
\ \isacommand{show}\isamarkupfalse% |
|
758 |
\ {\isachardoublequoteopen}{\isasymexists}inf{\isachardot}\ partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}inf\ {\isacharparenleft}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isacharparenright}\ f\ g\ inf{\isachardoublequoteclose}\isanewline |
|
759 |
\ \ \ \ \ \ \isacommand{by}\isamarkupfalse% |
|
760 |
\ fast\isanewline |
|
761 |
\ \ \isacommand{next}\isamarkupfalse% |
|
762 |
\isanewline |
|
763 |
\ \ \ \ \isacommand{fix}\isamarkupfalse% |
|
764 |
\ f\ g\isanewline |
|
765 |
\ \ \ \ \isacommand{have}\isamarkupfalse% |
|
766 |
\ {\isachardoublequoteopen}partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}sup\ {\isacharparenleft}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isacharparenright}\ f\ g\ {\isacharparenleft}{\isasymlambda}x{\isachardot}\ f\ x\ {\isasymsqunion}\ g\ x{\isacharparenright}{\isachardoublequoteclose}\isanewline |
|
767 |
\ \ \ \ \ \ \isacommand{apply}\isamarkupfalse% |
|
768 |
\ {\isacharparenleft}rule\ is{\isacharunderscore}supI{\isacharparenright}\ \isacommand{apply}\isamarkupfalse% |
|
769 |
\ rule{\isacharplus}\ \isacommand{apply}\isamarkupfalse% |
|
770 |
\ {\isacharparenleft}drule\ spec{\isacharcomma}\ assumption{\isacharparenright}{\isacharplus}\ \isacommand{done}\isamarkupfalse% |
|
771 |
\isanewline |
|
772 |
\ \ \ \ \isacommand{then}\isamarkupfalse% |
|
773 |
\ \isacommand{show}\isamarkupfalse% |
|
774 |
\ {\isachardoublequoteopen}{\isasymexists}sup{\isachardot}\ partial{\isacharunderscore}order{\isachardot}is{\isacharunderscore}sup\ {\isacharparenleft}{\isasymlambda}f\ g{\isachardot}\ {\isasymforall}x{\isachardot}\ f\ x\ {\isasymsqsubseteq}\ g\ x{\isacharparenright}\ f\ g\ sup{\isachardoublequoteclose}\isanewline |
|
775 |
\ \ \ \ \ \ \isacommand{by}\isamarkupfalse% |
|
776 |
\ fast\isanewline |
|
777 |
\ \ \isacommand{qed}\isamarkupfalse% |
|
778 |
% |
|
779 |
\endisatagproof |
|
780 |
{\isafoldproof}% |
|
781 |
% |
|
782 |
\isadelimproof |
|
783 |
% |
|
784 |
\endisadelimproof |
|
27063 | 785 |
% |
786 |
\isamarkupsection{Further Reading% |
|
787 |
} |
|
788 |
\isamarkuptrue% |
|
789 |
% |
|
790 |
\begin{isamarkuptext}% |
|
791 |
More information on locales and their interpretation is |
|
792 |
available. For the locale hierarchy of import and interpretation |
|
32983 | 793 |
dependencies see~\cite{Ballarin2006a}; interpretations in theories |
794 |
and proofs are covered in~\cite{Ballarin2006b}. In the latter, I |
|
27063 | 795 |
show how interpretation in proofs enables to reason about families |
796 |
of algebraic structures, which cannot be expressed with locales |
|
797 |
directly. |
|
798 |
||
32983 | 799 |
Haftmann and Wenzel~\cite{HaftmannWenzel2007} overcome a restriction |
27063 | 800 |
of axiomatic type classes through a combination with locale |
801 |
interpretation. The result is a Haskell-style class system with a |
|
30750
3779e2158dad
Update explanation of locale expressions to locale reimplementation.
ballarin
parents:
30580
diff
changeset
|
802 |
facility to generate ML and Haskell code. Classes are sufficient for |
27063 | 803 |
simple specifications with a single type parameter. The locales for |
804 |
orders and lattices presented in this tutorial fall into this |
|
805 |
category. Order preserving maps, homomorphisms and vector spaces, |
|
806 |
on the other hand, do not. |
|
807 |
||
32981 | 808 |
The locales reimplementation for Isabelle 2009 provides, among other |
32983 | 809 |
improvements, a clean integration with Isabelle/Isar's local theory |
810 |
mechanisms, which are described in another paper by Haftmann and |
|
811 |
Wenzel~\cite{HaftmannWenzel2009}. |
|
32981 | 812 |
|
32983 | 813 |
The original work of Kamm\"uller on locales~\cite{KammullerEtAl1999} |
814 |
may be of interest from a historical perspective. My previous |
|
815 |
report on locales and locale expressions~\cite{Ballarin2004a} |
|
816 |
describes a simpler form of expressions than available now and is |
|
817 |
outdated. The mathematical background on orders and lattices is |
|
818 |
taken from Jacobson's textbook on algebra~\cite[Chapter~8]{Jacobson1985}. |
|
32981 | 819 |
|
820 |
The sources of this tutorial, which include all proofs, are |
|
821 |
available with the Isabelle distribution at |
|
822 |
\url{http://isabelle.in.tum.de}.% |
|
27063 | 823 |
\end{isamarkuptext}% |
824 |
\isamarkuptrue% |
|
825 |
% |
|
826 |
\begin{isamarkuptext}% |
|
827 |
\begin{table} |
|
828 |
\hrule |
|
829 |
\vspace{2ex} |
|
830 |
\begin{center} |
|
831 |
\begin{tabular}{l>$c<$l} |
|
832 |
\multicolumn{3}{l}{Miscellaneous} \\ |
|
833 |
||
834 |
\textit{attr-name} & ::= |
|
835 |
& \textit{name} $|$ \textit{attribute} $|$ |
|
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
836 |
\textit{name} \textit{attribute} \\ |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
837 |
\textit{qualifier} & ::= |
30751 | 838 |
& \textit{name} [``\textbf{?}'' $|$ ``\textbf{!}''] \\[2ex] |
27063 | 839 |
|
840 |
\multicolumn{3}{l}{Context Elements} \\ |
|
841 |
||
842 |
\textit{fixes} & ::= |
|
843 |
& \textit{name} [ ``\textbf{::}'' \textit{type} ] |
|
844 |
[ ``\textbf{(}'' \textbf{structure} ``\textbf{)}'' $|$ |
|
845 |
\textit{mixfix} ] \\ |
|
846 |
\begin{comment} |
|
847 |
\textit{constrains} & ::= |
|
848 |
& \textit{name} ``\textbf{::}'' \textit{type} \\ |
|
849 |
\end{comment} |
|
850 |
\textit{assumes} & ::= |
|
851 |
& [ \textit{attr-name} ``\textbf{:}'' ] \textit{proposition} \\ |
|
852 |
\begin{comment} |
|
853 |
\textit{defines} & ::= |
|
854 |
& [ \textit{attr-name} ``\textbf{:}'' ] \textit{proposition} \\ |
|
855 |
\textit{notes} & ::= |
|
856 |
& [ \textit{attr-name} ``\textbf{=}'' ] |
|
857 |
( \textit{qualified-name} [ \textit{attribute} ] )$^+$ \\ |
|
858 |
\end{comment} |
|
859 |
||
860 |
\textit{element} & ::= |
|
861 |
& \textbf{fixes} \textit{fixes} ( \textbf{and} \textit{fixes} )$^*$ \\ |
|
862 |
\begin{comment} |
|
863 |
& | |
|
864 |
& \textbf{constrains} \textit{constrains} |
|
865 |
( \textbf{and} \textit{constrains} )$^*$ \\ |
|
866 |
\end{comment} |
|
867 |
& | |
|
868 |
& \textbf{assumes} \textit{assumes} ( \textbf{and} \textit{assumes} )$^*$ \\[2ex] |
|
869 |
%\begin{comment} |
|
870 |
% & | |
|
871 |
% & \textbf{defines} \textit{defines} ( \textbf{and} \textit{defines} )$^*$ \\ |
|
872 |
% & | |
|
873 |
% & \textbf{notes} \textit{notes} ( \textbf{and} \textit{notes} )$^*$ \\ |
|
874 |
%\end{comment} |
|
875 |
||
876 |
\multicolumn{3}{l}{Locale Expressions} \\ |
|
877 |
||
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
878 |
\textit{pos-insts} & ::= |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
879 |
& ( \textit{term} $|$ ``\textbf{\_}'' )$^*$ \\ |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
880 |
\textit{named-insts} & ::= |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
881 |
& \textbf{where} \textit{name} ``\textbf{=}'' \textit{term} |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
882 |
( \textbf{and} \textit{name} ``\textbf{=}'' \textit{term} )$^*$ \\ |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
883 |
\textit{instance} & ::= |
30751 | 884 |
& [ \textit{qualifier} ``\textbf{:}'' ] |
33868 | 885 |
\textit{name} ( \textit{pos-insts} $|$ \textit{named-inst} ) \\ |
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
886 |
\textit{expression} & ::= |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
887 |
& \textit{instance} ( ``\textbf{+}'' \textit{instance} )$^*$ |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
888 |
[ \textbf{for} \textit{fixes} ( \textbf{and} \textit{fixes} )$^*$ ] \\[2ex] |
27063 | 889 |
|
890 |
\multicolumn{3}{l}{Declaration of Locales} \\ |
|
891 |
||
892 |
\textit{locale} & ::= |
|
893 |
& \textit{element}$^+$ \\ |
|
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
894 |
& | & \textit{expression} [ ``\textbf{+}'' \textit{element}$^+$ ] \\ |
27063 | 895 |
\textit{toplevel} & ::= |
896 |
& \textbf{locale} \textit{name} [ ``\textbf{=}'' |
|
897 |
\textit{locale} ] \\[2ex] |
|
898 |
||
899 |
\multicolumn{3}{l}{Interpretation} \\ |
|
900 |
||
901 |
\textit{equation} & ::= & [ \textit{attr-name} ``\textbf{:}'' ] |
|
902 |
\textit{prop} \\ |
|
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
903 |
\textit{equations} & ::= & \textbf{where} \textit{equation} ( \textbf{and} |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
904 |
\textit{equation} )$^*$ \\ |
27063 | 905 |
\textit{toplevel} & ::= |
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
906 |
& \textbf{sublocale} \textit{name} ( ``$<$'' $|$ |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
907 |
``$\subseteq$'' ) \textit{expression} \textit{proof} \\ |
27063 | 908 |
& | |
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
909 |
& \textbf{interpretation} |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
910 |
\textit{expression} [ \textit{equations} ] \textit{proof} \\ |
27063 | 911 |
& | |
29566
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
912 |
& \textbf{interpret} |
937baa077df2
Fixed tutorial to compile with new locales; grammar of new locale commands.
ballarin
parents:
28259
diff
changeset
|
913 |
\textit{expression} \textit{proof} \\[2ex] |
27063 | 914 |
|
915 |
\multicolumn{3}{l}{Diagnostics} \\ |
|
916 |
||
917 |
\textit{toplevel} & ::= |
|
32981 | 918 |
& \textbf{print\_locales} \\ |
33868 | 919 |
& | & \textbf{print\_locale} [ ``\textbf{!}'' ] \textit{name} \\ |
920 |
& | & \textbf{print\_interps} \textit{name} |
|
27063 | 921 |
\end{tabular} |
922 |
\end{center} |
|
923 |
\hrule |
|
30826 | 924 |
\caption{Syntax of Locale Commands.} |
27063 | 925 |
\label{tab:commands} |
926 |
\end{table}% |
|
927 |
\end{isamarkuptext}% |
|
928 |
\isamarkuptrue% |
|
929 |
% |
|
930 |
\begin{isamarkuptext}% |
|
32983 | 931 |
\textbf{Revision History.} For the present third revision of |
932 |
the tutorial, much of the explanatory text |
|
933 |
was rewritten. Inheritance of interpretation equations is |
|
934 |
available with the forthcoming release of Isabelle, which at the |
|
935 |
time of editing these notes is expected for the end of 2009. |
|
936 |
The second revision accommodates changes introduced by the locales |
|
937 |
reimplementation for Isabelle 2009. Most notably locale expressions |
|
938 |
have been generalised from renaming to instantiation.% |
|
32981 | 939 |
\end{isamarkuptext}% |
940 |
\isamarkuptrue% |
|
941 |
% |
|
942 |
\begin{isamarkuptext}% |
|
27063 | 943 |
\textbf{Acknowledgements.} Alexander Krauss, Tobias Nipkow, |
37206 | 944 |
Randy Pollack, Andreas Schropp, Christian Sternagel and Makarius Wenzel |
945 |
have made |
|
32983 | 946 |
useful comments on earlier versions of this document. The section |
947 |
on conditional interpretation was inspired by a number of e-mail |
|
948 |
enquiries the author received from locale users, and which suggested |
|
949 |
that this use case is important enough to deserve explicit |
|
950 |
explanation. The term \emph{conditional interpretation} is due to |
|
951 |
Larry Paulson.% |
|
27063 | 952 |
\end{isamarkuptext}% |
953 |
\isamarkuptrue% |
|
954 |
% |
|
955 |
\isadelimtheory |
|
956 |
% |
|
957 |
\endisadelimtheory |
|
958 |
% |
|
959 |
\isatagtheory |
|
27080 | 960 |
\isacommand{end}\isamarkupfalse% |
27063 | 961 |
% |
962 |
\endisatagtheory |
|
963 |
{\isafoldtheory}% |
|
964 |
% |
|
965 |
\isadelimtheory |
|
966 |
% |
|
967 |
\endisadelimtheory |
|
27080 | 968 |
\isanewline |
27063 | 969 |
\end{isabellebody}% |
970 |
%%% Local Variables: |
|
971 |
%%% mode: latex |
|
972 |
%%% TeX-master: "root" |
|
973 |
%%% End: |