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