src/Tools/Code/code_preproc.ML
author haftmann
Tue Jun 23 12:09:30 2009 +0200 (2009-06-23)
changeset 31775 2b04504fcb69
parent 31599 src/Tools/code/code_preproc.ML@97b4d289c646
child 31957 a9742afd403e
permissions -rw-r--r--
uniformly capitialized names for subdirectories
     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_inline: 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 typ: code_graph -> string -> (string * sort) list * typ
    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 -> (sort -> sort)
    27     -> (code_algebra -> code_graph -> (string * sort) list -> term -> cterm -> thm) -> cterm -> thm
    28   val eval: theory -> (sort -> sort) -> ((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     in make_thmproc ((pre, post), functrans) end;
    58 
    59 structure Code_Preproc_Data = TheoryDataFun
    60 (
    61   type T = thmproc;
    62   val empty = make_thmproc ((Simplifier.empty_ss, Simplifier.empty_ss), []);
    63   fun copy spec = spec;
    64   val extend = copy;
    65   fun merge pp = 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 thy =
    76   thy
    77   |> Code.purge_data
    78   |> (Code_Preproc_Data.map o map_thmproc) f;
    79 
    80 val map_pre = map_data o apfst o apfst;
    81 val map_post = map_data o apfst o apsnd;
    82 
    83 val add_inline = map_pre o MetaSimplifier.add_simp;
    84 val del_inline = map_pre o MetaSimplifier.del_simp;
    85 val add_post = map_post o MetaSimplifier.add_simp;
    86 val del_post = map_post o MetaSimplifier.del_simp;
    87   
    88 fun add_functrans (name, f) = (map_data o apsnd)
    89   (AList.update (op =) (name, (serial (), f)));
    90 
    91 fun del_functrans name = (map_data o apsnd)
    92   (delete_force "function transformer" name);
    93 
    94 
    95 (* post- and preprocessing *)
    96 
    97 fun apply_functrans thy c _ [] = []
    98   | apply_functrans thy c [] eqns = eqns
    99   | apply_functrans thy c functrans eqns = eqns
   100       |> perhaps (perhaps_loop (perhaps_apply functrans))
   101       |> Code.assert_eqns_const thy c;
   102 
   103 fun rhs_conv conv thm = Thm.transitive thm ((conv o Thm.rhs_of) thm);
   104 
   105 fun term_of_conv thy f =
   106   Thm.cterm_of thy
   107   #> f
   108   #> Thm.prop_of
   109   #> Logic.dest_equals
   110   #> snd;
   111 
   112 fun preprocess thy c eqns =
   113   let
   114     val pre = (Simplifier.theory_context thy o #pre o the_thmproc) thy;
   115     val functrans = (map (fn (_, (_, f)) => f thy) o #functrans
   116       o the_thmproc) thy;
   117   in
   118     eqns
   119     |> apply_functrans thy c functrans
   120     |> (map o apfst) (Code.rewrite_eqn pre)
   121     |> (map o apfst) (AxClass.unoverload thy)
   122     |> map (Code.assert_eqn thy)
   123     |> burrow_fst (Code.norm_args thy)
   124     |> burrow_fst (Code.norm_varnames thy)
   125   end;
   126 
   127 fun preprocess_conv thy ct =
   128   let
   129     val pre = (Simplifier.theory_context thy o #pre o the_thmproc) thy;
   130   in
   131     ct
   132     |> Simplifier.rewrite pre
   133     |> rhs_conv (AxClass.unoverload_conv thy)
   134   end;
   135 
   136 fun postprocess_conv thy ct =
   137   let
   138     val post = (Simplifier.theory_context thy o #post o the_thmproc) thy;
   139   in
   140     ct
   141     |> AxClass.overload_conv thy
   142     |> rhs_conv (Simplifier.rewrite post)
   143   end;
   144 
   145 fun postprocess_term thy = term_of_conv thy (postprocess_conv thy);
   146 
   147 fun print_codeproc thy =
   148   let
   149     val ctxt = ProofContext.init thy;
   150     val pre = (#pre o the_thmproc) thy;
   151     val post = (#post o the_thmproc) thy;
   152     val functrans = (map fst o #functrans o the_thmproc) thy;
   153   in
   154     (Pretty.writeln o Pretty.chunks) [
   155       Pretty.block [
   156         Pretty.str "preprocessing simpset:",
   157         Pretty.fbrk,
   158         Simplifier.pretty_ss ctxt pre
   159       ],
   160       Pretty.block [
   161         Pretty.str "postprocessing simpset:",
   162         Pretty.fbrk,
   163         Simplifier.pretty_ss ctxt post
   164       ],
   165       Pretty.block (
   166         Pretty.str "function transformers:"
   167         :: Pretty.fbrk
   168         :: (Pretty.fbreaks o map Pretty.str) functrans
   169       )
   170     ]
   171   end;
   172 
   173 fun simple_functrans f thy eqns = case f thy (map fst eqns)
   174  of SOME thms' => SOME (map (rpair (forall snd eqns)) thms')
   175   | NONE => NONE;
   176 
   177 
   178 (** sort algebra and code equation graph types **)
   179 
   180 type code_algebra = (sort -> sort) * Sorts.algebra;
   181 type code_graph = (((string * sort) list * typ) * (thm * bool) list) Graph.T;
   182 
   183 fun eqns eqngr = these o Option.map snd o try (Graph.get_node eqngr);
   184 fun typ eqngr = fst o Graph.get_node eqngr;
   185 fun all eqngr = Graph.keys eqngr;
   186 
   187 fun pretty thy eqngr =
   188   AList.make (snd o Graph.get_node eqngr) (Graph.keys eqngr)
   189   |> (map o apfst) (Code.string_of_const thy)
   190   |> sort (string_ord o pairself fst)
   191   |> map (fn (s, thms) =>
   192        (Pretty.block o Pretty.fbreaks) (
   193          Pretty.str s
   194          :: map (Display.pretty_thm o fst) thms
   195        ))
   196   |> Pretty.chunks;
   197 
   198 
   199 (** the Waisenhaus algorithm **)
   200 
   201 (* auxiliary *)
   202 
   203 fun is_proper_class thy = can (AxClass.get_info thy);
   204 
   205 fun complete_proper_sort thy =
   206   Sign.complete_sort thy #> filter (is_proper_class thy);
   207 
   208 fun inst_params thy tyco =
   209   map (fn (c, _) => AxClass.param_of_inst thy (c, tyco))
   210     o maps (#params o AxClass.get_info thy);
   211 
   212 fun consts_of thy eqns = [] |> (fold o fold o fold_aterms)
   213   (fn Const (c, ty) => insert (op =) (c, Sign.const_typargs thy (c, Logic.unvarifyT ty)) | _ => I)
   214     (map (op :: o swap o apfst (snd o strip_comb) o Logic.dest_equals o Thm.plain_prop_of o fst) eqns);
   215 
   216 fun tyscm_rhss_of thy c eqns =
   217   let
   218     val tyscm = case eqns of [] => Code.default_typscheme thy c
   219       | ((thm, _) :: _) => Code.typscheme_eqn thy thm;
   220     val rhss = consts_of thy eqns;
   221   in (tyscm, rhss) end;
   222 
   223 
   224 (* data structures *)
   225 
   226 datatype const = Fun of string | Inst of class * string;
   227 
   228 fun const_ord (Fun c1, Fun c2) = fast_string_ord (c1, c2)
   229   | const_ord (Inst class_tyco1, Inst class_tyco2) =
   230       prod_ord fast_string_ord fast_string_ord (class_tyco1, class_tyco2)
   231   | const_ord (Fun _, Inst _) = LESS
   232   | const_ord (Inst _, Fun _) = GREATER;
   233 
   234 type var = const * int;
   235 
   236 structure Vargraph =
   237   GraphFun(type key = var val ord = prod_ord const_ord int_ord);
   238 
   239 datatype styp = Tyco of string * styp list | Var of var | Free;
   240 
   241 fun styp_of c_lhs (Type (tyco, tys)) = Tyco (tyco, map (styp_of c_lhs) tys)
   242   | styp_of c_lhs (TFree (v, _)) = case c_lhs
   243      of SOME (c, lhs) => Var (Fun c, find_index (fn (v', _) => v = v') lhs)
   244       | NONE => Free;
   245 
   246 type vardeps_data = ((string * styp list) list * class list) Vargraph.T
   247   * (((string * sort) list * (thm * bool) list) Symtab.table
   248     * (class * string) list);
   249 
   250 val empty_vardeps_data : vardeps_data =
   251   (Vargraph.empty, (Symtab.empty, []));
   252 
   253 
   254 (* retrieving equations and instances from the background context *)
   255 
   256 fun obtain_eqns thy eqngr c =
   257   case try (Graph.get_node eqngr) c
   258    of SOME ((lhs, _), eqns) => ((lhs, []), [])
   259     | NONE => let
   260         val eqns = Code.these_eqns thy c
   261           |> preprocess thy c;
   262         val ((lhs, _), rhss) = tyscm_rhss_of thy c eqns;
   263       in ((lhs, rhss), eqns) end;
   264 
   265 fun obtain_instance thy arities (inst as (class, tyco)) =
   266   case AList.lookup (op =) arities inst
   267    of SOME classess => (classess, ([], []))
   268     | NONE => let
   269         val all_classes = complete_proper_sort thy [class];
   270         val superclasses = remove (op =) class all_classes
   271         val classess = map (complete_proper_sort thy)
   272           (Sign.arity_sorts thy tyco [class]);
   273         val inst_params = inst_params thy tyco all_classes;
   274       in (classess, (superclasses, inst_params)) end;
   275 
   276 
   277 (* computing instantiations *)
   278 
   279 fun add_classes thy arities eqngr c_k new_classes vardeps_data =
   280   let
   281     val (styps, old_classes) = Vargraph.get_node (fst vardeps_data) c_k;
   282     val diff_classes = new_classes |> subtract (op =) old_classes;
   283   in if null diff_classes then vardeps_data
   284   else let
   285     val c_ks = Vargraph.imm_succs (fst vardeps_data) c_k |> insert (op =) c_k;
   286   in
   287     vardeps_data
   288     |> (apfst o Vargraph.map_node c_k o apsnd) (append diff_classes)
   289     |> fold (fn styp => fold (ensure_typmatch_inst thy arities eqngr styp) new_classes) styps
   290     |> fold (fn c_k => add_classes thy arities eqngr c_k diff_classes) c_ks
   291   end end
   292 and add_styp thy arities eqngr c_k tyco_styps vardeps_data =
   293   let
   294     val (old_styps, classes) = Vargraph.get_node (fst vardeps_data) c_k;
   295   in if member (op =) old_styps tyco_styps then vardeps_data
   296   else
   297     vardeps_data
   298     |> (apfst o Vargraph.map_node c_k o apfst) (cons tyco_styps)
   299     |> fold (ensure_typmatch_inst thy arities eqngr tyco_styps) classes
   300   end
   301 and add_dep thy arities eqngr c_k c_k' vardeps_data =
   302   let
   303     val (_, classes) = Vargraph.get_node (fst vardeps_data) c_k;
   304   in
   305     vardeps_data
   306     |> add_classes thy arities eqngr c_k' classes
   307     |> apfst (Vargraph.add_edge (c_k, c_k'))
   308   end
   309 and ensure_typmatch_inst thy arities eqngr (tyco, styps) class vardeps_data =
   310   if can (Sign.arity_sorts thy tyco) [class]
   311   then vardeps_data
   312     |> ensure_inst thy arities eqngr (class, tyco)
   313     |> fold_index (fn (k, styp) =>
   314          ensure_typmatch thy arities eqngr styp (Inst (class, tyco), k)) styps
   315   else vardeps_data (*permissive!*)
   316 and ensure_inst thy arities eqngr (inst as (class, tyco)) (vardeps_data as (_, (_, insts))) =
   317   if member (op =) insts inst then vardeps_data
   318   else let
   319     val (classess, (superclasses, inst_params)) =
   320       obtain_instance thy arities inst;
   321   in
   322     vardeps_data
   323     |> (apsnd o apsnd) (insert (op =) inst)
   324     |> fold_index (fn (k, _) =>
   325          apfst (Vargraph.new_node ((Inst (class, tyco), k), ([] ,[])))) classess
   326     |> fold (fn superclass => ensure_inst thy arities eqngr (superclass, tyco)) superclasses
   327     |> fold (ensure_fun thy arities eqngr) inst_params
   328     |> fold_index (fn (k, classes) =>
   329          add_classes thy arities eqngr (Inst (class, tyco), k) classes
   330          #> fold (fn superclass =>
   331              add_dep thy arities eqngr (Inst (superclass, tyco), k)
   332              (Inst (class, tyco), k)) superclasses
   333          #> fold (fn inst_param =>
   334              add_dep thy arities eqngr (Fun inst_param, k)
   335              (Inst (class, tyco), k)
   336              ) inst_params
   337          ) classess
   338   end
   339 and ensure_typmatch thy arities eqngr (Tyco tyco_styps) c_k vardeps_data =
   340       vardeps_data
   341       |> add_styp thy arities eqngr c_k tyco_styps
   342   | ensure_typmatch thy arities eqngr (Var c_k') c_k vardeps_data =
   343       vardeps_data
   344       |> add_dep thy arities eqngr c_k c_k'
   345   | ensure_typmatch thy arities eqngr Free c_k vardeps_data =
   346       vardeps_data
   347 and ensure_rhs thy arities eqngr (c', styps) vardeps_data =
   348   vardeps_data
   349   |> ensure_fun thy arities eqngr c'
   350   |> fold_index (fn (k, styp) =>
   351        ensure_typmatch thy arities eqngr styp (Fun c', k)) styps
   352 and ensure_fun thy arities eqngr c (vardeps_data as (_, (eqntab, _))) =
   353   if Symtab.defined eqntab c then vardeps_data
   354   else let
   355     val ((lhs, rhss), eqns) = obtain_eqns thy eqngr c;
   356     val rhss' = (map o apsnd o map) (styp_of (SOME (c, lhs))) rhss;
   357   in
   358     vardeps_data
   359     |> (apsnd o apfst) (Symtab.update_new (c, (lhs, eqns)))
   360     |> fold_index (fn (k, _) =>
   361          apfst (Vargraph.new_node ((Fun c, k), ([] ,[])))) lhs
   362     |> fold_index (fn (k, (_, sort)) =>
   363          add_classes thy arities eqngr (Fun c, k) (complete_proper_sort thy sort)) lhs
   364     |> fold (ensure_rhs thy arities eqngr) rhss'
   365   end;
   366 
   367 
   368 (* applying instantiations *)
   369 
   370 fun dicts_of thy (proj_sort, algebra) (T, sort) =
   371   let
   372     fun class_relation (x, _) _ = x;
   373     fun type_constructor tyco xs class =
   374       inst_params thy tyco (Sorts.complete_sort algebra [class])
   375         @ (maps o maps) fst xs;
   376     fun type_variable (TFree (_, sort)) = map (pair []) (proj_sort sort);
   377   in
   378     flat (Sorts.of_sort_derivation (Syntax.pp_global thy) algebra
   379       { class_relation = class_relation, type_constructor = type_constructor,
   380         type_variable = type_variable } (T, proj_sort sort)
   381        handle Sorts.CLASS_ERROR _ => [] (*permissive!*))
   382   end;
   383 
   384 fun add_arity thy vardeps (class, tyco) =
   385   AList.default (op =)
   386     ((class, tyco), map (fn k => (snd o Vargraph.get_node vardeps) (Inst (class, tyco), k))
   387       (0 upto Sign.arity_number thy tyco - 1));
   388 
   389 fun add_eqs thy vardeps (c, (proto_lhs, proto_eqns)) (rhss, eqngr) =
   390   if can (Graph.get_node eqngr) c then (rhss, eqngr)
   391   else let
   392     val lhs = map_index (fn (k, (v, _)) =>
   393       (v, snd (Vargraph.get_node vardeps (Fun c, k)))) proto_lhs;
   394     val inst_tab = Vartab.empty |> fold (fn (v, sort) =>
   395       Vartab.update ((v, 0), sort)) lhs;
   396     val eqns = proto_eqns
   397       |> (map o apfst) (Code.inst_thm thy inst_tab);
   398     val (tyscm, rhss') = tyscm_rhss_of thy c eqns;
   399     val eqngr' = Graph.new_node (c, (tyscm, eqns)) eqngr;
   400   in (map (pair c) rhss' @ rhss, eqngr') end;
   401 
   402 fun extend_arities_eqngr thy cs ts (arities, eqngr) =
   403   let
   404     val cs_rhss = (fold o fold_aterms) (fn Const (c_ty as (c, _)) =>
   405       insert (op =) (c, (map (styp_of NONE) o Sign.const_typargs thy) c_ty) | _ => I) ts [];
   406     val (vardeps, (eqntab, insts)) = empty_vardeps_data
   407       |> fold (ensure_fun thy arities eqngr) cs
   408       |> fold (ensure_rhs thy arities eqngr) cs_rhss;
   409     val arities' = fold (add_arity thy vardeps) insts arities;
   410     val pp = Syntax.pp_global thy;
   411     val algebra = Sorts.subalgebra pp (is_proper_class thy)
   412       (AList.lookup (op =) arities') (Sign.classes_of thy);
   413     val (rhss, eqngr') = Symtab.fold (add_eqs thy vardeps) eqntab ([], eqngr);
   414     fun deps_of (c, rhs) = c :: maps (dicts_of thy algebra)
   415       (rhs ~~ (map snd o fst o fst o Graph.get_node eqngr') c);
   416     val eqngr'' = fold (fn (c, rhs) => fold
   417       (curry Graph.add_edge c) (deps_of rhs)) rhss eqngr';
   418   in (algebra, (arities', eqngr'')) end;
   419 
   420 
   421 (** store for preprocessed arities and code equations **)
   422 
   423 structure Wellsorted = CodeDataFun
   424 (
   425   type T = ((string * class) * sort list) list * code_graph;
   426   val empty = ([], Graph.empty);
   427   fun purge thy cs (arities, eqngr) =
   428     let
   429       val del_cs = ((Graph.all_preds eqngr
   430         o filter (can (Graph.get_node eqngr))) cs);
   431       val del_arities = del_cs
   432         |> map_filter (AxClass.inst_of_param thy)
   433         |> maps (fn (c, tyco) =>
   434              (map (rpair tyco) o Sign.complete_sort thy o the_list
   435                o AxClass.class_of_param thy) c);
   436       val arities' = fold (AList.delete (op =)) del_arities arities;
   437       val eqngr' = Graph.del_nodes del_cs eqngr;
   438     in (arities', eqngr') end;
   439 );
   440 
   441 
   442 (** retrieval and evaluation interfaces **)
   443 
   444 fun obtain thy cs ts = apsnd snd
   445   (Wellsorted.change_yield thy (extend_arities_eqngr thy cs ts));
   446 
   447 fun prepare_sorts_typ prep_sort
   448   = map_type_tfree (fn (v, sort) => TFree (v, prep_sort sort));
   449 
   450 fun prepare_sorts prep_sort (Const (c, ty)) =
   451       Const (c, prepare_sorts_typ prep_sort ty)
   452   | prepare_sorts prep_sort (t1 $ t2) =
   453       prepare_sorts prep_sort t1 $ prepare_sorts prep_sort t2
   454   | prepare_sorts prep_sort (Abs (v, ty, t)) =
   455       Abs (v, prepare_sorts_typ prep_sort ty, prepare_sorts prep_sort t)
   456   | prepare_sorts _ (t as Bound _) = t;
   457 
   458 fun gen_eval thy cterm_of conclude_evaluation prep_sort evaluator proto_ct =
   459   let
   460     val pp = Syntax.pp_global thy;
   461     val ct = cterm_of proto_ct;
   462     val _ = (Sign.no_frees pp o map_types (K dummyT) o Sign.no_vars pp)
   463       (Thm.term_of ct);
   464     val thm = preprocess_conv thy ct;
   465     val ct' = Thm.rhs_of thm;
   466     val t' = Thm.term_of ct';
   467     val vs = Term.add_tfrees t' [];
   468     val consts = fold_aterms
   469       (fn Const (c, _) => insert (op =) c | _ => I) t' [];
   470  
   471     val t'' = prepare_sorts prep_sort 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) [thm1, thm2, thm3])
   487       end;
   488   in gen_eval thy I conclude_evaluation end;
   489 
   490 fun eval thy prep_sort postproc evaluator = gen_eval thy (Thm.cterm_of thy)
   491   (K o postproc (postprocess_term thy)) prep_sort (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 (name, (add, del)) =
   500       Code.add_attribute (name, Args.del |-- Scan.succeed (mk_attribute del)
   501         || Scan.succeed (mk_attribute add))
   502   in
   503     add_del_attribute ("inline", (add_inline, del_inline))
   504     #> add_del_attribute ("post", (add_post, del_post))
   505     #> Code.add_attribute ("unfold", Scan.succeed (Thm.declaration_attribute
   506        (fn thm => Context.mapping (Codegen.add_unfold thm #> add_inline thm) I)))
   507   end;
   508 
   509 val _ =
   510   OuterSyntax.improper_command "print_codeproc" "print code preprocessor setup"
   511   OuterKeyword.diag (Scan.succeed
   512       (Toplevel.no_timing o Toplevel.unknown_theory o Toplevel.keep
   513         (print_codeproc o Toplevel.theory_of)));
   514 
   515 end; (*struct*)