src/HOL/Library/RBT_Mapping.thy
author kuncar
Fri, 08 Mar 2013 13:21:58 +0100
changeset 51379 6dd83e007f56
parent 51161 6ed12ae3b3e1
child 51438 a614e456870b
permissions -rw-r--r--
convert mappings to parametric lifting
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
     1
(*  Title:      HOL/Library/RBT_Mapping.thy
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
     2
    Author:     Florian Haftmann and Ondrej Kuncar
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
     3
*)
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
     4
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
     5
header {* Implementation of mappings with Red-Black Trees *}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
     6
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
     7
(*<*)
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
     8
theory RBT_Mapping
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
     9
imports RBT Mapping
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    10
begin
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    11
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    12
subsection {* Implementation of mappings *}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    13
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    14
lift_definition Mapping :: "('a\<Colon>linorder, 'b) rbt \<Rightarrow> ('a, 'b) mapping" is lookup .
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    15
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    16
code_datatype Mapping
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    17
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    18
lemma lookup_Mapping [simp, code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    19
  "Mapping.lookup (Mapping t) = lookup t"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    20
   by (transfer fixing: t) rule
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    21
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    22
lemma empty_Mapping [code]: "Mapping.empty = Mapping empty"
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    23
proof -
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    24
  note RBT.empty.transfer[transfer_rule del]
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    25
  show ?thesis by transfer simp
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    26
qed
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    27
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    28
lemma is_empty_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    29
  "Mapping.is_empty (Mapping t) \<longleftrightarrow> is_empty t"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    30
  unfolding is_empty_def by (transfer fixing: t) simp
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    31
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    32
lemma insert_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    33
  "Mapping.update k v (Mapping t) = Mapping (insert k v t)"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    34
  by (transfer fixing: t) simp
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    35
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    36
lemma delete_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    37
  "Mapping.delete k (Mapping t) = Mapping (delete k t)"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    38
  by (transfer fixing: t) simp
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    39
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    40
lemma map_entry_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    41
  "Mapping.map_entry k f (Mapping t) = Mapping (map_entry k f t)"
51379
6dd83e007f56 convert mappings to parametric lifting
kuncar
parents: 51161
diff changeset
    42
by (transfer fixing: t, case_tac "lookup t k") auto
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    43
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    44
lemma keys_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    45
  "Mapping.keys (Mapping t) = set (keys t)"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    46
by (transfer fixing: t) (simp add: lookup_keys)
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    47
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    48
lemma ordered_keys_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    49
  "Mapping.ordered_keys (Mapping t) = keys t"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    50
unfolding ordered_keys_def 
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    51
by (transfer fixing: t) (auto simp add: lookup_keys intro: sorted_distinct_set_unique)
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    52
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    53
lemma Mapping_size_card_keys: (*FIXME*)
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    54
  "Mapping.size m = card (Mapping.keys m)"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    55
unfolding size_def by transfer simp
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    56
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    57
lemma size_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    58
  "Mapping.size (Mapping t) = length (keys t)"
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    59
unfolding size_def
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    60
by (transfer fixing: t) (simp add: lookup_keys distinct_card)
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    61
49929
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    62
context
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    63
  notes RBT.bulkload.transfer[transfer_rule del]
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    64
begin
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    65
  lemma tabulate_Mapping [code]:
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    66
    "Mapping.tabulate ks f = Mapping (bulkload (List.map (\<lambda>k. (k, f k)) ks))"
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    67
  by transfer (simp add: map_of_map_restrict)
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    68
  
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    69
  lemma bulkload_Mapping [code]:
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    70
    "Mapping.bulkload vs = Mapping (bulkload (List.map (\<lambda>n. (n, vs ! n)) [0..<length vs]))"
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    71
  by transfer (simp add: map_of_map_restrict fun_eq_iff)
70300f1b6835 update RBT_Mapping, AList_Mapping and Mapping to use lifting/transfer
kuncar
parents: 47450
diff changeset
    72
end
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    73
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    74
lemma equal_Mapping [code]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    75
  "HOL.equal (Mapping t1) (Mapping t2) \<longleftrightarrow> entries t1 = entries t2"
51161
6ed12ae3b3e1 attempt to re-establish conventions which theories are loaded into the grand unified library theory;
haftmann
parents: 49929
diff changeset
    76
  by (transfer fixing: t1 t2) (simp add: entries_lookup)
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    77
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    78
lemma [code nbe]:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    79
  "HOL.equal (x :: (_, _) mapping) x \<longleftrightarrow> True"
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    80
  by (fact equal_refl)
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    81
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    82
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    83
hide_const (open) impl_of lookup empty insert delete
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    84
  entries keys bulkload map_entry map fold
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    85
(*>*)
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    86
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    87
text {* 
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    88
  This theory defines abstract red-black trees as an efficient
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    89
  representation of finite maps, backed by the implementation
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    90
  in @{theory RBT_Impl}.
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    91
*}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    92
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    93
subsection {* Data type and invariant *}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    94
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    95
text {*
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    96
  The type @{typ "('k, 'v) RBT_Impl.rbt"} denotes red-black trees with
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    97
  keys of type @{typ "'k"} and values of type @{typ "'v"}. To function
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    98
  properly, the key type musorted belong to the @{text "linorder"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
    99
  class.
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   100
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   101
  A value @{term t} of this type is a valid red-black tree if it
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   102
  satisfies the invariant @{text "is_rbt t"}.  The abstract type @{typ
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   103
  "('k, 'v) rbt"} always obeys this invariant, and for this reason you
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   104
  should only use this in our application.  Going back to @{typ "('k,
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   105
  'v) RBT_Impl.rbt"} may be necessary in proofs if not yet proven
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   106
  properties about the operations must be established.
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   107
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   108
  The interpretation function @{const "RBT.lookup"} returns the partial
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   109
  map represented by a red-black tree:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   110
  @{term_type[display] "RBT.lookup"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   111
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   112
  This function should be used for reasoning about the semantics of the RBT
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   113
  operations. Furthermore, it implements the lookup functionality for
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   114
  the data structure: It is executable and the lookup is performed in
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   115
  $O(\log n)$.  
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   116
*}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   117
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   118
subsection {* Operations *}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   119
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   120
text {*
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   121
  Currently, the following operations are supported:
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   122
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   123
  @{term_type [display] "RBT.empty"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   124
  Returns the empty tree. $O(1)$
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   125
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   126
  @{term_type [display] "RBT.insert"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   127
  Updates the map at a given position. $O(\log n)$
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   128
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   129
  @{term_type [display] "RBT.delete"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   130
  Deletes a map entry at a given position. $O(\log n)$
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   131
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   132
  @{term_type [display] "RBT.entries"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   133
  Return a corresponding key-value list for a tree.
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   134
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   135
  @{term_type [display] "RBT.bulkload"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   136
  Builds a tree from a key-value list.
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   137
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   138
  @{term_type [display] "RBT.map_entry"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   139
  Maps a single entry in a tree.
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   140
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   141
  @{term_type [display] "RBT.map"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   142
  Maps all values in a tree. $O(n)$
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   143
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   144
  @{term_type [display] "RBT.fold"}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   145
  Folds over all entries in a tree. $O(n)$
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   146
*}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   147
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   148
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   149
subsection {* Invariant preservation *}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   150
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   151
text {*
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   152
  \noindent
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   153
  @{thm Empty_is_rbt}\hfill(@{text "Empty_is_rbt"})
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   154
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   155
  \noindent
47450
2ada2be850cb move RBT implementation into type class contexts
Andreas Lochbihler
parents: 43124
diff changeset
   156
  @{thm rbt_insert_is_rbt}\hfill(@{text "rbt_insert_is_rbt"})
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   157
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   158
  \noindent
47450
2ada2be850cb move RBT implementation into type class contexts
Andreas Lochbihler
parents: 43124
diff changeset
   159
  @{thm rbt_delete_is_rbt}\hfill(@{text "delete_is_rbt"})
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   160
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   161
  \noindent
47450
2ada2be850cb move RBT implementation into type class contexts
Andreas Lochbihler
parents: 43124
diff changeset
   162
  @{thm rbt_bulkload_is_rbt}\hfill(@{text "bulkload_is_rbt"})
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   163
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   164
  \noindent
47450
2ada2be850cb move RBT implementation into type class contexts
Andreas Lochbihler
parents: 43124
diff changeset
   165
  @{thm rbt_map_entry_is_rbt}\hfill(@{text "map_entry_is_rbt"})
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   166
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   167
  \noindent
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   168
  @{thm map_is_rbt}\hfill(@{text "map_is_rbt"})
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   169
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   170
  \noindent
47450
2ada2be850cb move RBT implementation into type class contexts
Andreas Lochbihler
parents: 43124
diff changeset
   171
  @{thm rbt_union_is_rbt}\hfill(@{text "union_is_rbt"})
43124
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   172
*}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   173
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   174
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   175
subsection {* Map Semantics *}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   176
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   177
text {*
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   178
  \noindent
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   179
  \underline{@{text "lookup_empty"}}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   180
  @{thm [display] lookup_empty}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   181
  \vspace{1ex}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   182
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   183
  \noindent
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   184
  \underline{@{text "lookup_insert"}}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   185
  @{thm [display] lookup_insert}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   186
  \vspace{1ex}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   187
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   188
  \noindent
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   189
  \underline{@{text "lookup_delete"}}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   190
  @{thm [display] lookup_delete}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   191
  \vspace{1ex}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   192
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   193
  \noindent
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   194
  \underline{@{text "lookup_bulkload"}}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   195
  @{thm [display] lookup_bulkload}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   196
  \vspace{1ex}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   197
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   198
  \noindent
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   199
  \underline{@{text "lookup_map"}}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   200
  @{thm [display] lookup_map}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   201
  \vspace{1ex}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   202
*}
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   203
fdb7e1d5f762 splitting RBT theory into RBT and RBT_Mapping
bulwahn
parents:
diff changeset
   204
end