src/HOL/Record.thy
author wenzelm
Wed Sep 17 21:27:14 2008 +0200 (2008-09-17)
changeset 28263 69eaa97e7e96
parent 25705 45a2ffc5911e
child 31723 f5cafe803b55
permissions -rw-r--r--
moved global ML bindings to global place;
wenzelm@4870
     1
(*  Title:      HOL/Record.thy
wenzelm@4870
     2
    ID:         $Id$
wenzelm@16114
     3
    Author:     Wolfgang Naraschewski, Norbert Schirmer and Markus Wenzel, TU Muenchen
wenzelm@4870
     4
*)
wenzelm@4870
     5
wenzelm@22817
     6
header {* Extensible records with structural subtyping *}
wenzelm@22817
     7
nipkow@15131
     8
theory Record
nipkow@15140
     9
imports Product_Type
haftmann@16417
    10
uses ("Tools/record_package.ML")
nipkow@15131
    11
begin
wenzelm@4870
    12
schirmer@14700
    13
lemma prop_subst: "s = t \<Longrightarrow> PROP P t \<Longrightarrow> PROP P s"
schirmer@14700
    14
  by simp
wenzelm@11826
    15
schirmer@14700
    16
lemma rec_UNIV_I: "\<And>x. x\<in>UNIV \<equiv> True"
schirmer@14700
    17
  by simp
wenzelm@11826
    18
schirmer@14700
    19
lemma rec_True_simp: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"
schirmer@14700
    20
  by simp
berghofe@14080
    21
schirmer@25705
    22
lemma K_record_comp: "(\<lambda>x. c) \<circ> f = (\<lambda>x. c)" 
schirmer@25705
    23
  by (simp add: comp_def)
wenzelm@11821
    24
wenzelm@22817
    25
wenzelm@11833
    26
subsection {* Concrete record syntax *}
wenzelm@4870
    27
wenzelm@4870
    28
nonterminals
wenzelm@5198
    29
  ident field_type field_types field fields update updates
wenzelm@4870
    30
syntax
wenzelm@11821
    31
  "_constify"           :: "id => ident"                        ("_")
wenzelm@11821
    32
  "_constify"           :: "longid => ident"                    ("_")
wenzelm@5198
    33
wenzelm@11821
    34
  "_field_type"         :: "[ident, type] => field_type"        ("(2_ ::/ _)")
wenzelm@11821
    35
  ""                    :: "field_type => field_types"          ("_")
wenzelm@11821
    36
  "_field_types"        :: "[field_type, field_types] => field_types"    ("_,/ _")
wenzelm@11821
    37
  "_record_type"        :: "field_types => type"                ("(3'(| _ |'))")
wenzelm@10093
    38
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3'(| _,/ (2... ::/ _) |'))")
wenzelm@5198
    39
wenzelm@11821
    40
  "_field"              :: "[ident, 'a] => field"               ("(2_ =/ _)")
wenzelm@11821
    41
  ""                    :: "field => fields"                    ("_")
wenzelm@11821
    42
  "_fields"             :: "[field, fields] => fields"          ("_,/ _")
wenzelm@11821
    43
  "_record"             :: "fields => 'a"                       ("(3'(| _ |'))")
wenzelm@10093
    44
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3'(| _,/ (2... =/ _) |'))")
wenzelm@5198
    45
wenzelm@10641
    46
  "_update_name"        :: idt
wenzelm@11821
    47
  "_update"             :: "[ident, 'a] => update"              ("(2_ :=/ _)")
wenzelm@11821
    48
  ""                    :: "update => updates"                  ("_")
wenzelm@11821
    49
  "_updates"            :: "[update, updates] => updates"       ("_,/ _")
wenzelm@10093
    50
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3'(| _ |'))" [900,0] 900)
wenzelm@4870
    51
wenzelm@10331
    52
syntax (xsymbols)
wenzelm@11821
    53
  "_record_type"        :: "field_types => type"                ("(3\<lparr>_\<rparr>)")
wenzelm@10093
    54
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3\<lparr>_,/ (2\<dots> ::/ _)\<rparr>)")
wenzelm@10093
    55
  "_record"             :: "fields => 'a"                               ("(3\<lparr>_\<rparr>)")
wenzelm@10093
    56
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3\<lparr>_,/ (2\<dots> =/ _)\<rparr>)")
wenzelm@10093
    57
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3\<lparr>_\<rparr>)" [900,0] 900)
wenzelm@9729
    58
wenzelm@16114
    59
use "Tools/record_package.ML"
wenzelm@16114
    60
setup RecordPackage.setup
wenzelm@10641
    61
wenzelm@4870
    62
end