src/HOL/Tools/BNF/bnf_fp_def_sugar_tactics.ML
changeset 59582 0fbed69ff081
parent 59580 cbc38731d42f
child 59621 291934bac95e
equal deleted inserted replaced
59580:cbc38731d42f 59582:0fbed69ff081
    92     Conv.arg_conv (Conv.abs_conv (hhf_concl_conv cv o snd) ctxt) ct
    92     Conv.arg_conv (Conv.abs_conv (hhf_concl_conv cv o snd) ctxt) ct
    93   | _ => Conv.concl_conv ~1 cv ct);
    93   | _ => Conv.concl_conv ~1 cv ct);
    94 
    94 
    95 fun co_induct_inst_as_projs ctxt k thm =
    95 fun co_induct_inst_as_projs ctxt k thm =
    96   let
    96   let
    97     val fs = Term.add_vars (prop_of thm) []
    97     val fs = Term.add_vars (Thm.prop_of thm) []
    98       |> filter (fn (_, Type (@{type_name fun}, [_, T'])) => T' <> HOLogic.boolT | _ => false);
    98       |> filter (fn (_, Type (@{type_name fun}, [_, T'])) => T' <> HOLogic.boolT | _ => false);
    99     fun mk_cfp (f as (_, T)) =
    99     fun mk_cfp (f as (_, T)) =
   100       (Proof_Context.cterm_of ctxt (Var f), Proof_Context.cterm_of ctxt (mk_proj T (num_binder_types T) k));
   100       (Proof_Context.cterm_of ctxt (Var f), Proof_Context.cterm_of ctxt (mk_proj T (num_binder_types T) k));
   101     val cfps = map mk_cfp fs;
   101     val cfps = map mk_cfp fs;
   102   in
   102   in
   105 
   105 
   106 val co_induct_inst_as_projs_tac = PRIMITIVE oo co_induct_inst_as_projs;
   106 val co_induct_inst_as_projs_tac = PRIMITIVE oo co_induct_inst_as_projs;
   107 
   107 
   108 fun mk_case_transfer_tac ctxt rel_cases cases =
   108 fun mk_case_transfer_tac ctxt rel_cases cases =
   109   let
   109   let
   110     val n = length (tl (prems_of rel_cases));
   110     val n = length (tl (Thm.prems_of rel_cases));
   111   in
   111   in
   112     REPEAT_DETERM (HEADGOAL (rtac rel_funI)) THEN
   112     REPEAT_DETERM (HEADGOAL (rtac rel_funI)) THEN
   113     HEADGOAL (etac rel_cases) THEN
   113     HEADGOAL (etac rel_cases) THEN
   114     ALLGOALS (hyp_subst_tac ctxt) THEN
   114     ALLGOALS (hyp_subst_tac ctxt) THEN
   115     unfold_thms_tac ctxt cases THEN
   115     unfold_thms_tac ctxt cases THEN
   510     Abs_pre_inverses =
   510     Abs_pre_inverses =
   511   let
   511   let
   512     val assms_tac =
   512     val assms_tac =
   513       let val assms' = map (unfold_thms ctxt (@{thm id_bnf_def} :: ctor_defs)) assms in
   513       let val assms' = map (unfold_thms ctxt (@{thm id_bnf_def} :: ctor_defs)) assms in
   514         fold (curry (op ORELSE')) (map (fn thm =>
   514         fold (curry (op ORELSE')) (map (fn thm =>
   515             funpow (length (prems_of thm)) (fn tac => tac THEN' atac) (rtac thm)) assms')
   515             funpow (length (Thm.prems_of thm)) (fn tac => tac THEN' atac) (rtac thm)) assms')
   516           (etac FalseE)
   516           (etac FalseE)
   517       end;
   517       end;
   518     val exhausts' = map (fn thm => thm RS @{thm asm_rl[of "P x y" for P x y]}) exhausts
   518     val exhausts' = map (fn thm => thm RS @{thm asm_rl[of "P x y" for P x y]}) exhausts
   519       |> map2 (fn ct => cterm_instantiate_pos [NONE, SOME ct]) cts;
   519       |> map2 (fn ct => cterm_instantiate_pos [NONE, SOME ct]) cts;
   520   in
   520   in