| author | nipkow | 
| Mon, 16 Sep 2019 18:00:27 +0200 | |
| changeset 70708 | 3e11f35496b3 | 
| parent 70180 | 5beca7396282 | 
| child 75669 | 43f5dfb7fa35 | 
| permissions | -rw-r--r-- | 
| 54552 
5d57cbec0f0f
moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
 blanchet parents: 
54551diff
changeset | 1 | (* Title: HOL/Order_Relation.thy | 
| 
5d57cbec0f0f
moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
 blanchet parents: 
54551diff
changeset | 2 | Author: Tobias Nipkow | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 3 | Author: Andrei Popescu, TU Muenchen | 
| 54552 
5d57cbec0f0f
moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
 blanchet parents: 
54551diff
changeset | 4 | *) | 
| 26273 | 5 | |
| 60758 | 6 | section \<open>Orders as Relations\<close> | 
| 26273 | 7 | |
| 8 | theory Order_Relation | |
| 55027 | 9 | imports Wfrec | 
| 26273 | 10 | begin | 
| 11 | ||
| 63572 | 12 | subsection \<open>Orders on a set\<close> | 
| 26295 | 13 | |
| 30198 | 14 | definition "preorder_on A r \<equiv> refl_on A r \<and> trans r" | 
| 26295 | 15 | |
| 16 | definition "partial_order_on A r \<equiv> preorder_on A r \<and> antisym r" | |
| 26273 | 17 | |
| 26295 | 18 | definition "linear_order_on A r \<equiv> partial_order_on A r \<and> total_on A r" | 
| 19 | ||
| 20 | definition "strict_linear_order_on A r \<equiv> trans r \<and> irrefl r \<and> total_on A r" | |
| 21 | ||
| 22 | definition "well_order_on A r \<equiv> linear_order_on A r \<and> wf(r - Id)" | |
| 26273 | 23 | |
| 26295 | 24 | lemmas order_on_defs = | 
| 25 | preorder_on_def partial_order_on_def linear_order_on_def | |
| 26 | strict_linear_order_on_def well_order_on_def | |
| 27 | ||
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 28 | lemma partial_order_onD: | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 29 | assumes "partial_order_on A r" shows "refl_on A r" and "trans r" and "antisym r" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 30 | using assms unfolding partial_order_on_def preorder_on_def by auto | 
| 26273 | 31 | |
| 26295 | 32 | lemma preorder_on_empty[simp]: "preorder_on {} {}"
 | 
| 63572 | 33 | by (simp add: preorder_on_def trans_def) | 
| 26295 | 34 | |
| 35 | lemma partial_order_on_empty[simp]: "partial_order_on {} {}"
 | |
| 63572 | 36 | by (simp add: partial_order_on_def) | 
| 26273 | 37 | |
| 26295 | 38 | lemma lnear_order_on_empty[simp]: "linear_order_on {} {}"
 | 
| 63572 | 39 | by (simp add: linear_order_on_def) | 
| 26295 | 40 | |
| 41 | lemma well_order_on_empty[simp]: "well_order_on {} {}"
 | |
| 63572 | 42 | by (simp add: well_order_on_def) | 
| 26295 | 43 | |
| 26273 | 44 | |
| 63572 | 45 | lemma preorder_on_converse[simp]: "preorder_on A (r\<inverse>) = preorder_on A r" | 
| 46 | by (simp add: preorder_on_def) | |
| 26295 | 47 | |
| 63572 | 48 | lemma partial_order_on_converse[simp]: "partial_order_on A (r\<inverse>) = partial_order_on A r" | 
| 49 | by (simp add: partial_order_on_def) | |
| 26273 | 50 | |
| 63572 | 51 | lemma linear_order_on_converse[simp]: "linear_order_on A (r\<inverse>) = linear_order_on A r" | 
| 52 | by (simp add: linear_order_on_def) | |
| 26295 | 53 | |
| 26273 | 54 | |
| 70180 | 55 | lemma partial_order_on_acyclic: | 
| 56 | "partial_order_on A r \<Longrightarrow> acyclic (r - Id)" | |
| 57 | by (simp add: acyclic_irrefl partial_order_on_def preorder_on_def trans_diff_Id) | |
| 58 | ||
| 59 | lemma partial_order_on_well_order_on: | |
| 60 | "finite r \<Longrightarrow> partial_order_on A r \<Longrightarrow> wf (r - Id)" | |
| 61 | by (simp add: finite_acyclic_wf partial_order_on_acyclic) | |
| 62 | ||
| 63572 | 63 | lemma strict_linear_order_on_diff_Id: "linear_order_on A r \<Longrightarrow> strict_linear_order_on A (r - Id)" | 
| 64 | by (simp add: order_on_defs trans_diff_Id) | |
| 26295 | 65 | |
| 63563 
0bcd79da075b
prefer [simp] over [iff] as [iff] break HOL-UNITY
 Andreas Lochbihler parents: 
63561diff
changeset | 66 | lemma linear_order_on_singleton [simp]: "linear_order_on {x} {(x, x)}"
 | 
| 63572 | 67 | by (simp add: order_on_defs) | 
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 68 | |
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 69 | lemma linear_order_on_acyclic: | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 70 | assumes "linear_order_on A r" | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 71 | shows "acyclic (r - Id)" | 
| 63572 | 72 | using strict_linear_order_on_diff_Id[OF assms] | 
| 73 | by (auto simp add: acyclic_irrefl strict_linear_order_on_def) | |
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 74 | |
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 75 | lemma linear_order_on_well_order_on: | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 76 | assumes "finite r" | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 77 | shows "linear_order_on A r \<longleftrightarrow> well_order_on A r" | 
| 63572 | 78 | unfolding well_order_on_def | 
| 79 | using assms finite_acyclic_wf[OF _ linear_order_on_acyclic, of r] by blast | |
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 80 | |
| 26295 | 81 | |
| 63572 | 82 | subsection \<open>Orders on the field\<close> | 
| 26273 | 83 | |
| 30198 | 84 | abbreviation "Refl r \<equiv> refl_on (Field r) r" | 
| 26295 | 85 | |
| 86 | abbreviation "Preorder r \<equiv> preorder_on (Field r) r" | |
| 87 | ||
| 88 | abbreviation "Partial_order r \<equiv> partial_order_on (Field r) r" | |
| 26273 | 89 | |
| 26295 | 90 | abbreviation "Total r \<equiv> total_on (Field r) r" | 
| 91 | ||
| 92 | abbreviation "Linear_order r \<equiv> linear_order_on (Field r) r" | |
| 93 | ||
| 94 | abbreviation "Well_order r \<equiv> well_order_on (Field r) r" | |
| 95 | ||
| 26273 | 96 | |
| 97 | lemma subset_Image_Image_iff: | |
| 63572 | 98 | "Preorder r \<Longrightarrow> A \<subseteq> Field r \<Longrightarrow> B \<subseteq> Field r \<Longrightarrow> | 
| 99 | r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b, a) \<in> r)" | |
| 100 | apply (simp add: preorder_on_def refl_on_def Image_def subset_eq) | |
| 101 | apply (simp only: trans_def) | |
| 102 | apply fast | |
| 103 | done | |
| 26273 | 104 | |
| 105 | lemma subset_Image1_Image1_iff: | |
| 63572 | 106 |   "Preorder r \<Longrightarrow> a \<in> Field r \<Longrightarrow> b \<in> Field r \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b, a) \<in> r"
 | 
| 107 | by (simp add: subset_Image_Image_iff) | |
| 26273 | 108 | |
| 109 | lemma Refl_antisym_eq_Image1_Image1_iff: | |
| 63572 | 110 | assumes "Refl r" | 
| 111 | and as: "antisym r" | |
| 112 | and abf: "a \<in> Field r" "b \<in> Field r" | |
| 54552 
5d57cbec0f0f
moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
 blanchet parents: 
54551diff
changeset | 113 |   shows "r `` {a} = r `` {b} \<longleftrightarrow> a = b"
 | 
| 63572 | 114 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 54552 
5d57cbec0f0f
moving 'Order_Relation' to 'HOL' (since it's a BNF dependency)
 blanchet parents: 
54551diff
changeset | 115 | proof | 
| 63572 | 116 | assume ?lhs | 
| 117 | then have *: "\<And>x. (a, x) \<in> r \<longleftrightarrow> (b, x) \<in> r" | |
| 118 | by (simp add: set_eq_iff) | |
| 119 | have "(a, a) \<in> r" "(b, b) \<in> r" using \<open>Refl r\<close> abf by (simp_all add: refl_on_def) | |
| 120 | then have "(a, b) \<in> r" "(b, a) \<in> r" using *[of a] *[of b] by simp_all | |
| 121 | then show ?rhs | |
| 122 | using \<open>antisym r\<close>[unfolded antisym_def] by blast | |
| 123 | next | |
| 124 | assume ?rhs | |
| 125 | then show ?lhs by fast | |
| 126 | qed | |
| 26273 | 127 | |
| 128 | lemma Partial_order_eq_Image1_Image1_iff: | |
| 63572 | 129 |   "Partial_order r \<Longrightarrow> a \<in> Field r \<Longrightarrow> b \<in> Field r \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a = b"
 | 
| 130 | by (auto simp: order_on_defs Refl_antisym_eq_Image1_Image1_iff) | |
| 26295 | 131 | |
| 52182 | 132 | lemma Total_Id_Field: | 
| 63572 | 133 | assumes "Total r" | 
| 134 | and not_Id: "\<not> r \<subseteq> Id" | |
| 135 | shows "Field r = Field (r - Id)" | |
| 136 | using mono_Field[of "r - Id" r] Diff_subset[of r Id] | |
| 137 | proof auto | |
| 52182 | 138 | fix a assume *: "a \<in> Field r" | 
| 63572 | 139 |   from not_Id have "r \<noteq> {}" by fast
 | 
| 140 | with not_Id obtain b and c where "b \<noteq> c \<and> (b,c) \<in> r" by auto | |
| 141 |   then have "b \<noteq> c \<and> {b, c} \<subseteq> Field r" by (auto simp: Field_def)
 | |
| 142 | with * obtain d where "d \<in> Field r" "d \<noteq> a" by auto | |
| 143 | with * \<open>Total r\<close> have "(a, d) \<in> r \<or> (d, a) \<in> r" by (simp add: total_on_def) | |
| 144 | with \<open>d \<noteq> a\<close> show "a \<in> Field (r - Id)" unfolding Field_def by blast | |
| 52182 | 145 | qed | 
| 146 | ||
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 147 | subsection\<open>Relations given by a predicate and the field\<close> | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 148 | |
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 149 | definition relation_of :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set"
 | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 150 |   where "relation_of P A \<equiv> { (a, b) \<in> A \<times> A. P a b }"
 | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 151 | |
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 152 | lemma Field_relation_of: | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 153 | assumes "refl_on A (relation_of P A)" shows "Field (relation_of P A) = A" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 154 | using assms unfolding refl_on_def Field_def by auto | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 155 | |
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 156 | lemma partial_order_on_relation_ofI: | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 157 | assumes refl: "\<And>a. a \<in> A \<Longrightarrow> P a a" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 158 | and trans: "\<And>a b c. \<lbrakk> a \<in> A; b \<in> A; c \<in> A \<rbrakk> \<Longrightarrow> P a b \<Longrightarrow> P b c \<Longrightarrow> P a c" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 159 | and antisym: "\<And>a b. \<lbrakk> a \<in> A; b \<in> A \<rbrakk> \<Longrightarrow> P a b \<Longrightarrow> P b a \<Longrightarrow> a = b" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 160 | shows "partial_order_on A (relation_of P A)" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 161 | proof - | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 162 | from refl have "refl_on A (relation_of P A)" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 163 | unfolding refl_on_def relation_of_def by auto | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 164 | moreover have "trans (relation_of P A)" and "antisym (relation_of P A)" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 165 | unfolding relation_of_def | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 166 | by (auto intro: transI dest: trans, auto intro: antisymI dest: antisym) | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 167 | ultimately show ?thesis | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 168 | unfolding partial_order_on_def preorder_on_def by simp | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 169 | qed | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 170 | |
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 171 | lemma Partial_order_relation_ofI: | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 172 | assumes "partial_order_on A (relation_of P A)" shows "Partial_order (relation_of P A)" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 173 | using Field_relation_of assms partial_order_on_def preorder_on_def by fastforce | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 174 | |
| 26295 | 175 | |
| 63572 | 176 | subsection \<open>Orders on a type\<close> | 
| 26295 | 177 | |
| 178 | abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV" | |
| 179 | ||
| 180 | abbreviation "linear_order \<equiv> linear_order_on UNIV" | |
| 181 | ||
| 54551 | 182 | abbreviation "well_order \<equiv> well_order_on UNIV" | 
| 26273 | 183 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 184 | |
| 60758 | 185 | subsection \<open>Order-like relations\<close> | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 186 | |
| 63572 | 187 | text \<open> | 
| 188 | In this subsection, we develop basic concepts and results pertaining | |
| 189 | to order-like relations, i.e., to reflexive and/or transitive and/or symmetric and/or | |
| 190 | total relations. We also further define upper and lower bounds operators. | |
| 191 | \<close> | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 192 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 193 | |
| 60758 | 194 | subsubsection \<open>Auxiliaries\<close> | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 195 | |
| 63572 | 196 | lemma refl_on_domain: "refl_on A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> a \<in> A \<and> b \<in> A" | 
| 197 | by (auto simp add: refl_on_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 198 | |
| 63572 | 199 | corollary well_order_on_domain: "well_order_on A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> a \<in> A \<and> b \<in> A" | 
| 200 | by (auto simp add: refl_on_domain order_on_defs) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 201 | |
| 63572 | 202 | lemma well_order_on_Field: "well_order_on A r \<Longrightarrow> A = Field r" | 
| 203 | by (auto simp add: refl_on_def Field_def order_on_defs) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 204 | |
| 63572 | 205 | lemma well_order_on_Well_order: "well_order_on A r \<Longrightarrow> A = Field r \<and> Well_order r" | 
| 206 | using well_order_on_Field [of A] by auto | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 207 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 208 | lemma Total_subset_Id: | 
| 63572 | 209 | assumes "Total r" | 
| 210 | and "r \<subseteq> Id" | |
| 211 |   shows "r = {} \<or> (\<exists>a. r = {(a, a)})"
 | |
| 212 | proof - | |
| 213 |   have "\<exists>a. r = {(a, a)}" if "r \<noteq> {}"
 | |
| 214 | proof - | |
| 215 | from that obtain a b where ab: "(a, b) \<in> r" by fast | |
| 216 | with \<open>r \<subseteq> Id\<close> have "a = b" by blast | |
| 217 | with ab have aa: "(a, a) \<in> r" by simp | |
| 218 | have "a = c \<and> a = d" if "(c, d) \<in> r" for c d | |
| 219 | proof - | |
| 220 |       from that have "{a, c, d} \<subseteq> Field r"
 | |
| 221 | using ab unfolding Field_def by blast | |
| 222 | 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)" | |
| 223 | using \<open>Total r\<close> unfolding total_on_def by blast | |
| 224 | with \<open>r \<subseteq> Id\<close> show ?thesis by blast | |
| 225 | qed | |
| 226 |     then have "r \<subseteq> {(a, a)}" by auto
 | |
| 227 | with aa show ?thesis by blast | |
| 228 | qed | |
| 229 | then show ?thesis by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 230 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 231 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 232 | lemma Linear_order_in_diff_Id: | 
| 63572 | 233 | assumes "Linear_order r" | 
| 234 | and "a \<in> Field r" | |
| 235 | and "b \<in> Field r" | |
| 236 | shows "(a, b) \<in> r \<longleftrightarrow> (b, a) \<notin> r - Id" | |
| 237 | using assms unfolding order_on_defs total_on_def antisym_def Id_def refl_on_def by force | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 238 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 239 | |
| 60758 | 240 | subsubsection \<open>The upper and lower bounds operators\<close> | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 241 | |
| 63572 | 242 | text \<open> | 
| 243 | Here we define upper (``above") and lower (``below") bounds operators. We | |
| 244 | think of \<open>r\<close> as a \<^emph>\<open>non-strict\<close> relation. The suffix \<open>S\<close> at the names of | |
| 245 | some operators indicates that the bounds are strict -- e.g., \<open>underS a\<close> is | |
| 246 | the set of all strict lower bounds of \<open>a\<close> (w.r.t. \<open>r\<close>). Capitalization of | |
| 247 | the first letter in the name reminds that the operator acts on sets, rather | |
| 248 | than on individual elements. | |
| 249 | \<close> | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 250 | |
| 63572 | 251 | definition under :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 252 |   where "under r a \<equiv> {b. (b, a) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 253 | |
| 63572 | 254 | definition underS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 255 |   where "underS r a \<equiv> {b. b \<noteq> a \<and> (b, a) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 256 | |
| 63572 | 257 | definition Under :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 258 |   where "Under r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (b, a) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 259 | |
| 63572 | 260 | definition UnderS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 261 |   where "UnderS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (b, a) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 262 | |
| 63572 | 263 | definition above :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 264 |   where "above r a \<equiv> {b. (a, b) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 265 | |
| 63572 | 266 | definition aboveS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 267 |   where "aboveS r a \<equiv> {b. b \<noteq> a \<and> (a, b) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 268 | |
| 63572 | 269 | definition Above :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 270 |   where "Above r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. (a, b) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 271 | |
| 63572 | 272 | definition AboveS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 273 |   where "AboveS r A \<equiv> {b \<in> Field r. \<forall>a \<in> A. b \<noteq> a \<and> (a, b) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 274 | |
| 55173 | 275 | definition ofilter :: "'a rel \<Rightarrow> 'a set \<Rightarrow> bool" | 
| 63572 | 276 | where "ofilter r A \<equiv> A \<subseteq> Field r \<and> (\<forall>a \<in> A. under r a \<subseteq> A)" | 
| 55173 | 277 | |
| 63572 | 278 | text \<open> | 
| 279 | Note: In the definitions of \<open>Above[S]\<close> and \<open>Under[S]\<close>, we bounded | |
| 280 | comprehension by \<open>Field r\<close> in order to properly cover the case of \<open>A\<close> being | |
| 281 | empty. | |
| 282 | \<close> | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 283 | |
| 63572 | 284 | lemma underS_subset_under: "underS r a \<subseteq> under r a" | 
| 285 | by (auto simp add: underS_def under_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 286 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 287 | lemma underS_notIn: "a \<notin> underS r a" | 
| 63572 | 288 | by (simp add: underS_def) | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 289 | |
| 63572 | 290 | lemma Refl_under_in: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> a \<in> under r a" | 
| 291 | by (simp add: refl_on_def under_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 292 | |
| 63572 | 293 | lemma AboveS_disjoint: "A \<inter> (AboveS r A) = {}"
 | 
| 294 | by (auto simp add: AboveS_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 295 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 296 | lemma in_AboveS_underS: "a \<in> Field r \<Longrightarrow> a \<in> AboveS r (underS r a)" | 
| 63572 | 297 | by (auto simp add: AboveS_def underS_def) | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 298 | |
| 63572 | 299 | lemma Refl_under_underS: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> under r a = underS r a \<union> {a}"
 | 
| 300 | unfolding under_def underS_def | |
| 301 | using refl_on_def[of _ r] by fastforce | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 302 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 303 | lemma underS_empty: "a \<notin> Field r \<Longrightarrow> underS r a = {}"
 | 
| 63572 | 304 | by (auto simp: Field_def underS_def) | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 305 | |
| 63572 | 306 | lemma under_Field: "under r a \<subseteq> Field r" | 
| 307 | by (auto simp: under_def Field_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 308 | |
| 63572 | 309 | lemma underS_Field: "underS r a \<subseteq> Field r" | 
| 310 | by (auto simp: underS_def Field_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 311 | |
| 63572 | 312 | lemma underS_Field2: "a \<in> Field r \<Longrightarrow> underS r a \<subset> Field r" | 
| 313 | using underS_notIn underS_Field by fast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 314 | |
| 63572 | 315 | lemma underS_Field3: "Field r \<noteq> {} \<Longrightarrow> underS r a \<subset> Field r"
 | 
| 316 | by (cases "a \<in> Field r") (auto simp: underS_Field2 underS_empty) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 317 | |
| 63572 | 318 | lemma AboveS_Field: "AboveS r A \<subseteq> Field r" | 
| 319 | by (auto simp: AboveS_def Field_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 320 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 321 | lemma under_incr: | 
| 63572 | 322 | assumes "trans r" | 
| 323 | and "(a, b) \<in> r" | |
| 324 | shows "under r a \<subseteq> under r b" | |
| 325 | unfolding under_def | |
| 326 | proof auto | |
| 327 | fix x assume "(x, a) \<in> r" | |
| 328 | with assms trans_def[of r] show "(x, b) \<in> r" by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 329 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 330 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 331 | lemma underS_incr: | 
| 63572 | 332 | assumes "trans r" | 
| 333 | and "antisym r" | |
| 334 | and ab: "(a, b) \<in> r" | |
| 335 | shows "underS r a \<subseteq> underS r b" | |
| 336 | unfolding underS_def | |
| 337 | proof auto | |
| 338 | assume *: "b \<noteq> a" and **: "(b, a) \<in> r" | |
| 339 | with \<open>antisym r\<close> antisym_def[of r] ab show False | |
| 340 | by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 341 | next | 
| 63572 | 342 | fix x assume "x \<noteq> a" "(x, a) \<in> r" | 
| 343 | with ab \<open>trans r\<close> trans_def[of r] show "(x, b) \<in> r" | |
| 344 | by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 345 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 346 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 347 | lemma underS_incl_iff: | 
| 63572 | 348 | assumes LO: "Linear_order r" | 
| 349 | and INa: "a \<in> Field r" | |
| 350 | and INb: "b \<in> Field r" | |
| 351 | shows "underS r a \<subseteq> underS r b \<longleftrightarrow> (a, b) \<in> r" | |
| 352 | (is "?lhs \<longleftrightarrow> ?rhs") | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 353 | proof | 
| 63572 | 354 | assume ?rhs | 
| 355 | with \<open>Linear_order r\<close> show ?lhs | |
| 356 | by (simp add: order_on_defs underS_incr) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 357 | next | 
| 63572 | 358 | assume *: ?lhs | 
| 359 | have "(a, b) \<in> r" if "a = b" | |
| 360 | using assms that by (simp add: order_on_defs refl_on_def) | |
| 361 | moreover have False if "a \<noteq> b" "(b, a) \<in> r" | |
| 362 | proof - | |
| 363 | from that have "b \<in> underS r a" unfolding underS_def by blast | |
| 364 | with * have "b \<in> underS r b" by blast | |
| 365 | then show ?thesis by (simp add: underS_notIn) | |
| 366 | qed | |
| 367 | ultimately show "(a,b) \<in> r" | |
| 368 | using assms order_on_defs[of "Field r" r] total_on_def[of "Field r" r] by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 369 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 370 | |
| 70180 | 371 | lemma finite_Partial_order_induct[consumes 3, case_names step]: | 
| 372 | assumes "Partial_order r" | |
| 373 | and "x \<in> Field r" | |
| 374 | and "finite r" | |
| 375 | and step: "\<And>x. x \<in> Field r \<Longrightarrow> (\<And>y. y \<in> aboveS r x \<Longrightarrow> P y) \<Longrightarrow> P x" | |
| 376 | shows "P x" | |
| 377 | using assms(2) | |
| 378 | proof (induct rule: wf_induct[of "r\<inverse> - Id"]) | |
| 379 | case 1 | |
| 380 | from assms(1,3) show "wf (r\<inverse> - Id)" | |
| 381 | using partial_order_on_well_order_on partial_order_on_converse by blast | |
| 382 | next | |
| 383 | case prems: (2 x) | |
| 384 | show ?case | |
| 385 | by (rule step) (use prems in \<open>auto simp: aboveS_def intro: FieldI2\<close>) | |
| 386 | qed | |
| 387 | ||
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 388 | lemma finite_Linear_order_induct[consumes 3, case_names step]: | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 389 | assumes "Linear_order r" | 
| 63572 | 390 | and "x \<in> Field r" | 
| 391 | and "finite r" | |
| 392 | and step: "\<And>x. x \<in> Field r \<Longrightarrow> (\<And>y. y \<in> aboveS r x \<Longrightarrow> P y) \<Longrightarrow> P x" | |
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 393 | shows "P x" | 
| 63572 | 394 | using assms(2) | 
| 395 | proof (induct rule: wf_induct[of "r\<inverse> - Id"]) | |
| 396 | case 1 | |
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 397 | from assms(1,3) show "wf (r\<inverse> - Id)" | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 398 | using linear_order_on_well_order_on linear_order_on_converse | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 399 | unfolding well_order_on_def by blast | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 400 | next | 
| 63572 | 401 | case prems: (2 x) | 
| 402 | show ?case | |
| 403 | by (rule step) (use prems in \<open>auto simp: aboveS_def intro: FieldI2\<close>) | |
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 404 | qed | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 405 | |
| 55027 | 406 | |
| 60758 | 407 | subsection \<open>Variations on Well-Founded Relations\<close> | 
| 55027 | 408 | |
| 60758 | 409 | text \<open> | 
| 68484 | 410 | This subsection contains some variations of the results from \<^theory>\<open>HOL.Wellfounded\<close>: | 
| 63572 | 411 | \<^item> means for slightly more direct definitions by well-founded recursion; | 
| 412 | \<^item> variations of well-founded induction; | |
| 413 | \<^item> means for proving a linear order to be a well-order. | |
| 60758 | 414 | \<close> | 
| 55027 | 415 | |
| 416 | ||
| 60758 | 417 | subsubsection \<open>Characterizations of well-foundedness\<close> | 
| 55027 | 418 | |
| 63572 | 419 | text \<open> | 
| 420 | A transitive relation is well-founded iff it is ``locally'' well-founded, | |
| 421 | i.e., iff its restriction to the lower bounds of of any element is | |
| 422 | well-founded. | |
| 423 | \<close> | |
| 55027 | 424 | |
| 425 | lemma trans_wf_iff: | |
| 63572 | 426 | assumes "trans r" | 
| 427 |   shows "wf r \<longleftrightarrow> (\<forall>a. wf (r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})))"
 | |
| 428 | proof - | |
| 429 |   define R where "R a = r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})" for a
 | |
| 430 | have "wf (R a)" if "wf r" for a | |
| 431 | using that R_def wf_subset[of r "R a"] by auto | |
| 55027 | 432 | moreover | 
| 63572 | 433 | have "wf r" if *: "\<forall>a. wf(R a)" | 
| 434 | unfolding wf_def | |
| 435 | proof clarify | |
| 436 | fix phi a | |
| 437 | assume **: "\<forall>a. (\<forall>b. (b, a) \<in> r \<longrightarrow> phi b) \<longrightarrow> phi a" | |
| 438 | define chi where "chi b \<longleftrightarrow> (b, a) \<in> r \<longrightarrow> phi b" for b | |
| 439 | with * have "wf (R a)" by auto | |
| 440 | then have "(\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b) \<longrightarrow> (\<forall>b. chi b)" | |
| 441 | unfolding wf_def by blast | |
| 442 | also have "\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b" | |
| 443 | proof (auto simp add: chi_def R_def) | |
| 444 | fix b | |
| 445 | assume "(b, a) \<in> r" and "\<forall>c. (c, b) \<in> r \<and> (c, a) \<in> r \<longrightarrow> phi c" | |
| 446 | then have "\<forall>c. (c, b) \<in> r \<longrightarrow> phi c" | |
| 447 | using assms trans_def[of r] by blast | |
| 448 | with ** show "phi b" by blast | |
| 449 | qed | |
| 450 | finally have "\<forall>b. chi b" . | |
| 451 | with ** chi_def show "phi a" by blast | |
| 452 | qed | |
| 453 | ultimately show ?thesis unfolding R_def by blast | |
| 55027 | 454 | qed | 
| 455 | ||
| 63952 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 456 | text\<open>A transitive relation is well-founded if all initial segments are finite.\<close> | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 457 | corollary wf_finite_segments: | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 458 |   assumes "irrefl r" and "trans r" and "\<And>x. finite {y. (y, x) \<in> r}"
 | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 459 | shows "wf (r)" | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 460 | proof (clarsimp simp: trans_wf_iff wf_iff_acyclic_if_finite converse_def assms) | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 461 | fix a | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 462 |   have "trans (r \<inter> ({x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r}))"
 | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 463 | using assms unfolding trans_def Field_def by blast | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 464 |   then show "acyclic (r \<inter> {x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r})"
 | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 465 | using assms acyclic_def assms irrefl_def by fastforce | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 466 | qed | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 467 | |
| 61799 | 468 | text \<open>The next lemma is a variation of \<open>wf_eq_minimal\<close> from Wellfounded, | 
| 63572 | 469 | allowing one to assume the set included in the field.\<close> | 
| 55027 | 470 | |
| 63572 | 471 | 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))"
 | 
| 55027 | 472 | proof- | 
| 63572 | 473 |   let ?phi = "\<lambda>A. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r)"
 | 
| 474 | have "wf r \<longleftrightarrow> (\<forall>A. ?phi A)" | |
| 475 | apply (auto simp: ex_in_conv [THEN sym]) | |
| 476 | apply (erule wfE_min) | |
| 477 | apply assumption | |
| 478 | apply blast | |
| 479 | apply (rule wfI_min) | |
| 480 | apply fast | |
| 481 | done | |
| 482 | also have "(\<forall>A. ?phi A) \<longleftrightarrow> (\<forall>B \<subseteq> Field r. ?phi B)" | |
| 55027 | 483 | proof | 
| 484 | assume "\<forall>A. ?phi A" | |
| 63572 | 485 | then show "\<forall>B \<subseteq> Field r. ?phi B" by simp | 
| 55027 | 486 | next | 
| 63572 | 487 | assume *: "\<forall>B \<subseteq> Field r. ?phi B" | 
| 55027 | 488 | show "\<forall>A. ?phi A" | 
| 63572 | 489 | proof clarify | 
| 490 | fix A :: "'a set" | |
| 491 |       assume **: "A \<noteq> {}"
 | |
| 492 | define B where "B = A \<inter> Field r" | |
| 493 | show "\<exists>a \<in> A. \<forall>a' \<in> A. (a', a) \<notin> r" | |
| 494 |       proof (cases "B = {}")
 | |
| 495 | case True | |
| 496 | with ** obtain a where a: "a \<in> A" "a \<notin> Field r" | |
| 497 | unfolding B_def by blast | |
| 498 | with a have "\<forall>a' \<in> A. (a',a) \<notin> r" | |
| 499 | unfolding Field_def by blast | |
| 500 | with a show ?thesis by blast | |
| 55027 | 501 | next | 
| 63572 | 502 | case False | 
| 503 | have "B \<subseteq> Field r" unfolding B_def by blast | |
| 504 | with False * obtain a where a: "a \<in> B" "\<forall>a' \<in> B. (a', a) \<notin> r" | |
| 505 | by blast | |
| 506 | have "(a', a) \<notin> r" if "a' \<in> A" for a' | |
| 507 | proof | |
| 508 | assume a'a: "(a', a) \<in> r" | |
| 509 | with that have "a' \<in> B" unfolding B_def Field_def by blast | |
| 510 | with a a'a show False by blast | |
| 55027 | 511 | qed | 
| 63572 | 512 | with a show ?thesis unfolding B_def by blast | 
| 55027 | 513 | qed | 
| 514 | qed | |
| 515 | qed | |
| 516 | finally show ?thesis by blast | |
| 517 | qed | |
| 518 | ||
| 519 | ||
| 60758 | 520 | subsubsection \<open>Characterizations of well-foundedness\<close> | 
| 55027 | 521 | |
| 63572 | 522 | text \<open> | 
| 523 | The next lemma and its corollary enable one to prove that a linear order is | |
| 524 | a well-order in a way which is more standard than via well-foundedness of | |
| 525 | the strict version of the relation. | |
| 526 | \<close> | |
| 55027 | 527 | |
| 528 | lemma Linear_order_wf_diff_Id: | |
| 63572 | 529 | assumes "Linear_order r" | 
| 530 |   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))"
 | |
| 531 | proof (cases "r \<subseteq> Id") | |
| 532 | case True | |
| 533 |   then have *: "r - Id = {}" by blast
 | |
| 534 | have "wf (r - Id)" by (simp add: *) | |
| 535 | moreover have "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r" | |
| 536 |     if *: "A \<subseteq> Field r" and **: "A \<noteq> {}" for A
 | |
| 537 | proof - | |
| 538 | from \<open>Linear_order r\<close> True | |
| 539 |     obtain a where a: "r = {} \<or> r = {(a, a)}"
 | |
| 540 | unfolding order_on_defs using Total_subset_Id [of r] by blast | |
| 541 |     with * ** have "A = {a} \<and> r = {(a, a)}"
 | |
| 542 | unfolding Field_def by blast | |
| 543 | with a show ?thesis by blast | |
| 544 | qed | |
| 55027 | 545 | ultimately show ?thesis by blast | 
| 546 | next | |
| 63572 | 547 | case False | 
| 548 | with \<open>Linear_order r\<close> have Field: "Field r = Field (r - Id)" | |
| 549 | unfolding order_on_defs using Total_Id_Field [of r] by blast | |
| 55027 | 550 | show ?thesis | 
| 551 | proof | |
| 63572 | 552 | assume *: "wf (r - Id)" | 
| 553 |     show "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
 | |
| 554 | proof clarify | |
| 555 | fix A | |
| 556 |       assume **: "A \<subseteq> Field r" and ***: "A \<noteq> {}"
 | |
| 557 | then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id" | |
| 558 | using Field * unfolding wf_eq_minimal2 by simp | |
| 559 | moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id" | |
| 560 | using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** by blast | |
| 561 | ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r" by blast | |
| 55027 | 562 | qed | 
| 563 | next | |
| 63572 | 564 |     assume *: "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
 | 
| 565 | show "wf (r - Id)" | |
| 566 | unfolding wf_eq_minimal2 | |
| 567 | proof clarify | |
| 568 | fix A | |
| 569 |       assume **: "A \<subseteq> Field(r - Id)" and ***: "A \<noteq> {}"
 | |
| 570 | then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r" | |
| 571 | using Field * by simp | |
| 572 | moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id" | |
| 573 | using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** mono_Field[of "r - Id" r] by blast | |
| 574 | ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id" | |
| 575 | by blast | |
| 55027 | 576 | qed | 
| 577 | qed | |
| 578 | qed | |
| 579 | ||
| 580 | corollary Linear_order_Well_order_iff: | |
| 63572 | 581 | "Linear_order r \<Longrightarrow> | 
| 582 |     Well_order r \<longleftrightarrow> (\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r))"
 | |
| 583 | unfolding well_order_on_def using Linear_order_wf_diff_Id[of r] by blast | |
| 55027 | 584 | |
| 26273 | 585 | end |