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