Nominal/nominal_dt_data.ML
author Christian Urban <urbanc@in.tum.de>
Thu, 23 Jun 2011 13:09:17 +0100
changeset 2890 503630c553a8
child 2927 116f9ba4f59f
permissions -rw-r--r--
added file
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2890
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
(* Author: Christian Urban
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
   data about nominal datatypes 
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
*)
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
signature NOMINAL_DT_DATA =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
sig
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  type info =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
   {inject : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
    distinct : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
    strong_inducts : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
    strong_exhaust : thm list}
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  val get_all_info: Proof.context -> (string * info) list
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  val get_info: Proof.context -> string -> info option
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  val the_info: Proof.context -> string -> info 
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
  val register_info: (string * info) -> Context.generic -> Context.generic
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
  val mk_infos: string list -> thm list -> thm list -> thm list -> thm list -> (string * info) list
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
end
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
structure Nominal_Dt_Data: NOMINAL_DT_DATA =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
struct
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
(* information generated by nominal_datatype *)
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
type info =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
   {inject : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
    distinct : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
    strong_inducts : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
    strong_exhaust : thm list}
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
structure NominalData = Generic_Data
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
 (type T = info Symtab.table
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  val empty = Symtab.empty
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
  val extend = I
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  val merge = Symtab.merge (K true))
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
val get_all_info = Symtab.dest o NominalData.get o Context.Proof
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
val get_info = Symtab.lookup o NominalData.get o Context.Proof
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
val register_info = NominalData.map o Symtab.update
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
fun the_info thy name =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  (case get_info thy name of
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
    SOME info => info
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  | NONE => error ("Unknown nominal datatype " ^ quote name))
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
fun mk_infos ty_names inject distinct strong_inducts strong_exhaust =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
let
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
  fun aux ty_name =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
    (ty_name, {inject = inject,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
               distinct = distinct,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
               strong_inducts = strong_inducts,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
               strong_exhaust = strong_exhaust 
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
              })
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
in
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  map aux ty_names
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
end
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
end