src/HOL/BNF/Tools/bnf_def_tactics.ML
changeset 52844 66fa0f602cc4
parent 52813 963297a24206
child 52986 7f7bbeb16538
equal deleted inserted replaced
52843:ea95702328cf 52844:66fa0f602cc4
    23     {prems: thm list, context: Proof.context} -> tactic
    23     {prems: thm list, context: Proof.context} -> tactic
    24   val mk_in_rel_tac: thm -> {prems: 'a, context: Proof.context} -> tactic
    24   val mk_in_rel_tac: thm -> {prems: 'a, context: Proof.context} -> tactic
    25   val mk_rel_conversep_tac: thm -> thm -> tactic
    25   val mk_rel_conversep_tac: thm -> thm -> tactic
    26   val mk_rel_conversep_le_tac: thm list -> thm -> thm -> thm -> thm list ->
    26   val mk_rel_conversep_le_tac: thm list -> thm -> thm -> thm -> thm list ->
    27     {prems: thm list, context: Proof.context} -> tactic
    27     {prems: thm list, context: Proof.context} -> tactic
    28   val mk_rel_mono_tac: thm list -> thm -> {prems: 'a, context: Proof.context} -> tactic
    28   val mk_rel_mono_tac: thm list -> thm -> tactic
    29   val mk_rel_mono_strong_tac: thm -> thm list -> {prems: 'a, context: Proof.context} -> tactic
    29   val mk_rel_mono_strong_tac: thm -> thm list -> {prems: 'a, context: Proof.context} -> tactic
    30 
    30 
    31   val mk_map_transfer_tac: thm -> thm -> thm list -> thm -> thm ->
    31   val mk_map_transfer_tac: thm -> thm -> thm list -> thm -> thm ->
    32     {prems: thm list, context: Proof.context} -> tactic
    32     {prems: thm list, context: Proof.context} -> tactic
    33 
    33 
    40 
    40 
    41 open BNF_Util
    41 open BNF_Util
    42 open BNF_Tactics
    42 open BNF_Tactics
    43 
    43 
    44 val ord_eq_le_trans = @{thm ord_eq_le_trans};
    44 val ord_eq_le_trans = @{thm ord_eq_le_trans};
       
    45 val ord_le_eq_trans = @{thm ord_le_eq_trans};
    45 val conversep_shift = @{thm conversep_le_swap} RS iffD1;
    46 val conversep_shift = @{thm conversep_le_swap} RS iffD1;
    46 
    47 
    47 fun mk_map_id' id = mk_trans (fun_cong OF [id]) @{thm id_apply};
    48 fun mk_map_id' id = mk_trans (fun_cong OF [id]) @{thm id_apply};
    48 fun mk_map_comp' comp = @{thm o_eq_dest_lhs} OF [mk_sym comp];
    49 fun mk_map_comp' comp = @{thm o_eq_dest_lhs} OF [mk_sym comp];
    49 fun mk_map_cong_tac ctxt cong0 =
    50 fun mk_map_cong_tac ctxt cong0 =
    83 
    84 
    84 fun mk_rel_Grp_tac rel_OO_Grps map_id map_cong0 map_id' map_comp set_maps
    85 fun mk_rel_Grp_tac rel_OO_Grps map_id map_cong0 map_id' map_comp set_maps
    85   {context = ctxt, prems = _} =
    86   {context = ctxt, prems = _} =
    86   let
    87   let
    87     val n = length set_maps;
    88     val n = length set_maps;
       
    89     val rel_OO_Grps_tac = if null rel_OO_Grps then K all_tac else rtac (hd rel_OO_Grps RS trans);
    88   in
    90   in
    89     if null set_maps then
    91     if null set_maps then
    90       unfold_thms_tac ctxt ((map_id RS @{thm Grp_UNIV_id}) :: rel_OO_Grps) THEN
    92       unfold_thms_tac ctxt ((map_id RS @{thm Grp_UNIV_id}) :: rel_OO_Grps) THEN
    91       rtac @{thm Grp_UNIV_idI[OF refl]} 1
    93       rtac @{thm Grp_UNIV_idI[OF refl]} 1
    92     else unfold_thms_tac ctxt rel_OO_Grps THEN
    94     else
    93       EVERY' [rtac @{thm antisym}, rtac @{thm predicate2I},
    95       EVERY' [rel_OO_Grps_tac, rtac @{thm antisym}, rtac @{thm predicate2I},
    94         REPEAT_DETERM o
    96         REPEAT_DETERM o
    95           eresolve_tac [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}],
    97           eresolve_tac [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}],
    96         hyp_subst_tac ctxt, rtac @{thm GrpI}, rtac trans, rtac map_comp, rtac map_cong0,
    98         hyp_subst_tac ctxt, rtac @{thm GrpI}, rtac trans, rtac map_comp, rtac map_cong0,
    97         REPEAT_DETERM_N n o EVERY' [rtac @{thm Collect_split_Grp_eqD}, etac @{thm set_mp}, atac],
    99         REPEAT_DETERM_N n o EVERY' [rtac @{thm Collect_split_Grp_eqD}, etac @{thm set_mp}, atac],
    98         rtac CollectI,
   100         rtac CollectI,
   120   (if n = 0 then rtac refl
   122   (if n = 0 then rtac refl
   121   else EVERY' [rtac @{thm arg_cong2[of _ _ _ _ "Grp"]},
   123   else EVERY' [rtac @{thm arg_cong2[of _ _ _ _ "Grp"]},
   122     rtac @{thm equalityI}, rtac subset_UNIV, rtac subsetI, rtac CollectI,
   124     rtac @{thm equalityI}, rtac subset_UNIV, rtac subsetI, rtac CollectI,
   123     CONJ_WRAP' (K (rtac subset_UNIV)) (1 upto n), rtac map_id])) 1;
   125     CONJ_WRAP' (K (rtac subset_UNIV)) (1 upto n), rtac map_id])) 1;
   124 
   126 
   125 fun mk_rel_mono_tac rel_OO_Grps in_mono {context = ctxt, prems = _} =
   127 fun mk_rel_mono_tac rel_OO_Grps in_mono =
   126   unfold_thms_tac ctxt rel_OO_Grps THEN
   128   let
   127     EVERY' [rtac @{thm relcompp_mono}, rtac @{thm iffD2[OF conversep_mono]},
   129     val rel_OO_Grps_tac = if null rel_OO_Grps then K all_tac
       
   130       else rtac (hd rel_OO_Grps RS ord_eq_le_trans) THEN'
       
   131         rtac (hd rel_OO_Grps RS sym RSN (2, ord_le_eq_trans));
       
   132   in
       
   133     EVERY' [rel_OO_Grps_tac, rtac @{thm relcompp_mono}, rtac @{thm iffD2[OF conversep_mono]},
   128       rtac @{thm Grp_mono}, rtac in_mono, REPEAT_DETERM o etac @{thm Collect_split_mono},
   134       rtac @{thm Grp_mono}, rtac in_mono, REPEAT_DETERM o etac @{thm Collect_split_mono},
   129       rtac @{thm Grp_mono}, rtac in_mono, REPEAT_DETERM o etac @{thm Collect_split_mono}] 1;
   135       rtac @{thm Grp_mono}, rtac in_mono, REPEAT_DETERM o etac @{thm Collect_split_mono}] 1
       
   136   end;
   130 
   137 
   131 fun mk_rel_conversep_le_tac rel_OO_Grps rel_eq map_cong0 map_comp set_maps
   138 fun mk_rel_conversep_le_tac rel_OO_Grps rel_eq map_cong0 map_comp set_maps
   132   {context = ctxt, prems = _} =
   139   {context = ctxt, prems = _} =
   133   let
   140   let
   134     val n = length set_maps;
   141     val n = length set_maps;
       
   142     val rel_OO_Grps_tac = if null rel_OO_Grps then K all_tac
       
   143       else rtac (hd rel_OO_Grps RS ord_eq_le_trans) THEN'
       
   144         rtac (hd rel_OO_Grps RS sym RS @{thm arg_cong[of _ _ conversep]} RSN (2, ord_le_eq_trans));
   135   in
   145   in
   136     if null set_maps then rtac (rel_eq RS @{thm leq_conversepI}) 1
   146     if null set_maps then rtac (rel_eq RS @{thm leq_conversepI}) 1
   137     else unfold_thms_tac ctxt (rel_OO_Grps) THEN
   147     else
   138       EVERY' [rtac @{thm predicate2I},
   148       EVERY' [rel_OO_Grps_tac, rtac @{thm predicate2I},
   139         REPEAT_DETERM o
   149         REPEAT_DETERM o
   140           eresolve_tac [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}],
   150           eresolve_tac [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}],
   141         hyp_subst_tac ctxt, rtac @{thm conversepI}, rtac @{thm relcomppI}, rtac @{thm conversepI},
   151         hyp_subst_tac ctxt, rtac @{thm conversepI}, rtac @{thm relcomppI}, rtac @{thm conversepI},
   142         EVERY' (map (fn thm => EVERY' [rtac @{thm GrpI}, rtac sym, rtac trans,
   152         EVERY' (map (fn thm => EVERY' [rtac @{thm GrpI}, rtac sym, rtac trans,
   143           rtac map_cong0, REPEAT_DETERM_N n o rtac thm,
   153           rtac map_cong0, REPEAT_DETERM_N n o rtac thm,
   149 fun mk_rel_conversep_tac le_conversep rel_mono =
   159 fun mk_rel_conversep_tac le_conversep rel_mono =
   150   EVERY' [rtac @{thm antisym}, rtac le_conversep, rtac @{thm xt1(6)}, rtac conversep_shift,
   160   EVERY' [rtac @{thm antisym}, rtac le_conversep, rtac @{thm xt1(6)}, rtac conversep_shift,
   151     rtac le_conversep, rtac @{thm iffD2[OF conversep_mono]}, rtac rel_mono,
   161     rtac le_conversep, rtac @{thm iffD2[OF conversep_mono]}, rtac rel_mono,
   152     REPEAT_DETERM o rtac @{thm eq_refl[OF sym[OF conversep_conversep]]}] 1;
   162     REPEAT_DETERM o rtac @{thm eq_refl[OF sym[OF conversep_conversep]]}] 1;
   153 
   163 
   154 fun mk_rel_OO_tac rel_OO_Grs rel_eq map_cong0 map_wppull map_comp set_maps
   164 fun mk_rel_OO_tac rel_OO_Grps rel_eq map_cong0 map_wppull map_comp set_maps
   155   {context = ctxt, prems = _} =
   165   {context = ctxt, prems = _} =
   156   let
   166   let
   157     val n = length set_maps;
   167     val n = length set_maps;
   158     fun in_tac nthO_in = rtac CollectI THEN'
   168     fun in_tac nthO_in = rtac CollectI THEN'
   159         CONJ_WRAP' (fn thm => EVERY' [rtac (thm RS ord_eq_le_trans),
   169         CONJ_WRAP' (fn thm => EVERY' [rtac (thm RS ord_eq_le_trans),
   160           rtac @{thm image_subsetI}, rtac nthO_in, etac set_mp, atac]) set_maps;
   170           rtac @{thm image_subsetI}, rtac nthO_in, etac set_mp, atac]) set_maps;
       
   171     val rel_OO_Grps_tac = if null rel_OO_Grps then K all_tac
       
   172       else rtac (hd rel_OO_Grps RS trans) THEN'
       
   173         rtac (@{thm arg_cong2[of _ _ _ _ "op OO"]} OF (replicate 2 (hd rel_OO_Grps RS sym)) RSN
       
   174           (2, trans));
   161   in
   175   in
   162     if null set_maps then rtac (rel_eq RS @{thm eq_OOI}) 1
   176     if null set_maps then rtac (rel_eq RS @{thm eq_OOI}) 1
   163     else unfold_thms_tac ctxt rel_OO_Grs THEN
   177     else
   164       EVERY' [rtac @{thm antisym}, rtac @{thm predicate2I},
   178       EVERY' [rel_OO_Grps_tac, rtac @{thm antisym}, rtac @{thm predicate2I},
   165         REPEAT_DETERM o
   179         REPEAT_DETERM o
   166           eresolve_tac [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}],
   180           eresolve_tac [CollectE, exE, conjE, @{thm GrpE}, @{thm relcomppE}, @{thm conversepE}],
   167         hyp_subst_tac ctxt,
   181         hyp_subst_tac ctxt,
   168         rtac @{thm relcomppI}, rtac @{thm relcomppI}, rtac @{thm conversepI}, rtac @{thm GrpI},
   182         rtac @{thm relcomppI}, rtac @{thm relcomppI}, rtac @{thm conversepI}, rtac @{thm GrpI},
   169         rtac trans, rtac map_comp, rtac sym, rtac map_cong0,
   183         rtac trans, rtac map_comp, rtac sym, rtac map_cong0,