src/Doc/Datatypes/Datatypes.thy
changeset 56644 efb39e0a89b0
parent 56124 315cc3c0a19a
child 56653 c1507d5f4665
equal deleted inserted replaced
56643:41d3596d8a64 56644:efb39e0a89b0
   568 @{text "\<sigma>\<^sub>1 \<Rightarrow> \<dots> \<Rightarrow> \<sigma>\<^sub>p \<Rightarrow> \<tau>"}
   568 @{text "\<sigma>\<^sub>1 \<Rightarrow> \<dots> \<Rightarrow> \<sigma>\<^sub>p \<Rightarrow> \<tau>"}
   569 (i.e., it may depend on @{text C}'s arguments).
   569 (i.e., it may depend on @{text C}'s arguments).
   570 *}
   570 *}
   571 
   571 
   572 
   572 
   573 subsubsection {* \keyw{datatype\_new\_compat}
   573 subsubsection {* \keyw{datatype\_compat}
   574   \label{sssec:datatype-new-compat} *}
   574   \label{sssec:datatype-compat} *}
   575 
   575 
   576 text {*
   576 text {*
   577 \begin{matharray}{rcl}
   577 \begin{matharray}{rcl}
   578   @{command_def "datatype_compat"} & : & @{text "local_theory \<rightarrow> local_theory"}
   578   @{command_def "datatype_compat"} & : & @{text "local_theory \<rightarrow> local_theory"}
   579 \end{matharray}
   579 \end{matharray}
   588 The @{command datatype_compat} command registers new-style datatypes as
   588 The @{command datatype_compat} command registers new-style datatypes as
   589 old-style datatypes. For example:
   589 old-style datatypes. For example:
   590 *}
   590 *}
   591 
   591 
   592     datatype_compat even_nat odd_nat
   592     datatype_compat even_nat odd_nat
   593 
       
   594 text {* \blankline *}
       
   595 
       
   596     thm even_nat_odd_nat.size
       
   597 
   593 
   598 text {* \blankline *}
   594 text {* \blankline *}
   599 
   595 
   600     ML {* Datatype_Data.get_info @{theory} @{type_name even_nat} *}
   596     ML {* Datatype_Data.get_info @{theory} @{type_name even_nat} *}
   601 
   597 
   969 written to call the old ML interfaces will need to be adapted to the new
   965 written to call the old ML interfaces will need to be adapted to the new
   970 interfaces. Little has been done so far in this direction. Whenever possible, it
   966 interfaces. Little has been done so far in this direction. Whenever possible, it
   971 is recommended to use @{command datatype_compat} or \keyw{rep\_datatype}
   967 is recommended to use @{command datatype_compat} or \keyw{rep\_datatype}
   972 to register new-style datatypes as old-style datatypes.
   968 to register new-style datatypes as old-style datatypes.
   973 
   969 
   974 \item \emph{The constants @{text t_case} and @{text t_rec} are now called
   970 \item \emph{The constants @{text t_case}, @{text t_rec}, and @{text t_size} are
   975 @{text case_t} and @{text rec_t}.}
   971 now called @{text case_t}, @{text rec_t}, and @{text size_t}.}
   976 
   972 
   977 \item \emph{The recursor @{text rec_t} has a different signature for nested
   973 \item \emph{The recursor @{text rec_t} has a different signature for nested
   978 recursive datatypes.} In the old package, nested recursion through non-functions
   974 recursive datatypes.} In the old package, nested recursion through non-functions
   979 was internally reduced to mutual recursion. This reduction was visible in the
   975 was internally reduced to mutual recursion. This reduction was visible in the
   980 type of the recursor, used by \keyw{primrec}. Recursion through functions was
   976 type of the recursor, used by \keyw{primrec}. Recursion through functions was
   992 
   988 
   993 \item \emph{The internal constructions are completely different.} Proof texts
   989 \item \emph{The internal constructions are completely different.} Proof texts
   994 that unfold the definition of constants introduced by \keyw{datatype} will be
   990 that unfold the definition of constants introduced by \keyw{datatype} will be
   995 difficult to port.
   991 difficult to port.
   996 
   992 
   997 \item \emph{Some induction rules have different names.}
   993 \item \emph{Some theorems have different names.}
   998 For non-mutually recursive datatypes,
   994 For non-mutually recursive datatypes,
   999 the alias @{text t.inducts} for @{text t.induct} is no longer generated.
   995 the alias @{text t.inducts} for @{text t.induct} is no longer generated.
  1000 For $m > 1$ mutually recursive datatypes,
   996 For $m > 1$ mutually recursive datatypes,
  1001 @{text "t\<^sub>1_\<dots>_t\<^sub>m.inducts(i)"} has been renamed
   997 @{text "t\<^sub>1_\<dots>_t\<^sub>m.inducts(i)"} has been renamed
  1002 @{text "t\<^sub>i.induct"} for each @{text "i \<in> {1, \<dots>, t}"}.
   998 @{text "t\<^sub>i.induct"} for each @{text "i \<in> {1, \<dots>, t}"}, and similarly the
       
   999 collection @{text "t\<^sub>1_\<dots>_t\<^sub>m.size"} has been divided into @{text "t\<^sub>1.size"},
       
  1000 \ldots, @{text "t\<^sub>m.size"}.
  1003 
  1001 
  1004 \item \emph{The @{text t.simps} collection has been extended.}
  1002 \item \emph{The @{text t.simps} collection has been extended.}
  1005 Previously available theorems are available at the same index.
  1003 Previously available theorems are available at the same index.
  1006 
  1004 
  1007 \item \emph{Variables in generated properties have different names.} This is
  1005 \item \emph{Variables in generated properties have different names.} This is
  1127 %
  1125 %
  1128 The next example is defined using \keyw{fun} to escape the syntactic
  1126 The next example is defined using \keyw{fun} to escape the syntactic
  1129 restrictions imposed on primitively recursive functions. The
  1127 restrictions imposed on primitively recursive functions. The
  1130 @{command datatype_compat} command is needed to register new-style datatypes
  1128 @{command datatype_compat} command is needed to register new-style datatypes
  1131 for use with \keyw{fun} and \keyw{function}
  1129 for use with \keyw{fun} and \keyw{function}
  1132 (Section~\ref{sssec:datatype-new-compat}):
  1130 (Section~\ref{sssec:datatype-compat}):
  1133 *}
  1131 *}
  1134 
  1132 
  1135     datatype_compat nat
  1133     datatype_compat nat
  1136 
  1134 
  1137 text {* \blankline *}
  1135 text {* \blankline *}
  2694 text {*
  2692 text {*
  2695 Known open issues of the package.
  2693 Known open issues of the package.
  2696 *}
  2694 *}
  2697 
  2695 
  2698 text {*
  2696 text {*
  2699 %* primcorecursive and primcorec is unfinished
       
  2700 %
       
  2701 %* slow n-ary mutual (co)datatype, avoid as much as possible (e.g. using nesting)
  2697 %* slow n-ary mutual (co)datatype, avoid as much as possible (e.g. using nesting)
  2702 %
       
  2703 %* issues with HOL-Proofs?
       
  2704 %
  2698 %
  2705 %* partial documentation
  2699 %* partial documentation
  2706 %
  2700 %
  2707 %* no way to register "sum" and "prod" as (co)datatypes to enable N2M reduction for them
  2701 %* no way to register "sum" and "prod" as (co)datatypes to enable N2M reduction for them
  2708 %  (for @{command datatype_compat} and prim(co)rec)
  2702 %  (for @{command datatype_compat} and prim(co)rec)
  2712 %* no recursion through unused arguments (unlike with the old package)
  2706 %* no recursion through unused arguments (unlike with the old package)
  2713 %
  2707 %
  2714 %* in a locale, cannot use locally fixed types (because of limitation in typedef)?
  2708 %* in a locale, cannot use locally fixed types (because of limitation in typedef)?
  2715 %
  2709 %
  2716 % *names of variables suboptimal
  2710 % *names of variables suboptimal
       
  2711 %
       
  2712 % * in a locale, size is half broken
  2717 *}
  2713 *}
  2718 *)
  2714 *)
  2719 
  2715 
  2720 
  2716 
  2721 text {*
  2717 text {*