src/HOL/BNF/Examples/TreeFsetI.thy
author wenzelm
Mon, 11 Feb 2013 14:39:04 +0100
changeset 51085 d90218288d51
parent 50516 ed6b40d15d1c
child 51410 f0865a641e76
permissions -rw-r--r--
make WWW_Find work again, now that its ML modules reside within a theory context (cf. bf5b45870110) -- patch by Rafal Kolanski;

(*  Title:      HOL/BNF/Examples/TreeFsetI.thy
    Author:     Dmitriy Traytel, TU Muenchen
    Author:     Andrei Popescu, TU Muenchen
    Copyright   2012

Finitely branching possibly infinite trees, with sets of children.
*)

header {* Finitely Branching Possibly Infinite Trees, with Sets of Children *}

theory TreeFsetI
imports "../BNF"
begin

hide_fact (open) Quotient_Product.prod_rel_def

codata 'a treeFsetI = Tree (lab: 'a) (sub: "'a treeFsetI fset")

definition pair_fun (infixr "\<odot>" 50) where
  "f \<odot> g \<equiv> \<lambda>x. (f x, g x)"

(* tree map (contrived example): *)
definition tmap where
"tmap f = treeFsetI_unfold (f o lab) sub"

lemma tmap_simps[simp]:
"lab (tmap f t) = f (lab t)"
"sub (tmap f t) = map_fset (tmap f) (sub t)"
unfolding tmap_def treeFsetI.sel_unfold by simp+

lemma "tmap (f o g) x = tmap f (tmap g x)"
apply (rule treeFsetI.coinduct[of "%x1 x2. \<exists>x. x1 = tmap (f o g) x \<and> x2 = tmap f (tmap g x)"])
apply auto
apply (unfold fset_rel_def)
by auto

end