src/HOL/Record.thy
author wenzelm
Fri Mar 28 19:43:54 2008 +0100 (2008-03-28)
changeset 26462 dac4e2bce00d
parent 25705 45a2ffc5911e
child 31723 f5cafe803b55
permissions -rw-r--r--
avoid rebinding of existing facts;
     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 lemma K_record_comp: "(\<lambda>x. c) \<circ> f = (\<lambda>x. c)" 
    23   by (simp add: comp_def)
    24 
    25 
    26 subsection {* Concrete record syntax *}
    27 
    28 nonterminals
    29   ident field_type field_types field fields update updates
    30 syntax
    31   "_constify"           :: "id => ident"                        ("_")
    32   "_constify"           :: "longid => ident"                    ("_")
    33 
    34   "_field_type"         :: "[ident, type] => field_type"        ("(2_ ::/ _)")
    35   ""                    :: "field_type => field_types"          ("_")
    36   "_field_types"        :: "[field_type, field_types] => field_types"    ("_,/ _")
    37   "_record_type"        :: "field_types => type"                ("(3'(| _ |'))")
    38   "_record_type_scheme" :: "[field_types, type] => type"        ("(3'(| _,/ (2... ::/ _) |'))")
    39 
    40   "_field"              :: "[ident, 'a] => field"               ("(2_ =/ _)")
    41   ""                    :: "field => fields"                    ("_")
    42   "_fields"             :: "[field, fields] => fields"          ("_,/ _")
    43   "_record"             :: "fields => 'a"                       ("(3'(| _ |'))")
    44   "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3'(| _,/ (2... =/ _) |'))")
    45 
    46   "_update_name"        :: idt
    47   "_update"             :: "[ident, 'a] => update"              ("(2_ :=/ _)")
    48   ""                    :: "update => updates"                  ("_")
    49   "_updates"            :: "[update, updates] => updates"       ("_,/ _")
    50   "_record_update"      :: "['a, updates] => 'b"                ("_/(3'(| _ |'))" [900,0] 900)
    51 
    52 syntax (xsymbols)
    53   "_record_type"        :: "field_types => type"                ("(3\<lparr>_\<rparr>)")
    54   "_record_type_scheme" :: "[field_types, type] => type"        ("(3\<lparr>_,/ (2\<dots> ::/ _)\<rparr>)")
    55   "_record"             :: "fields => 'a"                               ("(3\<lparr>_\<rparr>)")
    56   "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3\<lparr>_,/ (2\<dots> =/ _)\<rparr>)")
    57   "_record_update"      :: "['a, updates] => 'b"                ("_/(3\<lparr>_\<rparr>)" [900,0] 900)
    58 
    59 use "Tools/record_package.ML"
    60 setup RecordPackage.setup
    61 
    62 end