# HG changeset patch # User paulson # Date 1585522440 -3600 # Node ID 1f957615cae6a45ecb856b012f75f733c5354707 # Parent 4c8edd527940d420360adffde9b761c93710a7ca# Parent 2a24c2015a61adb475eac86e931b41ff01ab45ad merged diff -r 4c8edd527940 -r 1f957615cae6 src/HOL/Quotient.thy --- a/src/HOL/Quotient.thy Sun Mar 29 22:30:43 2020 +0200 +++ b/src/HOL/Quotient.thy Sun Mar 29 23:54:00 2020 +0100 @@ -253,27 +253,29 @@ fixes P::"'a \ bool" and x::"'a" assumes a: "equivp R2" - shows "(Ball (Respects (R1 ===> R2)) (\f. P (f x)) = All (\f. P (f x)))" - apply(rule iffI) - apply(rule allI) - apply(drule_tac x="\y. f x" in bspec) - apply(simp add: in_respects rel_fun_def) - apply(rule impI) - using a equivp_reflp_symp_transp[of "R2"] - apply (auto elim: equivpE reflpE) - done + shows "(Ball (Respects (R1 ===> R2)) (\f. P (f x)) = All (\f. P (f x)))" +proof (intro allI iffI) + fix f + assume "\f \ Respects (R1 ===> R2). P (f x)" + moreover have "(\y. f x) \ Respects (R1 ===> R2)" + using a equivp_reflp_symp_transp[of "R2"] + by(auto simp add: in_respects rel_fun_def elim: equivpE reflpE) + ultimately show "P (f x)" + by auto +qed auto lemma bex_reg_eqv_range: assumes a: "equivp R2" shows "(Bex (Respects (R1 ===> R2)) (\f. P (f x)) = Ex (\f. P (f x)))" - apply(auto) - apply(rule_tac x="\y. f x" in bexI) - apply(simp) - apply(simp add: Respects_def in_respects rel_fun_def) - apply(rule impI) - using a equivp_reflp_symp_transp[of "R2"] - apply (auto elim: equivpE reflpE) - done +proof - + { fix f + assume "P (f x)" + have "(\y. f x) \ Respects (R1 ===> R2)" + using a equivp_reflp_symp_transp[of "R2"] + by (auto simp add: Respects_def in_respects rel_fun_def elim: equivpE reflpE) } + then show ?thesis + by auto +qed (* Next four lemmas are unused *) lemma all_reg: @@ -322,35 +324,42 @@ assumes q: "Quotient3 R1 Abs1 Rep1" and a: "(R1 ===> R2) f g" shows "(R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)" - apply (auto simp add: Babs_def in_respects rel_fun_def) - apply (subgoal_tac "x \ Respects R1 \ y \ Respects R1") - using a apply (simp add: Babs_def rel_fun_def) - apply (simp add: in_respects rel_fun_def) - using Quotient3_rel[OF q] - by metis +proof (clarsimp simp add: Babs_def in_respects rel_fun_def) + fix x y + assume "R1 x y" + then have "x \ Respects R1 \ y \ Respects R1" + unfolding in_respects rel_fun_def using Quotient3_rel[OF q]by metis + then show "R2 (Babs (Respects R1) f x) (Babs (Respects R1) g y)" + using \R1 x y\ a by (simp add: Babs_def rel_fun_def) +qed lemma babs_prs: assumes q1: "Quotient3 R1 Abs1 Rep1" and q2: "Quotient3 R2 Abs2 Rep2" - shows "((Rep1 ---> Abs2) (Babs (Respects R1) ((Abs1 ---> Rep2) f))) = f" - apply (rule ext) - apply (simp add:) - apply (subgoal_tac "Rep1 x \ Respects R1") - apply (simp add: Babs_def Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2]) - apply (simp add: in_respects Quotient3_rel_rep[OF q1]) - done +shows "((Rep1 ---> Abs2) (Babs (Respects R1) ((Abs1 ---> Rep2) f))) = f" +proof - + { fix x + have "Rep1 x \ Respects R1" + by (simp add: in_respects Quotient3_rel_rep[OF q1]) + then have "Abs2 (Babs (Respects R1) ((Abs1 ---> Rep2) f) (Rep1 x)) = f x" + by (simp add: Babs_def Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2]) + } + then show ?thesis + by force +qed lemma babs_simp: assumes q: "Quotient3 R1 Abs Rep" shows "((R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)) = ((R1 ===> R2) f g)" - apply(rule iffI) - apply(simp_all only: babs_rsp[OF q]) - apply(auto simp add: Babs_def rel_fun_def) - apply(metis Babs_def in_respects Quotient3_rel[OF q]) - done + (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + unfolding rel_fun_def by (metis Babs_def in_respects Quotient3_rel[OF q]) +qed (simp add: babs_rsp[OF q]) -(* If a user proves that a particular functional relation - is an equivalence this may be useful in regularising *) +text \If a user proves that a particular functional relation + is an equivalence, this may be useful in regularising\ lemma babs_reg_eqv: shows "equivp R \ Babs (Respects R) P = P" by (simp add: fun_eq_iff Babs_def in_respects equivp_reflp) @@ -372,7 +381,8 @@ shows "Ex1 (\x. x \ Respects R \ f x) = Ex1 (\x. x \ Respects R \ g x)" using a by (auto elim: rel_funE simp add: Ex1_def in_respects) -(* 2 lemmas needed for cleaning of quantifiers *) +text \Two lemmas needed for cleaning of quantifiers\ + lemma all_prs: assumes a: "Quotient3 R absf repf" shows "Ball (Respects R) ((absf ---> id) f) = All f" @@ -410,10 +420,10 @@ lemma ex1_prs: assumes "Quotient3 R absf repf" shows "((absf ---> id) ---> id) (Bex1_rel R) f = Ex1 f" - apply (auto simp: Bex1_rel_def Respects_def) - apply (metis Quotient3_def assms) - apply (metis (full_types) Quotient3_def assms) - by (meson Quotient3_rel assms) + (is "?lhs = ?rhs") + using assms + apply (auto simp add: Bex1_rel_def Respects_def) + by (metis (full_types) Quotient3_def)+ lemma bex1_bexeq_reg: shows "(\!x\Respects R. P x) \ (Bex1_rel R (\x. P x))" @@ -543,7 +553,6 @@ subsection \Quotient composition\ - lemma OOO_quotient3: fixes R1 :: "'a \ 'a \ bool" fixes Abs1 :: "'a \ 'b" and Rep1 :: "'b \ 'a" @@ -558,29 +567,35 @@ proof - have *: "(R1 OOO R2') r r \ (R1 OOO R2') s s \ (Abs2 \ Abs1) r = (Abs2 \ Abs1) s \ (R1 OOO R2') r s" for r s - apply safe - subgoal for a b c d - apply simp - apply (rule_tac b="Rep1 (Abs1 r)" in relcomppI) - using Quotient3_refl1 R1 rep_abs_rsp apply fastforce - apply (rule_tac b="Rep1 (Abs1 s)" in relcomppI) - apply (metis (full_types) Rep1 Abs1 Quotient3_rel R2 Quotient3_refl1 [OF R1] Quotient3_refl2 [OF R1] Quotient3_rel_abs [OF R1]) - by (metis Quotient3_rel R1 rep_abs_rsp_left) - subgoal for x y - apply (drule Abs1) - apply (erule Quotient3_refl2 [OF R1]) - apply (erule Quotient3_refl1 [OF R1]) - apply (drule Quotient3_refl1 [OF R2], drule Rep1) - by (metis (full_types) Quotient3_def R1 relcompp.relcompI) - subgoal for x y - apply (drule Abs1) - apply (erule Quotient3_refl2 [OF R1]) - apply (erule Quotient3_refl1 [OF R1]) - apply (drule Quotient3_refl2 [OF R2], drule Rep1) - by (metis (full_types) Quotient3_def R1 relcompp.relcompI) - subgoal for x y - by simp (metis (full_types) Abs1 Quotient3_rel R1 R2) - done + proof (intro iffI conjI; clarify) + show "(R1 OOO R2') r s" + if r: "R1 r a" "R2' a b" "R1 b r" and eq: "(Abs2 \ Abs1) r = (Abs2 \ Abs1) s" + and s: "R1 s c" "R2' c d" "R1 d s" for a b c d + proof - + have "R1 r (Rep1 (Abs1 r))" + using r Quotient3_refl1 R1 rep_abs_rsp by fastforce + moreover have "R2' (Rep1 (Abs1 r)) (Rep1 (Abs1 s))" + using that + apply (simp add: ) + apply (metis (full_types) Rep1 Abs1 Quotient3_rel R2 Quotient3_refl1 [OF R1] Quotient3_refl2 [OF R1] Quotient3_rel_abs [OF R1]) + done + moreover have "R1 (Rep1 (Abs1 s)) s" + by (metis s Quotient3_rel R1 rep_abs_rsp_left) + ultimately show ?thesis + by (metis relcomppI) + qed + next + fix x y + assume xy: "R1 r x" "R2' x y" "R1 y s" + then have "R2 (Abs1 x) (Abs1 y)" + by (iprover dest: Abs1 elim: Quotient3_refl1 [OF R1] Quotient3_refl2 [OF R1]) + then have "R2' (Rep1 (Abs1 x)) (Rep1 (Abs1 x))" "R2' (Rep1 (Abs1 y)) (Rep1 (Abs1 y))" + by (simp_all add: Quotient3_refl1 [OF R2] Quotient3_refl2 [OF R2] Rep1) + with \R1 r x\ \R1 y s\ show "(R1 OOO R2') r r" "(R1 OOO R2') s s" + by (metis (full_types) Quotient3_def R1 relcompp.relcompI)+ + show "(Abs2 \ Abs1) r = (Abs2 \ Abs1) s" + using xy by simp (metis (full_types) Abs1 Quotient3_rel R1 R2) + qed show ?thesis apply (rule Quotient3I) using * apply (simp_all add: o_def Quotient3_abs_rep [OF R2] Quotient3_abs_rep [OF R1]) diff -r 4c8edd527940 -r 1f957615cae6 src/HOL/Transitive_Closure.thy --- a/src/HOL/Transitive_Closure.thy Sun Mar 29 22:30:43 2020 +0200 +++ b/src/HOL/Transitive_Closure.thy Sun Mar 29 23:54:00 2020 +0100 @@ -87,9 +87,7 @@ lemma r_into_rtrancl [intro]: "\p. p \ r \ p \ r\<^sup>*" \ \\rtrancl\ of \r\ contains \r\\ - apply (simp only: split_tupled_all) - apply (erule rtrancl_refl [THEN rtrancl_into_rtrancl]) - done + by (simp add: split_tupled_all rtrancl_refl [THEN rtrancl_into_rtrancl]) lemma r_into_rtranclp [intro]: "r x y \ r\<^sup>*\<^sup>* x y" \ \\rtrancl\ of \r\ contains \r\\ @@ -97,10 +95,11 @@ lemma rtranclp_mono: "r \ s \ r\<^sup>*\<^sup>* \ s\<^sup>*\<^sup>*" \ \monotonicity of \rtrancl\\ - apply (rule predicate2I) - apply (erule rtranclp.induct) - apply (rule_tac [2] rtranclp.rtrancl_into_rtrancl, blast+) - done +proof (rule predicate2I) + show "s\<^sup>*\<^sup>* x y" if "r \ s" "r\<^sup>*\<^sup>* x y" for x y + using \r\<^sup>*\<^sup>* x y\ \r \ s\ + by (induction rule: rtranclp.induct) (blast intro: rtranclp.rtrancl_into_rtrancl)+ +qed lemma mono_rtranclp[mono]: "(\a b. x a b \ y a b) \ x\<^sup>*\<^sup>* a b \ y\<^sup>*\<^sup>* a b" using rtranclp_mono[of x y] by auto @@ -164,9 +163,7 @@ qed lemma rtrancl_Int_subset: "Id \ s \ (r\<^sup>* \ s) O r \ s \ r\<^sup>* \ s" - apply clarify - apply (erule rtrancl_induct, auto) - done + by (fastforce elim: rtrancl_induct) lemma converse_rtranclp_into_rtranclp: "r a b \ r\<^sup>*\<^sup>* b c \ r\<^sup>*\<^sup>* a c" by (rule rtranclp_trans) iprover+ @@ -176,27 +173,23 @@ text \\<^medskip> More \<^term>\r\<^sup>*\ equations and inclusions.\ lemma rtranclp_idemp [simp]: "(r\<^sup>*\<^sup>*)\<^sup>*\<^sup>* = r\<^sup>*\<^sup>*" - apply (auto intro!: order_antisym) - apply (erule rtranclp_induct) - apply (rule rtranclp.rtrancl_refl) - apply (blast intro: rtranclp_trans) - done +proof - + have "r\<^sup>*\<^sup>*\<^sup>*\<^sup>* x y \ r\<^sup>*\<^sup>* x y" for x y + by (induction rule: rtranclp_induct) (blast intro: rtranclp_trans)+ + then show ?thesis + by (auto intro!: order_antisym) +qed lemmas rtrancl_idemp [simp] = rtranclp_idemp [to_set] lemma rtrancl_idemp_self_comp [simp]: "R\<^sup>* O R\<^sup>* = R\<^sup>*" - apply (rule set_eqI) - apply (simp only: split_tupled_all) - apply (blast intro: rtrancl_trans) - done + by (force intro: rtrancl_trans) lemma rtrancl_subset_rtrancl: "r \ s\<^sup>* \ r\<^sup>* \ s\<^sup>*" -by (drule rtrancl_mono, simp) + by (drule rtrancl_mono, simp) lemma rtranclp_subset: "R \ S \ S \ R\<^sup>*\<^sup>* \ S\<^sup>*\<^sup>* = R\<^sup>*\<^sup>*" - apply (drule rtranclp_mono) - apply (drule rtranclp_mono, simp) - done + by (fastforce dest: rtranclp_mono) lemmas rtrancl_subset = rtranclp_subset [to_set] @@ -319,11 +312,15 @@ subsection \Transitive closure\ -lemma trancl_mono: "\p. p \ r\<^sup>+ \ r \ s \ p \ s\<^sup>+" - apply (simp add: split_tupled_all) - apply (erule trancl.induct) - apply (iprover dest: subsetD)+ - done +lemma trancl_mono: + assumes "p \ r\<^sup>+" "r \ s" + shows "p \ s\<^sup>+" +proof - + have "\(a, b) \ r\<^sup>+; r \ s\ \ (a, b) \ s\<^sup>+" for a b + by (induction rule: trancl.induct) (iprover dest: subsetD)+ + with assms show ?thesis + by (cases p) force +qed lemma r_into_trancl': "\p. p \ r \ p \ r\<^sup>+" by (simp only: split_tupled_all) (erule r_into_trancl) @@ -342,12 +339,19 @@ lemmas rtrancl_into_trancl1 = rtranclp_into_tranclp1 [to_set] -lemma rtranclp_into_tranclp2: "r a b \ r\<^sup>*\<^sup>* b c \ r\<^sup>+\<^sup>+ a c" +lemma rtranclp_into_tranclp2: + assumes "r a b" "r\<^sup>*\<^sup>* b c" shows "r\<^sup>+\<^sup>+ a c" \ \intro rule from \r\ and \rtrancl\\ - apply (erule rtranclp.cases, iprover) - apply (rule rtranclp_trans [THEN rtranclp_into_tranclp1]) - apply (simp | rule r_into_rtranclp)+ - done + using \r\<^sup>*\<^sup>* b c\ +proof (cases rule: rtranclp.cases) + case rtrancl_refl + with assms show ?thesis + by iprover +next + case rtrancl_into_rtrancl + with assms show ?thesis + by (auto intro: rtranclp_trans [THEN rtranclp_into_tranclp1]) +qed lemmas rtrancl_into_trancl2 = rtranclp_into_tranclp2 [to_set] @@ -384,9 +388,7 @@ using assms by cases simp_all lemma trancl_Int_subset: "r \ s \ (r\<^sup>+ \ s) O r \ s \ r\<^sup>+ \ s" - apply clarify - apply (erule trancl_induct, auto) - done + by (fastforce simp add: elim: trancl_induct) lemma trancl_unfold: "r\<^sup>+ = r \ r\<^sup>+ O r" by (auto intro: trancl_into_trancl elim: tranclE) @@ -418,10 +420,7 @@ using assms(2,1) by induct iprover+ lemma trancl_id [simp]: "trans r \ r\<^sup>+ = r" - apply auto - apply (erule trancl_induct, assumption) - apply (unfold trans_def, blast) - done + unfolding trans_def by (fastforce simp add: elim: trancl_induct) lemma rtranclp_tranclp_tranclp: assumes "r\<^sup>*\<^sup>* x y" @@ -435,19 +434,30 @@ lemmas trancl_into_trancl2 = tranclp_into_tranclp2 [to_set] -lemma tranclp_converseI: "(r\<^sup>+\<^sup>+)\\ x y \ (r\\)\<^sup>+\<^sup>+ x y" - apply (drule conversepD) - apply (erule tranclp_induct) - apply (iprover intro: conversepI tranclp_trans)+ - done +lemma tranclp_converseI: + assumes "(r\<^sup>+\<^sup>+)\\ x y" shows "(r\\)\<^sup>+\<^sup>+ x y" + using conversepD [OF assms] +proof (induction rule: tranclp_induct) + case (base y) + then show ?case + by (iprover intro: conversepI) +next + case (step y z) + then show ?case + by (iprover intro: conversepI tranclp_trans) +qed lemmas trancl_converseI = tranclp_converseI [to_set] -lemma tranclp_converseD: "(r\\)\<^sup>+\<^sup>+ x y \ (r\<^sup>+\<^sup>+)\\ x y" - apply (rule conversepI) - apply (erule tranclp_induct) - apply (iprover dest: conversepD intro: tranclp_trans)+ - done +lemma tranclp_converseD: + assumes "(r\\)\<^sup>+\<^sup>+ x y" shows "(r\<^sup>+\<^sup>+)\\ x y" +proof - + have "r\<^sup>+\<^sup>+ y x" + using assms + by (induction rule: tranclp_induct) (iprover dest: conversepD intro: tranclp_trans)+ + then show ?thesis + by (rule conversepI) +qed lemmas trancl_converseD = tranclp_converseD [to_set] @@ -463,17 +473,21 @@ assumes major: "r\<^sup>+\<^sup>+ a b" and cases: "\y. r y b \ P y" "\y z. r y z \ r\<^sup>+\<^sup>+ z b \ P z \ P y" shows "P a" - apply (rule tranclp_induct [OF tranclp_converseI, OF conversepI, OF major]) - apply (blast intro: cases) - apply (blast intro: assms dest!: tranclp_converseD) - done +proof - + have "r\\\<^sup>+\<^sup>+ b a" + by (intro tranclp_converseI conversepI major) + then show ?thesis + by (induction rule: tranclp_induct) (blast intro: cases dest: tranclp_converseD)+ +qed lemmas converse_trancl_induct = converse_tranclp_induct [to_set] lemma tranclpD: "R\<^sup>+\<^sup>+ x y \ \z. R x z \ R\<^sup>*\<^sup>* z y" - apply (erule converse_tranclp_induct, auto) - apply (blast intro: rtranclp_trans) - done +proof (induction rule: converse_tranclp_induct) + case (step u v) + then show ?case + by (blast intro: rtranclp_trans) +qed auto lemmas tranclD = tranclpD [to_set] @@ -492,7 +506,7 @@ by iprover next case rtrancl_into_rtrancl - from this have "tranclp r y z" + then have "tranclp r y z" by (iprover intro: rtranclp_into_tranclp1) with \r x y\ step show P by iprover @@ -513,17 +527,15 @@ lemma trancl_subset_Sigma_aux: "(a, b) \ r\<^sup>* \ r \ A \ A \ a = b \ a \ A" by (induct rule: rtrancl_induct) auto -lemma trancl_subset_Sigma: "r \ A \ A \ r\<^sup>+ \ A \ A" - apply (clarsimp simp:) - apply (erule tranclE) - apply (blast dest!: trancl_into_rtrancl trancl_subset_Sigma_aux)+ - done +lemma trancl_subset_Sigma: + assumes "r \ A \ A" shows "r\<^sup>+ \ A \ A" +proof (rule trancl_Int_subset [OF assms]) + show "(r\<^sup>+ \ A \ A) O r \ A \ A" + using assms by auto +qed lemma reflclp_tranclp [simp]: "(r\<^sup>+\<^sup>+)\<^sup>=\<^sup>= = r\<^sup>*\<^sup>*" - apply (safe intro!: order_antisym) - apply (erule tranclp_into_rtranclp) - apply (blast elim: rtranclp.cases dest: rtranclp_into_tranclp1) - done + by (fast elim: rtranclp.cases tranclp_into_rtranclp dest: rtranclp_into_tranclp1) lemmas reflcl_trancl [simp] = reflclp_tranclp [to_set] @@ -629,19 +641,14 @@ qed lemma trancl_subset_Field2: "r\<^sup>+ \ Field r \ Field r" - apply clarify - apply (erule trancl_induct) - apply (auto simp: Field_def) - done + by (rule trancl_Int_subset) (auto simp: Field_def) lemma finite_trancl[simp]: "finite (r\<^sup>+) = finite r" proof show "finite (r\<^sup>+) \ finite r" by (blast intro: r_into_trancl' finite_subset) show "finite r \ finite (r\<^sup>+)" - apply (rule trancl_subset_Field2 [THEN finite_subset]) - apply (auto simp: finite_Field) - done + by (auto simp: finite_Field trancl_subset_Field2 [THEN finite_subset]) qed lemma finite_rtrancl_Image[simp]: assumes "finite R" "finite A" shows "finite (R\<^sup>* `` A)" @@ -665,9 +672,7 @@ next case (step y z) with xz \single_valued r\ show ?case - apply (auto simp: elim: converse_rtranclE dest: single_valuedD) - apply (blast intro: rtrancl_trans) - done + by (auto elim: converse_rtranclE dest: single_valuedD intro: rtrancl_trans) qed lemma r_r_into_trancl: "(a, b) \ R \ (b, c) \ R \ (a, c) \ R\<^sup>+" @@ -676,12 +681,14 @@ lemma trancl_into_trancl: "(a, b) \ r\<^sup>+ \ (b, c) \ r \ (a, c) \ r\<^sup>+" by (induct rule: trancl_induct) (fast intro: r_r_into_trancl trancl_trans)+ -lemma tranclp_rtranclp_tranclp: "r\<^sup>+\<^sup>+ a b \ r\<^sup>*\<^sup>* b c \ r\<^sup>+\<^sup>+ a c" - apply (drule tranclpD) - apply (elim exE conjE) - apply (drule rtranclp_trans, assumption) - apply (drule (2) rtranclp_into_tranclp2) - done +lemma tranclp_rtranclp_tranclp: + assumes "r\<^sup>+\<^sup>+ a b" "r\<^sup>*\<^sup>* b c" shows "r\<^sup>+\<^sup>+ a c" +proof - + obtain z where "r a z" "r\<^sup>*\<^sup>* z c" + using assms by (iprover dest: tranclpD rtranclp_trans) + then show ?thesis + by (blast dest: rtranclp_into_tranclp2) +qed lemma rtranclp_conversep: "r\\\<^sup>*\<^sup>* = r\<^sup>*\<^sup>*\\" by(auto simp add: fun_eq_iff intro: rtranclp_converseI rtranclp_converseD) @@ -717,13 +724,13 @@ lemma symclpI [simp, intro?]: shows symclpI1: "r x y \ symclp r x y" - and symclpI2: "r y x \ symclp r x y" -by(simp_all add: symclp_def) + and symclpI2: "r y x \ symclp r x y" + by(simp_all add: symclp_def) lemma symclpE [consumes 1, cases pred]: assumes "symclp r x y" obtains (base) "r x y" | (sym) "r y x" -using assms by(auto simp add: symclp_def) + using assms by(auto simp add: symclp_def) lemma symclp_pointfree: "symclp r = sup r r\\" by(auto simp add: symclp_def fun_eq_iff) @@ -962,12 +969,10 @@ lemma trancl_power: "p \ R\<^sup>+ \ (\n > 0. p \ R ^^ n)" proof - - have "((a, b) \ R\<^sup>+) = (\n>0. (a, b) \ R ^^ n)" for a b + have "(a, b) \ R\<^sup>+ \ (\n>0. (a, b) \ R ^^ n)" for a b proof safe show "(a, b) \ R\<^sup>+ \ \n>0. (a, b) \ R ^^ n" - apply (drule tranclD2) - apply (fastforce simp: rtrancl_is_UN_relpow relcomp_unfold) - done + by (fastforce simp: rtrancl_is_UN_relpow relcomp_unfold dest: tranclD2) show "(a, b) \ R\<^sup>+" if "n > 0" "(a, b) \ R ^^ n" for n proof (cases n) case (Suc m) @@ -1117,17 +1122,23 @@ fixes R :: "('a \ 'a) set" assumes "finite R" shows "R^^k \ (\n\{n. n \ card R}. R^^n)" - apply (cases k, force) - apply (use relpow_finite_bounded1[OF assms, of k] in auto) - done +proof (cases k) + case (Suc k') + then show ?thesis + using relpow_finite_bounded1[OF assms, of k] by auto +qed force lemma rtrancl_finite_eq_relpow: "finite R \ R\<^sup>* = (\n\{n. n \ card R}. R^^n)" by (fastforce simp: rtrancl_power dest: relpow_finite_bounded) -lemma trancl_finite_eq_relpow: "finite R \ R\<^sup>+ = (\n\{n. 0 < n \ n \ card R}. R^^n)" - apply (auto simp: trancl_power) - apply (auto dest: relpow_finite_bounded1) - done +lemma trancl_finite_eq_relpow: + assumes "finite R" shows "R\<^sup>+ = (\n\{n. 0 < n \ n \ card R}. R^^n)" +proof - + have "\a b n. \0 < n; (a, b) \ R ^^ n\ \ \x>0. x \ card R \ (a, b) \ R ^^ x" + using assms by (auto dest: relpow_finite_bounded1) + then show ?thesis + by (auto simp: trancl_power) +qed lemma finite_relcomp[simp,intro]: assumes "finite R" and "finite S" @@ -1189,7 +1200,7 @@ show ?thesis proof (cases "i = 1") case True - from this \(a, b) \ R ^^ i\ show ?thesis + with \(a, b) \ R ^^ i\ show ?thesis by (auto simp: ntrancl_def) next case False