tuned
authornipkow
Wed, 23 Sep 2015 09:14:22 +0200
changeset 61231 cc6969542f8d
parent 61230 e367b93f78e5
child 61232 c46faf9762f7
tuned
src/HOL/Data_Structures/AList_Upd_Del.thy
src/HOL/Data_Structures/List_Ins_Del.thy
src/HOL/Data_Structures/RBT.thy
src/HOL/Data_Structures/RBT_Map.thy
src/HOL/Data_Structures/RBT_Set.thy
src/HOL/Data_Structures/Tree_Map.thy
src/HOL/Data_Structures/Tree_Set.thy
--- a/src/HOL/Data_Structures/AList_Upd_Del.thy	Tue Sep 22 17:13:13 2015 +0200
+++ b/src/HOL/Data_Structures/AList_Upd_Del.thy	Wed Sep 23 09:14:22 2015 +0200
@@ -17,7 +17,7 @@
 "map_of [] = (\<lambda>a. None)" |
 "map_of ((x,y)#ps) = (\<lambda>a. if x=a then Some y else map_of ps a)"
 
-text \<open>Updating into an association list:\<close>
+text \<open>Updating an association list:\<close>
 
 fun upd_list :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) list \<Rightarrow> ('a*'b) list" where
 "upd_list a b [] = [(a,b)]" |
@@ -58,6 +58,7 @@
 by (meson le_less_trans map_of_None2 not_less sorted_snoc_iff)
 
 lemmas map_of_sorteds = map_of_sorted_Cons map_of_sorted_snoc
+lemmas map_of_simps = sorted_lems map_of_append map_of_sorteds
 
 
 subsection \<open>Lemmas for @{const upd_list}\<close>
@@ -136,4 +137,6 @@
 lemmas del_list_sorted =
   del_list_sorted1 del_list_sorted2 del_list_sorted3 del_list_sorted4 del_list_sorted5
 
+lemmas del_list_simps = sorted_lems del_list_sorted
+
 end
--- a/src/HOL/Data_Structures/List_Ins_Del.thy	Tue Sep 22 17:13:13 2015 +0200
+++ b/src/HOL/Data_Structures/List_Ins_Del.thy	Wed Sep 23 09:14:22 2015 +0200
@@ -74,7 +74,7 @@
   ins_list x (xs @ y # ys) = ins_list x xs @ (y#ys)"
 by(induction xs) (auto simp: sorted_lems)
 
-lemmas ins_simps = sorted_lems ins_list_sorted1 ins_list_sorted2
+lemmas ins_list_simps = sorted_lems ins_list_sorted1 ins_list_sorted2
 
 
 subsection \<open>Delete one occurrence of an element from a list:\<close>
@@ -123,7 +123,7 @@
    del_list a (xs @ x # ys @ y # zs @ z # us) @ u # vs" 
 by (induction xs) (auto simp: sorted_Cons_iff del_list_sorted4)
 
-lemmas del_simps = sorted_lems
+lemmas del_list_simps = sorted_lems
   del_list_sorted1
   del_list_sorted2
   del_list_sorted3
--- a/src/HOL/Data_Structures/RBT.thy	Tue Sep 22 17:13:13 2015 +0200
+++ b/src/HOL/Data_Structures/RBT.thy	Wed Sep 23 09:14:22 2015 +0200
@@ -1,6 +1,6 @@
 (* Author: Tobias Nipkow *)
 
-section \<open>Red-Black Trees\<close>
+section \<open>Red-Black Tree\<close>
 
 theory RBT
 imports Tree2
--- a/src/HOL/Data_Structures/RBT_Map.thy	Tue Sep 22 17:13:13 2015 +0200
+++ b/src/HOL/Data_Structures/RBT_Map.thy	Wed Sep 23 09:14:22 2015 +0200
@@ -5,15 +5,9 @@
 theory RBT_Map
 imports
   RBT_Set
-  Map_by_Ordered
+  Lookup2
 begin
 
-fun lookup :: "('a::linorder * 'b) rbt \<Rightarrow> 'a \<Rightarrow> 'b option" where
-"lookup Leaf x = None" |
-"lookup (Node _ l (a,b) r) x =
-  (if x < a then lookup l x else
-   if x > a then lookup r x else Some b)"
-
 fun update :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) rbt \<Rightarrow> ('a*'b) rbt" where
 "update x y Leaf = R Leaf (x,y) Leaf" |
 "update x y (B l (a,b) r) =
@@ -41,12 +35,6 @@
 
 subsection "Functional Correctness Proofs"
 
-lemma lookup_eq:
-  "sorted1(inorder t) \<Longrightarrow> lookup t x = map_of (inorder t) x"
-by(induction t)
-  (auto simp: sorted_lems map_of_append map_of_sorteds split: option.split)
-
-
 lemma inorder_update:
   "sorted1(inorder t) \<Longrightarrow> inorder(update x y t) = upd_list x y (inorder t)"
 by(induction x y t rule: update.induct)
@@ -60,7 +48,7 @@
  "sorted1(inorder t2) \<Longrightarrow>  inorder(deleteR x t1 a t2) =
     inorder t1 @ a # del_list x (inorder t2)"
 by(induction x t1 and x t1 a t2 and x t1 a t2 rule: delete_deleteL_deleteR.induct)
-  (auto simp: del_list_sorted sorted_lems inorder_combine inorder_balL inorder_balR)
+  (auto simp: del_list_simps inorder_combine inorder_balL inorder_balR)
 
 
 interpretation Map_by_Ordered
--- a/src/HOL/Data_Structures/RBT_Set.thy	Tue Sep 22 17:13:13 2015 +0200
+++ b/src/HOL/Data_Structures/RBT_Set.thy	Wed Sep 23 09:14:22 2015 +0200
@@ -35,29 +35,27 @@
 
 lemma inorder_bal:
   "inorder(bal l a r) = inorder l @ a # inorder r"
-by(induction l a r rule: bal.induct) (auto simp: sorted_lems)
+by(induction l a r rule: bal.induct) (auto)
 
 lemma inorder_insert:
   "sorted(inorder t) \<Longrightarrow> inorder(insert a t) = ins_list a (inorder t)"
-by(induction a t rule: insert.induct) (auto simp: ins_simps inorder_bal)
+by(induction a t rule: insert.induct) (auto simp: ins_list_simps inorder_bal)
 
 lemma inorder_red: "inorder(red t) = inorder t"
-by(induction t) (auto simp: sorted_lems)
+by(induction t) (auto)
 
 lemma inorder_balL:
   "inorder(balL l a r) = inorder l @ a # inorder r"
-by(induction l a r rule: balL.induct)
-  (auto simp: sorted_lems inorder_bal inorder_red)
+by(induction l a r rule: balL.induct)(auto simp: inorder_bal inorder_red)
 
 lemma inorder_balR:
   "inorder(balR l a r) = inorder l @ a # inorder r"
-by(induction l a r rule: balR.induct)
-  (auto simp: sorted_lems inorder_bal inorder_red)
+by(induction l a r rule: balR.induct) (auto simp: inorder_bal inorder_red)
 
 lemma inorder_combine:
   "inorder(combine l r) = inorder l @ inorder r"
 by(induction l r rule: combine.induct)
-  (auto simp: sorted_lems inorder_balL inorder_balR split: tree.split color.split)
+  (auto simp: inorder_balL inorder_balR split: tree.split color.split)
 
 lemma inorder_delete:
  "sorted(inorder t) \<Longrightarrow>  inorder(delete x t) = del_list x (inorder t)" and
@@ -66,7 +64,7 @@
  "sorted(inorder r) \<Longrightarrow>  inorder(deleteR x l a r) =
     inorder l @ a # del_list x (inorder r)"
 by(induction x t and x l a r and x l a r rule: delete_deleteL_deleteR.induct)
-  (auto simp: del_simps inorder_combine inorder_balL inorder_balR)
+  (auto simp: del_list_simps inorder_combine inorder_balL inorder_balR)
 
 interpretation Set_by_Ordered
 where empty = Leaf and isin = isin and insert = insert and delete = delete
--- a/src/HOL/Data_Structures/Tree_Map.thy	Tue Sep 22 17:13:13 2015 +0200
+++ b/src/HOL/Data_Structures/Tree_Map.thy	Wed Sep 23 09:14:22 2015 +0200
@@ -4,7 +4,7 @@
 
 theory Tree_Map
 imports
-  "~~/src/HOL/Library/Tree"
+  Tree_Set
   Map_by_Ordered
 begin
 
@@ -20,10 +20,6 @@
     else if a=x then Node l (a,b) r
     else Node l (x,y) (update a b r))"
 
-fun del_min :: "'a tree \<Rightarrow> 'a * 'a tree" where
-"del_min (Node Leaf a r) = (a, r)" |
-"del_min (Node l a r) = (let (x,l') = del_min l in (x, Node l' a r))"
-
 fun delete :: "'a::linorder \<Rightarrow> ('a*'b) tree \<Rightarrow> ('a*'b) tree" where
 "delete k Leaf = Leaf" |
 "delete k (Node l (a,b) r) = (if k<a then Node (delete k l) (a,b) r else
@@ -35,9 +31,7 @@
 
 lemma lookup_eq:
   "sorted1(inorder t) \<Longrightarrow> lookup t x = map_of (inorder t) x"
-apply (induction t)
-apply (auto simp: sorted_lems map_of_append map_of_sorteds split: option.split)
-done
+by (induction t) (auto simp: map_of_simps split: option.split)
 
 
 lemma inorder_update:
@@ -49,12 +43,11 @@
   "del_min t = (x,t') \<Longrightarrow> t \<noteq> Leaf \<Longrightarrow> sorted1(inorder t) \<Longrightarrow>
    x # inorder t' = inorder t"
 by(induction t arbitrary: t' rule: del_min.induct)
-  (auto simp: sorted_lems split: prod.splits)
+  (auto simp: del_list_simps split: prod.splits)
 
 lemma inorder_delete:
   "sorted1(inorder t) \<Longrightarrow> inorder(delete x t) = del_list x (inorder t)"
-by(induction t)
-  (auto simp: del_list_sorted sorted_lems dest!: del_minD split: prod.splits)
+by(induction t) (auto simp: del_list_simps del_minD split: prod.splits)
 
 
 interpretation Map_by_Ordered
--- a/src/HOL/Data_Structures/Tree_Set.thy	Tue Sep 22 17:13:13 2015 +0200
+++ b/src/HOL/Data_Structures/Tree_Set.thy	Wed Sep 23 09:14:22 2015 +0200
@@ -43,7 +43,7 @@
 
 lemma inorder_insert:
   "sorted(inorder t) \<Longrightarrow> inorder(insert x t) = ins_list x (inorder t)"
-by(induction t) (auto simp: ins_simps)
+by(induction t) (auto simp: ins_list_simps)
 
 
 lemma del_minD:
@@ -54,7 +54,7 @@
 
 lemma inorder_delete:
   "sorted(inorder t) \<Longrightarrow> inorder(delete x t) = del_list x (inorder t)"
-by(induction t) (auto simp: del_simps del_minD split: prod.splits)
+by(induction t) (auto simp: del_list_simps del_minD split: prod.splits)
 
 
 interpretation Set_by_Ordered