doc-src/TutorialI/Datatype/Fundata.thy
changeset 27015 f8537d69f514
parent 16417 9bc16273c2d4
equal deleted inserted replaced
27014:a5f53d9d2b60 27015:f8537d69f514
    17 has merely @{term"Tip"}s as further subtrees.
    17 has merely @{term"Tip"}s as further subtrees.
    18 
    18 
    19 Function @{term"map_bt"} applies a function to all labels in a @{text"bigtree"}:
    19 Function @{term"map_bt"} applies a function to all labels in a @{text"bigtree"}:
    20 *}
    20 *}
    21 
    21 
    22 consts map_bt :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a,'i)bigtree \<Rightarrow> ('b,'i)bigtree"
    22 primrec map_bt :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a,'i)bigtree \<Rightarrow> ('b,'i)bigtree"
    23 primrec
    23 where
    24 "map_bt f Tip      = Tip"
    24 "map_bt f Tip      = Tip" |
    25 "map_bt f (Br a F) = Br (f a) (\<lambda>i. map_bt f (F i))"
    25 "map_bt f (Br a F) = Br (f a) (\<lambda>i. map_bt f (F i))"
    26 
    26 
    27 text{*\noindent This is a valid \isacommand{primrec} definition because the
    27 text{*\noindent This is a valid \isacommand{primrec} definition because the
    28 recursive calls of @{term"map_bt"} involve only subtrees of
    28 recursive calls of @{term"map_bt"} involve only subtrees of
    29 @{term"F"}, which is itself a subterm of the left-hand side. Thus termination
    29 @{term"F"}, which is itself a subterm of the left-hand side. Thus termination