doc-src/TutorialI/Types/Records.thy
author paulson
Mon, 12 Nov 2001 10:56:38 +0100
changeset 12156 d2758965362e
parent 11942 06fac365248d
child 12407 70ebb59264f1
permissions -rw-r--r--
new-style numerals without leading #, along with generic 0 and 1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
     1
(*  Title:      HOL/ex/Records.thy
8db249f786ee for the records section
paulson
parents:
diff changeset
     2
    ID:         $Id$
8db249f786ee for the records section
paulson
parents:
diff changeset
     3
    Author:     Wolfgang Naraschewski and Markus Wenzel, TU Muenchen
8db249f786ee for the records section
paulson
parents:
diff changeset
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
8db249f786ee for the records section
paulson
parents:
diff changeset
     5
*)
8db249f786ee for the records section
paulson
parents:
diff changeset
     6
8db249f786ee for the records section
paulson
parents:
diff changeset
     7
header {* Extensible Records  *}
8db249f786ee for the records section
paulson
parents:
diff changeset
     8
8db249f786ee for the records section
paulson
parents:
diff changeset
     9
theory Records = Main:
8db249f786ee for the records section
paulson
parents:
diff changeset
    10
8db249f786ee for the records section
paulson
parents:
diff changeset
    11
subsection {* Points *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    12
8db249f786ee for the records section
paulson
parents:
diff changeset
    13
record point =
8db249f786ee for the records section
paulson
parents:
diff changeset
    14
  Xcoord :: int
8db249f786ee for the records section
paulson
parents:
diff changeset
    15
  Ycoord :: int
8db249f786ee for the records section
paulson
parents:
diff changeset
    16
8db249f786ee for the records section
paulson
parents:
diff changeset
    17
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    18
 Apart many other things, above record declaration produces the
8db249f786ee for the records section
paulson
parents:
diff changeset
    19
 following theorems:
8db249f786ee for the records section
paulson
parents:
diff changeset
    20
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    21
11428
332347b9b942 tidying the index
paulson
parents: 11389
diff changeset
    22
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
    23
thm "point.simps"
8db249f786ee for the records section
paulson
parents:
diff changeset
    24
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    25
Incomprehensible equations: the selectors Xcoord and Ycoord, also "more";
8db249f786ee for the records section
paulson
parents:
diff changeset
    26
Updates, make, make_scheme and equality introduction (extensionality)
8db249f786ee for the records section
paulson
parents:
diff changeset
    27
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    28
8db249f786ee for the records section
paulson
parents:
diff changeset
    29
thm "point.iffs"
8db249f786ee for the records section
paulson
parents:
diff changeset
    30
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    31
@{thm[display] point.iffs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    32
%%\rulename{point.iffs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    33
Simplify equations involving Xcoord, Ycoord (and presumably also both Xcoord and Ycoord)
8db249f786ee for the records section
paulson
parents:
diff changeset
    34
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    35
8db249f786ee for the records section
paulson
parents:
diff changeset
    36
thm "point.update_defs"
8db249f786ee for the records section
paulson
parents:
diff changeset
    37
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    38
@{thm[display] point.update_defs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    39
%%\rulename{point.update_defs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    40
Definitions of updates to Xcoord and Ycoord, also "more"
8db249f786ee for the records section
paulson
parents:
diff changeset
    41
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    42
8db249f786ee for the records section
paulson
parents:
diff changeset
    43
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    44
 The set of theorems @{thm [source] point.simps} is added
8db249f786ee for the records section
paulson
parents:
diff changeset
    45
 automatically to the standard simpset, @{thm [source] point.iffs} is
8db249f786ee for the records section
paulson
parents:
diff changeset
    46
 added to the Classical Reasoner and Simplifier context.
8db249f786ee for the records section
paulson
parents:
diff changeset
    47
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    48
8db249f786ee for the records section
paulson
parents:
diff changeset
    49
text {* Exchanging Xcoord and Ycoord yields a different type: we must
8db249f786ee for the records section
paulson
parents:
diff changeset
    50
unfortunately write the fields in a canonical order.*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    51
8db249f786ee for the records section
paulson
parents:
diff changeset
    52
8db249f786ee for the records section
paulson
parents:
diff changeset
    53
constdefs 
8db249f786ee for the records section
paulson
parents:
diff changeset
    54
  pt1 :: point
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
    55
   "pt1 == (| Xcoord = 999, Ycoord = 23 |)"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
    56
8db249f786ee for the records section
paulson
parents:
diff changeset
    57
  pt2 :: "(| Xcoord :: int, Ycoord :: int |)" 
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
    58
   "pt2 == (| Xcoord = -45, Ycoord = 97 |)" 
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
    59
8db249f786ee for the records section
paulson
parents:
diff changeset
    60
8db249f786ee for the records section
paulson
parents:
diff changeset
    61
subsubsection {* Some lemmas about records *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    62
8db249f786ee for the records section
paulson
parents:
diff changeset
    63
text {* Basic simplifications. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    64
8db249f786ee for the records section
paulson
parents:
diff changeset
    65
lemma "point.make a b = (| Xcoord = a, Ycoord = b |)"
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
    66
by (simp add: point.make_def) -- "needed?? forget it"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
    67
8db249f786ee for the records section
paulson
parents:
diff changeset
    68
lemma "Xcoord (| Xcoord = a, Ycoord = b |) = a"
8db249f786ee for the records section
paulson
parents:
diff changeset
    69
by simp -- "selection"
8db249f786ee for the records section
paulson
parents:
diff changeset
    70
8db249f786ee for the records section
paulson
parents:
diff changeset
    71
lemma "(| Xcoord = a, Ycoord = b |) (| Xcoord:= 0 |) = (| Xcoord = 0, Ycoord = b |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
    72
by simp -- "update"
8db249f786ee for the records section
paulson
parents:
diff changeset
    73
8db249f786ee for the records section
paulson
parents:
diff changeset
    74
subsection {* Coloured points: record extension *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    75
8db249f786ee for the records section
paulson
parents:
diff changeset
    76
8db249f786ee for the records section
paulson
parents:
diff changeset
    77
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    78
 Records are extensible.
8db249f786ee for the records section
paulson
parents:
diff changeset
    79
 
8db249f786ee for the records section
paulson
parents:
diff changeset
    80
 The name@{text  "more"} is reserved, since it is used for extensibility.
8db249f786ee for the records section
paulson
parents:
diff changeset
    81
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    82
8db249f786ee for the records section
paulson
parents:
diff changeset
    83
8db249f786ee for the records section
paulson
parents:
diff changeset
    84
datatype colour = Red | Green | Blue
8db249f786ee for the records section
paulson
parents:
diff changeset
    85
8db249f786ee for the records section
paulson
parents:
diff changeset
    86
record cpoint = point +
8db249f786ee for the records section
paulson
parents:
diff changeset
    87
  col :: colour
8db249f786ee for the records section
paulson
parents:
diff changeset
    88
8db249f786ee for the records section
paulson
parents:
diff changeset
    89
8db249f786ee for the records section
paulson
parents:
diff changeset
    90
constdefs 
8db249f786ee for the records section
paulson
parents:
diff changeset
    91
  cpt1 :: cpoint
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
    92
   "cpt1 == (| Xcoord = 999, Ycoord = 23, col = Green |)"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
    93
8db249f786ee for the records section
paulson
parents:
diff changeset
    94
8db249f786ee for the records section
paulson
parents:
diff changeset
    95
subsection {* Generic operations *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    96
8db249f786ee for the records section
paulson
parents:
diff changeset
    97
8db249f786ee for the records section
paulson
parents:
diff changeset
    98
text {* Record selection and record update; these are generic! *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    99
8db249f786ee for the records section
paulson
parents:
diff changeset
   100
lemma "Xcoord (| Xcoord = a, Ycoord = b, ... = p |) = a"
8db249f786ee for the records section
paulson
parents:
diff changeset
   101
by simp -- "selection"
8db249f786ee for the records section
paulson
parents:
diff changeset
   102
8db249f786ee for the records section
paulson
parents:
diff changeset
   103
lemma "point.more cpt1 = \<lparr>col = Green\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   104
by (simp add: cpt1_def) -- "tail of this record"
8db249f786ee for the records section
paulson
parents:
diff changeset
   105
8db249f786ee for the records section
paulson
parents:
diff changeset
   106
8db249f786ee for the records section
paulson
parents:
diff changeset
   107
lemma "(| Xcoord = a, Ycoord = b, ... = p |) (| Xcoord:= 0 |) = (| Xcoord = 0, Ycoord = b, ... = p |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   108
by simp -- "update"
8db249f786ee for the records section
paulson
parents:
diff changeset
   109
8db249f786ee for the records section
paulson
parents:
diff changeset
   110
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   111
  Record declarations define new type abbreviations:
8db249f786ee for the records section
paulson
parents:
diff changeset
   112
  @{text [display]
8db249f786ee for the records section
paulson
parents:
diff changeset
   113
"    point = (| Xcoord :: int, Ycoord :: int |)
8db249f786ee for the records section
paulson
parents:
diff changeset
   114
    'a point_scheme = (| Xcoord :: int, Ycoord :: int, ... :: 'a |)"}
8db249f786ee for the records section
paulson
parents:
diff changeset
   115
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   116
8db249f786ee for the records section
paulson
parents:
diff changeset
   117
constdefs
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   118
  getX :: "'a point_scheme \<Rightarrow> int"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   119
   "getX r == Xcoord r"
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   120
  setX :: "['a point_scheme, int] \<Rightarrow> 'a point_scheme"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   121
   "setX r a == r (| Xcoord := a |)"
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   122
  extendpt :: "'a \<Rightarrow> 'a point_scheme"
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   123
   "extendpt ext == (| Xcoord = 15, Ycoord = 0, ... = ext |)"
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   124
     text{*not sure what this is for!*}  (* FIXME use new point.make/extend/truncate *)
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   125
8db249f786ee for the records section
paulson
parents:
diff changeset
   126
8db249f786ee for the records section
paulson
parents:
diff changeset
   127
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   128
 \medskip Concrete records are type instances of record schemes.
8db249f786ee for the records section
paulson
parents:
diff changeset
   129
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   130
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   131
lemma "getX (| Xcoord = 64, Ycoord = 36 |) = 64"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   132
by (simp add: getX_def) 
8db249f786ee for the records section
paulson
parents:
diff changeset
   133
8db249f786ee for the records section
paulson
parents:
diff changeset
   134
8db249f786ee for the records section
paulson
parents:
diff changeset
   135
text {* \medskip Manipulating the `...' (more) part.  beware: EACH record
8db249f786ee for the records section
paulson
parents:
diff changeset
   136
   has its OWN more field, so a compound name is required! *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   137
8db249f786ee for the records section
paulson
parents:
diff changeset
   138
constdefs
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   139
  incX :: "'a point_scheme \<Rightarrow> 'a point_scheme"
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   140
  "incX r == \<lparr>Xcoord = (Xcoord r) + 1, Ycoord = Ycoord r, \<dots> = point.more r\<rparr>"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   141
8db249f786ee for the records section
paulson
parents:
diff changeset
   142
constdefs
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   143
  setGreen :: "[colour, 'a point_scheme] \<Rightarrow> cpoint"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   144
  "setGreen cl r == (| Xcoord = Xcoord r, Ycoord = Ycoord r, col = cl |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   145
8db249f786ee for the records section
paulson
parents:
diff changeset
   146
8db249f786ee for the records section
paulson
parents:
diff changeset
   147
text {* works (I think) for ALL extensions of type point? *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   148
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   149
lemma "incX r = setX r ((getX r) + 1)"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   150
by (simp add: getX_def setX_def incX_def)
8db249f786ee for the records section
paulson
parents:
diff changeset
   151
8db249f786ee for the records section
paulson
parents:
diff changeset
   152
text {* An equivalent definition. *}
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   153
lemma "incX r = r \<lparr>Xcoord := (Xcoord r) + 1\<rparr>"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   154
by (simp add: incX_def)
8db249f786ee for the records section
paulson
parents:
diff changeset
   155
8db249f786ee for the records section
paulson
parents:
diff changeset
   156
8db249f786ee for the records section
paulson
parents:
diff changeset
   157
8db249f786ee for the records section
paulson
parents:
diff changeset
   158
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   159
 Functions on @{text point} schemes work for type @{text cpoint} as
8db249f786ee for the records section
paulson
parents:
diff changeset
   160
 well.  *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   161
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   162
lemma "getX \<lparr>Xcoord = 23, Ycoord = 10, col = Blue\<rparr> = 23"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   163
by (simp add: getX_def)
8db249f786ee for the records section
paulson
parents:
diff changeset
   164
8db249f786ee for the records section
paulson
parents:
diff changeset
   165
8db249f786ee for the records section
paulson
parents:
diff changeset
   166
subsubsection {* Non-coercive structural subtyping *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   167
8db249f786ee for the records section
paulson
parents:
diff changeset
   168
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   169
 Function @{term setX} can be applied to type @{typ cpoint}, not just type
8db249f786ee for the records section
paulson
parents:
diff changeset
   170
 @{typ point}, and returns a result of the same type!  *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   171
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   172
lemma "setX \<lparr>Xcoord = 12, Ycoord = 0, col = Blue\<rparr> 23 =  
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   173
            \<lparr>Xcoord = 23, Ycoord = 0, col = Blue\<rparr>"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   174
by (simp add: setX_def)
8db249f786ee for the records section
paulson
parents:
diff changeset
   175
8db249f786ee for the records section
paulson
parents:
diff changeset
   176
8db249f786ee for the records section
paulson
parents:
diff changeset
   177
subsection {* Other features *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   178
8db249f786ee for the records section
paulson
parents:
diff changeset
   179
text {* Field names (and order) contribute to record identity. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   180
8db249f786ee for the records section
paulson
parents:
diff changeset
   181
8db249f786ee for the records section
paulson
parents:
diff changeset
   182
text {* \medskip Polymorphic records. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   183
8db249f786ee for the records section
paulson
parents:
diff changeset
   184
record 'a polypoint = point +
8db249f786ee for the records section
paulson
parents:
diff changeset
   185
  content :: 'a
8db249f786ee for the records section
paulson
parents:
diff changeset
   186
8db249f786ee for the records section
paulson
parents:
diff changeset
   187
types cpolypoint = "colour polypoint"
8db249f786ee for the records section
paulson
parents:
diff changeset
   188
8db249f786ee for the records section
paulson
parents:
diff changeset
   189
8db249f786ee for the records section
paulson
parents:
diff changeset
   190
subsection {* Equality of records. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   191
8db249f786ee for the records section
paulson
parents:
diff changeset
   192
lemma "(\<lparr>Xcoord = a, Ycoord = b\<rparr> = \<lparr>Xcoord = a', Ycoord = b'\<rparr>) = (a = a' & b = b')"
8db249f786ee for the records section
paulson
parents:
diff changeset
   193
  -- "simplification of concrete record equality"
8db249f786ee for the records section
paulson
parents:
diff changeset
   194
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   195
8db249f786ee for the records section
paulson
parents:
diff changeset
   196
text {* \medskip Surjective pairing *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   197
8db249f786ee for the records section
paulson
parents:
diff changeset
   198
lemma "r = \<lparr>Xcoord = Xcoord r, Ycoord = Ycoord r\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   199
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   200
8db249f786ee for the records section
paulson
parents:
diff changeset
   201
8db249f786ee for the records section
paulson
parents:
diff changeset
   202
8db249f786ee for the records section
paulson
parents:
diff changeset
   203
lemma "\<lparr>Xcoord = a, Ycoord = b, \<dots> = p\<rparr> = \<lparr>Xcoord = a, Ycoord = b\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   204
by auto
8db249f786ee for the records section
paulson
parents:
diff changeset
   205
8db249f786ee for the records section
paulson
parents:
diff changeset
   206
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   207
 A rigid record has ()::unit in its  name@{text "more"} part
8db249f786ee for the records section
paulson
parents:
diff changeset
   208
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   209
8db249f786ee for the records section
paulson
parents:
diff changeset
   210
text {* a polymorphic record equality (covers all possible extensions) *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   211
lemma "r \<lparr>Xcoord := a\<rparr> \<lparr>Ycoord := b\<rparr> = r \<lparr>Ycoord := b\<rparr> \<lparr>Xcoord := a\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   212
  -- "introduction of abstract record equality
11389
55e2aef8909b the records section
paulson
parents: 11387
diff changeset
   213
         (order of updates doesn't affect the value)"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   214
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   215
8db249f786ee for the records section
paulson
parents:
diff changeset
   216
lemma "r \<lparr>Xcoord := a, Ycoord := b\<rparr> = r \<lparr>Ycoord := b, Xcoord := a\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   217
  -- "abstract record equality (the same with iterated updates)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   218
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   219
8db249f786ee for the records section
paulson
parents:
diff changeset
   220
text {* Showing that repeated updates don't matter *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   221
lemma "r \<lparr>Xcoord := a\<rparr> \<lparr>Xcoord := a'\<rparr> = r \<lparr>Xcoord := a'\<rparr>"
11389
55e2aef8909b the records section
paulson
parents: 11387
diff changeset
   222
by simp
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   223
8db249f786ee for the records section
paulson
parents:
diff changeset
   224
8db249f786ee for the records section
paulson
parents:
diff changeset
   225
text {* surjective *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   226
8db249f786ee for the records section
paulson
parents:
diff changeset
   227
lemma "r = \<lparr>Xcoord = Xcoord r, Ycoord = Ycoord r, \<dots> = point.more r\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   228
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   229
8db249f786ee for the records section
paulson
parents:
diff changeset
   230
8db249f786ee for the records section
paulson
parents:
diff changeset
   231
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   232
 \medskip Splitting abstract record variables.
8db249f786ee for the records section
paulson
parents:
diff changeset
   233
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   234
8db249f786ee for the records section
paulson
parents:
diff changeset
   235
lemma "r \<lparr>Xcoord := a\<rparr> = r \<lparr>Xcoord := a'\<rparr> \<Longrightarrow> a = a'"
8db249f786ee for the records section
paulson
parents:
diff changeset
   236
  -- "elimination of abstract record equality (manual proof, by selector)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   237
apply (drule_tac f=Xcoord in arg_cong)
8db249f786ee for the records section
paulson
parents:
diff changeset
   238
    --{* @{subgoals[display,indent=0,margin=65]} *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   239
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   240
8db249f786ee for the records section
paulson
parents:
diff changeset
   241
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   242
So we replace the ugly manual proof by splitting.  These must be quantified: 
8db249f786ee for the records section
paulson
parents:
diff changeset
   243
  the @{text "!!r"} is \emph{necessary}!  Note the occurrence of more, since
8db249f786ee for the records section
paulson
parents:
diff changeset
   244
  r is polymorphic.
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   245
*}  (* FIXME better us cases/induct *)
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   246
lemma "!!r. r \<lparr>Xcoord := a\<rparr> = r \<lparr>Xcoord := a'\<rparr> \<Longrightarrow> a = a'"
8db249f786ee for the records section
paulson
parents:
diff changeset
   247
apply record_split --{* @{subgoals[display,indent=0,margin=65]} *}
11942
06fac365248d accomodate some recent changes of record package;
wenzelm
parents: 11711
diff changeset
   248
by simp
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   249
8db249f786ee for the records section
paulson
parents:
diff changeset
   250
end