src/Pure/Tools/codegen_consts.ML
author haftmann
Fri, 23 Mar 2007 09:40:53 +0100
changeset 22508 6ee2edbce31c
parent 22400 cb0b1bbf7e91
child 22554 d1499fff65d8
permissions -rw-r--r--
added concept for term constructors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20387
haftmann
parents:
diff changeset
     1
(*  Title:      Pure/Tools/codegen_consts.ML
haftmann
parents:
diff changeset
     2
    ID:         $Id$
haftmann
parents:
diff changeset
     3
    Author:     Florian Haftmann, TU Muenchen
haftmann
parents:
diff changeset
     4
20855
9f60d493c8fe clarified header comments
haftmann
parents: 20704
diff changeset
     5
Identifying constants by name plus normalized type instantantiation schemes.
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
     6
Convenient data structures for constants.  Auxiliary.
20387
haftmann
parents:
diff changeset
     7
*)
haftmann
parents:
diff changeset
     8
haftmann
parents:
diff changeset
     9
signature CODEGEN_CONSTS =
haftmann
parents:
diff changeset
    10
sig
haftmann
parents:
diff changeset
    11
  type const = string * typ list (*type instantiations*)
haftmann
parents:
diff changeset
    12
  val const_ord: const * const -> order
haftmann
parents:
diff changeset
    13
  val eq_const: const * const -> bool
haftmann
parents:
diff changeset
    14
  structure Consttab: TABLE
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    15
  val inst_of_typ: theory -> string * typ -> const
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    16
  val typ_of_inst: theory -> const -> string * typ
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    17
  val norm: theory -> const -> const
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    18
  val norm_of_typ: theory -> string * typ -> const
22508
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    19
  val typ_sort_inst: Sorts.algebra -> typ * sort
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    20
    -> sort Vartab.table -> sort Vartab.table
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    21
  val typargs: theory -> string * typ -> typ list
22508
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    22
  val co_of_const: theory -> const
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    23
    -> string * ((string * sort) list * (string * typ list))
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    24
  val co_of_const': theory -> const
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    25
    -> (string * ((string * sort) list * (string * typ list))) option
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    26
  val cos_of_consts: theory -> const list
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    27
    -> string * ((string * sort) list * (string * typ list) list)
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    28
  val const_of_co: theory -> string -> (string * sort) list
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    29
    -> string * typ list -> const
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    30
  val consts_of_cos: theory -> string -> (string * sort) list
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
    31
    -> (string * typ list) list -> const list
22183
0e6c0aeb04ec dropped useless stuff
haftmann
parents: 22049
diff changeset
    32
  val find_def: theory -> const -> (string (*theory name*) * thm) option
21118
d9789a87825d cleanup
haftmann
parents: 20855
diff changeset
    33
  val consts_of: theory -> term -> const list
20387
haftmann
parents:
diff changeset
    34
  val read_const: theory -> string -> const
haftmann
parents:
diff changeset
    35
  val string_of_const: theory -> const -> string
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    36
  val raw_string_of_const: const -> string
20387
haftmann
parents:
diff changeset
    37
  val string_of_const_typ: theory -> string * typ -> string
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    38
  val string_of_typ: theory -> typ -> string
20387
haftmann
parents:
diff changeset
    39
end;
haftmann
parents:
diff changeset
    40
haftmann
parents:
diff changeset
    41
structure CodegenConsts: CODEGEN_CONSTS =
haftmann
parents:
diff changeset
    42
struct
haftmann
parents:
diff changeset
    43
haftmann
parents:
diff changeset
    44
haftmann
parents:
diff changeset
    45
(* basic data structures *)
haftmann
parents:
diff changeset
    46
haftmann
parents:
diff changeset
    47
type const = string * typ list (*type instantiations*);
haftmann
parents:
diff changeset
    48
val const_ord = prod_ord fast_string_ord (list_ord Term.typ_ord);
haftmann
parents:
diff changeset
    49
val eq_const = is_equal o const_ord;
haftmann
parents:
diff changeset
    50
haftmann
parents:
diff changeset
    51
structure Consttab =
haftmann
parents:
diff changeset
    52
  TableFun(
haftmann
parents:
diff changeset
    53
    type key = string * typ list;
haftmann
parents:
diff changeset
    54
    val ord = const_ord;
haftmann
parents:
diff changeset
    55
  );
haftmann
parents:
diff changeset
    56
haftmann
parents:
diff changeset
    57
21463
42dd50268c8b completed class parameter handling in axclass.ML
haftmann
parents: 21118
diff changeset
    58
(* type instantiations, overloading, dictionary values *)
20387
haftmann
parents:
diff changeset
    59
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    60
fun string_of_typ thy = setmp show_sorts true (Sign.string_of_typ thy);
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    61
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    62
fun inst_of_typ thy (c_ty as (c, ty)) =
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    63
  (c, Sign.const_typargs thy c_ty);
20387
haftmann
parents:
diff changeset
    64
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    65
fun typ_of_inst thy (c_tys as (c, tys)) =
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    66
  (c, Sign.const_instance thy c_tys);
20387
haftmann
parents:
diff changeset
    67
20389
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
    68
fun find_def thy (c, tys) =
20387
haftmann
parents:
diff changeset
    69
  let
haftmann
parents:
diff changeset
    70
    val specs = Defs.specifications_of (Theory.defs_of thy) c;
20389
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
    71
    val typ_instance = case AxClass.class_of_param thy c
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
    72
     of SOME _ => let
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
    73
          fun instance_tycos (Type (tyco1, _), Type (tyco2, _)) = tyco1 = tyco2
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
    74
            | instance_tycos (_ , TVar _) = true
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
    75
            | instance_tycos ty_ty = Sign.typ_instance thy ty_ty;
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
    76
        in instance_tycos end
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    77
      | NONE =>  Sign.typ_instance thy;
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    78
    fun get_def (_, { is_def, thyname, name, lhs, rhs }) =
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    79
      if is_def andalso forall typ_instance (tys ~~ lhs) then
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    80
        case try (Thm.get_axiom_i thy) name
22183
0e6c0aeb04ec dropped useless stuff
haftmann
parents: 22049
diff changeset
    81
         of SOME thm => SOME (thyname, thm)
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    82
          | NONE => NONE
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    83
      else NONE
20387
haftmann
parents:
diff changeset
    84
  in
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    85
    get_first get_def specs
20387
haftmann
parents:
diff changeset
    86
  end;
haftmann
parents:
diff changeset
    87
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
    88
fun norm thy (c, insts) =
20387
haftmann
parents:
diff changeset
    89
  let
22183
0e6c0aeb04ec dropped useless stuff
haftmann
parents: 22049
diff changeset
    90
    fun disciplined class [ty as Type (tyco, _)] =
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    91
          let
22400
cb0b1bbf7e91 clarified error message
haftmann
parents: 22197
diff changeset
    92
            val sorts = Sorts.mg_domain (Sign.classes_of thy) tyco [class]
cb0b1bbf7e91 clarified error message
haftmann
parents: 22197
diff changeset
    93
              handle CLASS_ERROR => error ("No such instance: " ^ tyco ^ " :: " ^ class
cb0b1bbf7e91 clarified error message
haftmann
parents: 22197
diff changeset
    94
                ^ ",\nrequired for overloaded constant " ^ c);
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    95
            val vs = Name.invents Name.context "'a" (length sorts);
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    96
          in
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    97
            (c, [Type (tyco, map (fn v => TVar ((v, 0), [])) vs)])
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
    98
          end
22183
0e6c0aeb04ec dropped useless stuff
haftmann
parents: 22049
diff changeset
    99
      | disciplined class _ =
0e6c0aeb04ec dropped useless stuff
haftmann
parents: 22049
diff changeset
   100
          (c, [TVar (("'a", 0), [class])]);
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
   101
  in case AxClass.class_of_param thy c
22183
0e6c0aeb04ec dropped useless stuff
haftmann
parents: 22049
diff changeset
   102
   of SOME class => disciplined class insts
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   103
    | NONE => inst_of_typ thy (c, Sign.the_const_type thy c)
20387
haftmann
parents:
diff changeset
   104
  end;
haftmann
parents:
diff changeset
   105
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
   106
fun norm_of_typ thy (c, ty) =
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   107
  norm thy (c, Sign.const_typargs thy (c, ty));
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
   108
20704
a56f0743b3ee cleaned up
haftmann
parents: 20600
diff changeset
   109
fun consts_of thy t =
21118
d9789a87825d cleanup
haftmann
parents: 20855
diff changeset
   110
  fold_aterms (fn Const c => cons (norm_of_typ thy c) | _ => I) t []
20704
a56f0743b3ee cleaned up
haftmann
parents: 20600
diff changeset
   111
22197
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   112
fun typ_sort_inst algebra =
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   113
  let
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   114
    val inters = Sorts.inter_sort algebra;
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   115
    fun match _ [] = I
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   116
      | match (TVar (v, S)) S' = Vartab.map_default (v, []) (fn S'' => inters (S, inters (S', S'')))
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   117
      | match (Type (a, Ts)) S =
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   118
          fold2 match Ts (Sorts.mg_domain algebra a S)
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   119
  in uncurry match end;
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   120
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   121
fun typargs thy (c_ty as (c, ty)) =
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   122
  let
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   123
    val opt_class = AxClass.class_of_param thy c;
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   124
    val tys = Sign.const_typargs thy (c, ty);
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   125
  in case (opt_class, tys)
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   126
   of (SOME _, [Type (_, tys')]) => tys'
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   127
    | _ => tys
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   128
  end;
461130ccfef4 clarified code
haftmann
parents: 22183
diff changeset
   129
20387
haftmann
parents:
diff changeset
   130
22508
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   131
(* printing *)
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   132
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   133
fun string_of_const thy (c, tys) =
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   134
  space_implode " " (Sign.extern_const thy c
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   135
    :: map (enclose "[" "]" o Sign.string_of_typ thy) tys);
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   136
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   137
fun raw_string_of_const (c, tys) =
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   138
  space_implode " " (c
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   139
    :: map (enclose "[" "]" o Display.raw_string_of_typ) tys);
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   140
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   141
fun string_of_const_typ thy (c, ty) =
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   142
  string_of_const thy (c, Consts.typargs (Sign.consts_of thy) (c, ty));
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   143
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   144
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   145
(* conversion between constants and datatype constructors *)
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   146
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   147
fun const_of_co thy tyco vs (co, tys) =
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   148
  norm_of_typ thy (co, tys ---> Type (tyco, map TFree vs));
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   149
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   150
fun consts_of_cos thy tyco vs cos =
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   151
  let
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   152
    val dty = Type (tyco, map TFree vs);
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   153
    fun mk_co (co, tys) = norm_of_typ thy (co, tys ---> dty);
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   154
  in map mk_co cos end;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   155
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   156
local
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   157
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   158
exception BAD of string;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   159
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   160
fun gen_co_of_const thy const =
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   161
  let
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   162
    val (c, ty) = (apsnd Logic.unvarifyT o typ_of_inst thy) const;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   163
    fun err () = raise BAD
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   164
     ("Illegal type for datatype constructor: " ^ Sign.string_of_typ thy ty);
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   165
    val (tys, ty') = strip_type ty;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   166
    val (tyco, vs) = ((apsnd o map) dest_TFree o dest_Type) ty'
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   167
      handle TYPE _ => err ();
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   168
    val sorts = if has_duplicates (eq_fst op =) vs then err ()
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   169
      else map snd vs;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   170
    val vs_names = Name.invent_list [] "'a" (length vs);
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   171
    val vs_map = map fst vs ~~ vs_names;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   172
    val vs' = vs_names ~~ sorts;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   173
    val tys' = (map o map_type_tfree) (fn (v, sort) =>
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   174
      (TFree ((the o AList.lookup (op =) vs_map) v, sort))) tys
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   175
      handle Option => err ();
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   176
  in (tyco, (vs', (c, tys'))) end;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   177
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   178
in
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   179
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   180
fun co_of_const thy const = gen_co_of_const thy const handle BAD msg => error msg;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   181
fun co_of_const' thy const = SOME (gen_co_of_const thy const) handle BAD msg => NONE;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   182
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   183
end;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   184
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   185
fun cos_of_consts thy consts =
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   186
  let
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   187
    val raw_cos  = map (co_of_const thy) consts;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   188
    val (tyco, (vs_names, sorts_cos)) = if (length o distinct (eq_fst op =)) raw_cos = 1
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   189
      then ((fst o hd) raw_cos, ((map fst o fst o snd o hd) raw_cos,
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   190
        map ((apfst o map) snd o snd) raw_cos))
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   191
      else error ("Term constructors not referring to the same type: "
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   192
        ^ commas (map (string_of_const thy) consts));
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   193
    val sorts = foldr1 ((uncurry o map2 o curry o Sorts.inter_sort) (Sign.classes_of thy))
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   194
      (map fst sorts_cos);
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   195
    val cos = map snd sorts_cos;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   196
    val vs = vs_names ~~ sorts;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   197
  in (tyco, (vs, cos)) end;
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   198
6ee2edbce31c added concept for term constructors
haftmann
parents: 22400
diff changeset
   199
20387
haftmann
parents:
diff changeset
   200
(* reading constants as terms *)
haftmann
parents:
diff changeset
   201
haftmann
parents:
diff changeset
   202
fun read_const_typ thy raw_t =
haftmann
parents:
diff changeset
   203
  let
haftmann
parents:
diff changeset
   204
    val t = Sign.read_term thy raw_t
haftmann
parents:
diff changeset
   205
  in case try dest_Const t
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
   206
   of SOME c_ty => (typ_of_inst thy o norm_of_typ thy) c_ty
20389
8b6ecb22ef35 cleanup
haftmann
parents: 20387
diff changeset
   207
    | NONE => error ("Not a constant: " ^ Sign.string_of_term thy t)
20387
haftmann
parents:
diff changeset
   208
  end;
haftmann
parents:
diff changeset
   209
haftmann
parents:
diff changeset
   210
fun read_const thy =
20600
6d75e02ed285 added codegen_data
haftmann
parents: 20456
diff changeset
   211
  norm_of_typ thy o read_const_typ thy;
20387
haftmann
parents:
diff changeset
   212
haftmann
parents:
diff changeset
   213
haftmann
parents:
diff changeset
   214
end;