src/HOL/Record.thy
author Thomas Sewell <tsewell@nicta.com.au>
Mon, 28 Sep 2009 14:16:01 +1000
changeset 32756 fb32a99a7689
parent 32752 f65d74a264dd
child 32763 ebfaf9e3c03a
permissions -rw-r--r--
Fix unescaped expressions breaking latex output in Record.thy Expressions containing _ and ^ need to be adjusted or antiquoted in text comments for latex compatibility. This is in fact a little annoying, since it makes the comment less readable in both source and HTML form.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4870
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/Record.thy
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
     2
    Authors:    Wolfgang Naraschewski, Norbert Schirmer and Markus Wenzel, TU Muenchen
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
     3
                Thomas Sewell, NICTA
4870
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
     4
*)
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
     5
22817
9dfadec17cc4 added header;
wenzelm
parents: 22759
diff changeset
     6
header {* Extensible records with structural subtyping *}
9dfadec17cc4 added header;
wenzelm
parents: 22759
diff changeset
     7
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14701
diff changeset
     8
theory Record
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
     9
imports Product_Type
32744
50406c4951d9 Record patch imported and working.
Thomas Sewell <tsewell@nicta.com.au>
parents: 32743
diff changeset
    10
uses ("Tools/record.ML")
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14701
diff changeset
    11
begin
4870
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
    12
14700
2f885b7e5ba7 reimplementation of HOL records; only one type is created for
schirmer
parents: 14080
diff changeset
    13
lemma prop_subst: "s = t \<Longrightarrow> PROP P t \<Longrightarrow> PROP P s"
2f885b7e5ba7 reimplementation of HOL records; only one type is created for
schirmer
parents: 14080
diff changeset
    14
  by simp
11826
2203c7f9ec40 proper setup for abstract product types;
wenzelm
parents: 11821
diff changeset
    15
25705
45a2ffc5911e replaced K_record by lambda term %x. c
schirmer
parents: 22817
diff changeset
    16
lemma K_record_comp: "(\<lambda>x. c) \<circ> f = (\<lambda>x. c)" 
45a2ffc5911e replaced K_record by lambda term %x. c
schirmer
parents: 22817
diff changeset
    17
  by (simp add: comp_def)
11821
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    18
32743
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    19
lemma meta_iffD2:
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    20
  "\<lbrakk> PROP P \<equiv> PROP Q; PROP Q \<rbrakk> \<Longrightarrow> PROP P"
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    21
  by simp
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    22
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    23
lemma o_eq_dest_lhs:
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    24
  "a o b = c \<Longrightarrow> a (b v) = c v"
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    25
  by clarsimp
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    26
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    27
lemma id_o_refl:
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    28
  "id o f = f o id"
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    29
  by simp
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    30
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    31
lemma o_eq_id_dest:
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    32
  "a o b = id o c \<Longrightarrow> a (b v) = c v"
c4e9a48bc50e Initial attempt at porting record update to repository Isabelle.
tsewell@rubicon.NSW.bigpond.net.au
parents: 31723
diff changeset
    33
  by clarsimp
22817
9dfadec17cc4 added header;
wenzelm
parents: 22759
diff changeset
    34
11833
wenzelm
parents: 11826
diff changeset
    35
subsection {* Concrete record syntax *}
4870
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
    36
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
    37
nonterminals
5198
b1adae4f8b90 added type and update syntax;
wenzelm
parents: 5032
diff changeset
    38
  ident field_type field_types field fields update updates
4870
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
    39
syntax
11821
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    40
  "_constify"           :: "id => ident"                        ("_")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    41
  "_constify"           :: "longid => ident"                    ("_")
5198
b1adae4f8b90 added type and update syntax;
wenzelm
parents: 5032
diff changeset
    42
11821
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    43
  "_field_type"         :: "[ident, type] => field_type"        ("(2_ ::/ _)")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    44
  ""                    :: "field_type => field_types"          ("_")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    45
  "_field_types"        :: "[field_type, field_types] => field_types"    ("_,/ _")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    46
  "_record_type"        :: "field_types => type"                ("(3'(| _ |'))")
10093
44584c2b512b more symbolic syntax (currently "input");
wenzelm
parents: 9729
diff changeset
    47
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3'(| _,/ (2... ::/ _) |'))")
5198
b1adae4f8b90 added type and update syntax;
wenzelm
parents: 5032
diff changeset
    48
11821
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    49
  "_field"              :: "[ident, 'a] => field"               ("(2_ =/ _)")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    50
  ""                    :: "field => fields"                    ("_")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    51
  "_fields"             :: "[field, fields] => fields"          ("_,/ _")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    52
  "_record"             :: "fields => 'a"                       ("(3'(| _ |'))")
10093
44584c2b512b more symbolic syntax (currently "input");
wenzelm
parents: 9729
diff changeset
    53
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3'(| _,/ (2... =/ _) |'))")
5198
b1adae4f8b90 added type and update syntax;
wenzelm
parents: 5032
diff changeset
    54
10641
d1533f63c738 added "_update_name" and parse_translation;
wenzelm
parents: 10331
diff changeset
    55
  "_update_name"        :: idt
11821
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    56
  "_update"             :: "[ident, 'a] => update"              ("(2_ :=/ _)")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    57
  ""                    :: "update => updates"                  ("_")
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    58
  "_updates"            :: "[update, updates] => updates"       ("_,/ _")
10093
44584c2b512b more symbolic syntax (currently "input");
wenzelm
parents: 9729
diff changeset
    59
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3'(| _ |'))" [900,0] 900)
4870
cc36acb5b114 Extensible records with structural subtyping in HOL. See
wenzelm
parents:
diff changeset
    60
10331
7411e4659d4a more "xsymbols" syntax;
wenzelm
parents: 10309
diff changeset
    61
syntax (xsymbols)
11821
ad32c92435db abstract product types;
wenzelm
parents: 11489
diff changeset
    62
  "_record_type"        :: "field_types => type"                ("(3\<lparr>_\<rparr>)")
10093
44584c2b512b more symbolic syntax (currently "input");
wenzelm
parents: 9729
diff changeset
    63
  "_record_type_scheme" :: "[field_types, type] => type"        ("(3\<lparr>_,/ (2\<dots> ::/ _)\<rparr>)")
44584c2b512b more symbolic syntax (currently "input");
wenzelm
parents: 9729
diff changeset
    64
  "_record"             :: "fields => 'a"                               ("(3\<lparr>_\<rparr>)")
44584c2b512b more symbolic syntax (currently "input");
wenzelm
parents: 9729
diff changeset
    65
  "_record_scheme"      :: "[fields, 'a] => 'a"                 ("(3\<lparr>_,/ (2\<dots> =/ _)\<rparr>)")
44584c2b512b more symbolic syntax (currently "input");
wenzelm
parents: 9729
diff changeset
    66
  "_record_update"      :: "['a, updates] => 'b"                ("_/(3\<lparr>_\<rparr>)" [900,0] 900)
9729
40cfc3dd27da \<dots> syntax;
wenzelm
parents: 7357
diff changeset
    67
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    68
subsection {* Operators and lemmas for types isomorphic to tuples *}
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    69
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    70
text {*
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    71
Records are isomorphic to compound tuple types. To implement efficient
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    72
records, we make this isomorphism explicit. Consider the record
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    73
access/update simplification @{text "alpha (beta_update f rec) = alpha rec"} for
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    74
distinct fields alpha and beta of some record rec with n fields. There
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    75
are @{text "n ^ 2"} such theorems, which prohibits storage of all of them for
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    76
large n. The rules can be proved on the fly by case decomposition and
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    77
simplification in O(n) time. By creating O(n) isomorphic-tuple types
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    78
while defining the record, however, we can prove the access/update
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    79
simplification in @{text "O(log(n)^2)"} time.
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    80
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    81
The O(n) cost of case decomposition is not because O(n) steps are taken,
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    82
but rather because the resulting rule must contain O(n) new variables and
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    83
an O(n) size concrete record construction. To sidestep this cost, we would
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    84
like to avoid case decomposition in proving access/update theorems.
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    85
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    86
Record types are defined as isomorphic to tuple types. For instance, a
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    87
record type with fields 'a, 'b, 'c and 'd might be introduced as
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    88
isomorphic to @{text "'a \<times> ('b \<times> ('c \<times> 'd))"}. If we balance the tuple tree to
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    89
@{text "('a \<times> 'b) \<times> ('c \<times> 'd)"} then accessors can be defined by converting to
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    90
the underlying type then using O(log(n)) fst or snd operations.
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    91
Updators can be defined similarly, if we introduce a @{text "fst_update"} and
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    92
@{text "snd_update"} function. Furthermore, we can prove the access/update
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    93
theorem in O(log(n)) steps by using simple rewrites on fst, snd,
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
    94
@{text "fst_update"} and @{text "snd_update"}.
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    95
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    96
The catch is that, although O(log(n)) steps were taken, the underlying
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    97
type we converted to is a tuple tree of size O(n). Processing this term
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    98
type wastes performance. We avoid this for large n by taking each
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
    99
subtree of size K and defining a new type isomorphic to that tuple
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   100
subtree. A record can now be defined as isomorphic to a tuple tree
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   101
of these O(n/K) new types, or, if @{text "n > K*K"}, we can repeat the process,
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   102
until the record can be defined in terms of a tuple tree of complexity
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   103
less than the constant K.
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   104
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   105
If we prove the access/update theorem on this type with the analagous
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   106
steps to the tuple tree, we consume @{text "O(log(n)^2)"} time as the intermediate
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   107
terms are O(log(n)) in size and the types needed have size bounded by K.
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   108
To enable this analagous traversal, we define the functions seen below:
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   109
@{text "istuple_fst"}, @{text "istuple_snd"}, @{text "istuple_fst_update"}
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   110
and @{text "istuple_snd_update"}. These functions generalise tuple
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   111
operations by taking a parameter that encapsulates a tuple isomorphism.
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   112
The rewrites needed on these functions now need an additional assumption
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   113
which is that the isomorphism works.
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   114
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   115
These rewrites are typically used in a structured way. They are here
32756
fb32a99a7689 Fix unescaped expressions breaking latex output in Record.thy
Thomas Sewell <tsewell@nicta.com.au>
parents: 32752
diff changeset
   116
presented as the introduction rule @{text "isomorphic_tuple.intros"} rather than
32752
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   117
as a rewrite rule set. The introduction form is an optimisation, as net
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   118
matching can be performed at one term location for each step rather than
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   119
the simplifier searching the term for possible pattern matches. The rule
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   120
set is used as it is viewed outside the locale, with the locale assumption
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   121
(that the isomorphism is valid) left as a rule assumption. All rules are
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   122
structured to aid net matching, using either a point-free form or an
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   123
encapsulating predicate.
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   124
*}
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   125
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   126
typedef ('a, 'b, 'c) tuple_isomorphism
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   127
  = "UNIV :: (('a \<Rightarrow> ('b \<times> 'c)) \<times> (('b \<times> 'c) \<Rightarrow> 'a)) set"
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   128
  by simp
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   129
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   130
definition
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   131
  "TupleIsomorphism repr abst = Abs_tuple_isomorphism (repr, abst)"
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   132
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   133
definition
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   134
  istuple_fst :: "('a, 'b, 'c) tuple_isomorphism \<Rightarrow> 'a \<Rightarrow> 'b"
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   135
where
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset
   136
 "istuple_fst isom \<equiv> let (repr, abst) = Rep_tuple_isomorphism isom in fst \<circ> repr"
f65d74a264dd Initial response to feedback from Norbert, Makarius on record patch
tsewell@rubicon.NSW.bigpond.net.au
parents: 32745
diff changeset