src/ZF/Tools/datatype_package.ML
changeset 39557 fe5722fce758
parent 39288 f1ae2493d93f
child 41310 65631ca437c9
equal deleted inserted replaced
39556:32a00ff29d1a 39557:fe5722fce758
   240   (* Build the new theory *)
   240   (* Build the new theory *)
   241 
   241 
   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 |> Sign.add_consts_i
   246       thy
   247                     [(Binding.name recursor_base_name, recursor_typ, NoSyn)]
   247       |> Sign.add_consts_i
   248                |> (snd o PureThy.add_defs false [(Thm.no_attributes o apfst Binding.name) recursor_def])
   248         [(Binding.name recursor_base_name, recursor_typ, NoSyn)]
   249       else thy;
   249       |> (snd o Global_Theory.add_defs false [(Thm.no_attributes o apfst Binding.name) recursor_def])
       
   250     else thy;
   250 
   251 
   251   val (con_defs, thy0) = thy_path
   252   val (con_defs, thy0) = thy_path
   252              |> Sign.add_consts_i
   253              |> Sign.add_consts_i
   253                  (map (fn (c, T, mx) => (Binding.name c, T, mx))
   254                  (map (fn (c, T, mx) => (Binding.name c, T, mx))
   254                   ((case_base_name, case_typ, NoSyn) :: map #1 (flat con_ty_lists)))
   255                   ((case_base_name, case_typ, NoSyn) :: map #1 (flat con_ty_lists)))
   255              |> PureThy.add_defs false
   256              |> Global_Theory.add_defs false
   256                  (map (Thm.no_attributes o apfst Binding.name)
   257                  (map (Thm.no_attributes o apfst Binding.name)
   257                   (case_def ::
   258                   (case_def ::
   258                    flat (ListPair.map mk_con_defs (1 upto npart, con_ty_lists))))
   259                    flat (ListPair.map mk_con_defs (1 upto npart, con_ty_lists))))
   259              ||> add_recursor
   260              ||> add_recursor
   260              ||> Sign.parent_path
   261              ||> Sign.parent_path
   377   val con_pairs = map (fn c => (#1 (dest_Const c), con_info)) constructors
   378   val con_pairs = map (fn c => (#1 (dest_Const c), con_info)) constructors
   378 
   379 
   379  in
   380  in
   380   (*Updating theory components: simprules and datatype info*)
   381   (*Updating theory components: simprules and datatype info*)
   381   (thy1 |> Sign.add_path big_rec_base_name
   382   (thy1 |> Sign.add_path big_rec_base_name
   382         |> PureThy.add_thmss
   383         |> Global_Theory.add_thmss
   383          [((Binding.name "simps", simps), [Simplifier.simp_add]),
   384          [((Binding.name "simps", simps), [Simplifier.simp_add]),
   384           ((Binding.empty , intrs), [Classical.safe_intro NONE]),
   385           ((Binding.empty , intrs), [Classical.safe_intro NONE]),
   385           ((Binding.name "con_defs", con_defs), []),
   386           ((Binding.name "con_defs", con_defs), []),
   386           ((Binding.name "case_eqns", case_eqns), []),
   387           ((Binding.name "case_eqns", case_eqns), []),
   387           ((Binding.name "recursor_eqns", recursor_eqns), []),
   388           ((Binding.name "recursor_eqns", recursor_eqns), []),