src/Doc/Datatypes/Datatypes.thy
changeset 70818 13d6b561b0ea
parent 70078 3a1b2d8c89aa
child 70820 77c8b8e73f88
equal deleted inserted replaced
70817:dd675800469d 70818:13d6b561b0ea
  1225 section \<open>Defining Primitively Recursive Functions
  1225 section \<open>Defining Primitively Recursive Functions
  1226   \label{sec:defining-primitively-recursive-functions}\<close>
  1226   \label{sec:defining-primitively-recursive-functions}\<close>
  1227 
  1227 
  1228 text \<open>
  1228 text \<open>
  1229 Recursive functions over datatypes can be specified using the @{command primrec}
  1229 Recursive functions over datatypes can be specified using the @{command primrec}
  1230 command, which supports primitive recursion, or using the more general
  1230 command, which supports primitive recursion, or using the \keyw{fun},
  1231 \keyw{fun}, \keyw{function}, and \keyw{partial_function} commands. In this
  1231 \keyw{function}, and \keyw{partial_function} commands. In this tutorial, the
  1232 tutorial, the focus is on @{command primrec}; \keyw{fun} and \keyw{function} are
  1232 focus is on @{command primrec}; \keyw{fun} and \keyw{function} are described in
  1233 described in a separate tutorial @{cite "isabelle-function"}.
  1233 a separate tutorial @{cite "isabelle-function"}.
       
  1234 
       
  1235 Because it is restricted to primitive recursion, @{command primrec} is less
       
  1236 powerful than \keyw{fun} and \keyw{function}. However, there are primitively
       
  1237 recursive specifications (e.g., based on infinitely branching or mutually
       
  1238 recursive datatypes) for which \keyw{fun}'s termination check fails. It is also
       
  1239 good style to use the simpler @{command primrec} mechanism when it works, both
       
  1240 as an optimization and as documentation.
  1234 \<close>
  1241 \<close>
  1235 
  1242 
  1236 
  1243 
  1237 subsection \<open>Introductory Examples
  1244 subsection \<open>Introductory Examples
  1238   \label{ssec:primrec-introductory-examples}\<close>
  1245   \label{ssec:primrec-introductory-examples}\<close>