src/HOL/BNF/Tools/bnf_gfp_rec_sugar_tactics.ML
changeset 54926 28b621fce2f9
parent 54925 c63223067cab
child 54953 a2f4cf3387fc
equal deleted inserted replaced
54925:c63223067cab 54926:28b621fce2f9
   128     eresolve_tac (map (fn thm => thm RS neq_eq_eq_contradict) distincts) THEN' atac ORELSE'
   128     eresolve_tac (map (fn thm => thm RS neq_eq_eq_contradict) distincts) THEN' atac ORELSE'
   129     etac notE THEN' atac ORELSE'
   129     etac notE THEN' atac ORELSE'
   130     (CHANGED o SELECT_GOAL (unfold_thms_tac ctxt
   130     (CHANGED o SELECT_GOAL (unfold_thms_tac ctxt
   131        (@{thms id_def o_def split_def sum.cases} @ map_comps @ map_idents)))));
   131        (@{thms id_def o_def split_def sum.cases} @ map_comps @ map_idents)))));
   132 
   132 
   133 fun mk_primcorec_ctr_of_dtr_tac ctxt m collapse maybe_disc_fun sel_funs =
   133 fun mk_primcorec_ctr_of_dtr_tac ctxt m collapse disc_fun_opt sel_funs =
   134   HEADGOAL (rtac ((if null sel_funs then collapse else collapse RS sym) RS trans) THEN'
   134   HEADGOAL (rtac ((if null sel_funs then collapse else collapse RS sym) RS trans) THEN'
   135     (the_default (K all_tac) (Option.map rtac maybe_disc_fun)) THEN' REPEAT_DETERM_N m o atac) THEN
   135     (the_default (K all_tac) (Option.map rtac disc_fun_opt)) THEN' REPEAT_DETERM_N m o atac) THEN
   136   unfold_thms_tac ctxt (Let_def :: sel_funs) THEN HEADGOAL (rtac refl);
   136   unfold_thms_tac ctxt (Let_def :: sel_funs) THEN HEADGOAL (rtac refl);
   137 
   137 
   138 fun inst_split_eq ctxt split =
   138 fun inst_split_eq ctxt split =
   139   (case prop_of split of
   139   (case prop_of split of
   140     @{const Trueprop} $ (Const (@{const_name HOL.eq}, _) $ (Var (_, Type (_, [T, _])) $ _) $ _) =>
   140     @{const Trueprop} $ (Const (@{const_name HOL.eq}, _) $ (Var (_, Type (_, [T, _])) $ _) $ _) =>
   166   end;
   166   end;
   167 
   167 
   168 fun rulify_nchotomy n = funpow (n - 1) (fn thm => thm RS @{thm Meson.make_pos_rule'});
   168 fun rulify_nchotomy n = funpow (n - 1) (fn thm => thm RS @{thm Meson.make_pos_rule'});
   169 
   169 
   170 fun mk_primcorec_raw_code_of_ctr_tac ctxt distincts discIs splits split_asms ms fun_ctrs
   170 fun mk_primcorec_raw_code_of_ctr_tac ctxt distincts discIs splits split_asms ms fun_ctrs
   171     maybe_nchotomy =
   171     nchotomy_opt =
   172   let
   172   let
   173     val n = length ms;
   173     val n = length ms;
   174     val (ms', fun_ctrs') =
   174     val (ms', fun_ctrs') =
   175       (case maybe_nchotomy of
   175       (case nchotomy_opt of
   176         NONE => (ms, fun_ctrs)
   176         NONE => (ms, fun_ctrs)
   177       | SOME nchotomy =>
   177       | SOME nchotomy =>
   178         (ms |> split_last ||> K [n - 1] |> op @,
   178         (ms |> split_last ||> K [n - 1] |> op @,
   179          fun_ctrs
   179          fun_ctrs
   180          |> split_last
   180          |> split_last