doc-src/Locales/Locales/document/Examples1.tex
author ballarin
Sat, 28 Mar 2009 22:14:21 +0100
changeset 30780 c3f1e8a9e0b5
parent 30580 cc5a55d7a5be
child 30826 a53f4872400e
permissions -rw-r--r--
Default mode of qualifiers in locale commands.
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
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    21
\isamarkupsection{Use of Locales in Theories and Proofs%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    22
}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    23
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    24
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    25
\begin{isamarkuptext}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    26
Locales enable to prove theorems abstractly, relative to
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    27
  sets of assumptions.  These theorems can then be used in other
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    28
  contexts where the assumptions themselves, or
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    29
  instances of the assumptions, are theorems.  This form of theorem
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    30
  reuse is called \emph{interpretation}.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    31
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    32
  The changes of the locale
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    33
  hierarchy from the previous sections are examples of
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    34
  interpretations.  The command \isakeyword{sublocale} $l_1
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    35
  \subseteq l_2$ is said to \emph{interpret} locale $l_2$ in the
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    36
  context of $l_1$.  It causes all theorems of $l_2$ to be made
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    37
  available in $l_1$.  The interpretation is \emph{dynamic}: not only
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    38
  theorems already present in $l_2$ are available in $l_1$.  Theorems
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    39
  that will be added to $l_2$ in future will automatically be
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    40
  propagated to $l_1$.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    41
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    42
  Locales can also be interpreted in the contexts of theories and
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    43
  structured proofs.  These interpretations are dynamic, too.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    44
  Theorems added to locales will be propagated to theories.
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    45
  In this section the interpretation in
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    46
  theories is illustrated; interpretation in proofs is analogous.
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    47
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    48
  As an example, consider the type of natural numbers \isa{nat}.  The
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    49
  order relation \isa{{\isasymle}} is a total order over \isa{nat},
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    50
  divisibility \isa{dvd} is a distributive lattice.  We start with the
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    51
  interpretation that \isa{{\isasymle}} is a partial order.  The facilities of
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    52
  the interpretation command are explored in three versions.%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    53
\end{isamarkuptext}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    54
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    55
%
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    56
\isamarkupsubsection{First Version: Replacement of Parameters Only
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    57
  \label{sec:po-first}%
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    58
}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    59
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    60
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    61
\begin{isamarkuptext}%
27079
61ac01ff0aa9 updated generated file;
wenzelm
parents: 27063
diff changeset
    62
In the most basic form, interpretation just replaces the locale
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    63
  parameters by terms.  The following command interprets the locale
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    64
  \isa{partial{\isacharunderscore}order} in the global context of the theory.  The
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    65
  parameter \isa{le} is replaced by \isa{op\ {\isasymle}}.%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    66
\end{isamarkuptext}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    67
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    68
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    69
\isadelimvisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    70
\ \ %
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    71
\endisadelimvisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    72
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    73
\isatagvisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    74
\isacommand{interpretation}\isamarkupfalse%
30780
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
    75
\ nat{\isacharcolon}\ partial{\isacharunderscore}order\ {\isachardoublequoteopen}op\ {\isasymle}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymRightarrow}\ nat\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}%
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    76
\begin{isamarkuptxt}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    77
The locale name is succeeded by a \emph{parameter
30780
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
    78
  instantiation}.  This is a list of terms, which refer to
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    79
  the parameters in the order of declaration in the locale.  The
30780
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
    80
  locale name is preceded by an optional \emph{interpretation
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
    81
  qualifier}.
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    82
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    83
  The command creates the goal%
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    84
\footnote{Note that \isa{op} binds tighter than functions
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    85
  application: parentheses around \isa{op\ {\isasymle}} are not necessary.}
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    86
  \begin{isabelle}%
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    87
\ {\isadigit{1}}{\isachardot}\ partial{\isacharunderscore}order\ op\ {\isasymle}%
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
    88
\end{isabelle} which can be shown easily:%
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    89
\end{isamarkuptxt}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    90
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    91
\ \ \ \ \isacommand{by}\isamarkupfalse%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    92
\ unfold{\isacharunderscore}locales\ auto%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    93
\endisatagvisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    94
{\isafoldvisible}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    95
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    96
\isadelimvisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    97
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    98
\endisadelimvisible
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
    99
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   100
\begin{isamarkuptext}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   101
Now theorems from the locale are available in the theory,
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   102
  interpreted for natural numbers, for example \isa{nat{\isachardot}trans}: \begin{isabelle}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   103
\ \ {\isasymlbrakk}{\isacharquery}x\ {\isasymle}\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasymle}\ {\isacharquery}z{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharquery}x\ {\isasymle}\ {\isacharquery}z%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   104
\end{isabelle}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   105
30780
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   106
  The interpretation qualifier, \isa{nat} in the example, is applied
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   107
  to all names processed by the interpretation.  If a qualifer is
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   108
  given in the \isakeyword{interpretation} command, its use is
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   109
  mandatory when referencing the name.  For example, the above theorem
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   110
  cannot be referred to simply by \isa{trans}.  This prevents
c3f1e8a9e0b5 Default mode of qualifiers in locale commands.
ballarin
parents: 30580
diff changeset
   111
  unwanted hiding of theorems.%
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   112
\end{isamarkuptext}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   113
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   114
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   115
\isamarkupsubsection{Second Version: Replacement of Definitions%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   116
}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   117
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   118
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   119
\begin{isamarkuptext}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   120
The above interpretation also creates the theorem
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   121
  \isa{nat{\isachardot}less{\isacharunderscore}le{\isacharunderscore}trans}: \begin{isabelle}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   122
\ \ {\isasymlbrakk}partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasymle}\ {\isacharquery}x\ {\isacharquery}y{\isacharsemicolon}\ {\isacharquery}y\ {\isasymle}\ {\isacharquery}z{\isasymrbrakk}\isanewline
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   123
\isaindent{\ \ }{\isasymLongrightarrow}\ partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasymle}\ {\isacharquery}x\ {\isacharquery}z%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   124
\end{isabelle}
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   125
  Here, \isa{partial{\isacharunderscore}order{\isachardot}less\ op\ {\isasymle}}
30580
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
   126
  represents the strict order, although \isa{{\isacharless}} is the natural
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
   127
  strict order for \isa{nat}.  Interpretation allows to map concepts
cc5a55d7a5be Updated chapters 1-5 to locale reimplementation.
ballarin
parents: 29297
diff changeset
   128
  introduced through definitions in locales to the corresponding
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   129
  concepts of the theory.%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   130
\footnote{This applies not only to \isakeyword{definition} but also to
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   131
  \isakeyword{inductive}, \isakeyword{fun} and \isakeyword{function}.}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   132
\end{isamarkuptext}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   133
\isamarkuptrue%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   134
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   135
\isadelimtheory
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   136
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   137
\endisadelimtheory
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   138
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   139
\isatagtheory
27080
0ee385433247 updated generated file;
wenzelm
parents: 27079
diff changeset
   140
\isacommand{end}\isamarkupfalse%
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   141
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   142
\endisatagtheory
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   143
{\isafoldtheory}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   144
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   145
\isadelimtheory
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   146
%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   147
\endisadelimtheory
27080
0ee385433247 updated generated file;
wenzelm
parents: 27079
diff changeset
   148
\isanewline
27063
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   149
\end{isabellebody}%
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   150
%%% Local Variables:
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   151
%%% mode: latex
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   152
%%% TeX-master: "root"
d1d35284542f New version covering interpretation.
ballarin
parents:
diff changeset
   153
%%% End: