doc-src/Codegen/Thy/document/Further.tex
author haftmann
Thu, 02 Sep 2010 17:01:49 +0200
changeset 39070 352bcd845998
parent 38510 ec0408c7328b
child 39210 985b13c5a61d
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28447
haftmann
parents:
diff changeset
     1
%
haftmann
parents:
diff changeset
     2
\begin{isabellebody}%
haftmann
parents:
diff changeset
     3
\def\isabellecontext{Further}%
haftmann
parents:
diff changeset
     4
%
haftmann
parents:
diff changeset
     5
\isadelimtheory
haftmann
parents:
diff changeset
     6
%
haftmann
parents:
diff changeset
     7
\endisadelimtheory
haftmann
parents:
diff changeset
     8
%
haftmann
parents:
diff changeset
     9
\isatagtheory
haftmann
parents:
diff changeset
    10
\isacommand{theory}\isamarkupfalse%
haftmann
parents:
diff changeset
    11
\ Further\isanewline
haftmann
parents:
diff changeset
    12
\isakeyword{imports}\ Setup\isanewline
haftmann
parents:
diff changeset
    13
\isakeyword{begin}%
haftmann
parents:
diff changeset
    14
\endisatagtheory
haftmann
parents:
diff changeset
    15
{\isafoldtheory}%
haftmann
parents:
diff changeset
    16
%
haftmann
parents:
diff changeset
    17
\isadelimtheory
haftmann
parents:
diff changeset
    18
%
haftmann
parents:
diff changeset
    19
\endisadelimtheory
haftmann
parents:
diff changeset
    20
%
haftmann
parents:
diff changeset
    21
\isamarkupsection{Further issues \label{sec:further}%
haftmann
parents:
diff changeset
    22
}
haftmann
parents:
diff changeset
    23
\isamarkuptrue%
haftmann
parents:
diff changeset
    24
%
38437
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    25
\isamarkupsubsection{Modules namespace%
28447
haftmann
parents:
diff changeset
    26
}
haftmann
parents:
diff changeset
    27
\isamarkuptrue%
haftmann
parents:
diff changeset
    28
%
haftmann
parents:
diff changeset
    29
\begin{isamarkuptext}%
38437
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    30
When invoking the \hyperlink{command.export-code}{\mbox{\isa{\isacommand{export{\isacharunderscore}code}}}} command it is possible to leave
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    31
  out the \hyperlink{keyword.module-name}{\mbox{\isa{\isakeyword{module{\isacharunderscore}name}}}} part;  then code is distributed over
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    32
  different modules, where the module name space roughly is induced
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    33
  by the Isabelle theory name space.
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    34
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    35
  Then sometimes the awkward situation occurs that dependencies between
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    36
  definitions introduce cyclic dependencies between modules, which in the
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    37
  \isa{Haskell} world leaves you to the mercy of the \isa{Haskell} implementation
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    38
  you are using,  while for \isa{SML}/\isa{OCaml} code generation is not possible.
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    39
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    40
  A solution is to declare module names explicitly.
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    41
  Let use assume the three cyclically dependent
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    42
  modules are named \emph{A}, \emph{B} and \emph{C}.
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    43
  Then, by stating%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    44
\end{isamarkuptext}%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    45
\isamarkuptrue%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    46
%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    47
\isadelimquote
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    48
%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    49
\endisadelimquote
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    50
%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    51
\isatagquote
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    52
\isacommand{code{\isacharunderscore}modulename}\isamarkupfalse%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    53
\ SML\isanewline
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    54
\ \ A\ ABC\isanewline
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    55
\ \ B\ ABC\isanewline
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    56
\ \ C\ ABC%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    57
\endisatagquote
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    58
{\isafoldquote}%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    59
%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    60
\isadelimquote
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    61
%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    62
\endisadelimquote
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    63
%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    64
\begin{isamarkuptext}%
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    65
\noindent
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    66
  we explicitly map all those modules on \emph{ABC},
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    67
  resulting in an ad-hoc merge of this three modules
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
    68
  at serialisation time.%
28447
haftmann
parents:
diff changeset
    69
\end{isamarkuptext}%
haftmann
parents:
diff changeset
    70
\isamarkuptrue%
haftmann
parents:
diff changeset
    71
%
37426
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    72
\isamarkupsubsection{Locales and interpretation%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    73
}
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    74
\isamarkuptrue%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    75
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    76
\begin{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    77
A technical issue comes to surface when generating code from
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    78
  specifications stemming from locale interpretation.
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    79
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    80
  Let us assume a locale specifying a power operation
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    81
  on arbitrary types:%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    82
\end{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    83
\isamarkuptrue%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    84
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    85
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    86
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    87
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    88
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    89
\isatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    90
\isacommand{locale}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    91
\ power\ {\isacharequal}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    92
\ \ \isakeyword{fixes}\ power\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}b{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    93
\ \ \isakeyword{assumes}\ power{\isacharunderscore}commute{\isacharcolon}\ {\isachardoublequoteopen}power\ x\ {\isasymcirc}\ power\ y\ {\isacharequal}\ power\ y\ {\isasymcirc}\ power\ x{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    94
\isakeyword{begin}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    95
\endisatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    96
{\isafoldquote}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    97
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    98
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
    99
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   100
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   101
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   102
\begin{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   103
\noindent Inside that locale we can lift \isa{power} to exponent lists
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   104
  by means of specification relative to that locale:%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   105
\end{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   106
\isamarkuptrue%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   107
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   108
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   109
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   110
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   111
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   112
\isatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   113
\isacommand{primrec}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   114
\ powers\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}b\ {\isasymRightarrow}\ {\isacharprime}b{\isachardoublequoteclose}\ \isakeyword{where}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   115
\ \ {\isachardoublequoteopen}powers\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharequal}\ id{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   116
{\isacharbar}\ {\isachardoublequoteopen}powers\ {\isacharparenleft}x\ {\isacharhash}\ xs{\isacharparenright}\ {\isacharequal}\ power\ x\ {\isasymcirc}\ powers\ xs{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   117
\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   118
\isacommand{lemma}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   119
\ powers{\isacharunderscore}append{\isacharcolon}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   120
\ \ {\isachardoublequoteopen}powers\ {\isacharparenleft}xs\ {\isacharat}\ ys{\isacharparenright}\ {\isacharequal}\ powers\ xs\ {\isasymcirc}\ powers\ ys{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   121
\ \ \isacommand{by}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   122
\ {\isacharparenleft}induct\ xs{\isacharparenright}\ simp{\isacharunderscore}all\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   123
\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   124
\isacommand{lemma}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   125
\ powers{\isacharunderscore}power{\isacharcolon}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   126
\ \ {\isachardoublequoteopen}powers\ xs\ {\isasymcirc}\ power\ x\ {\isacharequal}\ power\ x\ {\isasymcirc}\ powers\ xs{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   127
\ \ \isacommand{by}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   128
\ {\isacharparenleft}induct\ xs{\isacharparenright}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   129
\ \ \ \ {\isacharparenleft}simp{\isacharunderscore}all\ del{\isacharcolon}\ o{\isacharunderscore}apply\ id{\isacharunderscore}apply\ add{\isacharcolon}\ o{\isacharunderscore}assoc\ {\isacharbrackleft}symmetric{\isacharbrackright}{\isacharcomma}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   130
\ \ \ \ \ \ simp\ del{\isacharcolon}\ o{\isacharunderscore}apply\ add{\isacharcolon}\ o{\isacharunderscore}assoc\ power{\isacharunderscore}commute{\isacharparenright}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   131
\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   132
\isacommand{lemma}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   133
\ powers{\isacharunderscore}rev{\isacharcolon}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   134
\ \ {\isachardoublequoteopen}powers\ {\isacharparenleft}rev\ xs{\isacharparenright}\ {\isacharequal}\ powers\ xs{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   135
\ \ \ \ \isacommand{by}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   136
\ {\isacharparenleft}induct\ xs{\isacharparenright}\ {\isacharparenleft}simp{\isacharunderscore}all\ add{\isacharcolon}\ powers{\isacharunderscore}append\ powers{\isacharunderscore}power{\isacharparenright}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   137
\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   138
\isacommand{end}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   139
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   140
\endisatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   141
{\isafoldquote}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   142
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   143
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   144
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   145
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   146
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   147
\begin{isamarkuptext}%
38505
2f8699695cf6 use command_def vs. command more consciously
haftmann
parents: 38437
diff changeset
   148
After an interpretation of this locale (say, \indexdef{}{command}{interpretation}\hypertarget{command.interpretation}{\hyperlink{command.interpretation}{\mbox{\isa{\isacommand{interpretation}}}}} \isa{fun{\isacharunderscore}power{\isacharcolon}} \isa{{\isachardoublequote}power\ {\isacharparenleft}{\isasymlambda}n\ {\isacharparenleft}f\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}{\isachardot}\ f\ {\isacharcircum}{\isacharcircum}\ n{\isacharparenright}{\isachardoublequote}}), one would expect to have a constant \isa{fun{\isacharunderscore}power{\isachardot}powers\ {\isacharcolon}{\isacharcolon}\ nat\ list\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a} for which code
37426
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   149
  can be generated.  But this not the case: internally, the term
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   150
  \isa{fun{\isacharunderscore}power{\isachardot}powers} is an abbreviation for the foundational
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   151
  term \isa{{\isachardoublequote}power{\isachardot}powers\ {\isacharparenleft}{\isasymlambda}n\ {\isacharparenleft}f\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}{\isachardot}\ f\ {\isacharcircum}{\isacharcircum}\ n{\isacharparenright}{\isachardoublequote}}
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   152
  (see \cite{isabelle-locale} for the details behind).
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   153
37836
2bcce92be291 adjusted; fixed typo
haftmann
parents: 37432
diff changeset
   154
  Fortunately, with minor effort the desired behaviour can be achieved.
37426
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   155
  First, a dedicated definition of the constant on which the local \isa{powers}
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   156
  after interpretation is supposed to be mapped on:%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   157
\end{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   158
\isamarkuptrue%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   159
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   160
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   161
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   162
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   163
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   164
\isatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   165
\isacommand{definition}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   166
\ funpows\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}nat\ list\ {\isasymRightarrow}\ {\isacharparenleft}{\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}\ {\isasymRightarrow}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isachardoublequoteclose}\ \isakeyword{where}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   167
\ \ {\isacharbrackleft}code\ del{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}funpows\ {\isacharequal}\ power{\isachardot}powers\ {\isacharparenleft}{\isasymlambda}n\ f{\isachardot}\ f\ {\isacharcircum}{\isacharcircum}\ n{\isacharparenright}{\isachardoublequoteclose}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   168
\endisatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   169
{\isafoldquote}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   170
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   171
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   172
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   173
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   174
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   175
\begin{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   176
\noindent In general, the pattern is \isa{c\ {\isacharequal}\ t} where \isa{c} is
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   177
  the name of the future constant and \isa{t} the foundational term
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   178
  corresponding to the local constant after interpretation.
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   179
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   180
  The interpretation itself is enriched with an equation \isa{t\ {\isacharequal}\ c}:%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   181
\end{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   182
\isamarkuptrue%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   183
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   184
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   185
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   186
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   187
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   188
\isatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   189
\isacommand{interpretation}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   190
\ fun{\isacharunderscore}power{\isacharcolon}\ power\ {\isachardoublequoteopen}{\isasymlambda}n\ {\isacharparenleft}f\ {\isacharcolon}{\isacharcolon}\ {\isacharprime}a\ {\isasymRightarrow}\ {\isacharprime}a{\isacharparenright}{\isachardot}\ f\ {\isacharcircum}{\isacharcircum}\ n{\isachardoublequoteclose}\ \isakeyword{where}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   191
\ \ {\isachardoublequoteopen}power{\isachardot}powers\ {\isacharparenleft}{\isasymlambda}n\ f{\isachardot}\ f\ {\isacharcircum}{\isacharcircum}\ n{\isacharparenright}\ {\isacharequal}\ funpows{\isachardoublequoteclose}\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   192
\ \ \isacommand{by}\isamarkupfalse%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   193
\ unfold{\isacharunderscore}locales\isanewline
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   194
\ \ \ \ {\isacharparenleft}simp{\isacharunderscore}all\ add{\isacharcolon}\ expand{\isacharunderscore}fun{\isacharunderscore}eq\ funpow{\isacharunderscore}mult\ mult{\isacharunderscore}commute\ funpows{\isacharunderscore}def{\isacharparenright}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   195
\endisatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   196
{\isafoldquote}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   197
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   198
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   199
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   200
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   201
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   202
\begin{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   203
\noindent This additional equation is trivially proved by the definition
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   204
  itself.
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   205
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   206
  After this setup procedure, code generation can continue as usual:%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   207
\end{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   208
\isamarkuptrue%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   209
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   210
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   211
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   212
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   213
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   214
\isatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   215
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   216
\begin{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   217
\isatypewriter%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   218
\noindent%
39070
352bcd845998 updated
haftmann
parents: 38510
diff changeset
   219
\hspace*{0pt}funpow ::~forall a.~Example.Nat -> (a -> a) -> a -> a;\\
352bcd845998 updated
haftmann
parents: 38510
diff changeset
   220
\hspace*{0pt}funpow Example.Zero{\char95}nat f = id;\\
352bcd845998 updated
haftmann
parents: 38510
diff changeset
   221
\hspace*{0pt}funpow (Example.Suc n) f = f .~Example.funpow n f;\\
37426
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   222
\hspace*{0pt}\\
39070
352bcd845998 updated
haftmann
parents: 38510
diff changeset
   223
\hspace*{0pt}funpows ::~forall a.~[Example.Nat] -> (a -> a) -> a -> a;\\
37426
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   224
\hspace*{0pt}funpows [] = id;\\
39070
352bcd845998 updated
haftmann
parents: 38510
diff changeset
   225
\hspace*{0pt}funpows (x :~xs) = Example.funpow x .~Example.funpows xs;%
37426
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   226
\end{isamarkuptext}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   227
\isamarkuptrue%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   228
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   229
\endisatagquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   230
{\isafoldquote}%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   231
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   232
\isadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   233
%
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   234
\endisadelimquote
04d58897bf90 subsection on locale interpretation
haftmann
parents: 34155
diff changeset
   235
%
38437
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
   236
\isamarkupsubsection{Imperative data structures%
28447
haftmann
parents:
diff changeset
   237
}
haftmann
parents:
diff changeset
   238
\isamarkuptrue%
haftmann
parents:
diff changeset
   239
%
haftmann
parents:
diff changeset
   240
\begin{isamarkuptext}%
38437
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
   241
If you consider imperative data structures as inevitable for a
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
   242
  specific application, you should consider \emph{Imperative
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
   243
  Functional Programming with Isabelle/HOL}
ffb1c5bf0425 adaptation to new outline
haftmann
parents: 38405
diff changeset
   244
  \cite{bulwahn-et-al:2008:imperative}; the framework described there
39070
352bcd845998 updated
haftmann
parents: 38510
diff changeset
   245
  is available in session \isa{Imperative{\isacharunderscore}HOL}.%
28447
haftmann
parents:
diff changeset
   246
\end{isamarkuptext}%
haftmann
parents:
diff changeset
   247
\isamarkuptrue%
haftmann
parents:
diff changeset
   248
%
38405
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   249
\isamarkupsubsection{ML system interfaces \label{sec:ml}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   250
}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   251
\isamarkuptrue%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   252
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   253
\begin{isamarkuptext}%
38510
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   254
Since the code generator framework not only aims to provide a nice
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   255
  Isar interface but also to form a base for code-generation-based
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   256
  applications, here a short description of the most fundamental ML
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   257
  interfaces.%
38405
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   258
\end{isamarkuptext}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   259
\isamarkuptrue%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   260
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   261
\isamarkupsubsubsection{Managing executable content%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   262
}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   263
\isamarkuptrue%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   264
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   265
\isadelimmlref
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   266
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   267
\endisadelimmlref
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   268
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   269
\isatagmlref
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   270
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   271
\begin{isamarkuptext}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   272
\begin{mldecls}
38510
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   273
  \indexdef{}{ML}{Code.read\_const}\verb|Code.read_const: theory -> string -> string| \\
38405
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   274
  \indexdef{}{ML}{Code.add\_eqn}\verb|Code.add_eqn: thm -> theory -> theory| \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   275
  \indexdef{}{ML}{Code.del\_eqn}\verb|Code.del_eqn: thm -> theory -> theory| \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   276
  \indexdef{}{ML}{Code\_Preproc.map\_pre}\verb|Code_Preproc.map_pre: (simpset -> simpset) -> theory -> theory| \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   277
  \indexdef{}{ML}{Code\_Preproc.map\_post}\verb|Code_Preproc.map_post: (simpset -> simpset) -> theory -> theory| \\
38509
9cea8a0e925a updated generated document
haftmann
parents: 38505
diff changeset
   278
  \indexdef{}{ML}{Code\_Preproc.add\_functrans}\verb|Code_Preproc.add_functrans: |\isasep\isanewline%
9cea8a0e925a updated generated document
haftmann
parents: 38505
diff changeset
   279
\verb|    string * (theory -> (thm * bool) list -> (thm * bool) list option)|\isasep\isanewline%
9cea8a0e925a updated generated document
haftmann
parents: 38505
diff changeset
   280
\verb|      -> theory -> theory| \\
38405
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   281
  \indexdef{}{ML}{Code\_Preproc.del\_functrans}\verb|Code_Preproc.del_functrans: string -> theory -> theory| \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   282
  \indexdef{}{ML}{Code.add\_datatype}\verb|Code.add_datatype: (string * typ) list -> theory -> theory| \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   283
  \indexdef{}{ML}{Code.get\_type}\verb|Code.get_type: theory -> string|\isasep\isanewline%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   284
\verb|    -> (string * sort) list * ((string * string list) * typ list) list| \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   285
  \indexdef{}{ML}{Code.get\_type\_of\_constr\_or\_abstr}\verb|Code.get_type_of_constr_or_abstr: theory -> string -> (string * bool) option|
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   286
  \end{mldecls}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   287
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   288
  \begin{description}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   289
38510
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   290
  \item \verb|Code.read_const|~\isa{thy}~\isa{s}
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   291
     reads a constant as a concrete term expression \isa{s}.
ec0408c7328b stub for evaluation chapter
haftmann
parents: 38509
diff changeset
   292
38405
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   293
  \item \verb|Code.add_eqn|~\isa{thm}~\isa{thy} adds function
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   294
     theorem \isa{thm} to executable content.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   295
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   296
  \item \verb|Code.del_eqn|~\isa{thm}~\isa{thy} removes function
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   297
     theorem \isa{thm} from executable content, if present.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   298
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   299
  \item \verb|Code_Preproc.map_pre|~\isa{f}~\isa{thy} changes
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   300
     the preprocessor simpset.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   301
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   302
  \item \verb|Code_Preproc.add_functrans|~\isa{{\isacharparenleft}name{\isacharcomma}\ f{\isacharparenright}}~\isa{thy} adds
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   303
     function transformer \isa{f} (named \isa{name}) to executable content;
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   304
     \isa{f} is a transformer of the code equations belonging
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   305
     to a certain function definition, depending on the
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   306
     current theory context.  Returning \isa{NONE} indicates that no
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   307
     transformation took place;  otherwise, the whole process will be iterated
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   308
     with the new code equations.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   309
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   310
  \item \verb|Code_Preproc.del_functrans|~\isa{name}~\isa{thy} removes
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   311
     function transformer named \isa{name} from executable content.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   312
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   313
  \item \verb|Code.add_datatype|~\isa{cs}~\isa{thy} adds
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   314
     a datatype to executable content, with generation
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   315
     set \isa{cs}.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   316
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   317
  \item \verb|Code.get_type_of_constr_or_abstr|~\isa{thy}~\isa{const}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   318
     returns type constructor corresponding to
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   319
     constructor \isa{const}; returns \isa{NONE}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   320
     if \isa{const} is no constructor.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   321
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   322
  \end{description}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   323
\end{isamarkuptext}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   324
\isamarkuptrue%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   325
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   326
\endisatagmlref
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   327
{\isafoldmlref}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   328
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   329
\isadelimmlref
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   330
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   331
\endisadelimmlref
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   332
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   333
\isamarkupsubsubsection{Data depending on the theory's executable content%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   334
}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   335
\isamarkuptrue%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   336
%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   337
\begin{isamarkuptext}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   338
Implementing code generator applications on top
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   339
  of the framework set out so far usually not only
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   340
  involves using those primitive interfaces
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   341
  but also storing code-dependent data and various
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   342
  other things.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   343
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   344
  Due to incrementality of code generation, changes in the
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   345
  theory's executable content have to be propagated in a
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   346
  certain fashion.  Additionally, such changes may occur
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   347
  not only during theory extension but also during theory
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   348
  merge, which is a little bit nasty from an implementation
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   349
  point of view.  The framework provides a solution
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   350
  to this technical challenge by providing a functorial
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   351
  data slot \verb|Code_Data|; on instantiation
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   352
  of this functor, the following types and operations
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   353
  are required:
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   354
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   355
  \medskip
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   356
  \begin{tabular}{l}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   357
  \isa{type\ T} \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   358
  \isa{val\ empty{\isacharcolon}\ T} \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   359
  \end{tabular}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   360
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   361
  \begin{description}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   362
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   363
  \item \isa{T} the type of data to store.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   364
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   365
  \item \isa{empty} initial (empty) data.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   366
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   367
  \end{description}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   368
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   369
  \noindent An instance of \verb|Code_Data| provides the following
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   370
  interface:
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   371
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   372
  \medskip
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   373
  \begin{tabular}{l}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   374
  \isa{change{\isacharcolon}\ theory\ {\isasymrightarrow}\ {\isacharparenleft}T\ {\isasymrightarrow}\ T{\isacharparenright}\ {\isasymrightarrow}\ T} \\
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   375
  \isa{change{\isacharunderscore}yield{\isacharcolon}\ theory\ {\isasymrightarrow}\ {\isacharparenleft}T\ {\isasymrightarrow}\ {\isacharprime}a\ {\isacharasterisk}\ T{\isacharparenright}\ {\isasymrightarrow}\ {\isacharprime}a\ {\isacharasterisk}\ T}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   376
  \end{tabular}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   377
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   378
  \begin{description}
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   379
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   380
  \item \isa{change} update of current data (cached!)
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   381
    by giving a continuation.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   382
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   383
  \item \isa{change{\isacharunderscore}yield} update with side result.
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   384
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   385
  \end{description}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   386
\end{isamarkuptext}%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   387
\isamarkuptrue%
7935b334893e sketch of new outline
haftmann
parents: 37836
diff changeset
   388
%
28447
haftmann
parents:
diff changeset
   389
\isadelimtheory
haftmann
parents:
diff changeset
   390
%
haftmann
parents:
diff changeset
   391
\endisadelimtheory
haftmann
parents:
diff changeset
   392
%
haftmann
parents:
diff changeset
   393
\isatagtheory
haftmann
parents:
diff changeset
   394
\isacommand{end}\isamarkupfalse%
haftmann
parents:
diff changeset
   395
%
haftmann
parents:
diff changeset
   396
\endisatagtheory
haftmann
parents:
diff changeset
   397
{\isafoldtheory}%
haftmann
parents:
diff changeset
   398
%
haftmann
parents:
diff changeset
   399
\isadelimtheory
haftmann
parents:
diff changeset
   400
%
haftmann
parents:
diff changeset
   401
\endisadelimtheory
haftmann
parents:
diff changeset
   402
\isanewline
haftmann
parents:
diff changeset
   403
\end{isabellebody}%
haftmann
parents:
diff changeset
   404
%%% Local Variables:
haftmann
parents:
diff changeset
   405
%%% mode: latex
haftmann
parents:
diff changeset
   406
%%% TeX-master: "root"
haftmann
parents:
diff changeset
   407
%%% End: