src/ZF/ex/tf.ML
changeset 56 2caa6f49f06e
parent 0 a5a9c433f639
child 71 729fe026c5f3
equal deleted inserted replaced
55:331d93292ee0 56:2caa6f49f06e
    20 	  ["[| a:A;  tf: forest(A) |] ==> Tcons(a,tf) : tree(A)",
    20 	  ["[| a:A;  tf: forest(A) |] ==> Tcons(a,tf) : tree(A)",
    21 	   "Fnil : forest(A)",
    21 	   "Fnil : forest(A)",
    22 	   "[| t: tree(A);  tf: forest(A) |] ==> Fcons(t,tf) : forest(A)"];
    22 	   "[| t: tree(A);  tf: forest(A) |] ==> Fcons(t,tf) : forest(A)"];
    23   val monos = [];
    23   val monos = [];
    24   val type_intrs = data_typechecks
    24   val type_intrs = data_typechecks
    25   val type_elims = []);
    25   val type_elims = data_elims);
    26 
    26 
    27 val [TconsI, FnilI, FconsI] = TF.intrs;
    27 val [TconsI, FnilI, FconsI] = TF.intrs;
    28 
    28 
    29 (** tree_forest(A) as the union of tree(A) and forest(A) **)
    29 (** tree_forest(A) as the union of tree(A) and forest(A) **)
    30 
    30 
    40 by (rtac (TF.dom_subset RS Part_sum_equality) 1);
    40 by (rtac (TF.dom_subset RS Part_sum_equality) 1);
    41 val TF_equals_Un = result();
    41 val TF_equals_Un = result();
    42 
    42 
    43 (** NOT useful, but interesting... **)
    43 (** NOT useful, but interesting... **)
    44 
    44 
       
    45 (*The (refl RS conjI RS exI RS exI) avoids considerable search!*)
       
    46 val unfold_cs = sum_cs addSIs [PartI, refl RS conjI RS exI RS exI]
       
    47                     addIs data_typechecks
       
    48                     addDs [TF.dom_subset RS subsetD]
       
    49 	            addSEs ([PartE] @ data_elims @ TF.free_SEs);
       
    50 
    45 goalw TF.thy (tl TF.defs) "tree(A) = {Inl(x). x: A*forest(A)}";
    51 goalw TF.thy (tl TF.defs) "tree(A) = {Inl(x). x: A*forest(A)}";
    46 by (res_inst_tac [("P", "%x.?t(x) = ?u::i")] (TF.unfold RS ssubst) 1);
    52 by (res_inst_tac [("P", "%x.?t(x) = ?u::i")] (TF.unfold RS ssubst) 1);
    47 by (rewrite_goals_tac TF.con_defs);
    53 by (rewrite_goals_tac TF.con_defs);
    48 by (rtac equalityI 1);
    54 by (rtac equalityI 1);
    49 by (fast_tac (ZF_cs addIs [PartI] addSEs (PartE::TF.free_SEs)) 1);
    55 by (fast_tac unfold_cs 1);
    50 by (fast_tac (ZF_cs addIs ([PartI,InlI,InrI] @ [TF.dom_subset RS subsetD]
    56 by (fast_tac unfold_cs 1);
    51 			   @ data_typechecks)
       
    52 	            addSEs (PartE::TF.free_SEs)) 1);
       
    53 val tree_unfold = result();
    57 val tree_unfold = result();
    54 
    58 
    55 goalw TF.thy (tl TF.defs) "forest(A) = {Inr(x). x: {0} + tree(A)*forest(A)}";
    59 goalw TF.thy (tl TF.defs) "forest(A) = {Inr(x). x: {0} + tree(A)*forest(A)}";
    56 by (res_inst_tac [("P", "%x.?t(x) = ?u::i")] (TF.unfold RS ssubst) 1);
    60 by (res_inst_tac [("P", "%x.?t(x) = ?u::i")] (TF.unfold RS ssubst) 1);
    57 by (rewrite_goals_tac TF.con_defs);
    61 by (rewrite_goals_tac TF.con_defs);
    58 by (rtac equalityI 1);
    62 by (rtac equalityI 1);
    59 by (fast_tac (ZF_cs addIs [PartI,InlI,InrI] 
    63 by (fast_tac unfold_cs 1);
    60                     addSEs (PartE::TF.free_SEs)) 1);
    64 by (fast_tac unfold_cs 1);
    61 by (fast_tac (ZF_cs addIs ([PartI,InlI,InrI] @ [TF.dom_subset RS subsetD]
       
    62 			   @ data_typechecks)
       
    63 	            addSEs ([PartE, sumE] @ TF.free_SEs)) 1);
       
    64 val forest_unfold = result();
    65 val forest_unfold = result();
    65 
    66