--- a/src/HOL/Order_Relation.thy Sun Jul 31 19:09:21 2016 +0200
+++ b/src/HOL/Order_Relation.thy Sun Jul 31 22:56:18 2016 +0200
@@ -9,7 +9,7 @@
imports Wfrec
begin
-subsection\<open>Orders on a set\<close>
+subsection \<open>Orders on a set\<close>
definition "preorder_on A r \<equiv> refl_on A r \<and> trans r"
@@ -27,51 +27,48 @@
lemma preorder_on_empty[simp]: "preorder_on {} {}"
-by(simp add:preorder_on_def trans_def)
+ by (simp add: preorder_on_def trans_def)
lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
-by(simp add:partial_order_on_def)
+ by (simp add: partial_order_on_def)
lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
-by(simp add:linear_order_on_def)
+ by (simp add: linear_order_on_def)
lemma well_order_on_empty[simp]: "well_order_on {} {}"
-by(simp add:well_order_on_def)
+ by (simp add: well_order_on_def)
-lemma preorder_on_converse[simp]: "preorder_on A (r^-1) = preorder_on A r"
-by (simp add:preorder_on_def)
+lemma preorder_on_converse[simp]: "preorder_on A (r\<inverse>) = preorder_on A r"
+ by (simp add: preorder_on_def)
-lemma partial_order_on_converse[simp]:
- "partial_order_on A (r^-1) = partial_order_on A r"
-by (simp add: partial_order_on_def)
+lemma partial_order_on_converse[simp]: "partial_order_on A (r\<inverse>) = partial_order_on A r"
+ by (simp add: partial_order_on_def)
-lemma linear_order_on_converse[simp]:
- "linear_order_on A (r^-1) = linear_order_on A r"
-by (simp add: linear_order_on_def)
+lemma linear_order_on_converse[simp]: "linear_order_on A (r\<inverse>) = linear_order_on A r"
+ by (simp add: linear_order_on_def)
-lemma strict_linear_order_on_diff_Id:
- "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r-Id)"
-by(simp add: order_on_defs trans_diff_Id)
+lemma strict_linear_order_on_diff_Id: "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r - Id)"
+ by (simp add: order_on_defs trans_diff_Id)
lemma linear_order_on_singleton [simp]: "linear_order_on {x} {(x, x)}"
-unfolding order_on_defs by simp
+ by (simp add: order_on_defs)
lemma linear_order_on_acyclic:
assumes "linear_order_on A r"
shows "acyclic (r - Id)"
-using strict_linear_order_on_diff_Id[OF assms]
-by(auto simp add: acyclic_irrefl strict_linear_order_on_def)
+ using strict_linear_order_on_diff_Id[OF assms]
+ by (auto simp add: acyclic_irrefl strict_linear_order_on_def)
lemma linear_order_on_well_order_on:
assumes "finite r"
shows "linear_order_on A r \<longleftrightarrow> well_order_on A r"
-unfolding well_order_on_def
-using assms finite_acyclic_wf[OF _ linear_order_on_acyclic, of r] by blast
+ unfolding well_order_on_def
+ using assms finite_acyclic_wf[OF _ linear_order_on_acyclic, of r] by blast
-subsection\<open>Orders on the field\<close>
+subsection \<open>Orders on the field\<close>
abbreviation "Refl r \<equiv> refl_on (Field r) r"
@@ -87,50 +84,57 @@
lemma subset_Image_Image_iff:
- "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow>
- r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)"
-unfolding preorder_on_def refl_on_def Image_def
-apply (simp add: subset_eq)
-unfolding trans_def by fast
+ "Preorder r \<Longrightarrow> A \<subseteq> Field r \<Longrightarrow> B \<subseteq> Field r \<Longrightarrow>
+ r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b, a) \<in> r)"
+ apply (simp add: preorder_on_def refl_on_def Image_def subset_eq)
+ apply (simp only: trans_def)
+ apply fast
+ done
lemma subset_Image1_Image1_iff:
- "\<lbrakk> Preorder r; a : Field r; b : Field r\<rbrakk> \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b,a):r"
-by(simp add:subset_Image_Image_iff)
+ "Preorder r \<Longrightarrow> a \<in> Field r \<Longrightarrow> b \<in> Field r \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b, a) \<in> r"
+ by (simp add: subset_Image_Image_iff)
lemma Refl_antisym_eq_Image1_Image1_iff:
- assumes r: "Refl r" and as: "antisym r" and abf: "a \<in> Field r" "b \<in> Field r"
+ assumes "Refl r"
+ and as: "antisym r"
+ and abf: "a \<in> Field r" "b \<in> Field r"
shows "r `` {a} = r `` {b} \<longleftrightarrow> a = b"
+ (is "?lhs \<longleftrightarrow> ?rhs")
proof
- assume "r `` {a} = r `` {b}"
- hence e: "\<And>x. (a, x) \<in> r \<longleftrightarrow> (b, x) \<in> r" by (simp add: set_eq_iff)
- have "(a, a) \<in> r" "(b, b) \<in> r" using r abf by (simp_all add: refl_on_def)
- hence "(a, b) \<in> r" "(b, a) \<in> r" using e[of a] e[of b] by simp_all
- thus "a = b" using as[unfolded antisym_def] by blast
-qed fast
+ assume ?lhs
+ then have *: "\<And>x. (a, x) \<in> r \<longleftrightarrow> (b, x) \<in> r"
+ by (simp add: set_eq_iff)
+ have "(a, a) \<in> r" "(b, b) \<in> r" using \<open>Refl r\<close> abf by (simp_all add: refl_on_def)
+ then have "(a, b) \<in> r" "(b, a) \<in> r" using *[of a] *[of b] by simp_all
+ then show ?rhs
+ using \<open>antisym r\<close>[unfolded antisym_def] by blast
+next
+ assume ?rhs
+ then show ?lhs by fast
+qed
lemma Partial_order_eq_Image1_Image1_iff:
- "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b"
-by(auto simp:order_on_defs Refl_antisym_eq_Image1_Image1_iff)
+ "Partial_order r \<Longrightarrow> a \<in> Field r \<Longrightarrow> b \<in> Field r \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a = b"
+ by (auto simp: order_on_defs Refl_antisym_eq_Image1_Image1_iff)
lemma Total_Id_Field:
-assumes TOT: "Total r" and NID: "\<not> (r <= Id)"
-shows "Field r = Field(r - Id)"
-using mono_Field[of "r - Id" r] Diff_subset[of r Id]
-proof(auto)
- have "r \<noteq> {}" using NID by fast
- then obtain b and c where "b \<noteq> c \<and> (b,c) \<in> r" using NID by auto
- hence 1: "b \<noteq> c \<and> {b,c} \<le> Field r" by (auto simp: Field_def)
-
+ assumes "Total r"
+ and not_Id: "\<not> r \<subseteq> Id"
+ shows "Field r = Field (r - Id)"
+ using mono_Field[of "r - Id" r] Diff_subset[of r Id]
+proof auto
fix a assume *: "a \<in> Field r"
- obtain d where 2: "d \<in> Field r" and 3: "d \<noteq> a"
- using * 1 by auto
- hence "(a,d) \<in> r \<or> (d,a) \<in> r" using * TOT
- by (simp add: total_on_def)
- thus "a \<in> Field(r - Id)" using 3 unfolding Field_def by blast
+ from not_Id have "r \<noteq> {}" by fast
+ with not_Id obtain b and c where "b \<noteq> c \<and> (b,c) \<in> r" by auto
+ then have "b \<noteq> c \<and> {b, c} \<subseteq> Field r" by (auto simp: Field_def)
+ with * obtain d where "d \<in> Field r" "d \<noteq> a" by auto
+ with * \<open>Total r\<close> have "(a, d) \<in> r \<or> (d, a) \<in> r" by (simp add: total_on_def)
+ with \<open>d \<noteq> a\<close> show "a \<in> Field (r - Id)" unfolding Field_def by blast
qed
-subsection\<open>Orders on a type\<close>
+subsection \<open>Orders on a type\<close>
abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV"
@@ -141,297 +145,303 @@
subsection \<open>Order-like relations\<close>
-text\<open>In this subsection, we develop basic concepts and results pertaining
-to order-like relations, i.e., to reflexive and/or transitive and/or symmetric and/or
-total relations. We also further define upper and lower bounds operators.\<close>
+text \<open>
+ In this subsection, we develop basic concepts and results pertaining
+ to order-like relations, i.e., to reflexive and/or transitive and/or symmetric and/or
+ total relations. We also further define upper and lower bounds operators.
+\<close>
subsubsection \<open>Auxiliaries\<close>
-lemma refl_on_domain:
-"\<lbrakk>refl_on A r; (a,b) : r\<rbrakk> \<Longrightarrow> a \<in> A \<and> b \<in> A"
-by(auto simp add: refl_on_def)
+lemma refl_on_domain: "refl_on A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> a \<in> A \<and> b \<in> A"
+ by (auto simp add: refl_on_def)
-corollary well_order_on_domain:
-"\<lbrakk>well_order_on A r; (a,b) \<in> r\<rbrakk> \<Longrightarrow> a \<in> A \<and> b \<in> A"
-by (auto simp add: refl_on_domain order_on_defs)
+corollary well_order_on_domain: "well_order_on A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> a \<in> A \<and> b \<in> A"
+ by (auto simp add: refl_on_domain order_on_defs)
-lemma well_order_on_Field:
-"well_order_on A r \<Longrightarrow> A = Field r"
-by(auto simp add: refl_on_def Field_def order_on_defs)
+lemma well_order_on_Field: "well_order_on A r \<Longrightarrow> A = Field r"
+ by (auto simp add: refl_on_def Field_def order_on_defs)
-lemma well_order_on_Well_order:
-"well_order_on A r \<Longrightarrow> A = Field r \<and> Well_order r"
-using well_order_on_Field by auto
+lemma well_order_on_Well_order: "well_order_on A r \<Longrightarrow> A = Field r \<and> Well_order r"
+ using well_order_on_Field [of A] by auto
lemma Total_subset_Id:
-assumes TOT: "Total r" and SUB: "r \<le> Id"
-shows "r = {} \<or> (\<exists>a. r = {(a,a)})"
-proof-
- {assume "r \<noteq> {}"
- then obtain a b where 1: "(a,b) \<in> r" by fast
- hence "a = b" using SUB by blast
- hence 2: "(a,a) \<in> r" using 1 by simp
- {fix c d assume "(c,d) \<in> r"
- hence "{a,c,d} \<le> Field r" using 1 unfolding Field_def by blast
- hence "((a,c) \<in> r \<or> (c,a) \<in> r \<or> a = c) \<and>
- ((a,d) \<in> r \<or> (d,a) \<in> r \<or> a = d)"
- using TOT unfolding total_on_def by blast
- hence "a = c \<and> a = d" using SUB by blast
- }
- hence "r \<le> {(a,a)}" by auto
- with 2 have "\<exists>a. r = {(a,a)}" by blast
- }
- thus ?thesis by blast
+ assumes "Total r"
+ and "r \<subseteq> Id"
+ shows "r = {} \<or> (\<exists>a. r = {(a, a)})"
+proof -
+ have "\<exists>a. r = {(a, a)}" if "r \<noteq> {}"
+ proof -
+ from that obtain a b where ab: "(a, b) \<in> r" by fast
+ with \<open>r \<subseteq> Id\<close> have "a = b" by blast
+ with ab have aa: "(a, a) \<in> r" by simp
+ have "a = c \<and> a = d" if "(c, d) \<in> r" for c d
+ proof -
+ from that have "{a, c, d} \<subseteq> Field r"
+ using ab unfolding Field_def by blast
+ then have "((a, c) \<in> r \<or> (c, a) \<in> r \<or> a = c) \<and> ((a, d) \<in> r \<or> (d, a) \<in> r \<or> a = d)"
+ using \<open>Total r\<close> unfolding total_on_def by blast
+ with \<open>r \<subseteq> Id\<close> show ?thesis by blast
+ qed
+ then have "r \<subseteq> {(a, a)}" by auto
+ with aa show ?thesis by blast
+ qed
+ then show ?thesis by blast
qed
lemma Linear_order_in_diff_Id:
-assumes LI: "Linear_order r" and
- IN1: "a \<in> Field r" and IN2: "b \<in> Field r"
-shows "((a,b) \<in> r) = ((b,a) \<notin> r - Id)"
-using assms unfolding order_on_defs total_on_def antisym_def Id_def refl_on_def by force
+ assumes "Linear_order r"
+ and "a \<in> Field r"
+ and "b \<in> Field r"
+ shows "(a, b) \<in> r \<longleftrightarrow> (b, a) \<notin> r - Id"
+ using assms unfolding order_on_defs total_on_def antisym_def Id_def refl_on_def by force
subsubsection \<open>The upper and lower bounds operators\<close>
-text\<open>Here we define upper (``above") and lower (``below") bounds operators.
-We think of \<open>r\<close> as a {\em non-strict} relation. The suffix ``S"
-at the names of some operators indicates that the bounds are strict -- e.g.,
-\<open>underS a\<close> is the set of all strict lower bounds of \<open>a\<close> (w.r.t. \<open>r\<close>).
-Capitalization of the first letter in the name reminds that the operator acts on sets, rather
-than on individual elements.\<close>
+text \<open>
+ Here we define upper (``above") and lower (``below") bounds operators. We
+ think of \<open>r\<close> as a \<^emph>\<open>non-strict\<close> relation. The suffix \<open>S\<close> at the names of
+ some operators indicates that the bounds are strict -- e.g., \<open>underS a\<close> is
+ the set of all strict lower bounds of \<open>a\<close> (w.r.t. \<open>r\<close>). Capitalization of
+ the first letter in the name reminds that the operator acts on sets, rather
+ than on individual elements.
+\<close>
-definition under::"'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
-where "under r a \<equiv> {b. (b,a) \<in> r}"
+definition under :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
+ where "under r a \<equiv> {b. (b, a) \<in> r}"
-definition underS::"'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
-where "underS r a \<equiv> {b. b \<noteq> a \<and> (b,a) \<in> r}"
+definition underS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
+ where "underS r a \<equiv> {b. b \<noteq> a \<and> (b, a) \<in> r}"
-definition Under::"'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
-where "Under r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (b,a) \<in> r}"
+definition Under :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
+ where "Under r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (b, a) \<in> r}"
-definition UnderS::"'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
-where "UnderS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (b,a) \<in> r}"
+definition UnderS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
+ where "UnderS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (b, a) \<in> r}"
-definition above::"'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
-where "above r a \<equiv> {b. (a,b) \<in> r}"
+definition above :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
+ where "above r a \<equiv> {b. (a, b) \<in> r}"
-definition aboveS::"'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
-where "aboveS r a \<equiv> {b. b \<noteq> a \<and> (a,b) \<in> r}"
+definition aboveS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set"
+ where "aboveS r a \<equiv> {b. b \<noteq> a \<and> (a, b) \<in> r}"
-definition Above::"'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
-where "Above r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (a,b) \<in> r}"
+definition Above :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
+ where "Above r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (a, b) \<in> r}"
-definition AboveS::"'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
-where "AboveS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (a,b) \<in> r}"
+definition AboveS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set"
+ where "AboveS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (a, b) \<in> r}"
definition ofilter :: "'a rel \<Rightarrow> 'a set \<Rightarrow> bool"
-where "ofilter r A \<equiv> (A \<le> Field r) \<and> (\<forall>a \<in> A. under r a \<le> A)"
+ where "ofilter r A \<equiv> A \<subseteq> Field r \<and> (\<forall>a \<in> A. under r a \<subseteq> A)"
-text\<open>Note: In the definitions of \<open>Above[S]\<close> and \<open>Under[S]\<close>,
- we bounded comprehension by \<open>Field r\<close> in order to properly cover
- the case of \<open>A\<close> being empty.\<close>
+text \<open>
+ Note: In the definitions of \<open>Above[S]\<close> and \<open>Under[S]\<close>, we bounded
+ comprehension by \<open>Field r\<close> in order to properly cover the case of \<open>A\<close> being
+ empty.
+\<close>
-lemma underS_subset_under: "underS r a \<le> under r a"
-by(auto simp add: underS_def under_def)
+lemma underS_subset_under: "underS r a \<subseteq> under r a"
+ by (auto simp add: underS_def under_def)
lemma underS_notIn: "a \<notin> underS r a"
-by(simp add: underS_def)
+ by (simp add: underS_def)
-lemma Refl_under_in: "\<lbrakk>Refl r; a \<in> Field r\<rbrakk> \<Longrightarrow> a \<in> under r a"
-by(simp add: refl_on_def under_def)
+lemma Refl_under_in: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> a \<in> under r a"
+ by (simp add: refl_on_def under_def)
-lemma AboveS_disjoint: "A Int (AboveS r A) = {}"
-by(auto simp add: AboveS_def)
+lemma AboveS_disjoint: "A \<inter> (AboveS r A) = {}"
+ by (auto simp add: AboveS_def)
lemma in_AboveS_underS: "a \<in> Field r \<Longrightarrow> a \<in> AboveS r (underS r a)"
-by(auto simp add: AboveS_def underS_def)
+ by (auto simp add: AboveS_def underS_def)
-lemma Refl_under_underS:
- assumes "Refl r" "a \<in> Field r"
- shows "under r a = underS r a \<union> {a}"
-unfolding under_def underS_def
-using assms refl_on_def[of _ r] by fastforce
+lemma Refl_under_underS: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> under r a = underS r a \<union> {a}"
+ unfolding under_def underS_def
+ using refl_on_def[of _ r] by fastforce
lemma underS_empty: "a \<notin> Field r \<Longrightarrow> underS r a = {}"
-by (auto simp: Field_def underS_def)
+ by (auto simp: Field_def underS_def)
-lemma under_Field: "under r a \<le> Field r"
-by(unfold under_def Field_def, auto)
+lemma under_Field: "under r a \<subseteq> Field r"
+ by (auto simp: under_def Field_def)
-lemma underS_Field: "underS r a \<le> Field r"
-by(unfold underS_def Field_def, auto)
+lemma underS_Field: "underS r a \<subseteq> Field r"
+ by (auto simp: underS_def Field_def)
-lemma underS_Field2:
-"a \<in> Field r \<Longrightarrow> underS r a < Field r"
-using underS_notIn underS_Field by fast
+lemma underS_Field2: "a \<in> Field r \<Longrightarrow> underS r a \<subset> Field r"
+ using underS_notIn underS_Field by fast
-lemma underS_Field3:
-"Field r \<noteq> {} \<Longrightarrow> underS r a < Field r"
-by(cases "a \<in> Field r", simp add: underS_Field2, auto simp add: underS_empty)
+lemma underS_Field3: "Field r \<noteq> {} \<Longrightarrow> underS r a \<subset> Field r"
+ by (cases "a \<in> Field r") (auto simp: underS_Field2 underS_empty)
-lemma AboveS_Field: "AboveS r A \<le> Field r"
-by(unfold AboveS_def Field_def, auto)
+lemma AboveS_Field: "AboveS r A \<subseteq> Field r"
+ by (auto simp: AboveS_def Field_def)
lemma under_incr:
- assumes TRANS: "trans r" and REL: "(a,b) \<in> r"
- shows "under r a \<le> under r b"
-proof(unfold under_def, auto)
- fix x assume "(x,a) \<in> r"
- with REL TRANS trans_def[of r]
- show "(x,b) \<in> r" by blast
+ assumes "trans r"
+ and "(a, b) \<in> r"
+ shows "under r a \<subseteq> under r b"
+ unfolding under_def
+proof auto
+ fix x assume "(x, a) \<in> r"
+ with assms trans_def[of r] show "(x, b) \<in> r" by blast
qed
lemma underS_incr:
-assumes TRANS: "trans r" and ANTISYM: "antisym r" and
- REL: "(a,b) \<in> r"
-shows "underS r a \<le> underS r b"
-proof(unfold underS_def, auto)
- assume *: "b \<noteq> a" and **: "(b,a) \<in> r"
- with ANTISYM antisym_def[of r] REL
- show False by blast
+ assumes "trans r"
+ and "antisym r"
+ and ab: "(a, b) \<in> r"
+ shows "underS r a \<subseteq> underS r b"
+ unfolding underS_def
+proof auto
+ assume *: "b \<noteq> a" and **: "(b, a) \<in> r"
+ with \<open>antisym r\<close> antisym_def[of r] ab show False
+ by blast
next
- fix x assume "x \<noteq> a" "(x,a) \<in> r"
- with REL TRANS trans_def[of r]
- show "(x,b) \<in> r" by blast
+ fix x assume "x \<noteq> a" "(x, a) \<in> r"
+ with ab \<open>trans r\<close> trans_def[of r] show "(x, b) \<in> r"
+ by blast
qed
lemma underS_incl_iff:
-assumes LO: "Linear_order r" and
- INa: "a \<in> Field r" and INb: "b \<in> Field r"
-shows "(underS r a \<le> underS r b) = ((a,b) \<in> r)"
+ assumes LO: "Linear_order r"
+ and INa: "a \<in> Field r"
+ and INb: "b \<in> Field r"
+ shows "underS r a \<subseteq> underS r b \<longleftrightarrow> (a, b) \<in> r"
+ (is "?lhs \<longleftrightarrow> ?rhs")
proof
- assume "(a,b) \<in> r"
- thus "underS r a \<le> underS r b" using LO
- by (simp add: order_on_defs underS_incr)
+ assume ?rhs
+ with \<open>Linear_order r\<close> show ?lhs
+ by (simp add: order_on_defs underS_incr)
next
- assume *: "underS r a \<le> underS r b"
- {assume "a = b"
- hence "(a,b) \<in> r" using assms
- by (simp add: order_on_defs refl_on_def)
- }
- moreover
- {assume "a \<noteq> b \<and> (b,a) \<in> r"
- hence "b \<in> underS r a" unfolding underS_def by blast
- hence "b \<in> underS r b" using * by blast
- hence False by (simp add: underS_notIn)
- }
- ultimately
- show "(a,b) \<in> r" using assms
- order_on_defs[of "Field r" r] total_on_def[of "Field r" r] by blast
+ assume *: ?lhs
+ have "(a, b) \<in> r" if "a = b"
+ using assms that by (simp add: order_on_defs refl_on_def)
+ moreover have False if "a \<noteq> b" "(b, a) \<in> r"
+ proof -
+ from that have "b \<in> underS r a" unfolding underS_def by blast
+ with * have "b \<in> underS r b" by blast
+ then show ?thesis by (simp add: underS_notIn)
+ qed
+ ultimately show "(a,b) \<in> r"
+ using assms order_on_defs[of "Field r" r] total_on_def[of "Field r" r] by blast
qed
lemma finite_Linear_order_induct[consumes 3, case_names step]:
assumes "Linear_order r"
- and "x \<in> Field r"
- and "finite r"
- and step: "\<And>x. \<lbrakk>x \<in> Field r; \<And>y. y \<in> aboveS r x \<Longrightarrow> P y\<rbrakk> \<Longrightarrow> P x"
+ and "x \<in> Field r"
+ and "finite r"
+ and step: "\<And>x. x \<in> Field r \<Longrightarrow> (\<And>y. y \<in> aboveS r x \<Longrightarrow> P y) \<Longrightarrow> P x"
shows "P x"
-using assms(2)
-proof(induct rule: wf_induct[of "r\<inverse> - Id"])
+ using assms(2)
+proof (induct rule: wf_induct[of "r\<inverse> - Id"])
+ case 1
from assms(1,3) show "wf (r\<inverse> - Id)"
using linear_order_on_well_order_on linear_order_on_converse
unfolding well_order_on_def by blast
next
- case (2 x) then show ?case
- by - (rule step; auto simp: aboveS_def intro: FieldI2)
+ case prems: (2 x)
+ show ?case
+ by (rule step) (use prems in \<open>auto simp: aboveS_def intro: FieldI2\<close>)
qed
subsection \<open>Variations on Well-Founded Relations\<close>
text \<open>
-This subsection contains some variations of the results from @{theory Wellfounded}:
-\begin{itemize}
-\item means for slightly more direct definitions by well-founded recursion;
-\item variations of well-founded induction;
-\item means for proving a linear order to be a well-order.
-\end{itemize}
+ This subsection contains some variations of the results from @{theory Wellfounded}:
+ \<^item> means for slightly more direct definitions by well-founded recursion;
+ \<^item> variations of well-founded induction;
+ \<^item> means for proving a linear order to be a well-order.
\<close>
subsubsection \<open>Characterizations of well-foundedness\<close>
-text \<open>A transitive relation is well-founded iff it is ``locally'' well-founded,
-i.e., iff its restriction to the lower bounds of of any element is well-founded.\<close>
+text \<open>
+ A transitive relation is well-founded iff it is ``locally'' well-founded,
+ i.e., iff its restriction to the lower bounds of of any element is
+ well-founded.
+\<close>
lemma trans_wf_iff:
-assumes "trans r"
-shows "wf r = (\<forall>a. wf(r Int (r^-1``{a} \<times> r^-1``{a})))"
-proof-
- obtain R where R_def: "R = (\<lambda> a. r Int (r^-1``{a} \<times> r^-1``{a}))" by blast
- {assume *: "wf r"
- {fix a
- have "wf(R a)"
- using * R_def wf_subset[of r "R a"] by auto
- }
- }
- (* *)
+ assumes "trans r"
+ shows "wf r \<longleftrightarrow> (\<forall>a. wf (r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})))"
+proof -
+ define R where "R a = r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})" for a
+ have "wf (R a)" if "wf r" for a
+ using that R_def wf_subset[of r "R a"] by auto
moreover
- {assume *: "\<forall>a. wf(R a)"
- have "wf r"
- proof(unfold wf_def, clarify)
- fix phi a
- assume **: "\<forall>a. (\<forall>b. (b,a) \<in> r \<longrightarrow> phi b) \<longrightarrow> phi a"
- obtain chi where chi_def: "chi = (\<lambda>b. (b,a) \<in> r \<longrightarrow> phi b)" by blast
- with * have "wf (R a)" by auto
- hence "(\<forall>b. (\<forall>c. (c,b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b) \<longrightarrow> (\<forall>b. chi b)"
- unfolding wf_def by blast
- moreover
- have "\<forall>b. (\<forall>c. (c,b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b"
- proof(auto simp add: chi_def R_def)
- fix b
- assume 1: "(b,a) \<in> r" and 2: "\<forall>c. (c, b) \<in> r \<and> (c, a) \<in> r \<longrightarrow> phi c"
- hence "\<forall>c. (c, b) \<in> r \<longrightarrow> phi c"
- using assms trans_def[of r] by blast
- thus "phi b" using ** by blast
- qed
- ultimately have "\<forall>b. chi b" by (rule mp)
- with ** chi_def show "phi a" by blast
- qed
- }
- ultimately show ?thesis using R_def by blast
+ have "wf r" if *: "\<forall>a. wf(R a)"
+ unfolding wf_def
+ proof clarify
+ fix phi a
+ assume **: "\<forall>a. (\<forall>b. (b, a) \<in> r \<longrightarrow> phi b) \<longrightarrow> phi a"
+ define chi where "chi b \<longleftrightarrow> (b, a) \<in> r \<longrightarrow> phi b" for b
+ with * have "wf (R a)" by auto
+ then have "(\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b) \<longrightarrow> (\<forall>b. chi b)"
+ unfolding wf_def by blast
+ also have "\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b"
+ proof (auto simp add: chi_def R_def)
+ fix b
+ assume "(b, a) \<in> r" and "\<forall>c. (c, b) \<in> r \<and> (c, a) \<in> r \<longrightarrow> phi c"
+ then have "\<forall>c. (c, b) \<in> r \<longrightarrow> phi c"
+ using assms trans_def[of r] by blast
+ with ** show "phi b" by blast
+ qed
+ finally have "\<forall>b. chi b" .
+ with ** chi_def show "phi a" by blast
+ qed
+ ultimately show ?thesis unfolding R_def by blast
qed
text \<open>The next lemma is a variation of \<open>wf_eq_minimal\<close> from Wellfounded,
-allowing one to assume the set included in the field.\<close>
+ allowing one to assume the set included in the field.\<close>
-lemma wf_eq_minimal2:
-"wf r = (\<forall>A. A <= Field r \<and> A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. \<not> (a',a) \<in> r))"
+lemma wf_eq_minimal2: "wf r \<longleftrightarrow> (\<forall>A. A \<subseteq> Field r \<and> A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a', a) \<notin> r))"
proof-
- let ?phi = "\<lambda> A. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. \<not> (a',a) \<in> r)"
- have "wf r = (\<forall>A. ?phi A)"
- by (auto simp: ex_in_conv [THEN sym], erule wfE_min, assumption, blast)
- (rule wfI_min, fast)
- (* *)
- also have "(\<forall>A. ?phi A) = (\<forall>B \<le> Field r. ?phi B)"
+ let ?phi = "\<lambda>A. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r)"
+ have "wf r \<longleftrightarrow> (\<forall>A. ?phi A)"
+ apply (auto simp: ex_in_conv [THEN sym])
+ apply (erule wfE_min)
+ apply assumption
+ apply blast
+ apply (rule wfI_min)
+ apply fast
+ done
+ also have "(\<forall>A. ?phi A) \<longleftrightarrow> (\<forall>B \<subseteq> Field r. ?phi B)"
proof
assume "\<forall>A. ?phi A"
- thus "\<forall>B \<le> Field r. ?phi B" by simp
+ then show "\<forall>B \<subseteq> Field r. ?phi B" by simp
next
- assume *: "\<forall>B \<le> Field r. ?phi B"
+ assume *: "\<forall>B \<subseteq> Field r. ?phi B"
show "\<forall>A. ?phi A"
- proof(clarify)
- fix A::"'a set" assume **: "A \<noteq> {}"
- obtain B where B_def: "B = A Int (Field r)" by blast
- show "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r"
- proof(cases "B = {}")
- assume Case1: "B = {}"
- obtain a where 1: "a \<in> A \<and> a \<notin> Field r"
- using ** Case1 unfolding B_def by blast
- hence "\<forall>a' \<in> A. (a',a) \<notin> r" using 1 unfolding Field_def by blast
- thus ?thesis using 1 by blast
+ proof clarify
+ fix A :: "'a set"
+ assume **: "A \<noteq> {}"
+ define B where "B = A \<inter> Field r"
+ show "\<exists>a \<in> A. \<forall>a' \<in> A. (a', a) \<notin> r"
+ proof (cases "B = {}")
+ case True
+ with ** obtain a where a: "a \<in> A" "a \<notin> Field r"
+ unfolding B_def by blast
+ with a have "\<forall>a' \<in> A. (a',a) \<notin> r"
+ unfolding Field_def by blast
+ with a show ?thesis by blast
next
- assume Case2: "B \<noteq> {}" have 1: "B \<le> Field r" unfolding B_def by blast
- obtain a where 2: "a \<in> B \<and> (\<forall>a' \<in> B. (a',a) \<notin> r)"
- using Case2 1 * by blast
- have "\<forall>a' \<in> A. (a',a) \<notin> r"
- proof(clarify)
- fix a' assume "a' \<in> A" and **: "(a',a) \<in> r"
- hence "a' \<in> B" unfolding B_def Field_def by blast
- thus False using 2 ** by blast
+ case False
+ have "B \<subseteq> Field r" unfolding B_def by blast
+ with False * obtain a where a: "a \<in> B" "\<forall>a' \<in> B. (a', a) \<notin> r"
+ by blast
+ have "(a', a) \<notin> r" if "a' \<in> A" for a'
+ proof
+ assume a'a: "(a', a) \<in> r"
+ with that have "a' \<in> B" unfolding B_def Field_def by blast
+ with a a'a show False by blast
qed
- thus ?thesis using 2 unfolding B_def by blast
+ with a show ?thesis unfolding B_def by blast
qed
qed
qed
@@ -441,58 +451,67 @@
subsubsection \<open>Characterizations of well-foundedness\<close>
-text \<open>The next lemma and its corollary enable one to prove that
-a linear order is a well-order in a way which is more standard than
-via well-foundedness of the strict version of the relation.\<close>
+text \<open>
+ The next lemma and its corollary enable one to prove that a linear order is
+ a well-order in a way which is more standard than via well-foundedness of
+ the strict version of the relation.
+\<close>
lemma Linear_order_wf_diff_Id:
-assumes LI: "Linear_order r"
-shows "wf(r - Id) = (\<forall>A \<le> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r))"
-proof(cases "r \<le> Id")
- assume Case1: "r \<le> Id"
- hence temp: "r - Id = {}" by blast
- hence "wf(r - Id)" by (simp add: temp)
- moreover
- {fix A assume *: "A \<le> Field r" and **: "A \<noteq> {}"
- obtain a where 1: "r = {} \<or> r = {(a,a)}" using LI
- unfolding order_on_defs using Case1 Total_subset_Id by auto
- hence "A = {a} \<and> r = {(a,a)}" using * ** unfolding Field_def by blast
- hence "\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r" using 1 by blast
- }
+ assumes "Linear_order r"
+ shows "wf (r - Id) \<longleftrightarrow> (\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r))"
+proof (cases "r \<subseteq> Id")
+ case True
+ then have *: "r - Id = {}" by blast
+ have "wf (r - Id)" by (simp add: *)
+ moreover have "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r"
+ if *: "A \<subseteq> Field r" and **: "A \<noteq> {}" for A
+ proof -
+ from \<open>Linear_order r\<close> True
+ obtain a where a: "r = {} \<or> r = {(a, a)}"
+ unfolding order_on_defs using Total_subset_Id [of r] by blast
+ with * ** have "A = {a} \<and> r = {(a, a)}"
+ unfolding Field_def by blast
+ with a show ?thesis by blast
+ qed
ultimately show ?thesis by blast
next
- assume Case2: "\<not> r \<le> Id"
- hence 1: "Field r = Field(r - Id)" using Total_Id_Field LI
- unfolding order_on_defs by blast
+ case False
+ with \<open>Linear_order r\<close> have Field: "Field r = Field (r - Id)"
+ unfolding order_on_defs using Total_Id_Field [of r] by blast
show ?thesis
proof
- assume *: "wf(r - Id)"
- show "\<forall>A \<le> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r)"
- proof(clarify)
- fix A assume **: "A \<le> Field r" and ***: "A \<noteq> {}"
- hence "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id"
- using 1 * unfolding wf_eq_minimal2 by simp
- moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. ((a,a') \<in> r) = ((a',a) \<notin> r - Id)"
- using Linear_order_in_diff_Id[of r] ** LI by blast
- ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r" by blast
+ assume *: "wf (r - Id)"
+ show "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
+ proof clarify
+ fix A
+ assume **: "A \<subseteq> Field r" and ***: "A \<noteq> {}"
+ then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id"
+ using Field * unfolding wf_eq_minimal2 by simp
+ moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id"
+ using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** by blast
+ ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r" by blast
qed
next
- assume *: "\<forall>A \<le> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r)"
- show "wf(r - Id)"
- proof(unfold wf_eq_minimal2, clarify)
- fix A assume **: "A \<le> Field(r - Id)" and ***: "A \<noteq> {}"
- hence "\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r"
- using 1 * by simp
- moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. ((a,a') \<in> r) = ((a',a) \<notin> r - Id)"
- using Linear_order_in_diff_Id[of r] ** LI mono_Field[of "r - Id" r] by blast
- ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id" by blast
+ assume *: "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
+ show "wf (r - Id)"
+ unfolding wf_eq_minimal2
+ proof clarify
+ fix A
+ assume **: "A \<subseteq> Field(r - Id)" and ***: "A \<noteq> {}"
+ then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r"
+ using Field * by simp
+ moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id"
+ using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** mono_Field[of "r - Id" r] by blast
+ ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id"
+ by blast
qed
qed
qed
corollary Linear_order_Well_order_iff:
-assumes "Linear_order r"
-shows "Well_order r = (\<forall>A \<le> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r))"
-using assms unfolding well_order_on_def using Linear_order_wf_diff_Id[of r] by blast
+ "Linear_order r \<Longrightarrow>
+ Well_order r \<longleftrightarrow> (\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r))"
+ unfolding well_order_on_def using Linear_order_wf_diff_Id[of r] by blast
end
--- a/src/HOL/Wellfounded.thy Sun Jul 31 19:09:21 2016 +0200
+++ b/src/HOL/Wellfounded.thy Sun Jul 31 22:56:18 2016 +0200
@@ -9,7 +9,7 @@
section \<open>Well-founded Recursion\<close>
theory Wellfounded
-imports Transitive_Closure
+ imports Transitive_Closure
begin
subsection \<open>Basic Definitions\<close>
@@ -59,12 +59,14 @@
lemma wf_not_refl [simp]: "wf r \<Longrightarrow> (a, a) \<notin> r"
by (blast elim: wf_asym)
-lemma wf_irrefl: assumes "wf r" obtains "(a, a) \<notin> r"
+lemma wf_irrefl:
+ assumes "wf r"
+ obtains "(a, a) \<notin> r"
by (drule wf_not_refl[OF assms])
lemma wf_wellorderI:
assumes wf: "wf {(x::'a::ord, y). x < y}"
- assumes lin: "OFCLASS('a::ord, linorder_class)"
+ and lin: "OFCLASS('a::ord, linorder_class)"
shows "OFCLASS('a::ord, wellorder_class)"
using lin
apply (rule wellorder_class.intro)
@@ -83,7 +85,7 @@
lemma wfE_pf:
assumes wf: "wf R"
- assumes a: "A \<subseteq> R `` A"
+ and a: "A \<subseteq> R `` A"
shows "A = {}"
proof -
from wf have "x \<notin> A" for x
@@ -130,10 +132,13 @@
qed
lemma wf_eq_minimal: "wf r \<longleftrightarrow> (\<forall>Q x. x \<in> Q \<longrightarrow> (\<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q))"
-apply auto
-apply (erule wfE_min, assumption, blast)
-apply (rule wfI_min, auto)
-done
+ apply auto
+ apply (erule wfE_min)
+ apply assumption
+ apply blast
+ apply (rule wfI_min)
+ apply auto
+ done
lemmas wfP_eq_minimal = wf_eq_minimal [to_pred]
@@ -200,18 +205,13 @@
then show ?thesis by (simp add: bot_fun_def)
qed
-lemma wf_Int1: "wf r \<Longrightarrow> wf (r Int r')"
- apply (erule wf_subset)
- apply (rule Int_lower1)
- done
+lemma wf_Int1: "wf r \<Longrightarrow> wf (r \<inter> r')"
+ by (erule wf_subset) (rule Int_lower1)
-lemma wf_Int2: "wf r \<Longrightarrow> wf (r' Int r)"
- apply (erule wf_subset)
- apply (rule Int_lower2)
- done
+lemma wf_Int2: "wf r \<Longrightarrow> wf (r' \<inter> r)"
+ by (erule wf_subset) (rule Int_lower2)
-text \<open>Exponentiation\<close>
-
+text \<open>Exponentiation.\<close>
lemma wf_exp:
assumes "wf (R ^^ n)"
shows "wf R"
@@ -222,38 +222,43 @@
show "A = {}" by (rule wfE_pf)
qed
-text \<open>Well-foundedness of insert\<close>
-
+text \<open>Well-foundedness of \<open>insert\<close>.\<close>
lemma wf_insert [iff]: "wf (insert (y, x) r) \<longleftrightarrow> wf r \<and> (x, y) \<notin> r\<^sup>*"
-apply (rule iffI)
- apply (blast elim: wf_trancl [THEN wf_irrefl]
- intro: rtrancl_into_trancl1 wf_subset
- rtrancl_mono [THEN [2] rev_subsetD])
-apply (simp add: wf_eq_minimal, safe)
-apply (rule allE, assumption, erule impE, blast)
-apply (erule bexE)
-apply (rename_tac "a", case_tac "a = x")
- prefer 2
-apply blast
-apply (case_tac "y \<in> Q")
- prefer 2 apply blast
-apply (rule_tac x = "{z. z \<in> Q \<and> (z,y) \<in> r\<^sup>*}" in allE)
- apply assumption
-apply (erule_tac V = "\<forall>Q. (\<exists>x. x \<in> Q) \<longrightarrow> P Q" for P in thin_rl)
+ apply (rule iffI)
+ apply (blast elim: wf_trancl [THEN wf_irrefl]
+ intro: rtrancl_into_trancl1 wf_subset rtrancl_mono [THEN [2] rev_subsetD])
+ apply (simp add: wf_eq_minimal)
+ apply safe
+ apply (rule allE)
+ apply assumption
+ apply (erule impE)
+ apply blast
+ apply (erule bexE)
+ apply (rename_tac a, case_tac "a = x")
+ prefer 2
+ apply blast
+ apply (case_tac "y \<in> Q")
+ prefer 2
+ apply blast
+ apply (rule_tac x = "{z. z \<in> Q \<and> (z,y) \<in> r\<^sup>*}" in allE)
+ apply assumption
+ apply (erule_tac V = "\<forall>Q. (\<exists>x. x \<in> Q) \<longrightarrow> P Q" for P in thin_rl)
(*essential for speed*)
-(*blast with new substOccur fails*)
-apply (fast intro: converse_rtrancl_into_rtrancl)
-done
+ (*blast with new substOccur fails*)
+ apply (fast intro: converse_rtrancl_into_rtrancl)
+ done
subsubsection \<open>Well-foundedness of image\<close>
lemma wf_map_prod_image: "wf r \<Longrightarrow> inj f \<Longrightarrow> wf (map_prod f f ` r)"
-apply (simp only: wf_eq_minimal, clarify)
-apply (case_tac "\<exists>p. f p \<in> Q")
-apply (erule_tac x = "{p. f p \<in> Q}" in allE)
-apply (fast dest: inj_onD, blast)
-done
+ apply (simp only: wf_eq_minimal)
+ apply clarify
+ apply (case_tac "\<exists>p. f p \<in> Q")
+ apply (erule_tac x = "{p. f p \<in> Q}" in allE)
+ apply (fast dest: inj_onD)
+apply blast
+ done
subsection \<open>Well-Foundedness Results for Unions\<close>
@@ -270,24 +275,21 @@
by (rule wfE_min [OF \<open>wf R\<close> \<open>x \<in> Q\<close>]) blast
with \<open>wf S\<close> obtain z where "z \<in> ?Q'" and zmin: "\<And>y. (y, z) \<in> S \<Longrightarrow> y \<notin> ?Q'"
by (erule wfE_min)
- {
- fix y assume "(y, z) \<in> S"
- then have "y \<notin> ?Q'" by (rule zmin)
- have "y \<notin> Q"
- proof
- assume "y \<in> Q"
- with \<open>y \<notin> ?Q'\<close> obtain w where "(w, y) \<in> R" and "w \<in> Q" by auto
- from \<open>(w, y) \<in> R\<close> \<open>(y, z) \<in> S\<close> have "(w, z) \<in> R O S" by (rule relcompI)
- with \<open>R O S \<subseteq> R\<close> have "(w, z) \<in> R" ..
- with \<open>z \<in> ?Q'\<close> have "w \<notin> Q" by blast
- with \<open>w \<in> Q\<close> show False by contradiction
- qed
- }
+ have "y \<notin> Q" if "(y, z) \<in> S" for y
+ proof
+ from that have "y \<notin> ?Q'" by (rule zmin)
+ assume "y \<in> Q"
+ with \<open>y \<notin> ?Q'\<close> obtain w where "(w, y) \<in> R" and "w \<in> Q" by auto
+ from \<open>(w, y) \<in> R\<close> \<open>(y, z) \<in> S\<close> have "(w, z) \<in> R O S" by (rule relcompI)
+ with \<open>R O S \<subseteq> R\<close> have "(w, z) \<in> R" ..
+ with \<open>z \<in> ?Q'\<close> have "w \<notin> Q" by blast
+ with \<open>w \<in> Q\<close> show False by contradiction
+ qed
with \<open>z \<in> ?Q'\<close> show "\<exists>z\<in>Q. \<forall>y. (y, z) \<in> R \<union> S \<longrightarrow> y \<notin> Q" by blast
qed
-text \<open>Well-foundedness of indexed union with disjoint domains and ranges\<close>
+text \<open>Well-foundedness of indexed union with disjoint domains and ranges.\<close>
lemma wf_UN:
assumes "\<forall>i\<in>I. wf (r i)"
@@ -306,10 +308,9 @@
done
lemma wfP_SUP:
- "\<forall>i. wfP (r i) \<Longrightarrow> \<forall>i j. r i \<noteq> r j \<longrightarrow> inf (DomainP (r i)) (RangeP (r j)) = bot \<Longrightarrow> wfP (SUPREMUM UNIV r)"
- apply (rule wf_UN[to_pred])
- apply simp_all
- done
+ "\<forall>i. wfP (r i) \<Longrightarrow> \<forall>i j. r i \<noteq> r j \<longrightarrow> inf (DomainP (r i)) (RangeP (r j)) = bot \<Longrightarrow>
+ wfP (SUPREMUM UNIV r)"
+ by (rule wf_UN[to_pred]) simp_all
lemma wf_Union:
assumes "\<forall>r\<in>R. wf r"
@@ -458,9 +459,7 @@
subsection \<open>Acyclic relations\<close>
lemma wf_acyclic: "wf r \<Longrightarrow> acyclic r"
-apply (simp add: acyclic_def)
-apply (blast elim: wf_trancl [THEN wf_irrefl])
-done
+ by (simp add: acyclic_def) (blast elim: wf_trancl [THEN wf_irrefl])
lemmas wfP_acyclicP = wf_acyclic [to_pred]
@@ -468,15 +467,15 @@
subsubsection \<open>Wellfoundedness of finite acyclic relations\<close>
lemma finite_acyclic_wf [rule_format]: "finite r \<Longrightarrow> acyclic r \<longrightarrow> wf r"
-apply (erule finite_induct, blast)
-apply (simp only: split_tupled_all)
-apply simp
-done
+ apply (erule finite_induct)
+ apply blast
+ apply (simp add: split_tupled_all)
+ done
lemma finite_acyclic_wf_converse: "finite r \<Longrightarrow> acyclic r \<Longrightarrow> wf (r\<inverse>)"
-apply (erule finite_converse [THEN iffD2, THEN finite_acyclic_wf])
-apply (erule acyclic_converse [THEN iffD2])
-done
+ apply (erule finite_converse [THEN iffD2, THEN finite_acyclic_wf])
+ apply (erule acyclic_converse [THEN iffD2])
+ done
text \<open>
Observe that the converse of an irreflexive, transitive,
@@ -488,12 +487,14 @@
shows "wf (r\<inverse>)"
proof -
have "acyclic r"
- using \<open>irrefl r\<close> and \<open>trans r\<close> by (simp add: irrefl_def acyclic_irrefl)
- with \<open>finite r\<close> show ?thesis by (rule finite_acyclic_wf_converse)
+ using \<open>irrefl r\<close> and \<open>trans r\<close>
+ by (simp add: irrefl_def acyclic_irrefl)
+ with \<open>finite r\<close> show ?thesis
+ by (rule finite_acyclic_wf_converse)
qed
lemma wf_iff_acyclic_if_finite: "finite r \<Longrightarrow> wf r = acyclic r"
-by (blast intro: finite_acyclic_wf wf_acyclic)
+ by (blast intro: finite_acyclic_wf wf_acyclic)
subsection \<open>@{typ nat} is well-founded\<close>
@@ -528,8 +529,10 @@
unfolding less_eq rtrancl_eq_or_trancl by auto
lemma wf_pred_nat: "wf pred_nat"
- apply (unfold wf_def pred_nat_def, clarify)
- apply (induct_tac x, blast+)
+ apply (unfold wf_def pred_nat_def)
+ apply clarify
+ apply (induct_tac x)
+ apply blast+
done
lemma wf_less_than [iff]: "wf less_than"
@@ -583,15 +586,13 @@
lemmas accp_induct_rule = accp_induct [rule_format, induct set: accp]
theorem accp_downward: "accp r b \<Longrightarrow> r a b \<Longrightarrow> accp r a"
- apply (erule accp.cases)
- apply fast
- done
+ by (cases rule: accp.cases)
lemma not_accp_down:
assumes na: "\<not> accp R x"
obtains z where "R z x" and "\<not> accp R z"
proof -
- assume a: "\<And>z. \<lbrakk>R z x; \<not> accp R z\<rbrakk> \<Longrightarrow> thesis"
+ assume a: "\<And>z. R z x \<Longrightarrow> \<not> accp R z \<Longrightarrow> thesis"
show thesis
proof (cases "\<forall>z. R z x \<longrightarrow> accp R z")
case True
@@ -612,12 +613,11 @@
done
theorem accp_downwards: "accp r a \<Longrightarrow> r\<^sup>*\<^sup>* b a \<Longrightarrow> accp r b"
- apply (blast dest: accp_downwards_aux)
- done
+ by (blast dest: accp_downwards_aux)
theorem accp_wfPI: "\<forall>x. accp r x \<Longrightarrow> wfP r"
apply (rule wfPUNIVI)
- apply (rule_tac P=P in accp_induct)
+ apply (rule_tac P = P in accp_induct)
apply blast
apply blast
done
@@ -629,22 +629,22 @@
done
theorem wfP_accp_iff: "wfP r = (\<forall>x. accp r x)"
- apply (blast intro: accp_wfPI dest: accp_wfPD)
- done
+ by (blast intro: accp_wfPI dest: accp_wfPD)
text \<open>Smaller relations have bigger accessible parts:\<close>
lemma accp_subset:
- assumes sub: "R1 \<le> R2"
+ assumes "R1 \<le> R2"
shows "accp R2 \<le> accp R1"
proof (rule predicate1I)
- fix x assume "accp R2 x"
+ fix x
+ assume "accp R2 x"
then show "accp R1 x"
proof (induct x)
fix x
- assume ih: "\<And>y. R2 y x \<Longrightarrow> accp R1 y"
- with sub show "accp R1 x"
+ assume "\<And>y. R2 y x \<Longrightarrow> accp R1 y"
+ with assms show "accp R1 x"
by (blast intro: accp.accI)
qed
qed
@@ -655,9 +655,9 @@
lemma accp_subset_induct:
assumes subset: "D \<le> accp R"
- and dcl: "\<And>x z. \<lbrakk>D x; R z x\<rbrakk> \<Longrightarrow> D z"
+ and dcl: "\<And>x z. D x \<Longrightarrow> R z x \<Longrightarrow> D z"
and "D x"
- and istep: "\<And>x. \<lbrakk>D x; (\<And>z. R z x \<Longrightarrow> P z)\<rbrakk> \<Longrightarrow> P x"
+ and istep: "\<And>x. D x \<Longrightarrow> (\<And>z. R z x \<Longrightarrow> P z) \<Longrightarrow> P x"
shows "P x"
proof -
from subset and \<open>D x\<close>
@@ -665,8 +665,7 @@
then show "P x" using \<open>D x\<close>
proof (induct x)
fix x
- assume "D x"
- and "\<And>y. R y x \<Longrightarrow> D y \<Longrightarrow> P y"
+ assume "D x" and "\<And>y. R y x \<Longrightarrow> D y \<Longrightarrow> P y"
with dcl and istep show "P x" by blast
qed
qed
@@ -691,15 +690,17 @@
text \<open>Inverse Image\<close>
-lemma wf_inv_image [simp,intro!]: "wf r \<Longrightarrow> wf (inv_image r f)" for f :: "'a \<Rightarrow> 'b"
-apply (simp add: inv_image_def wf_eq_minimal)
-apply clarify
-apply (subgoal_tac "\<exists>w::'b. w \<in> {w. \<exists>x::'a. x \<in> Q \<and> f x = w}")
-prefer 2 apply (blast del: allE)
-apply (erule allE)
-apply (erule (1) notE impE)
-apply blast
-done
+lemma wf_inv_image [simp,intro!]: "wf r \<Longrightarrow> wf (inv_image r f)"
+ for f :: "'a \<Rightarrow> 'b"
+ apply (simp add: inv_image_def wf_eq_minimal)
+ apply clarify
+ apply (subgoal_tac "\<exists>w::'b. w \<in> {w. \<exists>x::'a. x \<in> Q \<and> f x = w}")
+ prefer 2
+ apply (blast del: allE)
+ apply (erule allE)
+ apply (erule (1) notE impE)
+ apply blast
+ done
text \<open>Measure functions into @{typ nat}\<close>
@@ -710,17 +711,15 @@
by (simp add:measure_def)
lemma wf_measure [iff]: "wf (measure f)"
-apply (unfold measure_def)
-apply (rule wf_less_than [THEN wf_inv_image])
-done
+ unfolding measure_def by (rule wf_less_than [THEN wf_inv_image])
lemma wf_if_measure: "(\<And>x. P x \<Longrightarrow> f(g x) < f x) \<Longrightarrow> wf {(y,x). P x \<and> y = g x}"
for f :: "'a \<Rightarrow> nat"
-apply(insert wf_measure[of f])
-apply(simp only: measure_def inv_image_def less_than_def less_eq)
-apply(erule wf_subset)
-apply auto
-done
+ apply (insert wf_measure[of f])
+ apply (simp only: measure_def inv_image_def less_than_def less_eq)
+ apply (erule wf_subset)
+ apply auto
+ done
subsubsection \<open>Lexicographic combinations\<close>
@@ -730,13 +729,18 @@
where "ra <*lex*> rb = {((a, b), (a', b')). (a, a') \<in> ra \<or> a = a' \<and> (b, b') \<in> rb}"
lemma wf_lex_prod [intro!]: "wf ra \<Longrightarrow> wf rb \<Longrightarrow> wf (ra <*lex*> rb)"
-apply (unfold wf_def lex_prod_def)
-apply (rule allI, rule impI)
-apply (simp only: split_paired_All)
-apply (drule spec, erule mp)
-apply (rule allI, rule impI)
-apply (drule spec, erule mp, blast)
-done
+ apply (unfold wf_def lex_prod_def)
+ apply (rule allI)
+ apply (rule impI)
+ apply (simp only: split_paired_All)
+ apply (drule spec)
+ apply (erule mp)
+ apply (rule allI)
+ apply (rule impI)
+ apply (drule spec)
+ apply (erule mp)
+ apply blast
+ done
lemma in_lex_prod[simp]: "((a, b), (a', b')) \<in> r <*lex*> s \<longleftrightarrow> (a, a') \<in> r \<or> a = a' \<and> (b, b') \<in> s"
by (auto simp:lex_prod_def)
@@ -752,19 +756,17 @@
where "f <*mlex*> R = inv_image (less_than <*lex*> R) (\<lambda>x. (f x, x))"
lemma wf_mlex: "wf R \<Longrightarrow> wf (f <*mlex*> R)"
- unfolding mlex_prod_def
- by auto
+ by (auto simp: mlex_prod_def)
lemma mlex_less: "f x < f y \<Longrightarrow> (x, y) \<in> f <*mlex*> R"
- unfolding mlex_prod_def by simp
+ by (simp add: mlex_prod_def)
lemma mlex_leq: "f x \<le> f y \<Longrightarrow> (x, y) \<in> R \<Longrightarrow> (x, y) \<in> f <*mlex*> R"
- unfolding mlex_prod_def by auto
+ by (auto simp: mlex_prod_def)
-text \<open>proper subset relation on finite sets\<close>
-
+text \<open>Proper subset relation on finite sets.\<close>
definition finite_psubset :: "('a set \<times> 'a set) set"
- where "finite_psubset = {(A,B). A < B \<and> finite B}"
+ where "finite_psubset = {(A, B). A \<subset> B \<and> finite B}"
lemma wf_finite_psubset[simp]: "wf finite_psubset"
apply (unfold finite_psubset_def)
@@ -776,15 +778,15 @@
lemma trans_finite_psubset: "trans finite_psubset"
by (auto simp add: finite_psubset_def less_le trans_def)
-lemma in_finite_psubset[simp]: "(A, B) \<in> finite_psubset \<longleftrightarrow> A < B \<and> finite B"
+lemma in_finite_psubset[simp]: "(A, B) \<in> finite_psubset \<longleftrightarrow> A \<subset> B \<and> finite B"
unfolding finite_psubset_def by auto
text \<open>max- and min-extension of order to finite sets\<close>
inductive_set max_ext :: "('a \<times> 'a) set \<Rightarrow> ('a set \<times> 'a set) set"
for R :: "('a \<times> 'a) set"
-where
- max_extI[intro]: "finite X \<Longrightarrow> finite Y \<Longrightarrow> Y \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> \<exists>y\<in>Y. (x, y) \<in> R) \<Longrightarrow> (X, Y) \<in> max_ext R"
+ where max_extI[intro]:
+ "finite X \<Longrightarrow> finite Y \<Longrightarrow> Y \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> \<exists>y\<in>Y. (x, y) \<in> R) \<Longrightarrow> (X, Y) \<in> max_ext R"
lemma max_ext_wf:
assumes wf: "wf r"
@@ -792,23 +794,24 @@
proof (rule acc_wfI, intro allI)
fix M
show "M \<in> acc (max_ext r)" (is "_ \<in> ?W")
- proof cases
- assume "finite M"
+ proof (cases "finite M")
+ case True
then show ?thesis
proof (induct M)
- show "{} \<in> ?W"
+ case empty
+ show ?case
by (rule accI) (auto elim: max_ext.cases)
next
- fix M a assume "M \<in> ?W" "finite M"
- with wf show "insert a M \<in> ?W"
+ case (insert a M)
+ from wf \<open>M \<in> ?W\<close> \<open>finite M\<close> show "insert a M \<in> ?W"
proof (induct arbitrary: M)
fix M a
- assume "M \<in> ?W" and [intro]: "finite M"
+ assume "M \<in> ?W"
+ assume [intro]: "finite M"
assume hyp: "\<And>b M. (b, a) \<in> r \<Longrightarrow> M \<in> ?W \<Longrightarrow> finite M \<Longrightarrow> insert b M \<in> ?W"
- have add_less: "\<lbrakk>M \<in> ?W ; (\<And>y. y \<in> N \<Longrightarrow> (y, a) \<in> r)\<rbrakk> \<Longrightarrow> N \<union> M \<in> ?W"
+ have add_less: "M \<in> ?W \<Longrightarrow> (\<And>y. y \<in> N \<Longrightarrow> (y, a) \<in> r) \<Longrightarrow> N \<union> M \<in> ?W"
if "finite N" "finite M" for N M :: "'a set"
using that by (induct N arbitrary: M) (auto simp: hyp)
-
show "insert a M \<in> ?W"
proof (rule accI)
fix N
@@ -823,14 +826,13 @@
then have finites: "finite ?N1" "finite ?N2" by auto
have "?N2 \<in> ?W"
- proof cases
- assume [simp]: "M = {}"
+ proof (cases "M = {}")
+ case [simp]: True
have Mw: "{} \<in> ?W" by (rule accI) (auto elim: max_ext.cases)
-
from * have "?N2 = {}" by auto
with Mw show "?N2 \<in> ?W" by (simp only:)
next
- assume "M \<noteq> {}"
+ case False
from * finites have N2: "(?N2, M) \<in> max_ext r"
by (rule_tac max_extI[OF _ _ \<open>M \<noteq> {}\<close>]) auto
with \<open>M \<in> ?W\<close> show "?N2 \<in> ?W" by (rule acc_downward)
@@ -842,15 +844,13 @@
qed
qed
next
- assume [simp]: "\<not> finite M"
+ case [simp]: False
show ?thesis
by (rule accI) (auto elim: max_ext.cases)
qed
qed
-lemma max_ext_additive:
- "(A, B) \<in> max_ext R \<Longrightarrow> (C, D) \<in> max_ext R \<Longrightarrow>
- (A \<union> C, B \<union> D) \<in> max_ext R"
+lemma max_ext_additive: "(A, B) \<in> max_ext R \<Longrightarrow> (C, D) \<in> max_ext R \<Longrightarrow> (A \<union> C, B \<union> D) \<in> max_ext R"
by (force elim!: max_ext.cases)
@@ -874,13 +874,13 @@
obtain z where z: "z \<in> \<Union>Q" "\<And>y. (y, z) \<in> r \<Longrightarrow> y \<notin> \<Union>Q"
by (erule wfE_min)
from z obtain m where "m \<in> Q" "z \<in> m" by auto
- from \<open>m \<in> Q\<close>
- show ?thesis
- proof (rule, intro bexI allI impI)
+ from \<open>m \<in> Q\<close> show ?thesis
+ proof (intro rev_bexI allI impI)
fix n
assume smaller: "(n, m) \<in> min_ext r"
- with \<open>z \<in> m\<close> obtain y where y: "y \<in> n" "(y, z) \<in> r" by (auto simp: min_ext_def)
- then show "n \<notin> Q" using z(2) by auto
+ with \<open>z \<in> m\<close> obtain y where "y \<in> n" "(y, z) \<in> r"
+ by (auto simp: min_ext_def)
+ with z(2) show "n \<notin> Q" by auto
qed
qed
qed
@@ -893,32 +893,33 @@
and f :: "'a \<Rightarrow> nat"
assumes "\<And>a b. (b, a) \<in> r \<Longrightarrow> ub b \<le> ub a \<and> ub a \<ge> f b \<and> f b > f a"
shows "wf r"
- apply (rule wf_subset[OF wf_measure[of "\<lambda>a. ub a - f a"]])
- apply (auto dest: assms)
- done
+ by (rule wf_subset[OF wf_measure[of "\<lambda>a. ub a - f a"]]) (auto dest: assms)
lemma wf_bounded_set:
fixes ub :: "'a \<Rightarrow> 'b set"
and f :: "'a \<Rightarrow> 'b set"
assumes "\<And>a b. (b,a) \<in> r \<Longrightarrow> finite (ub a) \<and> ub b \<subseteq> ub a \<and> ub a \<supseteq> f b \<and> f b \<supset> f a"
shows "wf r"
- apply(rule wf_bounded_measure[of r "\<lambda>a. card(ub a)" "\<lambda>a. card(f a)"])
- apply(drule assms)
+ apply (rule wf_bounded_measure[of r "\<lambda>a. card (ub a)" "\<lambda>a. card (f a)"])
+ apply (drule assms)
apply (blast intro: card_mono finite_subset psubset_card_mono dest: psubset_eq[THEN iffD2])
done
lemma finite_subset_wf:
assumes "finite A"
- shows "wf {(X,Y). X \<subset> Y \<and> Y \<subseteq> A}"
+ shows "wf {(X,Y). X \<subset> Y \<and> Y \<subseteq> A}"
proof (intro finite_acyclic_wf)
- have "{(X,Y). X \<subset> Y \<and> Y \<subseteq> A} \<subseteq> Pow A \<times> Pow A" by blast
+ have "{(X,Y). X \<subset> Y \<and> Y \<subseteq> A} \<subseteq> Pow A \<times> Pow A"
+ by blast
then show "finite {(X,Y). X \<subset> Y \<and> Y \<subseteq> A}"
by (rule finite_subset) (auto simp: assms finite_cartesian_product)
next
have "{(X, Y). X \<subset> Y \<and> Y \<subseteq> A}\<^sup>+ = {(X, Y). X \<subset> Y \<and> Y \<subseteq> A}"
by (intro trancl_id transI) blast
- also have " \<forall>x. (x, x) \<notin> \<dots>" by blast
- finally show "acyclic {(X,Y). X \<subset> Y \<and> Y \<subseteq> A}" by (rule acyclicI)
+ also have " \<forall>x. (x, x) \<notin> \<dots>"
+ by blast
+ finally show "acyclic {(X,Y). X \<subset> Y \<and> Y \<subseteq> A}"
+ by (rule acyclicI)
qed
hide_const (open) acc accp
--- a/src/HOL/Wfrec.thy Sun Jul 31 19:09:21 2016 +0200
+++ b/src/HOL/Wfrec.thy Sun Jul 31 22:56:18 2016 +0200
@@ -7,20 +7,20 @@
section \<open>Well-Founded Recursion Combinator\<close>
theory Wfrec
-imports Wellfounded
+ imports Wellfounded
begin
-inductive wfrec_rel :: "('a \<times> 'a) set \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" for R F where
- wfrecI: "(\<And>z. (z, x) \<in> R \<Longrightarrow> wfrec_rel R F z (g z)) \<Longrightarrow> wfrec_rel R F x (F g x)"
+inductive wfrec_rel :: "('a \<times> 'a) set \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" for R F
+ where wfrecI: "(\<And>z. (z, x) \<in> R \<Longrightarrow> wfrec_rel R F z (g z)) \<Longrightarrow> wfrec_rel R F x (F g x)"
-definition cut :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b" where
- "cut f R x = (\<lambda>y. if (y, x) \<in> R then f y else undefined)"
+definition cut :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b"
+ where "cut f R x = (\<lambda>y. if (y, x) \<in> R then f y else undefined)"
-definition adm_wf :: "('a \<times> 'a) set \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)) \<Rightarrow> bool" where
- "adm_wf R F \<longleftrightarrow> (\<forall>f g x. (\<forall>z. (z, x) \<in> R \<longrightarrow> f z = g z) \<longrightarrow> F f x = F g x)"
+definition adm_wf :: "('a \<times> 'a) set \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)) \<Rightarrow> bool"
+ where "adm_wf R F \<longleftrightarrow> (\<forall>f g x. (\<forall>z. (z, x) \<in> R \<longrightarrow> f z = g z) \<longrightarrow> F f x = F g x)"
-definition wfrec :: "('a \<times> 'a) set \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)) \<Rightarrow> ('a \<Rightarrow> 'b)" where
- "wfrec R F = (\<lambda>x. THE y. wfrec_rel R (\<lambda>f x. F (cut f R x) x) x y)"
+definition wfrec :: "('a \<times> 'a) set \<Rightarrow> (('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)) \<Rightarrow> ('a \<Rightarrow> 'b)"
+ where "wfrec R F = (\<lambda>x. THE y. wfrec_rel R (\<lambda>f x. F (cut f R x) x) x y)"
lemma cuts_eq: "(cut f R x = cut g R x) \<longleftrightarrow> (\<forall>y. (y, x) \<in> R \<longrightarrow> f y = g y)"
by (simp add: fun_eq_iff cut_def)
@@ -28,13 +28,17 @@
lemma cut_apply: "(x, a) \<in> R \<Longrightarrow> cut f R a x = f x"
by (simp add: cut_def)
-text\<open>Inductive characterization of wfrec combinator; for details see:
-John Harrison, "Inductive definitions: automation and application"\<close>
+text \<open>
+ Inductive characterization of \<open>wfrec\<close> combinator; for details see:
+ John Harrison, "Inductive definitions: automation and application".
+\<close>
lemma theI_unique: "\<exists>!x. P x \<Longrightarrow> P x \<longleftrightarrow> x = The P"
by (auto intro: the_equality[symmetric] theI)
-lemma wfrec_unique: assumes "adm_wf R F" "wf R" shows "\<exists>!y. wfrec_rel R F x y"
+lemma wfrec_unique:
+ assumes "adm_wf R F" "wf R"
+ shows "\<exists>!y. wfrec_rel R F x y"
using \<open>wf R\<close>
proof induct
define f where "f y = (THE z. wfrec_rel R F y z)" for y
@@ -46,44 +50,46 @@
qed
lemma adm_lemma: "adm_wf R (\<lambda>f x. F (cut f R x) x)"
- by (auto simp add: adm_wf_def
- intro!: arg_cong[where f="\<lambda>x. F x y" for y] cuts_eq[THEN iffD2])
+ by (auto simp: adm_wf_def intro!: arg_cong[where f="\<lambda>x. F x y" for y] cuts_eq[THEN iffD2])
lemma wfrec: "wf R \<Longrightarrow> wfrec R F a = F (cut (wfrec R F) R a) a"
-apply (simp add: wfrec_def)
-apply (rule adm_lemma [THEN wfrec_unique, THEN the1_equality], assumption)
-apply (rule wfrec_rel.wfrecI)
-apply (erule adm_lemma [THEN wfrec_unique, THEN theI'])
-done
+ apply (simp add: wfrec_def)
+ apply (rule adm_lemma [THEN wfrec_unique, THEN the1_equality])
+ apply assumption
+ apply (rule wfrec_rel.wfrecI)
+ apply (erule adm_lemma [THEN wfrec_unique, THEN theI'])
+ done
-text\<open>* This form avoids giant explosions in proofs. NOTE USE OF ==\<close>
+text \<open>This form avoids giant explosions in proofs. NOTE USE OF \<open>\<equiv>\<close>.\<close>
lemma def_wfrec: "f \<equiv> wfrec R F \<Longrightarrow> wf R \<Longrightarrow> f a = F (cut f R a) a"
- by (auto intro: wfrec)
+ by (auto intro: wfrec)
subsubsection \<open>Well-founded recursion via genuine fixpoints\<close>
lemma wfrec_fixpoint:
- assumes WF: "wf R" and ADM: "adm_wf R F"
+ assumes wf: "wf R"
+ and adm: "adm_wf R F"
shows "wfrec R F = F (wfrec R F)"
proof (rule ext)
fix x
have "wfrec R F x = F (cut (wfrec R F) R x) x"
- using wfrec[of R F] WF by simp
+ using wfrec[of R F] wf by simp
also
- { have "\<And> y. (y,x) \<in> R \<Longrightarrow> (cut (wfrec R F) R x) y = (wfrec R F) y"
- by (auto simp add: cut_apply)
- hence "F (cut (wfrec R F) R x) x = F (wfrec R F) x"
- using ADM adm_wf_def[of R F] by auto }
+ have "\<And>y. (y, x) \<in> R \<Longrightarrow> cut (wfrec R F) R x y = wfrec R F y"
+ by (auto simp add: cut_apply)
+ then have "F (cut (wfrec R F) R x) x = F (wfrec R F) x"
+ using adm adm_wf_def[of R F] by auto
finally show "wfrec R F x = F (wfrec R F) x" .
qed
+
subsection \<open>Wellfoundedness of \<open>same_fst\<close>\<close>
-definition same_fst :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> ('b \<times> 'b) set) \<Rightarrow> (('a \<times> 'b) \<times> ('a \<times> 'b)) set" where
- "same_fst P R = {((x', y'), (x, y)) . x' = x \<and> P x \<and> (y',y) \<in> R x}"
- \<comment>\<open>For @{const wfrec} declarations where the first n parameters
+definition same_fst :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> ('b \<times> 'b) set) \<Rightarrow> (('a \<times> 'b) \<times> ('a \<times> 'b)) set"
+ where "same_fst P R = {((x', y'), (x, y)) . x' = x \<and> P x \<and> (y',y) \<in> R x}"
+ \<comment> \<open>For @{const wfrec} declarations where the first n parameters
stay unchanged in the recursive call.\<close>
lemma same_fstI [intro!]: "P x \<Longrightarrow> (y', y) \<in> R x \<Longrightarrow> ((x, y'), (x, y)) \<in> same_fst P R"
@@ -92,12 +98,13 @@
lemma wf_same_fst:
assumes prem: "\<And>x. P x \<Longrightarrow> wf (R x)"
shows "wf (same_fst P R)"
-apply (simp cong del: imp_cong add: wf_def same_fst_def)
-apply (intro strip)
-apply (rename_tac a b)
-apply (case_tac "wf (R a)")
- apply (erule_tac a = b in wf_induct, blast)
-apply (blast intro: prem)
-done
+ apply (simp cong del: imp_cong add: wf_def same_fst_def)
+ apply (intro strip)
+ apply (rename_tac a b)
+ apply (case_tac "wf (R a)")
+ apply (erule_tac a = b in wf_induct)
+ apply blast
+ apply (blast intro: prem)
+ done
end
--- a/src/HOL/Zorn.thy Sun Jul 31 19:09:21 2016 +0200
+++ b/src/HOL/Zorn.thy Sun Jul 31 22:56:18 2016 +0200
@@ -1,7 +1,7 @@
-(* Title: HOL/Zorn.thy
- Author: Jacques D. Fleuriot
- Author: Tobias Nipkow, TUM
- Author: Christian Sternagel, JAIST
+(* Title: HOL/Zorn.thy
+ Author: Jacques D. Fleuriot
+ Author: Tobias Nipkow, TUM
+ Author: Christian Sternagel, JAIST
Zorn's Lemma (ported from Larry Paulson's Zorn.thy in ZF).
The well-ordering theorem.
@@ -10,7 +10,7 @@
section \<open>Zorn's Lemma\<close>
theory Zorn
-imports Order_Relation Hilbert_Choice
+ imports Order_Relation Hilbert_Choice
begin
subsection \<open>Zorn's Lemma for the Subset Relation\<close>
@@ -20,36 +20,38 @@
text \<open>Let \<open>P\<close> be a binary predicate on the set \<open>A\<close>.\<close>
locale pred_on =
fixes A :: "'a set"
- and P :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubset>" 50)
+ and P :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubset>" 50)
begin
-abbreviation Peq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubseteq>" 50) where
- "x \<sqsubseteq> y \<equiv> P\<^sup>=\<^sup>= x y"
+abbreviation Peq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubseteq>" 50)
+ where "x \<sqsubseteq> y \<equiv> P\<^sup>=\<^sup>= x y"
+
+text \<open>A chain is a totally ordered subset of \<open>A\<close>.\<close>
+definition chain :: "'a set \<Rightarrow> bool"
+ where "chain C \<longleftrightarrow> C \<subseteq> A \<and> (\<forall>x\<in>C. \<forall>y\<in>C. x \<sqsubseteq> y \<or> y \<sqsubseteq> x)"
-text \<open>A chain is a totally ordered subset of @{term A}.\<close>
-definition chain :: "'a set \<Rightarrow> bool" where
- "chain C \<longleftrightarrow> C \<subseteq> A \<and> (\<forall>x\<in>C. \<forall>y\<in>C. x \<sqsubseteq> y \<or> y \<sqsubseteq> x)"
-
-text \<open>We call a chain that is a proper superset of some set @{term X},
-but not necessarily a chain itself, a superchain of @{term X}.\<close>
-abbreviation superchain :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" (infix "<c" 50) where
- "X <c C \<equiv> chain C \<and> X \<subset> C"
+text \<open>
+ We call a chain that is a proper superset of some set \<open>X\<close>,
+ but not necessarily a chain itself, a superchain of \<open>X\<close>.
+\<close>
+abbreviation superchain :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" (infix "<c" 50)
+ where "X <c C \<equiv> chain C \<and> X \<subset> C"
text \<open>A maximal chain is a chain that does not have a superchain.\<close>
-definition maxchain :: "'a set \<Rightarrow> bool" where
- "maxchain C \<longleftrightarrow> chain C \<and> \<not> (\<exists>S. C <c S)"
+definition maxchain :: "'a set \<Rightarrow> bool"
+ where "maxchain C \<longleftrightarrow> chain C \<and> (\<nexists>S. C <c S)"
-text \<open>We define the successor of a set to be an arbitrary
-superchain, if such exists, or the set itself, otherwise.\<close>
-definition suc :: "'a set \<Rightarrow> 'a set" where
- "suc C = (if \<not> chain C \<or> maxchain C then C else (SOME D. C <c D))"
+text \<open>
+ We define the successor of a set to be an arbitrary
+ superchain, if such exists, or the set itself, otherwise.
+\<close>
+definition suc :: "'a set \<Rightarrow> 'a set"
+ where "suc C = (if \<not> chain C \<or> maxchain C then C else (SOME D. C <c D))"
-lemma chainI [Pure.intro?]:
- "\<lbrakk>C \<subseteq> A; \<And>x y. \<lbrakk>x \<in> C; y \<in> C\<rbrakk> \<Longrightarrow> x \<sqsubseteq> y \<or> y \<sqsubseteq> x\<rbrakk> \<Longrightarrow> chain C"
+lemma chainI [Pure.intro?]: "C \<subseteq> A \<Longrightarrow> (\<And>x y. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> x \<sqsubseteq> y \<or> y \<sqsubseteq> x) \<Longrightarrow> chain C"
unfolding chain_def by blast
-lemma chain_total:
- "chain C \<Longrightarrow> x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
+lemma chain_total: "chain C \<Longrightarrow> x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
by (simp add: chain_def)
lemma not_chain_suc [simp]: "\<not> chain X \<Longrightarrow> suc X = X"
@@ -64,62 +66,67 @@
lemma chain_empty [simp]: "chain {}"
by (auto simp: chain_def)
-lemma not_maxchain_Some:
- "chain C \<Longrightarrow> \<not> maxchain C \<Longrightarrow> C <c (SOME D. C <c D)"
+lemma not_maxchain_Some: "chain C \<Longrightarrow> \<not> maxchain C \<Longrightarrow> C <c (SOME D. C <c D)"
by (rule someI_ex) (auto simp: maxchain_def)
-lemma suc_not_equals:
- "chain C \<Longrightarrow> \<not> maxchain C \<Longrightarrow> suc C \<noteq> C"
+lemma suc_not_equals: "chain C \<Longrightarrow> \<not> maxchain C \<Longrightarrow> suc C \<noteq> C"
using not_maxchain_Some by (auto simp: suc_def)
lemma subset_suc:
- assumes "X \<subseteq> Y" shows "X \<subseteq> suc Y"
+ assumes "X \<subseteq> Y"
+ shows "X \<subseteq> suc Y"
using assms by (rule subset_trans) (rule suc_subset)
-text \<open>We build a set @{term \<C>} that is closed under applications
-of @{term suc} and contains the union of all its subsets.\<close>
-inductive_set suc_Union_closed ("\<C>") where
- suc: "X \<in> \<C> \<Longrightarrow> suc X \<in> \<C>" |
- Union [unfolded Pow_iff]: "X \<in> Pow \<C> \<Longrightarrow> \<Union>X \<in> \<C>"
-
-text \<open>Since the empty set as well as the set itself is a subset of
-every set, @{term \<C>} contains at least @{term "{} \<in> \<C>"} and
-@{term "\<Union>\<C> \<in> \<C>"}.\<close>
-lemma
- suc_Union_closed_empty: "{} \<in> \<C>" and
- suc_Union_closed_Union: "\<Union>\<C> \<in> \<C>"
- using Union [of "{}"] and Union [of "\<C>"] by simp+
-text \<open>Thus closure under @{term suc} will hit a maximal chain
-eventually, as is shown below.\<close>
+text \<open>
+ We build a set @{term \<C>} that is closed under applications
+ of @{term suc} and contains the union of all its subsets.
+\<close>
+inductive_set suc_Union_closed ("\<C>")
+ where
+ suc: "X \<in> \<C> \<Longrightarrow> suc X \<in> \<C>"
+ | Union [unfolded Pow_iff]: "X \<in> Pow \<C> \<Longrightarrow> \<Union>X \<in> \<C>"
-lemma suc_Union_closed_induct [consumes 1, case_names suc Union,
- induct pred: suc_Union_closed]:
- assumes "X \<in> \<C>"
- and "\<And>X. \<lbrakk>X \<in> \<C>; Q X\<rbrakk> \<Longrightarrow> Q (suc X)"
- and "\<And>X. \<lbrakk>X \<subseteq> \<C>; \<forall>x\<in>X. Q x\<rbrakk> \<Longrightarrow> Q (\<Union>X)"
- shows "Q X"
- using assms by (induct) blast+
+text \<open>
+ Since the empty set as well as the set itself is a subset of
+ every set, @{term \<C>} contains at least @{term "{} \<in> \<C>"} and
+ @{term "\<Union>\<C> \<in> \<C>"}.
+\<close>
+lemma suc_Union_closed_empty: "{} \<in> \<C>"
+ and suc_Union_closed_Union: "\<Union>\<C> \<in> \<C>"
+ using Union [of "{}"] and Union [of "\<C>"] by simp_all
+
+text \<open>Thus closure under @{term suc} will hit a maximal chain
+ eventually, as is shown below.\<close>
-lemma suc_Union_closed_cases [consumes 1, case_names suc Union,
- cases pred: suc_Union_closed]:
+lemma suc_Union_closed_induct [consumes 1, case_names suc Union, induct pred: suc_Union_closed]:
assumes "X \<in> \<C>"
- and "\<And>Y. \<lbrakk>X = suc Y; Y \<in> \<C>\<rbrakk> \<Longrightarrow> Q"
- and "\<And>Y. \<lbrakk>X = \<Union>Y; Y \<subseteq> \<C>\<rbrakk> \<Longrightarrow> Q"
+ and "\<And>X. X \<in> \<C> \<Longrightarrow> Q X \<Longrightarrow> Q (suc X)"
+ and "\<And>X. X \<subseteq> \<C> \<Longrightarrow> \<forall>x\<in>X. Q x \<Longrightarrow> Q (\<Union>X)"
+ shows "Q X"
+ using assms by induct blast+
+
+lemma suc_Union_closed_cases [consumes 1, case_names suc Union, cases pred: suc_Union_closed]:
+ assumes "X \<in> \<C>"
+ and "\<And>Y. X = suc Y \<Longrightarrow> Y \<in> \<C> \<Longrightarrow> Q"
+ and "\<And>Y. X = \<Union>Y \<Longrightarrow> Y \<subseteq> \<C> \<Longrightarrow> Q"
shows "Q"
- using assms by (cases) simp+
+ using assms by cases simp_all
text \<open>On chains, @{term suc} yields a chain.\<close>
lemma chain_suc:
- assumes "chain X" shows "chain (suc X)"
+ assumes "chain X"
+ shows "chain (suc X)"
using assms
- by (cases "\<not> chain X \<or> maxchain X")
- (force simp: suc_def dest: not_maxchain_Some)+
+ by (cases "\<not> chain X \<or> maxchain X") (force simp: suc_def dest: not_maxchain_Some)+
lemma chain_sucD:
- assumes "chain X" shows "suc X \<subseteq> A \<and> chain (suc X)"
+ assumes "chain X"
+ shows "suc X \<subseteq> A \<and> chain (suc X)"
proof -
- from \<open>chain X\<close> have *: "chain (suc X)" by (rule chain_suc)
- then have "suc X \<subseteq> A" unfolding chain_def by blast
+ from \<open>chain X\<close> have *: "chain (suc X)"
+ by (rule chain_suc)
+ then have "suc X \<subseteq> A"
+ unfolding chain_def by blast
with * show ?thesis by blast
qed
@@ -128,27 +135,31 @@
and *: "\<And>Z. Z \<in> \<C> \<Longrightarrow> Z \<subseteq> Y \<Longrightarrow> Z = Y \<or> suc Z \<subseteq> Y"
shows "X \<subseteq> Y \<or> suc Y \<subseteq> X"
using \<open>X \<in> \<C>\<close>
-proof (induct)
+proof induct
case (suc X)
with * show ?case by (blast del: subsetI intro: subset_suc)
-qed blast
+next
+ case Union
+ then show ?case by blast
+qed
lemma suc_Union_closed_subsetD:
assumes "Y \<subseteq> X" and "X \<in> \<C>" and "Y \<in> \<C>"
shows "X = Y \<or> suc Y \<subseteq> X"
- using assms(2-, 1)
+ using assms(2,3,1)
proof (induct arbitrary: Y)
case (suc X)
- note * = \<open>\<And>Y. \<lbrakk>Y \<in> \<C>; Y \<subseteq> X\<rbrakk> \<Longrightarrow> X = Y \<or> suc Y \<subseteq> X\<close>
+ note * = \<open>\<And>Y. Y \<in> \<C> \<Longrightarrow> Y \<subseteq> X \<Longrightarrow> X = Y \<or> suc Y \<subseteq> X\<close>
with suc_Union_closed_total' [OF \<open>Y \<in> \<C>\<close> \<open>X \<in> \<C>\<close>]
- have "Y \<subseteq> X \<or> suc X \<subseteq> Y" by blast
+ have "Y \<subseteq> X \<or> suc X \<subseteq> Y" by blast
then show ?case
proof
assume "Y \<subseteq> X"
with * and \<open>Y \<in> \<C>\<close> have "X = Y \<or> suc Y \<subseteq> X" by blast
then show ?thesis
proof
- assume "X = Y" then show ?thesis by simp
+ assume "X = Y"
+ then show ?thesis by simp
next
assume "suc Y \<subseteq> X"
then have "suc Y \<subseteq> suc X" by (rule subset_suc)
@@ -164,21 +175,22 @@
proof (rule ccontr)
assume "\<not> ?thesis"
with \<open>Y \<subseteq> \<Union>X\<close> obtain x y z
- where "\<not> suc Y \<subseteq> \<Union>X"
- and "x \<in> X" and "y \<in> x" and "y \<notin> Y"
- and "z \<in> suc Y" and "\<forall>x\<in>X. z \<notin> x" by blast
+ where "\<not> suc Y \<subseteq> \<Union>X"
+ and "x \<in> X" and "y \<in> x" and "y \<notin> Y"
+ and "z \<in> suc Y" and "\<forall>x\<in>X. z \<notin> x" by blast
with \<open>X \<subseteq> \<C>\<close> have "x \<in> \<C>" by blast
- from Union and \<open>x \<in> X\<close>
- have *: "\<And>y. \<lbrakk>y \<in> \<C>; y \<subseteq> x\<rbrakk> \<Longrightarrow> x = y \<or> suc y \<subseteq> x" by blast
- with suc_Union_closed_total' [OF \<open>Y \<in> \<C>\<close> \<open>x \<in> \<C>\<close>]
- have "Y \<subseteq> x \<or> suc x \<subseteq> Y" by blast
+ from Union and \<open>x \<in> X\<close> have *: "\<And>y. y \<in> \<C> \<Longrightarrow> y \<subseteq> x \<Longrightarrow> x = y \<or> suc y \<subseteq> x"
+ by blast
+ with suc_Union_closed_total' [OF \<open>Y \<in> \<C>\<close> \<open>x \<in> \<C>\<close>] have "Y \<subseteq> x \<or> suc x \<subseteq> Y"
+ by blast
then show False
proof
assume "Y \<subseteq> x"
with * [OF \<open>Y \<in> \<C>\<close>] have "x = Y \<or> suc Y \<subseteq> x" by blast
then show False
proof
- assume "x = Y" with \<open>y \<in> x\<close> and \<open>y \<notin> Y\<close> show False by blast
+ assume "x = Y"
+ with \<open>y \<in> x\<close> and \<open>y \<notin> Y\<close> show False by blast
next
assume "suc Y \<subseteq> x"
with \<open>x \<in> X\<close> have "suc Y \<subseteq> \<Union>X" by blast
@@ -199,75 +211,87 @@
proof (cases "\<forall>Z\<in>\<C>. Z \<subseteq> Y \<longrightarrow> Z = Y \<or> suc Z \<subseteq> Y")
case True
with suc_Union_closed_total' [OF assms]
- have "X \<subseteq> Y \<or> suc Y \<subseteq> X" by blast
- then show ?thesis using suc_subset [of Y] by blast
+ have "X \<subseteq> Y \<or> suc Y \<subseteq> X" by blast
+ with suc_subset [of Y] show ?thesis by blast
next
case False
- then obtain Z
- where "Z \<in> \<C>" and "Z \<subseteq> Y" and "Z \<noteq> Y" and "\<not> suc Z \<subseteq> Y" by blast
- with suc_Union_closed_subsetD and \<open>Y \<in> \<C>\<close> show ?thesis by blast
+ then obtain Z where "Z \<in> \<C>" and "Z \<subseteq> Y" and "Z \<noteq> Y" and "\<not> suc Z \<subseteq> Y"
+ by blast
+ with suc_Union_closed_subsetD and \<open>Y \<in> \<C>\<close> show ?thesis
+ by blast
qed
text \<open>Once we hit a fixed point w.r.t. @{term suc}, all other elements
-of @{term \<C>} are subsets of this fixed point.\<close>
+ of @{term \<C>} are subsets of this fixed point.\<close>
lemma suc_Union_closed_suc:
assumes "X \<in> \<C>" and "Y \<in> \<C>" and "suc Y = Y"
shows "X \<subseteq> Y"
-using \<open>X \<in> \<C>\<close>
-proof (induct)
+ using \<open>X \<in> \<C>\<close>
+proof induct
case (suc X)
- with \<open>Y \<in> \<C>\<close> and suc_Union_closed_subsetD
- have "X = Y \<or> suc X \<subseteq> Y" by blast
- then show ?case by (auto simp: \<open>suc Y = Y\<close>)
-qed blast
+ with \<open>Y \<in> \<C>\<close> and suc_Union_closed_subsetD have "X = Y \<or> suc X \<subseteq> Y"
+ by blast
+ then show ?case
+ by (auto simp: \<open>suc Y = Y\<close>)
+next
+ case Union
+ then show ?case by blast
+qed
lemma eq_suc_Union:
assumes "X \<in> \<C>"
shows "suc X = X \<longleftrightarrow> X = \<Union>\<C>"
+ (is "?lhs \<longleftrightarrow> ?rhs")
proof
- assume "suc X = X"
- with suc_Union_closed_suc [OF suc_Union_closed_Union \<open>X \<in> \<C>\<close>]
- have "\<Union>\<C> \<subseteq> X" .
- with \<open>X \<in> \<C>\<close> show "X = \<Union>\<C>" by blast
+ assume ?lhs
+ then have "\<Union>\<C> \<subseteq> X"
+ by (rule suc_Union_closed_suc [OF suc_Union_closed_Union \<open>X \<in> \<C>\<close>])
+ with \<open>X \<in> \<C>\<close> show ?rhs
+ by blast
next
from \<open>X \<in> \<C>\<close> have "suc X \<in> \<C>" by (rule suc)
then have "suc X \<subseteq> \<Union>\<C>" by blast
- moreover assume "X = \<Union>\<C>"
+ moreover assume ?rhs
ultimately have "suc X \<subseteq> X" by simp
moreover have "X \<subseteq> suc X" by (rule suc_subset)
- ultimately show "suc X = X" ..
+ ultimately show ?lhs ..
qed
lemma suc_in_carrier:
assumes "X \<subseteq> A"
shows "suc X \<subseteq> A"
using assms
- by (cases "\<not> chain X \<or> maxchain X")
- (auto dest: chain_sucD)
+ by (cases "\<not> chain X \<or> maxchain X") (auto dest: chain_sucD)
lemma suc_Union_closed_in_carrier:
assumes "X \<in> \<C>"
shows "X \<subseteq> A"
using assms
- by (induct) (auto dest: suc_in_carrier)
+ by induct (auto dest: suc_in_carrier)
text \<open>All elements of @{term \<C>} are chains.\<close>
lemma suc_Union_closed_chain:
assumes "X \<in> \<C>"
shows "chain X"
-using assms
-proof (induct)
- case (suc X) then show ?case using not_maxchain_Some by (simp add: suc_def)
+ using assms
+proof induct
+ case (suc X)
+ then show ?case
+ using not_maxchain_Some by (simp add: suc_def)
next
case (Union X)
- then have "\<Union>X \<subseteq> A" by (auto dest: suc_Union_closed_in_carrier)
+ then have "\<Union>X \<subseteq> A"
+ by (auto dest: suc_Union_closed_in_carrier)
moreover have "\<forall>x\<in>\<Union>X. \<forall>y\<in>\<Union>X. x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
proof (intro ballI)
fix x y
assume "x \<in> \<Union>X" and "y \<in> \<Union>X"
- then obtain u v where "x \<in> u" and "u \<in> X" and "y \<in> v" and "v \<in> X" by blast
- with Union have "u \<in> \<C>" and "v \<in> \<C>" and "chain u" and "chain v" by blast+
- with suc_Union_closed_total have "u \<subseteq> v \<or> v \<subseteq> u" by blast
+ then obtain u v where "x \<in> u" and "u \<in> X" and "y \<in> v" and "v \<in> X"
+ by blast
+ with Union have "u \<in> \<C>" and "v \<in> \<C>" and "chain u" and "chain v"
+ by blast+
+ with suc_Union_closed_total have "u \<subseteq> v \<or> v \<subseteq> u"
+ by blast
then show "x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
proof
assume "u \<subseteq> v"
@@ -290,18 +314,17 @@
subsubsection \<open>Hausdorff's Maximum Principle\<close>
-text \<open>There exists a maximal totally ordered subset of @{term A}. (Note that we do not
-require @{term A} to be partially ordered.)\<close>
+text \<open>There exists a maximal totally ordered subset of \<open>A\<close>. (Note that we do not
+ require \<open>A\<close> to be partially ordered.)\<close>
theorem Hausdorff: "\<exists>C. maxchain C"
proof -
let ?M = "\<Union>\<C>"
have "maxchain ?M"
proof (rule ccontr)
- assume "\<not> maxchain ?M"
+ assume "\<not> ?thesis"
then have "suc ?M \<noteq> ?M"
- using suc_not_equals and
- suc_Union_closed_chain [OF suc_Union_closed_Union] by simp
+ using suc_not_equals and suc_Union_closed_chain [OF suc_Union_closed_Union] by simp
moreover have "suc ?M = ?M"
using eq_suc_Union [OF suc_Union_closed_Union] by simp
ultimately show False by contradiction
@@ -310,34 +333,35 @@
qed
text \<open>Make notation @{term \<C>} available again.\<close>
-no_notation suc_Union_closed ("\<C>")
+no_notation suc_Union_closed ("\<C>")
-lemma chain_extend:
- "chain C \<Longrightarrow> z \<in> A \<Longrightarrow> \<forall>x\<in>C. x \<sqsubseteq> z \<Longrightarrow> chain ({z} \<union> C)"
+lemma chain_extend: "chain C \<Longrightarrow> z \<in> A \<Longrightarrow> \<forall>x\<in>C. x \<sqsubseteq> z \<Longrightarrow> chain ({z} \<union> C)"
unfolding chain_def by blast
-lemma maxchain_imp_chain:
- "maxchain C \<Longrightarrow> chain C"
+lemma maxchain_imp_chain: "maxchain C \<Longrightarrow> chain C"
by (simp add: maxchain_def)
end
text \<open>Hide constant @{const pred_on.suc_Union_closed}, which was just needed
-for the proof of Hausforff's maximum principle.\<close>
+ for the proof of Hausforff's maximum principle.\<close>
hide_const pred_on.suc_Union_closed
lemma chain_mono:
- assumes "\<And>x y. \<lbrakk>x \<in> A; y \<in> A; P x y\<rbrakk> \<Longrightarrow> Q x y"
+ assumes "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> P x y \<Longrightarrow> Q x y"
and "pred_on.chain A P C"
shows "pred_on.chain A Q C"
using assms unfolding pred_on.chain_def by blast
+
subsubsection \<open>Results for the proper subset relation\<close>
interpretation subset: pred_on "A" "op \<subset>" for A .
lemma subset_maxchain_max:
- assumes "subset.maxchain A C" and "X \<in> A" and "\<Union>C \<subseteq> X"
+ assumes "subset.maxchain A C"
+ and "X \<in> A"
+ and "\<Union>C \<subseteq> X"
shows "\<Union>C = X"
proof (rule ccontr)
let ?C = "{X} \<union> C"
@@ -352,6 +376,7 @@
ultimately show False using * by blast
qed
+
subsubsection \<open>Zorn's lemma\<close>
text \<open>If every chain has an upper bound, then there is a maximal set.\<close>
@@ -360,19 +385,23 @@
shows "\<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M"
proof -
from subset.Hausdorff [of A] obtain M where "subset.maxchain A M" ..
- then have "subset.chain A M" by (rule subset.maxchain_imp_chain)
- with assms obtain Y where "Y \<in> A" and "\<forall>X\<in>M. X \<subseteq> Y" by blast
+ then have "subset.chain A M"
+ by (rule subset.maxchain_imp_chain)
+ with assms obtain Y where "Y \<in> A" and "\<forall>X\<in>M. X \<subseteq> Y"
+ by blast
moreover have "\<forall>X\<in>A. Y \<subseteq> X \<longrightarrow> Y = X"
proof (intro ballI impI)
fix X
assume "X \<in> A" and "Y \<subseteq> X"
show "Y = X"
proof (rule ccontr)
- assume "Y \<noteq> X"
+ assume "\<not> ?thesis"
with \<open>Y \<subseteq> X\<close> have "\<not> X \<subseteq> Y" by blast
from subset.chain_extend [OF \<open>subset.chain A M\<close> \<open>X \<in> A\<close>] and \<open>\<forall>X\<in>M. X \<subseteq> Y\<close>
- have "subset.chain A ({X} \<union> M)" using \<open>Y \<subseteq> X\<close> by auto
- moreover have "M \<subset> {X} \<union> M" using \<open>\<forall>X\<in>M. X \<subseteq> Y\<close> and \<open>\<not> X \<subseteq> Y\<close> by auto
+ have "subset.chain A ({X} \<union> M)"
+ using \<open>Y \<subseteq> X\<close> by auto
+ moreover have "M \<subset> {X} \<union> M"
+ using \<open>\<forall>X\<in>M. X \<subseteq> Y\<close> and \<open>\<not> X \<subseteq> Y\<close> by auto
ultimately show False
using \<open>subset.maxchain A M\<close> by (auto simp: subset.maxchain_def)
qed
@@ -380,13 +409,14 @@
ultimately show ?thesis by blast
qed
-text\<open>Alternative version of Zorn's lemma for the subset relation.\<close>
+text \<open>Alternative version of Zorn's lemma for the subset relation.\<close>
lemma subset_Zorn':
assumes "\<And>C. subset.chain A C \<Longrightarrow> \<Union>C \<in> A"
shows "\<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M"
proof -
from subset.Hausdorff [of A] obtain M where "subset.maxchain A M" ..
- then have "subset.chain A M" by (rule subset.maxchain_imp_chain)
+ then have "subset.chain A M"
+ by (rule subset.maxchain_imp_chain)
with assms have "\<Union>M \<in> A" .
moreover have "\<forall>Z\<in>A. \<Union>M \<subseteq> Z \<longrightarrow> \<Union>M = Z"
proof (intro ballI impI)
@@ -403,19 +433,17 @@
text \<open>Relate old to new definitions.\<close>
-(* Define globally? In Set.thy? *)
-definition chain_subset :: "'a set set \<Rightarrow> bool" ("chain\<^sub>\<subseteq>") where
- "chain\<^sub>\<subseteq> C \<longleftrightarrow> (\<forall>A\<in>C. \<forall>B\<in>C. A \<subseteq> B \<or> B \<subseteq> A)"
+definition chain_subset :: "'a set set \<Rightarrow> bool" ("chain\<^sub>\<subseteq>") (* Define globally? In Set.thy? *)
+ where "chain\<^sub>\<subseteq> C \<longleftrightarrow> (\<forall>A\<in>C. \<forall>B\<in>C. A \<subseteq> B \<or> B \<subseteq> A)"
-definition chains :: "'a set set \<Rightarrow> 'a set set set" where
- "chains A = {C. C \<subseteq> A \<and> chain\<^sub>\<subseteq> C}"
+definition chains :: "'a set set \<Rightarrow> 'a set set set"
+ where "chains A = {C. C \<subseteq> A \<and> chain\<^sub>\<subseteq> C}"
-(* Define globally? In Relation.thy? *)
-definition Chains :: "('a \<times> 'a) set \<Rightarrow> 'a set set" where
- "Chains r = {C. \<forall>a\<in>C. \<forall>b\<in>C. (a, b) \<in> r \<or> (b, a) \<in> r}"
+definition Chains :: "('a \<times> 'a) set \<Rightarrow> 'a set set" (* Define globally? In Relation.thy? *)
+ where "Chains r = {C. \<forall>a\<in>C. \<forall>b\<in>C. (a, b) \<in> r \<or> (b, a) \<in> r}"
-lemma chains_extend:
- "[| c \<in> chains S; z \<in> S; \<forall>x \<in> c. x \<subseteq> (z:: 'a set) |] ==> {z} Un c \<in> chains S"
+lemma chains_extend: "c \<in> chains S \<Longrightarrow> z \<in> S \<Longrightarrow> \<forall>x \<in> c. x \<subseteq> z \<Longrightarrow> {z} \<union> c \<in> chains S"
+ for z :: "'a set"
unfolding chains_def chain_subset_def by blast
lemma mono_Chains: "r \<subseteq> s \<Longrightarrow> Chains r \<subseteq> Chains s"
@@ -427,8 +455,7 @@
lemma chains_alt_def: "chains A = {C. subset.chain A C}"
by (simp add: chains_def chain_subset_alt_def subset.chain_def)
-lemma Chains_subset:
- "Chains r \<subseteq> {C. pred_on.chain UNIV (\<lambda>x y. (x, y) \<in> r) C}"
+lemma Chains_subset: "Chains r \<subseteq> {C. pred_on.chain UNIV (\<lambda>x y. (x, y) \<in> r) C}"
by (force simp add: Chains_def pred_on.chain_def)
lemma Chains_subset':
@@ -442,20 +469,18 @@
shows "Chains r = {C. pred_on.chain UNIV (\<lambda>x y. (x, y) \<in> r) C}"
using assms Chains_subset Chains_subset' by blast
-lemma Zorn_Lemma:
- "\<forall>C\<in>chains A. \<Union>C \<in> A \<Longrightarrow> \<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M"
+lemma Zorn_Lemma: "\<forall>C\<in>chains A. \<Union>C \<in> A \<Longrightarrow> \<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M"
using subset_Zorn' [of A] by (force simp: chains_alt_def)
-lemma Zorn_Lemma2:
- "\<forall>C\<in>chains A. \<exists>U\<in>A. \<forall>X\<in>C. X \<subseteq> U \<Longrightarrow> \<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M"
+lemma Zorn_Lemma2: "\<forall>C\<in>chains A. \<exists>U\<in>A. \<forall>X\<in>C. X \<subseteq> U \<Longrightarrow> \<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M"
using subset_Zorn [of A] by (auto simp: chains_alt_def)
-text\<open>Various other lemmas\<close>
+text \<open>Various other lemmas\<close>
-lemma chainsD: "[| c \<in> chains S; x \<in> c; y \<in> c |] ==> x \<subseteq> y | y \<subseteq> x"
+lemma chainsD: "c \<in> chains S \<Longrightarrow> x \<in> c \<Longrightarrow> y \<in> c \<Longrightarrow> x \<subseteq> y \<or> y \<subseteq> x"
unfolding chains_def chain_subset_def by blast
-lemma chainsD2: "!!(c :: 'a set set). c \<in> chains S ==> c \<subseteq> S"
+lemma chainsD2: "c \<in> chains S \<Longrightarrow> c \<subseteq> S"
unfolding chains_def by blast
lemma Zorns_po_lemma:
@@ -463,42 +488,49 @@
and u: "\<forall>C\<in>Chains r. \<exists>u\<in>Field r. \<forall>a\<in>C. (a, u) \<in> r"
shows "\<exists>m\<in>Field r. \<forall>a\<in>Field r. (m, a) \<in> r \<longrightarrow> a = m"
proof -
- have "Preorder r" using po by (simp add: partial_order_on_def)
-\<comment>\<open>Mirror r in the set of subsets below (wrt r) elements of A\<close>
- let ?B = "%x. r\<inverse> `` {x}" let ?S = "?B ` Field r"
- {
- fix C assume 1: "C \<subseteq> ?S" and 2: "\<forall>A\<in>C. \<forall>B\<in>C. A \<subseteq> B \<or> B \<subseteq> A"
+ have "Preorder r"
+ using po by (simp add: partial_order_on_def)
+ txt \<open>Mirror \<open>r\<close> in the set of subsets below (wrt \<open>r\<close>) elements of \<open>A\<close>.\<close>
+ let ?B = "\<lambda>x. r\<inverse> `` {x}"
+ let ?S = "?B ` Field r"
+ have "\<exists>u\<in>Field r. \<forall>A\<in>C. A \<subseteq> r\<inverse> `` {u}" (is "\<exists>u\<in>Field r. ?P u")
+ if 1: "C \<subseteq> ?S" and 2: "\<forall>A\<in>C. \<forall>B\<in>C. A \<subseteq> B \<or> B \<subseteq> A" for C
+ proof -
let ?A = "{x\<in>Field r. \<exists>M\<in>C. M = ?B x}"
- have "C = ?B ` ?A" using 1 by (auto simp: image_def)
+ from 1 have "C = ?B ` ?A" by (auto simp: image_def)
have "?A \<in> Chains r"
proof (simp add: Chains_def, intro allI impI, elim conjE)
fix a b
assume "a \<in> Field r" and "?B a \<in> C" and "b \<in> Field r" and "?B b \<in> C"
- hence "?B a \<subseteq> ?B b \<or> ?B b \<subseteq> ?B a" using 2 by auto
- thus "(a, b) \<in> r \<or> (b, a) \<in> r"
+ with 2 have "?B a \<subseteq> ?B b \<or> ?B b \<subseteq> ?B a" by auto
+ then show "(a, b) \<in> r \<or> (b, a) \<in> r"
using \<open>Preorder r\<close> and \<open>a \<in> Field r\<close> and \<open>b \<in> Field r\<close>
by (simp add:subset_Image1_Image1_iff)
qed
- then obtain u where uA: "u \<in> Field r" "\<forall>a\<in>?A. (a, u) \<in> r" using u by auto
- have "\<forall>A\<in>C. A \<subseteq> r\<inverse> `` {u}" (is "?P u")
+ with u obtain u where uA: "u \<in> Field r" "\<forall>a\<in>?A. (a, u) \<in> r" by auto
+ have "?P u"
proof auto
fix a B assume aB: "B \<in> C" "a \<in> B"
with 1 obtain x where "x \<in> Field r" and "B = r\<inverse> `` {x}" by auto
- thus "(a, u) \<in> r" using uA and aB and \<open>Preorder r\<close>
+ then show "(a, u) \<in> r"
+ using uA and aB and \<open>Preorder r\<close>
unfolding preorder_on_def refl_on_def by simp (fast dest: transD)
qed
- then have "\<exists>u\<in>Field r. ?P u" using \<open>u \<in> Field r\<close> by blast
- }
+ then show ?thesis
+ using \<open>u \<in> Field r\<close> by blast
+ qed
then have "\<forall>C\<in>chains ?S. \<exists>U\<in>?S. \<forall>A\<in>C. A \<subseteq> U"
by (auto simp: chains_def chain_subset_def)
- from Zorn_Lemma2 [OF this]
- obtain m B where "m \<in> Field r" and "B = r\<inverse> `` {m}"
- and "\<forall>x\<in>Field r. B \<subseteq> r\<inverse> `` {x} \<longrightarrow> r\<inverse> `` {x} = B"
+ from Zorn_Lemma2 [OF this] obtain m B
+ where "m \<in> Field r"
+ and "B = r\<inverse> `` {m}"
+ and "\<forall>x\<in>Field r. B \<subseteq> r\<inverse> `` {x} \<longrightarrow> r\<inverse> `` {x} = B"
by auto
- hence "\<forall>a\<in>Field r. (m, a) \<in> r \<longrightarrow> a = m"
+ then have "\<forall>a\<in>Field r. (m, a) \<in> r \<longrightarrow> a = m"
using po and \<open>Preorder r\<close> and \<open>m \<in> Field r\<close>
by (auto simp: subset_Image1_Image1_iff Partial_order_eq_Image1_Image1_iff)
- thus ?thesis using \<open>m \<in> Field r\<close> by blast
+ then show ?thesis
+ using \<open>m \<in> Field r\<close> by blast
qed
@@ -509,13 +541,12 @@
Definition correct/most general?
Naming?
*)
-definition init_seg_of :: "(('a \<times> 'a) set \<times> ('a \<times> 'a) set) set" where
- "init_seg_of = {(r, s). r \<subseteq> s \<and> (\<forall>a b c. (a, b) \<in> s \<and> (b, c) \<in> r \<longrightarrow> (a, b) \<in> r)}"
+definition init_seg_of :: "(('a \<times> 'a) set \<times> ('a \<times> 'a) set) set"
+ where "init_seg_of = {(r, s). r \<subseteq> s \<and> (\<forall>a b c. (a, b) \<in> s \<and> (b, c) \<in> r \<longrightarrow> (a, b) \<in> r)}"
-abbreviation
- initialSegmentOf :: "('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool" (infix "initial'_segment'_of" 55)
-where
- "r initial_segment_of s \<equiv> (r, s) \<in> init_seg_of"
+abbreviation initial_segment_of_syntax :: "('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"
+ (infix "initial'_segment'_of" 55)
+ where "r initial_segment_of s \<equiv> (r, s) \<in> init_seg_of"
lemma refl_on_init_seg_of [simp]: "r initial_segment_of r"
by (simp add: init_seg_of_def)
@@ -524,85 +555,97 @@
"r initial_segment_of s \<Longrightarrow> s initial_segment_of t \<Longrightarrow> r initial_segment_of t"
by (simp (no_asm_use) add: init_seg_of_def) blast
-lemma antisym_init_seg_of:
- "r initial_segment_of s \<Longrightarrow> s initial_segment_of r \<Longrightarrow> r = s"
+lemma antisym_init_seg_of: "r initial_segment_of s \<Longrightarrow> s initial_segment_of r \<Longrightarrow> r = s"
unfolding init_seg_of_def by safe
-lemma Chains_init_seg_of_Union:
- "R \<in> Chains init_seg_of \<Longrightarrow> r\<in>R \<Longrightarrow> r initial_segment_of \<Union>R"
+lemma Chains_init_seg_of_Union: "R \<in> Chains init_seg_of \<Longrightarrow> r\<in>R \<Longrightarrow> r initial_segment_of \<Union>R"
by (auto simp: init_seg_of_def Ball_def Chains_def) blast
lemma chain_subset_trans_Union:
assumes "chain\<^sub>\<subseteq> R" "\<forall>r\<in>R. trans r"
shows "trans (\<Union>R)"
proof (intro transI, elim UnionE)
- fix S1 S2 :: "'a rel" and x y z :: 'a
+ fix S1 S2 :: "'a rel" and x y z :: 'a
assume "S1 \<in> R" "S2 \<in> R"
- with assms(1) have "S1 \<subseteq> S2 \<or> S2 \<subseteq> S1" unfolding chain_subset_def by blast
+ with assms(1) have "S1 \<subseteq> S2 \<or> S2 \<subseteq> S1"
+ unfolding chain_subset_def by blast
moreover assume "(x, y) \<in> S1" "(y, z) \<in> S2"
- ultimately have "((x, y) \<in> S1 \<and> (y, z) \<in> S1) \<or> ((x, y) \<in> S2 \<and> (y, z) \<in> S2)" by blast
- with \<open>S1 \<in> R\<close> \<open>S2 \<in> R\<close> assms(2) show "(x, z) \<in> \<Union>R" by (auto elim: transE)
+ ultimately have "((x, y) \<in> S1 \<and> (y, z) \<in> S1) \<or> ((x, y) \<in> S2 \<and> (y, z) \<in> S2)"
+ by blast
+ with \<open>S1 \<in> R\<close> \<open>S2 \<in> R\<close> assms(2) show "(x, z) \<in> \<Union>R"
+ by (auto elim: transE)
qed
lemma chain_subset_antisym_Union:
assumes "chain\<^sub>\<subseteq> R" "\<forall>r\<in>R. antisym r"
shows "antisym (\<Union>R)"
proof (intro antisymI, elim UnionE)
- fix S1 S2 :: "'a rel" and x y :: 'a
+ fix S1 S2 :: "'a rel" and x y :: 'a
assume "S1 \<in> R" "S2 \<in> R"
- with assms(1) have "S1 \<subseteq> S2 \<or> S2 \<subseteq> S1" unfolding chain_subset_def by blast
+ with assms(1) have "S1 \<subseteq> S2 \<or> S2 \<subseteq> S1"
+ unfolding chain_subset_def by blast
moreover assume "(x, y) \<in> S1" "(y, x) \<in> S2"
- ultimately have "((x, y) \<in> S1 \<and> (y, x) \<in> S1) \<or> ((x, y) \<in> S2 \<and> (y, x) \<in> S2)" by blast
- with \<open>S1 \<in> R\<close> \<open>S2 \<in> R\<close> assms(2) show "x = y" unfolding antisym_def by auto
+ ultimately have "((x, y) \<in> S1 \<and> (y, x) \<in> S1) \<or> ((x, y) \<in> S2 \<and> (y, x) \<in> S2)"
+ by blast
+ with \<open>S1 \<in> R\<close> \<open>S2 \<in> R\<close> assms(2) show "x = y"
+ unfolding antisym_def by auto
qed
lemma chain_subset_Total_Union:
assumes "chain\<^sub>\<subseteq> R" and "\<forall>r\<in>R. Total r"
shows "Total (\<Union>R)"
proof (simp add: total_on_def Ball_def, auto del: disjCI)
- fix r s a b assume A: "r \<in> R" "s \<in> R" "a \<in> Field r" "b \<in> Field s" "a \<noteq> b"
+ fix r s a b
+ assume A: "r \<in> R" "s \<in> R" "a \<in> Field r" "b \<in> Field s" "a \<noteq> b"
from \<open>chain\<^sub>\<subseteq> R\<close> and \<open>r \<in> R\<close> and \<open>s \<in> R\<close> have "r \<subseteq> s \<or> s \<subseteq> r"
by (auto simp add: chain_subset_def)
- thus "(\<exists>r\<in>R. (a, b) \<in> r) \<or> (\<exists>r\<in>R. (b, a) \<in> r)"
+ then show "(\<exists>r\<in>R. (a, b) \<in> r) \<or> (\<exists>r\<in>R. (b, a) \<in> r)"
proof
- assume "r \<subseteq> s" hence "(a, b) \<in> s \<or> (b, a) \<in> s" using assms(2) A mono_Field[of r s]
+ assume "r \<subseteq> s"
+ then have "(a, b) \<in> s \<or> (b, a) \<in> s"
+ using assms(2) A mono_Field[of r s]
by (auto simp add: total_on_def)
- thus ?thesis using \<open>s \<in> R\<close> by blast
+ then show ?thesis
+ using \<open>s \<in> R\<close> by blast
next
- assume "s \<subseteq> r" hence "(a, b) \<in> r \<or> (b, a) \<in> r" using assms(2) A mono_Field[of s r]
+ assume "s \<subseteq> r"
+ then have "(a, b) \<in> r \<or> (b, a) \<in> r"
+ using assms(2) A mono_Field[of s r]
by (fastforce simp add: total_on_def)
- thus ?thesis using \<open>r \<in> R\<close> by blast
+ then show ?thesis
+ using \<open>r \<in> R\<close> by blast
qed
qed
lemma wf_Union_wf_init_segs:
- assumes "R \<in> Chains init_seg_of" and "\<forall>r\<in>R. wf r"
+ assumes "R \<in> Chains init_seg_of"
+ and "\<forall>r\<in>R. wf r"
shows "wf (\<Union>R)"
-proof(simp add: wf_iff_no_infinite_down_chain, rule ccontr, auto)
- fix f assume 1: "\<forall>i. \<exists>r\<in>R. (f (Suc i), f i) \<in> r"
+proof (simp add: wf_iff_no_infinite_down_chain, rule ccontr, auto)
+ fix f
+ assume 1: "\<forall>i. \<exists>r\<in>R. (f (Suc i), f i) \<in> r"
then obtain r where "r \<in> R" and "(f (Suc 0), f 0) \<in> r" by auto
- { fix i have "(f (Suc i), f i) \<in> r"
- proof (induct i)
- case 0 show ?case by fact
- next
- case (Suc i)
- then obtain s where s: "s \<in> R" "(f (Suc (Suc i)), f(Suc i)) \<in> s"
- using 1 by auto
- then have "s initial_segment_of r \<or> r initial_segment_of s"
- using assms(1) \<open>r \<in> R\<close> by (simp add: Chains_def)
- with Suc s show ?case by (simp add: init_seg_of_def) blast
- qed
- }
- thus False using assms(2) and \<open>r \<in> R\<close>
+ have "(f (Suc i), f i) \<in> r" for i
+ proof (induct i)
+ case 0
+ show ?case by fact
+ next
+ case (Suc i)
+ then obtain s where s: "s \<in> R" "(f (Suc (Suc i)), f(Suc i)) \<in> s"
+ using 1 by auto
+ then have "s initial_segment_of r \<or> r initial_segment_of s"
+ using assms(1) \<open>r \<in> R\<close> by (simp add: Chains_def)
+ with Suc s show ?case by (simp add: init_seg_of_def) blast
+ qed
+ then show False
+ using assms(2) and \<open>r \<in> R\<close>
by (simp add: wf_iff_no_infinite_down_chain) blast
qed
-lemma initial_segment_of_Diff:
- "p initial_segment_of q \<Longrightarrow> p - s initial_segment_of q - s"
+lemma initial_segment_of_Diff: "p initial_segment_of q \<Longrightarrow> p - s initial_segment_of q - s"
unfolding init_seg_of_def by blast
-lemma Chains_inits_DiffI:
- "R \<in> Chains init_seg_of \<Longrightarrow> {r - s |r. r \<in> R} \<in> Chains init_seg_of"
+lemma Chains_inits_DiffI: "R \<in> Chains init_seg_of \<Longrightarrow> {r - s |r. r \<in> R} \<in> Chains init_seg_of"
unfolding Chains_def by (blast intro: initial_segment_of_Diff)
theorem well_ordering: "\<exists>r::'a rel. Well_order r \<and> Field r = UNIV"
@@ -610,24 +653,28 @@
\<comment> \<open>The initial segment relation on well-orders:\<close>
let ?WO = "{r::'a rel. Well_order r}"
define I where "I = init_seg_of \<inter> ?WO \<times> ?WO"
- have I_init: "I \<subseteq> init_seg_of" by (auto simp: I_def)
- hence subch: "\<And>R. R \<in> Chains I \<Longrightarrow> chain\<^sub>\<subseteq> R"
+ then have I_init: "I \<subseteq> init_seg_of" by simp
+ then have subch: "\<And>R. R \<in> Chains I \<Longrightarrow> chain\<^sub>\<subseteq> R"
unfolding init_seg_of_def chain_subset_def Chains_def by blast
have Chains_wo: "\<And>R r. R \<in> Chains I \<Longrightarrow> r \<in> R \<Longrightarrow> Well_order r"
by (simp add: Chains_def I_def) blast
- have FI: "Field I = ?WO" by (auto simp add: I_def init_seg_of_def Field_def)
- hence 0: "Partial_order I"
+ have FI: "Field I = ?WO"
+ by (auto simp add: I_def init_seg_of_def Field_def)
+ then have 0: "Partial_order I"
by (auto simp: partial_order_on_def preorder_on_def antisym_def antisym_init_seg_of refl_on_def
- trans_def I_def elim!: trans_init_seg_of)
-\<comment> \<open>I-chains have upper bounds in ?WO wrt I: their Union\<close>
- { fix R assume "R \<in> Chains I"
- hence Ris: "R \<in> Chains init_seg_of" using mono_Chains [OF I_init] by blast
- have subch: "chain\<^sub>\<subseteq> R" using \<open>R : Chains I\<close> I_init
- by (auto simp: init_seg_of_def chain_subset_def Chains_def)
+ trans_def I_def elim!: trans_init_seg_of)
+\<comment> \<open>\<open>I\<close>-chains have upper bounds in \<open>?WO\<close> wrt \<open>I\<close>: their Union\<close>
+ have "\<Union>R \<in> ?WO \<and> (\<forall>r\<in>R. (r, \<Union>R) \<in> I)" if "R \<in> Chains I" for R
+ proof -
+ from that have Ris: "R \<in> Chains init_seg_of"
+ using mono_Chains [OF I_init] by blast
+ have subch: "chain\<^sub>\<subseteq> R"
+ using \<open>R : Chains I\<close> I_init by (auto simp: init_seg_of_def chain_subset_def Chains_def)
have "\<forall>r\<in>R. Refl r" and "\<forall>r\<in>R. trans r" and "\<forall>r\<in>R. antisym r"
and "\<forall>r\<in>R. Total r" and "\<forall>r\<in>R. wf (r - Id)"
using Chains_wo [OF \<open>R \<in> Chains I\<close>] by (simp_all add: order_on_defs)
- have "Refl (\<Union>R)" using \<open>\<forall>r\<in>R. Refl r\<close> unfolding refl_on_def by fastforce
+ have "Refl (\<Union>R)"
+ using \<open>\<forall>r\<in>R. Refl r\<close> unfolding refl_on_def by fastforce
moreover have "trans (\<Union>R)"
by (rule chain_subset_trans_Union [OF subch \<open>\<forall>r\<in>R. trans r\<close>])
moreover have "antisym (\<Union>R)"
@@ -640,21 +687,25 @@
with \<open>\<forall>r\<in>R. wf (r - Id)\<close> and wf_Union_wf_init_segs [OF Chains_inits_DiffI [OF Ris]]
show ?thesis by fastforce
qed
- ultimately have "Well_order (\<Union>R)" by(simp add:order_on_defs)
- moreover have "\<forall>r \<in> R. r initial_segment_of \<Union>R" using Ris
- by(simp add: Chains_init_seg_of_Union)
- ultimately have "\<Union>R \<in> ?WO \<and> (\<forall>r\<in>R. (r, \<Union>R) \<in> I)"
+ ultimately have "Well_order (\<Union>R)"
+ by (simp add:order_on_defs)
+ moreover have "\<forall>r \<in> R. r initial_segment_of \<Union>R"
+ using Ris by (simp add: Chains_init_seg_of_Union)
+ ultimately show ?thesis
using mono_Chains [OF I_init] Chains_wo[of R] and \<open>R \<in> Chains I\<close>
unfolding I_def by blast
- }
- hence 1: "\<forall>R \<in> Chains I. \<exists>u\<in>Field I. \<forall>r\<in>R. (r, u) \<in> I" by (subst FI) blast
-\<comment>\<open>Zorn's Lemma yields a maximal well-order m:\<close>
- then obtain m::"'a rel" where "Well_order m" and
- max: "\<forall>r. Well_order r \<and> (m, r) \<in> I \<longrightarrow> r = m"
+ qed
+ then have 1: "\<forall>R \<in> Chains I. \<exists>u\<in>Field I. \<forall>r\<in>R. (r, u) \<in> I"
+ by (subst FI) blast
+\<comment>\<open>Zorn's Lemma yields a maximal well-order \<open>m\<close>:\<close>
+ then obtain m :: "'a rel"
+ where "Well_order m"
+ and max: "\<forall>r. Well_order r \<and> (m, r) \<in> I \<longrightarrow> r = m"
using Zorns_po_lemma[OF 0 1] unfolding FI by fastforce
-\<comment>\<open>Now show by contradiction that m covers the whole type:\<close>
- { fix x::'a assume "x \<notin> Field m"
-\<comment>\<open>We assume that x is not covered and extend m at the top with x\<close>
+\<comment>\<open>Now show by contradiction that \<open>m\<close> covers the whole type:\<close>
+ have False if "x \<notin> Field m" for x :: 'a
+ proof -
+\<comment>\<open>Assuming that \<open>x\<close> is not covered and extend \<open>m\<close> at the top with \<open>x\<close>\<close>
have "m \<noteq> {}"
proof
assume "m = {}"
@@ -663,10 +714,10 @@
ultimately show False using max
by (auto simp: I_def init_seg_of_def simp del: Field_insert)
qed
- hence "Field m \<noteq> {}" by(auto simp:Field_def)
- moreover have "wf (m - Id)" using \<open>Well_order m\<close>
- by (simp add: well_order_on_def)
-\<comment>\<open>The extension of m by x:\<close>
+ then have "Field m \<noteq> {}" by (auto simp: Field_def)
+ moreover have "wf (m - Id)"
+ using \<open>Well_order m\<close> by (simp add: well_order_on_def)
+\<comment>\<open>The extension of \<open>m\<close> by \<open>x\<close>:\<close>
let ?s = "{(a, x) | a. a \<in> Field m}"
let ?m = "insert (x, x) m \<union> ?s"
have Fm: "Field ?m = insert x (Field m)"
@@ -674,49 +725,58 @@
have "Refl m" and "trans m" and "antisym m" and "Total m" and "wf (m - Id)"
using \<open>Well_order m\<close> by (simp_all add: order_on_defs)
\<comment>\<open>We show that the extension is a well-order\<close>
- have "Refl ?m" using \<open>Refl m\<close> Fm unfolding refl_on_def by blast
+ have "Refl ?m"
+ using \<open>Refl m\<close> Fm unfolding refl_on_def by blast
moreover have "trans ?m" using \<open>trans m\<close> and \<open>x \<notin> Field m\<close>
unfolding trans_def Field_def by blast
- moreover have "antisym ?m" using \<open>antisym m\<close> and \<open>x \<notin> Field m\<close>
- unfolding antisym_def Field_def by blast
- moreover have "Total ?m" using \<open>Total m\<close> and Fm by (auto simp: total_on_def)
+ moreover have "antisym ?m"
+ using \<open>antisym m\<close> and \<open>x \<notin> Field m\<close> unfolding antisym_def Field_def by blast
+ moreover have "Total ?m"
+ using \<open>Total m\<close> and Fm by (auto simp: total_on_def)
moreover have "wf (?m - Id)"
proof -
- have "wf ?s" using \<open>x \<notin> Field m\<close>
- by (auto simp: wf_eq_minimal Field_def Bex_def)
- thus ?thesis using \<open>wf (m - Id)\<close> and \<open>x \<notin> Field m\<close>
- wf_subset [OF \<open>wf ?s\<close> Diff_subset]
+ have "wf ?s"
+ using \<open>x \<notin> Field m\<close> by (auto simp: wf_eq_minimal Field_def Bex_def)
+ then show ?thesis
+ using \<open>wf (m - Id)\<close> and \<open>x \<notin> Field m\<close> wf_subset [OF \<open>wf ?s\<close> Diff_subset]
by (auto simp: Un_Diff Field_def intro: wf_Un)
qed
- ultimately have "Well_order ?m" by (simp add: order_on_defs)
-\<comment>\<open>We show that the extension is above m\<close>
- moreover have "(m, ?m) \<in> I" using \<open>Well_order ?m\<close> and \<open>Well_order m\<close> and \<open>x \<notin> Field m\<close>
+ ultimately have "Well_order ?m"
+ by (simp add: order_on_defs)
+\<comment>\<open>We show that the extension is above \<open>m\<close>\<close>
+ moreover have "(m, ?m) \<in> I"
+ using \<open>Well_order ?m\<close> and \<open>Well_order m\<close> and \<open>x \<notin> Field m\<close>
by (fastforce simp: I_def init_seg_of_def Field_def)
ultimately
-\<comment>\<open>This contradicts maximality of m:\<close>
- have False using max and \<open>x \<notin> Field m\<close> unfolding Field_def by blast
- }
- hence "Field m = UNIV" by auto
+\<comment>\<open>This contradicts maximality of \<open>m\<close>:\<close>
+ show False
+ using max and \<open>x \<notin> Field m\<close> unfolding Field_def by blast
+ qed
+ then have "Field m = UNIV" by auto
with \<open>Well_order m\<close> show ?thesis by blast
qed
corollary well_order_on: "\<exists>r::'a rel. well_order_on A r"
proof -
- obtain r::"'a rel" where wo: "Well_order r" and univ: "Field r = UNIV"
+ obtain r :: "'a rel" where wo: "Well_order r" and univ: "Field r = UNIV"
using well_ordering [where 'a = "'a"] by blast
let ?r = "{(x, y). x \<in> A \<and> y \<in> A \<and> (x, y) \<in> r}"
- have 1: "Field ?r = A" using wo univ
- by (fastforce simp: Field_def order_on_defs refl_on_def)
- have "Refl r" and "trans r" and "antisym r" and "Total r" and "wf (r - Id)"
- using \<open>Well_order r\<close> by (simp_all add: order_on_defs)
- have "Refl ?r" using \<open>Refl r\<close> by (auto simp: refl_on_def 1 univ)
- moreover have "trans ?r" using \<open>trans r\<close>
+ have 1: "Field ?r = A"
+ using wo univ by (fastforce simp: Field_def order_on_defs refl_on_def)
+ from \<open>Well_order r\<close> have "Refl r" "trans r" "antisym r" "Total r" "wf (r - Id)"
+ by (simp_all add: order_on_defs)
+ from \<open>Refl r\<close> have "Refl ?r"
+ by (auto simp: refl_on_def 1 univ)
+ moreover from \<open>trans r\<close> have "trans ?r"
unfolding trans_def by blast
- moreover have "antisym ?r" using \<open>antisym r\<close>
+ moreover from \<open>antisym r\<close> have "antisym ?r"
unfolding antisym_def by blast
- moreover have "Total ?r" using \<open>Total r\<close> by (simp add:total_on_def 1 univ)
- moreover have "wf (?r - Id)" by (rule wf_subset [OF \<open>wf (r - Id)\<close>]) blast
- ultimately have "Well_order ?r" by (simp add: order_on_defs)
+ moreover from \<open>Total r\<close> have "Total ?r"
+ by (simp add:total_on_def 1 univ)
+ moreover have "wf (?r - Id)"
+ by (rule wf_subset [OF \<open>wf (r - Id)\<close>]) blast
+ ultimately have "Well_order ?r"
+ by (simp add: order_on_defs)
with 1 show ?thesis by auto
qed
@@ -727,15 +787,16 @@
lemma dependent_wf_choice:
fixes P :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
- assumes "wf R" and adm: "\<And>f g x r. (\<And>z. (z, x) \<in> R \<Longrightarrow> f z = g z) \<Longrightarrow> P f x r = P g x r"
- assumes P: "\<And>x f. (\<And>y. (y, x) \<in> R \<Longrightarrow> P f y (f y)) \<Longrightarrow> \<exists>r. P f x r"
+ assumes "wf R"
+ and adm: "\<And>f g x r. (\<And>z. (z, x) \<in> R \<Longrightarrow> f z = g z) \<Longrightarrow> P f x r = P g x r"
+ and P: "\<And>x f. (\<And>y. (y, x) \<in> R \<Longrightarrow> P f y (f y)) \<Longrightarrow> \<exists>r. P f x r"
shows "\<exists>f. \<forall>x. P f x (f x)"
proof (intro exI allI)
- fix x
+ fix x
define f where "f \<equiv> wfrec R (\<lambda>f x. SOME r. P f x r)"
from \<open>wf R\<close> show "P f x (f x)"
proof (induct x)
- fix x assume "\<And>y. (y, x) \<in> R \<Longrightarrow> P f y (f y)"
+ case (less x)
show "P f x (f x)"
proof (subst (2) wfrec_def_adm[OF f_def \<open>wf R\<close>])
show "adm_wf R (\<lambda>f x. SOME r. P f x r)"
@@ -748,7 +809,7 @@
lemma (in wellorder) dependent_wellorder_choice:
assumes "\<And>r f g x. (\<And>y. y < x \<Longrightarrow> f y = g y) \<Longrightarrow> P f x r = P g x r"
- assumes P: "\<And>x f. (\<And>y. y < x \<Longrightarrow> P f y (f y)) \<Longrightarrow> \<exists>r. P f x r"
+ and P: "\<And>x f. (\<And>y. y < x \<Longrightarrow> P f y (f y)) \<Longrightarrow> \<exists>r. P f x r"
shows "\<exists>f. \<forall>x. P f x (f x)"
using wf by (rule dependent_wf_choice) (auto intro!: assms)