45 val unfold_cs = sum_cs addSIs [PartI, refl RS conjI RS exI RS exI] |
45 val unfold_cs = sum_cs addSIs [PartI, refl RS conjI RS exI RS exI] |
46 addIs datatype_intrs |
46 addIs datatype_intrs |
47 addDs [TF.dom_subset RS subsetD] |
47 addDs [TF.dom_subset RS subsetD] |
48 addSEs ([PartE] @ datatype_elims @ TF.free_SEs); |
48 addSEs ([PartE] @ datatype_elims @ TF.free_SEs); |
49 |
49 |
50 goalw TF.thy (tl TF.defs) "tree(A) = {Inl(x). x: A*forest(A)}"; |
50 goalw TF.thy (tl TF.defs) |
51 by (res_inst_tac [("P", "%x.?t(x) = ?u::i")] (TF.unfold RS ssubst) 1); |
51 "tree_forest(A) = (A*forest(A)) + ({0} + tree(A)*forest(A))"; |
|
52 by (rtac (TF.unfold RS trans) 1); |
52 by (rewrite_goals_tac TF.con_defs); |
53 by (rewrite_goals_tac TF.con_defs); |
53 by (rtac equalityI 1); |
54 by (rtac equalityI 1); |
54 by (fast_tac unfold_cs 1); |
55 by (fast_tac unfold_cs 1); |
55 by (fast_tac unfold_cs 1); |
56 by (fast_tac unfold_cs 1); |
|
57 val tree_forest_unfold = result(); |
|
58 |
|
59 val tree_forest_unfold' = rewrite_rule (tl TF.defs) tree_forest_unfold; |
|
60 |
|
61 |
|
62 goalw TF.thy (tl TF.defs) "tree(A) = {Inl(x). x: A*forest(A)}"; |
|
63 br (Part_Inl RS subst) 1; |
|
64 br (tree_forest_unfold' RS subst_context) 1; |
56 val tree_unfold = result(); |
65 val tree_unfold = result(); |
57 |
66 |
58 goalw TF.thy (tl TF.defs) "forest(A) = {Inr(x). x: {0} + tree(A)*forest(A)}"; |
67 goalw TF.thy (tl TF.defs) "forest(A) = {Inr(x). x: {0} + tree(A)*forest(A)}"; |
59 by (res_inst_tac [("P", "%x.?t(x) = ?u::i")] (TF.unfold RS ssubst) 1); |
68 br (Part_Inr RS subst) 1; |
60 by (rewrite_goals_tac TF.con_defs); |
69 br (tree_forest_unfold' RS subst_context) 1; |
61 by (rtac equalityI 1); |
|
62 by (fast_tac unfold_cs 1); |
|
63 by (fast_tac unfold_cs 1); |
|
64 val forest_unfold = result(); |
70 val forest_unfold = result(); |
65 |
71 |
|
72 |
|
73 |