588 \item[\isa{Pretty{\isacharunderscore}Char}] represents \isa{HOL} characters by |
588 \item[\isa{Pretty{\isacharunderscore}Char}] represents \isa{HOL} characters by |
589 character literals in target languages. |
589 character literals in target languages. |
590 \item[\isa{Pretty{\isacharunderscore}Char{\isacharunderscore}chr}] like \isa{Pretty{\isacharunderscore}Char}, |
590 \item[\isa{Pretty{\isacharunderscore}Char{\isacharunderscore}chr}] like \isa{Pretty{\isacharunderscore}Char}, |
591 but also offers treatment of character codes; includes |
591 but also offers treatment of character codes; includes |
592 \isa{Pretty{\isacharunderscore}Int}. |
592 \isa{Pretty{\isacharunderscore}Int}. |
593 \item[\isa{Executable{\isacharunderscore}Set}] allows to generate code |
593 \item[\isa{Executable{\isacharunderscore}Set}] \label{exec_set} allows to generate code |
594 for finite sets using lists. |
594 for finite sets using lists. |
595 \item[\isa{Executable{\isacharunderscore}Rat}] \label{exec_rat} implements rational |
595 \item[\isa{Executable{\isacharunderscore}Rat}] implements rational |
596 numbers as triples \isa{{\isacharparenleft}sign{\isacharcomma}\ enumerator{\isacharcomma}\ denominator{\isacharparenright}}. |
596 numbers. |
597 \item[\isa{Executable{\isacharunderscore}Real}] implements a subset of real numbers, |
597 \item[\isa{Executable{\isacharunderscore}Real}] implements a subset of real numbers, |
598 namly those representable by rational numbers. |
598 namly those representable by rational numbers. |
599 \item[\isa{Efficient{\isacharunderscore}Nat}] \label{eff_nat} implements natural numbers by integers, |
599 \item[\isa{Efficient{\isacharunderscore}Nat}] \label{eff_nat} implements natural numbers by integers, |
600 which in general will result in higher efficency; pattern |
600 which in general will result in higher efficency; pattern |
601 matching with \isa{{\isadigit{0}}} / \isa{Suc} |
601 matching with \isa{{\isadigit{0}}} / \isa{Suc} |
1568 % |
1568 % |
1569 \isatagmlref |
1569 \isatagmlref |
1570 % |
1570 % |
1571 \begin{isamarkuptext}% |
1571 \begin{isamarkuptext}% |
1572 \begin{mldecls} |
1572 \begin{mldecls} |
1573 \indexmltype{CodegenConsts.const}\verb|type CodegenConsts.const = string * string option| \\ |
1573 \indexmltype{CodeUnit.const}\verb|type CodeUnit.const = string * string option| \\ |
1574 \indexml{CodegenConsts.const-of-cexpr}\verb|CodegenConsts.const_of_cexpr: theory -> string * typ -> CodegenConsts.const| \\ |
1574 \indexml{CodeUnit.const-of-cexpr}\verb|CodeUnit.const_of_cexpr: theory -> string * typ -> CodeUnit.const| \\ |
1575 \end{mldecls} |
1575 \end{mldecls} |
1576 |
1576 |
1577 \begin{description} |
1577 \begin{description} |
1578 |
1578 |
1579 \item \verb|CodegenConsts.const| is the identifier type: |
1579 \item \verb|CodeUnit.const| is the identifier type: |
1580 the product of a \emph{string} with a list of \emph{typs}. |
1580 the product of a \emph{string} with a list of \emph{typs}. |
1581 The \emph{string} is the constant name as represented inside Isabelle; |
1581 The \emph{string} is the constant name as represented inside Isabelle; |
1582 for overloaded constants, the attached \emph{string option} |
1582 for overloaded constants, the attached \emph{string option} |
1583 is either \isa{SOME} type constructor denoting an instance, |
1583 is either \isa{SOME} type constructor denoting an instance, |
1584 or \isa{NONE} for the polymorphic constant. |
1584 or \isa{NONE} for the polymorphic constant. |
1585 |
1585 |
1586 \item \verb|CodegenConsts.const_of_cexpr|~\isa{thy}~\isa{{\isacharparenleft}constname{\isacharcomma}\ typ{\isacharparenright}} |
1586 \item \verb|CodeUnit.const_of_cexpr|~\isa{thy}~\isa{{\isacharparenleft}constname{\isacharcomma}\ typ{\isacharparenright}} |
1587 maps a constant expression \isa{{\isacharparenleft}constname{\isacharcomma}\ typ{\isacharparenright}} |
1587 maps a constant expression \isa{{\isacharparenleft}constname{\isacharcomma}\ typ{\isacharparenright}} |
1588 to its canonical identifier. |
1588 to its canonical identifier. |
1589 |
1589 |
1590 \end{description}% |
1590 \end{description}% |
1591 \end{isamarkuptext}% |
1591 \end{isamarkuptext}% |
1618 % |
1618 % |
1619 \isatagmlref |
1619 \isatagmlref |
1620 % |
1620 % |
1621 \begin{isamarkuptext}% |
1621 \begin{isamarkuptext}% |
1622 \begin{mldecls} |
1622 \begin{mldecls} |
1623 \indexml{CodegenData.lazy-thms}\verb|CodegenData.lazy_thms: (unit -> thm list) -> thm list Susp.T| |
1623 \indexml{Code.add-func}\verb|Code.add_func: bool -> thm -> theory -> theory| \\ |
|
1624 \indexml{Code.del-func}\verb|Code.del_func: thm -> theory -> theory| \\ |
|
1625 \indexml{Code.add-funcl}\verb|Code.add_funcl: CodeUnit.const * thm list Susp.T -> theory -> theory| \\ |
|
1626 \indexml{Code.add-inline}\verb|Code.add_inline: thm -> theory -> theory| \\ |
|
1627 \indexml{Code.del-inline}\verb|Code.del_inline: thm -> theory -> theory| \\ |
|
1628 \indexml{Code.add-inline-proc}\verb|Code.add_inline_proc: string * (theory -> cterm list -> thm list)|\isasep\isanewline% |
|
1629 \verb| -> theory -> theory| \\ |
|
1630 \indexml{Code.del-inline-proc}\verb|Code.del_inline_proc: string -> theory -> theory| \\ |
|
1631 \indexml{Code.add-preproc}\verb|Code.add_preproc: string * (theory -> thm list -> thm list)|\isasep\isanewline% |
|
1632 \verb| -> theory -> theory| \\ |
|
1633 \indexml{Code.del-preproc}\verb|Code.del_preproc: string -> theory -> theory| \\ |
|
1634 \indexml{Code.add-datatype}\verb|Code.add_datatype: string * ((string * sort) list * (string * typ list) list)|\isasep\isanewline% |
|
1635 \verb| -> theory -> theory| \\ |
|
1636 \indexml{Code.get-datatype}\verb|Code.get_datatype: theory -> string|\isasep\isanewline% |
|
1637 \verb| -> (string * sort) list * (string * typ list) list| \\ |
|
1638 \indexml{Code.get-datatype-of-constr}\verb|Code.get_datatype_of_constr: theory -> CodeUnit.const -> string option| |
1624 \end{mldecls} |
1639 \end{mldecls} |
1625 |
1640 |
1626 \begin{description} |
1641 \begin{description} |
1627 |
1642 |
1628 \item \verb|CodegenData.lazy_thms|~\isa{f} turns an abstract |
1643 \item \verb|Code.add_func|~\isa{thm}~\isa{thy} adds function |
1629 theorem computation \isa{f} into a suspension of theorems. |
|
1630 |
|
1631 \end{description}% |
|
1632 \end{isamarkuptext}% |
|
1633 \isamarkuptrue% |
|
1634 % |
|
1635 \endisatagmlref |
|
1636 {\isafoldmlref}% |
|
1637 % |
|
1638 \isadelimmlref |
|
1639 % |
|
1640 \endisadelimmlref |
|
1641 % |
|
1642 \isamarkupsubsubsection{Managing executable content% |
|
1643 } |
|
1644 \isamarkuptrue% |
|
1645 % |
|
1646 \isadelimmlref |
|
1647 % |
|
1648 \endisadelimmlref |
|
1649 % |
|
1650 \isatagmlref |
|
1651 % |
|
1652 \begin{isamarkuptext}% |
|
1653 \begin{mldecls} |
|
1654 \indexml{CodegenData.add-func}\verb|CodegenData.add_func: bool -> thm -> theory -> theory| \\ |
|
1655 \indexml{CodegenData.del-func}\verb|CodegenData.del_func: thm -> theory -> theory| \\ |
|
1656 \indexml{CodegenData.add-funcl}\verb|CodegenData.add_funcl: CodegenConsts.const * thm list Susp.T -> theory -> theory| \\ |
|
1657 \indexml{CodegenData.add-inline}\verb|CodegenData.add_inline: thm -> theory -> theory| \\ |
|
1658 \indexml{CodegenData.del-inline}\verb|CodegenData.del_inline: thm -> theory -> theory| \\ |
|
1659 \indexml{CodegenData.add-inline-proc}\verb|CodegenData.add_inline_proc: string * (theory -> cterm list -> thm list)|\isasep\isanewline% |
|
1660 \verb| -> theory -> theory| \\ |
|
1661 \indexml{CodegenData.del-inline-proc}\verb|CodegenData.del_inline_proc: string -> theory -> theory| \\ |
|
1662 \indexml{CodegenData.add-preproc}\verb|CodegenData.add_preproc: string * (theory -> thm list -> thm list)|\isasep\isanewline% |
|
1663 \verb| -> theory -> theory| \\ |
|
1664 \indexml{CodegenData.del-preproc}\verb|CodegenData.del_preproc: string -> theory -> theory| \\ |
|
1665 \indexml{CodegenData.add-datatype}\verb|CodegenData.add_datatype: string * ((string * sort) list * (string * typ list) list)|\isasep\isanewline% |
|
1666 \verb| -> theory -> theory| \\ |
|
1667 \indexml{CodegenData.get-datatype}\verb|CodegenData.get_datatype: theory -> string|\isasep\isanewline% |
|
1668 \verb| -> (string * sort) list * (string * typ list) list| \\ |
|
1669 \indexml{CodegenData.get-datatype-of-constr}\verb|CodegenData.get_datatype_of_constr: theory -> CodegenConsts.const -> string option| |
|
1670 \end{mldecls} |
|
1671 |
|
1672 \begin{description} |
|
1673 |
|
1674 \item \verb|CodegenData.add_func|~\isa{thm}~\isa{thy} adds function |
|
1675 theorem \isa{thm} to executable content. |
1644 theorem \isa{thm} to executable content. |
1676 |
1645 |
1677 \item \verb|CodegenData.del_func|~\isa{thm}~\isa{thy} removes function |
1646 \item \verb|Code.del_func|~\isa{thm}~\isa{thy} removes function |
1678 theorem \isa{thm} from executable content, if present. |
1647 theorem \isa{thm} from executable content, if present. |
1679 |
1648 |
1680 \item \verb|CodegenData.add_funcl|~\isa{{\isacharparenleft}const{\isacharcomma}\ lthms{\isacharparenright}}~\isa{thy} adds |
1649 \item \verb|Code.add_funcl|~\isa{{\isacharparenleft}const{\isacharcomma}\ lthms{\isacharparenright}}~\isa{thy} adds |
1681 suspended defining equations \isa{lthms} for constant |
1650 suspended defining equations \isa{lthms} for constant |
1682 \isa{const} to executable content. |
1651 \isa{const} to executable content. |
1683 |
1652 |
1684 \item \verb|CodegenData.add_inline|~\isa{thm}~\isa{thy} adds |
1653 \item \verb|Code.add_inline|~\isa{thm}~\isa{thy} adds |
1685 inlining theorem \isa{thm} to executable content. |
1654 inlining theorem \isa{thm} to executable content. |
1686 |
1655 |
1687 \item \verb|CodegenData.del_inline|~\isa{thm}~\isa{thy} remove |
1656 \item \verb|Code.del_inline|~\isa{thm}~\isa{thy} remove |
1688 inlining theorem \isa{thm} from executable content, if present. |
1657 inlining theorem \isa{thm} from executable content, if present. |
1689 |
1658 |
1690 \item \verb|CodegenData.add_inline_proc|~\isa{{\isacharparenleft}name{\isacharcomma}\ f{\isacharparenright}}~\isa{thy} adds |
1659 \item \verb|Code.add_inline_proc|~\isa{{\isacharparenleft}name{\isacharcomma}\ f{\isacharparenright}}~\isa{thy} adds |
1691 inline procedure \isa{f} (named \isa{name}) to executable content; |
1660 inline procedure \isa{f} (named \isa{name}) to executable content; |
1692 \isa{f} is a computation of rewrite rules dependent on |
1661 \isa{f} is a computation of rewrite rules dependent on |
1693 the current theory context and the list of all arguments |
1662 the current theory context and the list of all arguments |
1694 and right hand sides of the defining equations belonging |
1663 and right hand sides of the defining equations belonging |
1695 to a certain function definition. |
1664 to a certain function definition. |
1696 |
1665 |
1697 \item \verb|CodegenData.del_inline_proc|~\isa{name}~\isa{thy} removes |
1666 \item \verb|Code.del_inline_proc|~\isa{name}~\isa{thy} removes |
1698 inline procedure named \isa{name} from executable content. |
1667 inline procedure named \isa{name} from executable content. |
1699 |
1668 |
1700 \item \verb|CodegenData.add_preproc|~\isa{{\isacharparenleft}name{\isacharcomma}\ f{\isacharparenright}}~\isa{thy} adds |
1669 \item \verb|Code.add_preproc|~\isa{{\isacharparenleft}name{\isacharcomma}\ f{\isacharparenright}}~\isa{thy} adds |
1701 generic preprocessor \isa{f} (named \isa{name}) to executable content; |
1670 generic preprocessor \isa{f} (named \isa{name}) to executable content; |
1702 \isa{f} is a transformation of the defining equations belonging |
1671 \isa{f} is a transformation of the defining equations belonging |
1703 to a certain function definition, depending on the |
1672 to a certain function definition, depending on the |
1704 current theory context. |
1673 current theory context. |
1705 |
1674 |
1706 \item \verb|CodegenData.del_preproc|~\isa{name}~\isa{thy} removes |
1675 \item \verb|Code.del_preproc|~\isa{name}~\isa{thy} removes |
1707 generic preprcoessor named \isa{name} from executable content. |
1676 generic preprcoessor named \isa{name} from executable content. |
1708 |
1677 |
1709 \item \verb|CodegenData.add_datatype|~\isa{{\isacharparenleft}name{\isacharcomma}\ spec{\isacharparenright}}~\isa{thy} adds |
1678 \item \verb|Code.add_datatype|~\isa{{\isacharparenleft}name{\isacharcomma}\ spec{\isacharparenright}}~\isa{thy} adds |
1710 a datatype to executable content, with type constructor |
1679 a datatype to executable content, with type constructor |
1711 \isa{name} and specification \isa{spec}; \isa{spec} is |
1680 \isa{name} and specification \isa{spec}; \isa{spec} is |
1712 a pair consisting of a list of type variable with sort |
1681 a pair consisting of a list of type variable with sort |
1713 constraints and a list of constructors with name |
1682 constraints and a list of constructors with name |
1714 and types of arguments. |
1683 and types of arguments. |
1715 |
1684 |
1716 \item \verb|CodegenData.get_datatype_of_constr|~\isa{thy}~\isa{const} |
1685 \item \verb|Code.get_datatype_of_constr|~\isa{thy}~\isa{const} |
1717 returns type constructor corresponding to |
1686 returns type constructor corresponding to |
1718 constructor \isa{const}; returns \isa{NONE} |
1687 constructor \isa{const}; returns \isa{NONE} |
1719 if \isa{const} is no constructor. |
1688 if \isa{const} is no constructor. |
1720 |
1689 |
1721 \end{description}% |
1690 \end{description}% |
1739 % |
1708 % |
1740 \isatagmlref |
1709 \isatagmlref |
1741 % |
1710 % |
1742 \begin{isamarkuptext}% |
1711 \begin{isamarkuptext}% |
1743 \begin{mldecls} |
1712 \begin{mldecls} |
1744 \indexml{CodegenConsts.const-ord}\verb|CodegenConsts.const_ord: CodegenConsts.const * CodegenConsts.const -> order| \\ |
1713 \indexml{CodeUnit.const-ord}\verb|CodeUnit.const_ord: CodeUnit.const * CodeUnit.const -> order| \\ |
1745 \indexml{CodegenConsts.eq-const}\verb|CodegenConsts.eq_const: CodegenConsts.const * CodegenConsts.const -> bool| \\ |
1714 \indexml{CodeUnit.eq-const}\verb|CodeUnit.eq_const: CodeUnit.const * CodeUnit.const -> bool| \\ |
1746 \indexml{CodegenConsts.read-const}\verb|CodegenConsts.read_const: theory -> string -> CodegenConsts.const| \\ |
1715 \indexml{CodeUnit.read-const}\verb|CodeUnit.read_const: theory -> string -> CodeUnit.const| \\ |
1747 \indexmlstructure{CodegenConsts.Consttab}\verb|structure CodegenConsts.Consttab| \\ |
1716 \indexmlstructure{CodeUnit.Consttab}\verb|structure CodeUnit.Consttab| \\ |
1748 \indexml{CodegenFunc.head-func}\verb|CodegenFunc.head_func: thm -> CodegenConsts.const * typ| \\ |
1717 \indexml{CodeUnit.head-func}\verb|CodeUnit.head_func: thm -> CodeUnit.const * typ| \\ |
1749 \indexml{CodegenFunc.rewrite-func}\verb|CodegenFunc.rewrite_func: thm list -> thm -> thm| \\ |
1718 \indexml{CodeUnit.rewrite-func}\verb|CodeUnit.rewrite_func: thm list -> thm -> thm| \\ |
1750 \end{mldecls} |
1719 \end{mldecls} |
1751 |
1720 |
1752 \begin{description} |
1721 \begin{description} |
1753 |
1722 |
1754 \item \verb|CodegenConsts.const_ord|,~\verb|CodegenConsts.eq_const| |
1723 \item \verb|CodeUnit.const_ord|,~\verb|CodeUnit.eq_const| |
1755 provide order and equality on constant identifiers. |
1724 provide order and equality on constant identifiers. |
1756 |
1725 |
1757 \item \verb|CodegenConsts.Consttab| |
1726 \item \verb|CodeUnit.Consttab| |
1758 provides table structures with constant identifiers as keys. |
1727 provides table structures with constant identifiers as keys. |
1759 |
1728 |
1760 \item \verb|CodegenConsts.read_const|~\isa{thy}~\isa{s} |
1729 \item \verb|CodeUnit.read_const|~\isa{thy}~\isa{s} |
1761 reads a constant as a concrete term expression \isa{s}. |
1730 reads a constant as a concrete term expression \isa{s}. |
1762 |
1731 |
1763 \item \verb|CodegenFunc.head_func|~\isa{thm} |
1732 \item \verb|CodeUnit.head_func|~\isa{thm} |
1764 extracts the constant and its type from a defining equation \isa{thm}. |
1733 extracts the constant and its type from a defining equation \isa{thm}. |
1765 |
1734 |
1766 \item \verb|CodegenFunc.rewrite_func|~\isa{rews}~\isa{thm} |
1735 \item \verb|CodeUnit.rewrite_func|~\isa{rews}~\isa{thm} |
1767 rewrites a defining equation \isa{thm} with a set of rewrite |
1736 rewrites a defining equation \isa{thm} with a set of rewrite |
1768 rules \isa{rews}; only arguments and right hand side are rewritten, |
1737 rules \isa{rews}; only arguments and right hand side are rewritten, |
1769 not the head of the defining equation. |
1738 not the head of the defining equation. |
1770 |
1739 |
1771 \end{description}% |
1740 \end{description}% |
1921 % |
1890 % |
1922 \isatagmlref |
1891 \isatagmlref |
1923 % |
1892 % |
1924 \begin{isamarkuptext}% |
1893 \begin{isamarkuptext}% |
1925 \begin{mldecls} |
1894 \begin{mldecls} |
1926 \indexmltype{CodegenFuncgr.T}\verb|type CodegenFuncgr.T| \\ |
1895 \indexmltype{CodeFuncgr.T}\verb|type CodeFuncgr.T| \\ |
1927 \indexml{CodegenFuncgr.funcs}\verb|CodegenFuncgr.funcs: CodegenFuncgr.T -> CodegenConsts.const -> thm list| \\ |
1896 \indexml{CodeFuncgr.funcs}\verb|CodeFuncgr.funcs: CodeFuncgr.T -> CodeUnit.const -> thm list| \\ |
1928 \indexml{CodegenFuncgr.typ}\verb|CodegenFuncgr.typ: CodegenFuncgr.T -> CodegenConsts.const -> typ| \\ |
1897 \indexml{CodeFuncgr.typ}\verb|CodeFuncgr.typ: CodeFuncgr.T -> CodeUnit.const -> typ| \\ |
1929 \indexml{CodegenFuncgr.deps}\verb|CodegenFuncgr.deps: CodegenFuncgr.T|\isasep\isanewline% |
1898 \indexml{CodeFuncgr.deps}\verb|CodeFuncgr.deps: CodeFuncgr.T|\isasep\isanewline% |
1930 \verb| -> CodegenConsts.const list -> CodegenConsts.const list list| \\ |
1899 \verb| -> CodeUnit.const list -> CodeUnit.const list list| \\ |
1931 \indexml{CodegenFuncgr.all}\verb|CodegenFuncgr.all: CodegenFuncgr.T -> CodegenConsts.const list| |
1900 \indexml{CodeFuncgr.all}\verb|CodeFuncgr.all: CodeFuncgr.T -> CodeUnit.const list| |
1932 \end{mldecls} |
1901 \end{mldecls} |
1933 |
1902 |
1934 \begin{description} |
1903 \begin{description} |
1935 |
1904 |
1936 \item \verb|CodegenFuncgr.T| represents |
1905 \item \verb|CodeFuncgr.T| represents |
1937 a normalized defining equation system. |
1906 a normalized defining equation system. |
1938 |
1907 |
1939 \item \verb|CodegenFuncgr.funcs|~\isa{funcgr}~\isa{const} |
1908 \item \verb|CodeFuncgr.funcs|~\isa{funcgr}~\isa{const} |
1940 retrieves defining equiations for constant \isa{const}. |
1909 retrieves defining equiations for constant \isa{const}. |
1941 |
1910 |
1942 \item \verb|CodegenFuncgr.typ|~\isa{funcgr}~\isa{const} |
1911 \item \verb|CodeFuncgr.typ|~\isa{funcgr}~\isa{const} |
1943 retrieves function type for constant \isa{const}. |
1912 retrieves function type for constant \isa{const}. |
1944 |
1913 |
1945 \item \verb|CodegenFuncgr.deps|~\isa{funcgr}~\isa{consts} |
1914 \item \verb|CodeFuncgr.deps|~\isa{funcgr}~\isa{consts} |
1946 returns the transitive closure of dependencies for |
1915 returns the transitive closure of dependencies for |
1947 constants \isa{consts} as a partitioning where each partition |
1916 constants \isa{consts} as a partitioning where each partition |
1948 corresponds to a strongly connected component of |
1917 corresponds to a strongly connected component of |
1949 dependencies and any partition does \emph{not} |
1918 dependencies and any partition does \emph{not} |
1950 depend on partitions further left. |
1919 depend on partitions further left. |
1951 |
1920 |
1952 \item \verb|CodegenFuncgr.all|~\isa{funcgr} |
1921 \item \verb|CodeFuncgr.all|~\isa{funcgr} |
1953 returns all currently represented constants. |
1922 returns all currently represented constants. |
1954 |
1923 |
1955 \end{description}% |
1924 \end{description}% |
1956 \end{isamarkuptext}% |
1925 \end{isamarkuptext}% |
1957 \isamarkuptrue% |
1926 \isamarkuptrue% |