src/HOL/Data_Structures/Tree234_Map.thy
changeset 63411 e051eea34990
parent 62130 90a3016a6c12
child 63636 6f38b7abb648
     1.1 --- a/src/HOL/Data_Structures/Tree234_Map.thy	Thu Jul 07 09:24:03 2016 +0200
     1.2 +++ b/src/HOL/Data_Structures/Tree234_Map.thy	Thu Jul 07 18:08:02 2016 +0200
     1.3 @@ -10,7 +10,7 @@
     1.4  
     1.5  subsection \<open>Map operations on 2-3-4 trees\<close>
     1.6  
     1.7 -fun lookup :: "('a::cmp * 'b) tree234 \<Rightarrow> 'a \<Rightarrow> 'b option" where
     1.8 +fun lookup :: "('a::linorder * 'b) tree234 \<Rightarrow> 'a \<Rightarrow> 'b option" where
     1.9  "lookup Leaf x = None" |
    1.10  "lookup (Node2 l (a,b) r) x = (case cmp x a of
    1.11    LT \<Rightarrow> lookup l x |
    1.12 @@ -30,7 +30,7 @@
    1.13    GT \<Rightarrow> (case cmp x a3 of
    1.14             LT \<Rightarrow> lookup t3 x | EQ \<Rightarrow> Some b3 | GT \<Rightarrow> lookup t4 x))"
    1.15  
    1.16 -fun upd :: "'a::cmp \<Rightarrow> 'b \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) up\<^sub>i" where
    1.17 +fun upd :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) up\<^sub>i" where
    1.18  "upd x y Leaf = Up\<^sub>i Leaf (x,y) Leaf" |
    1.19  "upd x y (Node2 l ab r) = (case cmp x (fst ab) of
    1.20     LT \<Rightarrow> (case upd x y l of
    1.21 @@ -72,10 +72,10 @@
    1.22                      T\<^sub>i t4' => T\<^sub>i (Node4 t1 ab1 t2 ab2 t3 ab3 t4')
    1.23                    | Up\<^sub>i t41 q t42 => Up\<^sub>i (Node2 t1 ab1 t2) ab2 (Node3 t3 ab3 t41 q t42))))"
    1.24  
    1.25 -definition update :: "'a::cmp \<Rightarrow> 'b \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) tree234" where
    1.26 +definition update :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) tree234" where
    1.27  "update x y t = tree\<^sub>i(upd x y t)"
    1.28  
    1.29 -fun del :: "'a::cmp \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) up\<^sub>d" where
    1.30 +fun del :: "'a::linorder \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) up\<^sub>d" where
    1.31  "del x Leaf = T\<^sub>d Leaf" |
    1.32  "del x (Node2 Leaf ab1 Leaf) = (if x=fst ab1 then Up\<^sub>d Leaf else T\<^sub>d(Node2 Leaf ab1 Leaf))" |
    1.33  "del x (Node3 Leaf ab1 Leaf ab2 Leaf) = T\<^sub>d(if x=fst ab1 then Node2 Leaf ab2 Leaf
    1.34 @@ -107,7 +107,7 @@
    1.35            EQ \<Rightarrow> let (ab',t4') = del_min t4 in node44 t1 ab1 t2 ab2 t3 ab' t4' |
    1.36            GT \<Rightarrow> node44 t1 ab1 t2 ab2 t3 ab3 (del x t4)))"
    1.37  
    1.38 -definition delete :: "'a::cmp \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) tree234" where
    1.39 +definition delete :: "'a::linorder \<Rightarrow> ('a*'b) tree234 \<Rightarrow> ('a*'b) tree234" where
    1.40  "delete x t = tree\<^sub>d(del x t)"
    1.41  
    1.42