doc-src/TutorialI/Types/Records.thy
author wenzelm
Mon, 08 Oct 2001 14:29:02 +0200
changeset 11711 ecdfd237ffee
parent 11428 332347b9b942
child 11942 06fac365248d
permissions -rw-r--r--
fixed numerals;
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 |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
    66
by simp -- "needed?? forget it"
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
  Extensions `...' must be in type class @{text more}.
8db249f786ee for the records section
paulson
parents:
diff changeset
   116
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   117
8db249f786ee for the records section
paulson
parents:
diff changeset
   118
constdefs
8db249f786ee for the records section
paulson
parents:
diff changeset
   119
  getX :: "('a::more) point_scheme \<Rightarrow> int"
8db249f786ee for the records section
paulson
parents:
diff changeset
   120
   "getX r == Xcoord r"
8db249f786ee for the records section
paulson
parents:
diff changeset
   121
  setX :: "[('a::more) point_scheme, int] \<Rightarrow> 'a point_scheme"
8db249f786ee for the records section
paulson
parents:
diff changeset
   122
   "setX r a == r (| Xcoord := a |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   123
  extendpt :: "'a \<Rightarrow> ('a::more) point_scheme"
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   124
   "extendpt ext == (| Xcoord = 15, Ycoord = 0, ... = ext |)"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   125
     text{*not sure what this is for!*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   126
8db249f786ee for the records section
paulson
parents:
diff changeset
   127
8db249f786ee for the records section
paulson
parents:
diff changeset
   128
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   129
 \medskip Concrete records are type instances of record schemes.
8db249f786ee for the records section
paulson
parents:
diff changeset
   130
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   131
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   132
lemma "getX (| Xcoord = 64, Ycoord = 36 |) = 64"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   133
by (simp add: getX_def) 
8db249f786ee for the records section
paulson
parents:
diff changeset
   134
8db249f786ee for the records section
paulson
parents:
diff changeset
   135
8db249f786ee for the records section
paulson
parents:
diff changeset
   136
text {* \medskip Manipulating the `...' (more) part.  beware: EACH record
8db249f786ee for the records section
paulson
parents:
diff changeset
   137
   has its OWN more field, so a compound name is required! *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   138
8db249f786ee for the records section
paulson
parents:
diff changeset
   139
constdefs
8db249f786ee for the records section
paulson
parents:
diff changeset
   140
  incX :: "('a::more) point_scheme \<Rightarrow> 'a point_scheme"
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   141
  "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
   142
8db249f786ee for the records section
paulson
parents:
diff changeset
   143
constdefs
8db249f786ee for the records section
paulson
parents:
diff changeset
   144
  setGreen :: "[colour, ('a::more) point_scheme] \<Rightarrow> cpoint"
8db249f786ee for the records section
paulson
parents:
diff changeset
   145
  "setGreen cl r == (| Xcoord = Xcoord r, Ycoord = Ycoord r, col = cl |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   146
8db249f786ee for the records section
paulson
parents:
diff changeset
   147
8db249f786ee for the records section
paulson
parents:
diff changeset
   148
text {* works (I think) for ALL extensions of type point? *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   149
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   150
lemma "incX r = setX r ((getX r) + 1)"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   151
by (simp add: getX_def setX_def incX_def)
8db249f786ee for the records section
paulson
parents:
diff changeset
   152
8db249f786ee for the records section
paulson
parents:
diff changeset
   153
text {* An equivalent definition. *}
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   154
lemma "incX r = r \<lparr>Xcoord := (Xcoord r) + 1\<rparr>"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   155
by (simp add: incX_def)
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   159
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   160
 Functions on @{text point} schemes work for type @{text cpoint} as
8db249f786ee for the records section
paulson
parents:
diff changeset
   161
 well.  *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   162
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   163
lemma "getX \<lparr>Xcoord = 23, Ycoord = 10, col = Blue\<rparr> = 23"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   164
by (simp add: getX_def)
8db249f786ee for the records section
paulson
parents:
diff changeset
   165
8db249f786ee for the records section
paulson
parents:
diff changeset
   166
8db249f786ee for the records section
paulson
parents:
diff changeset
   167
subsubsection {* Non-coercive structural subtyping *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   168
8db249f786ee for the records section
paulson
parents:
diff changeset
   169
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   170
 Function @{term setX} can be applied to type @{typ cpoint}, not just type
8db249f786ee for the records section
paulson
parents:
diff changeset
   171
 @{typ point}, and returns a result of the same type!  *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   172
11711
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   173
lemma "setX \<lparr>Xcoord = 12, Ycoord = 0, col = Blue\<rparr> 23 =  
ecdfd237ffee fixed numerals;
wenzelm
parents: 11428
diff changeset
   174
            \<lparr>Xcoord = 23, Ycoord = 0, col = Blue\<rparr>"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   175
by (simp add: setX_def)
8db249f786ee for the records section
paulson
parents:
diff changeset
   176
8db249f786ee for the records section
paulson
parents:
diff changeset
   177
8db249f786ee for the records section
paulson
parents:
diff changeset
   178
subsection {* Other features *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   179
8db249f786ee for the records section
paulson
parents:
diff changeset
   180
text {* Field names (and order) contribute to record identity. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   181
8db249f786ee for the records section
paulson
parents:
diff changeset
   182
8db249f786ee for the records section
paulson
parents:
diff changeset
   183
text {* \medskip Polymorphic records. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   184
8db249f786ee for the records section
paulson
parents:
diff changeset
   185
record 'a polypoint = point +
8db249f786ee for the records section
paulson
parents:
diff changeset
   186
  content :: 'a
8db249f786ee for the records section
paulson
parents:
diff changeset
   187
8db249f786ee for the records section
paulson
parents:
diff changeset
   188
types cpolypoint = "colour polypoint"
8db249f786ee for the records section
paulson
parents:
diff changeset
   189
8db249f786ee for the records section
paulson
parents:
diff changeset
   190
8db249f786ee for the records section
paulson
parents:
diff changeset
   191
subsection {* Equality of records. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   192
8db249f786ee for the records section
paulson
parents:
diff changeset
   193
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
   194
  -- "simplification of concrete record equality"
8db249f786ee for the records section
paulson
parents:
diff changeset
   195
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   196
8db249f786ee for the records section
paulson
parents:
diff changeset
   197
text {* \medskip Surjective pairing *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   198
8db249f786ee for the records section
paulson
parents:
diff changeset
   199
lemma "r = \<lparr>Xcoord = Xcoord r, Ycoord = Ycoord r\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   200
by simp
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   204
lemma "\<lparr>Xcoord = a, Ycoord = b, \<dots> = p\<rparr> = \<lparr>Xcoord = a, Ycoord = b\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   205
by auto
8db249f786ee for the records section
paulson
parents:
diff changeset
   206
8db249f786ee for the records section
paulson
parents:
diff changeset
   207
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   208
 A rigid record has ()::unit in its  name@{text "more"} part
8db249f786ee for the records section
paulson
parents:
diff changeset
   209
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   210
8db249f786ee for the records section
paulson
parents:
diff changeset
   211
text {* a polymorphic record equality (covers all possible extensions) *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   212
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
   213
  -- "introduction of abstract record equality
11389
55e2aef8909b the records section
paulson
parents: 11387
diff changeset
   214
         (order of updates doesn't affect the value)"
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   215
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   216
8db249f786ee for the records section
paulson
parents:
diff changeset
   217
lemma "r \<lparr>Xcoord := a, Ycoord := b\<rparr> = r \<lparr>Ycoord := b, Xcoord := a\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   218
  -- "abstract record equality (the same with iterated updates)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   219
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   220
8db249f786ee for the records section
paulson
parents:
diff changeset
   221
text {* Showing that repeated updates don't matter *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   222
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
   223
by simp
11387
8db249f786ee for the records section
paulson
parents:
diff changeset
   224
8db249f786ee for the records section
paulson
parents:
diff changeset
   225
8db249f786ee for the records section
paulson
parents:
diff changeset
   226
text {* surjective *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   227
8db249f786ee for the records section
paulson
parents:
diff changeset
   228
lemma "r = \<lparr>Xcoord = Xcoord r, Ycoord = Ycoord r, \<dots> = point.more r\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   229
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   230
8db249f786ee for the records section
paulson
parents:
diff changeset
   231
8db249f786ee for the records section
paulson
parents:
diff changeset
   232
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   233
 \medskip Splitting abstract record variables.
8db249f786ee for the records section
paulson
parents:
diff changeset
   234
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   235
8db249f786ee for the records section
paulson
parents:
diff changeset
   236
lemma "r \<lparr>Xcoord := a\<rparr> = r \<lparr>Xcoord := a'\<rparr> \<Longrightarrow> a = a'"
8db249f786ee for the records section
paulson
parents:
diff changeset
   237
  -- "elimination of abstract record equality (manual proof, by selector)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   238
apply (drule_tac f=Xcoord in arg_cong)
8db249f786ee for the records section
paulson
parents:
diff changeset
   239
    --{* @{subgoals[display,indent=0,margin=65]} *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   240
by simp
8db249f786ee for the records section
paulson
parents:
diff changeset
   241
8db249f786ee for the records section
paulson
parents:
diff changeset
   242
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   243
So we replace the ugly manual proof by splitting.  These must be quantified: 
8db249f786ee for the records section
paulson
parents:
diff changeset
   244
  the @{text "!!r"} is \emph{necessary}!  Note the occurrence of more, since
8db249f786ee for the records section
paulson
parents:
diff changeset
   245
  r is polymorphic.
8db249f786ee for the records section
paulson
parents:
diff changeset
   246
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
   247
lemma "!!r. r \<lparr>Xcoord := a\<rparr> = r \<lparr>Xcoord := a'\<rparr> \<Longrightarrow> a = a'"
8db249f786ee for the records section
paulson
parents:
diff changeset
   248
apply record_split --{* @{subgoals[display,indent=0,margin=65]} *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   249
by simp 
8db249f786ee for the records section
paulson
parents:
diff changeset
   250
8db249f786ee for the records section
paulson
parents:
diff changeset
   251
8db249f786ee for the records section
paulson
parents:
diff changeset
   252
end