(* Title: HOL/Tools/BNF/bnf_fp_def_sugar_tactics.ML Author: Jasmin Blanchette, TU Muenchen Author: Martin Desharnais, TU Muenchen Copyright 2012, 2013, 2014
Tactics for datatype and codatatype sugar.
*)
signature BNF_FP_DEF_SUGAR_TACTICS = sig val sumprod_thms_rel: thm list
val co_induct_inst_as_projs_tac: Proof.context -> int -> tactic val mk_case_transfer_tac: Proof.context -> thm -> thm list -> tactic val mk_coinduct_discharge_prem_tac: Proof.context -> thm list -> thm list -> int -> int -> int ->
thm -> thm -> thm -> thm -> thm -> thm list -> thm listlist -> thm listlist -> int -> tactic val mk_coinduct_tac: Proof.context -> thm list -> int -> int list -> thm -> thm list ->
thm list -> thm list -> thm list -> thm list -> thm listlist -> thm listlistlist ->
thm listlistlist -> tactic val mk_corec_tac: thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context -> tactic val mk_corec_disc_iff_tac: thm list -> thm list -> thm list -> Proof.context -> tactic val mk_co_rec_o_map_tac: Proof.context -> thm -> thm list -> thm list -> thm list -> thm -> thm ->
thm Seq.seq val mk_corec_transfer_tac: Proof.context -> cterm list -> cterm list -> thm list -> thm list ->
thm list -> thm list -> thm list -> ''a list -> ''a listlist -> ''a listlistlistlist -> ''a listlistlistlist -> tactic val mk_ctor_iff_dtor_tac: Proof.context -> ctyp optionlist -> cterm -> cterm -> thm -> thm ->
tactic val mk_ctr_transfer_tac: Proof.context -> thm list -> thm list -> tactic val mk_disc_transfer_tac: Proof.context -> thm -> thm -> thm list -> tactic val mk_exhaust_tac: Proof.context -> int -> thm list -> thm -> thm -> tactic val mk_half_distinct_tac: Proof.context -> thm -> thm -> thm list -> tactic val mk_induct_discharge_prem_tac: Proof.context -> int -> int -> thm list -> thm list ->
thm list -> thm list -> int -> int -> int list -> tactic val mk_induct_tac: Proof.context -> int -> int list -> int listlist -> int listlistlist ->
thm list -> thm -> thm list -> thm list -> thm list -> thm listlist -> tactic val mk_inject_tac: Proof.context -> thm -> thm -> thm -> tactic val mk_map_tac: Proof.context -> thm list -> thm -> thm -> thm list -> thm list -> thm list ->
tactic val mk_map_disc_iff_tac: Proof.context -> cterm -> thm -> thm list -> thm list -> tactic val mk_map_sel_tac: Proof.context -> cterm -> thm -> thm list -> thm list -> thm list ->
thm list -> tactic val mk_rec_tac: thm list -> thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context ->
tactic val mk_rec_transfer_tac: Proof.context -> int -> int list -> cterm list -> cterm list ->
term listlistlistlist -> thm list -> thm list -> thm list -> thm list -> tactic val mk_rel_tac: Proof.context -> thm list -> thm -> thm -> thm list -> thm list -> thm list ->
tactic val mk_rel_case_tac: Proof.context -> cterm -> cterm -> thm -> thm list -> thm list -> thm list ->
thm list -> thm list -> tactic val mk_rel_coinduct0_tac: Proof.context -> thm -> cterm list -> thm list -> thm list ->
thm listlist -> thm listlist -> thm listlist -> thm list -> thm list -> thm list ->
thm list -> thm list -> thm list -> tactic val mk_rel_induct0_tac: Proof.context -> thm -> thm list -> cterm list -> thm list ->
thm listlist -> thm list -> thm list -> thm list -> thm list -> tactic val mk_rel_sel_tac: Proof.context -> cterm -> cterm -> thm -> thm list -> thm list -> thm list ->
thm list -> thm list -> thm list -> tactic val mk_sel_transfer_tac: Proof.context -> int -> thm list -> thm -> tactic val mk_set0_tac: Proof.context -> thm list -> thm list -> thm -> thm list -> thm list ->
thm list -> thm list -> thm list -> tactic val mk_set_cases_tac: Proof.context -> cterm -> thm list -> thm -> thm list -> tactic val mk_set_induct0_tac: Proof.context -> cterm list -> thm list -> thm list -> thm list ->
thm list -> thm list -> thm list -> thm list -> tactic val mk_set_intros_tac: Proof.context -> thm list -> tactic val mk_set_sel_tac: Proof.context -> cterm -> thm -> thm list -> thm list -> thm list -> tactic end;
fun mk_unfold_Inl_Inr_Pair_tac total pos =
HEADGOAL (Inl_Inr_Pair_tac THEN'
select_prem_tac ctxt total (dtac ctxt asm_rl) pos THEN'
dtac ctxt rel_funD THEN' assume_tac ctxt THEN' assume_tac ctxt);
fun mk_unfold_arg_tac qs gs =
EVERY (map (mk_unfold_If_tac num_pgs o prem_no_of) qs) THEN
EVERY (map (mk_unfold_Inl_Inr_Pair_tac num_pgs o prem_no_of) gs);
fun mk_unfold_ctr_tac type_definition qss gss =
HEADGOAL (rtac ctxt (mk_rel_funDN 1 (@{thm Abs_transfer} OF
[type_definition, type_definition])) THEN' Inl_Inr_Pair_tac) THEN
(case (qss, gss) of
([], []) => HEADGOAL (rtac ctxt refl)
| _ => EVERY (map2 mk_unfold_arg_tac qss gss));
fun mk_unfold_type_tac type_definition ps qsss gsss = let val p_tacs = map (mk_unfold_If_tac num_pgs o prem_no_of) ps; val qg_tacs = map2 (mk_unfold_ctr_tac type_definition) qsss gsss; fun mk_unfold_ty [] [qg_tac] = qg_tac
| mk_unfold_ty (p_tac :: p_tacs) (qg_tac :: qg_tacs) =
p_tac THEN qg_tac THEN mk_unfold_ty p_tacs qg_tacs in
HEADGOAL (rtac ctxt rel_funI) THEN mk_unfold_ty p_tacs qg_tacs end;
fun mk_unfold_corec_type_tac dtor_corec_transfer corec_def = let val active :: actives' = actives; val dtor_corec_transfer' =
infer_instantiate' ctxt
(SOME active :: map SOME passives @ map SOME actives') dtor_corec_transfer; in
HEADGOAL Goal.conjunction_tac THEN REPEAT_DETERM (HEADGOAL (rtac ctxt rel_funI)) THEN
unfold_thms_tac ctxt [corec_def] THEN
HEADGOAL (etac ctxt (mk_rel_funDN_rotated (1 + length actives) dtor_corec_transfer')) THEN
unfold_thms_tac ctxt (rel_pre_T_defs @ rel_eqs) end;
fun mk_unfold_prop_tac dtor_corec_transfer corec_def =
mk_unfold_corec_type_tac dtor_corec_transfer corec_def THEN
EVERY (@{map 4} mk_unfold_type_tac type_definitions pss qssss gssss); in
HEADGOAL Goal.conjunction_tac THEN
EVERY (map2 mk_unfold_prop_tac dtor_corec_transfers corec_defs) end;
fun mk_induct_discharge_prem_tac ctxt nn n pre_abs_inverses abs_inverses set_maps pre_set_defs m k
kks = letval r = length kks in
HEADGOAL (EVERY' [select_prem_tac ctxt n (rotate_tac 1) k, rotate_tac ~1, hyp_subst_tac ctxt,
REPEAT_DETERM_N m o (dtac ctxt meta_spec THEN' rotate_tac ~1)]) THEN
EVERY [REPEAT_DETERM_N r
(HEADGOAL (rotate_tac ~1 THEN' dtac ctxt meta_mp THEN' rotate_tac 1) THEN prefer_tac 2), if r > 0 then ALLGOALS (Goal.norm_hhf_tac ctxt) else all_tac, HEADGOAL (assume_tac ctxt),
mk_induct_leverage_prem_prems_tac ctxt nn kks pre_abs_inverses abs_inverses set_maps
pre_set_defs] end;
fun mk_induct_tac ctxt nn ns mss kksss ctr_defs ctor_induct' pre_abs_inverses abs_inverses set_maps
pre_set_defss = letval n = Integer.sum ns in
(ifexists is_def_looping ctr_defs then
EVERY (map (fn def => HEADGOAL (subst_asm_tac ctxt NONE [def])) ctr_defs) else
unfold_thms_tac ctxt ctr_defs) THEN
HEADGOAL (rtac ctxt ctor_induct') THEN co_induct_inst_as_projs_tac ctxt 0 THEN
EVERY (@{map 4} (EVERY oooo @{map 3} o
mk_induct_discharge_prem_tac ctxt nn n pre_abs_inverses abs_inverses set_maps)
pre_set_defss mss (unflat mss (1 upto n)) kksss) end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.