src/Tools/code/code_wellsorted.ML
author haftmann
Fri Apr 17 14:29:56 2009 +0200 (2009-04-17)
changeset 30947 dd551284a300
parent 30942 1e246776f876
child 30970 3fe2e418a071
permissions -rw-r--r--
re-engineering of evaluation conversions
haftmann@30010
     1
(*  Title:      Tools/code/code_wellsorted.ML
haftmann@30010
     2
    Author:     Florian Haftmann, TU Muenchen
haftmann@30010
     3
haftmann@30061
     4
Producing well-sorted systems of code equations in a graph
haftmann@30010
     5
with explicit dependencies -- the Waisenhaus algorithm.
haftmann@30010
     6
*)
haftmann@30010
     7
haftmann@30202
     8
signature CODE_WELLSORTED =
haftmann@30010
     9
sig
haftmann@30947
    10
  type code_algebra
haftmann@30947
    11
  type code_graph
haftmann@30947
    12
  val eqns: code_graph -> string -> (thm * bool) list
haftmann@30947
    13
  val typ: code_graph -> string -> (string * sort) list * typ
haftmann@30947
    14
  val all: code_graph -> string list
haftmann@30947
    15
  val pretty: theory -> code_graph -> Pretty.T
haftmann@30947
    16
  val obtain: theory -> string list -> term list -> code_algebra * code_graph
haftmann@30947
    17
  val eval_conv: theory -> (sort -> sort)
haftmann@30947
    18
    -> (code_algebra -> code_graph -> (string * sort) list -> term -> cterm -> thm) -> cterm -> thm
haftmann@30947
    19
  val eval_term: theory -> (sort -> sort)
haftmann@30947
    20
    -> (code_algebra -> code_graph -> (string * sort) list -> term -> term) -> term -> term
haftmann@30947
    21
  val eval: theory -> (sort -> sort)
haftmann@30947
    22
    -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a
haftmann@30010
    23
end
haftmann@30010
    24
haftmann@30202
    25
structure Code_Wellsorted : CODE_WELLSORTED =
haftmann@30010
    26
struct
haftmann@30010
    27
haftmann@30947
    28
(** the algebra and code equation graph types **)
haftmann@30010
    29
haftmann@30947
    30
type code_algebra = (sort -> sort) * Sorts.algebra;
haftmann@30947
    31
type code_graph = (((string * sort) list * typ) * (thm * bool) list) Graph.T;
haftmann@30010
    32
haftmann@30010
    33
fun eqns eqngr = these o Option.map snd o try (Graph.get_node eqngr);
haftmann@30010
    34
fun typ eqngr = fst o Graph.get_node eqngr;
haftmann@30010
    35
fun all eqngr = Graph.keys eqngr;
haftmann@30010
    36
haftmann@30010
    37
fun pretty thy eqngr =
haftmann@30010
    38
  AList.make (snd o Graph.get_node eqngr) (Graph.keys eqngr)
haftmann@30010
    39
  |> (map o apfst) (Code_Unit.string_of_const thy)
haftmann@30010
    40
  |> sort (string_ord o pairself fst)
haftmann@30010
    41
  |> map (fn (s, thms) =>
haftmann@30010
    42
       (Pretty.block o Pretty.fbreaks) (
haftmann@30010
    43
         Pretty.str s
haftmann@30010
    44
         :: map (Display.pretty_thm o fst) thms
haftmann@30010
    45
       ))
haftmann@30010
    46
  |> Pretty.chunks;
haftmann@30010
    47
haftmann@30010
    48
haftmann@30010
    49
(** the Waisenhaus algorithm **)
haftmann@30010
    50
haftmann@30010
    51
(* auxiliary *)
haftmann@30010
    52
haftmann@30942
    53
fun is_proper_class thy = can (AxClass.get_info thy);
haftmann@30942
    54
haftmann@30010
    55
fun complete_proper_sort thy =
haftmann@30942
    56
  Sign.complete_sort thy #> filter (is_proper_class thy);
haftmann@30010
    57
haftmann@30029
    58
fun inst_params thy tyco =
haftmann@30010
    59
  map (fn (c, _) => AxClass.param_of_inst thy (c, tyco))
haftmann@30029
    60
    o maps (#params o AxClass.get_info thy);
haftmann@30010
    61
haftmann@30010
    62
fun consts_of thy eqns = [] |> (fold o fold o fold_aterms)
haftmann@30010
    63
  (fn Const (c, ty) => insert (op =) (c, Sign.const_typargs thy (c, Logic.unvarifyT ty)) | _ => I)
haftmann@30010
    64
    (map (op :: o swap o apfst (snd o strip_comb) o Logic.dest_equals o Thm.plain_prop_of o fst) eqns);
haftmann@30010
    65
haftmann@30010
    66
fun tyscm_rhss_of thy c eqns =
haftmann@30010
    67
  let
haftmann@30010
    68
    val tyscm = case eqns of [] => Code.default_typscheme thy c
haftmann@30010
    69
      | ((thm, _) :: _) => (snd o Code_Unit.head_eqn thy) thm;
haftmann@30010
    70
    val rhss = consts_of thy eqns;
haftmann@30010
    71
  in (tyscm, rhss) end;
haftmann@30010
    72
haftmann@30010
    73
haftmann@30010
    74
(* data structures *)
haftmann@30010
    75
haftmann@30010
    76
datatype const = Fun of string | Inst of class * string;
haftmann@30010
    77
haftmann@30010
    78
fun const_ord (Fun c1, Fun c2) = fast_string_ord (c1, c2)
haftmann@30010
    79
  | const_ord (Inst class_tyco1, Inst class_tyco2) =
haftmann@30010
    80
      prod_ord fast_string_ord fast_string_ord (class_tyco1, class_tyco2)
haftmann@30010
    81
  | const_ord (Fun _, Inst _) = LESS
haftmann@30010
    82
  | const_ord (Inst _, Fun _) = GREATER;
haftmann@30010
    83
haftmann@30010
    84
type var = const * int;
haftmann@30010
    85
haftmann@30010
    86
structure Vargraph =
haftmann@30010
    87
  GraphFun(type key = var val ord = prod_ord const_ord int_ord);
haftmann@30010
    88
haftmann@30054
    89
datatype styp = Tyco of string * styp list | Var of var | Free;
haftmann@30054
    90
haftmann@30054
    91
fun styp_of c_lhs (Type (tyco, tys)) = Tyco (tyco, map (styp_of c_lhs) tys)
haftmann@30054
    92
  | styp_of c_lhs (TFree (v, _)) = case c_lhs
haftmann@30054
    93
     of SOME (c, lhs) => Var (Fun c, find_index (fn (v', _) => v = v') lhs)
haftmann@30054
    94
      | NONE => Free;
haftmann@30010
    95
haftmann@30054
    96
type vardeps_data = ((string * styp list) list * class list) Vargraph.T
haftmann@30054
    97
  * (((string * sort) list * (thm * bool) list) Symtab.table
haftmann@30054
    98
    * (class * string) list);
haftmann@30010
    99
haftmann@30054
   100
val empty_vardeps_data : vardeps_data =
haftmann@30054
   101
  (Vargraph.empty, (Symtab.empty, []));
haftmann@30054
   102
haftmann@30876
   103
haftmann@30054
   104
(* retrieving equations and instances from the background context *)
haftmann@30010
   105
haftmann@30010
   106
fun obtain_eqns thy eqngr c =
haftmann@30010
   107
  case try (Graph.get_node eqngr) c
haftmann@30058
   108
   of SOME ((lhs, _), eqns) => ((lhs, []), [])
haftmann@30010
   109
    | NONE => let
haftmann@30010
   110
        val eqns = Code.these_eqns thy c
haftmann@30010
   111
          |> burrow_fst (Code_Unit.norm_args thy)
haftmann@30010
   112
          |> burrow_fst (Code_Unit.norm_varnames thy Code_Name.purify_tvar Code_Name.purify_var);
haftmann@30010
   113
        val ((lhs, _), rhss) = tyscm_rhss_of thy c eqns;
haftmann@30010
   114
      in ((lhs, rhss), eqns) end;
haftmann@30010
   115
haftmann@30010
   116
fun obtain_instance thy arities (inst as (class, tyco)) =
haftmann@30010
   117
  case AList.lookup (op =) arities inst
haftmann@30010
   118
   of SOME classess => (classess, ([], []))
haftmann@30010
   119
    | NONE => let
haftmann@30029
   120
        val all_classes = complete_proper_sort thy [class];
haftmann@30029
   121
        val superclasses = remove (op =) class all_classes
haftmann@30010
   122
        val classess = map (complete_proper_sort thy)
haftmann@30010
   123
          (Sign.arity_sorts thy tyco [class]);
haftmann@30029
   124
        val inst_params = inst_params thy tyco all_classes;
haftmann@30010
   125
      in (classess, (superclasses, inst_params)) end;
haftmann@30010
   126
haftmann@30054
   127
haftmann@30054
   128
(* computing instantiations *)
haftmann@30054
   129
haftmann@30010
   130
fun add_classes thy arities eqngr c_k new_classes vardeps_data =
haftmann@30010
   131
  let
haftmann@30010
   132
    val (styps, old_classes) = Vargraph.get_node (fst vardeps_data) c_k;
haftmann@30010
   133
    val diff_classes = new_classes |> subtract (op =) old_classes;
haftmann@30010
   134
  in if null diff_classes then vardeps_data
haftmann@30010
   135
  else let
haftmann@30010
   136
    val c_ks = Vargraph.imm_succs (fst vardeps_data) c_k |> insert (op =) c_k;
haftmann@30010
   137
  in
haftmann@30010
   138
    vardeps_data
haftmann@30010
   139
    |> (apfst o Vargraph.map_node c_k o apsnd) (append diff_classes)
haftmann@30054
   140
    |> fold (fn styp => fold (assert_typmatch_inst thy arities eqngr styp) new_classes) styps
haftmann@30010
   141
    |> fold (fn c_k => add_classes thy arities eqngr c_k diff_classes) c_ks
haftmann@30010
   142
  end end
haftmann@30010
   143
and add_styp thy arities eqngr c_k tyco_styps vardeps_data =
haftmann@30010
   144
  let
haftmann@30010
   145
    val (old_styps, classes) = Vargraph.get_node (fst vardeps_data) c_k;
haftmann@30010
   146
  in if member (op =) old_styps tyco_styps then vardeps_data
haftmann@30010
   147
  else
haftmann@30010
   148
    vardeps_data
haftmann@30010
   149
    |> (apfst o Vargraph.map_node c_k o apfst) (cons tyco_styps)
haftmann@30054
   150
    |> fold (assert_typmatch_inst thy arities eqngr tyco_styps) classes
haftmann@30010
   151
  end
haftmann@30010
   152
and add_dep thy arities eqngr c_k c_k' vardeps_data =
haftmann@30010
   153
  let
haftmann@30010
   154
    val (_, classes) = Vargraph.get_node (fst vardeps_data) c_k;
haftmann@30010
   155
  in
haftmann@30010
   156
    vardeps_data
haftmann@30010
   157
    |> add_classes thy arities eqngr c_k' classes
haftmann@30010
   158
    |> apfst (Vargraph.add_edge (c_k, c_k'))
haftmann@30010
   159
  end
haftmann@30054
   160
and assert_typmatch_inst thy arities eqngr (tyco, styps) class vardeps_data =
haftmann@30010
   161
  if can (Sign.arity_sorts thy tyco) [class]
haftmann@30010
   162
  then vardeps_data
haftmann@30054
   163
    |> assert_inst thy arities eqngr (class, tyco)
haftmann@30010
   164
    |> fold_index (fn (k, styp) =>
haftmann@30054
   165
         assert_typmatch thy arities eqngr styp (Inst (class, tyco), k)) styps
haftmann@30010
   166
  else vardeps_data (*permissive!*)
haftmann@30054
   167
and assert_inst thy arities eqngr (inst as (class, tyco)) (vardeps_data as (_, (_, insts))) =
haftmann@30054
   168
  if member (op =) insts inst then vardeps_data
haftmann@30054
   169
  else let
haftmann@30010
   170
    val (classess, (superclasses, inst_params)) =
haftmann@30010
   171
      obtain_instance thy arities inst;
haftmann@30010
   172
  in
haftmann@30010
   173
    vardeps_data
haftmann@30054
   174
    |> (apsnd o apsnd) (insert (op =) inst)
haftmann@30083
   175
    |> fold_index (fn (k, _) =>
haftmann@30083
   176
         apfst (Vargraph.new_node ((Inst (class, tyco), k), ([] ,[])))) classess
haftmann@30054
   177
    |> fold (fn superclass => assert_inst thy arities eqngr (superclass, tyco)) superclasses
haftmann@30054
   178
    |> fold (assert_fun thy arities eqngr) inst_params
haftmann@30010
   179
    |> fold_index (fn (k, classes) =>
haftmann@30075
   180
         add_classes thy arities eqngr (Inst (class, tyco), k) classes
haftmann@30010
   181
         #> fold (fn superclass =>
haftmann@30010
   182
             add_dep thy arities eqngr (Inst (superclass, tyco), k)
haftmann@30010
   183
             (Inst (class, tyco), k)) superclasses
haftmann@30010
   184
         #> fold (fn inst_param =>
haftmann@30010
   185
             add_dep thy arities eqngr (Fun inst_param, k)
haftmann@30010
   186
             (Inst (class, tyco), k)
haftmann@30010
   187
             ) inst_params
haftmann@30010
   188
         ) classess
haftmann@30010
   189
  end
haftmann@30054
   190
and assert_typmatch thy arities eqngr (Tyco tyco_styps) c_k vardeps_data =
haftmann@30054
   191
      vardeps_data
haftmann@30054
   192
      |> add_styp thy arities eqngr c_k tyco_styps
haftmann@30054
   193
  | assert_typmatch thy arities eqngr (Var c_k') c_k vardeps_data =
haftmann@30054
   194
      vardeps_data
haftmann@30054
   195
      |> add_dep thy arities eqngr c_k c_k'
haftmann@30054
   196
  | assert_typmatch thy arities eqngr Free c_k vardeps_data =
haftmann@30054
   197
      vardeps_data
haftmann@30054
   198
and assert_rhs thy arities eqngr (c', styps) vardeps_data =
haftmann@30054
   199
  vardeps_data
haftmann@30054
   200
  |> assert_fun thy arities eqngr c'
haftmann@30054
   201
  |> fold_index (fn (k, styp) =>
haftmann@30054
   202
       assert_typmatch thy arities eqngr styp (Fun c', k)) styps
haftmann@30054
   203
and assert_fun thy arities eqngr c (vardeps_data as (_, (eqntab, _))) =
haftmann@30054
   204
  if Symtab.defined eqntab c then vardeps_data
haftmann@30054
   205
  else let
haftmann@30010
   206
    val ((lhs, rhss), eqns) = obtain_eqns thy eqngr c;
haftmann@30054
   207
    val rhss' = (map o apsnd o map) (styp_of (SOME (c, lhs))) rhss;
haftmann@30010
   208
  in
haftmann@30010
   209
    vardeps_data
haftmann@30054
   210
    |> (apsnd o apfst) (Symtab.update_new (c, (lhs, eqns)))
haftmann@30083
   211
    |> fold_index (fn (k, _) =>
haftmann@30083
   212
         apfst (Vargraph.new_node ((Fun c, k), ([] ,[])))) lhs
haftmann@30010
   213
    |> fold_index (fn (k, (_, sort)) =>
haftmann@30083
   214
         add_classes thy arities eqngr (Fun c, k) (complete_proper_sort thy sort)) lhs
haftmann@30054
   215
    |> fold (assert_rhs thy arities eqngr) rhss'
haftmann@30054
   216
  end;
haftmann@30010
   217
haftmann@30010
   218
haftmann@30010
   219
(* applying instantiations *)
haftmann@30010
   220
haftmann@30010
   221
fun dicts_of thy (proj_sort, algebra) (T, sort) =
haftmann@30010
   222
  let
haftmann@30010
   223
    fun class_relation (x, _) _ = x;
haftmann@30010
   224
    fun type_constructor tyco xs class =
haftmann@30054
   225
      inst_params thy tyco (Sorts.complete_sort algebra [class])
haftmann@30054
   226
        @ (maps o maps) fst xs;
haftmann@30010
   227
    fun type_variable (TFree (_, sort)) = map (pair []) (proj_sort sort);
haftmann@30010
   228
  in
haftmann@30010
   229
    flat (Sorts.of_sort_derivation (Syntax.pp_global thy) algebra
haftmann@30010
   230
      { class_relation = class_relation, type_constructor = type_constructor,
haftmann@30010
   231
        type_variable = type_variable } (T, proj_sort sort)
haftmann@30010
   232
       handle Sorts.CLASS_ERROR _ => [] (*permissive!*))
haftmann@30010
   233
  end;
haftmann@30010
   234
haftmann@30054
   235
fun add_arity thy vardeps (class, tyco) =
haftmann@30058
   236
  AList.default (op =)
haftmann@30054
   237
    ((class, tyco), map (fn k => (snd o Vargraph.get_node vardeps) (Inst (class, tyco), k))
haftmann@30054
   238
      (0 upto Sign.arity_number thy tyco - 1));
haftmann@30010
   239
haftmann@30942
   240
fun add_eqs thy vardeps (c, (proto_lhs, proto_eqns)) (rhss, eqngr) =
haftmann@30058
   241
  if can (Graph.get_node eqngr) c then (rhss, eqngr)
haftmann@30058
   242
  else let
haftmann@30010
   243
    val lhs = map_index (fn (k, (v, _)) =>
haftmann@30010
   244
      (v, snd (Vargraph.get_node vardeps (Fun c, k)))) proto_lhs;
haftmann@30010
   245
    val inst_tab = Vartab.empty |> fold (fn (v, sort) =>
haftmann@30010
   246
      Vartab.update ((v, 0), sort)) lhs;
haftmann@30010
   247
    val eqns = proto_eqns
haftmann@30010
   248
      |> (map o apfst) (Code_Unit.inst_thm thy inst_tab);
haftmann@30054
   249
    val (tyscm, rhss') = tyscm_rhss_of thy c eqns;
haftmann@30054
   250
    val eqngr' = Graph.new_node (c, (tyscm, eqns)) eqngr;
haftmann@30054
   251
  in (map (pair c) rhss' @ rhss, eqngr') end;
haftmann@30010
   252
haftmann@30942
   253
fun extend_arities_eqngr thy cs ts (arities, eqngr) =
haftmann@30010
   254
  let
haftmann@30942
   255
    val cs_rhss = (fold o fold_aterms) (fn Const (c_ty as (c, _)) =>
haftmann@30942
   256
      insert (op =) (c, (map (styp_of NONE) o Sign.const_typargs thy) c_ty) | _ => I) ts [];
haftmann@30054
   257
    val (vardeps, (eqntab, insts)) = empty_vardeps_data
haftmann@30054
   258
      |> fold (assert_fun thy arities eqngr) cs
haftmann@30942
   259
      |> fold (assert_rhs thy arities eqngr) cs_rhss;
haftmann@30054
   260
    val arities' = fold (add_arity thy vardeps) insts arities;
haftmann@30064
   261
    val pp = Syntax.pp_global thy;
haftmann@30942
   262
    val algebra = Sorts.subalgebra pp (is_proper_class thy)
haftmann@30064
   263
      (AList.lookup (op =) arities') (Sign.classes_of thy);
haftmann@30942
   264
    val (rhss, eqngr') = Symtab.fold (add_eqs thy vardeps) eqntab ([], eqngr);
haftmann@30942
   265
    fun deps_of (c, rhs) = c :: maps (dicts_of thy algebra)
haftmann@30942
   266
      (rhs ~~ (map snd o fst o fst o Graph.get_node eqngr') c);
haftmann@30054
   267
    val eqngr'' = fold (fn (c, rhs) => fold
haftmann@30054
   268
      (curry Graph.add_edge c) (deps_of rhs)) rhss eqngr';
haftmann@30942
   269
  in (algebra, (arities', eqngr'')) end;
haftmann@30010
   270
haftmann@30010
   271
haftmann@30942
   272
(** store **)
haftmann@30010
   273
haftmann@30010
   274
structure Wellsorted = CodeDataFun
haftmann@30010
   275
(
haftmann@30947
   276
  type T = ((string * class) * sort list) list * code_graph;
haftmann@30010
   277
  val empty = ([], Graph.empty);
haftmann@30010
   278
  fun purge thy cs (arities, eqngr) =
haftmann@30010
   279
    let
haftmann@30010
   280
      val del_cs = ((Graph.all_preds eqngr
haftmann@30010
   281
        o filter (can (Graph.get_node eqngr))) cs);
haftmann@30050
   282
      val del_arities = del_cs
haftmann@30050
   283
        |> map_filter (AxClass.inst_of_param thy)
haftmann@30050
   284
        |> maps (fn (c, tyco) =>
haftmann@30050
   285
             (map (rpair tyco) o Sign.complete_sort thy o the_list
haftmann@30050
   286
               o AxClass.class_of_param thy) c);
haftmann@30010
   287
      val arities' = fold (AList.delete (op =)) del_arities arities;
haftmann@30010
   288
      val eqngr' = Graph.del_nodes del_cs eqngr;
haftmann@30010
   289
    in (arities', eqngr') end;
haftmann@30010
   290
);
haftmann@30010
   291
haftmann@30010
   292
haftmann@30942
   293
(** retrieval interfaces **)
haftmann@30010
   294
haftmann@30942
   295
fun obtain thy cs ts = apsnd snd
haftmann@30942
   296
  (Wellsorted.change_yield thy (extend_arities_eqngr thy cs ts));
haftmann@30010
   297
haftmann@30947
   298
fun prepare_sorts prep_sort (Const (c, ty)) = Const (c, map_type_tfree
haftmann@30947
   299
      (fn (v, sort) => TFree (v, prep_sort sort)) ty)
haftmann@30947
   300
  | prepare_sorts prep_sort (t1 $ t2) =
haftmann@30947
   301
      prepare_sorts prep_sort t1 $ prepare_sorts prep_sort t2
haftmann@30947
   302
  | prepare_sorts prep_sort (Abs (v, ty, t)) =
haftmann@30947
   303
      Abs (v, Type.strip_sorts ty, prepare_sorts prep_sort t)
haftmann@30947
   304
  | prepare_sorts _ (Term.Free (v, ty)) = Term.Free (v, Type.strip_sorts ty)
haftmann@30947
   305
  | prepare_sorts _ (t as Bound _) = t;
haftmann@30010
   306
haftmann@30947
   307
fun gen_eval thy cterm_of conclude_evaluation prep_sort evaluator proto_ct =
haftmann@30942
   308
  let
haftmann@30942
   309
    val ct = cterm_of proto_ct;
haftmann@30947
   310
    val _ = (Term.map_types Type.no_tvars o Sign.no_vars (Syntax.pp_global thy))
haftmann@30947
   311
      (Thm.term_of ct);
haftmann@30942
   312
    val thm = Code.preprocess_conv thy ct;
haftmann@30942
   313
    val ct' = Thm.rhs_of thm;
haftmann@30942
   314
    val t' = Thm.term_of ct';
haftmann@30947
   315
    val vs = Term.add_tfrees t' [];
haftmann@30947
   316
    val consts = fold_aterms
haftmann@30947
   317
      (fn Const (c, _) => insert (op =) c | _ => I) t' [];
haftmann@30947
   318
    val t'' = prepare_sorts prep_sort t';
haftmann@30942
   319
    val (algebra', eqngr') = obtain thy consts [t''];
haftmann@30947
   320
  in conclude_evaluation (evaluator algebra' eqngr' vs t'' ct') thm end;
haftmann@30947
   321
haftmann@30947
   322
fun simple_evaluator evaluator algebra eqngr vs t ct =
haftmann@30947
   323
  evaluator algebra eqngr vs t;
haftmann@30010
   324
haftmann@30942
   325
fun eval_conv thy =
haftmann@30942
   326
  let
haftmann@30947
   327
    fun conclude_evaluation thm2 thm1 =
haftmann@30942
   328
      let
haftmann@30942
   329
        val thm3 = Code.postprocess_conv thy (Thm.rhs_of thm2);
haftmann@30942
   330
      in
haftmann@30942
   331
        Thm.transitive thm1 (Thm.transitive thm2 thm3) handle THM _ =>
haftmann@30942
   332
          error ("could not construct evaluation proof:\n"
haftmann@30942
   333
          ^ (cat_lines o map Display.string_of_thm) [thm1, thm2, thm3])
haftmann@30942
   334
      end;
haftmann@30947
   335
  in gen_eval thy I conclude_evaluation end;
haftmann@30010
   336
haftmann@30947
   337
fun eval_term thy prep_sort evaluator = gen_eval thy (Thm.cterm_of thy)
haftmann@30947
   338
  (fn t => K (Code.postprocess_term thy t)) prep_sort (simple_evaluator evaluator);
haftmann@30947
   339
haftmann@30947
   340
fun eval thy prep_sort evaluator = gen_eval thy (Thm.cterm_of thy)
haftmann@30947
   341
  (fn t => K t) prep_sort (simple_evaluator evaluator);
haftmann@30010
   342
haftmann@30010
   343
end; (*struct*)