# HG changeset patch # User desharna # Date 1665578223 -7200 # Node ID 5ea1f8bfb795aea0291f1bb2d15d4f2cbe46f46d # Parent 0b2fcf0c61dba37c641deb4764e7205b8562b2a7 added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat diff -r 0b2fcf0c61db -r 5ea1f8bfb795 NEWS --- a/NEWS Wed Oct 12 14:33:04 2022 +0200 +++ b/NEWS Wed Oct 12 14:37:03 2022 +0200 @@ -24,6 +24,12 @@ reflp_le[simp] totalp_on_singleton[simp] +* Theory "HOL.Wellfounded": + - Added lemmas. + wfP_if_convertible_to_nat + wfP_if_convertible_to_wfP + wf_if_convertible_to_wf + New in Isabelle2022 (October 2022) ---------------------------------- diff -r 0b2fcf0c61db -r 5ea1f8bfb795 src/HOL/Wellfounded.thy --- a/src/HOL/Wellfounded.thy Wed Oct 12 14:33:04 2022 +0200 +++ b/src/HOL/Wellfounded.thy Wed Oct 12 14:37:03 2022 +0200 @@ -772,7 +772,35 @@ by (clarsimp simp: inv_image_def wf_eq_minimal) qed -text \Measure functions into \<^typ>\nat\\ + +subsubsection \Conversion to a known well-founded relation\ + +lemma wf_if_convertible_to_wf: + fixes r :: "'a rel" and s :: "'b rel" and f :: "'a \ 'b" + assumes "wf s" and convertible: "\x y. (x, y) \ r \ (f x, f y) \ s" + shows "wf r" +proof (rule wfI_min[of r]) + fix x :: 'a and Q :: "'a set" + assume "x \ Q" + then obtain y where "y \ Q" and "\z. (f z, f y) \ s \ z \ Q" + by (auto elim: wfE_min[OF wf_inv_image[of s f, OF \wf s\], unfolded in_inv_image]) + thus "\z \ Q. \y. (y, z) \ r \ y \ Q" + by (auto intro: convertible) +qed + +lemma wfP_if_convertible_to_wfP: "wfP S \ (\x y. R x y \ S (f x) (f y)) \ wfP R" + using wf_if_convertible_to_wf[to_pred, of S R f] by simp + +text \Converting to @{typ nat} is a very common special case that might be found more easily by + Sledgehammer.\ + +lemma wfP_if_convertible_to_nat: + fixes f :: "_ \ nat" + shows "(\x y. R x y \ f x < f y) \ wfP R" + by (rule wfP_if_convertible_to_wfP[of "(<) :: nat \ nat \ bool", simplified]) + + +subsubsection \Measure functions into \<^typ>\nat\\ definition measure :: "('a \ nat) \ ('a \ 'a) set" where "measure = inv_image less_than"