equal
deleted
inserted
replaced
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 |