theory Scratch imports Wellfounded begin text \Bachmair and Dershowitz 1986, Lemma 2.\ lemma qc_wf_relto_iff: assumes "R O S \ (R \ S)\<^sup>* O R" -- \R quasi-commutes over S\ shows "wf (S\<^sup>* O R O S\<^sup>*) \ wf R" (is "wf ?S \ _") proof assume "wf ?S" moreover have "R \ ?S" by auto ultimately show "wf R" using wf_subset by auto next assume "wf R" show "wf ?S" proof (rule wfI_pf) fix A assume A: "A \ ?S `` A" let ?X = "(R \ S)\<^sup>* `` A" have *: "R O (R \ S)\<^sup>* \ (R \ S)\<^sup>* O R" proof - { fix x y z assume "(y, z) \ (R \ S)\<^sup>*" and "(x, y) \ R" then have "(x, z) \ (R \ S)\<^sup>* O R" proof (induct y z) case rtrancl_refl then show ?case by auto next case (rtrancl_into_rtrancl a b c) then have "(x, c) \ ((R \ S)\<^sup>* O (R \ S)\<^sup>*) O R" using assms by blast then show ?case by simp qed } then show ?thesis by auto qed then have "R O S\<^sup>* \ (R \ S)\<^sup>* O R" using rtrancl_Un_subset by blast then have "?S \ (R \ S)\<^sup>* O (R \ S)\<^sup>* O R" by (simp add: relcomp_mono rtrancl_mono) also have "\ = (R \ S)\<^sup>* O R" by (simp add: O_assoc[symmetric]) finally have "?S O (R \ S)\<^sup>* \ (R \ S)\<^sup>* O R O (R \ S)\<^sup>*" by (simp add: O_assoc[symmetric] relcomp_mono) also have "\ \ (R \ S)\<^sup>* O (R \ S)\<^sup>* O R" using * by (simp add: relcomp_mono) finally have "?S O (R \ S)\<^sup>* \ (R \ S)\<^sup>* O R" by (simp add: O_assoc[symmetric]) then have "(?S O (R \ S)\<^sup>*) `` A \ ((R \ S)\<^sup>* O R) `` A" by (simp add: Image_mono) moreover have "?X \ (?S O (R \ S)\<^sup>*) `` A" using A by (auto simp: relcomp_Image) ultimately have "?X \ R `` ?X" by (auto simp: relcomp_Image) then have "?X = {}" using \wf R\ by (simp add: wfE_pf) moreover have "A \ ?X" by auto ultimately show "A = {}" by simp qed qed