# HG changeset patch # User desharna # Date 1741113252 -3600 # Node ID 1b73c3e17d9ff9d2cb56a67662f82ffc2909bae1 # Parent 3f70b283bea9882f9e173de5e54b4896d0ff19de added lemma wf_on_lex_prod[intro] diff -r 3f70b283bea9 -r 1b73c3e17d9f NEWS --- a/NEWS Tue Mar 04 17:57:10 2025 +0100 +++ b/NEWS Tue Mar 04 19:34:12 2025 +0100 @@ -16,6 +16,7 @@ * Theory "HOL.Wellfounded": - Added lemmas. + wf_on_lex_prod[intro] wfp_on_iff_wfp * Theory "HOL-Library.Multiset": diff -r 3f70b283bea9 -r 1b73c3e17d9f src/HOL/Wellfounded.thy --- a/src/HOL/Wellfounded.thy Tue Mar 04 17:57:10 2025 +0100 +++ b/src/HOL/Wellfounded.thy Tue Mar 04 19:34:12 2025 +0100 @@ -1211,28 +1211,59 @@ lemma in_lex_prod[simp]: "((a, b), (a', b')) \ r <*lex*> s \ (a, a') \ r \ a = a' \ (b, b') \ s" by (auto simp:lex_prod_def) +lemma wf_on_lex_prod[intro]: + assumes wfA: "wf_on A r\<^sub>A" and wfB: "wf_on B r\<^sub>B" + shows "wf_on (A \ B) (r\<^sub>A <*lex*> r\<^sub>B)" + unfolding wf_on_iff_ex_minimal +proof (intro allI impI) + fix AB assume "AB \ A \ B" and "AB \ {}" + hence "fst ` AB \ A" and "snd ` AB \ B" + by auto + + from \fst ` AB \ A\ \AB \ {}\ obtain a where + a_in: "a \ fst ` AB" and + a_minimal: "(\y. (y, a) \ r\<^sub>A \ y \ fst ` AB)" + using wfA[unfolded wf_on_iff_ex_minimal, rule_format, of "fst ` AB"] + by auto + + from \snd ` AB \ B\ \AB \ {}\ a_in obtain b where + b_in: "b \ snd ` {p \ AB. fst p = a}" and + b_minimal: "(\y. (y, b) \ r\<^sub>B \ y \ snd ` {p \ AB. fst p = a})" + using wfB[unfolded wf_on_iff_ex_minimal, rule_format, of "snd ` {p \ AB. fst p = a}"] + by blast + + show "\z\AB. \y. (y, z) \ r\<^sub>A <*lex*> r\<^sub>B \ y \ AB" + proof (rule bexI) + show "(a, b) \ AB" + using b_in by (simp add: image_iff) + next + show "\y. (y, (a, b)) \ r\<^sub>A <*lex*> r\<^sub>B \ y \ AB" + proof (intro allI impI) + fix p assume "(p, (a, b)) \ r\<^sub>A <*lex*> r\<^sub>B" + hence "(fst p, a) \ r\<^sub>A \ fst p = a \ (snd p, b) \ r\<^sub>B" + unfolding lex_prod_def by auto + thus "p \ AB" + proof (elim disjE conjE) + assume "(fst p, a) \ r\<^sub>A" + hence "fst p \ fst ` AB" + using a_minimal by simp + thus ?thesis + by (rule contrapos_nn) simp + next + assume "fst p = a" and "(snd p, b) \ r\<^sub>B" + hence "snd p \ snd ` {p \ AB. fst p = a}" + using b_minimal by simp + thus "p \ AB" + by (rule contrapos_nn) (simp add: \fst p = a\) + qed + qed + qed +qed + lemma wf_lex_prod [intro!]: assumes "wf ra" "wf rb" shows "wf (ra <*lex*> rb)" -proof (rule wfI) - fix z :: "'a \ 'b" and P - assume * [rule_format]: "\u. (\v. (v, u) \ ra <*lex*> rb \ P v) \ P u" - obtain x y where zeq: "z = (x,y)" - by fastforce - have "P(x,y)" using \wf ra\ - proof (induction x arbitrary: y rule: wf_induct_rule) - case (less x) - note lessx = less - show ?case using \wf rb\ less - proof (induction y rule: wf_induct_rule) - case (less y) - show ?case - by (force intro: * less.IH lessx) - qed - qed - then show "P z" - by (simp add: zeq) -qed auto + using wf_on_lex_prod[OF \wf ra\ \wf rb\, unfolded UNIV_Times_UNIV] . lemma refl_lex_prod[simp]: "refl r\<^sub>B \ refl (r\<^sub>A <*lex*> r\<^sub>B)" by (auto intro!: reflI dest: refl_onD)