author | wenzelm |
Mon, 09 Apr 2012 23:06:14 +0200 | |
changeset 47410 | 33f2f968c0a1 |
parent 40406 | 313a24b66a8d |
permissions | -rw-r--r-- |
27063 | 1 |
% |
2 |
\begin{isabellebody}% |
|
3 |
\def\isabellecontext{Examples{\isadigit{1}}}% |
|
4 |
% |
|
5 |
\isadelimtheory |
|
6 |
% |
|
7 |
\endisadelimtheory |
|
8 |
% |
|
9 |
\isatagtheory |
|
27080 | 10 |
\isacommand{theory}\isamarkupfalse% |
11 |
\ Examples{\isadigit{1}}\isanewline |
|
12 |
\isakeyword{imports}\ Examples\isanewline |
|
13 |
\isakeyword{begin}% |
|
27063 | 14 |
\endisatagtheory |
15 |
{\isafoldtheory}% |
|
16 |
% |
|
17 |
\isadelimtheory |
|
18 |
% |
|
19 |
\endisadelimtheory |
|
20 |
% |
|
32983 | 21 |
\begin{isamarkuptext}% |
22 |
\vspace{-5ex}% |
|
23 |
\end{isamarkuptext}% |
|
24 |
\isamarkuptrue% |
|
25 |
% |
|
32981 | 26 |
\isamarkupsection{Use of Locales in Theories and Proofs |
27 |
\label{sec:interpretation}% |
|
27063 | 28 |
} |
29 |
\isamarkuptrue% |
|
30 |
% |
|
31 |
\begin{isamarkuptext}% |
|
32983 | 32 |
Locales can be interpreted in the contexts of theories and |
27063 | 33 |
structured proofs. These interpretations are dynamic, too. |
32981 | 34 |
Conclusions of locales will be propagated to the current theory or |
35 |
the current proof context.% |
|
36 |
\footnote{Strictly speaking, only interpretation in theories is |
|
37 |
dynamic since it is not possible to change locales or the locale |
|
38 |
hierarchy from within a proof.} |
|
39 |
The focus of this section is on |
|
40 |
interpretation in theories, but we will also encounter |
|
41 |
interpretations in proofs, in |
|
42 |
Section~\ref{sec:local-interpretation}. |
|
30580
cc5a55d7a5be
Updated chapters 1-5 to locale reimplementation.
ballarin
parents:
29297
diff
changeset
|
43 |
|
32982 | 44 |
As an example, consider the type of integers \isa{int}. The |
40406 | 45 |
relation \isa{op\ {\isaliteral{5C3C6C653E}{\isasymle}}} is a total order over \isa{int}. We start |
46 |
with the interpretation that \isa{op\ {\isaliteral{5C3C6C653E}{\isasymle}}} is a partial order. The |
|
32983 | 47 |
facilities of the interpretation command are explored gradually in |
48 |
three versions.% |
|
27063 | 49 |
\end{isamarkuptext}% |
50 |
\isamarkuptrue% |
|
51 |
% |
|
30580
cc5a55d7a5be
Updated chapters 1-5 to locale reimplementation.
ballarin
parents:
29297
diff
changeset
|
52 |
\isamarkupsubsection{First Version: Replacement of Parameters Only |
cc5a55d7a5be
Updated chapters 1-5 to locale reimplementation.
ballarin
parents:
29297
diff
changeset
|
53 |
\label{sec:po-first}% |
27063 | 54 |
} |
55 |
\isamarkuptrue% |
|
56 |
% |
|
57 |
\begin{isamarkuptext}% |
|
32981 | 58 |
The command \isakeyword{interpretation} is for the interpretation of |
59 |
locale in theories. In the following example, the parameter of locale |
|
40406 | 60 |
\isa{partial{\isaliteral{5F}{\isacharunderscore}}order} is replaced by \isa{op\ {\isaliteral{5C3C6C653E}{\isasymle}}} and the locale instance is interpreted in the current |
32981 | 61 |
theory.% |
27063 | 62 |
\end{isamarkuptext}% |
63 |
\isamarkuptrue% |
|
64 |
% |
|
65 |
\isadelimvisible |
|
66 |
\ \ % |
|
67 |
\endisadelimvisible |
|
68 |
% |
|
69 |
\isatagvisible |
|
70 |
\isacommand{interpretation}\isamarkupfalse% |
|
40406 | 71 |
\ int{\isaliteral{3A}{\isacharcolon}}\ partial{\isaliteral{5F}{\isacharunderscore}}order\ {\isaliteral{22}{\isachardoublequoteopen}}op\ {\isaliteral{5C3C6C653E}{\isasymle}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ int\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ int\ {\isaliteral{5C3C52696768746172726F773E}{\isasymRightarrow}}\ bool{\isaliteral{22}{\isachardoublequoteclose}}% |
27063 | 72 |
\begin{isamarkuptxt}% |
32981 | 73 |
\normalsize |
74 |
The argument of the command is a simple \emph{locale expression} |
|
75 |
consisting of the name of the interpreted locale, which is |
|
40406 | 76 |
preceded by the qualifier \isa{int{\isaliteral{3A}{\isacharcolon}}} and succeeded by a |
32981 | 77 |
white-space-separated list of terms, which provide a full |
78 |
instantiation of the locale parameters. The parameters are referred |
|
79 |
to by order of declaration, which is also the order in which |
|
32983 | 80 |
\isakeyword{print\_locale} outputs them. The locale has only a |
81 |
single parameter, hence the list of instantiation terms is a |
|
82 |
singleton. |
|
32981 | 83 |
|
84 |
The command creates the goal |
|
30580
cc5a55d7a5be
Updated chapters 1-5 to locale reimplementation.
ballarin
parents:
29297
diff
changeset
|
85 |
\begin{isabelle}% |
40406 | 86 |
\ {\isadigit{1}}{\isaliteral{2E}{\isachardot}}\ partial{\isaliteral{5F}{\isacharunderscore}}order\ op\ {\isaliteral{5C3C6C653E}{\isasymle}}% |
30580
cc5a55d7a5be
Updated chapters 1-5 to locale reimplementation.
ballarin
parents:
29297
diff
changeset
|
87 |
\end{isabelle} which can be shown easily:% |
27063 | 88 |
\end{isamarkuptxt}% |
89 |
\isamarkuptrue% |
|
90 |
\ \ \ \ \isacommand{by}\isamarkupfalse% |
|
40406 | 91 |
\ unfold{\isaliteral{5F}{\isacharunderscore}}locales\ auto% |
27063 | 92 |
\endisatagvisible |
93 |
{\isafoldvisible}% |
|
94 |
% |
|
95 |
\isadelimvisible |
|
96 |
% |
|
97 |
\endisadelimvisible |
|
98 |
% |
|
99 |
\begin{isamarkuptext}% |
|
32981 | 100 |
The effect of the command is that instances of all |
101 |
conclusions of the locale are available in the theory, where names |
|
40406 | 102 |
are prefixed by the qualifier. For example, transitivity for \isa{int} is named \isa{int{\isaliteral{2E}{\isachardot}}trans} and is the following |
32981 | 103 |
theorem: |
104 |
\begin{isabelle}% |
|
40406 | 105 |
\ \ {\isaliteral{5C3C6C6272616B6B3E}{\isasymlbrakk}}{\isaliteral{3F}{\isacharquery}}x\ {\isaliteral{5C3C6C653E}{\isasymle}}\ {\isaliteral{3F}{\isacharquery}}y{\isaliteral{3B}{\isacharsemicolon}}\ {\isaliteral{3F}{\isacharquery}}y\ {\isaliteral{5C3C6C653E}{\isasymle}}\ {\isaliteral{3F}{\isacharquery}}z{\isaliteral{5C3C726272616B6B3E}{\isasymrbrakk}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ {\isaliteral{3F}{\isacharquery}}x\ {\isaliteral{5C3C6C653E}{\isasymle}}\ {\isaliteral{3F}{\isacharquery}}z% |
27063 | 106 |
\end{isabelle} |
32983 | 107 |
It is not possible to reference this theorem simply as \isa{trans}. This prevents unwanted hiding of existing theorems of the |
32981 | 108 |
theory by an interpretation.% |
27063 | 109 |
\end{isamarkuptext}% |
110 |
\isamarkuptrue% |
|
111 |
% |
|
112 |
\isamarkupsubsection{Second Version: Replacement of Definitions% |
|
113 |
} |
|
114 |
\isamarkuptrue% |
|
115 |
% |
|
116 |
\begin{isamarkuptext}% |
|
32981 | 117 |
Not only does the above interpretation qualify theorem names. |
32982 | 118 |
The prefix \isa{int} is applied to all names introduced in locale |
32981 | 119 |
conclusions including names introduced in definitions. The |
40406 | 120 |
qualified name \isa{int{\isaliteral{2E}{\isachardot}}less} is short for |
121 |
the interpretation of the definition, which is \isa{partial{\isaliteral{5F}{\isacharunderscore}}order{\isaliteral{2E}{\isachardot}}less\ op\ {\isaliteral{5C3C6C653E}{\isasymle}}}. |
|
32981 | 122 |
Qualified name and expanded form may be used almost |
123 |
interchangeably.% |
|
40406 | 124 |
\footnote{Since \isa{op\ {\isaliteral{5C3C6C653E}{\isasymle}}} is polymorphic, for \isa{partial{\isaliteral{5F}{\isacharunderscore}}order{\isaliteral{2E}{\isachardot}}less\ op\ {\isaliteral{5C3C6C653E}{\isasymle}}} a |
125 |
more general type will be inferred than for \isa{int{\isaliteral{2E}{\isachardot}}less} which |
|
32982 | 126 |
is over type \isa{int}.} |
32981 | 127 |
The latter is preferred on output, as for example in the theorem |
40406 | 128 |
\isa{int{\isaliteral{2E}{\isachardot}}less{\isaliteral{5F}{\isacharunderscore}}le{\isaliteral{5F}{\isacharunderscore}}trans}: \begin{isabelle}% |
129 |
\ \ {\isaliteral{5C3C6C6272616B6B3E}{\isasymlbrakk}}partial{\isaliteral{5F}{\isacharunderscore}}order{\isaliteral{2E}{\isachardot}}less\ op\ {\isaliteral{5C3C6C653E}{\isasymle}}\ {\isaliteral{3F}{\isacharquery}}x\ {\isaliteral{3F}{\isacharquery}}y{\isaliteral{3B}{\isacharsemicolon}}\ {\isaliteral{3F}{\isacharquery}}y\ {\isaliteral{5C3C6C653E}{\isasymle}}\ {\isaliteral{3F}{\isacharquery}}z{\isaliteral{5C3C726272616B6B3E}{\isasymrbrakk}}\isanewline |
|
130 |
\isaindent{\ \ }{\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ partial{\isaliteral{5F}{\isacharunderscore}}order{\isaliteral{2E}{\isachardot}}less\ op\ {\isaliteral{5C3C6C653E}{\isasymle}}\ {\isaliteral{3F}{\isacharquery}}x\ {\isaliteral{3F}{\isacharquery}}z% |
|
27063 | 131 |
\end{isabelle} |
32981 | 132 |
Both notations for the strict order are not satisfactory. The |
40406 | 133 |
constant \isa{op\ {\isaliteral{3C}{\isacharless}}} is the strict order for \isa{int}. |
32981 | 134 |
In order to allow for the desired replacement, interpretation |
135 |
accepts \emph{equations} in addition to the parameter instantiation. |
|
136 |
These follow the locale expression and are indicated with the |
|
32983 | 137 |
keyword \isakeyword{where}. This is the revised interpretation:% |
27063 | 138 |
\end{isamarkuptext}% |
139 |
\isamarkuptrue% |
|
140 |
% |
|
141 |
\isadelimtheory |
|
142 |
% |
|
143 |
\endisadelimtheory |
|
144 |
% |
|
145 |
\isatagtheory |
|
27080 | 146 |
\isacommand{end}\isamarkupfalse% |
27063 | 147 |
% |
148 |
\endisatagtheory |
|
149 |
{\isafoldtheory}% |
|
150 |
% |
|
151 |
\isadelimtheory |
|
152 |
% |
|
153 |
\endisadelimtheory |
|
27080 | 154 |
\isanewline |
27063 | 155 |
\end{isabellebody}% |
156 |
%%% Local Variables: |
|
157 |
%%% mode: latex |
|
158 |
%%% TeX-master: "root" |
|
159 |
%%% End: |