src/HOL/Tools/BNF/bnf_fp_n2m_tactics.ML
changeset 58375 7b92932ffea5
parent 58237 17200800a553
child 58634 9f10d82e8188
equal deleted inserted replaced
58374:1b4d31b7bd10 58375:7b92932ffea5
     6 *)
     6 *)
     7 
     7 
     8 signature BNF_FP_N2M_TACTICS =
     8 signature BNF_FP_N2M_TACTICS =
     9 sig
     9 sig
    10   val mk_rel_xtor_co_induct_tactic: BNF_Util.fp_kind -> thm list -> thm list -> thm list ->
    10   val mk_rel_xtor_co_induct_tactic: BNF_Util.fp_kind -> thm list -> thm list -> thm list ->
    11     thm list -> thm list -> {prems: thm list, context: Proof.context} -> tactic
    11     thm list -> thm list -> thm list -> {prems: thm list, context: Proof.context} -> tactic
    12 end;
    12 end;
    13 
    13 
    14 structure BNF_FP_N2M_Tactics : BNF_FP_N2M_TACTICS =
    14 structure BNF_FP_N2M_Tactics : BNF_FP_N2M_TACTICS =
    15 struct
    15 struct
    16 
    16 
    18 open BNF_Tactics
    18 open BNF_Tactics
    19 open BNF_FP_Util
    19 open BNF_FP_Util
    20 
    20 
    21 val vimage2p_unfolds = o_apply :: @{thms vimage2p_def};
    21 val vimage2p_unfolds = o_apply :: @{thms vimage2p_def};
    22 
    22 
    23 fun mk_rel_xtor_co_induct_tactic fp abs_inverses co_inducts0 rel_defs rel_monos nesting_rel_eqs
    23 fun mk_rel_xtor_co_induct_tactic fp abs_inverses co_inducts0 rel_defs rel_monos nesting_rel_eqs0
    24   {context = ctxt, prems = raw_C_IHs} =
    24   nesting_rel_monos0 {context = ctxt, prems = raw_C_IHs} =
    25   let
    25   let
    26     val co_inducts = map (unfold_thms ctxt
    26     val nesting_rel_eqs = @{thms prod.rel_eq sum.rel_eq} @ nesting_rel_eqs0;
    27       (vimage2p_unfolds @ @{thms prod.rel_eq sum.rel_eq} @ nesting_rel_eqs)) co_inducts0;
    27     val nesting_rel_monos = map (fn thm => rotate_prems ~1 (thm RS @{thm predicate2D}))
       
    28       (@{thms prod.rel_mono sum.rel_mono} @ nesting_rel_monos0);
       
    29     val co_inducts = map (unfold_thms ctxt (vimage2p_unfolds @ nesting_rel_eqs)) co_inducts0;
    28     val unfolds = map (fn def =>
    30     val unfolds = map (fn def =>
    29       unfold_thms ctxt (id_apply :: vimage2p_unfolds @ abs_inverses @ no_reflexive [def])) rel_defs;
    31       unfold_thms ctxt (id_apply :: vimage2p_unfolds @ abs_inverses @ no_reflexive [def])) rel_defs;
    30     val folded_C_IHs = map (fn thm => thm RS @{thm spec2} RS mp) raw_C_IHs;
    32     val folded_C_IHs = map (fn thm => thm RS @{thm spec2} RS mp) raw_C_IHs;
    31     val C_IHs = map2 (curry op |>) folded_C_IHs unfolds;
    33     val C_IHs = map2 (curry op |>) folded_C_IHs unfolds;
    32     val C_IH_monos =
    34     val C_IH_monos =
    39   in
    41   in
    40     unfold_thms_tac ctxt vimage2p_unfolds THEN
    42     unfold_thms_tac ctxt vimage2p_unfolds THEN
    41     HEADGOAL (CONJ_WRAP_GEN' (rtac @{thm context_conjI})
    43     HEADGOAL (CONJ_WRAP_GEN' (rtac @{thm context_conjI})
    42       (fn thm => rtac thm THEN_ALL_NEW (rotate_tac ~1 THEN'
    44       (fn thm => rtac thm THEN_ALL_NEW (rotate_tac ~1 THEN'
    43          REPEAT_ALL_NEW (FIRST' [eresolve_tac C_IHs, eresolve_tac C_IH_monos,
    45          REPEAT_ALL_NEW (FIRST' [eresolve_tac C_IHs, eresolve_tac C_IH_monos,
    44            rtac @{thm order_refl}, atac, resolve_tac co_inducts])))
    46            SELECT_GOAL (unfold_thms_tac ctxt nesting_rel_eqs) THEN' rtac @{thm order_refl},
       
    47            atac, resolve_tac co_inducts,
       
    48            resolve_tac C_IH_monos THEN' REPEAT_ALL_NEW (eresolve_tac nesting_rel_monos)])))
    45     co_inducts)
    49     co_inducts)
    46   end;
    50   end;
    47 
    51 
    48 end;
    52 end;