src/HOL/Induct/Tree.thy
author wenzelm
Tue Nov 13 22:18:03 2001 +0100 (2001-11-13)
changeset 12171 dc87f33db447
parent 11649 dfb59b9954a6
child 14981 e73f8140af78
permissions -rw-r--r--
tuned inductions;
     1 (*  Title:      HOL/Induct/Tree.thy
     2     ID:         $Id$
     3     Author:     Stefan Berghofer,  TU Muenchen
     4     License:    GPL (GNU GENERAL PUBLIC LICENSE)
     5 *)
     6 
     7 header {* Infinitely branching trees *}
     8 
     9 theory Tree = Main:
    10 
    11 datatype 'a tree =
    12     Atom 'a
    13   | Branch "nat => 'a tree"
    14 
    15 consts
    16   map_tree :: "('a => 'b) => 'a tree => 'b tree"
    17 primrec
    18   "map_tree f (Atom a) = Atom (f a)"
    19   "map_tree f (Branch ts) = Branch (\<lambda>x. map_tree f (ts x))"
    20 
    21 lemma tree_map_compose: "map_tree g (map_tree f t) = map_tree (g \<circ> f) t"
    22   by (induct t) simp_all
    23 
    24 consts
    25   exists_tree :: "('a => bool) => 'a tree => bool"
    26 primrec
    27   "exists_tree P (Atom a) = P a"
    28   "exists_tree P (Branch ts) = (\<exists>x. exists_tree P (ts x))"
    29 
    30 lemma exists_map:
    31   "(!!x. P x ==> Q (f x)) ==>
    32     exists_tree P ts ==> exists_tree Q (map_tree f ts)"
    33   by (induct ts) auto
    34 
    35 end