src/HOL/Tools/datatype_package.ML
changeset 11345 cd605c85e421
parent 10930 7c7a7b0e1d0c
child 11539 0f17da240450
equal deleted inserted replaced
11344:57b7ad51971c 11345:cd605c85e421
   283   map (RuleCases.case_names o exhaust_cases descr o #1)
   283   map (RuleCases.case_names o exhaust_cases descr o #1)
   284     (filter (fn ((_, (name, _, _))) => name mem_string new) descr);
   284     (filter (fn ((_, (name, _, _))) => name mem_string new) descr);
   285 
   285 
   286 end;
   286 end;
   287 
   287 
       
   288 fun add_rules simps case_thms size_thms rec_thms inject distinct
       
   289                   weak_case_congs cong_att =
       
   290   (#1 o PureThy.add_thmss [(("simps", simps), []),
       
   291     (("", flat case_thms @ size_thms @ 
       
   292           flat distinct  @ rec_thms), [Simplifier.simp_add_global]),
       
   293     (("", flat inject),               [iff_add_global]),
       
   294     (("", flat distinct RL [notE]),   [Classical.safe_elim_global]),
       
   295     (("", weak_case_congs),           [cong_att])]);
       
   296 
   288 
   297 
   289 (* add_cases_induct *)
   298 (* add_cases_induct *)
   290 
   299 
   291 fun add_cases_induct infos =
   300 fun add_cases_induct infos =
   292   let
   301   let
   568     val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms;
   577     val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms;
   569     val split_thms = split ~~ split_asm;
   578     val split_thms = split ~~ split_asm;
   570 
   579 
   571     val thy12 = thy11 |>
   580     val thy12 = thy11 |>
   572       Theory.add_path (space_implode "_" new_type_names) |>
   581       Theory.add_path (space_implode "_" new_type_names) |>
   573       (#1 o PureThy.add_thmss [(("simps", simps), []),
   582       add_rules simps case_thms size_thms rec_thms inject distinct
   574         (("", flat case_thms @ size_thms @ rec_thms), [Simplifier.simp_add_global]),
   583                 weak_case_congs Simplifier.cong_add_global |> 
   575         (("", flat (inject @ distinct)), [iff_add_global]),
       
   576         (("", weak_case_congs), [Simplifier.cong_add_global])]) |>
       
   577       put_datatypes (foldr Symtab.update (dt_infos, dt_info)) |>
   584       put_datatypes (foldr Symtab.update (dt_infos, dt_info)) |>
   578       add_cases_induct dt_infos |>
   585       add_cases_induct dt_infos |>
   579       Theory.parent_path |>
   586       Theory.parent_path |>
   580       (#1 o store_thmss "splits" new_type_names (map (fn (x, y) => [x, y]) split_thms));
   587       (#1 o store_thmss "splits" new_type_names (map (fn (x, y) => [x, y]) split_thms));
   581   in
   588   in
   626 
   633 
   627     val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms;
   634     val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms;
   628 
   635 
   629     val thy12 = thy11 |>
   636     val thy12 = thy11 |>
   630       Theory.add_path (space_implode "_" new_type_names) |>
   637       Theory.add_path (space_implode "_" new_type_names) |>
   631       (#1 o PureThy.add_thmss [(("simps", simps), []),
   638       add_rules simps case_thms size_thms rec_thms inject distinct
   632         (("", flat case_thms @ size_thms @ rec_thms), [Simplifier.simp_add_global]),
   639                 weak_case_congs (Simplifier.change_global_ss (op addcongs)) |> 
   633         (("", flat (inject @ distinct)), [iff_add_global]),
       
   634         (("", weak_case_congs), [Simplifier.change_global_ss (op addcongs)])]) |>
       
   635       put_datatypes (foldr Symtab.update (dt_infos, dt_info)) |>
   640       put_datatypes (foldr Symtab.update (dt_infos, dt_info)) |>
   636       add_cases_induct dt_infos |>
   641       add_cases_induct dt_infos |>
   637       Theory.parent_path |>
   642       Theory.parent_path |>
   638       (#1 o store_thmss "splits" new_type_names (map (fn (x, y) => [x, y]) split_thms));
   643       (#1 o store_thmss "splits" new_type_names (map (fn (x, y) => [x, y]) split_thms));
   639   in
   644   in
   732         map FewConstrs distinct ~~ inject ~~ nchotomys ~~ case_congs ~~ weak_case_congs);
   737         map FewConstrs distinct ~~ inject ~~ nchotomys ~~ case_congs ~~ weak_case_congs);
   733 
   738 
   734     val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms;
   739     val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms;
   735 
   740 
   736     val thy11 = thy10 |>
   741     val thy11 = thy10 |>
   737       (#1 o PureThy.add_thmss [(("simps", simps), []),
   742       add_rules simps case_thms size_thms rec_thms inject distinct
   738         (("", flat case_thms @ size_thms @ rec_thms), [Simplifier.simp_add_global]),
   743                 weak_case_congs (Simplifier.change_global_ss (op addcongs)) |> 
   739         (("", flat (inject @ distinct)), [iff_add_global]),
       
   740         (("", weak_case_congs), [Simplifier.change_global_ss (op addcongs)])]) |>
       
   741       put_datatypes (foldr Symtab.update (dt_infos, dt_info)) |>
   744       put_datatypes (foldr Symtab.update (dt_infos, dt_info)) |>
   742       add_cases_induct dt_infos |>
   745       add_cases_induct dt_infos |>
   743       Theory.parent_path |>
   746       Theory.parent_path |>
   744       (#1 o store_thmss "splits" new_type_names (map (fn (x, y) => [x, y]) split_thms));
   747       (#1 o store_thmss "splits" new_type_names (map (fn (x, y) => [x, y]) split_thms));
   745   in
   748   in