src/HOL/Record.thy
author wenzelm
Wed Sep 27 19:34:46 2000 +0200 (2000-09-27)
changeset 10093 44584c2b512b
parent 9729 40cfc3dd27da
child 10309 a7f961fb62c6
permissions -rw-r--r--
more symbolic syntax (currently "input");
wenzelm@4870
     1
(*  Title:      HOL/Record.thy
wenzelm@4870
     2
    ID:         $Id$
wenzelm@4870
     3
    Author:     Wolfgang Naraschewski and Markus Wenzel, TU Muenchen
wenzelm@4870
     4
wenzelm@4870
     5
Extensible records with structural subtyping in HOL.  See
wenzelm@4870
     6
Tools/record_package.ML for the actual implementation.
wenzelm@4870
     7
*)
wenzelm@4870
     8
wenzelm@7357
     9
theory Record = Datatype
wenzelm@7357
    10
files "Tools/record_package.ML":
wenzelm@4870
    11
wenzelm@4870
    12
wenzelm@4870
    13
(* concrete syntax *)
wenzelm@4870
    14
wenzelm@4870
    15
nonterminals
wenzelm@5198
    16
  ident field_type field_types field fields update updates
wenzelm@4870
    17
wenzelm@4870
    18
syntax
wenzelm@5198
    19
  (*field names*)
wenzelm@10093
    20
  ""                    :: "id => ident"                                ("_")
wenzelm@10093
    21
  ""                    :: "longid => ident"                            ("_")
wenzelm@5198
    22
wenzelm@5198
    23
  (*record types*)
wenzelm@10093
    24
  "_field_type"         :: "[ident, type] => field_type"                ("(2_ ::/ _)")
wenzelm@10093
    25
  ""                    :: "field_type => field_types"                  ("_")
wenzelm@10093
    26
  "_field_types"        :: "[field_type, field_types] => field_types"   ("_,/ _")
wenzelm@10093
    27
  "_record_type"        :: "field_types => type"                        ("(3'(| _ |'))")
wenzelm@10093
    28
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3'(| _,/ (2... ::/ _) |'))")
wenzelm@5198
    29
wenzelm@5198
    30
  (*records*)
wenzelm@10093
    31
  "_field"              :: "[ident, 'a] => field"                       ("(2_ =/ _)")
wenzelm@10093
    32
  ""                    :: "field => fields"                            ("_")
wenzelm@10093
    33
  "_fields"             :: "[field, fields] => fields"                  ("_,/ _")
wenzelm@10093
    34
  "_record"             :: "fields => 'a"                               ("(3'(| _ |'))")
wenzelm@10093
    35
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3'(| _,/ (2... =/ _) |'))")
wenzelm@5198
    36
wenzelm@5198
    37
  (*record updates*)
wenzelm@10093
    38
  "_update"             :: "[ident, 'a] => update"                      ("(2_ :=/ _)")
wenzelm@10093
    39
  ""                    :: "update => updates"                          ("_")
wenzelm@10093
    40
  "_updates"            :: "[update, updates] => updates"               ("_,/ _")
wenzelm@10093
    41
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3'(| _ |'))" [900,0] 900)
wenzelm@4870
    42
wenzelm@10093
    43
syntax (input)   (* FIXME (xsymbols) *)
wenzelm@10093
    44
  "_record_type"        :: "field_types => type"                        ("(3\<lparr>_\<rparr>)")
wenzelm@10093
    45
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3\<lparr>_,/ (2\<dots> ::/ _)\<rparr>)")
wenzelm@10093
    46
  "_record"             :: "fields => 'a"                               ("(3\<lparr>_\<rparr>)")
wenzelm@10093
    47
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3\<lparr>_,/ (2\<dots> =/ _)\<rparr>)")
wenzelm@10093
    48
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3\<lparr>_\<rparr>)" [900,0] 900)
wenzelm@9729
    49
wenzelm@4870
    50
wenzelm@4870
    51
(* type class for record extensions *)
wenzelm@4870
    52
wenzelm@7357
    53
axclass more < "term"
wenzelm@4870
    54
instance unit :: more
wenzelm@7357
    55
  by intro_classes
wenzelm@4870
    56
wenzelm@4870
    57
wenzelm@4870
    58
(* initialize the package *)
wenzelm@4870
    59
wenzelm@4870
    60
setup
wenzelm@4870
    61
  RecordPackage.setup
wenzelm@4870
    62
wenzelm@4870
    63
wenzelm@4870
    64
end