added lemma wf_on_iff_wf
authordesharna
Mon, 25 Mar 2024 19:27:53 +0100
changeset 79997 d8320c3a43ec
parent 79996 4f803ae64781
child 79998 9df291750cc0
added lemma wf_on_iff_wf
NEWS
src/HOL/Wellfounded.thy
--- a/NEWS	Mon Mar 25 19:27:32 2024 +0100
+++ b/NEWS	Mon Mar 25 19:27:53 2024 +0100
@@ -110,7 +110,7 @@
     Lemmas wf_def and wfP_def are explicitly provided for backward
     compatibility but their usage is discouraged. Minor INCOMPATIBILITY.
   - Added wfp as alias for wfP for greater consistency with other predicates
-    such as asymp, transp, or totalp. 
+    such as asymp, transp, or totalp.
   - Added lemmas.
       wellorder.wfp_on_less[simp]
       wfP_iff_ex_minimal
@@ -120,6 +120,7 @@
       wf_on_antimono
       wf_on_antimono_strong
       wf_on_iff_ex_minimal
+      wf_on_iff_wf
       wf_on_induct
       wf_on_subset
       wfp_on_antimono
--- a/src/HOL/Wellfounded.thy	Mon Mar 25 19:27:32 2024 +0100
+++ b/src/HOL/Wellfounded.thy	Mon Mar 25 19:27:53 2024 +0100
@@ -71,6 +71,57 @@
 
 lemmas wfP_induct_rule = wf_induct_rule [to_pred, induct set: wfP]
 
+lemma wf_on_iff_wf: "wf_on A r \<longleftrightarrow> wf {(x, y) \<in> r. x \<in> A \<and> y \<in> A}"
+proof (rule iffI)
+  assume wf: "wf_on A r"
+  show "wf {(x, y) \<in> r. x \<in> A \<and> y \<in> A}"
+    unfolding wf_def
+  proof (intro allI impI ballI)
+    fix P x
+    assume IH: "\<forall>x. (\<forall>y. (y, x) \<in> {(x, y). (x, y) \<in> r \<and> x \<in> A \<and> y \<in> A} \<longrightarrow> P y) \<longrightarrow> P x"
+    show "P x"
+    proof (cases "x \<in> A")
+      case True
+      show ?thesis
+        using wf
+      proof (induction x rule: wf_on_induct)
+        case in_set
+        thus ?case
+          using True .
+      next
+        case (less x)
+        thus ?case
+          by (auto intro: IH[rule_format])
+      qed
+    next
+      case False
+      then show ?thesis
+        by (auto intro: IH[rule_format])
+    qed
+  qed
+next
+  assume wf: "wf {(x, y). (x, y) \<in> r \<and> x \<in> A \<and> y \<in> A}"
+  show "wf_on A r"
+    unfolding wf_on_def
+  proof (intro allI impI ballI)
+    fix P x
+    assume IH: "\<forall>x\<in>A. (\<forall>y\<in>A. (y, x) \<in> r \<longrightarrow> P y) \<longrightarrow> P x" and "x \<in> A"
+    show "P x"
+      using wf \<open>x \<in> A\<close>
+    proof (induction x rule: wf_on_induct)
+      case in_set
+      show ?case
+        by simp
+    next
+      case (less y)
+      hence "\<And>z. (z, y) \<in> r \<Longrightarrow> z \<in> A \<Longrightarrow> P z"
+        by simp
+      thus ?case
+        using IH[rule_format, OF \<open>y \<in> A\<close>] by simp
+    qed
+  qed
+qed
+
 
 subsection \<open>Introduction Rules\<close>