doc-src/TutorialI/Datatype/Nested.thy
changeset 11458 09a6c44a48ea
parent 11310 51e70b7bc315
child 12334 60bf75e157e4
equal deleted inserted replaced
11457:279da0358aa9 11458:09a6c44a48ea
     1 (*<*)
     1 (*<*)
     2 theory Nested = ABexpr:
     2 theory Nested = ABexpr:
     3 (*>*)
     3 (*>*)
     4 
     4 
     5 text{*
     5 text{*
       
     6 \index{datatypes!and nested recursion}%
     6 So far, all datatypes had the property that on the right-hand side of their
     7 So far, all datatypes had the property that on the right-hand side of their
     7 definition they occurred only at the top-level, i.e.\ directly below a
     8 definition they occurred only at the top-level: directly below a
     8 constructor. Now we consider \emph{nested recursion}, where the recursive
     9 constructor. Now we consider \emph{nested recursion}, where the recursive
     9 datatype occurs nested in some other datatype (but not inside itself!).
    10 datatype occurs nested in some other datatype (but not inside itself!).
    10 Consider the following model of terms
    11 Consider the following model of terms
    11 where function symbols can be applied to a list of arguments:
    12 where function symbols can be applied to a list of arguments:
    12 *}
    13 *}
    53 
    54 
    54   "substs s [] = []"
    55   "substs s [] = []"
    55   "substs s (t # ts) = subst s t # substs s ts";
    56   "substs s (t # ts) = subst s t # substs s ts";
    56 
    57 
    57 text{*\noindent
    58 text{*\noindent
    58 Individual equations in a primrec definition may be named as shown for @{thm[source]subst_App}.
    59 Individual equations in a \commdx{primrec} definition may be
       
    60 named as shown for @{thm[source]subst_App}.
    59 The significance of this device will become apparent below.
    61 The significance of this device will become apparent below.
    60 
    62 
    61 Similarly, when proving a statement about terms inductively, we need
    63 Similarly, when proving a statement about terms inductively, we need
    62 to prove a related statement about term lists simultaneously. For example,
    64 to prove a related statement about term lists simultaneously. For example,
    63 the fact that the identity substitution does not change a term needs to be
    65 the fact that the identity substitution does not change a term needs to be