202 next |
202 next |
203 case False |
203 case False |
204 let ?L1 = "set_tree l1" let ?R1 = "set_tree r1" |
204 let ?L1 = "set_tree l1" let ?R1 = "set_tree r1" |
205 have *: "a \<notin> ?L1 \<union> ?R1" using \<open>bst t1\<close> by (fastforce) |
205 have *: "a \<notin> ?L1 \<union> ?R1" using \<open>bst t1\<close> by (fastforce) |
206 obtain l2 ain r2 where sp: "split t2 a = (l2,ain,r2)" using prod_cases3 by blast |
206 obtain l2 ain r2 where sp: "split t2 a = (l2,ain,r2)" using prod_cases3 by blast |
207 let ?L2 = "set_tree l2" let ?R2 = "set_tree r2" let ?K = "if ain then {a} else {}" |
207 let ?L2 = "set_tree l2" let ?R2 = "set_tree r2" let ?A = "if ain then {a} else {}" |
208 have t2: "set_tree t2 = ?L2 \<union> ?R2 \<union> ?K" and |
208 have t2: "set_tree t2 = ?L2 \<union> ?R2 \<union> ?A" and |
209 **: "?L2 \<inter> ?R2 = {}" "a \<notin> ?L2 \<union> ?R2" "?L1 \<inter> ?R2 = {}" "?L2 \<inter> ?R1 = {}" |
209 **: "?L2 \<inter> ?R2 = {}" "a \<notin> ?L2 \<union> ?R2" "?L1 \<inter> ?R2 = {}" "?L2 \<inter> ?R1 = {}" |
210 using split[OF sp] \<open>bst t1\<close> \<open>bst t2\<close> by (force, force, force, force, force) |
210 using split[OF sp] \<open>bst t1\<close> \<open>bst t2\<close> by (force, force, force, force, force) |
211 have IHl: "set_tree (inter l1 l2) = set_tree l1 \<inter> set_tree l2" |
211 have IHl: "set_tree (inter l1 l2) = set_tree l1 \<inter> set_tree l2" |
212 using "1.IH"(1)[OF _ False _ _ sp[symmetric]] "1.prems"(1,2) split[OF sp] by simp |
212 using "1.IH"(1)[OF _ False _ _ sp[symmetric]] "1.prems"(1,2) split[OF sp] by simp |
213 have IHr: "set_tree (inter r1 r2) = set_tree r1 \<inter> set_tree r2" |
213 have IHr: "set_tree (inter r1 r2) = set_tree r1 \<inter> set_tree r2" |
214 using "1.IH"(2)[OF _ False _ _ sp[symmetric]] "1.prems"(1,2) split[OF sp] by simp |
214 using "1.IH"(2)[OF _ False _ _ sp[symmetric]] "1.prems"(1,2) split[OF sp] by simp |
215 have "set_tree t1 \<inter> set_tree t2 = (?L1 \<union> ?R1 \<union> {a}) \<inter> (?L2 \<union> ?R2 \<union> ?K)" |
215 have "set_tree t1 \<inter> set_tree t2 = (?L1 \<union> ?R1 \<union> {a}) \<inter> (?L2 \<union> ?R2 \<union> ?A)" |
216 by(simp add: t2) |
216 by(simp add: t2) |
217 also have "\<dots> = (?L1 \<inter> ?L2) \<union> (?R1 \<inter> ?R2) \<union> ?K" |
217 also have "\<dots> = (?L1 \<inter> ?L2) \<union> (?R1 \<inter> ?R2) \<union> ?A" |
218 using * ** by auto |
218 using * ** by auto |
219 also have "\<dots> = set_tree (inter t1 t2)" |
219 also have "\<dots> = set_tree (inter t1 t2)" |
220 using IHl IHr sp inter.simps[of t1 t2] False by(simp) |
220 using IHl IHr sp inter.simps[of t1 t2] False by(simp) |
221 finally show ?thesis by simp |
221 finally show ?thesis by simp |
222 qed |
222 qed |
266 case True thus ?thesis by (simp add: diff.simps) |
266 case True thus ?thesis by (simp add: diff.simps) |
267 next |
267 next |
268 case False |
268 case False |
269 let ?L2 = "set_tree l2" let ?R2 = "set_tree r2" |
269 let ?L2 = "set_tree l2" let ?R2 = "set_tree r2" |
270 obtain l1 ain r1 where sp: "split t1 a = (l1,ain,r1)" using prod_cases3 by blast |
270 obtain l1 ain r1 where sp: "split t1 a = (l1,ain,r1)" using prod_cases3 by blast |
271 let ?L1 = "set_tree l1" let ?R1 = "set_tree r1" let ?K = "if ain then {a} else {}" |
271 let ?L1 = "set_tree l1" let ?R1 = "set_tree r1" let ?A = "if ain then {a} else {}" |
272 have t1: "set_tree t1 = ?L1 \<union> ?R1 \<union> ?K" and |
272 have t1: "set_tree t1 = ?L1 \<union> ?R1 \<union> ?A" and |
273 **: "a \<notin> ?L1 \<union> ?R1" "?L1 \<inter> ?R2 = {}" "?L2 \<inter> ?R1 = {}" |
273 **: "a \<notin> ?L1 \<union> ?R1" "?L1 \<inter> ?R2 = {}" "?L2 \<inter> ?R1 = {}" |
274 using split[OF sp] \<open>bst t1\<close> \<open>bst t2\<close> by (force, force, force, force) |
274 using split[OF sp] \<open>bst t1\<close> \<open>bst t2\<close> by (force, force, force, force) |
275 have IHl: "set_tree (diff l1 l2) = set_tree l1 - set_tree l2" |
275 have IHl: "set_tree (diff l1 l2) = set_tree l1 - set_tree l2" |
276 using "1.IH"(1)[OF False _ _ _ sp[symmetric]] "1.prems"(1,2) split[OF sp] by simp |
276 using "1.IH"(1)[OF False _ _ _ sp[symmetric]] "1.prems"(1,2) split[OF sp] by simp |
277 have IHr: "set_tree (diff r1 r2) = set_tree r1 - set_tree r2" |
277 have IHr: "set_tree (diff r1 r2) = set_tree r1 - set_tree r2" |