diff -r b87b14e885af -r 43f5dfb7fa35 src/HOL/Order_Relation.thy --- a/src/HOL/Order_Relation.thy Fri Jul 15 09:18:21 2022 +0200 +++ b/src/HOL/Order_Relation.thy Fri Jul 22 14:39:56 2022 +0200 @@ -133,15 +133,19 @@ assumes "Total r" and not_Id: "\ r \ Id" shows "Field r = Field (r - Id)" - using mono_Field[of "r - Id" r] Diff_subset[of r Id] -proof auto - fix a assume *: "a \ Field r" - from not_Id have "r \ {}" by fast - with not_Id obtain b and c where "b \ c \ (b,c) \ r" by auto - then have "b \ c \ {b, c} \ Field r" by (auto simp: Field_def) - with * obtain d where "d \ Field r" "d \ a" by auto - with * \Total r\ have "(a, d) \ r \ (d, a) \ r" by (simp add: total_on_def) - with \d \ a\ show "a \ Field (r - Id)" unfolding Field_def by blast +proof - + have "Field r \ Field (r - Id)" + proof (rule subsetI) + fix a assume *: "a \ Field r" + from not_Id have "r \ {}" by fast + with not_Id obtain b and c where "b \ c \ (b,c) \ r" by auto + then have "b \ c \ {b, c} \ Field r" by (auto simp: Field_def) + with * obtain d where "d \ Field r" "d \ a" by auto + with * \Total r\ have "(a, d) \ r \ (d, a) \ r" by (simp add: total_on_def) + with \d \ a\ show "a \ Field (r - Id)" unfolding Field_def by blast + qed + then show ?thesis + using mono_Field[of "r - Id" r] Diff_subset[of r Id] by auto qed subsection\Relations given by a predicate and the field\ @@ -323,7 +327,7 @@ and "(a, b) \ r" shows "under r a \ under r b" unfolding under_def -proof auto +proof safe fix x assume "(x, a) \ r" with assms trans_def[of r] show "(x, b) \ r" by blast qed @@ -334,7 +338,7 @@ and ab: "(a, b) \ r" shows "underS r a \ underS r b" unfolding underS_def -proof auto +proof safe assume *: "b \ a" and **: "(b, a) \ r" with \antisym r\ antisym_def[of r] ab show False by blast @@ -440,12 +444,18 @@ then have "(\b. (\c. (c, b) \ R a \ chi c) \ chi b) \ (\b. chi b)" unfolding wf_def by blast also have "\b. (\c. (c, b) \ R a \ chi c) \ chi b" - proof (auto simp add: chi_def R_def) + proof safe fix b - assume "(b, a) \ r" and "\c. (c, b) \ r \ (c, a) \ r \ phi c" - then have "\c. (c, b) \ r \ phi c" - using assms trans_def[of r] by blast - with ** show "phi b" by blast + assume "\c. (c, b) \ R a \ chi c" + moreover have "(b, a) \ r \ \c. (c, b) \ r \ (c, a) \ r \ phi c \ phi b" + proof - + assume "(b, a) \ r" and "\c. (c, b) \ r \ (c, a) \ r \ phi c" + then have "\c. (c, b) \ r \ phi c" + using assms trans_def[of r] by blast + with ** show "phi b" by blast + qed + ultimately show "chi b" + by (auto simp add: chi_def R_def) qed finally have "\b. chi b" . with ** chi_def show "phi a" by blast @@ -456,13 +466,18 @@ text\A transitive relation is well-founded if all initial segments are finite.\ corollary wf_finite_segments: assumes "irrefl r" and "trans r" and "\x. finite {y. (y, x) \ r}" - shows "wf (r)" -proof (clarsimp simp: trans_wf_iff wf_iff_acyclic_if_finite converse_def assms) - fix a - have "trans (r \ ({x. (x, a) \ r} \ {x. (x, a) \ r}))" - using assms unfolding trans_def Field_def by blast - then show "acyclic (r \ {x. (x, a) \ r} \ {x. (x, a) \ r})" - using assms acyclic_def assms irrefl_def by fastforce + shows "wf r" +proof - + have "\a. acyclic (r \ {x. (x, a) \ r} \ {x. (x, a) \ r})" + proof - + fix a + have "trans (r \ ({x. (x, a) \ r} \ {x. (x, a) \ r}))" + using assms unfolding trans_def Field_def by blast + then show "acyclic (r \ {x. (x, a) \ r} \ {x. (x, a) \ r})" + using assms acyclic_def assms irrefl_def by fastforce + qed + then show ?thesis + by (clarsimp simp: trans_wf_iff wf_iff_acyclic_if_finite converse_def assms) qed text \The next lemma is a variation of \wf_eq_minimal\ from Wellfounded, @@ -472,13 +487,26 @@ proof- let ?phi = "\A. A \ {} \ (\a \ A. \a' \ A. (a',a) \ r)" have "wf r \ (\A. ?phi A)" - apply (auto simp: ex_in_conv [THEN sym]) - apply (erule wfE_min) - apply assumption - apply blast - apply (rule wfI_min) - apply fast - done + proof + assume "wf r" + show "\A. ?phi A" + proof clarify + fix A:: "'a set" + assume "A \ {}" + then obtain x where "x \ A" + by auto + show "\a\A. \a'\A. (a', a) \ r" + apply (rule wfE_min[of r x A]) + apply fact+ + by blast + qed + next + assume *: "\A. ?phi A" + then show "wf r" + apply (clarsimp simp: ex_in_conv [THEN sym]) + apply (rule wfI_min) + by fast + qed also have "(\A. ?phi A) \ (\B \ Field r. ?phi B)" proof assume "\A. ?phi A"