src/Tools/Code/code_preproc.ML
author haftmann
Mon Jan 04 14:09:56 2010 +0100 (2010-01-04)
changeset 34244 03f8dcab55f3
parent 34173 458ced35abb8
child 34251 cd642bb91f64
permissions -rw-r--r--
code cache without copy; tuned
     1 (*  Title:      Tools/code/code_preproc.ML
     2     Author:     Florian Haftmann, TU Muenchen
     3 
     4 Preprocessing code equations into a well-sorted system
     5 in a graph with explicit dependencies.
     6 *)
     7 
     8 signature CODE_PREPROC =
     9 sig
    10   val map_pre: (simpset -> simpset) -> theory -> theory
    11   val map_post: (simpset -> simpset) -> theory -> theory
    12   val add_unfold: thm -> theory -> theory
    13   val add_functrans: string * (theory -> (thm * bool) list -> (thm * bool) list option) -> theory -> theory
    14   val del_functrans: string -> theory -> theory
    15   val simple_functrans: (theory -> thm list -> thm list option)
    16     -> theory -> (thm * bool) list -> (thm * bool) list option
    17   val print_codeproc: theory -> unit
    18 
    19   type code_algebra
    20   type code_graph
    21   val eqns: code_graph -> string -> (thm * bool) list
    22   val sortargs: code_graph -> string -> sort list
    23   val all: code_graph -> string list
    24   val pretty: theory -> code_graph -> Pretty.T
    25   val obtain: theory -> string list -> term list -> code_algebra * code_graph
    26   val eval_conv: theory
    27     -> (code_algebra -> code_graph -> (string * sort) list -> term -> cterm -> thm) -> cterm -> thm
    28   val eval: theory -> ((term -> term) -> 'a -> 'a)
    29     -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a
    30 
    31   val setup: theory -> theory
    32 end
    33 
    34 structure Code_Preproc : CODE_PREPROC =
    35 struct
    36 
    37 (** preprocessor administration **)
    38 
    39 (* theory data *)
    40 
    41 datatype thmproc = Thmproc of {
    42   pre: simpset,
    43   post: simpset,
    44   functrans: (string * (serial * (theory -> (thm * bool) list -> (thm * bool) list option))) list
    45 };
    46 
    47 fun make_thmproc ((pre, post), functrans) =
    48   Thmproc { pre = pre, post = post, functrans = functrans };
    49 fun map_thmproc f (Thmproc { pre, post, functrans }) =
    50   make_thmproc (f ((pre, post), functrans));
    51 fun merge_thmproc (Thmproc { pre = pre1, post = post1, functrans = functrans1 },
    52   Thmproc { pre = pre2, post = post2, functrans = functrans2 }) =
    53     let
    54       val pre = Simplifier.merge_ss (pre1, pre2);
    55       val post = Simplifier.merge_ss (post1, post2);
    56       val functrans = AList.merge (op =) (eq_fst (op =)) (functrans1, functrans2);
    57         (* FIXME handle AList.DUP (!?) *)
    58     in make_thmproc ((pre, post), functrans) end;
    59 
    60 structure Code_Preproc_Data = Theory_Data
    61 (
    62   type T = thmproc;
    63   val empty = make_thmproc ((Simplifier.empty_ss, Simplifier.empty_ss), []);
    64   val extend = I;
    65   val merge = merge_thmproc;
    66 );
    67 
    68 fun the_thmproc thy = case Code_Preproc_Data.get thy
    69  of Thmproc x => x;
    70 
    71 fun delete_force msg key xs =
    72   if AList.defined (op =) xs key then AList.delete (op =) key xs
    73   else error ("No such " ^ msg ^ ": " ^ quote key);
    74 
    75 fun map_data f = Code.purge_data
    76   #> (Code_Preproc_Data.map o map_thmproc) f;
    77 
    78 val map_pre_post = map_data o apfst;
    79 val map_pre = map_pre_post o apfst;
    80 val map_post = map_pre_post o apsnd;
    81 
    82 val add_unfold = map_pre o MetaSimplifier.add_simp;
    83 val del_unfold = map_pre o MetaSimplifier.del_simp;
    84 val add_post = map_post o MetaSimplifier.add_simp;
    85 val del_post = map_post o MetaSimplifier.del_simp;
    86 
    87 fun add_unfold_post raw_thm thy =
    88   let
    89     val thm = LocalDefs.meta_rewrite_rule (ProofContext.init thy) raw_thm;
    90     val thm_sym = Thm.symmetric thm;
    91   in
    92     thy |> map_pre_post (fn (pre, post) =>
    93       (pre |> MetaSimplifier.add_simp thm, post |> MetaSimplifier.del_simp thm_sym))
    94   end;
    95 
    96 fun add_functrans (name, f) = (map_data o apsnd)
    97   (AList.update (op =) (name, (serial (), f)));
    98 
    99 fun del_functrans name = (map_data o apsnd)
   100   (delete_force "function transformer" name);
   101 
   102 
   103 (* post- and preprocessing *)
   104 
   105 fun apply_functrans thy c _ [] = []
   106   | apply_functrans thy c [] eqns = eqns
   107   | apply_functrans thy c functrans eqns = eqns
   108       |> perhaps (perhaps_loop (perhaps_apply functrans))
   109       |> Code.assert_eqns_const thy c
   110       (*FIXME in future, the check here should be more accurate wrt. type schemes
   111       -- perhaps by means of upcoming code certificates with a corresponding
   112          preprocessor protocol*);
   113 
   114 fun trans_conv_rule conv thm = Thm.transitive thm ((conv o Thm.rhs_of) thm);
   115 
   116 fun eqn_conv conv =
   117   let
   118     fun lhs_conv ct = if can Thm.dest_comb ct
   119       then Conv.combination_conv lhs_conv conv ct
   120       else Conv.all_conv ct;
   121   in Conv.combination_conv (Conv.arg_conv lhs_conv) conv end;
   122 
   123 val rewrite_eqn = Conv.fconv_rule o eqn_conv o Simplifier.rewrite;
   124 
   125 fun term_of_conv thy f =
   126   Thm.cterm_of thy
   127   #> f
   128   #> Thm.prop_of
   129   #> Logic.dest_equals
   130   #> snd;
   131 
   132 fun preprocess thy c eqns =
   133   let
   134     val pre = (Simplifier.theory_context thy o #pre o the_thmproc) thy;
   135     val functrans = (map (fn (_, (_, f)) => f thy) o #functrans
   136       o the_thmproc) thy;
   137   in
   138     eqns
   139     |> apply_functrans thy c functrans
   140     |> (map o apfst) (rewrite_eqn pre)
   141     |> (map o apfst) (AxClass.unoverload thy)
   142     |> map (Code.assert_eqn thy)
   143   end;
   144 
   145 fun preprocess_conv thy ct =
   146   let
   147     val pre = (Simplifier.theory_context thy o #pre o the_thmproc) thy;
   148   in
   149     ct
   150     |> Simplifier.rewrite pre
   151     |> trans_conv_rule (AxClass.unoverload_conv thy)
   152   end;
   153 
   154 fun postprocess_conv thy ct =
   155   let
   156     val post = (Simplifier.theory_context thy o #post o the_thmproc) thy;
   157   in
   158     ct
   159     |> AxClass.overload_conv thy
   160     |> trans_conv_rule (Simplifier.rewrite post)
   161   end;
   162 
   163 fun postprocess_term thy = term_of_conv thy (postprocess_conv thy);
   164 
   165 fun print_codeproc thy =
   166   let
   167     val ctxt = ProofContext.init thy;
   168     val pre = (#pre o the_thmproc) thy;
   169     val post = (#post o the_thmproc) thy;
   170     val functrans = (map fst o #functrans o the_thmproc) thy;
   171   in
   172     (Pretty.writeln o Pretty.chunks) [
   173       Pretty.block [
   174         Pretty.str "preprocessing simpset:",
   175         Pretty.fbrk,
   176         Simplifier.pretty_ss ctxt pre
   177       ],
   178       Pretty.block [
   179         Pretty.str "postprocessing simpset:",
   180         Pretty.fbrk,
   181         Simplifier.pretty_ss ctxt post
   182       ],
   183       Pretty.block (
   184         Pretty.str "function transformers:"
   185         :: Pretty.fbrk
   186         :: (Pretty.fbreaks o map Pretty.str) functrans
   187       )
   188     ]
   189   end;
   190 
   191 fun simple_functrans f thy eqns = case f thy (map fst eqns)
   192  of SOME thms' => SOME (map (rpair (forall snd eqns)) thms')
   193   | NONE => NONE;
   194 
   195 
   196 (** sort algebra and code equation graph types **)
   197 
   198 type code_algebra = (sort -> sort) * Sorts.algebra;
   199 type code_graph = ((string * sort) list * (thm * bool) list) Graph.T;
   200 
   201 fun eqns eqngr = these o Option.map snd o try (Graph.get_node eqngr);
   202 fun sortargs eqngr = map snd o fst o Graph.get_node eqngr
   203 fun all eqngr = Graph.keys eqngr;
   204 
   205 fun pretty thy eqngr =
   206   AList.make (snd o Graph.get_node eqngr) (Graph.keys eqngr)
   207   |> (map o apfst) (Code.string_of_const thy)
   208   |> sort (string_ord o pairself fst)
   209   |> map (fn (s, thms) =>
   210        (Pretty.block o Pretty.fbreaks) (
   211          Pretty.str s
   212          :: map (Display.pretty_thm_global thy o fst) thms
   213        ))
   214   |> Pretty.chunks;
   215 
   216 
   217 (** the Waisenhaus algorithm **)
   218 
   219 (* auxiliary *)
   220 
   221 fun is_proper_class thy = can (AxClass.get_info thy);
   222 
   223 fun complete_proper_sort thy =
   224   Sign.complete_sort thy #> filter (is_proper_class thy);
   225 
   226 fun inst_params thy tyco =
   227   map (fn (c, _) => AxClass.param_of_inst thy (c, tyco))
   228     o maps (#params o AxClass.get_info thy);
   229 
   230 fun typscheme_rhss thy c eqns =
   231   let
   232     val tyscm = Code.typscheme_eqns thy c (map fst eqns);
   233     val rhss = [] |> (fold o fold o fold_aterms)
   234       (fn Const (c, ty) => insert (op =) (c, Sign.const_typargs thy (c, Logic.unvarifyT ty)) | _ => I)
   235         (map (op :: o swap o apfst (snd o strip_comb) o Logic.dest_equals o Thm.plain_prop_of o fst) eqns);
   236   in (tyscm, rhss) end;
   237 
   238 
   239 (* data structures *)
   240 
   241 datatype const = Fun of string | Inst of class * string;
   242 
   243 fun const_ord (Fun c1, Fun c2) = fast_string_ord (c1, c2)
   244   | const_ord (Inst class_tyco1, Inst class_tyco2) =
   245       prod_ord fast_string_ord fast_string_ord (class_tyco1, class_tyco2)
   246   | const_ord (Fun _, Inst _) = LESS
   247   | const_ord (Inst _, Fun _) = GREATER;
   248 
   249 type var = const * int;
   250 
   251 structure Vargraph =
   252   Graph(type key = var val ord = prod_ord const_ord int_ord);
   253 
   254 datatype styp = Tyco of string * styp list | Var of var | Free;
   255 
   256 fun styp_of c_lhs (Type (tyco, tys)) = Tyco (tyco, map (styp_of c_lhs) tys)
   257   | styp_of c_lhs (TFree (v, _)) = case c_lhs
   258      of SOME (c, lhs) => Var (Fun c, find_index (fn (v', _) => v = v') lhs)
   259       | NONE => Free;
   260 
   261 type vardeps_data = ((string * styp list) list * class list) Vargraph.T
   262   * (((string * sort) list * (thm * bool) list) Symtab.table
   263     * (class * string) list);
   264 
   265 val empty_vardeps_data : vardeps_data =
   266   (Vargraph.empty, (Symtab.empty, []));
   267 
   268 
   269 (* retrieving equations and instances from the background context *)
   270 
   271 fun obtain_eqns thy eqngr c =
   272   case try (Graph.get_node eqngr) c
   273    of SOME (lhs, eqns) => ((lhs, []), [])
   274     | NONE => let
   275         val eqns = Code.these_eqns thy c
   276           |> preprocess thy c;
   277         val ((lhs, _), rhss) = typscheme_rhss thy c eqns;
   278       in ((lhs, rhss), eqns) end;
   279 
   280 fun obtain_instance thy arities (inst as (class, tyco)) =
   281   case AList.lookup (op =) arities inst
   282    of SOME classess => (classess, ([], []))
   283     | NONE => let
   284         val all_classes = complete_proper_sort thy [class];
   285         val superclasses = remove (op =) class all_classes
   286         val classess = map (complete_proper_sort thy)
   287           (Sign.arity_sorts thy tyco [class]);
   288         val inst_params = inst_params thy tyco all_classes;
   289       in (classess, (superclasses, inst_params)) end;
   290 
   291 
   292 (* computing instantiations *)
   293 
   294 fun add_classes thy arities eqngr c_k new_classes vardeps_data =
   295   let
   296     val (styps, old_classes) = Vargraph.get_node (fst vardeps_data) c_k;
   297     val diff_classes = new_classes |> subtract (op =) old_classes;
   298   in if null diff_classes then vardeps_data
   299   else let
   300     val c_ks = Vargraph.imm_succs (fst vardeps_data) c_k |> insert (op =) c_k;
   301   in
   302     vardeps_data
   303     |> (apfst o Vargraph.map_node c_k o apsnd) (append diff_classes)
   304     |> fold (fn styp => fold (ensure_typmatch_inst thy arities eqngr styp) new_classes) styps
   305     |> fold (fn c_k => add_classes thy arities eqngr c_k diff_classes) c_ks
   306   end end
   307 and add_styp thy arities eqngr c_k tyco_styps vardeps_data =
   308   let
   309     val (old_styps, classes) = Vargraph.get_node (fst vardeps_data) c_k;
   310   in if member (op =) old_styps tyco_styps then vardeps_data
   311   else
   312     vardeps_data
   313     |> (apfst o Vargraph.map_node c_k o apfst) (cons tyco_styps)
   314     |> fold (ensure_typmatch_inst thy arities eqngr tyco_styps) classes
   315   end
   316 and add_dep thy arities eqngr c_k c_k' vardeps_data =
   317   let
   318     val (_, classes) = Vargraph.get_node (fst vardeps_data) c_k;
   319   in
   320     vardeps_data
   321     |> add_classes thy arities eqngr c_k' classes
   322     |> apfst (Vargraph.add_edge (c_k, c_k'))
   323   end
   324 and ensure_typmatch_inst thy arities eqngr (tyco, styps) class vardeps_data =
   325   if can (Sign.arity_sorts thy tyco) [class]
   326   then vardeps_data
   327     |> ensure_inst thy arities eqngr (class, tyco)
   328     |> fold_index (fn (k, styp) =>
   329          ensure_typmatch thy arities eqngr styp (Inst (class, tyco), k)) styps
   330   else vardeps_data (*permissive!*)
   331 and ensure_inst thy arities eqngr (inst as (class, tyco)) (vardeps_data as (_, (_, insts))) =
   332   if member (op =) insts inst then vardeps_data
   333   else let
   334     val (classess, (superclasses, inst_params)) =
   335       obtain_instance thy arities inst;
   336   in
   337     vardeps_data
   338     |> (apsnd o apsnd) (insert (op =) inst)
   339     |> fold_index (fn (k, _) =>
   340          apfst (Vargraph.new_node ((Inst (class, tyco), k), ([] ,[])))) classess
   341     |> fold (fn superclass => ensure_inst thy arities eqngr (superclass, tyco)) superclasses
   342     |> fold (ensure_fun thy arities eqngr) inst_params
   343     |> fold_index (fn (k, classes) =>
   344          add_classes thy arities eqngr (Inst (class, tyco), k) classes
   345          #> fold (fn superclass =>
   346              add_dep thy arities eqngr (Inst (superclass, tyco), k)
   347              (Inst (class, tyco), k)) superclasses
   348          #> fold (fn inst_param =>
   349              add_dep thy arities eqngr (Fun inst_param, k)
   350              (Inst (class, tyco), k)
   351              ) inst_params
   352          ) classess
   353   end
   354 and ensure_typmatch thy arities eqngr (Tyco tyco_styps) c_k vardeps_data =
   355       vardeps_data
   356       |> add_styp thy arities eqngr c_k tyco_styps
   357   | ensure_typmatch thy arities eqngr (Var c_k') c_k vardeps_data =
   358       vardeps_data
   359       |> add_dep thy arities eqngr c_k c_k'
   360   | ensure_typmatch thy arities eqngr Free c_k vardeps_data =
   361       vardeps_data
   362 and ensure_rhs thy arities eqngr (c', styps) vardeps_data =
   363   vardeps_data
   364   |> ensure_fun thy arities eqngr c'
   365   |> fold_index (fn (k, styp) =>
   366        ensure_typmatch thy arities eqngr styp (Fun c', k)) styps
   367 and ensure_fun thy arities eqngr c (vardeps_data as (_, (eqntab, _))) =
   368   if Symtab.defined eqntab c then vardeps_data
   369   else let
   370     val ((lhs, rhss), eqns) = obtain_eqns thy eqngr c;
   371     val rhss' = (map o apsnd o map) (styp_of (SOME (c, lhs))) rhss;
   372   in
   373     vardeps_data
   374     |> (apsnd o apfst) (Symtab.update_new (c, (lhs, eqns)))
   375     |> fold_index (fn (k, _) =>
   376          apfst (Vargraph.new_node ((Fun c, k), ([] ,[])))) lhs
   377     |> fold_index (fn (k, (_, sort)) =>
   378          add_classes thy arities eqngr (Fun c, k) (complete_proper_sort thy sort)) lhs
   379     |> fold (ensure_rhs thy arities eqngr) rhss'
   380   end;
   381 
   382 
   383 (* applying instantiations *)
   384 
   385 fun dicts_of thy (proj_sort, algebra) (T, sort) =
   386   let
   387     fun class_relation (x, _) _ = x;
   388     fun type_constructor tyco xs class =
   389       inst_params thy tyco (Sorts.complete_sort algebra [class])
   390         @ (maps o maps) fst xs;
   391     fun type_variable (TFree (_, sort)) = map (pair []) (proj_sort sort);
   392   in
   393     flat (Sorts.of_sort_derivation algebra
   394       { class_relation = class_relation, type_constructor = type_constructor,
   395         type_variable = type_variable } (T, proj_sort sort)
   396        handle Sorts.CLASS_ERROR _ => [] (*permissive!*))
   397   end;
   398 
   399 fun inst_thm thy tvars' thm =
   400   let
   401     val tvars = (Term.add_tvars o Thm.prop_of) thm [];
   402     val inter_sort = Sorts.inter_sort (Sign.classes_of thy);
   403     fun mk_inst (tvar as (v, sort)) = case Vartab.lookup tvars' v
   404      of SOME sort' => SOME (pairself (Thm.ctyp_of thy o TVar)
   405           (tvar, (v, inter_sort (sort, sort'))))
   406       | NONE => NONE;
   407     val insts = map_filter mk_inst tvars;
   408   in Thm.instantiate (insts, []) thm end;
   409 
   410 fun add_arity thy vardeps (class, tyco) =
   411   AList.default (op =) ((class, tyco),
   412     map_range (fn k => (snd o Vargraph.get_node vardeps) (Inst (class, tyco), k)) (Sign.arity_number thy tyco));
   413 
   414 fun add_eqs thy vardeps (c, (proto_lhs, proto_eqns)) (rhss, eqngr) =
   415   if can (Graph.get_node eqngr) c then (rhss, eqngr)
   416   else let
   417     val lhs = map_index (fn (k, (v, _)) =>
   418       (v, snd (Vargraph.get_node vardeps (Fun c, k)))) proto_lhs;
   419     val inst_tab = Vartab.empty |> fold (fn (v, sort) =>
   420       Vartab.update ((v, 0), sort)) lhs;
   421     val eqns = proto_eqns
   422       |> (map o apfst) (inst_thm thy inst_tab);
   423     val ((vs, _), rhss') = typscheme_rhss thy c eqns;
   424     val eqngr' = Graph.new_node (c, (vs, eqns)) eqngr;
   425   in (map (pair c) rhss' @ rhss, eqngr') end;
   426 
   427 fun extend_arities_eqngr thy cs ts (arities, (eqngr : code_graph)) =
   428   let
   429     val cs_rhss = (fold o fold_aterms) (fn Const (c_ty as (c, _)) =>
   430       insert (op =) (c, (map (styp_of NONE) o Sign.const_typargs thy) c_ty) | _ => I) ts [];
   431     val (vardeps, (eqntab, insts)) = empty_vardeps_data
   432       |> fold (ensure_fun thy arities eqngr) cs
   433       |> fold (ensure_rhs thy arities eqngr) cs_rhss;
   434     val arities' = fold (add_arity thy vardeps) insts arities;
   435     val pp = Syntax.pp_global thy;
   436     val algebra = Sorts.subalgebra pp (is_proper_class thy)
   437       (AList.lookup (op =) arities') (Sign.classes_of thy);
   438     val (rhss, eqngr') = Symtab.fold (add_eqs thy vardeps) eqntab ([], eqngr);
   439     fun deps_of (c, rhs) = c :: maps (dicts_of thy algebra)
   440       (rhs ~~ sortargs eqngr' c);
   441     val eqngr'' = fold (fn (c, rhs) => fold
   442       (curry Graph.add_edge c) (deps_of rhs)) rhss eqngr';
   443   in (algebra, (arities', eqngr'')) end;
   444 
   445 
   446 (** store for preprocessed arities and code equations **)
   447 
   448 structure Wellsorted = Code_Data
   449 (
   450   type T = ((string * class) * sort list) list * code_graph;
   451   val empty = ([], Graph.empty);
   452 );
   453 
   454 
   455 (** retrieval and evaluation interfaces **)
   456 
   457 fun obtain theory cs ts = apsnd snd
   458   (Wellsorted.change_yield theory (fn thy => extend_arities_eqngr thy cs ts));
   459 
   460 fun gen_eval thy cterm_of conclude_evaluation evaluator proto_ct =
   461   let
   462     val pp = Syntax.pp_global thy;
   463     val ct = cterm_of proto_ct;
   464     val _ = (Sign.no_frees pp o map_types (K dummyT) o Sign.no_vars pp)
   465       (Thm.term_of ct);
   466     val thm = preprocess_conv thy ct;
   467     val ct' = Thm.rhs_of thm;
   468     val t' = Thm.term_of ct';
   469     val vs = Term.add_tfrees t' [];
   470     val consts = fold_aterms
   471       (fn Const (c, _) => insert (op =) c | _ => I) t' [];
   472     val (algebra', eqngr') = obtain thy consts [t'];
   473   in conclude_evaluation (evaluator algebra' eqngr' vs t' ct') thm end;
   474 
   475 fun simple_evaluator evaluator algebra eqngr vs t ct =
   476   evaluator algebra eqngr vs t;
   477 
   478 fun eval_conv thy =
   479   let
   480     fun conclude_evaluation thm2 thm1 =
   481       let
   482         val thm3 = postprocess_conv thy (Thm.rhs_of thm2);
   483       in
   484         Thm.transitive thm1 (Thm.transitive thm2 thm3) handle THM _ =>
   485           error ("could not construct evaluation proof:\n"
   486           ^ (cat_lines o map (Display.string_of_thm_global thy)) [thm1, thm2, thm3])
   487       end;
   488   in gen_eval thy I conclude_evaluation end;
   489 
   490 fun eval thy postproc evaluator = gen_eval thy (Thm.cterm_of thy)
   491   (K o postproc (postprocess_term thy)) (simple_evaluator evaluator);
   492 
   493 
   494 (** setup **)
   495 
   496 val setup = 
   497   let
   498     fun mk_attribute f = Thm.declaration_attribute (fn thm => Context.mapping (f thm) I);
   499     fun add_del_attribute_parser add del =
   500       Attrib.add_del (mk_attribute add) (mk_attribute del);
   501     fun both f g thm = f thm #> g thm;
   502   in
   503     Attrib.setup @{binding code_unfold} (add_del_attribute_parser 
   504        (both Codegen.add_unfold add_unfold) (both Codegen.del_unfold del_unfold))
   505         "preprocessing equations for code generators"
   506     #> Attrib.setup @{binding code_inline} (add_del_attribute_parser add_unfold del_unfold)
   507         "preprocessing equations for code generator"
   508     #> Attrib.setup @{binding code_post} (add_del_attribute_parser add_post del_post)
   509         "postprocessing equations for code generator"
   510     #> Attrib.setup @{binding code_unfold_post} (Scan.succeed (mk_attribute add_unfold_post))
   511         "pre- and postprocessing equations for code generator"
   512   end;
   513 
   514 val _ =
   515   OuterSyntax.improper_command "print_codeproc" "print code preprocessor setup"
   516   OuterKeyword.diag (Scan.succeed
   517       (Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep
   518         (print_codeproc o Toplevel.theory_of)));
   519 
   520 end; (*struct*)