src/HOL/Record.thy
author haftmann
Fri Apr 20 11:21:42 2007 +0200 (2007-04-20)
changeset 22744 5cbe966d67a2
parent 21226 a607ae87ee81
child 22759 e4a3f49eb924
permissions -rw-r--r--
Isar definitions are now added explicitly to code theorem table
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
nipkow@15131
     6
theory Record
nipkow@15140
     7
imports Product_Type
haftmann@16417
     8
uses ("Tools/record_package.ML")
nipkow@15131
     9
begin
wenzelm@4870
    10
schirmer@14700
    11
lemma prop_subst: "s = t \<Longrightarrow> PROP P t \<Longrightarrow> PROP P s"
schirmer@14700
    12
  by simp
wenzelm@11826
    13
schirmer@14700
    14
lemma rec_UNIV_I: "\<And>x. x\<in>UNIV \<equiv> True"
schirmer@14700
    15
  by simp
wenzelm@11826
    16
schirmer@14700
    17
lemma rec_True_simp: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"
schirmer@14700
    18
  by simp
berghofe@14080
    19
haftmann@22744
    20
definition
haftmann@22744
    21
  K_record:: "'a \<Rightarrow> 'b \<Rightarrow> 'a"
haftmann@22744
    22
where
haftmann@22744
    23
  K_record_apply [simp]: "K_record c x = c"
schirmer@21226
    24
schirmer@21226
    25
lemma K_record_comp [simp]: "(K_record c \<circ> f) = K_record c"
schirmer@21226
    26
  by (rule ext) (simp add: K_record_apply comp_def)
schirmer@21226
    27
schirmer@21226
    28
lemma K_record_cong [cong]: "K_record c x = K_record c x"
schirmer@21226
    29
  by (rule refl)
wenzelm@11821
    30
wenzelm@11833
    31
subsection {* Concrete record syntax *}
wenzelm@4870
    32
wenzelm@4870
    33
nonterminals
wenzelm@5198
    34
  ident field_type field_types field fields update updates
wenzelm@4870
    35
syntax
wenzelm@11821
    36
  "_constify"           :: "id => ident"                        ("_")
wenzelm@11821
    37
  "_constify"           :: "longid => ident"                    ("_")
wenzelm@5198
    38
wenzelm@11821
    39
  "_field_type"         :: "[ident, type] => field_type"        ("(2_ ::/ _)")
wenzelm@11821
    40
  ""                    :: "field_type => field_types"          ("_")
wenzelm@11821
    41
  "_field_types"        :: "[field_type, field_types] => field_types"    ("_,/ _")
wenzelm@11821
    42
  "_record_type"        :: "field_types => type"                ("(3'(| _ |'))")
wenzelm@10093
    43
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3'(| _,/ (2... ::/ _) |'))")
wenzelm@5198
    44
wenzelm@11821
    45
  "_field"              :: "[ident, 'a] => field"               ("(2_ =/ _)")
wenzelm@11821
    46
  ""                    :: "field => fields"                    ("_")
wenzelm@11821
    47
  "_fields"             :: "[field, fields] => fields"          ("_,/ _")
wenzelm@11821
    48
  "_record"             :: "fields => 'a"                       ("(3'(| _ |'))")
wenzelm@10093
    49
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3'(| _,/ (2... =/ _) |'))")
wenzelm@5198
    50
wenzelm@10641
    51
  "_update_name"        :: idt
wenzelm@11821
    52
  "_update"             :: "[ident, 'a] => update"              ("(2_ :=/ _)")
wenzelm@11821
    53
  ""                    :: "update => updates"                  ("_")
wenzelm@11821
    54
  "_updates"            :: "[update, updates] => updates"       ("_,/ _")
wenzelm@10093
    55
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3'(| _ |'))" [900,0] 900)
wenzelm@4870
    56
wenzelm@10331
    57
syntax (xsymbols)
wenzelm@11821
    58
  "_record_type"        :: "field_types => type"                ("(3\<lparr>_\<rparr>)")
wenzelm@10093
    59
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3\<lparr>_,/ (2\<dots> ::/ _)\<rparr>)")
wenzelm@10093
    60
  "_record"             :: "fields => 'a"                               ("(3\<lparr>_\<rparr>)")
wenzelm@10093
    61
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3\<lparr>_,/ (2\<dots> =/ _)\<rparr>)")
wenzelm@10093
    62
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3\<lparr>_\<rparr>)" [900,0] 900)
wenzelm@9729
    63
wenzelm@16114
    64
use "Tools/record_package.ML"
wenzelm@16114
    65
setup RecordPackage.setup
wenzelm@10641
    66
wenzelm@4870
    67
end
schirmer@14700
    68