doc-src/HOL/HOL.tex
changeset 27452 5c1fb7d262bf
parent 22921 475ff421a6a3
child 30686 47a32dd1b86e
equal deleted inserted replaced
27451:85d546d2ebe8 27452:5c1fb7d262bf
  2070 For foundational reasons, some basic types such as \texttt{nat}, \texttt{*}, {\tt
  2070 For foundational reasons, some basic types such as \texttt{nat}, \texttt{*}, {\tt
  2071   +}, \texttt{bool} and \texttt{unit} are not defined in a \texttt{datatype} section,
  2071   +}, \texttt{bool} and \texttt{unit} are not defined in a \texttt{datatype} section,
  2072 but by more primitive means using \texttt{typedef}. To be able to use the
  2072 but by more primitive means using \texttt{typedef}. To be able to use the
  2073 tactics \texttt{induct_tac} and \texttt{case_tac} and to define functions by
  2073 tactics \texttt{induct_tac} and \texttt{case_tac} and to define functions by
  2074 primitive recursion on these types, such types may be represented as actual
  2074 primitive recursion on these types, such types may be represented as actual
  2075 datatypes.  This is done by specifying an induction rule, as well as theorems
  2075 datatypes.  This is done by specifying the constructors of the desired type,
       
  2076 plus a proof of the  induction rule, as well as theorems
  2076 stating the distinctness and injectivity of constructors in a {\tt
  2077 stating the distinctness and injectivity of constructors in a {\tt
  2077   rep_datatype} section.  For type \texttt{nat} this works as follows:
  2078 rep_datatype} section.  For the sum type this works as follows:
  2078 \begin{ttbox}
  2079 \begin{ttbox}
  2079 rep_datatype nat
  2080 rep_datatype (sum) Inl Inr
  2080   distinct Suc_not_Zero, Zero_not_Suc
  2081 proof -
  2081   inject   Suc_Suc_eq
  2082   fix P
  2082   induct   nat_induct
  2083   fix s :: "'a + 'b"
       
  2084   assume x: "!!x::'a. P (Inl x)" and y: "!!y::'b. P (Inr y)"
       
  2085   then show "P s" by (auto intro: sumE [of s])
       
  2086 qed simp_all
  2083 \end{ttbox}
  2087 \end{ttbox}
  2084 The datatype package automatically derives additional theorems for recursion
  2088 The datatype package automatically derives additional theorems for recursion
  2085 and case combinators from these rules.  Any of the basic HOL types mentioned
  2089 and case combinators from these rules.  Any of the basic HOL types mentioned
  2086 above are represented as datatypes.  Try an induction on \texttt{bool}
  2090 above are represented as datatypes.  Try an induction on \texttt{bool}
  2087 today.
  2091 today.