Nominal/nominal_dt_data.ML
author Christian Urban <urbanc@in.tum.de>
Sat, 12 May 2012 22:24:04 +0100
branchNominal2-Isabelle2012
changeset 3171 f5057aabf5c0
parent 3065 51ef8a3cb6ef
child 3239 67370521c09c
permissions -rw-r--r--
further cleaning
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
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
     8
  (* info of raw binding functions *)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
     9
  type bn_info = term * int * (int * term option) list list
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    10
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    11
  (* binding modes and binding clauses *)
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    12
  datatype bmode = Lst | Res | Set
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    13
  datatype bclause = BC of bmode * (term option * int) list * int list
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    14
2890
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  type info =
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    16
    {inject : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    17
     distinct : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    18
     strong_inducts : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    19
     strong_exhaust : thm list}
2890
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
  val get_all_info: Proof.context -> (string * info) list
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  val get_info: Proof.context -> string -> info option
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  val the_info: Proof.context -> string -> info 
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
  val register_info: (string * info) -> Context.generic -> Context.generic
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  val mk_infos: string list -> thm list -> thm list -> thm list -> thm list -> (string * info) list
2927
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    26
2959
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
    27
  datatype user_data = UserData of
3065
51ef8a3cb6ef updated to lates changes in the datatype package
Christian Urban <urbanc@in.tum.de>
parents: 2959
diff changeset
    28
    {dts      : Datatype.spec list,
2959
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
    29
     cn_names : string list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
    30
     cn_tys   : (string * string) list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
    31
     bn_funs  : (binding * typ * mixfix) list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
    32
     bn_eqs   : (Attrib.binding * term) list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
    33
     bclauses : bclause list list list}
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
    34
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    35
  datatype raw_dt_info = RawDtInfo of
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    36
    {raw_dt_names         : string list,
3065
51ef8a3cb6ef updated to lates changes in the datatype package
Christian Urban <urbanc@in.tum.de>
parents: 2959
diff changeset
    37
     raw_dts              : Datatype.spec list,
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    38
     raw_tys              : typ list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    39
     raw_ty_args          : (string * sort) list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    40
     raw_cns_info         : cns_info list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    41
     raw_all_cns          : term list list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    42
     raw_inject_thms      : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    43
     raw_distinct_thms    : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    44
     raw_induct_thm       : thm,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    45
     raw_induct_thms      : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    46
     raw_exhaust_thms     : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    47
     raw_size_trms        : term list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    48
     raw_size_thms        : thm list}
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    49
2927
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    50
  datatype alpha_result = AlphaResult of
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    51
    {alpha_names      : string list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    52
     alpha_trms       : term list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    53
     alpha_tys        : typ list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    54
     alpha_bn_names   : string list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    55
     alpha_bn_trms    : term list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    56
     alpha_bn_tys     : typ list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    57
     alpha_intros     : thm list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    58
     alpha_cases      : thm list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    59
     alpha_raw_induct : thm}
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    60
   
2890
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
end
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
structure Nominal_Dt_Data: NOMINAL_DT_DATA =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
struct
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    66
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    67
(* term              - is constant of the bn-function 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    68
   int               - is datatype number over which the bn-function is defined
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    69
   int * term option - is number of the corresponding argument with possibly
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    70
                       recursive call with bn-function term 
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    71
*)  
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    72
type bn_info = term * int * (int * term option) list list
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    73
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    74
datatype bmode = Lst | Res | Set
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    75
datatype bclause = BC of bmode * (term option * int) list * int list
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
    76
2927
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
    77
2890
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
(* information generated by nominal_datatype *)
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
type info =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
   {inject : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
    distinct : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
    strong_inducts : thm list,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
    strong_exhaust : thm list}
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
structure NominalData = Generic_Data
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
 (type T = info Symtab.table
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
  val empty = Symtab.empty
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
  val extend = I
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
  val merge = Symtab.merge (K true))
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
val get_all_info = Symtab.dest o NominalData.get o Context.Proof
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
val get_info = Symtab.lookup o NominalData.get o Context.Proof
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
val register_info = NominalData.map o Symtab.update
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
fun the_info thy name =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
  (case get_info thy name of
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
    SOME info => info
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
  | NONE => error ("Unknown nominal datatype " ^ quote name))
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
fun mk_infos ty_names inject distinct strong_inducts strong_exhaust =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
let
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  fun aux ty_name =
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
    (ty_name, {inject = inject,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
               distinct = distinct,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
               strong_inducts = strong_inducts,
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
               strong_exhaust = strong_exhaust 
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
              })
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
in
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  map aux ty_names
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
end
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   112
2959
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   113
datatype user_data = UserData of
3065
51ef8a3cb6ef updated to lates changes in the datatype package
Christian Urban <urbanc@in.tum.de>
parents: 2959
diff changeset
   114
  {dts      : Datatype.spec list,
2959
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   115
   cn_names : string list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   116
   cn_tys   : (string * string) list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   117
   bn_funs  : (binding * typ * mixfix) list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   118
   bn_eqs   : (Attrib.binding * term) list,
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   119
   bclauses : bclause list list list}
9bd97ed202f7 some code refactoring
Christian Urban <urbanc@in.tum.de>
parents: 2957
diff changeset
   120
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   121
datatype raw_dt_info = RawDtInfo of
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   122
  {raw_dt_names         : string list,
3065
51ef8a3cb6ef updated to lates changes in the datatype package
Christian Urban <urbanc@in.tum.de>
parents: 2959
diff changeset
   123
   raw_dts              : Datatype.spec list,
2957
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   124
   raw_tys              : typ list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   125
   raw_ty_args          : (string * sort) list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   126
   raw_cns_info         : cns_info list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   127
   raw_all_cns          : term list list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   128
   raw_inject_thms      : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   129
   raw_distinct_thms    : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   130
   raw_induct_thm       : thm,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   131
   raw_induct_thms      : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   132
   raw_exhaust_thms     : thm list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   133
   raw_size_trms        : term list,
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   134
   raw_size_thms        : thm list}
01ff621599bc code refactoring; introduced a record for raw_dt_info
Christian Urban <urbanc@in.tum.de>
parents: 2927
diff changeset
   135
2927
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   136
datatype alpha_result = AlphaResult of
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   137
  {alpha_names      : string list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   138
   alpha_trms       : term list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   139
   alpha_tys        : typ list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   140
   alpha_bn_names   : string list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   141
   alpha_bn_trms    : term list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   142
   alpha_bn_tys     : typ list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   143
   alpha_intros     : thm list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   144
   alpha_cases      : thm list,
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   145
   alpha_raw_induct : thm}
116f9ba4f59f combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
parents: 2890
diff changeset
   146
2890
503630c553a8 added file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
end