572 library; beside being useful in applications, they may serve |
572 library; beside being useful in applications, they may serve |
573 as a tutorial for customizing the code generator setup. |
573 as a tutorial for customizing the code generator setup. |
574 |
574 |
575 \begin{description} |
575 \begin{description} |
576 |
576 |
577 \item[ExecutableSet] allows to generate code |
577 \item[\isa{ExecutableSet}] allows to generate code |
578 for finite sets using lists. |
578 for finite sets using lists. |
579 \item[ExecutableRat] \label{exec_rat} implements rational |
579 \item[\isa{ExecutableRat}] \label{exec_rat} implements rational |
580 numbers as triples \isa{{\isacharparenleft}sign{\isacharcomma}\ enumerator{\isacharcomma}\ denominator{\isacharparenright}}. |
580 numbers as triples \isa{{\isacharparenleft}sign{\isacharcomma}\ enumerator{\isacharcomma}\ denominator{\isacharparenright}}. |
581 \item[EfficientNat] \label{eff_nat} implements natural numbers by integers, |
581 \item[\isa{EfficientNat}] \label{eff_nat} implements natural numbers by integers, |
582 which in general will result in higher efficency; pattern |
582 which in general will result in higher efficency; pattern |
583 matching with \isa{{\isadigit{0}}} / \isa{Suc} |
583 matching with \isa{{\isadigit{0}}} / \isa{Suc} |
584 is eliminated. |
584 is eliminated. |
585 \item[MLString] provides an additional datatype \isa{mlstring}; |
585 \item[\isa{MLString}] provides an additional datatype \isa{mlstring}; |
586 in the HOL default setup, strings in HOL are mapped to list |
586 in the HOL default setup, strings in HOL are mapped to list |
587 of chars in SML; values of type \isa{mlstring} are |
587 of chars in SML; values of type \isa{mlstring} are |
588 mapped to strings in SML. |
588 mapped to strings in SML. |
589 |
589 |
590 \end{description}% |
590 \end{description}% |
685 \emph{Generic preprocessors} provide a most general interface, |
685 \emph{Generic preprocessors} provide a most general interface, |
686 transforming a list of function theorems to another |
686 transforming a list of function theorems to another |
687 list of function theorems, provided that neither the heading |
687 list of function theorems, provided that neither the heading |
688 constant nor its type change. The \isa{{\isadigit{0}}} / \isa{Suc} |
688 constant nor its type change. The \isa{{\isadigit{0}}} / \isa{Suc} |
689 pattern elimination implemented in |
689 pattern elimination implemented in |
690 theory EfficientNat (\secref{eff_nat}) uses this |
690 theory \isa{EfficientNat} (\secref{eff_nat}) uses this |
691 interface. |
691 interface. |
692 |
692 |
693 \begin{warn} |
693 \begin{warn} |
694 The order in which single preprocessing steps are carried |
694 The order in which single preprocessing steps are carried |
695 out currently is not specified; in particular, preprocessing |
695 out currently is not specified; in particular, preprocessing |
1012 |
1008 |
1013 Though this class is designed to get rarely in the way, there |
1009 Though this class is designed to get rarely in the way, there |
1014 are some cases when it suddenly comes to surface:% |
1010 are some cases when it suddenly comes to surface:% |
1015 \end{isamarkuptext}% |
1011 \end{isamarkuptext}% |
1016 \isamarkuptrue% |
1012 \isamarkuptrue% |
1017 % |
|
1018 \isamarkupsubsubsection{code lemmas and customary serializations for equality% |
|
1019 } |
|
1020 \isamarkuptrue% |
|
1021 % |
|
1022 \begin{isamarkuptext}% |
|
1023 Examine the following:% |
|
1024 \end{isamarkuptext}% |
|
1025 \isamarkuptrue% |
|
1026 % |
|
1027 \isadelimtt |
|
1028 % |
|
1029 \endisadelimtt |
|
1030 % |
|
1031 \isatagtt |
|
1032 \isacommand{code{\isacharunderscore}const}\isamarkupfalse% |
|
1033 \ {\isachardoublequoteopen}op\ {\isacharequal}\ {\isasymColon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\isanewline |
|
1034 \ \ {\isacharparenleft}SML\ {\isachardoublequoteopen}{\isacharbang}{\isacharparenleft}{\isacharunderscore}\ {\isacharcolon}\ IntInf{\isachardot}int\ {\isacharequal}\ {\isacharunderscore}{\isacharparenright}{\isachardoublequoteclose}{\isacharparenright}% |
|
1035 \endisatagtt |
|
1036 {\isafoldtt}% |
|
1037 % |
|
1038 \isadelimtt |
|
1039 % |
|
1040 \endisadelimtt |
|
1041 % |
|
1042 \begin{isamarkuptext}% |
|
1043 What is wrong here? Since \isa{op\ {\isacharequal}} is nothing else then |
|
1044 a plain constant, this customary serialization will refer |
|
1045 to polymorphic equality \isa{op\ {\isacharequal}}. |
|
1046 Instead, we want the specific equality on \isa{int}, |
|
1047 by using the overloaded constant \isa{Code{\isacharunderscore}Generator{\isachardot}eq}:% |
|
1048 \end{isamarkuptext}% |
|
1049 \isamarkuptrue% |
|
1050 % |
|
1051 \isadelimtt |
|
1052 % |
|
1053 \endisadelimtt |
|
1054 % |
|
1055 \isatagtt |
|
1056 \isacommand{code{\isacharunderscore}const}\isamarkupfalse% |
|
1057 \ {\isachardoublequoteopen}Code{\isacharunderscore}Generator{\isachardot}eq\ {\isasymColon}\ int\ {\isasymRightarrow}\ int\ {\isasymRightarrow}\ bool{\isachardoublequoteclose}\isanewline |
|
1058 \ \ {\isacharparenleft}SML\ {\isachardoublequoteopen}{\isacharbang}{\isacharparenleft}{\isacharunderscore}\ {\isacharcolon}\ IntInf{\isachardot}int\ {\isacharequal}\ {\isacharunderscore}{\isacharparenright}{\isachardoublequoteclose}{\isacharparenright}% |
|
1059 \endisatagtt |
|
1060 {\isafoldtt}% |
|
1061 % |
|
1062 \isadelimtt |
|
1063 % |
|
1064 \endisadelimtt |
|
1065 % |
1013 % |
1066 \isamarkupsubsubsection{typedecls interpreted by customary serializations% |
1014 \isamarkupsubsubsection{typedecls interpreted by customary serializations% |
1067 } |
1015 } |
1068 \isamarkuptrue% |
1016 \isamarkuptrue% |
1069 % |
1017 % |
1098 % |
1046 % |
1099 \begin{isamarkuptext}% |
1047 \begin{isamarkuptext}% |
1100 This, though, is not sufficient: \isa{key} is no instance |
1048 This, though, is not sufficient: \isa{key} is no instance |
1101 of \isa{eq} since \isa{key} is no datatype; the instance |
1049 of \isa{eq} since \isa{key} is no datatype; the instance |
1102 has to be declared manually, including a serialization |
1050 has to be declared manually, including a serialization |
1103 for the particular instance of \isa{Code{\isacharunderscore}Generator{\isachardot}eq}:% |
1051 for the particular instance of \isa{op\ {\isacharequal}}:% |
1104 \end{isamarkuptext}% |
1052 \end{isamarkuptext}% |
1105 \isamarkuptrue% |
1053 \isamarkuptrue% |
1106 \isacommand{instance}\isamarkupfalse% |
1054 \isacommand{instance}\isamarkupfalse% |
1107 \ key\ {\isacharcolon}{\isacharcolon}\ eq% |
1055 \ key\ {\isacharcolon}{\isacharcolon}\ eq% |
1108 \isadelimproof |
1056 \isadelimproof |
1571 By that, we replace any \isa{arbitrary} with option type |
1519 By that, we replace any \isa{arbitrary} with option type |
1572 by \isa{arbitrary{\isacharunderscore}option} in function equations. |
1520 by \isa{arbitrary{\isacharunderscore}option} in function equations. |
1573 |
1521 |
1574 For technical reasons, we further have to provide a |
1522 For technical reasons, we further have to provide a |
1575 synonym for \isa{None} which in code generator view |
1523 synonym for \isa{None} which in code generator view |
1576 is a function rather than a datatype constructor% |
1524 is a function rather than a datatype constructor:% |
1577 \end{isamarkuptext}% |
1525 \end{isamarkuptext}% |
1578 \isamarkuptrue% |
1526 \isamarkuptrue% |
1579 \isacommand{definition}\isamarkupfalse% |
1527 \isacommand{definition}\isamarkupfalse% |
1580 \isanewline |
1528 \isanewline |
1581 \ \ {\isachardoublequoteopen}None{\isacharprime}\ {\isacharequal}\ None{\isachardoublequoteclose}% |
1529 \ \ {\isachardoublequoteopen}None{\isacharprime}\ {\isacharequal}\ None{\isachardoublequoteclose}% |
1931 |
1879 |
1932 \begin{warn} |
1880 \begin{warn} |
1933 Some interfaces discussed here have not reached |
1881 Some interfaces discussed here have not reached |
1934 a final state yet. |
1882 a final state yet. |
1935 Changes likely to occur in future. |
1883 Changes likely to occur in future. |
1936 \end{warn} |
1884 \end{warn}% |
1937 |
|
1938 \fixme% |
|
1939 \end{isamarkuptext}% |
1885 \end{isamarkuptext}% |
1940 \isamarkuptrue% |
1886 \isamarkuptrue% |
1941 % |
1887 % |
1942 \isamarkupsubsubsection{Data depending on the theory's executable content% |
1888 \isamarkupsubsubsection{Data depending on the theory's executable content% |
1943 } |
1889 } |
1944 \isamarkuptrue% |
1890 \isamarkuptrue% |
1945 % |
1891 % |
1946 \begin{isamarkuptext}% |
1892 \begin{isamarkuptext}% |
1947 \medskip |
1893 Due to incrementality of code generation, changes in the |
|
1894 theory's executable content have to be propagated in a |
|
1895 certain fashion. Additionally, such changes may occur |
|
1896 not only during theory extension but also during theory |
|
1897 merge, which is a little bit nasty from an implementation |
|
1898 point of view. The framework provides a solution |
|
1899 to this technical challenge by providing a functorial |
|
1900 data slot \verb|CodeDataFun|; on instantiation |
|
1901 of this functor, the following types and operations |
|
1902 are required: |
|
1903 |
|
1904 \medskip |
1948 \begin{tabular}{l} |
1905 \begin{tabular}{l} |
1949 \isa{val\ name{\isacharcolon}\ string} \\ |
1906 \isa{val\ name{\isacharcolon}\ string} \\ |
1950 \isa{type\ T} \\ |
1907 \isa{type\ T} \\ |
1951 \isa{val\ empty{\isacharcolon}\ T} \\ |
1908 \isa{val\ empty{\isacharcolon}\ T} \\ |
1952 \isa{val\ merge{\isacharcolon}\ Pretty{\isachardot}pp\ {\isasymrightarrow}\ T\ {\isacharasterisk}\ T\ {\isasymrightarrow}\ T} \\ |
1909 \isa{val\ merge{\isacharcolon}\ Pretty{\isachardot}pp\ {\isasymrightarrow}\ T\ {\isacharasterisk}\ T\ {\isasymrightarrow}\ T} \\ |
1953 \isa{val\ purge{\isacharcolon}\ theory\ option\ {\isasymrightarrow}\ CodegenConsts{\isachardot}const\ list\ option\ {\isasymrightarrow}\ T\ {\isasymrightarrow}\ T} |
1910 \isa{val\ purge{\isacharcolon}\ theory\ option\ {\isasymrightarrow}\ CodegenConsts{\isachardot}const\ list\ option\ {\isasymrightarrow}\ T\ {\isasymrightarrow}\ T} |
1954 \end{tabular} |
1911 \end{tabular} |
1955 |
1912 |
|
1913 \begin{description} |
|
1914 |
|
1915 \item \isa{name} is a system-wide unique name identifying the data. |
|
1916 |
|
1917 \item \isa{T} the type of data to store. |
|
1918 |
|
1919 \item \isa{empty} initial (empty) data. |
|
1920 |
|
1921 \item \isa{merge} merging two data slots. |
|
1922 |
|
1923 \item \isa{purge}~\isa{thy}~\isa{cs} propagates changes in executable content; |
|
1924 if possible, the current theory context is handed over |
|
1925 as argument \isa{thy} (if there is no current theory context (e.g.~during |
|
1926 theory merge, \verb|NONE|); \isa{cs} indicates the kind |
|
1927 of change: \verb|NONE| stands for a fundamental change |
|
1928 which invalidates any existing code, \isa{SOME\ cs} |
|
1929 hints that executable content for constants \isa{cs} |
|
1930 has changed. |
|
1931 |
|
1932 \end{description} |
|
1933 |
|
1934 An instance of \verb|CodeDataFun| provides the following |
|
1935 interface: |
|
1936 |
1956 \medskip |
1937 \medskip |
1957 |
|
1958 \begin{tabular}{l} |
1938 \begin{tabular}{l} |
1959 \isa{init{\isacharcolon}\ theory\ {\isasymrightarrow}\ theory} \\ |
1939 \isa{init{\isacharcolon}\ theory\ {\isasymrightarrow}\ theory} \\ |
1960 \isa{get{\isacharcolon}\ theory\ {\isasymrightarrow}\ T} \\ |
1940 \isa{get{\isacharcolon}\ theory\ {\isasymrightarrow}\ T} \\ |
1961 \isa{change{\isacharcolon}\ theory\ {\isasymrightarrow}\ {\isacharparenleft}T\ {\isasymrightarrow}\ T{\isacharparenright}\ {\isasymrightarrow}\ T} \\ |
1941 \isa{change{\isacharcolon}\ theory\ {\isasymrightarrow}\ {\isacharparenleft}T\ {\isasymrightarrow}\ T{\isacharparenright}\ {\isasymrightarrow}\ T} \\ |
1962 \isa{change{\isacharunderscore}yield{\isacharcolon}\ theory\ {\isasymrightarrow}\ {\isacharparenleft}T\ {\isasymrightarrow}\ {\isacharprime}a\ {\isacharasterisk}\ T{\isacharparenright}\ {\isasymrightarrow}\ {\isacharprime}a\ {\isacharasterisk}\ T} |
1942 \isa{change{\isacharunderscore}yield{\isacharcolon}\ theory\ {\isasymrightarrow}\ {\isacharparenleft}T\ {\isasymrightarrow}\ {\isacharprime}a\ {\isacharasterisk}\ T{\isacharparenright}\ {\isasymrightarrow}\ {\isacharprime}a\ {\isacharasterisk}\ T} |
1963 \end{tabular}% |
1943 \end{tabular} |
1964 \end{isamarkuptext}% |
|
1965 \isamarkuptrue% |
|
1966 % |
|
1967 \isadelimmlref |
|
1968 % |
|
1969 \endisadelimmlref |
|
1970 % |
|
1971 \isatagmlref |
|
1972 % |
|
1973 \begin{isamarkuptext}% |
|
1974 \begin{mldecls} |
|
1975 \indexmlfunctor{CodeDataFun}\verb|functor CodeDataFun| |
|
1976 \end{mldecls} |
|
1977 |
1944 |
1978 \begin{description} |
1945 \begin{description} |
1979 |
1946 |
1980 \item \verb|CodeDataFun|\isa{{\isacharparenleft}spec{\isacharparenright}} declares code |
1947 \item \isa{init} initialization during theory setup. |
1981 dependent data according to the specification provided as |
1948 |
1982 argument structure. The resulting structure provides data init and |
1949 \item \isa{get} retrieval of the current data. |
1983 access operations as described above. |
1950 |
|
1951 \item \isa{change} update of current data (cached!) |
|
1952 by giving a continuation. |
|
1953 |
|
1954 \item \isa{change{\isacharunderscore}yield} update with side result. |
1984 |
1955 |
1985 \end{description}% |
1956 \end{description}% |
1986 \end{isamarkuptext}% |
1957 \end{isamarkuptext}% |
1987 \isamarkuptrue% |
1958 \isamarkuptrue% |
1988 % |
1959 % |
1989 \endisatagmlref |
|
1990 {\isafoldmlref}% |
|
1991 % |
|
1992 \isadelimmlref |
|
1993 % |
|
1994 \endisadelimmlref |
|
1995 % |
|
1996 \isamarkupsubsubsection{Datatype hooks% |
1960 \isamarkupsubsubsection{Datatype hooks% |
1997 } |
1961 } |
|
1962 \isamarkuptrue% |
|
1963 % |
|
1964 \begin{isamarkuptext}% |
|
1965 Isabelle/HOL's datatype package provides a mechanism to |
|
1966 extend theories depending on datatype declarations: |
|
1967 \emph{datatype hooks}. For example, when declaring a new |
|
1968 datatype, a hook proves function equations for equality on |
|
1969 that datatype (if possible).% |
|
1970 \end{isamarkuptext}% |
1998 \isamarkuptrue% |
1971 \isamarkuptrue% |
1999 % |
1972 % |
2000 \isadelimmlref |
1973 \isadelimmlref |
2001 % |
1974 % |
2002 \endisadelimmlref |
1975 \endisadelimmlref |
2005 % |
1978 % |
2006 \begin{isamarkuptext}% |
1979 \begin{isamarkuptext}% |
2007 \begin{mldecls} |
1980 \begin{mldecls} |
2008 \indexmltype{DatatypeHooks.hook}\verb|type DatatypeHooks.hook = string list -> theory -> theory| \\ |
1981 \indexmltype{DatatypeHooks.hook}\verb|type DatatypeHooks.hook = string list -> theory -> theory| \\ |
2009 \indexml{DatatypeHooks.add}\verb|DatatypeHooks.add: DatatypeHooks.hook -> theory -> theory| |
1982 \indexml{DatatypeHooks.add}\verb|DatatypeHooks.add: DatatypeHooks.hook -> theory -> theory| |
2010 \end{mldecls}% |
1983 \end{mldecls} |
2011 \end{isamarkuptext}% |
1984 |
2012 \isamarkuptrue% |
1985 \begin{description} |
|
1986 |
|
1987 \item \verb|DatatypeHooks.hook| specifies the interface |
|
1988 of \emph{datatype hooks}: a theory update |
|
1989 depending on the list of newly introduced |
|
1990 datatype names. |
|
1991 |
|
1992 \item \verb|DatatypeHooks.add| adds a hook to the |
|
1993 chain of all hooks. |
|
1994 |
|
1995 \end{description}% |
|
1996 \end{isamarkuptext}% |
|
1997 \isamarkuptrue% |
|
1998 % |
|
1999 \endisatagmlref |
|
2000 {\isafoldmlref}% |
|
2001 % |
|
2002 \isadelimmlref |
|
2003 % |
|
2004 \endisadelimmlref |
|
2005 % |
|
2006 \isamarkupsubsubsection{Trivial typedefs -- type copies% |
|
2007 } |
|
2008 \isamarkuptrue% |
|
2009 % |
|
2010 \begin{isamarkuptext}% |
|
2011 Sometimes packages will introduce new types |
|
2012 as \emph{marked type copies} similar to Haskell's |
|
2013 \isa{newtype} declaration (e.g. the HOL record package) |
|
2014 \emph{without} tinkering with the overhead of datatypes. |
|
2015 Technically, these type copies are trivial forms of typedefs. |
|
2016 Since these type copies in code generation view are nothing |
|
2017 else than datatypes, they have been given a own package |
|
2018 in order to faciliate code generation:% |
|
2019 \end{isamarkuptext}% |
|
2020 \isamarkuptrue% |
|
2021 % |
|
2022 \isadelimmlref |
|
2023 % |
|
2024 \endisadelimmlref |
|
2025 % |
|
2026 \isatagmlref |
2013 % |
2027 % |
2014 \begin{isamarkuptext}% |
2028 \begin{isamarkuptext}% |
2015 \begin{mldecls} |
2029 \begin{mldecls} |
2016 \indexmltype{TypecopyPackage.info}\verb|type TypecopyPackage.info = {|\isasep\isanewline% |
2030 \indexmltype{TypecopyPackage.info}\verb|type TypecopyPackage.info| \\ |
2017 \verb| vs: (string * sort) list,|\isasep\isanewline% |
|
2018 \verb| constr: string,|\isasep\isanewline% |
|
2019 \verb| typ: typ,|\isasep\isanewline% |
|
2020 \verb| inject: thm,|\isasep\isanewline% |
|
2021 \verb| proj: string * typ,|\isasep\isanewline% |
|
2022 \verb| proj_def: thm|\isasep\isanewline% |
|
2023 \verb| }| \\ |
|
2024 \indexml{TypecopyPackage.add-typecopy}\verb|TypecopyPackage.add_typecopy: |\isasep\isanewline% |
2031 \indexml{TypecopyPackage.add-typecopy}\verb|TypecopyPackage.add_typecopy: |\isasep\isanewline% |
2025 \verb| bstring * string list -> typ -> (bstring * bstring) option|\isasep\isanewline% |
2032 \verb| bstring * string list -> typ -> (bstring * bstring) option|\isasep\isanewline% |
2026 \verb| -> theory -> (string * TypecopyPackage.info) * theory| \\ |
2033 \verb| -> theory -> (string * TypecopyPackage.info) * theory| \\ |
2027 \indexml{TypecopyPackage.get-typecopies}\verb|TypecopyPackage.get_typecopies: theory -> string list| \\ |
|
2028 \indexml{TypecopyPackage.get-typecopy-info}\verb|TypecopyPackage.get_typecopy_info: theory|\isasep\isanewline% |
2034 \indexml{TypecopyPackage.get-typecopy-info}\verb|TypecopyPackage.get_typecopy_info: theory|\isasep\isanewline% |
2029 \verb| -> string -> TypecopyPackage.info option| \\ |
2035 \verb| -> string -> TypecopyPackage.info option| \\ |
2030 \indexmltype{TypecopyPackage.hook}\verb|type TypecopyPackage.hook| \\ |
2036 \indexml{TypecopyPackage.get-spec}\verb|TypecopyPackage.get_spec: theory -> string|\isasep\isanewline% |
|
2037 \verb| -> (string * sort) list * (string * typ list) list| \\ |
|
2038 \indexmltype{TypecopyPackage.hook}\verb|type TypecopyPackage.hook = string * TypecopyPackage.info -> theory -> theory| \\ |
2031 \indexml{TypecopyPackage.add-hook}\verb|TypecopyPackage.add_hook: TypecopyPackage.hook -> theory -> theory| \\ |
2039 \indexml{TypecopyPackage.add-hook}\verb|TypecopyPackage.add_hook: TypecopyPackage.hook -> theory -> theory| \\ |
2032 \indexml{TypecopyPackage.get-spec}\verb|TypecopyPackage.get_spec: theory -> string|\isasep\isanewline% |
2040 \end{mldecls} |
2033 \verb| -> (string * sort) list * (string * typ list) list| |
2041 |
2034 \end{mldecls}% |
2042 \begin{description} |
2035 \end{isamarkuptext}% |
2043 |
2036 \isamarkuptrue% |
2044 \item \verb|TypecopyPackage.info| a record containing |
|
2045 the specification and further data of a type copy. |
|
2046 |
|
2047 \item \verb|TypecopyPackage.add_typecopy| defines a new |
|
2048 type copy. |
|
2049 |
|
2050 \item \verb|TypecopyPackage.get_typecopy_info| retrieves |
|
2051 data of an existing type copy. |
|
2052 |
|
2053 \item \verb|TypecopyPackage.get_spec| retrieves datatype-like |
|
2054 specification of a type copy. |
|
2055 |
|
2056 \item \verb|TypecopyPackage.hook|,~\verb|TypecopyPackage.add_hook| |
|
2057 provide a hook mechanism corresponding to the hook mechanism |
|
2058 on datatypes. |
|
2059 |
|
2060 \end{description}% |
|
2061 \end{isamarkuptext}% |
|
2062 \isamarkuptrue% |
|
2063 % |
|
2064 \endisatagmlref |
|
2065 {\isafoldmlref}% |
|
2066 % |
|
2067 \isadelimmlref |
|
2068 % |
|
2069 \endisadelimmlref |
|
2070 % |
|
2071 \isamarkupsubsubsection{Unifying type copies and datatypes% |
|
2072 } |
|
2073 \isamarkuptrue% |
|
2074 % |
|
2075 \begin{isamarkuptext}% |
|
2076 Since datatypes and type copies are mapped to the same concept (datatypes) |
|
2077 by code generation, the view on both is unified \qt{code types}:% |
|
2078 \end{isamarkuptext}% |
|
2079 \isamarkuptrue% |
|
2080 % |
|
2081 \isadelimmlref |
|
2082 % |
|
2083 \endisadelimmlref |
|
2084 % |
|
2085 \isatagmlref |
2037 % |
2086 % |
2038 \begin{isamarkuptext}% |
2087 \begin{isamarkuptext}% |
2039 \begin{mldecls} |
2088 \begin{mldecls} |
2040 \indexmltype{DatatypeCodegen.hook}\verb|type DatatypeCodegen.hook = (string * (bool * ((string * sort) list * (string * typ list) list))) list|\isasep\isanewline% |
2089 \indexmltype{DatatypeCodegen.hook}\verb|type DatatypeCodegen.hook = (string * (bool * ((string * sort) list|\isasep\isanewline% |
|
2090 \verb| * (string * typ list) list))) list|\isasep\isanewline% |
2041 \verb| -> theory -> theory| \\ |
2091 \verb| -> theory -> theory| \\ |
2042 \indexml{DatatypeCodegen.add-codetypes-hook-bootstrap}\verb|DatatypeCodegen.add_codetypes_hook_bootstrap: |\isasep\isanewline% |
2092 \indexml{DatatypeCodegen.add-codetypes-hook-bootstrap}\verb|DatatypeCodegen.add_codetypes_hook_bootstrap: |\isasep\isanewline% |
2043 \verb| DatatypeCodegen.hook -> theory -> theory| |
2093 \verb| DatatypeCodegen.hook -> theory -> theory| |
2044 \end{mldecls}% |
2094 \end{mldecls}% |
2045 \end{isamarkuptext}% |
2095 \end{isamarkuptext}% |
2051 \isadelimmlref |
2101 \isadelimmlref |
2052 % |
2102 % |
2053 \endisadelimmlref |
2103 \endisadelimmlref |
2054 % |
2104 % |
2055 \begin{isamarkuptext}% |
2105 \begin{isamarkuptext}% |
2056 \fixme |
2106 \begin{description} |
2057 % \emph{Happy proving, happy hacking!}% |
2107 |
|
2108 \item \verb|DatatypeCodegen.hook| specifies the code type hook |
|
2109 interface: a theory transformation depending on a list of |
|
2110 mutual recursive code types; each entry in the list |
|
2111 has the structure \isa{{\isacharparenleft}name{\isacharcomma}\ {\isacharparenleft}is{\isacharunderscore}data{\isacharcomma}\ {\isacharparenleft}vars{\isacharcomma}\ cons{\isacharparenright}{\isacharparenright}{\isacharparenright}} |
|
2112 where \isa{name} is the name of the code type, \isa{is{\isacharunderscore}data} |
|
2113 is true iff \isa{name} is a datatype rather then a type copy, |
|
2114 and \isa{{\isacharparenleft}vars{\isacharcomma}\ cons{\isacharparenright}} is the specification of the code type. |
|
2115 |
|
2116 \item \verb|DatatypeCodegen.add_codetypes_hook_bootstrap| adds a code |
|
2117 type hook; the hook is immediately processed for all already |
|
2118 existing datatypes, in blocks of mutual recursive datatypes, |
|
2119 where all datatypes a block depends on are processed before |
|
2120 the block. |
|
2121 |
|
2122 \end{description} |
|
2123 |
|
2124 \emph{Happy proving, happy hacking!}% |
2058 \end{isamarkuptext}% |
2125 \end{isamarkuptext}% |
2059 \isamarkuptrue% |
2126 \isamarkuptrue% |
2060 % |
2127 % |
2061 \isadelimtheory |
2128 \isadelimtheory |
2062 % |
2129 % |