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 |
|
594 for finite sets using lists. |
|
595 \item[\isa{Executable{\isacharunderscore}Rat}] implements rational |
593 \item[\isa{Executable{\isacharunderscore}Rat}] implements rational |
596 numbers. |
594 numbers. |
597 \item[\isa{Executable{\isacharunderscore}Real}] implements a subset of real numbers, |
595 \item[\isa{Executable{\isacharunderscore}Real}] implements a subset of real numbers, |
598 namly those representable by rational numbers. |
596 namly those representable by rational numbers. |
599 \item[\isa{Efficient{\isacharunderscore}Nat}] \label{eff_nat} implements natural numbers by integers, |
597 \item[\isa{Efficient{\isacharunderscore}Nat}] \label{eff_nat} implements natural numbers by integers, |
1302 how to implement finite sets by lists |
1300 how to implement finite sets by lists |
1303 using the conversion \isa{{\isachardoublequote}set\ {\isasymColon}\ {\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a\ set{\isachardoublequote}} |
1301 using the conversion \isa{{\isachardoublequote}set\ {\isasymColon}\ {\isacharprime}a\ list\ {\isasymRightarrow}\ {\isacharprime}a\ set{\isachardoublequote}} |
1304 as constructor:% |
1302 as constructor:% |
1305 \end{isamarkuptext}% |
1303 \end{isamarkuptext}% |
1306 \isamarkuptrue% |
1304 \isamarkuptrue% |
|
1305 \ % |
|
1306 \isadelimML |
|
1307 % |
|
1308 \endisadelimML |
|
1309 % |
|
1310 \isatagML |
|
1311 % |
|
1312 \endisatagML |
|
1313 {\isafoldML}% |
|
1314 % |
|
1315 \isadelimML |
|
1316 % |
|
1317 \endisadelimML |
|
1318 \isanewline |
1307 \isacommand{code{\isacharunderscore}datatype}\isamarkupfalse% |
1319 \isacommand{code{\isacharunderscore}datatype}\isamarkupfalse% |
1308 \ set\isanewline |
1320 \ set\isanewline |
1309 \isanewline |
1321 \isanewline |
1310 \isacommand{lemma}\isamarkupfalse% |
1322 \isacommand{lemma}\isamarkupfalse% |
1311 \ {\isacharbrackleft}code\ func{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharbraceleft}{\isacharbraceright}\ {\isacharequal}\ set\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequoteclose}% |
1323 \ {\isacharbrackleft}code\ func{\isacharbrackright}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharbraceleft}{\isacharbraceright}\ {\isacharequal}\ set\ {\isacharbrackleft}{\isacharbrackright}{\isachardoublequoteclose}% |
1471 code-generation-based applications, here a short |
1483 code-generation-based applications, here a short |
1472 description of the most important ML interfaces.% |
1484 description of the most important ML interfaces.% |
1473 \end{isamarkuptext}% |
1485 \end{isamarkuptext}% |
1474 \isamarkuptrue% |
1486 \isamarkuptrue% |
1475 % |
1487 % |
1476 \isamarkupsubsection{Basics: \isa{CodeUnit}% |
|
1477 } |
|
1478 \isamarkuptrue% |
|
1479 % |
|
1480 \begin{isamarkuptext}% |
|
1481 This module provides identification of (probably overloaded) |
|
1482 constants by unique identifiers.% |
|
1483 \end{isamarkuptext}% |
|
1484 \isamarkuptrue% |
|
1485 % |
|
1486 \isadelimmlref |
|
1487 % |
|
1488 \endisadelimmlref |
|
1489 % |
|
1490 \isatagmlref |
|
1491 % |
|
1492 \begin{isamarkuptext}% |
|
1493 \begin{mldecls} |
|
1494 \indexmltype{CodeUnit.const}\verb|type CodeUnit.const = string * string option| \\ |
|
1495 \indexml{CodeUnit.const-of-cexpr}\verb|CodeUnit.const_of_cexpr: theory -> string * typ -> CodeUnit.const| \\ |
|
1496 \end{mldecls} |
|
1497 |
|
1498 \begin{description} |
|
1499 |
|
1500 \item \verb|CodeUnit.const| is the identifier type: |
|
1501 the product of a \emph{string} with a list of \emph{typs}. |
|
1502 The \emph{string} is the constant name as represented inside Isabelle; |
|
1503 for overloaded constants, the attached \emph{string option} |
|
1504 is either \isa{SOME} type constructor denoting an instance, |
|
1505 or \isa{NONE} for the polymorphic constant. |
|
1506 |
|
1507 \item \verb|CodeUnit.const_of_cexpr|~\isa{thy}~\isa{{\isacharparenleft}constname{\isacharcomma}\ typ{\isacharparenright}} |
|
1508 maps a constant expression \isa{{\isacharparenleft}constname{\isacharcomma}\ typ{\isacharparenright}} |
|
1509 to its canonical identifier. |
|
1510 |
|
1511 \end{description}% |
|
1512 \end{isamarkuptext}% |
|
1513 \isamarkuptrue% |
|
1514 % |
|
1515 \endisatagmlref |
|
1516 {\isafoldmlref}% |
|
1517 % |
|
1518 \isadelimmlref |
|
1519 % |
|
1520 \endisadelimmlref |
|
1521 % |
|
1522 \isamarkupsubsection{Executable theory content: \isa{Code}% |
1488 \isamarkupsubsection{Executable theory content: \isa{Code}% |
1523 } |
1489 } |
1524 \isamarkuptrue% |
1490 \isamarkuptrue% |
1525 % |
1491 % |
1526 \begin{isamarkuptext}% |
1492 \begin{isamarkuptext}% |
1541 % |
1507 % |
1542 \begin{isamarkuptext}% |
1508 \begin{isamarkuptext}% |
1543 \begin{mldecls} |
1509 \begin{mldecls} |
1544 \indexml{Code.add-func}\verb|Code.add_func: bool -> thm -> theory -> theory| \\ |
1510 \indexml{Code.add-func}\verb|Code.add_func: bool -> thm -> theory -> theory| \\ |
1545 \indexml{Code.del-func}\verb|Code.del_func: thm -> theory -> theory| \\ |
1511 \indexml{Code.del-func}\verb|Code.del_func: thm -> theory -> theory| \\ |
1546 \indexml{Code.add-funcl}\verb|Code.add_funcl: CodeUnit.const * thm list Susp.T -> theory -> theory| \\ |
1512 \indexml{Code.add-funcl}\verb|Code.add_funcl: string * thm list Susp.T -> theory -> theory| \\ |
1547 \indexml{Code.add-inline}\verb|Code.add_inline: thm -> theory -> theory| \\ |
1513 \indexml{Code.add-inline}\verb|Code.add_inline: thm -> theory -> theory| \\ |
1548 \indexml{Code.del-inline}\verb|Code.del_inline: thm -> theory -> theory| \\ |
1514 \indexml{Code.del-inline}\verb|Code.del_inline: thm -> theory -> theory| \\ |
1549 \indexml{Code.add-inline-proc}\verb|Code.add_inline_proc: string * (theory -> cterm list -> thm list)|\isasep\isanewline% |
1515 \indexml{Code.add-inline-proc}\verb|Code.add_inline_proc: string * (theory -> cterm list -> thm list)|\isasep\isanewline% |
1550 \verb| -> theory -> theory| \\ |
1516 \verb| -> theory -> theory| \\ |
1551 \indexml{Code.del-inline-proc}\verb|Code.del_inline_proc: string -> theory -> theory| \\ |
1517 \indexml{Code.del-inline-proc}\verb|Code.del_inline_proc: string -> theory -> theory| \\ |
1552 \indexml{Code.add-preproc}\verb|Code.add_preproc: string * (theory -> thm list -> thm list)|\isasep\isanewline% |
1518 \indexml{Code.add-preproc}\verb|Code.add_preproc: string * (theory -> thm list -> thm list)|\isasep\isanewline% |
1553 \verb| -> theory -> theory| \\ |
1519 \verb| -> theory -> theory| \\ |
1554 \indexml{Code.del-preproc}\verb|Code.del_preproc: string -> theory -> theory| \\ |
1520 \indexml{Code.del-preproc}\verb|Code.del_preproc: string -> theory -> theory| \\ |
1555 \indexml{Code.add-datatype}\verb|Code.add_datatype: string * ((string * sort) list * (string * typ list) list)|\isasep\isanewline% |
1521 \indexml{Code.add-datatype}\verb|Code.add_datatype: (string * typ) list -> theory -> theory| \\ |
1556 \verb| -> theory -> theory| \\ |
|
1557 \indexml{Code.get-datatype}\verb|Code.get_datatype: theory -> string|\isasep\isanewline% |
1522 \indexml{Code.get-datatype}\verb|Code.get_datatype: theory -> string|\isasep\isanewline% |
1558 \verb| -> (string * sort) list * (string * typ list) list| \\ |
1523 \verb| -> (string * sort) list * (string * typ list) list| \\ |
1559 \indexml{Code.get-datatype-of-constr}\verb|Code.get_datatype_of_constr: theory -> CodeUnit.const -> string option| |
1524 \indexml{Code.get-datatype-of-constr}\verb|Code.get_datatype_of_constr: theory -> string -> string option| |
1560 \end{mldecls} |
1525 \end{mldecls} |
1561 |
1526 |
1562 \begin{description} |
1527 \begin{description} |
1563 |
1528 |
1564 \item \verb|Code.add_func|~\isa{thm}~\isa{thy} adds function |
1529 \item \verb|Code.add_func|~\isa{thm}~\isa{thy} adds function |
1594 current theory context. |
1559 current theory context. |
1595 |
1560 |
1596 \item \verb|Code.del_preproc|~\isa{name}~\isa{thy} removes |
1561 \item \verb|Code.del_preproc|~\isa{name}~\isa{thy} removes |
1597 generic preprcoessor named \isa{name} from executable content. |
1562 generic preprcoessor named \isa{name} from executable content. |
1598 |
1563 |
1599 \item \verb|Code.add_datatype|~\isa{{\isacharparenleft}name{\isacharcomma}\ spec{\isacharparenright}}~\isa{thy} adds |
1564 \item \verb|Code.add_datatype|~\isa{cs}~\isa{thy} adds |
1600 a datatype to executable content, with type constructor |
1565 a datatype to executable content, with generation |
1601 \isa{name} and specification \isa{spec}; \isa{spec} is |
1566 set \isa{cs}. |
1602 a pair consisting of a list of type variable with sort |
|
1603 constraints and a list of constructors with name |
|
1604 and types of arguments. |
|
1605 |
1567 |
1606 \item \verb|Code.get_datatype_of_constr|~\isa{thy}~\isa{const} |
1568 \item \verb|Code.get_datatype_of_constr|~\isa{thy}~\isa{const} |
1607 returns type constructor corresponding to |
1569 returns type constructor corresponding to |
1608 constructor \isa{const}; returns \isa{NONE} |
1570 constructor \isa{const}; returns \isa{NONE} |
1609 if \isa{const} is no constructor. |
1571 if \isa{const} is no constructor. |
1629 % |
1591 % |
1630 \isatagmlref |
1592 \isatagmlref |
1631 % |
1593 % |
1632 \begin{isamarkuptext}% |
1594 \begin{isamarkuptext}% |
1633 \begin{mldecls} |
1595 \begin{mldecls} |
1634 \indexml{CodeUnit.const-ord}\verb|CodeUnit.const_ord: CodeUnit.const * CodeUnit.const -> order| \\ |
1596 \indexml{CodeUnit.read-const}\verb|CodeUnit.read_const: theory -> string -> string| \\ |
1635 \indexml{CodeUnit.eq-const}\verb|CodeUnit.eq_const: CodeUnit.const * CodeUnit.const -> bool| \\ |
1597 \indexml{CodeUnit.head-func}\verb|CodeUnit.head_func: thm -> string * typ| \\ |
1636 \indexml{CodeUnit.read-const}\verb|CodeUnit.read_const: theory -> string -> CodeUnit.const| \\ |
|
1637 \indexmlstructure{CodeUnit.Consttab}\verb|structure CodeUnit.Consttab| \\ |
|
1638 \indexml{CodeUnit.head-func}\verb|CodeUnit.head_func: thm -> CodeUnit.const * typ| \\ |
|
1639 \indexml{CodeUnit.rewrite-func}\verb|CodeUnit.rewrite_func: thm list -> thm -> thm| \\ |
1598 \indexml{CodeUnit.rewrite-func}\verb|CodeUnit.rewrite_func: thm list -> thm -> thm| \\ |
1640 \end{mldecls} |
1599 \end{mldecls} |
1641 |
1600 |
1642 \begin{description} |
1601 \begin{description} |
1643 |
|
1644 \item \verb|CodeUnit.const_ord|,~\verb|CodeUnit.eq_const| |
|
1645 provide order and equality on constant identifiers. |
|
1646 |
|
1647 \item \verb|CodeUnit.Consttab| |
|
1648 provides table structures with constant identifiers as keys. |
|
1649 |
1602 |
1650 \item \verb|CodeUnit.read_const|~\isa{thy}~\isa{s} |
1603 \item \verb|CodeUnit.read_const|~\isa{thy}~\isa{s} |
1651 reads a constant as a concrete term expression \isa{s}. |
1604 reads a constant as a concrete term expression \isa{s}. |
1652 |
1605 |
1653 \item \verb|CodeUnit.head_func|~\isa{thm} |
1606 \item \verb|CodeUnit.head_func|~\isa{thm} |