src/HOL/Tools/BNF/bnf_lfp_compat.ML
changeset 58119 8119d6e5d024
parent 58117 9608028d8f43
child 58122 eaac3e01158a
equal deleted inserted replaced
58118:0a58bff4939d 58119:8119d6e5d024
     1 (*  Title:      HOL/Tools/BNF/bnf_lfp_compat.ML
     1 (*  Title:      HOL/Tools/BNF/bnf_lfp_compat.ML
     2     Author:     Jasmin Blanchette, TU Muenchen
     2     Author:     Jasmin Blanchette, TU Muenchen
     3     Copyright   2013, 2014
     3     Copyright   2013, 2014
     4 
     4 
     5 Compatibility layer with the old datatype package.
     5 Compatibility layer with the old datatype package. Parly based on:
       
     6 
       
     7     Title:      HOL/Tools/Old_Datatype/old_datatype_data.ML
       
     8     Author:     Stefan Berghofer, TU Muenchen
     6 *)
     9 *)
     7 
    10 
     8 signature BNF_LFP_COMPAT =
    11 signature BNF_LFP_COMPAT =
     9 sig
    12 sig
    10   val get_all: theory -> bool -> Old_Datatype_Aux.info Symtab.table
    13   val get_all: theory -> bool -> Old_Datatype_Aux.info Symtab.table
   237     (descr, vs, T_names, prefix, (names, auxnames), (Ts, Us))
   240     (descr, vs, T_names, prefix, (names, auxnames), (Ts, Us))
   238   end;
   241   end;
   239 
   242 
   240 fun get_constrs thy unfold_nesting T_name =
   243 fun get_constrs thy unfold_nesting T_name =
   241   try (the_spec thy unfold_nesting) T_name
   244   try (the_spec thy unfold_nesting) T_name
   242   |> Option.map (fn (Ts, ctrs) =>
   245   |> Option.map (fn (tfrees, ctrs) =>
   243       let
   246     let
   244         fun subst (v, S) = TVar ((v, 0), S);
   247       fun varify_tfree (s, S) = TVar ((s, 0), S);
   245         fun subst_ty (TFree v) = subst v
   248       fun varify_typ (TFree x) = varify_tfree x
   246           | subst_ty ty = ty;
   249         | varify_typ T = T;
   247         val dataT = Type (T_name, map subst Ts);
   250 
   248         fun mk_ctr_typ Ts = map (Term.map_atyps subst_ty) Ts ---> dataT;
   251       val dataT = Type (T_name, map varify_tfree tfrees);
   249       in
   252 
   250         map (apsnd mk_ctr_typ) ctrs
   253       fun mk_ctr_typ Ts = map (Term.map_atyps varify_typ) Ts ---> dataT;
   251       end);
   254     in
       
   255       map (apsnd mk_ctr_typ) ctrs
       
   256     end);
   252 
   257 
   253 fun interpretation f thy = Old_Datatype_Data.interpretation f thy;
   258 fun interpretation f thy = Old_Datatype_Data.interpretation f thy;
   254 
   259 
   255 fun add_datatype config specs thy = ([], thy);
   260 fun add_datatype config specs thy = ([], thy);
   256 
   261