# HG changeset patch # User krauss # Date 1180703645 -7200 # Node ID f948708bc1005177261c88a01d925b1d4dd1d706 # Parent 1fa87978cf27f22ec837265c056b481e4163ecb6 Added "merge-lemma" about wellfoundedness of unions (useful for some termination proofs) diff -r 1fa87978cf27 -r f948708bc100 src/HOL/Wellfounded_Recursion.thy --- a/src/HOL/Wellfounded_Recursion.thy Fri Jun 01 15:12:56 2007 +0200 +++ b/src/HOL/Wellfounded_Recursion.thy Fri Jun 01 15:14:05 2007 +0200 @@ -136,6 +136,19 @@ qed qed +lemma wfE_min: + assumes p:"wf R" "x \ Q" + obtains z where "z \ Q" "\y. (y, z) \ R \ y \ Q" + using p + unfolding wf_eq_minimal + by blast + +lemma wfI_min: + "(\x Q. x \ Q \ \z\Q. \y. (y, z) \ R \ y \ Q) + \ wf R" + unfolding wf_eq_minimal + by blast + lemmas wfP_eq_minimal = wf_eq_minimal [to_pred] text{*Well-foundedness of subsets*} @@ -242,6 +255,60 @@ apply (blast elim!: allE) done +lemma wf_union_merge: + "wf (R \ S) = wf (R O R \ R O S \ S)" (is "wf ?A = wf ?B") +proof + assume "wf ?A" + with wf_trancl have wfT: "wf (?A^+)" . + moreover have "?B \ ?A^+" + by (subst trancl_unfold, subst trancl_unfold) blast + ultimately show "wf ?B" by (rule wf_subset) +next + assume "wf ?B" + + show "wf ?A" + proof (rule wfI_min) + fix Q :: "'a set" and x + assume "x \ Q" + + with `wf ?B` + obtain z where "z \ Q" and "\y. (y, z) \ ?B \ y \ Q" + by (erule wfE_min) + hence A1: "\y. (y, z) \ R O R \ y \ Q" + and A2: "\y. (y, z) \ R O S \ y \ Q" + and A3: "\y. (y, z) \ S \ y \ Q" + by auto + + show "\z\Q. \y. (y, z) \ ?A \ y \ Q" + proof (cases "\y. (y, z) \ R \ y \ Q") + case True + with `z \ Q` A3 show ?thesis by blast + next + case False + then obtain z' where "z'\Q" "(z', z) \ R" by blast + + have "\y. (y, z') \ ?A \ y \ Q" + proof (intro allI impI) + fix y assume "(y, z') \ ?A" + thus "y \ Q" + proof + assume "(y, z') \ R" + hence "(y, z) \ R O R" using `(z', z) \ R` .. + with A1 show "y \ Q" . + next + assume "(y, z') \ S" + hence "(y, z) \ R O S" using `(z', z) \ R` .. + with A2 show "y \ Q" . + qed + qed + thus ?thesis .. + qed + qed +qed + +lemma wf_comp_self: "wf R = wf (R O R)" (* special case *) + by (fact wf_union_merge[where S = "{}", simplified]) + subsubsection {*acyclic*} lemma acyclicI: "ALL x. (x, x) ~: r^+ ==> acyclic r"