src/ZF/Tools/datatype_package.ML
changeset 56239 17df7145a871
parent 54742 7a86358a3c0b
child 56249 0fda98dd2c93
equal deleted inserted replaced
56237:69a9dfe71aed 56239:17df7145a871
   242   val need_recursor = (not coind andalso recursor_typ <> case_typ);
   242   val need_recursor = (not coind andalso recursor_typ <> case_typ);
   243 
   243 
   244   fun add_recursor thy =
   244   fun add_recursor thy =
   245     if need_recursor then
   245     if need_recursor then
   246       thy
   246       thy
   247       |> Sign.add_consts_i
   247       |> Sign.add_consts [(Binding.name recursor_base_name, recursor_typ, NoSyn)]
   248         [(Binding.name recursor_base_name, recursor_typ, NoSyn)]
       
   249       |> (snd o Global_Theory.add_defs false [(Thm.no_attributes o apfst Binding.name) recursor_def])
   248       |> (snd o Global_Theory.add_defs false [(Thm.no_attributes o apfst Binding.name) recursor_def])
   250     else thy;
   249     else thy;
   251 
   250 
   252   val (con_defs, thy0) = thy_path
   251   val (con_defs, thy0) = thy_path
   253              |> Sign.add_consts_i
   252     |> Sign.add_consts
   254                  (map (fn (c, T, mx) => (Binding.name c, T, mx))
   253         (map (fn (c, T, mx) => (Binding.name c, T, mx))
   255                   ((case_base_name, case_typ, NoSyn) :: map #1 (flat con_ty_lists)))
   254          ((case_base_name, case_typ, NoSyn) :: map #1 (flat con_ty_lists)))
   256              |> Global_Theory.add_defs false
   255     |> Global_Theory.add_defs false
   257                  (map (Thm.no_attributes o apfst Binding.name)
   256         (map (Thm.no_attributes o apfst Binding.name)
   258                   (case_def ::
   257          (case_def ::
   259                    flat (ListPair.map mk_con_defs (1 upto npart, con_ty_lists))))
   258           flat (ListPair.map mk_con_defs (1 upto npart, con_ty_lists))))
   260              ||> add_recursor
   259     ||> add_recursor
   261              ||> Sign.parent_path
   260     ||> Sign.parent_path;
   262 
   261 
   263   val intr_names = map (Binding.name o #2) (flat con_ty_lists);
   262   val intr_names = map (Binding.name o #2) (flat con_ty_lists);
   264   val (thy1, ind_result) =
   263   val (thy1, ind_result) =
   265     thy0 |> Ind_Package.add_inductive_i
   264     thy0 |> Ind_Package.add_inductive_i
   266       false (rec_tms, dom_sum) (map Thm.no_attributes (intr_names ~~ intr_tms))
   265       false (rec_tms, dom_sum) (map Thm.no_attributes (intr_names ~~ intr_tms))