src/Doc/Datatypes/Datatypes.thy
author blanchet
Thu, 01 Aug 2013 15:50:16 +0200
changeset 52824 b7a83845bc93
parent 52822 ae938ac9a721
child 52827 395d3df496ed
permissions -rw-r--r--
more (co)datatype documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     1
(*  Title:      Doc/Datatypes/Datatypes.thy
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     2
    Author:     Jasmin Blanchette, TU Muenchen
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     3
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     4
Tutorial for (co)datatype definitions with the new package.
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     5
*)
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     6
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     7
theory Datatypes
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
     8
imports Setup
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
     9
begin
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    10
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    11
section {* Introduction *}
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    12
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    13
text {*
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    14
The 2013 edition of Isabelle introduced new definitional package for datatypes
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    15
and codatatypes. The datatype support is similar to that provided by the earlier
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    16
package due to Berghofer and Wenzel \cite{Berghofer-Wenzel:1999:TPHOL};
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
    17
indeed, replacing @{command datatype} by @{command datatype_new} is usually sufficient
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    18
to port existing specifications to the new package. What makes the new package
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    19
attractive is that it supports definitions with recursion through a large class
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    20
of non-datatypes, notably finite sets:
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    21
*}
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    22
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    23
    datatype_new 'a treeFS = TreeFS 'a "'a treeFS fset"
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    24
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    25
text {*
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    26
\noindent
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    27
Another advantage of the new package is that it supports local definitions:
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    28
*}
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    29
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    30
    context linorder
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    31
    begin
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    32
      datatype_new flag = Less | Eq | Greater
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    33
    end
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    34
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    35
text {*
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    36
\noindent
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    37
Finally, the package also provides some convenience, notably automatically
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
    38
generated destructors.
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    39
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
    40
The command @{command datatype_new} is expected to displace @{command datatype} in a future
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
    41
release. Authors of new theories are encouraged to use @{command datatype_new}, and
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    42
maintainers of older theories may want to consider upgrading in the coming months.
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    43
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    44
The package also provides codatatypes (or ``coinductive datatypes''), which may
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    45
have infinite values. The following command introduces a codatatype of infinite
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    46
streams:
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    47
*}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    48
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    49
    codatatype 'a stream = Stream 'a "'a stream"
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    50
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    51
text {*
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    52
\noindent
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    53
Mixed inductive--coinductive recursion is possible via nesting.
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    54
Compare the following four examples:
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    55
*}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    56
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    57
    datatype_new 'a treeFF = TreeFF 'a "'a treeFF list"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    58
    datatype_new 'a treeFI = TreeFI 'a "'a treeFF stream"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    59
    codatatype 'a treeIF = TreeIF 'a "'a treeFF list"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    60
    codatatype 'a treeII = TreeII 'a "'a treeFF stream"
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    61
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    62
text {*
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    63
To use the package, it is necessary to import the @{theory BNF} theory, which
52806
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
    64
can be precompiled as the \textit{HOL-BNF} image. The following commands show
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
    65
how to launch jEdit/PIDE with the image loaded and how to build the image
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
    66
without launching jEdit:
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    67
*}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    68
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    69
text {*
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    70
\noindent
52806
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
    71
\ \ \ \ \texttt{isabelle jedit -l HOL-BNF} \\
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    72
\ \ \ \ \texttt{isabelle build -b HOL-BNF}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    73
*}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    74
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    75
text {*
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    76
The package, like its predecessor, fully adheres to the LCF philosophy
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    77
\cite{mgordon79}: The characteristic theorems associated with the specified
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    78
(co)datatypes are derived rather than introduced axiomatically.%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    79
\footnote{Nonetheless, if the \textit{quick\_and\_dirty} option is enabled, some
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    80
of the internal constructions and most of the internal proof obligations are
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    81
skipped.}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    82
The package's metatheory is described in a pair of papers
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    83
\cite{traytel-et-al-2012,blanchette-et-al-wit}.
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    84
*}
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
    85
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    86
text {*
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    87
This tutorial is organized as follows:
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
    88
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    89
\begin{itemize}
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
    90
\setlength{\itemsep}{0pt}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
    91
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    92
\item Section \ref{sec:defining-datatypes}, ``Defining Datatypes,''
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
    93
describes how to specify datatypes using the @{command datatype_new} command.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    94
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    95
\item Section \ref{sec:defining-recursive-functions}, ``Defining Recursive 
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    96
Functions,'' describes how to specify recursive functions using
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
    97
\keyw{primrec\_new}, @{command fun}, and @{command function}.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    98
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
    99
\item Section \ref{sec:defining-codatatypes}, ``Defining Codatatypes,''
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   100
describes how to specify codatatypes using the @{command codatatype} command.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   101
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   102
\item Section \ref{sec:defining-corecursive-functions}, ``Defining Corecursive 
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   103
Functions,'' describes how to specify corecursive functions using the
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   104
\keyw{primcorec} command.
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   105
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   106
\item Section \ref{sec:registering-bounded-natural-functors}, ``Registering 
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   107
Bounded Natural Functors,'' explains how to set up the (co)datatype package to
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   108
allow nested recursion through custom well-behaved type constructors.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   109
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   110
\item Section \ref{sec:generating-free-constructor-theorems}, ``Generating Free 
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   111
Constructor Theorems,'' explains how to derive convenience theorems for free
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   112
constructors, as performed internally by @{command datatype_new} and
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   113
@{command codatatype}.
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   114
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   115
\item Section \ref{sec:standard-ml-interface}, ``Standard ML Interface,''
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   116
describes the package's programmatic interface.
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   117
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   118
\item Section \ref{sec:interoperability}, ``Interoperability,''
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   119
is concerned with the packages' interaction with other Isabelle packages and
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   120
tools, such as the code generator and the counterexample generators.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   121
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   122
\item Section \ref{sec:known-bugs-and-limitations}, ``Known Bugs and 
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   123
Limitations,'' concludes with known open issues at the time of writing.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   124
\end{itemize}
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   125
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   126
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   127
\newbox\boxA
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   128
\setbox\boxA=\hbox{\texttt{nospam}}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   129
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   130
\newcommand\authoremaili{\texttt{blan{\color{white}nospam}\kern-\wd\boxA{}chette@\allowbreak
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   131
in.\allowbreak tum.\allowbreak de}}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   132
\newcommand\authoremailii{\texttt{pope{\color{white}nospam}\kern-\wd\boxA{}scua@\allowbreak
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   133
in.\allowbreak tum.\allowbreak de}}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   134
\newcommand\authoremailiii{\texttt{tray{\color{white}nospam}\kern-\wd\boxA{}tel@\allowbreak
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   135
in.\allowbreak tum.\allowbreak de}}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   136
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   137
\noindent
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   138
Comments and bug reports concerning either
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   139
the tool or the manual should be directed to the authors at
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   140
\authoremaili, \authoremailii, and \authoremailiii.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   141
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   142
\begin{framed}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   143
\noindent
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   144
\textbf{Warning:} This document is under heavy construction. Please apologise
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   145
for its appearance and come back in a few months.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   146
\end{framed}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   147
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   148
*}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   149
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   150
section {* Defining Datatypes%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   151
  \label{sec:defining-datatypes} *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   152
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   153
text {*
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   154
This section describes how to specify datatypes using the @{command datatype_new}
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   155
command. The command is first illustrated through concrete examples featuring
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   156
different flavors of recursion. More examples can be found in the directory
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   157
\verb|~~/src/HOL/BNF/Examples|.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   158
*}
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   159
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   160
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   161
subsection {* Introductory Examples *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   162
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   163
subsubsection {* Nonrecursive Types *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   164
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   165
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   166
enumeration type:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   167
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   168
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   169
    datatype_new trool = Truue | Faalse | Maaybe
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   170
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   171
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   172
Haskell-style option type:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   173
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   174
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   175
    datatype_new 'a maybe = Nothing | Just 'a
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   176
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   177
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   178
triple:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   179
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   180
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   181
    datatype_new ('a, 'b, 'c) triple = Triple 'a 'b 'c
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   182
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   183
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   184
subsubsection {* Simple Recursion *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   185
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   186
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   187
simplest recursive type: natural numbers
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   188
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   189
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   190
    datatype_new nat = Zero | Suc nat
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   191
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   192
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   193
lists were shown in the introduction
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   194
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   195
terminated lists are a variant:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   196
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   197
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   198
    datatype_new ('a, 'b) tlist = TNil 'b | TCons 'a "('a, 'b) tlist"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   199
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   200
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   201
On the right-hand side of the equal sign, the usual Isabelle conventions apply:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   202
Nonatomic types must be enclosed in double quotes.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   203
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   204
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   205
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   206
subsubsection {* Mutual Recursion *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   207
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   208
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   209
Mutual recursion = Define several types simultaneously, referring to each other.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   210
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   211
Simple example: distinction between even and odd natural numbers:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   212
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   213
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   214
    datatype_new even_nat = Zero | Even_Suc odd_nat
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   215
    and odd_nat = Odd_Suc even_nat
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   216
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   217
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   218
More complex, and more realistic, example:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   219
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   220
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   221
    datatype_new ('a, 'b) expr =
52806
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   222
      Term "('a, 'b) trm" | Sum "('a, 'b) trm" "('a, 'b) expr"
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   223
    and ('a, 'b) trm =
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   224
      Factor "('a, 'b) factor" | Prod "('a, 'b) factor" "('a, 'b) trm"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   225
    and ('a, 'b) factor =
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   226
      Const 'a | Var 'b | Sub_Expr "('a, 'b) expr"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   227
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   228
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   229
subsubsection {* Nested Recursion *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   230
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   231
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   232
Nested recursion = Have recursion through a type constructor.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   233
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   234
The introduction showed some examples of trees with nesting through lists.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   235
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   236
More complex example, which reuses our maybe and triple types:
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   237
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   238
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   239
    datatype_new 'a triple_tree =
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   240
      Triple_Tree "('a triple_tree maybe, bool, 'a triple_tree maybe) triple"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   241
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   242
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   243
Recursion may not be arbitrary; e.g. impossible to define
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   244
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   245
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   246
(*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   247
    datatype_new 'a foo = Foo (*<*) datatype_new 'a bar = Bar  "'a foo \<Rightarrow> 'a foo"
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   248
*)
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   249
52806
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   250
    datatype_new 'a evil = Evil (*<*)'a
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   251
    typ (*>*)"'a evil \<Rightarrow> 'a evil"
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   252
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   253
text {*
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   254
Issue: => allows recursion only on its right-hand side.
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   255
This issue is inherited by polymorphic datatypes (and codatatypes)
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   256
defined in terms of =>.
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   257
In general, type constructors "('a1, ..., 'an) k" allow recursion on a subset
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   258
of their type arguments.
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   259
*}
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   260
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   261
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   262
subsubsection {* Auxiliary Constants and Syntaxes *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   263
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   264
text {*
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   265
The @{command datatype_new} command introduces various constants in addition to the
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   266
constructors. Given a type @{text "('a1,\<dots>,'aM) t"} with constructors
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   267
@{text t.C1}, \ldots, @{text t.C}$\!M,$ the following auxiliary constants are
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   268
introduced (among others):
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   269
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   270
\begin{itemize}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   271
\setlength{\itemsep}{0pt}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   272
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   273
\item \emph{Set functions} (\emph{natural transformations}): @{text t_set1},
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   274
\ldots, @{text t_set}$M$
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   275
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   276
\item \emph{Map function} (\emph{functorial action}): @{text t_map}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   277
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   278
\item \emph{Relator}: @{text t_rel}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   279
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   280
\item \emph{Iterator}: @{text t_fold}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   281
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   282
\item \emph{Recursor}: @{text t_rec}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   283
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   284
\item \emph{Discriminators}: @{text t.is_C1}, \ldots, @{text t.is_C}$\!M$
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   285
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   286
\item \emph{Selectors}:
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   287
@{text t.un_C11}, \ldots, @{text t.un_C1}$k_1$, \ldots,
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   288
@{text t.un_C}$\!M$@{text 1}, \ldots, @{text t.un_C}$\!Mk_M$
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   289
\end{itemize}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   290
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   291
The discriminators and selectors are collectively called \emph{destructors}.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   292
The @{text "t."} prefix is optional.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   293
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   294
The set functions, map function, relator, discriminators, and selectors can be
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   295
given custom names, as in the example below:
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   296
*}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   297
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   298
(*<*)hide_const Nil Cons hd tl(*>*)
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   299
    datatype_new (set: 'a) list (map: map rel: list_all2) =
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   300
      null: Nil (defaults tl: Nil)
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   301
    | Cons (hd: 'a) (tl: "'a list")
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   302
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   303
text {*
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   304
\noindent
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   305
The command introduces a discriminator @{const null} and a pair of selectors
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   306
@{const hd} and @{const tl} characterized as follows:
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   307
%
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   308
\[@{thm list.collapse(1)[of xs, no_vars]}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   309
  \qquad @{thm list.collapse(2)[of xs, no_vars]}\]
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   310
%
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   311
For two-constructor datatypes, a single discriminator constant suffices. The
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   312
discriminator associated with @{const Cons} is simply @{text "\<not> null"}.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   313
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   314
The \keyw{defaults} keyword following the @{const Nil} constructor specifies a
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   315
default value for selectors associated with other constructors. Here, it is
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   316
used to specify that the tail of the empty list is the empty list (instead of
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   317
being unspecified).
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   318
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   319
Because @{const Nil} is a nullary constructor, it is also possible to use @{text
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   320
"= Nil"} as a discriminator. This is specified by specifying @{text "="} instead
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   321
of the identifier @{const null} in the declaration above. Although this may look
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   322
appealing, the mixture of constructors and selectors in the resulting
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   323
characteristic theorems can lead Isabelle's automation to switch between the
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   324
constructor and the destructor view in surprising ways.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   325
*}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   326
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   327
text {*
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   328
The usual mixfix syntaxes are available for both types and constructors. For example:
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   329
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   330
%%% FIXME: remove trailing underscore and use locale trick instead once this is
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   331
%%% supported.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   332
*}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   333
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   334
    datatype_new ('a, 'b) prod (infixr "*" 20) =
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   335
      Pair 'a 'b
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   336
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   337
    datatype_new (set_: 'a) list_ =
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   338
      null: Nil ("[]")
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   339
    | Cons (hd: 'a) (tl: "'a list_") (infixr "#" 65)
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   340
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   341
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   342
subsection {* General Syntax *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   343
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   344
text {*
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   345
Datatype definitions have the following general syntax:
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   346
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   347
@{rail "
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   348
  @@{command datatype_new} ('(' (@{syntax dt_option} + ',') ')')? \\
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   349
    (@{syntax dt_name} '=' (@{syntax ctor} + '|') + @'and')
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   350
"}
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   351
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   352
Two options are supported:
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   353
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   354
@{rail "
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   355
  @{syntax_def dt_option}: @'no_dests' | @'rep_compat'
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   356
"}
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   357
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   358
\begin{itemize}
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   359
\setlength{\itemsep}{0pt}
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   360
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   361
\item
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   362
The \keyw{no\_dests} option indicates that no destructors (i.e.,
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   363
discriminators and selectors) should be generated.
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   364
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   365
\item
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   366
The \keyw{rep\_compat} option indicates that the names generated by the
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   367
package should contain optional (and normally not displayed) @{text "new."}
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   368
components to prevent clashes with a later call to @{command rep_datatype}. See
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   369
Section~\ref{ssec:datatype-compatibility-issues} for details.
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   370
\end{itemize}
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   371
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   372
Left-hand sides specify the name of the type to define, its type parameters,
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   373
and more:
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   374
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   375
@{rail "
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   376
  @{syntax_def dt_name}: @{syntax type_params}? @{syntax name} \\
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   377
    @{syntax map_rel}? @{syntax mixfix}?
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   378
  ;
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   379
  @{syntax_def type_params}: @{syntax typefree} | '(' ((@{syntax name} ':')? @{syntax typefree} + ',') ')'
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   380
  ;
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   381
  @{syntax_def map_rel}: '(' ((('map' | 'rel') ':' @{syntax name}) +) ')'
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   382
"}
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   383
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   384
@{syntax name} specifies the type name ...
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   385
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   386
@{syntax typefree} is type variable ('a, 'b, \ldots)
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   387
The names are for the set functions.
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   388
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   389
Additional constraint: All mutually recursive datatypes defined together must
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   390
specify the same type variables in the same order.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   391
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   392
@{syntax mixfix} is the usual parenthesized mixfix notation, documented in the
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   393
Isar reference manual \cite{isabelle-isar-ref}.
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   394
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   395
@{rail "
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   396
  @{syntax_def ctor}: (@{syntax name} ':')? @{syntax name} (@{syntax ctor_arg} *) \\
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   397
    @{syntax sel_defaults}? @{syntax mixfix}?
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   398
"}
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   399
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   400
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   401
First, optional name: discriminator. Second, mandatory name: name of
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   402
constructor. Default names for discriminators are generated.
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   403
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   404
@{rail "
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   405
  @{syntax_def ctor_arg}: @{syntax type} | '(' (@{syntax name} ':')? @{syntax type} ')'
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   406
  ;
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   407
  @{syntax_def sel_defaults}: '(' @'defaults' (@{syntax name} ':' @{syntax term} *) ')'
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   408
"}
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   409
*}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   410
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   411
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   412
subsection {* Characteristic Theorems *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   413
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   414
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   415
subsection {* Compatibility Issues%
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   416
  \label{ssec:datatype-compatibility-issues} *}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   417
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   418
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   419
section {* Defining Recursive Functions%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   420
  \label{sec:defining-recursive-functions} *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   421
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   422
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   423
This describes how to specify recursive functions over datatypes
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   424
specified using @{command datatype_new}. The focus in on the \keyw{primrec\_new}
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   425
command, which supports primitive recursion. A few examples feature the
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   426
@{command fun} and @{command function} commands, described in a separate
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   427
tutorial \cite{isabelle-function}.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   428
%%% TODO: partial_function?
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   429
*}
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   430
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   431
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   432
subsection {* Introductory Examples *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   433
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   434
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   435
More examples in \verb|~~/src/HOL/BNF/Examples|.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   436
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   437
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   438
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   439
subsection {* General Syntax *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   440
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   441
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   442
subsection {* Characteristic Theorems *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   443
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   444
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   445
subsection {* Compatibility Issues *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   446
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   447
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   448
section {* Defining Codatatypes%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   449
  \label{sec:defining-codatatypes} *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   450
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   451
text {*
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   452
This section describes how to specify codatatypes using the @{command codatatype}
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   453
command.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   454
*}
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   455
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   456
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   457
subsection {* Introductory Examples *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   458
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   459
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   460
More examples in \verb|~~/src/HOL/BNF/Examples|.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   461
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   462
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   463
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   464
subsection {* General Syntax *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   465
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   466
text {*
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   467
\keyw{no\_dests} is not available.
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   468
*}
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   469
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   470
subsection {* Characteristic Theorems *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   471
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   472
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   473
section {* Defining Corecursive Functions%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   474
  \label{sec:defining-corecursive-functions} *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   475
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   476
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   477
This section describes how to specify corecursive functions using the
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   478
\keyw{primcorec} command.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   479
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   480
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   481
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   482
subsection {* Introductory Examples *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   483
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   484
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   485
More examples in \verb|~~/src/HOL/BNF/Examples|.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   486
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   487
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   488
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   489
subsection {* General Syntax *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   490
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   491
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   492
subsection {* Characteristic Theorems *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   493
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   494
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   495
section {* Registering Bounded Natural Functors%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   496
  \label{sec:registering-bounded-natural-functors} *}
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   497
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   498
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   499
This section explains how to set up the (co)datatype package to allow nested
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   500
recursion through custom well-behaved type constructors. The key concept is that
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   501
of a bounded natural functor (BNF).
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   502
*}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   503
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   504
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   505
subsection {* Introductory Example *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   506
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   507
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   508
More examples in \verb|~~/src/HOL/BNF/Basic_BNFs.thy| and
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   509
\verb|~~/src/HOL/BNF/More_BNFs.thy|.
52806
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   510
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   511
Mention distinction between live and dead type arguments;
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   512
mention =>.
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   513
*}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   514
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   515
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   516
subsection {* General Syntax *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   517
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   518
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   519
section {* Generating Free Constructor Theorems%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   520
  \label{sec:generating-free-constructor-theorems} *}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   521
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   522
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   523
This section explains how to derive convenience theorems for free constructors,
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   524
as performed internally by @{command datatype_new} and @{command codatatype}.
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   525
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   526
  * need for this is rare but may arise if you want e.g. to add destructors to
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   527
    a type not introduced by ...
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   528
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   529
  * also useful for compatibility with old package, e.g. add destructors to
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   530
    old @{command datatype}
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   531
*}
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   532
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   533
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   534
subsection {* Introductory Example *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   535
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   536
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   537
subsection {* General Syntax *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   538
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   539
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   540
section {* Standard ML Interface%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   541
  \label{sec:standard-ml-interface} *}
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   542
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   543
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   544
This section describes the package's programmatic interface.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   545
*}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   546
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   547
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   548
section {* Interoperability%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   549
  \label{sec:interoperability} *}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   550
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   551
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   552
This section is concerned with the packages' interaction with other Isabelle
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   553
packages and tools, such as the code generator and the counterexample
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   554
generators.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   555
*}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   556
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   557
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   558
subsection {* Transfer and Lifting *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   559
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   560
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   561
subsection {* Code Generator *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   562
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   563
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   564
subsection {* Quickcheck *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   565
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   566
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   567
subsection {* Nitpick *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   568
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   569
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   570
subsection {* Nominal Isabelle *}
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   571
52805
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   572
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   573
section {* Known Bugs and Limitations%
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   574
  \label{sec:known-bugs-and-limitations} *}
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   575
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   576
text {*
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   577
This section lists known open issues of the package.
7f2f42046361 more (co)datatype documentation
blanchet
parents: 52795
diff changeset
   578
*}
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   579
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   580
text {*
52806
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   581
* primrec\_new and primcorec are vaporware
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   582
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   583
* slow n-ary mutual (co)datatype, avoid as much as possible (e.g. using nesting)
52806
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   584
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   585
* issues with HOL-Proofs?
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   586
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   587
* partial documentation
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   588
146ce45c3619 more work on (co)datatype docs
blanchet
parents: 52805
diff changeset
   589
* too much output by commands like "datatype_new" and "codatatype"
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   590
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   591
* no direct way to define recursive functions for default values -- but show trick
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   592
  based on overloading
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   593
*}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   594
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   595
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   596
section {* Acknowledgments%
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   597
  \label{sec:acknowledgments} *}
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   598
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   599
text {*
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   600
  * same people as usual
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   601
    * Tobias Nipkow
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   602
    * Makarius Wenzel
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   603
    * Andreas Lochbihler
52822
ae938ac9a721 more (co)datatype docs
blanchet
parents: 52806
diff changeset
   604
    * Brian Huffman
52824
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   605
  * also:
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   606
    * Stefan Milius
b7a83845bc93 more (co)datatype documentation
blanchet
parents: 52822
diff changeset
   607
    * Lutz Schr\"oder
52794
aae782070611 more (co)datatype documentation
blanchet
parents: 52792
diff changeset
   608
*}
52792
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   609
3e651be14fcd sketched documentation for new (co)datatype package
blanchet
parents:
diff changeset
   610
end