src/HOL/Tools/BNF/bnf_fp_def_sugar_tactics.ML
changeset 58093 6f37a300c82b
parent 58044 b5cdfb352814
child 58095 b280d4028443
equal deleted inserted replaced
58092:4ae52c60603a 58093:6f37a300c82b
    11   val sumprod_thms_map: thm list
    11   val sumprod_thms_map: thm list
    12   val sumprod_thms_set: thm list
    12   val sumprod_thms_set: thm list
    13   val basic_sumprod_thms_set: thm list
    13   val basic_sumprod_thms_set: thm list
    14   val sumprod_thms_rel: thm list
    14   val sumprod_thms_rel: thm list
    15 
    15 
       
    16   val mk_case_transfer_tac: Proof.context -> thm -> thm list -> tactic
    16   val mk_coinduct_tac: Proof.context -> thm list -> int -> int list -> thm -> thm list ->
    17   val mk_coinduct_tac: Proof.context -> thm list -> int -> int list -> thm -> thm list ->
    17     thm list -> thm list -> thm list -> thm list -> thm list list -> thm list list list ->
    18     thm list -> thm list -> thm list -> thm list -> thm list list -> thm list list list ->
    18     thm list list list -> tactic
    19     thm list list list -> tactic
    19   val mk_corec_tac: thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context -> tactic
    20   val mk_corec_tac: thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context -> tactic
    20   val mk_corec_disc_iff_tac: thm list -> thm list -> thm list -> Proof.context -> tactic
    21   val mk_corec_disc_iff_tac: thm list -> thm list -> thm list -> Proof.context -> tactic
    82     Drule.cterm_instantiate cfps thm
    83     Drule.cterm_instantiate cfps thm
    83   end;
    84   end;
    84 
    85 
    85 val co_induct_inst_as_projs_tac = PRIMITIVE oo co_induct_inst_as_projs;
    86 val co_induct_inst_as_projs_tac = PRIMITIVE oo co_induct_inst_as_projs;
    86 
    87 
       
    88 fun mk_case_transfer_tac ctxt rel_cases cases =
       
    89   let
       
    90     val n = length (tl (prems_of rel_cases));
       
    91   in
       
    92     REPEAT_DETERM (HEADGOAL (rtac @{thm rel_funI})) THEN
       
    93     HEADGOAL (etac rel_cases) THEN
       
    94     ALLGOALS (hyp_subst_tac ctxt) THEN
       
    95     unfold_thms_tac ctxt cases THEN
       
    96     ALLGOALS (fn k => (select_prem_tac n (dtac asm_rl) k THEN' rotate_tac ~1) k) THEN
       
    97     ALLGOALS (REPEAT_ALL_NEW (atac ORELSE' rtac refl ORELSE' dtac @{thm rel_funD}))
       
    98   end;
       
    99 
    87 fun mk_exhaust_tac ctxt n ctr_defs ctor_iff_dtor sumEN' =
   100 fun mk_exhaust_tac ctxt n ctr_defs ctor_iff_dtor sumEN' =
    88   unfold_thms_tac ctxt (ctor_iff_dtor :: ctr_defs) THEN HEADGOAL (rtac sumEN') THEN
   101   unfold_thms_tac ctxt (ctor_iff_dtor :: ctr_defs) THEN HEADGOAL (rtac sumEN') THEN
    89   HEADGOAL (EVERY' (maps (fn k => [select_prem_tac n (rotate_tac 1) k,
   102   HEADGOAL (EVERY' (maps (fn k => [select_prem_tac n (rotate_tac 1) k,
    90     REPEAT_DETERM o dtac meta_spec, etac meta_mp, atac]) (1 upto n)));
   103     REPEAT_DETERM o dtac meta_spec, etac meta_mp, atac]) (1 upto n)));
    91 
   104 
   254     dtor_ctors ctor_injects abs_injects rel_pre_defs abs_inverses nesting_rel_eqs =
   267     dtor_ctors ctor_injects abs_injects rel_pre_defs abs_inverses nesting_rel_eqs =
   255   rtac dtor_rel_coinduct 1 THEN
   268   rtac dtor_rel_coinduct 1 THEN
   256    EVERY (map11 (fn ct => fn assm => fn exhaust => fn discs => fn sels => fn ctor_defs =>
   269    EVERY (map11 (fn ct => fn assm => fn exhaust => fn discs => fn sels => fn ctor_defs =>
   257      fn dtor_ctor => fn ctor_inject => fn abs_inject => fn rel_pre_def => fn abs_inverse =>
   270      fn dtor_ctor => fn ctor_inject => fn abs_inject => fn rel_pre_def => fn abs_inverse =>
   258       (rtac exhaust THEN_ALL_NEW (rtac exhaust THEN_ALL_NEW
   271       (rtac exhaust THEN_ALL_NEW (rtac exhaust THEN_ALL_NEW
   259          (dtac (rotate_prems (~1) (cterm_instantiate_pos [NONE, NONE, NONE, NONE, SOME ct]
   272          (dtac (rotate_prems ~1 (cterm_instantiate_pos [NONE, NONE, NONE, NONE, SOME ct]
   260             @{thm arg_cong2} RS iffD1)) THEN'
   273             @{thm arg_cong2} RS iffD1)) THEN'
   261           atac THEN' atac THEN' hyp_subst_tac ctxt THEN' dtac assm THEN'
   274           atac THEN' atac THEN' hyp_subst_tac ctxt THEN' dtac assm THEN'
   262           REPEAT_DETERM o etac conjE))) 1 THEN
   275           REPEAT_DETERM o etac conjE))) 1 THEN
   263       unfold_thms_tac ctxt ((discs RL [eqTrueI, eqFalseI]) @ sels @ simp_thms') THEN
   276       unfold_thms_tac ctxt ((discs RL [eqTrueI, eqFalseI]) @ sels @ simp_thms') THEN
   264       unfold_thms_tac ctxt (dtor_ctor :: rel_pre_def :: abs_inverse :: ctor_inject ::
   277       unfold_thms_tac ctxt (dtor_ctor :: rel_pre_def :: abs_inverse :: ctor_inject ::