src/HOL/Codatatype/Tools/bnf_lfp_tactics.ML
changeset 49227 2652319c394e
parent 48975 7f79f94a432c
child 49306 c13fff97a8df
equal deleted inserted replaced
49226:510c6d4a73ec 49227:2652319c394e
    20   val mk_copy_str_tac: thm list list -> thm -> thm list -> tactic
    20   val mk_copy_str_tac: thm list list -> thm -> thm list -> tactic
    21   val mk_ex_copy_alg_tac: int -> thm -> thm -> tactic
    21   val mk_ex_copy_alg_tac: int -> thm -> thm -> tactic
    22   val mk_fld_induct2_tac: ctyp option list -> cterm option list -> thm -> thm list ->
    22   val mk_fld_induct2_tac: ctyp option list -> cterm option list -> thm -> thm list ->
    23     {prems: 'a, context: Proof.context} -> tactic
    23     {prems: 'a, context: Proof.context} -> tactic
    24   val mk_fld_induct_tac: int -> thm list list -> thm -> thm list -> thm -> thm list -> thm list ->
    24   val mk_fld_induct_tac: int -> thm list list -> thm -> thm list -> thm -> thm list -> thm list ->
    25     thm list -> thm list -> thm list -> tactic
    25     thm list -> tactic
    26   val mk_in_bd_tac: thm -> thm -> thm -> thm -> tactic
    26   val mk_in_bd_tac: thm -> thm -> thm -> thm -> tactic
    27   val mk_incl_min_alg_tac: (int -> tactic) -> thm list list list -> thm list -> thm ->
    27   val mk_incl_min_alg_tac: (int -> tactic) -> thm list list list -> thm list -> thm ->
    28     {prems: 'a, context: Proof.context} -> tactic
    28     {prems: 'a, context: Proof.context} -> tactic
    29   val mk_init_ex_mor_tac: thm -> thm -> thm -> thm list -> thm -> thm -> thm ->
    29   val mk_init_ex_mor_tac: thm -> thm -> thm -> thm list -> thm -> thm -> thm ->
    30     {prems: 'a, context: Proof.context} -> tactic
    30     {prems: 'a, context: Proof.context} -> tactic
    31   val mk_init_induct_tac: int -> thm -> thm -> thm list -> thm list -> tactic
    31   val mk_init_induct_tac: int -> thm -> thm -> thm list -> thm list -> tactic
    32   val mk_init_unique_mor_tac: int -> thm -> thm -> thm list -> thm list -> thm list -> thm list ->
    32   val mk_init_unique_mor_tac: int -> thm -> thm -> thm list -> thm list -> thm list -> thm list ->
    33     thm list -> tactic
    33     thm list -> tactic
    34   val mk_iso_alt_tac: thm list -> thm -> tactic
    34   val mk_iso_alt_tac: thm list -> thm -> tactic
    35   val mk_iter_unique_mor_tac: thm list -> thm list -> thm list -> thm list -> thm -> thm -> thm ->
    35   val mk_iter_unique_mor_tac: thm list -> thm list -> thm list -> thm -> thm -> thm -> tactic
    36     tactic
       
    37   val mk_least_min_alg_tac: thm -> thm -> tactic
    36   val mk_least_min_alg_tac: thm -> thm -> tactic
    38   val mk_lfp_map_wpull_tac: int -> (int -> tactic) -> thm list -> thm list -> thm list list ->
    37   val mk_lfp_map_wpull_tac: int -> (int -> tactic) -> thm list -> thm list -> thm list list ->
    39     thm list list list -> thm list -> tactic
    38     thm list list list -> thm list -> tactic
    40   val mk_map_comp_tac: thm list -> thm list -> thm -> int -> tactic
    39   val mk_map_comp_tac: thm list -> thm list -> thm -> int -> tactic
    41   val mk_map_id_tac: thm list -> thm -> tactic
    40   val mk_map_id_tac: thm list -> thm -> tactic
   495 fun mk_mor_iter_tac cT ct iter_defs ex_mor mor =
   494 fun mk_mor_iter_tac cT ct iter_defs ex_mor mor =
   496   (EVERY' (map stac iter_defs) THEN' EVERY' [rtac rev_mp, rtac ex_mor, rtac impI] THEN'
   495   (EVERY' (map stac iter_defs) THEN' EVERY' [rtac rev_mp, rtac ex_mor, rtac impI] THEN'
   497   REPEAT_DETERM_N (length iter_defs) o etac exE THEN'
   496   REPEAT_DETERM_N (length iter_defs) o etac exE THEN'
   498   rtac (Drule.instantiate' [SOME cT] [SOME ct] @{thm someI}) THEN' etac mor) 1;
   497   rtac (Drule.instantiate' [SOME cT] [SOME ct] @{thm someI}) THEN' etac mor) 1;
   499 
   498 
   500 fun mk_iter_unique_mor_tac type_defs init_unique_mors subsets Reps mor_comp mor_Abs mor_iter =
   499 fun mk_iter_unique_mor_tac type_defs init_unique_mors Reps mor_comp mor_Abs mor_iter =
   501   let
   500   let
   502     fun mk_subset subset Rep = etac subset ORELSE' rtac (Rep RS subset);
       
   503     fun mk_unique type_def =
   501     fun mk_unique type_def =
   504       EVERY' [rtac @{thm surj_fun_eq}, rtac (type_def RS @{thm type_definition.Abs_image}),
   502       EVERY' [rtac @{thm surj_fun_eq}, rtac (type_def RS @{thm type_definition.Abs_image}),
   505         rtac ballI, resolve_tac init_unique_mors, EVERY' (map2 mk_subset subsets Reps),
   503         rtac ballI, resolve_tac init_unique_mors,
       
   504         EVERY' (map (fn thm => atac ORELSE' rtac thm) Reps),
   506         rtac mor_comp, rtac mor_Abs, atac,
   505         rtac mor_comp, rtac mor_Abs, atac,
   507         rtac mor_comp, rtac mor_Abs, rtac mor_iter];
   506         rtac mor_comp, rtac mor_Abs, rtac mor_iter];
   508   in
   507   in
   509     CONJ_WRAP' mk_unique type_defs 1
   508     CONJ_WRAP' mk_unique type_defs 1
   510   end;
   509   end;
   520   Local_Defs.unfold_tac ctxt
   519   Local_Defs.unfold_tac ctxt
   521     (rec_defs @ map (fn thm => thm RS @{thm convol_expand_snd}) fst_recs) THEN
   520     (rec_defs @ map (fn thm => thm RS @{thm convol_expand_snd}) fst_recs) THEN
   522   EVERY' [rtac trans, rtac o_apply, rtac trans, rtac (iter RS @{thm arg_cong[of _ _ snd]}),
   521   EVERY' [rtac trans, rtac o_apply, rtac trans, rtac (iter RS @{thm arg_cong[of _ _ snd]}),
   523     rtac @{thm snd_convol'}] 1;
   522     rtac @{thm snd_convol'}] 1;
   524 
   523 
   525 fun mk_fld_induct_tac m set_natural'ss init_induct morEs mor_Abs Rep_invs Abs_invs Reps
   524 fun mk_fld_induct_tac m set_natural'ss init_induct morEs mor_Abs Rep_invs Abs_invs Reps =
   526     subset1s subset2s =
       
   527   let
   525   let
   528     val n = length set_natural'ss;
   526     val n = length set_natural'ss;
   529     val ks = 1 upto n;
   527     val ks = 1 upto n;
   530 
   528 
   531     fun mk_IH_tac Rep_inv Abs_inv set_natural' subset =
   529     fun mk_IH_tac Rep_inv Abs_inv set_natural' =
   532       DETERM o EVERY' [dtac @{thm meta_mp}, rtac (Rep_inv RS arg_cong RS subst), etac bspec,
   530       DETERM o EVERY' [dtac @{thm meta_mp}, rtac (Rep_inv RS arg_cong RS subst), etac bspec,
   533         dtac @{thm set_rev_mp}, rtac equalityD1, rtac set_natural', etac imageE,
   531         dtac @{thm set_rev_mp}, rtac equalityD1, rtac set_natural', etac imageE,
   534         hyp_subst_tac, rtac (Abs_inv RS ssubst), rtac subset, etac @{thm set_mp},
   532         hyp_subst_tac, rtac (Abs_inv RS ssubst), etac @{thm set_mp},
   535         atac, atac];
   533         atac, atac];
   536 
   534 
   537     fun mk_closed_tac (k, (morE, set_natural's)) =
   535     fun mk_closed_tac (k, (morE, set_natural's)) =
   538       EVERY' [select_prem_tac n (dtac asm_rl) k, rtac ballI, rtac impI,
   536       EVERY' [select_prem_tac n (dtac asm_rl) k, rtac ballI, rtac impI,
   539         rtac (mor_Abs RS morE RS arg_cong RS ssubst), atac,
   537         rtac (mor_Abs RS morE RS arg_cong RS ssubst), atac,
   540         REPEAT_DETERM o eresolve_tac [CollectE, conjE], dtac @{thm meta_spec},
   538         REPEAT_DETERM o eresolve_tac [CollectE, conjE], dtac @{thm meta_spec},
   541         EVERY' (map4 mk_IH_tac Rep_invs Abs_invs (drop m set_natural's) subset1s), atac];
   539         EVERY' (map3 mk_IH_tac Rep_invs Abs_invs (drop m set_natural's)), atac];
   542 
   540 
   543     fun mk_induct_tac ((Rep, Rep_inv), subset) =
   541     fun mk_induct_tac (Rep, Rep_inv) =
   544       EVERY' [rtac (Rep_inv RS arg_cong RS subst), etac (Rep RS subset RSN (2, bspec))];
   542       EVERY' [rtac (Rep_inv RS arg_cong RS subst), etac (Rep RSN (2, bspec))];
   545   in
   543   in
   546     (rtac mp THEN' rtac impI THEN'
   544     (rtac mp THEN' rtac impI THEN'
   547     DETERM o CONJ_WRAP_GEN' (etac conjE THEN' rtac conjI) mk_induct_tac
   545     DETERM o CONJ_WRAP_GEN' (etac conjE THEN' rtac conjI) mk_induct_tac (Reps ~~ Rep_invs) THEN'
   548       ((Reps ~~ Rep_invs) ~~ subset2s) THEN'
       
   549     rtac init_induct THEN'
   546     rtac init_induct THEN'
   550     DETERM o CONJ_WRAP' mk_closed_tac
   547     DETERM o CONJ_WRAP' mk_closed_tac (ks ~~ (morEs ~~ set_natural'ss))) 1
   551       (ks ~~ (morEs ~~ set_natural'ss))) 1
       
   552   end;
   548   end;
   553 
   549 
   554 fun mk_fld_induct2_tac cTs cts fld_induct weak_fld_inducts {context = ctxt, prems = _} =
   550 fun mk_fld_induct2_tac cTs cts fld_induct weak_fld_inducts {context = ctxt, prems = _} =
   555   let
   551   let
   556     val n = length weak_fld_inducts;
   552     val n = length weak_fld_inducts;