author | wenzelm |
Mon, 12 Apr 2021 14:14:47 +0200 | |
changeset 73563 | 55b66a45bc94 |
parent 72184 | 881bd98bddee |
child 74868 | 2741ef11ccf6 |
permissions | -rw-r--r-- |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32704
diff
changeset
|
1 |
(* Title: HOL/Wellfounded.thy |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32704
diff
changeset
|
2 |
Author: Tobias Nipkow |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32704
diff
changeset
|
3 |
Author: Lawrence C Paulson |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32704
diff
changeset
|
4 |
Author: Konrad Slind |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32704
diff
changeset
|
5 |
Author: Alexander Krauss |
55027 | 6 |
Author: Andrei Popescu, TU Muenchen |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
7 |
*) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
8 |
|
60758 | 9 |
section \<open>Well-founded Recursion\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
10 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
11 |
theory Wellfounded |
63572 | 12 |
imports Transitive_Closure |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
13 |
begin |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
14 |
|
60758 | 15 |
subsection \<open>Basic Definitions\<close> |
26976 | 16 |
|
63108 | 17 |
definition wf :: "('a \<times> 'a) set \<Rightarrow> bool" |
18 |
where "wf r \<longleftrightarrow> (\<forall>P. (\<forall>x. (\<forall>y. (y, x) \<in> r \<longrightarrow> P y) \<longrightarrow> P x) \<longrightarrow> (\<forall>x. P x))" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
19 |
|
63108 | 20 |
definition wfP :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" |
21 |
where "wfP r \<longleftrightarrow> wf {(x, y). r x y}" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
22 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
23 |
lemma wfP_wf_eq [pred_set_conv]: "wfP (\<lambda>x y. (x, y) \<in> r) = wf r" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
24 |
by (simp add: wfP_def) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
25 |
|
63108 | 26 |
lemma wfUNIVI: "(\<And>P x. (\<forall>x. (\<forall>y. (y, x) \<in> r \<longrightarrow> P y) \<longrightarrow> P x) \<Longrightarrow> P x) \<Longrightarrow> wf r" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
27 |
unfolding wf_def by blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
28 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
29 |
lemmas wfPUNIVI = wfUNIVI [to_pred] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
30 |
|
63108 | 31 |
text \<open>Restriction to domain \<open>A\<close> and range \<open>B\<close>. |
32 |
If \<open>r\<close> is well-founded over their intersection, then \<open>wf r\<close>.\<close> |
|
33 |
lemma wfI: |
|
34 |
assumes "r \<subseteq> A \<times> B" |
|
35 |
and "\<And>x P. \<lbrakk>\<forall>x. (\<forall>y. (y, x) \<in> r \<longrightarrow> P y) \<longrightarrow> P x; x \<in> A; x \<in> B\<rbrakk> \<Longrightarrow> P x" |
|
36 |
shows "wf r" |
|
37 |
using assms unfolding wf_def by blast |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
38 |
|
63108 | 39 |
lemma wf_induct: |
40 |
assumes "wf r" |
|
41 |
and "\<And>x. \<forall>y. (y, x) \<in> r \<longrightarrow> P y \<Longrightarrow> P x" |
|
42 |
shows "P a" |
|
43 |
using assms unfolding wf_def by blast |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
44 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
45 |
lemmas wfP_induct = wf_induct [to_pred] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
46 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
47 |
lemmas wf_induct_rule = wf_induct [rule_format, consumes 1, case_names less, induct set: wf] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
48 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
49 |
lemmas wfP_induct_rule = wf_induct_rule [to_pred, induct set: wfP] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
50 |
|
63108 | 51 |
lemma wf_not_sym: "wf r \<Longrightarrow> (a, x) \<in> r \<Longrightarrow> (x, a) \<notin> r" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
52 |
by (induct a arbitrary: x set: wf) blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
53 |
|
33215
6fd85372981e
replaced (outdated) comments by explicit statements
krauss
parents:
32960
diff
changeset
|
54 |
lemma wf_asym: |
6fd85372981e
replaced (outdated) comments by explicit statements
krauss
parents:
32960
diff
changeset
|
55 |
assumes "wf r" "(a, x) \<in> r" |
6fd85372981e
replaced (outdated) comments by explicit statements
krauss
parents:
32960
diff
changeset
|
56 |
obtains "(x, a) \<notin> r" |
6fd85372981e
replaced (outdated) comments by explicit statements
krauss
parents:
32960
diff
changeset
|
57 |
by (drule wf_not_sym[OF assms]) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
58 |
|
63108 | 59 |
lemma wf_not_refl [simp]: "wf r \<Longrightarrow> (a, a) \<notin> r" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
60 |
by (blast elim: wf_asym) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
61 |
|
63572 | 62 |
lemma wf_irrefl: |
63 |
assumes "wf r" |
|
64 |
obtains "(a, a) \<notin> r" |
|
63108 | 65 |
by (drule wf_not_refl[OF assms]) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
66 |
|
72170
7fa9605b226c
Another go with lex: now lexordp back in class ord
paulson <lp15@cam.ac.uk>
parents:
72168
diff
changeset
|
67 |
lemma wf_imp_irrefl: |
7fa9605b226c
Another go with lex: now lexordp back in class ord
paulson <lp15@cam.ac.uk>
parents:
72168
diff
changeset
|
68 |
assumes "wf r" shows "irrefl r" |
7fa9605b226c
Another go with lex: now lexordp back in class ord
paulson <lp15@cam.ac.uk>
parents:
72168
diff
changeset
|
69 |
using wf_irrefl [OF assms] by (auto simp add: irrefl_def) |
7fa9605b226c
Another go with lex: now lexordp back in class ord
paulson <lp15@cam.ac.uk>
parents:
72168
diff
changeset
|
70 |
|
27823 | 71 |
lemma wf_wellorderI: |
72 |
assumes wf: "wf {(x::'a::ord, y). x < y}" |
|
63572 | 73 |
and lin: "OFCLASS('a::ord, linorder_class)" |
27823 | 74 |
shows "OFCLASS('a::ord, wellorder_class)" |
71410 | 75 |
apply (rule wellorder_class.intro [OF lin]) |
76 |
apply (simp add: wellorder_class.intro class.wellorder_axioms.intro wf_induct_rule [OF wf]) |
|
63108 | 77 |
done |
27823 | 78 |
|
63108 | 79 |
lemma (in wellorder) wf: "wf {(x, y). x < y}" |
80 |
unfolding wf_def by (blast intro: less_induct) |
|
27823 | 81 |
|
82 |
||
60758 | 83 |
subsection \<open>Basic Results\<close> |
26976 | 84 |
|
60758 | 85 |
text \<open>Point-free characterization of well-foundedness\<close> |
33216 | 86 |
|
87 |
lemma wfE_pf: |
|
88 |
assumes wf: "wf R" |
|
63572 | 89 |
and a: "A \<subseteq> R `` A" |
33216 | 90 |
shows "A = {}" |
91 |
proof - |
|
63108 | 92 |
from wf have "x \<notin> A" for x |
93 |
proof induct |
|
94 |
fix x assume "\<And>y. (y, x) \<in> R \<Longrightarrow> y \<notin> A" |
|
95 |
then have "x \<notin> R `` A" by blast |
|
96 |
with a show "x \<notin> A" by blast |
|
97 |
qed |
|
98 |
then show ?thesis by auto |
|
33216 | 99 |
qed |
100 |
||
101 |
lemma wfI_pf: |
|
102 |
assumes a: "\<And>A. A \<subseteq> R `` A \<Longrightarrow> A = {}" |
|
103 |
shows "wf R" |
|
104 |
proof (rule wfUNIVI) |
|
105 |
fix P :: "'a \<Rightarrow> bool" and x |
|
106 |
let ?A = "{x. \<not> P x}" |
|
107 |
assume "\<forall>x. (\<forall>y. (y, x) \<in> R \<longrightarrow> P y) \<longrightarrow> P x" |
|
108 |
then have "?A \<subseteq> R `` ?A" by blast |
|
109 |
with a show "P x" by blast |
|
110 |
qed |
|
111 |
||
63108 | 112 |
|
113 |
subsubsection \<open>Minimal-element characterization of well-foundedness\<close> |
|
33216 | 114 |
|
115 |
lemma wfE_min: |
|
116 |
assumes wf: "wf R" and Q: "x \<in> Q" |
|
117 |
obtains z where "z \<in> Q" "\<And>y. (y, z) \<in> R \<Longrightarrow> y \<notin> Q" |
|
118 |
using Q wfE_pf[OF wf, of Q] by blast |
|
119 |
||
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
63088
diff
changeset
|
120 |
lemma wfE_min': |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
63088
diff
changeset
|
121 |
"wf R \<Longrightarrow> Q \<noteq> {} \<Longrightarrow> (\<And>z. z \<in> Q \<Longrightarrow> (\<And>y. (y, z) \<in> R \<Longrightarrow> y \<notin> Q) \<Longrightarrow> thesis) \<Longrightarrow> thesis" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
63088
diff
changeset
|
122 |
using wfE_min[of R _ Q] by blast |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
63088
diff
changeset
|
123 |
|
33216 | 124 |
lemma wfI_min: |
125 |
assumes a: "\<And>x Q. x \<in> Q \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> Q" |
|
126 |
shows "wf R" |
|
127 |
proof (rule wfI_pf) |
|
63108 | 128 |
fix A |
129 |
assume b: "A \<subseteq> R `` A" |
|
130 |
have False if "x \<in> A" for x |
|
131 |
using a[OF that] b by blast |
|
132 |
then show "A = {}" by blast |
|
33216 | 133 |
qed |
134 |
||
63108 | 135 |
lemma wf_eq_minimal: "wf r \<longleftrightarrow> (\<forall>Q x. x \<in> Q \<longrightarrow> (\<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q))" |
68646 | 136 |
apply (rule iffI) |
137 |
apply (blast intro: elim!: wfE_min) |
|
138 |
by (rule wfI_min) auto |
|
33216 | 139 |
|
140 |
lemmas wfP_eq_minimal = wf_eq_minimal [to_pred] |
|
141 |
||
63108 | 142 |
|
143 |
subsubsection \<open>Well-foundedness of transitive closure\<close> |
|
33216 | 144 |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
145 |
lemma wf_trancl: |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
146 |
assumes "wf r" |
63108 | 147 |
shows "wf (r\<^sup>+)" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
148 |
proof - |
63108 | 149 |
have "P x" if induct_step: "\<And>x. (\<And>y. (y, x) \<in> r\<^sup>+ \<Longrightarrow> P y) \<Longrightarrow> P x" for P x |
150 |
proof (rule induct_step) |
|
151 |
show "P y" if "(y, x) \<in> r\<^sup>+" for y |
|
152 |
using \<open>wf r\<close> and that |
|
153 |
proof (induct x arbitrary: y) |
|
154 |
case (less x) |
|
155 |
note hyp = \<open>\<And>x' y'. (x', x) \<in> r \<Longrightarrow> (y', x') \<in> r\<^sup>+ \<Longrightarrow> P y'\<close> |
|
156 |
from \<open>(y, x) \<in> r\<^sup>+\<close> show "P y" |
|
157 |
proof cases |
|
158 |
case base |
|
159 |
show "P y" |
|
160 |
proof (rule induct_step) |
|
161 |
fix y' |
|
162 |
assume "(y', y) \<in> r\<^sup>+" |
|
163 |
with \<open>(y, x) \<in> r\<close> show "P y'" |
|
164 |
by (rule hyp [of y y']) |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32704
diff
changeset
|
165 |
qed |
63108 | 166 |
next |
167 |
case step |
|
168 |
then obtain x' where "(x', x) \<in> r" and "(y, x') \<in> r\<^sup>+" |
|
169 |
by simp |
|
170 |
then show "P y" by (rule hyp [of x' y]) |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
171 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
172 |
qed |
63108 | 173 |
qed |
174 |
then show ?thesis unfolding wf_def by blast |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
175 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
176 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
177 |
lemmas wfP_trancl = wf_trancl [to_pred] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
178 |
|
63108 | 179 |
lemma wf_converse_trancl: "wf (r\<inverse>) \<Longrightarrow> wf ((r\<^sup>+)\<inverse>)" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
180 |
apply (subst trancl_converse [symmetric]) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
181 |
apply (erule wf_trancl) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
182 |
done |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
183 |
|
60758 | 184 |
text \<open>Well-foundedness of subsets\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
185 |
|
63108 | 186 |
lemma wf_subset: "wf r \<Longrightarrow> p \<subseteq> r \<Longrightarrow> wf p" |
63612 | 187 |
by (simp add: wf_eq_minimal) fast |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
188 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
189 |
lemmas wfP_subset = wf_subset [to_pred] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
190 |
|
60758 | 191 |
text \<open>Well-foundedness of the empty relation\<close> |
33216 | 192 |
|
193 |
lemma wf_empty [iff]: "wf {}" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
194 |
by (simp add: wf_def) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
195 |
|
63612 | 196 |
lemma wfP_empty [iff]: "wfP (\<lambda>x y. False)" |
32205 | 197 |
proof - |
63612 | 198 |
have "wfP bot" |
66952 | 199 |
by (fact wf_empty[to_pred bot_empty_eq2]) |
63612 | 200 |
then show ?thesis |
201 |
by (simp add: bot_fun_def) |
|
32205 | 202 |
qed |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
203 |
|
63572 | 204 |
lemma wf_Int1: "wf r \<Longrightarrow> wf (r \<inter> r')" |
205 |
by (erule wf_subset) (rule Int_lower1) |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
206 |
|
63572 | 207 |
lemma wf_Int2: "wf r \<Longrightarrow> wf (r' \<inter> r)" |
208 |
by (erule wf_subset) (rule Int_lower2) |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
209 |
|
63572 | 210 |
text \<open>Exponentiation.\<close> |
33216 | 211 |
lemma wf_exp: |
212 |
assumes "wf (R ^^ n)" |
|
213 |
shows "wf R" |
|
214 |
proof (rule wfI_pf) |
|
215 |
fix A assume "A \<subseteq> R `` A" |
|
63612 | 216 |
then have "A \<subseteq> (R ^^ n) `` A" |
217 |
by (induct n) force+ |
|
218 |
with \<open>wf (R ^^ n)\<close> show "A = {}" |
|
219 |
by (rule wfE_pf) |
|
33216 | 220 |
qed |
221 |
||
63572 | 222 |
text \<open>Well-foundedness of \<open>insert\<close>.\<close> |
68646 | 223 |
lemma wf_insert [iff]: "wf (insert (y,x) r) \<longleftrightarrow> wf r \<and> (x,y) \<notin> r\<^sup>*" (is "?lhs = ?rhs") |
224 |
proof |
|
225 |
assume ?lhs then show ?rhs |
|
226 |
by (blast elim: wf_trancl [THEN wf_irrefl] |
|
227 |
intro: rtrancl_into_trancl1 wf_subset rtrancl_mono [THEN subsetD]) |
|
228 |
next |
|
71410 | 229 |
assume R: ?rhs |
68646 | 230 |
then have R': "Q \<noteq> {} \<Longrightarrow> (\<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q)" for Q |
231 |
by (auto simp: wf_eq_minimal) |
|
232 |
show ?lhs |
|
233 |
unfolding wf_eq_minimal |
|
234 |
proof clarify |
|
235 |
fix Q :: "'a set" and q |
|
236 |
assume "q \<in> Q" |
|
237 |
then obtain a where "a \<in> Q" and a: "\<And>y. (y, a) \<in> r \<Longrightarrow> y \<notin> Q" |
|
238 |
using R by (auto simp: wf_eq_minimal) |
|
239 |
show "\<exists>z\<in>Q. \<forall>y'. (y', z) \<in> insert (y, x) r \<longrightarrow> y' \<notin> Q" |
|
240 |
proof (cases "a=x") |
|
241 |
case True |
|
242 |
show ?thesis |
|
243 |
proof (cases "y \<in> Q") |
|
244 |
case True |
|
245 |
then obtain z where "z \<in> Q" "(z, y) \<in> r\<^sup>*" |
|
246 |
"\<And>z'. (z', z) \<in> r \<longrightarrow> z' \<in> Q \<longrightarrow> (z', y) \<notin> r\<^sup>*" |
|
247 |
using R' [of "{z \<in> Q. (z,y) \<in> r\<^sup>*}"] by auto |
|
248 |
with R show ?thesis |
|
249 |
by (rule_tac x="z" in bexI) (blast intro: rtrancl_trans) |
|
250 |
next |
|
251 |
case False |
|
252 |
then show ?thesis |
|
253 |
using a \<open>a \<in> Q\<close> by blast |
|
254 |
qed |
|
255 |
next |
|
256 |
case False |
|
257 |
with a \<open>a \<in> Q\<close> show ?thesis |
|
258 |
by blast |
|
259 |
qed |
|
260 |
qed |
|
261 |
qed |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
262 |
|
63108 | 263 |
|
264 |
subsubsection \<open>Well-foundedness of image\<close> |
|
33216 | 265 |
|
68259
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
266 |
lemma wf_map_prod_image_Dom_Ran: |
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
267 |
fixes r:: "('a \<times> 'a) set" |
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
268 |
and f:: "'a \<Rightarrow> 'b" |
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
269 |
assumes wf_r: "wf r" |
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
270 |
and inj: "\<And> a a'. a \<in> Domain r \<Longrightarrow> a' \<in> Range r \<Longrightarrow> f a = f a' \<Longrightarrow> a = a'" |
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
271 |
shows "wf (map_prod f f ` r)" |
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
272 |
proof (unfold wf_eq_minimal, clarify) |
68262 | 273 |
fix B :: "'b set" and b::"'b" |
274 |
assume "b \<in> B" |
|
275 |
define A where "A = f -` B \<inter> Domain r" |
|
276 |
show "\<exists>z\<in>B. \<forall>y. (y, z) \<in> map_prod f f ` r \<longrightarrow> y \<notin> B" |
|
277 |
proof (cases "A = {}") |
|
68259
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
278 |
case False |
68262 | 279 |
then obtain a0 where "a0 \<in> A" and "\<forall>a. (a, a0) \<in> r \<longrightarrow> a \<notin> A" |
68259
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
280 |
using wfE_min[OF wf_r] by auto |
71410 | 281 |
thus ?thesis |
68262 | 282 |
using inj unfolding A_def |
283 |
by (intro bexI[of _ "f a0"]) auto |
|
71410 | 284 |
qed (insert \<open>b \<in> B\<close>, unfold A_def, auto) |
68259
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
285 |
qed |
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
286 |
|
63108 | 287 |
lemma wf_map_prod_image: "wf r \<Longrightarrow> inj f \<Longrightarrow> wf (map_prod f f ` r)" |
68259
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
nipkow
parents:
67399
diff
changeset
|
288 |
by(rule wf_map_prod_image_Dom_Ran) (auto dest: inj_onD) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
289 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
290 |
|
60758 | 291 |
subsection \<open>Well-Foundedness Results for Unions\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
292 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
293 |
lemma wf_union_compatible: |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
294 |
assumes "wf R" "wf S" |
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
32205
diff
changeset
|
295 |
assumes "R O S \<subseteq> R" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
296 |
shows "wf (R \<union> S)" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
297 |
proof (rule wfI_min) |
63108 | 298 |
fix x :: 'a and Q |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
299 |
let ?Q' = "{x \<in> Q. \<forall>y. (y, x) \<in> R \<longrightarrow> y \<notin> Q}" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
300 |
assume "x \<in> Q" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
301 |
obtain a where "a \<in> ?Q'" |
60758 | 302 |
by (rule wfE_min [OF \<open>wf R\<close> \<open>x \<in> Q\<close>]) blast |
63108 | 303 |
with \<open>wf S\<close> obtain z where "z \<in> ?Q'" and zmin: "\<And>y. (y, z) \<in> S \<Longrightarrow> y \<notin> ?Q'" |
304 |
by (erule wfE_min) |
|
63572 | 305 |
have "y \<notin> Q" if "(y, z) \<in> S" for y |
306 |
proof |
|
307 |
from that have "y \<notin> ?Q'" by (rule zmin) |
|
308 |
assume "y \<in> Q" |
|
309 |
with \<open>y \<notin> ?Q'\<close> obtain w where "(w, y) \<in> R" and "w \<in> Q" by auto |
|
310 |
from \<open>(w, y) \<in> R\<close> \<open>(y, z) \<in> S\<close> have "(w, z) \<in> R O S" by (rule relcompI) |
|
311 |
with \<open>R O S \<subseteq> R\<close> have "(w, z) \<in> R" .. |
|
312 |
with \<open>z \<in> ?Q'\<close> have "w \<notin> Q" by blast |
|
313 |
with \<open>w \<in> Q\<close> show False by contradiction |
|
314 |
qed |
|
60758 | 315 |
with \<open>z \<in> ?Q'\<close> show "\<exists>z\<in>Q. \<forall>y. (y, z) \<in> R \<union> S \<longrightarrow> y \<notin> Q" by blast |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
316 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
317 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
318 |
|
63572 | 319 |
text \<open>Well-foundedness of indexed union with disjoint domains and ranges.\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
320 |
|
63108 | 321 |
lemma wf_UN: |
68646 | 322 |
assumes r: "\<And>i. i \<in> I \<Longrightarrow> wf (r i)" |
323 |
and disj: "\<And>i j. \<lbrakk>i \<in> I; j \<in> I; r i \<noteq> r j\<rbrakk> \<Longrightarrow> Domain (r i) \<inter> Range (r j) = {}" |
|
63108 | 324 |
shows "wf (\<Union>i\<in>I. r i)" |
68646 | 325 |
unfolding wf_eq_minimal |
326 |
proof clarify |
|
327 |
fix A and a :: "'b" |
|
328 |
assume "a \<in> A" |
|
69275 | 329 |
show "\<exists>z\<in>A. \<forall>y. (y, z) \<in> \<Union>(r ` I) \<longrightarrow> y \<notin> A" |
68646 | 330 |
proof (cases "\<exists>i\<in>I. \<exists>a\<in>A. \<exists>b\<in>A. (b, a) \<in> r i") |
331 |
case True |
|
332 |
then obtain i b c where ibc: "i \<in> I" "b \<in> A" "c \<in> A" "(c,b) \<in> r i" |
|
333 |
by blast |
|
334 |
have ri: "\<And>Q. Q \<noteq> {} \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> r i \<longrightarrow> y \<notin> Q" |
|
335 |
using r [OF \<open>i \<in> I\<close>] unfolding wf_eq_minimal by auto |
|
336 |
show ?thesis |
|
71410 | 337 |
using ri [of "{a. a \<in> A \<and> (\<exists>b\<in>A. (b, a) \<in> r i) }"] ibc disj |
68646 | 338 |
by blast |
339 |
next |
|
340 |
case False |
|
341 |
with \<open>a \<in> A\<close> show ?thesis |
|
342 |
by blast |
|
343 |
qed |
|
344 |
qed |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
345 |
|
32263 | 346 |
lemma wfP_SUP: |
64632 | 347 |
"\<forall>i. wfP (r i) \<Longrightarrow> \<forall>i j. r i \<noteq> r j \<longrightarrow> inf (Domainp (r i)) (Rangep (r j)) = bot \<Longrightarrow> |
69275 | 348 |
wfP (\<Squnion>(range r))" |
63572 | 349 |
by (rule wf_UN[to_pred]) simp_all |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
350 |
|
63108 | 351 |
lemma wf_Union: |
352 |
assumes "\<forall>r\<in>R. wf r" |
|
353 |
and "\<forall>r\<in>R. \<forall>s\<in>R. r \<noteq> s \<longrightarrow> Domain r \<inter> Range s = {}" |
|
354 |
shows "wf (\<Union>R)" |
|
355 |
using assms wf_UN[of R "\<lambda>i. i"] by simp |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
356 |
|
63109 | 357 |
text \<open> |
358 |
Intuition: We find an \<open>R \<union> S\<close>-min element of a nonempty subset \<open>A\<close> by case distinction. |
|
359 |
\<^enum> There is a step \<open>a \<midarrow>R\<rightarrow> b\<close> with \<open>a, b \<in> A\<close>. |
|
360 |
Pick an \<open>R\<close>-min element \<open>z\<close> of the (nonempty) set \<open>{a\<in>A | \<exists>b\<in>A. a \<midarrow>R\<rightarrow> b}\<close>. |
|
361 |
By definition, there is \<open>z' \<in> A\<close> s.t. \<open>z \<midarrow>R\<rightarrow> z'\<close>. Because \<open>z\<close> is \<open>R\<close>-min in the |
|
362 |
subset, \<open>z'\<close> must be \<open>R\<close>-min in \<open>A\<close>. Because \<open>z'\<close> has an \<open>R\<close>-predecessor, it cannot |
|
363 |
have an \<open>S\<close>-successor and is thus \<open>S\<close>-min in \<open>A\<close> as well. |
|
364 |
\<^enum> There is no such step. |
|
365 |
Pick an \<open>S\<close>-min element of \<open>A\<close>. In this case it must be an \<open>R\<close>-min |
|
366 |
element of \<open>A\<close> as well. |
|
367 |
\<close> |
|
63108 | 368 |
lemma wf_Un: "wf r \<Longrightarrow> wf s \<Longrightarrow> Domain r \<inter> Range s = {} \<Longrightarrow> wf (r \<union> s)" |
369 |
using wf_union_compatible[of s r] |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
370 |
by (auto simp: Un_ac) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
371 |
|
63108 | 372 |
lemma wf_union_merge: "wf (R \<union> S) = wf (R O R \<union> S O R \<union> S)" |
373 |
(is "wf ?A = wf ?B") |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
374 |
proof |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
375 |
assume "wf ?A" |
63108 | 376 |
with wf_trancl have wfT: "wf (?A\<^sup>+)" . |
377 |
moreover have "?B \<subseteq> ?A\<^sup>+" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
378 |
by (subst trancl_unfold, subst trancl_unfold) blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
379 |
ultimately show "wf ?B" by (rule wf_subset) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
380 |
next |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
381 |
assume "wf ?B" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
382 |
show "wf ?A" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
383 |
proof (rule wfI_min) |
63108 | 384 |
fix Q :: "'a set" and x |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
385 |
assume "x \<in> Q" |
63109 | 386 |
with \<open>wf ?B\<close> obtain z where "z \<in> Q" and "\<And>y. (y, z) \<in> ?B \<Longrightarrow> y \<notin> Q" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
387 |
by (erule wfE_min) |
63109 | 388 |
then have 1: "\<And>y. (y, z) \<in> R O R \<Longrightarrow> y \<notin> Q" |
389 |
and 2: "\<And>y. (y, z) \<in> S O R \<Longrightarrow> y \<notin> Q" |
|
390 |
and 3: "\<And>y. (y, z) \<in> S \<Longrightarrow> y \<notin> Q" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
391 |
by auto |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
392 |
show "\<exists>z\<in>Q. \<forall>y. (y, z) \<in> ?A \<longrightarrow> y \<notin> Q" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
393 |
proof (cases "\<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> Q") |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
394 |
case True |
63109 | 395 |
with \<open>z \<in> Q\<close> 3 show ?thesis by blast |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
396 |
next |
63108 | 397 |
case False |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
398 |
then obtain z' where "z'\<in>Q" "(z', z) \<in> R" by blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
399 |
have "\<forall>y. (y, z') \<in> ?A \<longrightarrow> y \<notin> Q" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
400 |
proof (intro allI impI) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
401 |
fix y assume "(y, z') \<in> ?A" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
402 |
then show "y \<notin> Q" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
403 |
proof |
63108 | 404 |
assume "(y, z') \<in> R" |
60758 | 405 |
then have "(y, z) \<in> R O R" using \<open>(z', z) \<in> R\<close> .. |
63109 | 406 |
with 1 show "y \<notin> Q" . |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
407 |
next |
63108 | 408 |
assume "(y, z') \<in> S" |
60758 | 409 |
then have "(y, z) \<in> S O R" using \<open>(z', z) \<in> R\<close> .. |
63109 | 410 |
with 2 show "y \<notin> Q" . |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
411 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
412 |
qed |
60758 | 413 |
with \<open>z' \<in> Q\<close> show ?thesis .. |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
414 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
415 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
416 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
417 |
|
63612 | 418 |
lemma wf_comp_self: "wf R \<longleftrightarrow> wf (R O R)" \<comment> \<open>special case\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
419 |
by (rule wf_union_merge [where S = "{}", simplified]) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
420 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
421 |
|
60758 | 422 |
subsection \<open>Well-Foundedness of Composition\<close> |
60148 | 423 |
|
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
424 |
text \<open>Bachmair and Dershowitz 1986, Lemma 2. [Provided by Tjark Weber]\<close> |
60148 | 425 |
|
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
426 |
lemma qc_wf_relto_iff: |
61799 | 427 |
assumes "R O S \<subseteq> (R \<union> S)\<^sup>* O R" \<comment> \<open>R quasi-commutes over S\<close> |
63109 | 428 |
shows "wf (S\<^sup>* O R O S\<^sup>*) \<longleftrightarrow> wf R" |
63612 | 429 |
(is "wf ?S \<longleftrightarrow> _") |
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
430 |
proof |
63109 | 431 |
show "wf R" if "wf ?S" |
432 |
proof - |
|
433 |
have "R \<subseteq> ?S" by auto |
|
63612 | 434 |
with wf_subset [of ?S] that show "wf R" |
435 |
by auto |
|
63109 | 436 |
qed |
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
437 |
next |
63109 | 438 |
show "wf ?S" if "wf R" |
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
439 |
proof (rule wfI_pf) |
63109 | 440 |
fix A |
441 |
assume A: "A \<subseteq> ?S `` A" |
|
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
442 |
let ?X = "(R \<union> S)\<^sup>* `` A" |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
443 |
have *: "R O (R \<union> S)\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R" |
63109 | 444 |
proof - |
445 |
have "(x, z) \<in> (R \<union> S)\<^sup>* O R" if "(y, z) \<in> (R \<union> S)\<^sup>*" and "(x, y) \<in> R" for x y z |
|
446 |
using that |
|
447 |
proof (induct y z) |
|
448 |
case rtrancl_refl |
|
449 |
then show ?case by auto |
|
450 |
next |
|
451 |
case (rtrancl_into_rtrancl a b c) |
|
452 |
then have "(x, c) \<in> ((R \<union> S)\<^sup>* O (R \<union> S)\<^sup>*) O R" |
|
453 |
using assms by blast |
|
454 |
then show ?case by simp |
|
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
455 |
qed |
63109 | 456 |
then show ?thesis by auto |
457 |
qed |
|
458 |
then have "R O S\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R" |
|
459 |
using rtrancl_Un_subset by blast |
|
460 |
then have "?S \<subseteq> (R \<union> S)\<^sup>* O (R \<union> S)\<^sup>* O R" |
|
461 |
by (simp add: relcomp_mono rtrancl_mono) |
|
462 |
also have "\<dots> = (R \<union> S)\<^sup>* O R" |
|
463 |
by (simp add: O_assoc[symmetric]) |
|
464 |
finally have "?S O (R \<union> S)\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R O (R \<union> S)\<^sup>*" |
|
465 |
by (simp add: O_assoc[symmetric] relcomp_mono) |
|
466 |
also have "\<dots> \<subseteq> (R \<union> S)\<^sup>* O (R \<union> S)\<^sup>* O R" |
|
467 |
using * by (simp add: relcomp_mono) |
|
468 |
finally have "?S O (R \<union> S)\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R" |
|
469 |
by (simp add: O_assoc[symmetric]) |
|
470 |
then have "(?S O (R \<union> S)\<^sup>*) `` A \<subseteq> ((R \<union> S)\<^sup>* O R) `` A" |
|
471 |
by (simp add: Image_mono) |
|
472 |
moreover have "?X \<subseteq> (?S O (R \<union> S)\<^sup>*) `` A" |
|
473 |
using A by (auto simp: relcomp_Image) |
|
474 |
ultimately have "?X \<subseteq> R `` ?X" |
|
475 |
by (auto simp: relcomp_Image) |
|
476 |
then have "?X = {}" |
|
477 |
using \<open>wf R\<close> by (simp add: wfE_pf) |
|
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
478 |
moreover have "A \<subseteq> ?X" by auto |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
479 |
ultimately show "A = {}" by simp |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
480 |
qed |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
481 |
qed |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
482 |
|
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
483 |
corollary wf_relcomp_compatible: |
60148 | 484 |
assumes "wf R" and "R O S \<subseteq> S O R" |
485 |
shows "wf (S O R)" |
|
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
486 |
proof - |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
487 |
have "R O S \<subseteq> (R \<union> S)\<^sup>* O R" |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
488 |
using assms by blast |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
489 |
then have "wf (S\<^sup>* O R O S\<^sup>*)" |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
490 |
by (simp add: assms qc_wf_relto_iff) |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
491 |
then show ?thesis |
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
492 |
by (rule Wellfounded.wf_subset) blast |
60148 | 493 |
qed |
494 |
||
495 |
||
60758 | 496 |
subsection \<open>Acyclic relations\<close> |
33217 | 497 |
|
63108 | 498 |
lemma wf_acyclic: "wf r \<Longrightarrow> acyclic r" |
63572 | 499 |
by (simp add: acyclic_def) (blast elim: wf_trancl [THEN wf_irrefl]) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
500 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
501 |
lemmas wfP_acyclicP = wf_acyclic [to_pred] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
502 |
|
63108 | 503 |
|
504 |
subsubsection \<open>Wellfoundedness of finite acyclic relations\<close> |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
505 |
|
68646 | 506 |
lemma finite_acyclic_wf: |
507 |
assumes "finite r" "acyclic r" shows "wf r" |
|
508 |
using assms |
|
509 |
proof (induction r rule: finite_induct) |
|
510 |
case (insert x r) |
|
511 |
then show ?case |
|
512 |
by (cases x) simp |
|
513 |
qed simp |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
514 |
|
63108 | 515 |
lemma finite_acyclic_wf_converse: "finite r \<Longrightarrow> acyclic r \<Longrightarrow> wf (r\<inverse>)" |
63572 | 516 |
apply (erule finite_converse [THEN iffD2, THEN finite_acyclic_wf]) |
517 |
apply (erule acyclic_converse [THEN iffD2]) |
|
518 |
done |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
519 |
|
63088
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
520 |
text \<open> |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
521 |
Observe that the converse of an irreflexive, transitive, |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
522 |
and finite relation is again well-founded. Thus, we may |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
523 |
employ it for well-founded induction. |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
524 |
\<close> |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
525 |
lemma wf_converse: |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
526 |
assumes "irrefl r" and "trans r" and "finite r" |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
527 |
shows "wf (r\<inverse>)" |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
528 |
proof - |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
529 |
have "acyclic r" |
63572 | 530 |
using \<open>irrefl r\<close> and \<open>trans r\<close> |
531 |
by (simp add: irrefl_def acyclic_irrefl) |
|
532 |
with \<open>finite r\<close> show ?thesis |
|
533 |
by (rule finite_acyclic_wf_converse) |
|
63088
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
534 |
qed |
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
haftmann
parents:
61952
diff
changeset
|
535 |
|
63108 | 536 |
lemma wf_iff_acyclic_if_finite: "finite r \<Longrightarrow> wf r = acyclic r" |
63572 | 537 |
by (blast intro: finite_acyclic_wf wf_acyclic) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
538 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
539 |
|
69593 | 540 |
subsection \<open>\<^typ>\<open>nat\<close> is well-founded\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
541 |
|
67399 | 542 |
lemma less_nat_rel: "(<) = (\<lambda>m n. n = Suc m)\<^sup>+\<^sup>+" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
543 |
proof (rule ext, rule ext, rule iffI) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
544 |
fix n m :: nat |
63108 | 545 |
show "(\<lambda>m n. n = Suc m)\<^sup>+\<^sup>+ m n" if "m < n" |
546 |
using that |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
547 |
proof (induct n) |
63108 | 548 |
case 0 |
549 |
then show ?case by auto |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
550 |
next |
63108 | 551 |
case (Suc n) |
552 |
then show ?case |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
553 |
by (auto simp add: less_Suc_eq_le le_less intro: tranclp.trancl_into_trancl) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
554 |
qed |
63108 | 555 |
show "m < n" if "(\<lambda>m n. n = Suc m)\<^sup>+\<^sup>+ m n" |
556 |
using that by (induct n) (simp_all add: less_Suc_eq_le reflexive le_less) |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
557 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
558 |
|
63108 | 559 |
definition pred_nat :: "(nat \<times> nat) set" |
560 |
where "pred_nat = {(m, n). n = Suc m}" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
561 |
|
63108 | 562 |
definition less_than :: "(nat \<times> nat) set" |
563 |
where "less_than = pred_nat\<^sup>+" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
564 |
|
63108 | 565 |
lemma less_eq: "(m, n) \<in> pred_nat\<^sup>+ \<longleftrightarrow> m < n" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
566 |
unfolding less_nat_rel pred_nat_def trancl_def by simp |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
567 |
|
63108 | 568 |
lemma pred_nat_trancl_eq_le: "(m, n) \<in> pred_nat\<^sup>* \<longleftrightarrow> m \<le> n" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
569 |
unfolding less_eq rtrancl_eq_or_trancl by auto |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
570 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
571 |
lemma wf_pred_nat: "wf pred_nat" |
63572 | 572 |
apply (unfold wf_def pred_nat_def) |
573 |
apply clarify |
|
574 |
apply (induct_tac x) |
|
575 |
apply blast+ |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
576 |
done |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
577 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
578 |
lemma wf_less_than [iff]: "wf less_than" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
579 |
by (simp add: less_than_def wf_pred_nat [THEN wf_trancl]) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
580 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
581 |
lemma trans_less_than [iff]: "trans less_than" |
35216 | 582 |
by (simp add: less_than_def) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
583 |
|
63108 | 584 |
lemma less_than_iff [iff]: "((x,y) \<in> less_than) = (x<y)" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
585 |
by (simp add: less_than_def less_eq) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
586 |
|
71827 | 587 |
lemma irrefl_less_than: "irrefl less_than" |
588 |
using irrefl_def by blast |
|
589 |
||
71935
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
590 |
lemma asym_less_than: "asym less_than" |
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
591 |
by (simp add: asym.simps irrefl_less_than) |
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
592 |
|
71766
1249b998e377
New theory Library/List_Lenlexorder.thy, a type class instantiation for well-ordering lists
paulson <lp15@cam.ac.uk>
parents:
71544
diff
changeset
|
593 |
lemma total_less_than: "total less_than" and total_on_less_than [simp]: "total_on A less_than" |
1249b998e377
New theory Library/List_Lenlexorder.thy, a type class instantiation for well-ordering lists
paulson <lp15@cam.ac.uk>
parents:
71544
diff
changeset
|
594 |
using total_on_def by force+ |
71404
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
595 |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
596 |
lemma wf_less: "wf {(x, y::nat). x < y}" |
60493
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
paulson <lp15@cam.ac.uk>
parents:
60148
diff
changeset
|
597 |
by (rule Wellfounded.wellorder_class.wf) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
598 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
599 |
|
60758 | 600 |
subsection \<open>Accessible Part\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
601 |
|
60758 | 602 |
text \<open> |
63108 | 603 |
Inductive definition of the accessible part \<open>acc r\<close> of a |
604 |
relation; see also @{cite "paulin-tlca"}. |
|
60758 | 605 |
\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
606 |
|
63108 | 607 |
inductive_set acc :: "('a \<times> 'a) set \<Rightarrow> 'a set" for r :: "('a \<times> 'a) set" |
608 |
where accI: "(\<And>y. (y, x) \<in> r \<Longrightarrow> y \<in> acc r) \<Longrightarrow> x \<in> acc r" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
609 |
|
63108 | 610 |
abbreviation termip :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> bool" |
611 |
where "termip r \<equiv> accp (r\<inverse>\<inverse>)" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
612 |
|
63108 | 613 |
abbreviation termi :: "('a \<times> 'a) set \<Rightarrow> 'a set" |
614 |
where "termi r \<equiv> acc (r\<inverse>)" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
615 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
616 |
lemmas accpI = accp.accI |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
617 |
|
63108 | 618 |
lemma accp_eq_acc [code]: "accp r = (\<lambda>x. x \<in> Wellfounded.acc {(x, y). r x y})" |
54295 | 619 |
by (simp add: acc_def) |
620 |
||
621 |
||
60758 | 622 |
text \<open>Induction rules\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
623 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
624 |
theorem accp_induct: |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
625 |
assumes major: "accp r a" |
63108 | 626 |
assumes hyp: "\<And>x. accp r x \<Longrightarrow> \<forall>y. r y x \<longrightarrow> P y \<Longrightarrow> P x" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
627 |
shows "P a" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
628 |
apply (rule major [THEN accp.induct]) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
629 |
apply (rule hyp) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
630 |
apply (rule accp.accI) |
68646 | 631 |
apply auto |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
632 |
done |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
633 |
|
61337 | 634 |
lemmas accp_induct_rule = accp_induct [rule_format, induct set: accp] |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
635 |
|
63108 | 636 |
theorem accp_downward: "accp r b \<Longrightarrow> r a b \<Longrightarrow> accp r a" |
63572 | 637 |
by (cases rule: accp.cases) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
638 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
639 |
lemma not_accp_down: |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
640 |
assumes na: "\<not> accp R x" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
641 |
obtains z where "R z x" and "\<not> accp R z" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
642 |
proof - |
63572 | 643 |
assume a: "\<And>z. R z x \<Longrightarrow> \<not> accp R z \<Longrightarrow> thesis" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
644 |
show thesis |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
645 |
proof (cases "\<forall>z. R z x \<longrightarrow> accp R z") |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
646 |
case True |
63108 | 647 |
then have "\<And>z. R z x \<Longrightarrow> accp R z" by auto |
648 |
then have "accp R x" by (rule accp.accI) |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
649 |
with na show thesis .. |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
650 |
next |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
651 |
case False then obtain z where "R z x" and "\<not> accp R z" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
652 |
by auto |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
653 |
with a show thesis . |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
654 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
655 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
656 |
|
63108 | 657 |
lemma accp_downwards_aux: "r\<^sup>*\<^sup>* b a \<Longrightarrow> accp r a \<longrightarrow> accp r b" |
63612 | 658 |
by (erule rtranclp_induct) (blast dest: accp_downward)+ |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
659 |
|
63108 | 660 |
theorem accp_downwards: "accp r a \<Longrightarrow> r\<^sup>*\<^sup>* b a \<Longrightarrow> accp r b" |
63572 | 661 |
by (blast dest: accp_downwards_aux) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
662 |
|
63108 | 663 |
theorem accp_wfPI: "\<forall>x. accp r x \<Longrightarrow> wfP r" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
664 |
apply (rule wfPUNIVI) |
63572 | 665 |
apply (rule_tac P = P in accp_induct) |
68646 | 666 |
apply blast+ |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
667 |
done |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
668 |
|
63108 | 669 |
theorem accp_wfPD: "wfP r \<Longrightarrow> accp r x" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
670 |
apply (erule wfP_induct_rule) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
671 |
apply (rule accp.accI) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
672 |
apply blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
673 |
done |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
674 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
675 |
theorem wfP_accp_iff: "wfP r = (\<forall>x. accp r x)" |
63572 | 676 |
by (blast intro: accp_wfPI dest: accp_wfPD) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
677 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
678 |
|
60758 | 679 |
text \<open>Smaller relations have bigger accessible parts:\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
680 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
681 |
lemma accp_subset: |
63572 | 682 |
assumes "R1 \<le> R2" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
683 |
shows "accp R2 \<le> accp R1" |
26803
0af0f674845d
- Explicitely passed pred_subset_eq and pred_equals_eq as an argument to the
berghofe
parents:
26748
diff
changeset
|
684 |
proof (rule predicate1I) |
63572 | 685 |
fix x |
686 |
assume "accp R2 x" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
687 |
then show "accp R1 x" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
688 |
proof (induct x) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
689 |
fix x |
63572 | 690 |
assume "\<And>y. R2 y x \<Longrightarrow> accp R1 y" |
691 |
with assms show "accp R1 x" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
692 |
by (blast intro: accp.accI) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
693 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
694 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
695 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
696 |
|
60758 | 697 |
text \<open>This is a generalized induction theorem that works on |
698 |
subsets of the accessible part.\<close> |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
699 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
700 |
lemma accp_subset_induct: |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
701 |
assumes subset: "D \<le> accp R" |
63572 | 702 |
and dcl: "\<And>x z. D x \<Longrightarrow> R z x \<Longrightarrow> D z" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
703 |
and "D x" |
63572 | 704 |
and istep: "\<And>x. D x \<Longrightarrow> (\<And>z. R z x \<Longrightarrow> P z) \<Longrightarrow> P x" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
705 |
shows "P x" |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
706 |
proof - |
60758 | 707 |
from subset and \<open>D x\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
708 |
have "accp R x" .. |
60758 | 709 |
then show "P x" using \<open>D x\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
710 |
proof (induct x) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
711 |
fix x |
63572 | 712 |
assume "D x" and "\<And>y. R y x \<Longrightarrow> D y \<Longrightarrow> P y" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
713 |
with dcl and istep show "P x" by blast |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
714 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
715 |
qed |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
716 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
717 |
|
60758 | 718 |
text \<open>Set versions of the above theorems\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
719 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
720 |
lemmas acc_induct = accp_induct [to_set] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
721 |
lemmas acc_induct_rule = acc_induct [rule_format, induct set: acc] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
722 |
lemmas acc_downward = accp_downward [to_set] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
723 |
lemmas not_acc_down = not_accp_down [to_set] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
724 |
lemmas acc_downwards_aux = accp_downwards_aux [to_set] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
725 |
lemmas acc_downwards = accp_downwards [to_set] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
726 |
lemmas acc_wfI = accp_wfPI [to_set] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
727 |
lemmas acc_wfD = accp_wfPD [to_set] |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
728 |
lemmas wf_acc_iff = wfP_accp_iff [to_set] |
46177
adac34829e10
pred_subset_eq and SUP_UN_eq2 are now standard pred_set_conv rules
berghofe
parents:
45970
diff
changeset
|
729 |
lemmas acc_subset = accp_subset [to_set] |
adac34829e10
pred_subset_eq and SUP_UN_eq2 are now standard pred_set_conv rules
berghofe
parents:
45970
diff
changeset
|
730 |
lemmas acc_subset_induct = accp_subset_induct [to_set] |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
731 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
732 |
|
60758 | 733 |
subsection \<open>Tools for building wellfounded relations\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
734 |
|
60758 | 735 |
text \<open>Inverse Image\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
736 |
|
71544 | 737 |
lemma wf_inv_image [simp,intro!]: |
738 |
fixes f :: "'a \<Rightarrow> 'b" |
|
739 |
assumes "wf r" |
|
740 |
shows "wf (inv_image r f)" |
|
741 |
proof (clarsimp simp: inv_image_def wf_eq_minimal) |
|
742 |
fix P and x::'a |
|
743 |
assume "x \<in> P" |
|
744 |
then obtain w where w: "w \<in> {w. \<exists>x::'a. x \<in> P \<and> f x = w}" |
|
745 |
by auto |
|
746 |
have *: "\<And>Q u. u \<in> Q \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q" |
|
747 |
using assms by (auto simp add: wf_eq_minimal) |
|
748 |
show "\<exists>z\<in>P. \<forall>y. (f y, f z) \<in> r \<longrightarrow> y \<notin> P" |
|
749 |
using * [OF w] by auto |
|
750 |
qed |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
751 |
|
69593 | 752 |
text \<open>Measure functions into \<^typ>\<open>nat\<close>\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
753 |
|
63108 | 754 |
definition measure :: "('a \<Rightarrow> nat) \<Rightarrow> ('a \<times> 'a) set" |
755 |
where "measure = inv_image less_than" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
756 |
|
63108 | 757 |
lemma in_measure[simp, code_unfold]: "(x, y) \<in> measure f \<longleftrightarrow> f x < f y" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
758 |
by (simp add:measure_def) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
759 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
760 |
lemma wf_measure [iff]: "wf (measure f)" |
63572 | 761 |
unfolding measure_def by (rule wf_less_than [THEN wf_inv_image]) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
762 |
|
63108 | 763 |
lemma wf_if_measure: "(\<And>x. P x \<Longrightarrow> f(g x) < f x) \<Longrightarrow> wf {(y,x). P x \<and> y = g x}" |
764 |
for f :: "'a \<Rightarrow> nat" |
|
68646 | 765 |
using wf_measure[of f] unfolding measure_def inv_image_def less_than_def less_eq |
766 |
by (rule wf_subset) auto |
|
41720 | 767 |
|
768 |
||
63108 | 769 |
subsubsection \<open>Lexicographic combinations\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
770 |
|
63108 | 771 |
definition lex_prod :: "('a \<times>'a) set \<Rightarrow> ('b \<times> 'b) set \<Rightarrow> (('a \<times> 'b) \<times> ('a \<times> 'b)) set" |
772 |
(infixr "<*lex*>" 80) |
|
72184 | 773 |
where "ra <*lex*> rb = {((a, b), (a', b')). (a, a') \<in> ra \<or> a = a' \<and> (b, b') \<in> rb}" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
774 |
|
72184 | 775 |
lemma in_lex_prod[simp]: "((a, b), (a', b')) \<in> r <*lex*> s \<longleftrightarrow> (a, a') \<in> r \<or> a = a' \<and> (b, b') \<in> s" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
776 |
by (auto simp:lex_prod_def) |
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
777 |
|
71410 | 778 |
lemma wf_lex_prod [intro!]: |
779 |
assumes "wf ra" "wf rb" |
|
780 |
shows "wf (ra <*lex*> rb)" |
|
781 |
proof (rule wfI) |
|
782 |
fix z :: "'a \<times> 'b" and P |
|
783 |
assume * [rule_format]: "\<forall>u. (\<forall>v. (v, u) \<in> ra <*lex*> rb \<longrightarrow> P v) \<longrightarrow> P u" |
|
784 |
obtain x y where zeq: "z = (x,y)" |
|
785 |
by fastforce |
|
786 |
have "P(x,y)" using \<open>wf ra\<close> |
|
787 |
proof (induction x arbitrary: y rule: wf_induct_rule) |
|
788 |
case (less x) |
|
789 |
note lessx = less |
|
790 |
show ?case using \<open>wf rb\<close> less |
|
791 |
proof (induction y rule: wf_induct_rule) |
|
792 |
case (less y) |
|
793 |
show ?case |
|
794 |
by (force intro: * less.IH lessx) |
|
795 |
qed |
|
796 |
qed |
|
797 |
then show "P z" |
|
798 |
by (simp add: zeq) |
|
799 |
qed auto |
|
800 |
||
63108 | 801 |
text \<open>\<open><*lex*>\<close> preserves transitivity\<close> |
72184 | 802 |
lemma trans_lex_prod [simp,intro!]: "trans R1 \<Longrightarrow> trans R2 \<Longrightarrow> trans (R1 <*lex*> R2)" |
803 |
unfolding trans_def lex_prod_def by blast |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
804 |
|
71404
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
805 |
lemma total_on_lex_prod [simp]: "total_on A r \<Longrightarrow> total_on B s \<Longrightarrow> total_on (A \<times> B) (r <*lex*> s)" |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
806 |
by (auto simp: total_on_def) |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
807 |
|
71935
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
808 |
lemma asym_lex_prod: "\<lbrakk>asym R; asym S\<rbrakk> \<Longrightarrow> asym (R <*lex*> S)" |
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
809 |
by (auto simp add: asym_iff lex_prod_def) |
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
810 |
|
71404
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
811 |
lemma total_lex_prod [simp]: "total r \<Longrightarrow> total s \<Longrightarrow> total (r <*lex*> s)" |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
812 |
by (auto simp: total_on_def) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
813 |
|
60758 | 814 |
text \<open>lexicographic combinations with measure functions\<close> |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
815 |
|
63108 | 816 |
definition mlex_prod :: "('a \<Rightarrow> nat) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set" (infixr "<*mlex*>" 80) |
817 |
where "f <*mlex*> R = inv_image (less_than <*lex*> R) (\<lambda>x. (f x, x))" |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
818 |
|
66952 | 819 |
lemma |
820 |
wf_mlex: "wf R \<Longrightarrow> wf (f <*mlex*> R)" and |
|
821 |
mlex_less: "f x < f y \<Longrightarrow> (x, y) \<in> f <*mlex*> R" and |
|
822 |
mlex_leq: "f x \<le> f y \<Longrightarrow> (x, y) \<in> R \<Longrightarrow> (x, y) \<in> f <*mlex*> R" and |
|
823 |
mlex_iff: "(x, y) \<in> f <*mlex*> R \<longleftrightarrow> f x < f y \<or> f x = f y \<and> (x, y) \<in> R" |
|
63572 | 824 |
by (auto simp: mlex_prod_def) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
825 |
|
63572 | 826 |
text \<open>Proper subset relation on finite sets.\<close> |
63108 | 827 |
definition finite_psubset :: "('a set \<times> 'a set) set" |
63572 | 828 |
where "finite_psubset = {(A, B). A \<subset> B \<and> finite B}" |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
829 |
|
63108 | 830 |
lemma wf_finite_psubset[simp]: "wf finite_psubset" |
831 |
apply (unfold finite_psubset_def) |
|
832 |
apply (rule wf_measure [THEN wf_subset]) |
|
833 |
apply (simp add: measure_def inv_image_def less_than_def less_eq) |
|
834 |
apply (fast elim!: psubset_card_mono) |
|
835 |
done |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
836 |
|
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
837 |
lemma trans_finite_psubset: "trans finite_psubset" |
63612 | 838 |
by (auto simp: finite_psubset_def less_le trans_def) |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
839 |
|
63572 | 840 |
lemma in_finite_psubset[simp]: "(A, B) \<in> finite_psubset \<longleftrightarrow> A \<subset> B \<and> finite B" |
63108 | 841 |
unfolding finite_psubset_def by auto |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
842 |
|
60758 | 843 |
text \<open>max- and min-extension of order to finite sets\<close> |
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
844 |
|
63108 | 845 |
inductive_set max_ext :: "('a \<times> 'a) set \<Rightarrow> ('a set \<times> 'a set) set" |
846 |
for R :: "('a \<times> 'a) set" |
|
63572 | 847 |
where max_extI[intro]: |
848 |
"finite X \<Longrightarrow> finite Y \<Longrightarrow> Y \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> \<exists>y\<in>Y. (x, y) \<in> R) \<Longrightarrow> (X, Y) \<in> max_ext R" |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
849 |
|
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
850 |
lemma max_ext_wf: |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
851 |
assumes wf: "wf r" |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
852 |
shows "wf (max_ext r)" |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
853 |
proof (rule acc_wfI, intro allI) |
63915 | 854 |
show "M \<in> acc (max_ext r)" (is "_ \<in> ?W") for M |
855 |
proof (induct M rule: infinite_finite_induct) |
|
856 |
case empty |
|
857 |
show ?case |
|
858 |
by (rule accI) (auto elim: max_ext.cases) |
|
859 |
next |
|
860 |
case (insert a M) |
|
861 |
from wf \<open>M \<in> ?W\<close> \<open>finite M\<close> show "insert a M \<in> ?W" |
|
862 |
proof (induct arbitrary: M) |
|
863 |
fix M a |
|
864 |
assume "M \<in> ?W" |
|
865 |
assume [intro]: "finite M" |
|
866 |
assume hyp: "\<And>b M. (b, a) \<in> r \<Longrightarrow> M \<in> ?W \<Longrightarrow> finite M \<Longrightarrow> insert b M \<in> ?W" |
|
867 |
have add_less: "M \<in> ?W \<Longrightarrow> (\<And>y. y \<in> N \<Longrightarrow> (y, a) \<in> r) \<Longrightarrow> N \<union> M \<in> ?W" |
|
868 |
if "finite N" "finite M" for N M :: "'a set" |
|
869 |
using that by (induct N arbitrary: M) (auto simp: hyp) |
|
870 |
show "insert a M \<in> ?W" |
|
871 |
proof (rule accI) |
|
872 |
fix N |
|
873 |
assume Nless: "(N, insert a M) \<in> max_ext r" |
|
874 |
then have *: "\<And>x. x \<in> N \<Longrightarrow> (x, a) \<in> r \<or> (\<exists>y \<in> M. (x, y) \<in> r)" |
|
875 |
by (auto elim!: max_ext.cases) |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
876 |
|
63915 | 877 |
let ?N1 = "{n \<in> N. (n, a) \<in> r}" |
878 |
let ?N2 = "{n \<in> N. (n, a) \<notin> r}" |
|
879 |
have N: "?N1 \<union> ?N2 = N" by (rule set_eqI) auto |
|
880 |
from Nless have "finite N" by (auto elim: max_ext.cases) |
|
881 |
then have finites: "finite ?N1" "finite ?N2" by auto |
|
63108 | 882 |
|
63915 | 883 |
have "?N2 \<in> ?W" |
884 |
proof (cases "M = {}") |
|
885 |
case [simp]: True |
|
886 |
have Mw: "{} \<in> ?W" by (rule accI) (auto elim: max_ext.cases) |
|
887 |
from * have "?N2 = {}" by auto |
|
888 |
with Mw show "?N2 \<in> ?W" by (simp only:) |
|
889 |
next |
|
890 |
case False |
|
891 |
from * finites have N2: "(?N2, M) \<in> max_ext r" |
|
892 |
by (rule_tac max_extI[OF _ _ \<open>M \<noteq> {}\<close>]) auto |
|
893 |
with \<open>M \<in> ?W\<close> show "?N2 \<in> ?W" by (rule acc_downward) |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
894 |
qed |
63915 | 895 |
with finites have "?N1 \<union> ?N2 \<in> ?W" |
896 |
by (rule add_less) simp |
|
897 |
then show "N \<in> ?W" by (simp only: N) |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
898 |
qed |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
899 |
qed |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
900 |
next |
63982 | 901 |
case infinite |
902 |
show ?case |
|
903 |
by (rule accI) (auto elim: max_ext.cases simp: infinite) |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
904 |
qed |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
905 |
qed |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
906 |
|
63572 | 907 |
lemma max_ext_additive: "(A, B) \<in> max_ext R \<Longrightarrow> (C, D) \<in> max_ext R \<Longrightarrow> (A \<union> C, B \<union> D) \<in> max_ext R" |
63108 | 908 |
by (force elim!: max_ext.cases) |
29125
d41182a8135c
method "sizechange" proves termination of functions; added more infrastructure for termination proofs
krauss
parents:
28845
diff
changeset
|
909 |
|
63108 | 910 |
definition min_ext :: "('a \<times> 'a) set \<Rightarrow> ('a set \<times> 'a set) set" |
911 |
where "min_ext r = {(X, Y) | X Y. X \<noteq> {} \<and> (\<forall>y \<in> Y. (\<exists>x \<in> X. (x, y) \<in> r))}" |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
912 |
|
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
913 |
lemma min_ext_wf: |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
914 |
assumes "wf r" |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
915 |
shows "wf (min_ext r)" |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
916 |
proof (rule wfI_min) |
66952 | 917 |
show "\<exists>m \<in> Q. (\<forall>n. (n, m) \<in> min_ext r \<longrightarrow> n \<notin> Q)" if nonempty: "x \<in> Q" |
63108 | 918 |
for Q :: "'a set set" and x |
919 |
proof (cases "Q = {{}}") |
|
920 |
case True |
|
921 |
then show ?thesis by (simp add: min_ext_def) |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
922 |
next |
63108 | 923 |
case False |
924 |
with nonempty obtain e x where "x \<in> Q" "e \<in> x" by force |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
925 |
then have eU: "e \<in> \<Union>Q" by auto |
63108 | 926 |
with \<open>wf r\<close> |
927 |
obtain z where z: "z \<in> \<Union>Q" "\<And>y. (y, z) \<in> r \<Longrightarrow> y \<notin> \<Union>Q" |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
928 |
by (erule wfE_min) |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
929 |
from z obtain m where "m \<in> Q" "z \<in> m" by auto |
63572 | 930 |
from \<open>m \<in> Q\<close> show ?thesis |
931 |
proof (intro rev_bexI allI impI) |
|
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
932 |
fix n |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
933 |
assume smaller: "(n, m) \<in> min_ext r" |
63572 | 934 |
with \<open>z \<in> m\<close> obtain y where "y \<in> n" "(y, z) \<in> r" |
935 |
by (auto simp: min_ext_def) |
|
936 |
with z(2) show "n \<notin> Q" by auto |
|
63108 | 937 |
qed |
28735
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
938 |
qed |
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
krauss
parents:
28562
diff
changeset
|
939 |
qed |
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
940 |
|
63108 | 941 |
|
942 |
subsubsection \<open>Bounded increase must terminate\<close> |
|
43137 | 943 |
|
944 |
lemma wf_bounded_measure: |
|
63108 | 945 |
fixes ub :: "'a \<Rightarrow> nat" |
946 |
and f :: "'a \<Rightarrow> nat" |
|
947 |
assumes "\<And>a b. (b, a) \<in> r \<Longrightarrow> ub b \<le> ub a \<and> ub a \<ge> f b \<and> f b > f a" |
|
948 |
shows "wf r" |
|
63572 | 949 |
by (rule wf_subset[OF wf_measure[of "\<lambda>a. ub a - f a"]]) (auto dest: assms) |
43137 | 950 |
|
951 |
lemma wf_bounded_set: |
|
63108 | 952 |
fixes ub :: "'a \<Rightarrow> 'b set" |
953 |
and f :: "'a \<Rightarrow> 'b set" |
|
954 |
assumes "\<And>a b. (b,a) \<in> r \<Longrightarrow> finite (ub a) \<and> ub b \<subseteq> ub a \<and> ub a \<supseteq> f b \<and> f b \<supset> f a" |
|
955 |
shows "wf r" |
|
63572 | 956 |
apply (rule wf_bounded_measure[of r "\<lambda>a. card (ub a)" "\<lambda>a. card (f a)"]) |
957 |
apply (drule assms) |
|
63108 | 958 |
apply (blast intro: card_mono finite_subset psubset_card_mono dest: psubset_eq[THEN iffD2]) |
959 |
done |
|
43137 | 960 |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
63088
diff
changeset
|
961 |
lemma finite_subset_wf: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
63088
diff
changeset
|
962 |
assumes "finite A" |
66952 | 963 |
shows "wf {(X, Y). X \<subset> Y \<and> Y \<subseteq> A}" |
964 |
by (rule wf_subset[OF wf_finite_psubset[unfolded finite_psubset_def]]) |
|
965 |
(auto intro: finite_subset[OF _ assms]) |
|
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
966 |
|
54295 | 967 |
hide_const (open) acc accp |
968 |
||
26748
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
krauss
parents:
diff
changeset
|
969 |
end |