src/Doc/Datatypes/Datatypes.thy
changeset 60135 852f7a49ec0c
parent 60134 e8472fc02fe5
child 60136 4e1ba085be4a
equal deleted inserted replaced
60134:e8472fc02fe5 60135:852f7a49ec0c
   602     ML {* Old_Datatype_Data.get_info @{theory} @{type_name even_nat} *}
   602     ML {* Old_Datatype_Data.get_info @{theory} @{type_name even_nat} *}
   603 
   603 
   604 text {*
   604 text {*
   605 The syntactic entity \synt{name} denotes an identifier @{cite "isabelle-isar-ref"}.
   605 The syntactic entity \synt{name} denotes an identifier @{cite "isabelle-isar-ref"}.
   606 
   606 
   607 The command can be useful because the old datatype package provides some
   607 The command is sometimes useful when migrating from the old datatype package to
   608 functionality that is not yet replicated in the new package.
   608 the new one.
   609 
   609 
   610 A few remarks concern nested recursive datatypes:
   610 A few remarks concern nested recursive datatypes:
   611 
   611 
   612 \begin{itemize}
   612 \begin{itemize}
   613 \setlength{\itemsep}{0pt}
   613 \setlength{\itemsep}{0pt}
  1086 \begin{itemize}
  1086 \begin{itemize}
  1087 \setlength{\itemsep}{0pt}
  1087 \setlength{\itemsep}{0pt}
  1088 
  1088 
  1089 \item \emph{The Standard ML interfaces are different.} Tools and extensions
  1089 \item \emph{The Standard ML interfaces are different.} Tools and extensions
  1090 written to call the old ML interfaces will need to be adapted to the new
  1090 written to call the old ML interfaces will need to be adapted to the new
  1091 interfaces. If possible, it is recommended to register new-style datatypes as
  1091 interfaces. The @{text BNF_LFP_Compat} structure provides convenience functions
  1092 old-style datatypes using the @{command datatype_compat} command.
  1092 that simulate the old interfaces in terms of the new ones.
  1093 
  1093 
  1094 \item \emph{The recursor @{text rec_t} has a different signature for nested
  1094 \item \emph{The recursor @{text rec_t} has a different signature for nested
  1095 recursive datatypes.} In the old package, nested recursion through non-functions
  1095 recursive datatypes.} In the old package, nested recursion through non-functions
  1096 was internally reduced to mutual recursion. This reduction was visible in the
  1096 was internally reduced to mutual recursion. This reduction was visible in the
  1097 type of the recursor, used by \keyw{primrec}. Recursion through functions was
  1097 type of the recursor, used by \keyw{primrec}. Recursion through functions was
  1254 %
  1254 %
  1255 \[@{thm at_simps(1)[no_vars]}
  1255 \[@{thm at_simps(1)[no_vars]}
  1256   \qquad @{thm at_simps(2)[no_vars]}\]
  1256   \qquad @{thm at_simps(2)[no_vars]}\]
  1257 %
  1257 %
  1258 The next example is defined using \keyw{fun} to escape the syntactic
  1258 The next example is defined using \keyw{fun} to escape the syntactic
  1259 restrictions imposed on primitively recursive functions. The
  1259 restrictions imposed on primitively recursive functions:
  1260 @{command datatype_compat} command is needed to register new-style datatypes
  1260 *}
  1261 for use with \keyw{fun} and \keyw{function}
       
  1262 (Section~\ref{sssec:datatype-compat}):
       
  1263 *}
       
  1264 
       
  1265     datatype_compat nat
       
  1266 
       
  1267 text {* \blankline *}
       
  1268 
  1261 
  1269     fun at_least_two :: "nat \<Rightarrow> bool" where
  1262     fun at_least_two :: "nat \<Rightarrow> bool" where
  1270       "at_least_two (Succ (Succ _)) \<longleftrightarrow> True" |
  1263       "at_least_two (Succ (Succ _)) \<longleftrightarrow> True" |
  1271       "at_least_two _ \<longleftrightarrow> False"
  1264       "at_least_two _ \<longleftrightarrow> False"
  1272 
  1265 
  3216 \emph{There is no way to register the same type as both a datatype and a
  3209 \emph{There is no way to register the same type as both a datatype and a
  3217 codatatype.} This affects types such as the extended natural numbers, for which
  3210 codatatype.} This affects types such as the extended natural numbers, for which
  3218 both views would make sense (for a different set of constructors).
  3211 both views would make sense (for a different set of constructors).
  3219 
  3212 
  3220 \item
  3213 \item
  3221 \emph{The \emph{\keyw{derive}} command from the \emph{Archive of Formal Proofs}
       
  3222 has not yet been fully ported to the new-style datatypes.} Specimens featuring
       
  3223 nested recursion require the use of @{command datatype_compat}
       
  3224 (Section~\ref{sssec:datatype-compat}).
       
  3225 
       
  3226 \item
       
  3227 \emph{The names of variables are often suboptimal in the properties generated by
  3214 \emph{The names of variables are often suboptimal in the properties generated by
  3228 the package.}
  3215 the package.}
  3229 
  3216 
  3230 \end{enumerate}
  3217 \end{enumerate}
  3231 *}
  3218 *}
  3239 versions of the package, especially on the coinductive part. Brian Huffman
  3226 versions of the package, especially on the coinductive part. Brian Huffman
  3240 suggested major simplifications to the internal constructions. Ond\v{r}ej
  3227 suggested major simplifications to the internal constructions. Ond\v{r}ej
  3241 Kun\v{c}ar implemented the @{text transfer} and @{text lifting} plugins.
  3228 Kun\v{c}ar implemented the @{text transfer} and @{text lifting} plugins.
  3242 Florian Haftmann and Christian Urban provided general advice on Isabelle and
  3229 Florian Haftmann and Christian Urban provided general advice on Isabelle and
  3243 package writing. Stefan Milius and Lutz Schr\"oder found an elegant proof that
  3230 package writing. Stefan Milius and Lutz Schr\"oder found an elegant proof that
  3244 eliminated one of the BNF proof obligations. Andreas Lochbihler, Tobias Nipkow,
  3231 eliminated one of the BNF proof obligations. Gerwin Klein, Andreas Lochbihler,
  3245 and Christian Sternagel suggested many textual improvements to this tutorial.
  3232 Tobias Nipkow, and Christian Sternagel suggested many textual improvements to
       
  3233 this tutorial.
  3246 *}
  3234 *}
  3247 
  3235 
  3248 end
  3236 end