doc-src/TutorialI/Types/Records.thy
author paulson
Fri, 29 Jun 2001 18:12:18 +0200
changeset 11389 55e2aef8909b
parent 11387 8db249f786ee
child 11428 332347b9b942
permissions -rw-r--r--
the records section
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
8db249f786ee for the records section
paulson
parents:
diff changeset
    22
thm "point.simps"
8db249f786ee for the records section
paulson
parents:
diff changeset
    23
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    24
Incomprehensible equations: the selectors Xcoord and Ycoord, also "more";
8db249f786ee for the records section
paulson
parents:
diff changeset
    25
Updates, make, make_scheme and equality introduction (extensionality)
8db249f786ee for the records section
paulson
parents:
diff changeset
    26
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    27
8db249f786ee for the records section
paulson
parents:
diff changeset
    28
thm "point.iffs"
8db249f786ee for the records section
paulson
parents:
diff changeset
    29
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    30
@{thm[display] point.iffs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    31
%%\rulename{point.iffs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    32
Simplify equations involving Xcoord, Ycoord (and presumably also both Xcoord and Ycoord)
8db249f786ee for the records section
paulson
parents:
diff changeset
    33
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    34
8db249f786ee for the records section
paulson
parents:
diff changeset
    35
thm "point.update_defs"
8db249f786ee for the records section
paulson
parents:
diff changeset
    36
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    37
@{thm[display] point.update_defs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    38
%%\rulename{point.update_defs}
8db249f786ee for the records section
paulson
parents:
diff changeset
    39
Definitions of updates to Xcoord and Ycoord, also "more"
8db249f786ee for the records section
paulson
parents:
diff changeset
    40
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    41
8db249f786ee for the records section
paulson
parents:
diff changeset
    42
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    43
 The set of theorems @{thm [source] point.simps} is added
8db249f786ee for the records section
paulson
parents:
diff changeset
    44
 automatically to the standard simpset, @{thm [source] point.iffs} is
8db249f786ee for the records section
paulson
parents:
diff changeset
    45
 added to the Classical Reasoner and Simplifier context.
8db249f786ee for the records section
paulson
parents:
diff changeset
    46
*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    47
8db249f786ee for the records section
paulson
parents:
diff changeset
    48
text {* Exchanging Xcoord and Ycoord yields a different type: we must
8db249f786ee for the records section
paulson
parents:
diff changeset
    49
unfortunately write the fields in a canonical order.*}
8db249f786ee for the records section
paulson
parents:
diff changeset
    50
8db249f786ee for the records section
paulson
parents:
diff changeset
    51
8db249f786ee for the records section
paulson
parents:
diff changeset
    52
constdefs 
8db249f786ee for the records section
paulson
parents:
diff changeset
    53
  pt1 :: point
8db249f786ee for the records section
paulson
parents:
diff changeset
    54
   "pt1 == (| Xcoord = #999, Ycoord = #23 |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
    55
8db249f786ee for the records section
paulson
parents:
diff changeset
    56
  pt2 :: "(| Xcoord :: int, Ycoord :: int |)" 
8db249f786ee for the records section
paulson
parents:
diff changeset
    57
   "pt2 == (| Xcoord = #-45, Ycoord = #97 |)" 
8db249f786ee for the records section
paulson
parents:
diff changeset
    58
8db249f786ee for the records section
paulson
parents:
diff changeset
    59
8db249f786ee for the records section
paulson
parents:
diff changeset
    60
subsubsection {* Some lemmas about records *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    61
8db249f786ee for the records section
paulson
parents:
diff changeset
    62
text {* Basic simplifications. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    63
8db249f786ee for the records section
paulson
parents:
diff changeset
    64
lemma "point.make a b = (| Xcoord = a, Ycoord = b |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
    65
by simp -- "needed?? forget it"
8db249f786ee for the records section
paulson
parents:
diff changeset
    66
8db249f786ee for the records section
paulson
parents:
diff changeset
    67
lemma "Xcoord (| Xcoord = a, Ycoord = b |) = a"
8db249f786ee for the records section
paulson
parents:
diff changeset
    68
by simp -- "selection"
8db249f786ee for the records section
paulson
parents:
diff changeset
    69
8db249f786ee for the records section
paulson
parents:
diff changeset
    70
lemma "(| Xcoord = a, Ycoord = b |) (| Xcoord:= 0 |) = (| Xcoord = 0, Ycoord = b |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
    71
by simp -- "update"
8db249f786ee for the records section
paulson
parents:
diff changeset
    72
8db249f786ee for the records section
paulson
parents:
diff changeset
    73
subsection {* Coloured points: record extension *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    74
8db249f786ee for the records section
paulson
parents:
diff changeset
    75
8db249f786ee for the records section
paulson
parents:
diff changeset
    76
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
    77
 Records are extensible.
8db249f786ee for the records section
paulson
parents:
diff changeset
    78
 
8db249f786ee for the records section
paulson
parents:
diff changeset
    79
 The name@{text  "more"} is reserved, since it is used for extensibility.
8db249f786ee for the records section
paulson
parents:
diff changeset
    80
*}
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
datatype colour = Red | Green | Blue
8db249f786ee for the records section
paulson
parents:
diff changeset
    84
8db249f786ee for the records section
paulson
parents:
diff changeset
    85
record cpoint = point +
8db249f786ee for the records section
paulson
parents:
diff changeset
    86
  col :: colour
8db249f786ee for the records section
paulson
parents:
diff changeset
    87
8db249f786ee for the records section
paulson
parents:
diff changeset
    88
8db249f786ee for the records section
paulson
parents:
diff changeset
    89
constdefs 
8db249f786ee for the records section
paulson
parents:
diff changeset
    90
  cpt1 :: cpoint
8db249f786ee for the records section
paulson
parents:
diff changeset
    91
   "cpt1 == (| Xcoord = #999, Ycoord = #23, col = Green |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
    92
8db249f786ee for the records section
paulson
parents:
diff changeset
    93
8db249f786ee for the records section
paulson
parents:
diff changeset
    94
subsection {* Generic operations *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    95
8db249f786ee for the records section
paulson
parents:
diff changeset
    96
8db249f786ee for the records section
paulson
parents:
diff changeset
    97
text {* Record selection and record update; these are generic! *}
8db249f786ee for the records section
paulson
parents:
diff changeset
    98
8db249f786ee for the records section
paulson
parents:
diff changeset
    99
lemma "Xcoord (| Xcoord = a, Ycoord = b, ... = p |) = a"
8db249f786ee for the records section
paulson
parents:
diff changeset
   100
by simp -- "selection"
8db249f786ee for the records section
paulson
parents:
diff changeset
   101
8db249f786ee for the records section
paulson
parents:
diff changeset
   102
lemma "point.more cpt1 = \<lparr>col = Green\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   103
by (simp add: cpt1_def) -- "tail of this record"
8db249f786ee for the records section
paulson
parents:
diff changeset
   104
8db249f786ee for the records section
paulson
parents:
diff changeset
   105
8db249f786ee for the records section
paulson
parents:
diff changeset
   106
lemma "(| Xcoord = a, Ycoord = b, ... = p |) (| Xcoord:= 0 |) = (| Xcoord = 0, Ycoord = b, ... = p |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   107
by simp -- "update"
8db249f786ee for the records section
paulson
parents:
diff changeset
   108
8db249f786ee for the records section
paulson
parents:
diff changeset
   109
text {*
8db249f786ee for the records section
paulson
parents:
diff changeset
   110
  Record declarations define new type abbreviations:
8db249f786ee for the records section
paulson
parents:
diff changeset
   111
  @{text [display]
8db249f786ee for the records section
paulson
parents:
diff changeset
   112
"    point = (| Xcoord :: int, Ycoord :: int |)
8db249f786ee for the records section
paulson
parents:
diff changeset
   113
    'a point_scheme = (| Xcoord :: int, Ycoord :: int, ... :: 'a |)"}
8db249f786ee for the records section
paulson
parents:
diff changeset
   114
  Extensions `...' must be in type class @{text more}.
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   118
  getX :: "('a::more) point_scheme \<Rightarrow> int"
8db249f786ee for the records section
paulson
parents:
diff changeset
   119
   "getX r == Xcoord r"
8db249f786ee for the records section
paulson
parents:
diff changeset
   120
  setX :: "[('a::more) point_scheme, int] \<Rightarrow> 'a point_scheme"
8db249f786ee for the records section
paulson
parents:
diff changeset
   121
   "setX r a == r (| Xcoord := a |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   122
  extendpt :: "'a \<Rightarrow> ('a::more) point_scheme"
8db249f786ee for the records section
paulson
parents:
diff changeset
   123
   "extendpt ext == (| Xcoord = #15, Ycoord = 0, ... = ext |)"
8db249f786ee for the records section
paulson
parents:
diff changeset
   124
     text{*not sure what this is for!*}
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   131
lemma "getX (| Xcoord = #64, Ycoord = #36 |) = #64"
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   139
  incX :: "('a::more) point_scheme \<Rightarrow> 'a point_scheme"
8db249f786ee for the records section
paulson
parents:
diff changeset
   140
  "incX r == \<lparr>Xcoord = (Xcoord r) + #1, Ycoord = Ycoord r, \<dots> = point.more r\<rparr>"
8db249f786ee for the records section
paulson
parents:
diff changeset
   141
8db249f786ee for the records section
paulson
parents:
diff changeset
   142
constdefs
8db249f786ee for the records section
paulson
parents:
diff changeset
   143
  setGreen :: "[colour, ('a::more) point_scheme] \<Rightarrow> cpoint"
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   149
lemma "incX r = setX r ((getX r) + #1)"
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. *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   153
lemma "incX r = r \<lparr>Xcoord := (Xcoord r) + #1\<rparr>"
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   162
lemma "getX \<lparr>Xcoord = #23, Ycoord = #10, col = Blue\<rparr> = #23"
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
8db249f786ee for the records section
paulson
parents:
diff changeset
   172
lemma "setX \<lparr>Xcoord = #12, Ycoord = 0, col = Blue\<rparr> #23 =  
8db249f786ee for the records section
paulson
parents:
diff changeset
   173
            \<lparr>Xcoord = #23, Ycoord = 0, col = Blue\<rparr>"
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.
8db249f786ee for the records section
paulson
parents:
diff changeset
   245
*}
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]} *}
8db249f786ee for the records section
paulson
parents:
diff changeset
   248
by simp 
8db249f786ee for the records section
paulson
parents:
diff changeset
   249
8db249f786ee for the records section
paulson
parents:
diff changeset
   250
8db249f786ee for the records section
paulson
parents:
diff changeset
   251
end