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