116 sorted(map fst (inorder l) @ x # map fst (inorder r))" |
116 sorted(map fst (inorder l) @ x # map fst (inorder r))" |
117 unfolding inorder_splay[of x t, symmetric] |
117 unfolding inorder_splay[of x t, symmetric] |
118 by(induction x t arbitrary: l a r rule: splay.induct) |
118 by(induction x t arbitrary: l a r rule: splay.induct) |
119 (auto simp: sorted_lems sorted_Cons_le sorted_snoc_le splay_Leaf_iff split: tree.splits) |
119 (auto simp: sorted_lems sorted_Cons_le sorted_snoc_le splay_Leaf_iff split: tree.splits) |
120 |
120 |
121 (* more upd_list lemmas; unify with basic set? *) |
|
122 |
|
123 lemma upd_list_Cons: |
|
124 "sorted1 ((x,y) # xs) \<Longrightarrow> upd_list x y xs = (x,y) # xs" |
|
125 by (induction xs) auto |
|
126 |
|
127 lemma upd_list_snoc: |
|
128 "sorted1 (xs @ [(x,y)]) \<Longrightarrow> upd_list x y xs = xs @ [(x,y)]" |
|
129 by(induction xs) (auto simp add: sorted_mid_iff2) |
|
130 |
|
131 lemma inorder_update: |
121 lemma inorder_update: |
132 "sorted1(inorder t) \<Longrightarrow> inorder(update x y t) = upd_list x y (inorder t)" |
122 "sorted1(inorder t) \<Longrightarrow> inorder(update x y t) = upd_list x y (inorder t)" |
133 using inorder_splay[of x t, symmetric] sorted_splay[of t x] |
123 using inorder_splay[of x t, symmetric] sorted_splay[of t x] |
134 by(auto simp: upd_list_simps upd_list_Cons upd_list_snoc neq_Leaf_iff split: tree.split) |
124 by(auto simp: upd_list_simps upd_list_Cons upd_list_snoc neq_Leaf_iff split: tree.split) |
135 |
125 |
136 |
126 |
137 subsubsection "Proofs for delete" |
127 subsubsection "Proofs for delete" |
138 |
|
139 (* more del_simp lemmas; unify with basic set? *) |
|
140 |
|
141 lemma del_list_notin_Cons: "sorted (x # map fst xs) \<Longrightarrow> del_list x xs = xs" |
|
142 by(induction xs)(auto simp: sorted_Cons_iff) |
|
143 |
|
144 lemma del_list_sorted_app: |
|
145 "sorted(map fst xs @ [x]) \<Longrightarrow> del_list x (xs @ ys) = xs @ del_list x ys" |
|
146 by (induction xs) (auto simp: sorted_mid_iff2) |
|
147 |
128 |
148 lemma inorder_splay_maxD: |
129 lemma inorder_splay_maxD: |
149 "splay_max t = Node l a r \<Longrightarrow> sorted1(inorder t) \<Longrightarrow> |
130 "splay_max t = Node l a r \<Longrightarrow> sorted1(inorder t) \<Longrightarrow> |
150 inorder l @ [a] = inorder t \<and> r = Leaf" |
131 inorder l @ [a] = inorder t \<and> r = Leaf" |
151 by(induction t arbitrary: l a r rule: splay_max.induct) |
132 by(induction t arbitrary: l a r rule: splay_max.induct) |