src/HOL/thy_data.ML
author paulson
Wed, 09 Oct 1996 13:32:33 +0200
changeset 2073 fb0655539d05
parent 1726 cbea219f5e5a
child 2562 d571d6660240
permissions -rw-r--r--
New unified treatment of sequent calculi by Sara Kalvala combines the old LK and Modal with the new ILL (Int. Linear Logic)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1455
diff changeset
     1
(*  Title:      HOL/thy_data.ML
1455
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1455
diff changeset
     3
    Author:     Carsten Clasohm
1455
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
     4
    Copyright   1995 TU Muenchen
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
     5
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
     6
Definitions that have to be reread after init_thy_reader has been invoked
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
     7
*)
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
     8
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
     9
fun simpset_of tname =
1657
a7a6c3fb3cdd changed first parameter of add_thydata and get_thydata
clasohm
parents: 1465
diff changeset
    10
  case get_thydata tname "simpset" of
1455
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
    11
      None => empty_ss
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
    12
    | Some (SS_DATA ss) => ss;
52a0271621f3 changed the way simpsets and information about datatypes are stored
clasohm
parents:
diff changeset
    13
1726
cbea219f5e5a Added function claset_of.
berghofe
parents: 1668
diff changeset
    14
fun claset_of tname =
cbea219f5e5a Added function claset_of.
berghofe
parents: 1668
diff changeset
    15
  case get_thydata tname "claset" of
cbea219f5e5a Added function claset_of.
berghofe
parents: 1668
diff changeset
    16
      None => empty_cs
cbea219f5e5a Added function claset_of.
berghofe
parents: 1668
diff changeset
    17
    | Some (CS_DATA cs) => cs;
cbea219f5e5a Added function claset_of.
berghofe
parents: 1668
diff changeset
    18
1668
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    19
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    20
(** Information about datatypes **)
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    21
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    22
(* Retrieve information for a specific datatype *)
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    23
fun datatype_info thy tname =
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    24
  case get_thydata (thyname_of_sign (sign_of thy)) "datatypes" of
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    25
      None => None
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    26
    | Some (DT_DATA ds) => assoc (ds, tname);
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    27
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    28
fun match_info thy tname =
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    29
  case datatype_info thy tname of
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    30
      Some {case_const, constructors, ...} =>
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    31
        {case_const=case_const, constructors=constructors}
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    32
    | None => error ("No datatype \"" ^ tname ^ "\" defined in this theory.");
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    33
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    34
fun induct_info thy tname =
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    35
  case datatype_info thy tname of
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    36
      Some {constructors, nchotomy, ...} =>
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    37
        {constructors=constructors, nchotomy=nchotomy}
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    38
    | None => error ("No datatype \"" ^ tname ^ "\" defined in this theory.");
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    39
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    40
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    41
(* Retrieve information for all datatypes defined in a theory and its
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    42
   ancestors *)
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    43
fun extract_info thy =
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    44
  let val (congs, rewrites) =
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    45
        case get_thydata (thyname_of_sign (sign_of thy)) "datatypes" of
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    46
            None => ([], [])
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    47
          | Some (DT_DATA ds) =>
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    48
              let val info = map snd ds
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    49
              in (map #case_cong info, flat (map #case_rewrites info)) end;
8ead1fe65aad added Konrad's code for the datatype package
clasohm
parents: 1657
diff changeset
    50
  in {case_congs = congs, case_rewrites = rewrites} end;