src/Doc/Datatypes/Datatypes.thy
changeset 58737 b45405874f8f
parent 58735 919186869943
child 58739 cf78e16caa3a
equal deleted inserted replaced
58736:552ccec3f00f 58737:b45405874f8f
  1079 @{text "[unfolded all_mem_range]"} attribute on @{text t.induct}.
  1079 @{text "[unfolded all_mem_range]"} attribute on @{text t.induct}.
  1080 
  1080 
  1081 \item \emph{The @{const size} function has a slightly different definition.}
  1081 \item \emph{The @{const size} function has a slightly different definition.}
  1082 The new function returns @{text 1} instead of @{text 0} for some nonrecursive
  1082 The new function returns @{text 1} instead of @{text 0} for some nonrecursive
  1083 constructors. This departure from the old behavior made it possible to implement
  1083 constructors. This departure from the old behavior made it possible to implement
  1084 @{const size} in terms of the parameterized function @{text "t.size_t"}.
  1084 @{const size} in terms of the generic function @{text "t.size_t"}.
  1085 Moreover, the new function considers nested occurrences of a value, in the nested
  1085 Moreover, the new function considers nested occurrences of a value, in the nested
  1086 recursive case. The old behavior can be obtained by disabling the @{text size}
  1086 recursive case. The old behavior can be obtained by disabling the @{text size}
  1087 plugin (Section~\ref{sec:controlling-plugins}) and instantiating the
  1087 plugin (Section~\ref{sec:controlling-plugins}) and instantiating the
  1088 @{text size} type class manually.
  1088 @{text size} type class manually.
  1089 
  1089 
  2847 
  2847 
  2848 subsection {* Size
  2848 subsection {* Size
  2849   \label{ssec:size} *}
  2849   \label{ssec:size} *}
  2850 
  2850 
  2851 text {*
  2851 text {*
  2852 For each datatype, the \hthm{size} plugin generates a parameterized size
  2852 For each datatype, the \hthm{size} plugin generates a generic size
  2853 function @{text "t.size_t"} as well as a specific instance
  2853 function @{text "t.size_t"} as well as a specific instance
  2854 @{text "size \<Colon> t \<Rightarrow> bool"} belonging to the @{text size} type
  2854 @{text "size \<Colon> t \<Rightarrow> bool"} belonging to the @{text size} type
  2855 class. The \keyw{fun} command relies on @{const size} to prove termination of
  2855 class. The \keyw{fun} command relies on @{const size} to prove termination of
  2856 recursive functions on datatypes.
  2856 recursive functions on datatypes.
  2857 
  2857 
  2863 \item[@{text "t."}\hthm{size} @{text "[simp, code]"}\rm:] ~ \\
  2863 \item[@{text "t."}\hthm{size} @{text "[simp, code]"}\rm:] ~ \\
  2864 @{thm list.size(1)[no_vars]} \\
  2864 @{thm list.size(1)[no_vars]} \\
  2865 @{thm list.size(2)[no_vars]} \\
  2865 @{thm list.size(2)[no_vars]} \\
  2866 @{thm list.size(3)[no_vars]} \\
  2866 @{thm list.size(3)[no_vars]} \\
  2867 @{thm list.size(4)[no_vars]}
  2867 @{thm list.size(4)[no_vars]}
       
  2868 
       
  2869 \item[@{text "t."}\hthm{size_gen}\rm:] ~ \\
       
  2870 @{thm list.size_gen(1)[no_vars]} \\
       
  2871 @{thm list.size_gen(2)[no_vars]}
  2868 
  2872 
  2869 \item[@{text "t."}\hthm{size_o_map}\rm:] ~ \\
  2873 \item[@{text "t."}\hthm{size_o_map}\rm:] ~ \\
  2870 @{thm list.size_o_map[no_vars]}
  2874 @{thm list.size_o_map[no_vars]}
  2871 
  2875 
  2872 \end{description}
  2876 \end{description}