| author | haftmann | 
| Sun, 30 Mar 2025 20:20:26 +0200 | |
| changeset 82388 | f1ff9123c62a | 
| parent 82252 | 8a7620fe0e83 | 
| 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 | |
| 82248 | 14 | definition "preorder_on A r \<equiv> r \<subseteq> A \<times> A \<and> 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: | 
| 82248 | 29 | assumes "partial_order_on A r" shows "refl_on A r" and "trans r" and "antisym r" and "r \<subseteq> A \<times> A" | 
| 68745 
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" | 
| 82248 | 46 | by (auto 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)" | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 136 | proof - | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 137 | have "Field r \<subseteq> Field (r - Id)" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 138 | proof (rule subsetI) | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 139 | fix a assume *: "a \<in> Field r" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 140 |     from not_Id have "r \<noteq> {}" by fast
 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 141 | with not_Id obtain b and c where "b \<noteq> c \<and> (b,c) \<in> r" by auto | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 142 |     then have "b \<noteq> c \<and> {b, c} \<subseteq> Field r" by (auto simp: Field_def)
 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 143 | with * obtain d where "d \<in> Field r" "d \<noteq> a" by auto | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 144 | with * \<open>Total r\<close> have "(a, d) \<in> r \<or> (d, a) \<in> r" by (simp add: total_on_def) | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 145 | with \<open>d \<noteq> a\<close> show "a \<in> Field (r - Id)" unfolding Field_def by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 146 | qed | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 147 | then show ?thesis | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 148 | using mono_Field[of "r - Id" r] Diff_subset[of r Id] by auto | 
| 52182 | 149 | qed | 
| 150 | ||
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 151 | 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 | 152 | |
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 153 | 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 | 154 |   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 | 155 | |
| 82252 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 156 | lemma refl_relation_ofD: "refl (relation_of R S) \<Longrightarrow> reflp_on S R" | 
| 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 157 | by (auto simp: relation_of_def intro: reflp_onI dest: reflD) | 
| 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 158 | |
| 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 159 | lemma irrefl_relation_ofD: "irrefl (relation_of R S) \<Longrightarrow> irreflp_on S R" | 
| 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 160 | by (auto simp: relation_of_def intro: irreflp_onI dest: irreflD) | 
| 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 161 | |
| 82251 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 162 | lemma sym_relation_of[simp]: "sym (relation_of R S) \<longleftrightarrow> symp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 163 | proof (rule iffI) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 164 | show "sym (relation_of R S) \<Longrightarrow> symp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 165 | by (auto simp: relation_of_def intro: symp_onI dest: symD) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 166 | next | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 167 | show "symp_on S R \<Longrightarrow> sym (relation_of R S)" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 168 | by (auto simp: relation_of_def intro: symI dest: symp_onD) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 169 | qed | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 170 | |
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 171 | lemma asym_relation_of[simp]: "asym (relation_of R S) \<longleftrightarrow> asymp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 172 | proof (rule iffI) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 173 | show "asym (relation_of R S) \<Longrightarrow> asymp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 174 | by (auto simp: relation_of_def intro: asymp_onI dest: asymD) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 175 | next | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 176 | show "asymp_on S R \<Longrightarrow> asym (relation_of R S)" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 177 | by (auto simp: relation_of_def intro: asymI dest: asymp_onD) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 178 | qed | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 179 | |
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 180 | lemma antisym_relation_of[simp]: "antisym (relation_of R S) \<longleftrightarrow> antisymp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 181 | proof (rule iffI) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 182 | show "antisym (relation_of R S) \<Longrightarrow> antisymp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 183 | by (simp add: antisym_on_def antisymp_on_def relation_of_def) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 184 | next | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 185 | show "antisymp_on S R \<Longrightarrow> antisym (relation_of R S)" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 186 | by (simp add: antisym_on_def antisymp_on_def relation_of_def) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 187 | qed | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 188 | |
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 189 | lemma trans_relation_of[simp]: "trans (relation_of R S) \<longleftrightarrow> transp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 190 | proof (rule iffI) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 191 | show "trans (relation_of R S) \<Longrightarrow> transp_on S R" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 192 | by (auto simp: relation_of_def intro: transp_onI dest: transD) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 193 | next | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 194 | show "transp_on S R \<Longrightarrow> trans (relation_of R S)" | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 195 | by (auto simp: relation_of_def intro: transI dest: transp_onD) | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 196 | qed | 
| 
8cf503824ccf
added lemmas antisym_relation_of[simp], asym_relation_of[simp], sym_relation_of[simp], trans_relation_of[simp]
 desharna parents: 
82248diff
changeset | 197 | |
| 82252 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 198 | lemma total_relation_ofD: "total (relation_of R S) \<Longrightarrow> totalp_on S R" | 
| 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 199 | by (auto simp: relation_of_def total_on_def intro: totalp_onI) | 
| 
8a7620fe0e83
added lemmas  irrefl_relation_ofD, refl_relation_ofD, total_relation_ofD
 desharna parents: 
82251diff
changeset | 200 | |
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 201 | lemma Field_relation_of: | 
| 82248 | 202 | assumes "relation_of P A \<subseteq> A \<times> A" and "refl_on A (relation_of P A)" | 
| 203 | shows "Field (relation_of P A) = A" | |
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 204 | 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 | 205 | |
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 206 | lemma partial_order_on_relation_ofI: | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 207 | 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 | 208 | 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 | 209 | 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 | 210 | 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 | 211 | proof - | 
| 82248 | 212 | have "relation_of P A \<subseteq> A \<times> A" | 
| 213 | unfolding relation_of_def by auto | |
| 214 | moreover have "refl_on A (relation_of P A)" | |
| 215 | using refl unfolding refl_on_def relation_of_def by auto | |
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 216 | 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 | 217 | unfolding relation_of_def | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 218 | 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 | 219 | ultimately show ?thesis | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 220 | 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 | 221 | qed | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 222 | |
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 223 | lemma Partial_order_relation_ofI: | 
| 82248 | 224 | assumes "partial_order_on A (relation_of P A)" | 
| 225 | shows "Partial_order (relation_of P A)" | |
| 226 | proof - | |
| 227 | have *: "Field (relation_of P A) = A" | |
| 228 | using assms by (simp_all only: Field_relation_of partial_order_on_def preorder_on_def) | |
| 229 | show ?thesis | |
| 230 | unfolding * | |
| 231 | using assms . | |
| 232 | qed | |
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
68484diff
changeset | 233 | |
| 26295 | 234 | |
| 63572 | 235 | subsection \<open>Orders on a type\<close> | 
| 26295 | 236 | |
| 237 | abbreviation "strict_linear_order \<equiv> strict_linear_order_on UNIV" | |
| 238 | ||
| 239 | abbreviation "linear_order \<equiv> linear_order_on UNIV" | |
| 240 | ||
| 54551 | 241 | abbreviation "well_order \<equiv> well_order_on UNIV" | 
| 26273 | 242 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 243 | |
| 60758 | 244 | subsection \<open>Order-like relations\<close> | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 245 | |
| 63572 | 246 | text \<open> | 
| 247 | In this subsection, we develop basic concepts and results pertaining | |
| 248 | to order-like relations, i.e., to reflexive and/or transitive and/or symmetric and/or | |
| 249 | total relations. We also further define upper and lower bounds operators. | |
| 250 | \<close> | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 251 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 252 | |
| 60758 | 253 | subsubsection \<open>Auxiliaries\<close> | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 254 | |
| 63572 | 255 | corollary well_order_on_domain: "well_order_on A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> a \<in> A \<and> b \<in> A" | 
| 82248 | 256 | by (auto simp add: order_on_defs) | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 257 | |
| 63572 | 258 | lemma well_order_on_Field: "well_order_on A r \<Longrightarrow> A = Field r" | 
| 259 | 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 | 260 | |
| 63572 | 261 | lemma well_order_on_Well_order: "well_order_on A r \<Longrightarrow> A = Field r \<and> Well_order r" | 
| 262 | using well_order_on_Field [of A] by auto | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 263 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 264 | lemma Total_subset_Id: | 
| 63572 | 265 | assumes "Total r" | 
| 266 | and "r \<subseteq> Id" | |
| 267 |   shows "r = {} \<or> (\<exists>a. r = {(a, a)})"
 | |
| 268 | proof - | |
| 269 |   have "\<exists>a. r = {(a, a)}" if "r \<noteq> {}"
 | |
| 270 | proof - | |
| 271 | from that obtain a b where ab: "(a, b) \<in> r" by fast | |
| 272 | with \<open>r \<subseteq> Id\<close> have "a = b" by blast | |
| 273 | with ab have aa: "(a, a) \<in> r" by simp | |
| 274 | have "a = c \<and> a = d" if "(c, d) \<in> r" for c d | |
| 275 | proof - | |
| 276 |       from that have "{a, c, d} \<subseteq> Field r"
 | |
| 277 | using ab unfolding Field_def by blast | |
| 278 | 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)" | |
| 279 | using \<open>Total r\<close> unfolding total_on_def by blast | |
| 280 | with \<open>r \<subseteq> Id\<close> show ?thesis by blast | |
| 281 | qed | |
| 282 |     then have "r \<subseteq> {(a, a)}" by auto
 | |
| 283 | with aa show ?thesis by blast | |
| 284 | qed | |
| 285 | then show ?thesis by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 286 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 287 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 288 | lemma Linear_order_in_diff_Id: | 
| 63572 | 289 | assumes "Linear_order r" | 
| 290 | and "a \<in> Field r" | |
| 291 | and "b \<in> Field r" | |
| 292 | shows "(a, b) \<in> r \<longleftrightarrow> (b, a) \<notin> r - Id" | |
| 293 | 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 | 294 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 295 | |
| 60758 | 296 | subsubsection \<open>The upper and lower bounds operators\<close> | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 297 | |
| 63572 | 298 | text \<open> | 
| 299 | Here we define upper (``above") and lower (``below") bounds operators. We | |
| 300 | think of \<open>r\<close> as a \<^emph>\<open>non-strict\<close> relation. The suffix \<open>S\<close> at the names of | |
| 301 | some operators indicates that the bounds are strict -- e.g., \<open>underS a\<close> is | |
| 302 | the set of all strict lower bounds of \<open>a\<close> (w.r.t. \<open>r\<close>). Capitalization of | |
| 303 | the first letter in the name reminds that the operator acts on sets, rather | |
| 304 | than on individual elements. | |
| 305 | \<close> | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 306 | |
| 63572 | 307 | definition under :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 308 |   where "under r a \<equiv> {b. (b, a) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 309 | |
| 63572 | 310 | definition underS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 311 |   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 | 312 | |
| 63572 | 313 | definition Under :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 314 |   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 | 315 | |
| 63572 | 316 | definition UnderS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 317 |   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 | 318 | |
| 63572 | 319 | definition above :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 320 |   where "above r a \<equiv> {b. (a, b) \<in> r}"
 | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 321 | |
| 63572 | 322 | definition aboveS :: "'a rel \<Rightarrow> 'a \<Rightarrow> 'a set" | 
| 323 |   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 | 324 | |
| 63572 | 325 | definition Above :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 326 |   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 | 327 | |
| 63572 | 328 | definition AboveS :: "'a rel \<Rightarrow> 'a set \<Rightarrow> 'a set" | 
| 329 |   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 | 330 | |
| 55173 | 331 | definition ofilter :: "'a rel \<Rightarrow> 'a set \<Rightarrow> bool" | 
| 63572 | 332 | where "ofilter r A \<equiv> A \<subseteq> Field r \<and> (\<forall>a \<in> A. under r a \<subseteq> A)" | 
| 55173 | 333 | |
| 63572 | 334 | text \<open> | 
| 335 | Note: In the definitions of \<open>Above[S]\<close> and \<open>Under[S]\<close>, we bounded | |
| 336 | comprehension by \<open>Field r\<close> in order to properly cover the case of \<open>A\<close> being | |
| 337 | empty. | |
| 338 | \<close> | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 339 | |
| 63572 | 340 | lemma underS_subset_under: "underS r a \<subseteq> under r a" | 
| 341 | by (auto simp add: underS_def under_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 342 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 343 | lemma underS_notIn: "a \<notin> underS r a" | 
| 63572 | 344 | by (simp add: underS_def) | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 345 | |
| 63572 | 346 | lemma Refl_under_in: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> a \<in> under r a" | 
| 347 | by (simp add: refl_on_def under_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 348 | |
| 63572 | 349 | lemma AboveS_disjoint: "A \<inter> (AboveS r A) = {}"
 | 
| 350 | by (auto simp add: AboveS_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 351 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 352 | lemma in_AboveS_underS: "a \<in> Field r \<Longrightarrow> a \<in> AboveS r (underS r a)" | 
| 63572 | 353 | by (auto simp add: AboveS_def underS_def) | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 354 | |
| 63572 | 355 | lemma Refl_under_underS: "Refl r \<Longrightarrow> a \<in> Field r \<Longrightarrow> under r a = underS r a \<union> {a}"
 | 
| 356 | unfolding under_def underS_def | |
| 357 | using refl_on_def[of _ r] by fastforce | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 358 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 359 | lemma underS_empty: "a \<notin> Field r \<Longrightarrow> underS r a = {}"
 | 
| 63572 | 360 | by (auto simp: Field_def underS_def) | 
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 361 | |
| 63572 | 362 | lemma under_Field: "under r a \<subseteq> Field r" | 
| 363 | by (auto simp: under_def Field_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 364 | |
| 63572 | 365 | lemma underS_Field: "underS r a \<subseteq> Field r" | 
| 366 | by (auto simp: underS_def Field_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 367 | |
| 63572 | 368 | lemma underS_Field2: "a \<in> Field r \<Longrightarrow> underS r a \<subset> Field r" | 
| 369 | using underS_notIn underS_Field by fast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 370 | |
| 63572 | 371 | lemma underS_Field3: "Field r \<noteq> {} \<Longrightarrow> underS r a \<subset> Field r"
 | 
| 372 | 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 | 373 | |
| 63572 | 374 | lemma AboveS_Field: "AboveS r A \<subseteq> Field r" | 
| 375 | by (auto simp: AboveS_def Field_def) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 376 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 377 | lemma under_incr: | 
| 63572 | 378 | assumes "trans r" | 
| 379 | and "(a, b) \<in> r" | |
| 380 | shows "under r a \<subseteq> under r b" | |
| 381 | unfolding under_def | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 382 | proof safe | 
| 63572 | 383 | fix x assume "(x, a) \<in> r" | 
| 384 | 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 | 385 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 386 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 387 | lemma underS_incr: | 
| 63572 | 388 | assumes "trans r" | 
| 389 | and "antisym r" | |
| 390 | and ab: "(a, b) \<in> r" | |
| 391 | shows "underS r a \<subseteq> underS r b" | |
| 392 | unfolding underS_def | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 393 | proof safe | 
| 63572 | 394 | assume *: "b \<noteq> a" and **: "(b, a) \<in> r" | 
| 395 | with \<open>antisym r\<close> antisym_def[of r] ab show False | |
| 396 | by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 397 | next | 
| 63572 | 398 | fix x assume "x \<noteq> a" "(x, a) \<in> r" | 
| 399 | with ab \<open>trans r\<close> trans_def[of r] show "(x, b) \<in> r" | |
| 400 | by blast | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 401 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 402 | |
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 403 | lemma underS_incl_iff: | 
| 63572 | 404 | assumes LO: "Linear_order r" | 
| 405 | and INa: "a \<in> Field r" | |
| 406 | and INb: "b \<in> Field r" | |
| 407 | shows "underS r a \<subseteq> underS r b \<longleftrightarrow> (a, b) \<in> r" | |
| 408 | (is "?lhs \<longleftrightarrow> ?rhs") | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 409 | proof | 
| 63572 | 410 | assume ?rhs | 
| 411 | with \<open>Linear_order r\<close> show ?lhs | |
| 412 | by (simp add: order_on_defs underS_incr) | |
| 55026 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 413 | next | 
| 63572 | 414 | assume *: ?lhs | 
| 415 | have "(a, b) \<in> r" if "a = b" | |
| 416 | using assms that by (simp add: order_on_defs refl_on_def) | |
| 417 | moreover have False if "a \<noteq> b" "(b, a) \<in> r" | |
| 418 | proof - | |
| 419 | from that have "b \<in> underS r a" unfolding underS_def by blast | |
| 420 | with * have "b \<in> underS r b" by blast | |
| 421 | then show ?thesis by (simp add: underS_notIn) | |
| 422 | qed | |
| 423 | ultimately show "(a,b) \<in> r" | |
| 424 | 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 | 425 | qed | 
| 
258fa7b5a621
folded 'Order_Relation_More_FP' into 'Order_Relation'
 blanchet parents: 
54552diff
changeset | 426 | |
| 70180 | 427 | lemma finite_Partial_order_induct[consumes 3, case_names step]: | 
| 428 | assumes "Partial_order r" | |
| 429 | and "x \<in> Field r" | |
| 430 | and "finite r" | |
| 431 | and step: "\<And>x. x \<in> Field r \<Longrightarrow> (\<And>y. y \<in> aboveS r x \<Longrightarrow> P y) \<Longrightarrow> P x" | |
| 432 | shows "P x" | |
| 433 | using assms(2) | |
| 434 | proof (induct rule: wf_induct[of "r\<inverse> - Id"]) | |
| 435 | case 1 | |
| 436 | from assms(1,3) show "wf (r\<inverse> - Id)" | |
| 437 | using partial_order_on_well_order_on partial_order_on_converse by blast | |
| 438 | next | |
| 439 | case prems: (2 x) | |
| 440 | show ?case | |
| 441 | by (rule step) (use prems in \<open>auto simp: aboveS_def intro: FieldI2\<close>) | |
| 442 | qed | |
| 443 | ||
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 444 | lemma finite_Linear_order_induct[consumes 3, case_names step]: | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 445 | assumes "Linear_order r" | 
| 63572 | 446 | and "x \<in> Field r" | 
| 447 | and "finite r" | |
| 448 | 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 | 449 | shows "P x" | 
| 63572 | 450 | using assms(2) | 
| 451 | proof (induct rule: wf_induct[of "r\<inverse> - Id"]) | |
| 452 | case 1 | |
| 63561 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 453 | from assms(1,3) show "wf (r\<inverse> - Id)" | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 454 | using linear_order_on_well_order_on linear_order_on_converse | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 455 | unfolding well_order_on_def by blast | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 456 | next | 
| 63572 | 457 | case prems: (2 x) | 
| 458 | show ?case | |
| 459 | 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 | 460 | qed | 
| 
fba08009ff3e
add lemmas contributed by Peter Gammie
 Andreas Lochbihler parents: 
61799diff
changeset | 461 | |
| 55027 | 462 | |
| 60758 | 463 | subsection \<open>Variations on Well-Founded Relations\<close> | 
| 55027 | 464 | |
| 60758 | 465 | text \<open> | 
| 68484 | 466 | This subsection contains some variations of the results from \<^theory>\<open>HOL.Wellfounded\<close>: | 
| 63572 | 467 | \<^item> means for slightly more direct definitions by well-founded recursion; | 
| 468 | \<^item> variations of well-founded induction; | |
| 469 | \<^item> means for proving a linear order to be a well-order. | |
| 60758 | 470 | \<close> | 
| 55027 | 471 | |
| 472 | ||
| 60758 | 473 | subsubsection \<open>Characterizations of well-foundedness\<close> | 
| 55027 | 474 | |
| 63572 | 475 | text \<open> | 
| 476 | A transitive relation is well-founded iff it is ``locally'' well-founded, | |
| 477 | i.e., iff its restriction to the lower bounds of of any element is | |
| 478 | well-founded. | |
| 479 | \<close> | |
| 55027 | 480 | |
| 481 | lemma trans_wf_iff: | |
| 63572 | 482 | assumes "trans r" | 
| 483 |   shows "wf r \<longleftrightarrow> (\<forall>a. wf (r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})))"
 | |
| 484 | proof - | |
| 485 |   define R where "R a = r \<inter> (r\<inverse>``{a} \<times> r\<inverse>``{a})" for a
 | |
| 486 | have "wf (R a)" if "wf r" for a | |
| 487 | using that R_def wf_subset[of r "R a"] by auto | |
| 55027 | 488 | moreover | 
| 63572 | 489 | have "wf r" if *: "\<forall>a. wf(R a)" | 
| 490 | unfolding wf_def | |
| 491 | proof clarify | |
| 492 | fix phi a | |
| 493 | assume **: "\<forall>a. (\<forall>b. (b, a) \<in> r \<longrightarrow> phi b) \<longrightarrow> phi a" | |
| 494 | define chi where "chi b \<longleftrightarrow> (b, a) \<in> r \<longrightarrow> phi b" for b | |
| 495 | with * have "wf (R a)" by auto | |
| 496 | then have "(\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b) \<longrightarrow> (\<forall>b. chi b)" | |
| 497 | unfolding wf_def by blast | |
| 498 | also have "\<forall>b. (\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c) \<longrightarrow> chi b" | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 499 | proof safe | 
| 63572 | 500 | fix b | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 501 | assume "\<forall>c. (c, b) \<in> R a \<longrightarrow> chi c" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 502 | moreover have "(b, a) \<in> r \<Longrightarrow> \<forall>c. (c, b) \<in> r \<and> (c, a) \<in> r \<longrightarrow> phi c \<Longrightarrow> phi b" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 503 | proof - | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 504 | assume "(b, a) \<in> r" and "\<forall>c. (c, b) \<in> r \<and> (c, a) \<in> r \<longrightarrow> phi c" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 505 | then have "\<forall>c. (c, b) \<in> r \<longrightarrow> phi c" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 506 | using assms trans_def[of r] by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 507 | with ** show "phi b" by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 508 | qed | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 509 | ultimately show "chi b" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 510 | by (auto simp add: chi_def R_def) | 
| 63572 | 511 | qed | 
| 512 | finally have "\<forall>b. chi b" . | |
| 513 | with ** chi_def show "phi a" by blast | |
| 514 | qed | |
| 515 | ultimately show ?thesis unfolding R_def by blast | |
| 55027 | 516 | qed | 
| 517 | ||
| 63952 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 518 | 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 | 519 | corollary wf_finite_segments: | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 520 |   assumes "irrefl r" and "trans r" and "\<And>x. finite {y. (y, x) \<in> r}"
 | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 521 | shows "wf r" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 522 | proof - | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 523 |   have "\<And>a. acyclic (r \<inter> {x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r})"
 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 524 | proof - | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 525 | fix a | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 526 |     have "trans (r \<inter> ({x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r}))"
 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 527 | using assms unfolding trans_def Field_def by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 528 |     then show "acyclic (r \<inter> {x. (x, a) \<in> r} \<times> {x. (x, a) \<in> r})"
 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 529 | using assms acyclic_def assms irrefl_def by fastforce | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 530 | qed | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 531 | then show ?thesis | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 532 | by (clarsimp simp: trans_wf_iff wf_iff_acyclic_if_finite converse_def assms) | 
| 63952 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 533 | qed | 
| 
354808e9f44b
new material connected with HOL Light measure theory, plus more rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63572diff
changeset | 534 | |
| 61799 | 535 | text \<open>The next lemma is a variation of \<open>wf_eq_minimal\<close> from Wellfounded, | 
| 63572 | 536 | allowing one to assume the set included in the field.\<close> | 
| 55027 | 537 | |
| 63572 | 538 | 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 | 539 | proof- | 
| 63572 | 540 |   let ?phi = "\<lambda>A. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r)"
 | 
| 541 | have "wf r \<longleftrightarrow> (\<forall>A. ?phi A)" | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 542 | proof | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 543 | assume "wf r" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 544 | show "\<forall>A. ?phi A" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 545 | proof clarify | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 546 | fix A:: "'a set" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 547 |       assume "A \<noteq> {}"
 | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 548 | then obtain x where "x \<in> A" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 549 | by auto | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 550 | show "\<exists>a\<in>A. \<forall>a'\<in>A. (a', a) \<notin> r" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 551 | apply (rule wfE_min[of r x A]) | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 552 | apply fact+ | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 553 | by blast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 554 | qed | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 555 | next | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 556 | assume *: "\<forall>A. ?phi A" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 557 | then show "wf r" | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 558 | apply (clarsimp simp: ex_in_conv [THEN sym]) | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 559 | apply (rule wfI_min) | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 560 | by fast | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
70180diff
changeset | 561 | qed | 
| 63572 | 562 | also have "(\<forall>A. ?phi A) \<longleftrightarrow> (\<forall>B \<subseteq> Field r. ?phi B)" | 
| 55027 | 563 | proof | 
| 564 | assume "\<forall>A. ?phi A" | |
| 63572 | 565 | then show "\<forall>B \<subseteq> Field r. ?phi B" by simp | 
| 55027 | 566 | next | 
| 63572 | 567 | assume *: "\<forall>B \<subseteq> Field r. ?phi B" | 
| 55027 | 568 | show "\<forall>A. ?phi A" | 
| 63572 | 569 | proof clarify | 
| 570 | fix A :: "'a set" | |
| 571 |       assume **: "A \<noteq> {}"
 | |
| 572 | define B where "B = A \<inter> Field r" | |
| 573 | show "\<exists>a \<in> A. \<forall>a' \<in> A. (a', a) \<notin> r" | |
| 574 |       proof (cases "B = {}")
 | |
| 575 | case True | |
| 576 | with ** obtain a where a: "a \<in> A" "a \<notin> Field r" | |
| 577 | unfolding B_def by blast | |
| 578 | with a have "\<forall>a' \<in> A. (a',a) \<notin> r" | |
| 579 | unfolding Field_def by blast | |
| 580 | with a show ?thesis by blast | |
| 55027 | 581 | next | 
| 63572 | 582 | case False | 
| 583 | have "B \<subseteq> Field r" unfolding B_def by blast | |
| 584 | with False * obtain a where a: "a \<in> B" "\<forall>a' \<in> B. (a', a) \<notin> r" | |
| 585 | by blast | |
| 586 | have "(a', a) \<notin> r" if "a' \<in> A" for a' | |
| 587 | proof | |
| 588 | assume a'a: "(a', a) \<in> r" | |
| 589 | with that have "a' \<in> B" unfolding B_def Field_def by blast | |
| 590 | with a a'a show False by blast | |
| 55027 | 591 | qed | 
| 63572 | 592 | with a show ?thesis unfolding B_def by blast | 
| 55027 | 593 | qed | 
| 594 | qed | |
| 595 | qed | |
| 596 | finally show ?thesis by blast | |
| 597 | qed | |
| 598 | ||
| 599 | ||
| 60758 | 600 | subsubsection \<open>Characterizations of well-foundedness\<close> | 
| 55027 | 601 | |
| 63572 | 602 | text \<open> | 
| 603 | The next lemma and its corollary enable one to prove that a linear order is | |
| 604 | a well-order in a way which is more standard than via well-foundedness of | |
| 605 | the strict version of the relation. | |
| 606 | \<close> | |
| 55027 | 607 | |
| 608 | lemma Linear_order_wf_diff_Id: | |
| 63572 | 609 | assumes "Linear_order r" | 
| 610 |   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))"
 | |
| 611 | proof (cases "r \<subseteq> Id") | |
| 612 | case True | |
| 613 |   then have *: "r - Id = {}" by blast
 | |
| 614 | have "wf (r - Id)" by (simp add: *) | |
| 615 | moreover have "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r" | |
| 616 |     if *: "A \<subseteq> Field r" and **: "A \<noteq> {}" for A
 | |
| 617 | proof - | |
| 618 | from \<open>Linear_order r\<close> True | |
| 619 |     obtain a where a: "r = {} \<or> r = {(a, a)}"
 | |
| 620 | unfolding order_on_defs using Total_subset_Id [of r] by blast | |
| 621 |     with * ** have "A = {a} \<and> r = {(a, a)}"
 | |
| 622 | unfolding Field_def by blast | |
| 623 | with a show ?thesis by blast | |
| 624 | qed | |
| 55027 | 625 | ultimately show ?thesis by blast | 
| 626 | next | |
| 63572 | 627 | case False | 
| 628 | with \<open>Linear_order r\<close> have Field: "Field r = Field (r - Id)" | |
| 629 | unfolding order_on_defs using Total_Id_Field [of r] by blast | |
| 55027 | 630 | show ?thesis | 
| 631 | proof | |
| 63572 | 632 | assume *: "wf (r - Id)" | 
| 633 |     show "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
 | |
| 634 | proof clarify | |
| 635 | fix A | |
| 636 |       assume **: "A \<subseteq> Field r" and ***: "A \<noteq> {}"
 | |
| 637 | then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id" | |
| 638 | using Field * unfolding wf_eq_minimal2 by simp | |
| 639 | moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id" | |
| 640 | using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** by blast | |
| 641 | ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r" by blast | |
| 55027 | 642 | qed | 
| 643 | next | |
| 63572 | 644 |     assume *: "\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r)"
 | 
| 645 | show "wf (r - Id)" | |
| 646 | unfolding wf_eq_minimal2 | |
| 647 | proof clarify | |
| 648 | fix A | |
| 649 |       assume **: "A \<subseteq> Field(r - Id)" and ***: "A \<noteq> {}"
 | |
| 650 | then have "\<exists>a \<in> A. \<forall>a' \<in> A. (a,a') \<in> r" | |
| 651 | using Field * by simp | |
| 652 | moreover have "\<forall>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r \<longleftrightarrow> (a', a) \<notin> r - Id" | |
| 653 | using Linear_order_in_diff_Id [OF \<open>Linear_order r\<close>] ** mono_Field[of "r - Id" r] by blast | |
| 654 | ultimately show "\<exists>a \<in> A. \<forall>a' \<in> A. (a',a) \<notin> r - Id" | |
| 655 | by blast | |
| 55027 | 656 | qed | 
| 657 | qed | |
| 658 | qed | |
| 659 | ||
| 660 | corollary Linear_order_Well_order_iff: | |
| 63572 | 661 | "Linear_order r \<Longrightarrow> | 
| 662 |     Well_order r \<longleftrightarrow> (\<forall>A \<subseteq> Field r. A \<noteq> {} \<longrightarrow> (\<exists>a \<in> A. \<forall>a' \<in> A. (a, a') \<in> r))"
 | |
| 663 | unfolding well_order_on_def using Linear_order_wf_diff_Id[of r] by blast | |
| 55027 | 664 | |
| 26273 | 665 | end |