src/HOL/BNF/Tools/bnf_def.ML
changeset 51766 f19a4d0ab1bf
parent 51765 224b6eb2313a
child 51767 bbcdd8519253
equal deleted inserted replaced
51765:224b6eb2313a 51766:f19a4d0ab1bf
    43   val bd_Card_order_of_bnf: BNF -> thm
    43   val bd_Card_order_of_bnf: BNF -> thm
    44   val bd_Cinfinite_of_bnf: BNF -> thm
    44   val bd_Cinfinite_of_bnf: BNF -> thm
    45   val bd_Cnotzero_of_bnf: BNF -> thm
    45   val bd_Cnotzero_of_bnf: BNF -> thm
    46   val bd_card_order_of_bnf: BNF -> thm
    46   val bd_card_order_of_bnf: BNF -> thm
    47   val bd_cinfinite_of_bnf: BNF -> thm
    47   val bd_cinfinite_of_bnf: BNF -> thm
    48   val collect_set_natural_of_bnf: BNF -> thm
    48   val collect_set_map_of_bnf: BNF -> thm
    49   val in_bd_of_bnf: BNF -> thm
    49   val in_bd_of_bnf: BNF -> thm
    50   val in_cong_of_bnf: BNF -> thm
    50   val in_cong_of_bnf: BNF -> thm
    51   val in_mono_of_bnf: BNF -> thm
    51   val in_mono_of_bnf: BNF -> thm
    52   val in_srel_of_bnf: BNF -> thm
    52   val in_srel_of_bnf: BNF -> thm
    53   val map_comp'_of_bnf: BNF -> thm
    53   val map_comp'_of_bnf: BNF -> thm
    63   val rel_eq_of_bnf: BNF -> thm
    63   val rel_eq_of_bnf: BNF -> thm
    64   val rel_flip_of_bnf: BNF -> thm
    64   val rel_flip_of_bnf: BNF -> thm
    65   val rel_srel_of_bnf: BNF -> thm
    65   val rel_srel_of_bnf: BNF -> thm
    66   val set_bd_of_bnf: BNF -> thm list
    66   val set_bd_of_bnf: BNF -> thm list
    67   val set_defs_of_bnf: BNF -> thm list
    67   val set_defs_of_bnf: BNF -> thm list
    68   val set_natural'_of_bnf: BNF -> thm list
    68   val set_map'_of_bnf: BNF -> thm list
    69   val set_natural_of_bnf: BNF -> thm list
    69   val set_map_of_bnf: BNF -> thm list
    70   val srel_def_of_bnf: BNF -> thm
    70   val srel_def_of_bnf: BNF -> thm
    71   val srel_Gr_of_bnf: BNF -> thm
    71   val srel_Gr_of_bnf: BNF -> thm
    72   val srel_Id_of_bnf: BNF -> thm
    72   val srel_Id_of_bnf: BNF -> thm
    73   val srel_O_of_bnf: BNF -> thm
    73   val srel_O_of_bnf: BNF -> thm
    74   val srel_O_Gr_of_bnf: BNF -> thm
    74   val srel_O_Gr_of_bnf: BNF -> thm
   109 
   109 
   110 type axioms = {
   110 type axioms = {
   111   map_id: thm,
   111   map_id: thm,
   112   map_comp: thm,
   112   map_comp: thm,
   113   map_cong0: thm,
   113   map_cong0: thm,
   114   set_natural: thm list,
   114   set_map: thm list,
   115   bd_card_order: thm,
   115   bd_card_order: thm,
   116   bd_cinfinite: thm,
   116   bd_cinfinite: thm,
   117   set_bd: thm list,
   117   set_bd: thm list,
   118   in_bd: thm,
   118   in_bd: thm,
   119   map_wpull: thm,
   119   map_wpull: thm,
   120   srel_O_Gr: thm
   120   srel_O_Gr: thm
   121 };
   121 };
   122 
   122 
   123 fun mk_axioms' (((((((((id, comp), cong), nat), c_o), cinf), set_bd), in_bd), wpull), srel) =
   123 fun mk_axioms' (((((((((id, comp), cong), nat), c_o), cinf), set_bd), in_bd), wpull), srel) =
   124   {map_id = id, map_comp = comp, map_cong0 = cong, set_natural = nat, bd_card_order = c_o,
   124   {map_id = id, map_comp = comp, map_cong0 = cong, set_map = nat, bd_card_order = c_o,
   125    bd_cinfinite = cinf, set_bd = set_bd, in_bd = in_bd, map_wpull = wpull, srel_O_Gr = srel};
   125    bd_cinfinite = cinf, set_bd = set_bd, in_bd = in_bd, map_wpull = wpull, srel_O_Gr = srel};
   126 
   126 
   127 fun dest_cons [] = raise Empty
   127 fun dest_cons [] = raise Empty
   128   | dest_cons (x :: xs) = (x, xs);
   128   | dest_cons (x :: xs) = (x, xs);
   129 
   129 
   142   |> mk_axioms';
   142   |> mk_axioms';
   143 
   143 
   144 fun zip_axioms mid mcomp mcong snat bdco bdinf sbd inbd wpull srel =
   144 fun zip_axioms mid mcomp mcong snat bdco bdinf sbd inbd wpull srel =
   145   [mid, mcomp, mcong] @ snat @ [bdco, bdinf] @ sbd @ [inbd, wpull, srel];
   145   [mid, mcomp, mcong] @ snat @ [bdco, bdinf] @ sbd @ [inbd, wpull, srel];
   146 
   146 
   147 fun dest_axioms {map_id, map_comp, map_cong0, set_natural, bd_card_order, bd_cinfinite, set_bd,
   147 fun dest_axioms {map_id, map_comp, map_cong0, set_map, bd_card_order, bd_cinfinite, set_bd, in_bd,
   148   in_bd, map_wpull, srel_O_Gr} =
   148   map_wpull, srel_O_Gr} =
   149   zip_axioms map_id map_comp map_cong0 set_natural bd_card_order bd_cinfinite set_bd in_bd map_wpull
   149   zip_axioms map_id map_comp map_cong0 set_map bd_card_order bd_cinfinite set_bd in_bd map_wpull
   150     srel_O_Gr;
   150     srel_O_Gr;
   151 
   151 
   152 fun map_axioms f {map_id, map_comp, map_cong0, set_natural, bd_card_order, bd_cinfinite, set_bd,
   152 fun map_axioms f {map_id, map_comp, map_cong0, set_map, bd_card_order, bd_cinfinite, set_bd,
   153   in_bd, map_wpull, srel_O_Gr} =
   153   in_bd, map_wpull, srel_O_Gr} =
   154   {map_id = f map_id,
   154   {map_id = f map_id,
   155     map_comp = f map_comp,
   155     map_comp = f map_comp,
   156     map_cong0 = f map_cong0,
   156     map_cong0 = f map_cong0,
   157     set_natural = map f set_natural,
   157     set_map = map f set_map,
   158     bd_card_order = f bd_card_order,
   158     bd_card_order = f bd_card_order,
   159     bd_cinfinite = f bd_cinfinite,
   159     bd_cinfinite = f bd_cinfinite,
   160     set_bd = map f set_bd,
   160     set_bd = map f set_bd,
   161     in_bd = f in_bd,
   161     in_bd = f in_bd,
   162     map_wpull = f map_wpull,
   162     map_wpull = f map_wpull,
   180 
   180 
   181 type facts = {
   181 type facts = {
   182   bd_Card_order: thm,
   182   bd_Card_order: thm,
   183   bd_Cinfinite: thm,
   183   bd_Cinfinite: thm,
   184   bd_Cnotzero: thm,
   184   bd_Cnotzero: thm,
   185   collect_set_natural: thm lazy,
   185   collect_set_map: thm lazy,
   186   in_cong: thm lazy,
   186   in_cong: thm lazy,
   187   in_mono: thm lazy,
   187   in_mono: thm lazy,
   188   in_srel: thm lazy,
   188   in_srel: thm lazy,
   189   map_comp': thm lazy,
   189   map_comp': thm lazy,
   190   map_cong: thm lazy,
   190   map_cong: thm lazy,
   191   map_id': thm lazy,
   191   map_id': thm lazy,
   192   map_wppull: thm lazy,
   192   map_wppull: thm lazy,
   193   rel_eq: thm lazy,
   193   rel_eq: thm lazy,
   194   rel_flip: thm lazy,
   194   rel_flip: thm lazy,
   195   rel_srel: thm lazy,
   195   rel_srel: thm lazy,
   196   set_natural': thm lazy list,
   196   set_map': thm lazy list,
   197   srel_cong: thm lazy,
   197   srel_cong: thm lazy,
   198   srel_mono: thm lazy,
   198   srel_mono: thm lazy,
   199   srel_Id: thm lazy,
   199   srel_Id: thm lazy,
   200   srel_Gr: thm lazy,
   200   srel_Gr: thm lazy,
   201   srel_converse: thm lazy,
   201   srel_converse: thm lazy,
   202   srel_O: thm lazy
   202   srel_O: thm lazy
   203 };
   203 };
   204 
   204 
   205 fun mk_facts bd_Card_order bd_Cinfinite bd_Cnotzero collect_set_natural in_cong in_mono in_srel
   205 fun mk_facts bd_Card_order bd_Cinfinite bd_Cnotzero collect_set_map in_cong in_mono in_srel
   206     map_comp' map_cong map_id' map_wppull rel_eq rel_flip rel_srel set_natural' srel_cong srel_mono
   206     map_comp' map_cong map_id' map_wppull rel_eq rel_flip rel_srel set_map' srel_cong srel_mono
   207     srel_Id srel_Gr srel_converse srel_O = {
   207     srel_Id srel_Gr srel_converse srel_O = {
   208   bd_Card_order = bd_Card_order,
   208   bd_Card_order = bd_Card_order,
   209   bd_Cinfinite = bd_Cinfinite,
   209   bd_Cinfinite = bd_Cinfinite,
   210   bd_Cnotzero = bd_Cnotzero,
   210   bd_Cnotzero = bd_Cnotzero,
   211   collect_set_natural = collect_set_natural,
   211   collect_set_map = collect_set_map,
   212   in_cong = in_cong,
   212   in_cong = in_cong,
   213   in_mono = in_mono,
   213   in_mono = in_mono,
   214   in_srel = in_srel,
   214   in_srel = in_srel,
   215   map_comp' = map_comp',
   215   map_comp' = map_comp',
   216   map_cong = map_cong,
   216   map_cong = map_cong,
   217   map_id' = map_id',
   217   map_id' = map_id',
   218   map_wppull = map_wppull,
   218   map_wppull = map_wppull,
   219   rel_eq = rel_eq,
   219   rel_eq = rel_eq,
   220   rel_flip = rel_flip,
   220   rel_flip = rel_flip,
   221   rel_srel = rel_srel,
   221   rel_srel = rel_srel,
   222   set_natural' = set_natural',
   222   set_map' = set_map',
   223   srel_cong = srel_cong,
   223   srel_cong = srel_cong,
   224   srel_mono = srel_mono,
   224   srel_mono = srel_mono,
   225   srel_Id = srel_Id,
   225   srel_Id = srel_Id,
   226   srel_Gr = srel_Gr,
   226   srel_Gr = srel_Gr,
   227   srel_converse = srel_converse,
   227   srel_converse = srel_converse,
   229 
   229 
   230 fun map_facts f {
   230 fun map_facts f {
   231   bd_Card_order,
   231   bd_Card_order,
   232   bd_Cinfinite,
   232   bd_Cinfinite,
   233   bd_Cnotzero,
   233   bd_Cnotzero,
   234   collect_set_natural,
   234   collect_set_map,
   235   in_cong,
   235   in_cong,
   236   in_mono,
   236   in_mono,
   237   in_srel,
   237   in_srel,
   238   map_comp',
   238   map_comp',
   239   map_cong,
   239   map_cong,
   240   map_id',
   240   map_id',
   241   map_wppull,
   241   map_wppull,
   242   rel_eq,
   242   rel_eq,
   243   rel_flip,
   243   rel_flip,
   244   rel_srel,
   244   rel_srel,
   245   set_natural',
   245   set_map',
   246   srel_cong,
   246   srel_cong,
   247   srel_mono,
   247   srel_mono,
   248   srel_Id,
   248   srel_Id,
   249   srel_Gr,
   249   srel_Gr,
   250   srel_converse,
   250   srel_converse,
   251   srel_O} =
   251   srel_O} =
   252   {bd_Card_order = f bd_Card_order,
   252   {bd_Card_order = f bd_Card_order,
   253     bd_Cinfinite = f bd_Cinfinite,
   253     bd_Cinfinite = f bd_Cinfinite,
   254     bd_Cnotzero = f bd_Cnotzero,
   254     bd_Cnotzero = f bd_Cnotzero,
   255     collect_set_natural = Lazy.map f collect_set_natural,
   255     collect_set_map = Lazy.map f collect_set_map,
   256     in_cong = Lazy.map f in_cong,
   256     in_cong = Lazy.map f in_cong,
   257     in_mono = Lazy.map f in_mono,
   257     in_mono = Lazy.map f in_mono,
   258     in_srel = Lazy.map f in_srel,
   258     in_srel = Lazy.map f in_srel,
   259     map_comp' = Lazy.map f map_comp',
   259     map_comp' = Lazy.map f map_comp',
   260     map_cong = Lazy.map f map_cong,
   260     map_cong = Lazy.map f map_cong,
   261     map_id' = Lazy.map f map_id',
   261     map_id' = Lazy.map f map_id',
   262     map_wppull = Lazy.map f map_wppull,
   262     map_wppull = Lazy.map f map_wppull,
   263     rel_eq = Lazy.map f rel_eq,
   263     rel_eq = Lazy.map f rel_eq,
   264     rel_flip = Lazy.map f rel_flip,
   264     rel_flip = Lazy.map f rel_flip,
   265     rel_srel = Lazy.map f rel_srel,
   265     rel_srel = Lazy.map f rel_srel,
   266     set_natural' = map (Lazy.map f) set_natural',
   266     set_map' = map (Lazy.map f) set_map',
   267     srel_cong = Lazy.map f srel_cong,
   267     srel_cong = Lazy.map f srel_cong,
   268     srel_mono = Lazy.map f srel_mono,
   268     srel_mono = Lazy.map f srel_mono,
   269     srel_Id = Lazy.map f srel_Id,
   269     srel_Id = Lazy.map f srel_Id,
   270     srel_Gr = Lazy.map f srel_Gr,
   270     srel_Gr = Lazy.map f srel_Gr,
   271     srel_converse = Lazy.map f srel_converse,
   271     srel_converse = Lazy.map f srel_converse,
   366 val bd_card_order_of_bnf = #bd_card_order o #axioms o rep_bnf;
   366 val bd_card_order_of_bnf = #bd_card_order o #axioms o rep_bnf;
   367 val bd_cinfinite_of_bnf = #bd_cinfinite o #axioms o rep_bnf;
   367 val bd_cinfinite_of_bnf = #bd_cinfinite o #axioms o rep_bnf;
   368 val bd_Card_order_of_bnf = #bd_Card_order o #facts o rep_bnf;
   368 val bd_Card_order_of_bnf = #bd_Card_order o #facts o rep_bnf;
   369 val bd_Cinfinite_of_bnf = #bd_Cinfinite o #facts o rep_bnf;
   369 val bd_Cinfinite_of_bnf = #bd_Cinfinite o #facts o rep_bnf;
   370 val bd_Cnotzero_of_bnf = #bd_Cnotzero o #facts o rep_bnf;
   370 val bd_Cnotzero_of_bnf = #bd_Cnotzero o #facts o rep_bnf;
   371 val collect_set_natural_of_bnf = Lazy.force o #collect_set_natural o #facts o rep_bnf;
   371 val collect_set_map_of_bnf = Lazy.force o #collect_set_map o #facts o rep_bnf;
   372 val in_bd_of_bnf = #in_bd o #axioms o rep_bnf;
   372 val in_bd_of_bnf = #in_bd o #axioms o rep_bnf;
   373 val in_cong_of_bnf = Lazy.force o #in_cong o #facts o rep_bnf;
   373 val in_cong_of_bnf = Lazy.force o #in_cong o #facts o rep_bnf;
   374 val in_mono_of_bnf = Lazy.force o #in_mono o #facts o rep_bnf;
   374 val in_mono_of_bnf = Lazy.force o #in_mono o #facts o rep_bnf;
   375 val in_srel_of_bnf = Lazy.force o #in_srel o #facts o rep_bnf;
   375 val in_srel_of_bnf = Lazy.force o #in_srel o #facts o rep_bnf;
   376 val map_def_of_bnf = #map_def o #defs o rep_bnf;
   376 val map_def_of_bnf = #map_def o #defs o rep_bnf;
   386 val rel_eq_of_bnf = Lazy.force o #rel_eq o #facts o rep_bnf;
   386 val rel_eq_of_bnf = Lazy.force o #rel_eq o #facts o rep_bnf;
   387 val rel_flip_of_bnf = Lazy.force o #rel_flip o #facts o rep_bnf;
   387 val rel_flip_of_bnf = Lazy.force o #rel_flip o #facts o rep_bnf;
   388 val rel_srel_of_bnf = Lazy.force o #rel_srel o #facts o rep_bnf;
   388 val rel_srel_of_bnf = Lazy.force o #rel_srel o #facts o rep_bnf;
   389 val set_bd_of_bnf = #set_bd o #axioms o rep_bnf;
   389 val set_bd_of_bnf = #set_bd o #axioms o rep_bnf;
   390 val set_defs_of_bnf = #set_defs o #defs o rep_bnf;
   390 val set_defs_of_bnf = #set_defs o #defs o rep_bnf;
   391 val set_natural_of_bnf = #set_natural o #axioms o rep_bnf;
   391 val set_map_of_bnf = #set_map o #axioms o rep_bnf;
   392 val set_natural'_of_bnf = map Lazy.force o #set_natural' o #facts o rep_bnf;
   392 val set_map'_of_bnf = map Lazy.force o #set_map' o #facts o rep_bnf;
   393 val srel_cong_of_bnf = Lazy.force o #srel_cong o #facts o rep_bnf;
   393 val srel_cong_of_bnf = Lazy.force o #srel_cong o #facts o rep_bnf;
   394 val srel_mono_of_bnf = Lazy.force o #srel_mono o #facts o rep_bnf;
   394 val srel_mono_of_bnf = Lazy.force o #srel_mono o #facts o rep_bnf;
   395 val srel_def_of_bnf = #srel_def o #defs o rep_bnf;
   395 val srel_def_of_bnf = #srel_def o #defs o rep_bnf;
   396 val srel_Id_of_bnf = Lazy.force o #srel_Id o #facts o rep_bnf;
   396 val srel_Id_of_bnf = Lazy.force o #srel_Id o #facts o rep_bnf;
   397 val srel_Gr_of_bnf = Lazy.force o #srel_Gr o #facts o rep_bnf;
   397 val srel_Gr_of_bnf = Lazy.force o #srel_Gr o #facts o rep_bnf;
   505 val bd_card_orderN = "bd_card_order";
   505 val bd_card_orderN = "bd_card_order";
   506 val bd_cinfiniteN = "bd_cinfinite";
   506 val bd_cinfiniteN = "bd_cinfinite";
   507 val bd_Card_orderN = "bd_Card_order";
   507 val bd_Card_orderN = "bd_Card_order";
   508 val bd_CinfiniteN = "bd_Cinfinite";
   508 val bd_CinfiniteN = "bd_Cinfinite";
   509 val bd_CnotzeroN = "bd_Cnotzero";
   509 val bd_CnotzeroN = "bd_Cnotzero";
   510 val collect_set_naturalN = "collect_set_natural";
   510 val collect_set_mapN = "collect_set_map";
   511 val in_bdN = "in_bd";
   511 val in_bdN = "in_bd";
   512 val in_monoN = "in_mono";
   512 val in_monoN = "in_mono";
   513 val in_srelN = "in_srel";
   513 val in_srelN = "in_srel";
   514 val map_idN = "map_id";
   514 val map_idN = "map_id";
   515 val map_id'N = "map_id'";
   515 val map_id'N = "map_id'";
   519 val map_congN = "map_cong";
   519 val map_congN = "map_cong";
   520 val map_wpullN = "map_wpull";
   520 val map_wpullN = "map_wpull";
   521 val rel_eqN = "rel_eq";
   521 val rel_eqN = "rel_eq";
   522 val rel_flipN = "rel_flip";
   522 val rel_flipN = "rel_flip";
   523 val rel_srelN = "rel_srel";
   523 val rel_srelN = "rel_srel";
   524 val set_naturalN = "set_natural";
   524 val set_mapN = "set_map";
   525 val set_natural'N = "set_natural'";
   525 val set_map'N = "set_map'";
   526 val set_bdN = "set_bd";
   526 val set_bdN = "set_bd";
   527 val srel_IdN = "srel_Id";
   527 val srel_IdN = "srel_Id";
   528 val srel_GrN = "srel_Gr";
   528 val srel_GrN = "srel_Gr";
   529 val srel_converseN = "srel_converse";
   529 val srel_converseN = "srel_converse";
   530 val srel_monoN = "srel_mono"
   530 val srel_monoN = "srel_mono"
   833           Term.list_comb (bnf_map_AsBs, fs_copy) $ x);
   833           Term.list_comb (bnf_map_AsBs, fs_copy) $ x);
   834       in
   834       in
   835         fold_rev Logic.all (x :: fs @ fs_copy) (Logic.list_implies (prems, eq))
   835         fold_rev Logic.all (x :: fs @ fs_copy) (Logic.list_implies (prems, eq))
   836       end;
   836       end;
   837 
   837 
   838     val set_naturals_goal =
   838     val set_maps_goal =
   839       let
   839       let
   840         fun mk_goal setA setB f =
   840         fun mk_goal setA setB f =
   841           let
   841           let
   842             val set_comp_map =
   842             val set_comp_map =
   843               HOLogic.mk_comp (setB, Term.list_comb (bnf_map_AsBs, fs));
   843               HOLogic.mk_comp (setB, Term.list_comb (bnf_map_AsBs, fs));
   895           (Logic.list_implies (prems, HOLogic.mk_Trueprop map_wpull))
   895           (Logic.list_implies (prems, HOLogic.mk_Trueprop map_wpull))
   896       end;
   896       end;
   897 
   897 
   898     val srel_O_Gr_goal = fold_rev Logic.all Rs (mk_Trueprop_eq (Term.list_comb (srel, Rs), O_Gr));
   898     val srel_O_Gr_goal = fold_rev Logic.all Rs (mk_Trueprop_eq (Term.list_comb (srel, Rs), O_Gr));
   899 
   899 
   900     val goals = zip_axioms map_id_goal map_comp_goal map_cong0_goal set_naturals_goal
   900     val goals = zip_axioms map_id_goal map_comp_goal map_cong0_goal set_maps_goal card_order_bd_goal
   901       card_order_bd_goal cinfinite_bd_goal set_bds_goal in_bd_goal map_wpull_goal srel_O_Gr_goal;
   901       cinfinite_bd_goal set_bds_goal in_bd_goal map_wpull_goal srel_O_Gr_goal;
   902 
   902 
   903     fun mk_wit_goals (I, wit) =
   903     fun mk_wit_goals (I, wit) =
   904       let
   904       let
   905         val xs = map (nth bs) I;
   905         val xs = map (nth bs) I;
   906         fun wit_goal i =
   906         fun wit_goal i =
   926 
   926 
   927         val bd_Card_order = #bd_card_order axioms RS @{thm conjunct2[OF card_order_on_Card_order]};
   927         val bd_Card_order = #bd_card_order axioms RS @{thm conjunct2[OF card_order_on_Card_order]};
   928         val bd_Cinfinite = @{thm conjI} OF [#bd_cinfinite axioms, bd_Card_order];
   928         val bd_Cinfinite = @{thm conjI} OF [#bd_cinfinite axioms, bd_Card_order];
   929         val bd_Cnotzero = bd_Cinfinite RS @{thm Cinfinite_Cnotzero};
   929         val bd_Cnotzero = bd_Cinfinite RS @{thm Cinfinite_Cnotzero};
   930 
   930 
   931         fun mk_collect_set_natural () =
   931         fun mk_collect_set_map () =
   932           let
   932           let
   933             val defT = mk_bnf_T Ts CA --> HOLogic.mk_setT T;
   933             val defT = mk_bnf_T Ts CA --> HOLogic.mk_setT T;
   934             val collect_map = HOLogic.mk_comp
   934             val collect_map = HOLogic.mk_comp
   935               (mk_collect (map (mk_bnf_t Ts) bnf_sets) defT,
   935               (mk_collect (map (mk_bnf_t Ts) bnf_sets) defT,
   936               Term.list_comb (mk_bnf_map As' Ts, hs));
   936               Term.list_comb (mk_bnf_map As' Ts, hs));
   938               (map2 (fn h => fn set => HOLogic.mk_comp (mk_image h, set)) hs bnf_sets_As)
   938               (map2 (fn h => fn set => HOLogic.mk_comp (mk_image h, set)) hs bnf_sets_As)
   939               defT;
   939               defT;
   940             (*collect {set1 ... setm} o map f1 ... fm = collect {f1` o set1 ... fm` o setm}*)
   940             (*collect {set1 ... setm} o map f1 ... fm = collect {f1` o set1 ... fm` o setm}*)
   941             val goal = fold_rev Logic.all hs (mk_Trueprop_eq (collect_map, image_collect));
   941             val goal = fold_rev Logic.all hs (mk_Trueprop_eq (collect_map, image_collect));
   942           in
   942           in
   943             Goal.prove_sorry lthy [] [] goal (K (mk_collect_set_natural_tac (#set_natural axioms)))
   943             Goal.prove_sorry lthy [] [] goal (K (mk_collect_set_map_tac (#set_map axioms)))
   944             |> Thm.close_derivation
   944             |> Thm.close_derivation
   945           end;
   945           end;
   946 
   946 
   947         val collect_set_natural = Lazy.lazy mk_collect_set_natural;
   947         val collect_set_map = Lazy.lazy mk_collect_set_map;
   948 
   948 
   949         fun mk_in_mono () =
   949         fun mk_in_mono () =
   950           let
   950           let
   951             val prems_mono = map2 (HOLogic.mk_Trueprop oo mk_subset) As As_copy;
   951             val prems_mono = map2 (HOLogic.mk_Trueprop oo mk_subset) As As_copy;
   952             val in_mono_goal =
   952             val in_mono_goal =
   990             |> Thm.close_derivation
   990             |> Thm.close_derivation
   991           end;
   991           end;
   992 
   992 
   993         val map_cong = Lazy.lazy mk_map_cong;
   993         val map_cong = Lazy.lazy mk_map_cong;
   994 
   994 
   995         val set_natural' =
   995         val set_map' = map (fn thm => Lazy.lazy (fn () => mk_set_map' thm)) (#set_map axioms);
   996           map (fn thm => Lazy.lazy (fn () => mk_set_natural' thm)) (#set_natural axioms);
       
   997 
   996 
   998         fun mk_map_wppull () =
   997         fun mk_map_wppull () =
   999           let
   998           let
  1000             val prems = if live = 0 then [] else
   999             val prems = if live = 0 then [] else
  1001               [HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
  1000               [HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
  1025               fold_rev Logic.all (Xs @ B1s @ B2s @ f1s @ f2s @ e1s @ e2s @ p1s @ p2s)
  1024               fold_rev Logic.all (Xs @ B1s @ B2s @ f1s @ f2s @ e1s @ e2s @ p1s @ p2s)
  1026                 (Logic.list_implies (prems, HOLogic.mk_Trueprop concl))
  1025                 (Logic.list_implies (prems, HOLogic.mk_Trueprop concl))
  1027           in
  1026           in
  1028             Goal.prove_sorry lthy [] [] goal
  1027             Goal.prove_sorry lthy [] [] goal
  1029               (fn _ => mk_map_wppull_tac (#map_id axioms) (#map_cong0 axioms)
  1028               (fn _ => mk_map_wppull_tac (#map_id axioms) (#map_cong0 axioms)
  1030                 (#map_wpull axioms) (Lazy.force map_comp') (map Lazy.force set_natural'))
  1029                 (#map_wpull axioms) (Lazy.force map_comp') (map Lazy.force set_map'))
  1031             |> Thm.close_derivation
  1030             |> Thm.close_derivation
  1032           end;
  1031           end;
  1033 
  1032 
  1034         val map_wppull = Lazy.lazy mk_map_wppull;
  1033         val map_wppull = Lazy.lazy mk_map_wppull;
  1035 
  1034 
  1041             val rhs = mk_Gr (mk_in As bnf_sets_As CA') (Term.list_comb (bnf_map_AsBs, fs));
  1040             val rhs = mk_Gr (mk_in As bnf_sets_As CA') (Term.list_comb (bnf_map_AsBs, fs));
  1042             val goal = fold_rev Logic.all (As @ fs) (mk_Trueprop_eq (lhs, rhs));
  1041             val goal = fold_rev Logic.all (As @ fs) (mk_Trueprop_eq (lhs, rhs));
  1043           in
  1042           in
  1044             Goal.prove_sorry lthy [] [] goal
  1043             Goal.prove_sorry lthy [] [] goal
  1045               (mk_srel_Gr_tac srel_O_Grs (#map_id axioms) (#map_cong0 axioms) (Lazy.force map_id')
  1044               (mk_srel_Gr_tac srel_O_Grs (#map_id axioms) (#map_cong0 axioms) (Lazy.force map_id')
  1046                 (Lazy.force map_comp') (map Lazy.force set_natural'))
  1045                 (Lazy.force map_comp') (map Lazy.force set_map'))
  1047             |> Thm.close_derivation
  1046             |> Thm.close_derivation
  1048           end;
  1047           end;
  1049 
  1048 
  1050         val srel_Gr = Lazy.lazy mk_srel_Gr;
  1049         val srel_Gr = Lazy.lazy mk_srel_Gr;
  1051 
  1050 
  1094             val lhs = Term.list_comb (srelBsAs, map mk_converse Rs);
  1093             val lhs = Term.list_comb (srelBsAs, map mk_converse Rs);
  1095             val rhs = mk_converse (Term.list_comb (srel, Rs));
  1094             val rhs = mk_converse (Term.list_comb (srel, Rs));
  1096             val le_goal = fold_rev Logic.all Rs (HOLogic.mk_Trueprop (mk_subset lhs rhs));
  1095             val le_goal = fold_rev Logic.all Rs (HOLogic.mk_Trueprop (mk_subset lhs rhs));
  1097             val le_thm = Goal.prove_sorry lthy [] [] le_goal
  1096             val le_thm = Goal.prove_sorry lthy [] [] le_goal
  1098               (mk_srel_converse_le_tac srel_O_Grs (Lazy.force srel_Id) (#map_cong0 axioms)
  1097               (mk_srel_converse_le_tac srel_O_Grs (Lazy.force srel_Id) (#map_cong0 axioms)
  1099                 (Lazy.force map_comp') (map Lazy.force set_natural'))
  1098                 (Lazy.force map_comp') (map Lazy.force set_map'))
  1100               |> Thm.close_derivation
  1099               |> Thm.close_derivation
  1101             val goal = fold_rev Logic.all Rs (mk_Trueprop_eq (lhs, rhs));
  1100             val goal = fold_rev Logic.all Rs (mk_Trueprop_eq (lhs, rhs));
  1102           in
  1101           in
  1103             Goal.prove_sorry lthy [] [] goal (fn _ => mk_srel_converse_tac le_thm)
  1102             Goal.prove_sorry lthy [] [] goal (fn _ => mk_srel_converse_tac le_thm)
  1104             |> Thm.close_derivation
  1103             |> Thm.close_derivation
  1114             val rhs = mk_rel_comp (Term.list_comb (srel, Rs), Term.list_comb (srelBsCs, Ss));
  1113             val rhs = mk_rel_comp (Term.list_comb (srel, Rs), Term.list_comb (srelBsCs, Ss));
  1115             val goal = fold_rev Logic.all (Rs @ Ss) (mk_Trueprop_eq (lhs, rhs));
  1114             val goal = fold_rev Logic.all (Rs @ Ss) (mk_Trueprop_eq (lhs, rhs));
  1116           in
  1115           in
  1117             Goal.prove_sorry lthy [] [] goal
  1116             Goal.prove_sorry lthy [] [] goal
  1118               (mk_srel_O_tac srel_O_Grs (Lazy.force srel_Id) (#map_cong0 axioms)
  1117               (mk_srel_O_tac srel_O_Grs (Lazy.force srel_Id) (#map_cong0 axioms)
  1119                 (Lazy.force map_wppull) (Lazy.force map_comp') (map Lazy.force set_natural'))
  1118                 (Lazy.force map_wppull) (Lazy.force map_comp') (map Lazy.force set_map'))
  1120             |> Thm.close_derivation
  1119             |> Thm.close_derivation
  1121           end;
  1120           end;
  1122 
  1121 
  1123         val srel_O = Lazy.lazy mk_srel_O;
  1122         val srel_O = Lazy.lazy mk_srel_O;
  1124 
  1123 
  1174 
  1173 
  1175         val rel_flip = Lazy.lazy mk_rel_flip;
  1174         val rel_flip = Lazy.lazy mk_rel_flip;
  1176 
  1175 
  1177         val defs = mk_defs bnf_map_def bnf_set_defs bnf_rel_def bnf_srel_def;
  1176         val defs = mk_defs bnf_map_def bnf_set_defs bnf_rel_def bnf_srel_def;
  1178 
  1177 
  1179         val facts = mk_facts bd_Card_order bd_Cinfinite bd_Cnotzero collect_set_natural in_cong
  1178         val facts = mk_facts bd_Card_order bd_Cinfinite bd_Cnotzero collect_set_map in_cong in_mono
  1180           in_mono in_srel map_comp' map_cong map_id' map_wppull rel_eq rel_flip rel_srel
  1179           in_srel map_comp' map_cong map_id' map_wppull rel_eq rel_flip rel_srel set_map'
  1181           set_natural' srel_cong srel_mono srel_Id srel_Gr srel_converse srel_O;
  1180           srel_cong srel_mono srel_Id srel_Gr srel_converse srel_O;
  1182 
  1181 
  1183         val wits = map2 mk_witness bnf_wits wit_thms;
  1182         val wits = map2 mk_witness bnf_wits wit_thms;
  1184 
  1183 
  1185         val bnf_rel =
  1184         val bnf_rel =
  1186           Term.subst_atomic_types ((Ds ~~ deads) @ (As' ~~ alphas) @ (Bs' ~~ betas)) rel;
  1185           Term.subst_atomic_types ((Ds ~~ deads) @ (As' ~~ alphas) @ (Bs' ~~ betas)) rel;
  1198                     [(bd_card_orderN, [#bd_card_order axioms]),
  1197                     [(bd_card_orderN, [#bd_card_order axioms]),
  1199                     (bd_cinfiniteN, [#bd_cinfinite axioms]),
  1198                     (bd_cinfiniteN, [#bd_cinfinite axioms]),
  1200                     (bd_Card_orderN, [#bd_Card_order facts]),
  1199                     (bd_Card_orderN, [#bd_Card_order facts]),
  1201                     (bd_CinfiniteN, [#bd_Cinfinite facts]),
  1200                     (bd_CinfiniteN, [#bd_Cinfinite facts]),
  1202                     (bd_CnotzeroN, [#bd_Cnotzero facts]),
  1201                     (bd_CnotzeroN, [#bd_Cnotzero facts]),
  1203                     (collect_set_naturalN, [Lazy.force (#collect_set_natural facts)]),
  1202                     (collect_set_mapN, [Lazy.force (#collect_set_map facts)]),
  1204                     (in_bdN, [#in_bd axioms]),
  1203                     (in_bdN, [#in_bd axioms]),
  1205                     (in_monoN, [Lazy.force (#in_mono facts)]),
  1204                     (in_monoN, [Lazy.force (#in_mono facts)]),
  1206                     (in_srelN, [Lazy.force (#in_srel facts)]),
  1205                     (in_srelN, [Lazy.force (#in_srel facts)]),
  1207                     (map_compN, [#map_comp axioms]),
  1206                     (map_compN, [#map_comp axioms]),
  1208                     (map_idN, [#map_id axioms]),
  1207                     (map_idN, [#map_id axioms]),
  1209                     (map_wpullN, [#map_wpull axioms]),
  1208                     (map_wpullN, [#map_wpull axioms]),
  1210                     (set_naturalN, #set_natural axioms),
  1209                     (set_mapN, #set_map axioms),
  1211                     (set_bdN, #set_bd axioms)] @
  1210                     (set_bdN, #set_bd axioms)] @
  1212                     (witNs ~~ wit_thms)
  1211                     (witNs ~~ wit_thms)
  1213                     |> map (fn (thmN, thms) =>
  1212                     |> map (fn (thmN, thms) =>
  1214                       ((qualify (Binding.qualify true (Binding.name_of b) (Binding.name thmN)), []),
  1213                       ((qualify (Binding.qualify true (Binding.name_of b) (Binding.name thmN)), []),
  1215                       [(thms, [])]));
  1214                       [(thms, [])]));
  1226                     (map_congN, [Lazy.force (#map_cong facts)], fundef_cong_attrs),
  1225                     (map_congN, [Lazy.force (#map_cong facts)], fundef_cong_attrs),
  1227                     (map_id'N, [Lazy.force (#map_id' facts)], []),
  1226                     (map_id'N, [Lazy.force (#map_id' facts)], []),
  1228                     (rel_eqN, [Lazy.force (#rel_eq facts)], []),
  1227                     (rel_eqN, [Lazy.force (#rel_eq facts)], []),
  1229                     (rel_flipN, [Lazy.force (#rel_flip facts)], []),
  1228                     (rel_flipN, [Lazy.force (#rel_flip facts)], []),
  1230                     (rel_srelN, [Lazy.force (#rel_srel facts)], []),
  1229                     (rel_srelN, [Lazy.force (#rel_srel facts)], []),
  1231                     (set_natural'N, map Lazy.force (#set_natural' facts), []),
  1230                     (set_map'N, map Lazy.force (#set_map' facts), []),
  1232                     (srel_O_GrN, srel_O_Grs, []),
  1231                     (srel_O_GrN, srel_O_Grs, []),
  1233                     (srel_IdN, [Lazy.force (#srel_Id facts)], []),
  1232                     (srel_IdN, [Lazy.force (#srel_Id facts)], []),
  1234                     (srel_GrN, [Lazy.force (#srel_Gr facts)], []),
  1233                     (srel_GrN, [Lazy.force (#srel_Gr facts)], []),
  1235                     (srel_converseN, [Lazy.force (#srel_converse facts)], []),
  1234                     (srel_converseN, [Lazy.force (#srel_converse facts)], []),
  1236                     (srel_monoN, [Lazy.force (#srel_mono facts)], []),
  1235                     (srel_monoN, [Lazy.force (#srel_mono facts)], []),