src/HOL/Tools/datatype_package.ML
changeset 25677 8b2ddc6e7be1
parent 25537 55017c8b0a24
child 25888 48cc198b9ac5
equal deleted inserted replaced
25676:f3815084e89e 25677:8b2ddc6e7be1
   454   end;
   454   end;
   455 
   455 
   456 
   456 
   457 (**** make datatype info ****)
   457 (**** make datatype info ****)
   458 
   458 
   459 fun make_dt_info head_len descr sorts induct reccomb_names rec_thms
   459 fun make_dt_info alt_names descr sorts induct reccomb_names rec_thms
   460     (((((((((i, (_, (tname, _, _))), case_name), case_thms),
   460     (((((((((i, (_, (tname, _, _))), case_name), case_thms),
   461       exhaustion_thm), distinct_thm), inject), nchotomy), case_cong), weak_case_cong) =
   461       exhaustion_thm), distinct_thm), inject), nchotomy), case_cong), weak_case_cong) =
   462   (tname,
   462   (tname,
   463    {index = i,
   463    {index = i,
   464     head_len = head_len,
   464     alt_names = alt_names,
   465     descr = descr,
   465     descr = descr,
   466     sorts = sorts,
   466     sorts = sorts,
   467     rec_names = reccomb_names,
   467     rec_names = reccomb_names,
   468     rec_rewrites = rec_thms,
   468     rec_rewrites = rec_thms,
   469     case_name = case_name,
   469     case_name = case_name,
   618     val (case_congs, thy10) = add_and_get_axioms "case_cong" new_type_names
   618     val (case_congs, thy10) = add_and_get_axioms "case_cong" new_type_names
   619       (DatatypeProp.make_case_congs new_type_names descr sorts thy9) thy9;
   619       (DatatypeProp.make_case_congs new_type_names descr sorts thy9) thy9;
   620     val (weak_case_congs, thy11) = add_and_get_axioms "weak_case_cong" new_type_names
   620     val (weak_case_congs, thy11) = add_and_get_axioms "weak_case_cong" new_type_names
   621       (DatatypeProp.make_weak_case_congs new_type_names descr sorts thy10) thy10;
   621       (DatatypeProp.make_weak_case_congs new_type_names descr sorts thy10) thy10;
   622 
   622 
   623     val dt_infos = map (make_dt_info (length (hd descr)) descr' sorts induct
   623     val dt_infos = map (make_dt_info NONE descr' sorts induct reccomb_names' rec_thms)
   624         reccomb_names' rec_thms)
       
   625       ((0 upto length (hd descr) - 1) ~~ (hd descr) ~~ case_names' ~~ case_thms ~~
   624       ((0 upto length (hd descr) - 1) ~~ (hd descr) ~~ case_names' ~~ case_thms ~~
   626         exhaustion ~~ replicate (length (hd descr)) QuickAndDirty ~~ inject ~~
   625         exhaustion ~~ replicate (length (hd descr)) QuickAndDirty ~~ inject ~~
   627           nchotomys ~~ case_congs ~~ weak_case_congs);
   626           nchotomys ~~ case_congs ~~ weak_case_congs);
   628 
   627 
   629     val simps = flat (distinct @ inject @ case_thms) @ rec_thms;
   628     val simps = flat (distinct @ inject @ case_thms) @ rec_thms;
   678     val (case_congs, thy9) = DatatypeAbsProofs.prove_case_congs new_type_names
   677     val (case_congs, thy9) = DatatypeAbsProofs.prove_case_congs new_type_names
   679       descr sorts nchotomys case_thms thy8;
   678       descr sorts nchotomys case_thms thy8;
   680     val (weak_case_congs, thy10) = DatatypeAbsProofs.prove_weak_case_congs new_type_names
   679     val (weak_case_congs, thy10) = DatatypeAbsProofs.prove_weak_case_congs new_type_names
   681       descr sorts thy9;
   680       descr sorts thy9;
   682 
   681 
   683     val dt_infos = map (make_dt_info (length (hd descr)) (flat descr) sorts induct
   682     val dt_infos = map (make_dt_info NONE (flat descr) sorts induct reccomb_names rec_thms)
   684         reccomb_names rec_thms)
       
   685       ((0 upto length (hd descr) - 1) ~~ (hd descr) ~~ case_names ~~ case_thms ~~
   683       ((0 upto length (hd descr) - 1) ~~ (hd descr) ~~ case_names ~~ case_thms ~~
   686         casedist_thms ~~ simproc_dists ~~ inject ~~ nchotomys ~~ case_congs ~~ weak_case_congs);
   684         casedist_thms ~~ simproc_dists ~~ inject ~~ nchotomys ~~ case_congs ~~ weak_case_congs);
   687 
   685 
   688     val simps = flat (distinct @ inject @ case_thms) @ rec_thms;
   686     val simps = flat (distinct @ inject @ case_thms) @ rec_thms;
   689 
   687 
   779       |> store_thmss "inject" new_type_names inject
   777       |> store_thmss "inject" new_type_names inject
   780       ||>> store_thmss "distinct" new_type_names distinct
   778       ||>> store_thmss "distinct" new_type_names distinct
   781       ||> Sign.add_path (space_implode "_" new_type_names)
   779       ||> Sign.add_path (space_implode "_" new_type_names)
   782       ||>> PureThy.add_thms [(("induct", induction), [case_names_induct])];
   780       ||>> PureThy.add_thms [(("induct", induction), [case_names_induct])];
   783 
   781 
   784     val dt_infos = map (make_dt_info (length descr) descr sorts induction'
   782     val dt_infos = map (make_dt_info alt_names descr sorts induction' reccomb_names rec_thms)
   785         reccomb_names rec_thms)
       
   786       ((0 upto length descr - 1) ~~ descr ~~ case_names ~~ case_thms ~~ casedist_thms ~~
   783       ((0 upto length descr - 1) ~~ descr ~~ case_names ~~ case_thms ~~ casedist_thms ~~
   787         map FewConstrs distinct ~~ inject ~~ nchotomys ~~ case_congs ~~ weak_case_congs);
   784         map FewConstrs distinct ~~ inject ~~ nchotomys ~~ case_congs ~~ weak_case_congs);
   788 
   785 
   789     val simps = flat (distinct @ inject @ case_thms) @ rec_thms;
   786     val simps = flat (distinct @ inject @ case_thms) @ rec_thms;
   790 
   787