lemma Collect_split_eq: "{p. P (case_prod f p)} = {(a,b). P (f a b)}" by auto
lemma subset_insertD: "A \ insert x B \ A \ B \ x \ A \ (\B'. A = insert x B' \ B' \ B)" apply (case_tac "x \ A") apply (rule disjI2) apply (rule_tac x = "A - {x}"in exI) apply fast+ done
abbreviation nat3 :: nat (\<open>3\<close>) where "3 \<equiv> Suc 2" abbreviation nat4 :: nat (\<open>4\<close>) where "4 \<equiv> Suc 3"
(* irrefl_tranclI in Transitive_Closure.thy is more general *) lemma irrefl_tranclI': "r\ \ r\<^sup>+ = {} \ \x. (x, x) \ r\<^sup>+" by (blast elim: tranclE dest: trancl_into_rtrancl)
lemma rtrancl_into_trancl3: "\(a, b) \ r\<^sup>*; a \ b\ \ (a, b) \ r\<^sup>+" apply (drule rtranclD) apply auto done
lemma rtrancl_into_rtrancl2: "\(a, b) \ r; (b, c) \ r\<^sup>*\ \ (a, c) \ r\<^sup>*" by (auto intro: rtrancl_trans)
lemma triangle_lemma: assumes unique: "\a b c. \(a,b)\r; (a,c)\r\ \ b = c" and ax: "(a,x)\r\<^sup>*" and ay: "(a,y)\r\<^sup>*" shows"(x,y)\r\<^sup>* \ (y,x)\r\<^sup>*" using ax ay proof (induct rule: converse_rtrancl_induct) assume"(x,y)\r\<^sup>*" thenshow ?thesis by blast next fix a v assume a_v_r: "(a, v) \ r" and v_x_rt: "(v, x) \ r\<^sup>*" and a_y_rt: "(a, y) \ r\<^sup>*" and hyp: "(v, y) \ r\<^sup>* \ (x, y) \ r\<^sup>* \ (y, x) \ r\<^sup>*" from a_y_rt show"(x, y) \ r\<^sup>* \ (y, x) \ r\<^sup>*" proof (cases rule: converse_rtranclE) assume"a = y" with a_v_r v_x_rt have"(y,x) \ r\<^sup>*" by (auto intro: rtrancl_trans) thenshow ?thesis by blast next fix w assume a_w_r: "(a, w) \ r" and w_y_rt: "(w, y) \ r\<^sup>*" from a_v_r a_w_r unique have"v=w"by auto with w_y_rt hyp show ?thesis by blast qed qed
lemma Ball_weaken: "\Ball s P; \ x. P x\Q x\\Ball s Q" by auto
lemma finite_SetCompr2: "finite {f y x |x y. P y}"if"finite (Collect P)" "\y. P y \ finite (range (f y))" proof - have"{f y x |x y. P y} = (\y\Collect P. range (f y))" by auto with that show ?thesis by simp qed
lemma list_all2_trans: "\a b c. P1 a b \ P2 b c \ P3 a c \ \<forall>xs2 xs3. list_all2 P1 xs1 xs2 \<longrightarrow> list_all2 P2 xs2 xs3 \<longrightarrow> list_all2 P3 xs1 xs3" apply (induct_tac xs1) apply simp apply (rule allI) apply (induct_tac xs2) apply simp apply (rule allI) apply (induct_tac xs3) apply auto done