src/HOL/Record.thy
author wenzelm
Thu Oct 04 20:29:42 2007 +0200 (2007-10-04)
changeset 24850 0cfd722ab579
parent 22817 9dfadec17cc4
child 25705 45a2ffc5911e
permissions -rw-r--r--
Name.uu, Name.aT;
     1 (*  Title:      HOL/Record.thy
     2     ID:         $Id$
     3     Author:     Wolfgang Naraschewski, Norbert Schirmer and Markus Wenzel, TU Muenchen
     4 *)
     5 
     6 header {* Extensible records with structural subtyping *}
     7 
     8 theory Record
     9 imports Product_Type
    10 uses ("Tools/record_package.ML")
    11 begin
    12 
    13 lemma prop_subst: "s = t \<Longrightarrow> PROP P t \<Longrightarrow> PROP P s"
    14   by simp
    15 
    16 lemma rec_UNIV_I: "\<And>x. x\<in>UNIV \<equiv> True"
    17   by simp
    18 
    19 lemma rec_True_simp: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"
    20   by simp
    21 
    22 constdefs
    23   K_record:: "'a \<Rightarrow> 'b \<Rightarrow> 'a"
    24   K_record_apply [simp, code func]: "K_record c x \<equiv> c"
    25 
    26 lemma K_record_comp [simp]: "(K_record c \<circ> f) = K_record c"
    27   by (rule ext) (simp add: K_record_apply comp_def)
    28 
    29 lemma K_record_cong [cong]: "K_record c x = K_record c x"
    30   by (rule refl)
    31 
    32 
    33 subsection {* Concrete record syntax *}
    34 
    35 nonterminals
    36   ident field_type field_types field fields update updates
    37 syntax
    38   "_constify"           :: "id => ident"                        ("_")
    39   "_constify"           :: "longid => ident"                    ("_")
    40 
    41   "_field_type"         :: "[ident, type] => field_type"        ("(2_ ::/ _)")
    42   ""                    :: "field_type => field_types"          ("_")
    43   "_field_types"        :: "[field_type, field_types] => field_types"    ("_,/ _")
    44   "_record_type"        :: "field_types => type"                ("(3'(| _ |'))")
    45   "_record_type_scheme" :: "[field_types, type] => type"        ("(3'(| _,/ (2... ::/ _) |'))")
    46 
    47   "_field"              :: "[ident, 'a] => field"               ("(2_ =/ _)")
    48   ""                    :: "field => fields"                    ("_")
    49   "_fields"             :: "[field, fields] => fields"          ("_,/ _")
    50   "_record"             :: "fields => 'a"                       ("(3'(| _ |'))")
    51   "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3'(| _,/ (2... =/ _) |'))")
    52 
    53   "_update_name"        :: idt
    54   "_update"             :: "[ident, 'a] => update"              ("(2_ :=/ _)")
    55   ""                    :: "update => updates"                  ("_")
    56   "_updates"            :: "[update, updates] => updates"       ("_,/ _")
    57   "_record_update"      :: "['a, updates] => 'b"                ("_/(3'(| _ |'))" [900,0] 900)
    58 
    59 syntax (xsymbols)
    60   "_record_type"        :: "field_types => type"                ("(3\<lparr>_\<rparr>)")
    61   "_record_type_scheme" :: "[field_types, type] => type"        ("(3\<lparr>_,/ (2\<dots> ::/ _)\<rparr>)")
    62   "_record"             :: "fields => 'a"                               ("(3\<lparr>_\<rparr>)")
    63   "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3\<lparr>_,/ (2\<dots> =/ _)\<rparr>)")
    64   "_record_update"      :: "['a, updates] => 'b"                ("_/(3\<lparr>_\<rparr>)" [900,0] 900)
    65 
    66 use "Tools/record_package.ML"
    67 setup RecordPackage.setup
    68 
    69 end