| author | paulson <lp15@cam.ac.uk> | 
| Fri, 02 May 2025 16:25:38 +0100 | |
| changeset 82595 | c0587d661ea8 | 
| parent 82342 | 4238ebc9918d | 
| 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  | 
| 
80046
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
7  | 
Author: Martin Desharnais, MPI-INF Saarbruecken  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
8  | 
*)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
9  | 
|
| 60758 | 10  | 
section \<open>Well-founded Recursion\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
11  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
12  | 
theory Wellfounded  | 
| 63572 | 13  | 
imports Transitive_Closure  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
14  | 
begin  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
15  | 
|
| 60758 | 16  | 
subsection \<open>Basic Definitions\<close>  | 
| 26976 | 17  | 
|
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
18  | 
definition wf_on :: "'a set \<Rightarrow> 'a rel \<Rightarrow> bool" where  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
19  | 
"wf_on A r \<longleftrightarrow> (\<forall>P. (\<forall>x \<in> A. (\<forall>y \<in> A. (y, x) \<in> r \<longrightarrow> P y) \<longrightarrow> P x) \<longrightarrow> (\<forall>x \<in> A. P x))"  | 
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
20  | 
|
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
21  | 
abbreviation wf :: "('a \<times> 'a) set \<Rightarrow> bool" where
 | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
22  | 
"wf \<equiv> wf_on UNIV"  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
23  | 
|
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
24  | 
definition wfp_on :: "'a set \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
 | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
25  | 
"wfp_on A R \<longleftrightarrow> (\<forall>P. (\<forall>x \<in> A. (\<forall>y \<in> A. R y x \<longrightarrow> P y) \<longrightarrow> P x) \<longrightarrow> (\<forall>x \<in> A. P x))"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
26  | 
|
| 
79965
 
233d70cad0cf
redefined wfP as an abbreviation for "wfp_on UNIV"
 
desharna 
parents: 
79963 
diff
changeset
 | 
27  | 
abbreviation wfP :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
 | 
| 
 
233d70cad0cf
redefined wfP as an abbreviation for "wfp_on UNIV"
 
desharna 
parents: 
79963 
diff
changeset
 | 
28  | 
"wfP \<equiv> wfp_on UNIV"  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
29  | 
|
| 79924 | 30  | 
alias wfp = wfP  | 
31  | 
||
32  | 
text \<open>We keep old name \<^const>\<open>wfP\<close> for backward compatibility, but offer new name \<^const>\<open>wfp\<close> to be  | 
|
33  | 
consistent with similar predicates, e.g., \<^const>\<open>asymp\<close>, \<^const>\<open>transp\<close>, \<^const>\<open>totalp\<close>.\<close>  | 
|
34  | 
||
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
35  | 
|
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
36  | 
subsection \<open>Equivalence of Definitions\<close>  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
37  | 
|
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
38  | 
lemma wfp_on_wf_on_eq[pred_set_conv]: "wfp_on A (\<lambda>x y. (x, y) \<in> r) \<longleftrightarrow> wf_on A r"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
39  | 
by (simp add: wfp_on_def wf_on_def)  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
40  | 
|
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
41  | 
lemma wf_def: "wf r \<longleftrightarrow> (\<forall>P. (\<forall>x. (\<forall>y. (y, x) \<in> r \<longrightarrow> P y) \<longrightarrow> P x) \<longrightarrow> (\<forall>x. P x))"  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
42  | 
unfolding wf_on_def by simp  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
43  | 
|
| 80322 | 44  | 
lemma wfp_def: "wfp r \<longleftrightarrow> wf {(x, y). r x y}"
 | 
| 
79965
 
233d70cad0cf
redefined wfP as an abbreviation for "wfp_on UNIV"
 
desharna 
parents: 
79963 
diff
changeset
 | 
45  | 
unfolding wf_def wfp_on_def by simp  | 
| 
 
233d70cad0cf
redefined wfP as an abbreviation for "wfp_on UNIV"
 
desharna 
parents: 
79963 
diff
changeset
 | 
46  | 
|
| 80322 | 47  | 
lemma wfp_wf_eq: "wfp (\<lambda>x y. (x, y) \<in> r) = wf r"  | 
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
48  | 
using wfp_on_wf_on_eq .  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
49  | 
|
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
50  | 
|
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
51  | 
subsection \<open>Induction Principles\<close>  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
52  | 
|
| 
79996
 
4f803ae64781
changed number of consumed assumptions of wf_on_induct and wfp_on_induct
 
desharna 
parents: 
79971 
diff
changeset
 | 
53  | 
lemma wf_on_induct[consumes 1, case_names in_set less, induct set: wf_on]:  | 
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
54  | 
assumes "wf_on A r" and "x \<in> A" and "\<And>x. x \<in> A \<Longrightarrow> (\<And>y. y \<in> A \<Longrightarrow> (y, x) \<in> r \<Longrightarrow> P y) \<Longrightarrow> P x"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
55  | 
shows "P x"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
56  | 
using assms(2,3) by (auto intro: \<open>wf_on A r\<close>[unfolded wf_on_def, rule_format])  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
57  | 
|
| 
79996
 
4f803ae64781
changed number of consumed assumptions of wf_on_induct and wfp_on_induct
 
desharna 
parents: 
79971 
diff
changeset
 | 
58  | 
lemma wfp_on_induct[consumes 1, case_names in_set less, induct pred: wfp_on]:  | 
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
59  | 
assumes "wfp_on A r" and "x \<in> A" and "\<And>x. x \<in> A \<Longrightarrow> (\<And>y. y \<in> A \<Longrightarrow> r y x \<Longrightarrow> P y) \<Longrightarrow> P x"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
60  | 
shows "P x"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
61  | 
using assms by (fact wf_on_induct[to_pred])  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
62  | 
|
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
63  | 
lemma wf_induct:  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
64  | 
assumes "wf r"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
65  | 
and "\<And>x. \<forall>y. (y, x) \<in> r \<longrightarrow> P y \<Longrightarrow> P x"  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
66  | 
shows "P a"  | 
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
67  | 
using assms by (auto intro: wf_on_induct[of UNIV])  | 
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
68  | 
|
| 80322 | 69  | 
lemmas wfp_induct = wf_induct [to_pred]  | 
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
70  | 
|
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
71  | 
lemmas wf_induct_rule = wf_induct [rule_format, consumes 1, case_names less, induct set: wf]  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
72  | 
|
| 80322 | 73  | 
lemmas wfp_induct_rule = wf_induct_rule [to_pred, induct set: wfp]  | 
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
74  | 
|
| 79997 | 75  | 
lemma wf_on_iff_wf: "wf_on A r \<longleftrightarrow> wf {(x, y) \<in> r. x \<in> A \<and> y \<in> A}"
 | 
76  | 
proof (rule iffI)  | 
|
77  | 
assume wf: "wf_on A r"  | 
|
78  | 
  show "wf {(x, y) \<in> r. x \<in> A \<and> y \<in> A}"
 | 
|
79  | 
unfolding wf_def  | 
|
80  | 
proof (intro allI impI ballI)  | 
|
81  | 
fix P x  | 
|
82  | 
    assume IH: "\<forall>x. (\<forall>y. (y, x) \<in> {(x, y). (x, y) \<in> r \<and> x \<in> A \<and> y \<in> A} \<longrightarrow> P y) \<longrightarrow> P x"
 | 
|
83  | 
show "P x"  | 
|
84  | 
proof (cases "x \<in> A")  | 
|
85  | 
case True  | 
|
86  | 
show ?thesis  | 
|
87  | 
using wf  | 
|
88  | 
proof (induction x rule: wf_on_induct)  | 
|
89  | 
case in_set  | 
|
90  | 
thus ?case  | 
|
91  | 
using True .  | 
|
92  | 
next  | 
|
93  | 
case (less x)  | 
|
94  | 
thus ?case  | 
|
95  | 
by (auto intro: IH[rule_format])  | 
|
96  | 
qed  | 
|
97  | 
next  | 
|
98  | 
case False  | 
|
99  | 
then show ?thesis  | 
|
100  | 
by (auto intro: IH[rule_format])  | 
|
101  | 
qed  | 
|
102  | 
qed  | 
|
103  | 
next  | 
|
104  | 
  assume wf: "wf {(x, y). (x, y) \<in> r \<and> x \<in> A \<and> y \<in> A}"
 | 
|
105  | 
show "wf_on A r"  | 
|
106  | 
unfolding wf_on_def  | 
|
107  | 
proof (intro allI impI ballI)  | 
|
108  | 
fix P x  | 
|
109  | 
assume IH: "\<forall>x\<in>A. (\<forall>y\<in>A. (y, x) \<in> r \<longrightarrow> P y) \<longrightarrow> P x" and "x \<in> A"  | 
|
110  | 
show "P x"  | 
|
111  | 
using wf \<open>x \<in> A\<close>  | 
|
112  | 
proof (induction x rule: wf_on_induct)  | 
|
113  | 
case in_set  | 
|
114  | 
show ?case  | 
|
115  | 
by simp  | 
|
116  | 
next  | 
|
117  | 
case (less y)  | 
|
118  | 
hence "\<And>z. (z, y) \<in> r \<Longrightarrow> z \<in> A \<Longrightarrow> P z"  | 
|
119  | 
by simp  | 
|
120  | 
thus ?case  | 
|
121  | 
using IH[rule_format, OF \<open>y \<in> A\<close>] by simp  | 
|
122  | 
qed  | 
|
123  | 
qed  | 
|
124  | 
qed  | 
|
125  | 
||
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
126  | 
|
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
127  | 
subsection \<open>Introduction Rules\<close>  | 
| 
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
128  | 
|
| 63108 | 129  | 
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
 | 
130  | 
unfolding wf_def by blast  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
131  | 
|
| 80322 | 132  | 
lemmas wfpUNIVI = wfUNIVI [to_pred]  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
133  | 
|
| 63108 | 134  | 
text \<open>Restriction to domain \<open>A\<close> and range \<open>B\<close>.  | 
135  | 
If \<open>r\<close> is well-founded over their intersection, then \<open>wf r\<close>.\<close>  | 
|
136  | 
lemma wfI:  | 
|
137  | 
assumes "r \<subseteq> A \<times> B"  | 
|
138  | 
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"  | 
|
139  | 
shows "wf r"  | 
|
140  | 
using assms unfolding wf_def by blast  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
141  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
142  | 
|
| 
79917
 
d0205dde00bb
added definitions wf_on and wfp_on as restricted versions of wf and wfP respectively
 
desharna 
parents: 
77172 
diff
changeset
 | 
143  | 
subsection \<open>Ordering Properties\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
144  | 
|
| 63108 | 145  | 
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
 | 
146  | 
by (induct a arbitrary: x set: wf) blast  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
147  | 
|
| 
33215
 
6fd85372981e
replaced (outdated) comments by explicit statements
 
krauss 
parents: 
32960 
diff
changeset
 | 
148  | 
lemma wf_asym:  | 
| 
 
6fd85372981e
replaced (outdated) comments by explicit statements
 
krauss 
parents: 
32960 
diff
changeset
 | 
149  | 
assumes "wf r" "(a, x) \<in> r"  | 
| 
 
6fd85372981e
replaced (outdated) comments by explicit statements
 
krauss 
parents: 
32960 
diff
changeset
 | 
150  | 
obtains "(x, a) \<notin> r"  | 
| 
 
6fd85372981e
replaced (outdated) comments by explicit statements
 
krauss 
parents: 
32960 
diff
changeset
 | 
151  | 
by (drule wf_not_sym[OF assms])  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
152  | 
|
| 
74971
 
16eaa56f69f7
added lemmas wf_imp_asym, wfP_imp_asymp, and wfP_imp_irreflp
 
desharna 
parents: 
74868 
diff
changeset
 | 
153  | 
lemma wf_imp_asym: "wf r \<Longrightarrow> asym r"  | 
| 
 
16eaa56f69f7
added lemmas wf_imp_asym, wfP_imp_asymp, and wfP_imp_irreflp
 
desharna 
parents: 
74868 
diff
changeset
 | 
154  | 
by (auto intro: asymI elim: wf_asym)  | 
| 
 
16eaa56f69f7
added lemmas wf_imp_asym, wfP_imp_asymp, and wfP_imp_irreflp
 
desharna 
parents: 
74868 
diff
changeset
 | 
155  | 
|
| 80322 | 156  | 
lemma wfp_imp_asymp: "wfp r \<Longrightarrow> asymp r"  | 
| 
74971
 
16eaa56f69f7
added lemmas wf_imp_asym, wfP_imp_asymp, and wfP_imp_irreflp
 
desharna 
parents: 
74868 
diff
changeset
 | 
157  | 
by (rule wf_imp_asym[to_pred])  | 
| 
 
16eaa56f69f7
added lemmas wf_imp_asym, wfP_imp_asymp, and wfP_imp_irreflp
 
desharna 
parents: 
74868 
diff
changeset
 | 
158  | 
|
| 63108 | 159  | 
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
 | 
160  | 
by (blast elim: wf_asym)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
161  | 
|
| 63572 | 162  | 
lemma wf_irrefl:  | 
163  | 
assumes "wf r"  | 
|
164  | 
obtains "(a, a) \<notin> r"  | 
|
| 63108 | 165  | 
by (drule wf_not_refl[OF assms])  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
166  | 
|
| 
72170
 
7fa9605b226c
Another go with lex: now lexordp back in class ord
 
paulson <lp15@cam.ac.uk> 
parents: 
72168 
diff
changeset
 | 
167  | 
lemma wf_imp_irrefl:  | 
| 
 
7fa9605b226c
Another go with lex: now lexordp back in class ord
 
paulson <lp15@cam.ac.uk> 
parents: 
72168 
diff
changeset
 | 
168  | 
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
 | 
169  | 
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
 | 
170  | 
|
| 80322 | 171  | 
lemma wfp_imp_irreflp: "wfp r \<Longrightarrow> irreflp r"  | 
| 
76588
 
82a36e3d1b55
rewrite proofs using to_pred attribute on existing lemmas
 
desharna 
parents: 
76559 
diff
changeset
 | 
172  | 
by (rule wf_imp_irrefl[to_pred])  | 
| 
74971
 
16eaa56f69f7
added lemmas wf_imp_asym, wfP_imp_asymp, and wfP_imp_irreflp
 
desharna 
parents: 
74868 
diff
changeset
 | 
173  | 
|
| 27823 | 174  | 
lemma wf_wellorderI:  | 
175  | 
  assumes wf: "wf {(x::'a::ord, y). x < y}"
 | 
|
| 63572 | 176  | 
    and lin: "OFCLASS('a::ord, linorder_class)"
 | 
| 27823 | 177  | 
  shows "OFCLASS('a::ord, wellorder_class)"
 | 
| 71410 | 178  | 
apply (rule wellorder_class.intro [OF lin])  | 
179  | 
apply (simp add: wellorder_class.intro class.wellorder_axioms.intro wf_induct_rule [OF wf])  | 
|
| 63108 | 180  | 
done  | 
| 27823 | 181  | 
|
| 63108 | 182  | 
lemma (in wellorder) wf: "wf {(x, y). x < y}"
 | 
183  | 
unfolding wf_def by (blast intro: less_induct)  | 
|
| 27823 | 184  | 
|
| 79963 | 185  | 
lemma (in wellorder) wfp_on_less[simp]: "wfp_on A (<)"  | 
186  | 
unfolding wfp_on_def  | 
|
187  | 
proof (intro allI impI ballI)  | 
|
188  | 
fix P x  | 
|
189  | 
assume hyps: "\<forall>x\<in>A. (\<forall>y\<in>A. y < x \<longrightarrow> P y) \<longrightarrow> P x"  | 
|
190  | 
show "x \<in> A \<Longrightarrow> P x"  | 
|
191  | 
proof (induction x rule: less_induct)  | 
|
192  | 
case (less x)  | 
|
193  | 
show ?case  | 
|
194  | 
proof (rule hyps[rule_format])  | 
|
195  | 
show "x \<in> A"  | 
|
196  | 
using \<open>x \<in> A\<close> .  | 
|
197  | 
next  | 
|
198  | 
show "\<And>y. y \<in> A \<Longrightarrow> y < x \<Longrightarrow> P y"  | 
|
199  | 
using less.IH .  | 
|
200  | 
qed  | 
|
201  | 
qed  | 
|
202  | 
qed  | 
|
203  | 
||
| 27823 | 204  | 
|
| 60758 | 205  | 
subsection \<open>Basic Results\<close>  | 
| 26976 | 206  | 
|
| 60758 | 207  | 
text \<open>Point-free characterization of well-foundedness\<close>  | 
| 33216 | 208  | 
|
| 
79919
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
209  | 
lemma wf_onE_pf:  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
210  | 
assumes wf: "wf_on A r" and "B \<subseteq> A" and "B \<subseteq> r `` B"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
211  | 
  shows "B = {}"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
212  | 
proof -  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
213  | 
have "x \<notin> B" if "x \<in> A" for x  | 
| 
79996
 
4f803ae64781
changed number of consumed assumptions of wf_on_induct and wfp_on_induct
 
desharna 
parents: 
79971 
diff
changeset
 | 
214  | 
using wf  | 
| 
79919
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
215  | 
proof (induction x rule: wf_on_induct)  | 
| 
79996
 
4f803ae64781
changed number of consumed assumptions of wf_on_induct and wfp_on_induct
 
desharna 
parents: 
79971 
diff
changeset
 | 
216  | 
case in_set  | 
| 
 
4f803ae64781
changed number of consumed assumptions of wf_on_induct and wfp_on_induct
 
desharna 
parents: 
79971 
diff
changeset
 | 
217  | 
show ?case  | 
| 
 
4f803ae64781
changed number of consumed assumptions of wf_on_induct and wfp_on_induct
 
desharna 
parents: 
79971 
diff
changeset
 | 
218  | 
using that .  | 
| 
 
4f803ae64781
changed number of consumed assumptions of wf_on_induct and wfp_on_induct
 
desharna 
parents: 
79971 
diff
changeset
 | 
219  | 
next  | 
| 
79919
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
220  | 
case (less x)  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
221  | 
have "x \<notin> r `` B"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
222  | 
using less.IH \<open>B \<subseteq> A\<close> by blast  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
223  | 
thus ?case  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
224  | 
using \<open>B \<subseteq> r `` B\<close> by blast  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
225  | 
qed  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
226  | 
with \<open>B \<subseteq> A\<close> show ?thesis  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
227  | 
by blast  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
228  | 
qed  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
229  | 
|
| 79920 | 230  | 
lemma wfE_pf: "wf R \<Longrightarrow> A \<subseteq> R `` A \<Longrightarrow> A = {}"
 | 
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
231  | 
using wf_onE_pf[of UNIV, simplified] .  | 
| 33216 | 232  | 
|
| 
79919
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
233  | 
lemma wf_onI_pf:  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
234  | 
  assumes "\<And>B. B \<subseteq> A \<Longrightarrow> B \<subseteq> R `` B \<Longrightarrow> B = {}"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
235  | 
shows "wf_on A R"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
236  | 
unfolding wf_on_def  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
237  | 
proof (intro allI impI ballI)  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
238  | 
fix P :: "'a \<Rightarrow> bool" and x :: 'a  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
239  | 
  let ?B = "{x \<in> A. \<not> P x}"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
240  | 
assume "\<forall>x\<in>A. (\<forall>y\<in>A. (y, x) \<in> R \<longrightarrow> P y) \<longrightarrow> P x"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
241  | 
hence "?B \<subseteq> R `` ?B" by blast  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
242  | 
  hence "{x \<in> A. \<not> P x} = {}"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
243  | 
using assms(1)[of ?B] by simp  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
244  | 
moreover assume "x \<in> A"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
245  | 
ultimately show "P x"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
246  | 
by simp  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
247  | 
qed  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
248  | 
|
| 79920 | 249  | 
lemma wfI_pf: "(\<And>A. A \<subseteq> R `` A \<Longrightarrow> A = {}) \<Longrightarrow> wf R"
 | 
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
250  | 
using wf_onI_pf[of UNIV, simplified] .  | 
| 33216 | 251  | 
|
| 63108 | 252  | 
|
253  | 
subsubsection \<open>Minimal-element characterization of well-foundedness\<close>  | 
|
| 33216 | 254  | 
|
| 
79919
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
255  | 
lemma wf_on_iff_ex_minimal: "wf_on A R \<longleftrightarrow> (\<forall>B \<subseteq> A. B \<noteq> {} \<longrightarrow> (\<exists>z \<in> B. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> B))"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
256  | 
proof (intro iffI allI impI)  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
257  | 
fix B  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
258  | 
  assume "wf_on A R" and "B \<subseteq> A" and "B \<noteq> {}"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
259  | 
show "\<exists>z \<in> B. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> B"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
260  | 
  using wf_onE_pf[OF \<open>wf_on A R\<close> \<open>B \<subseteq> A\<close>] \<open>B \<noteq> {}\<close> by blast
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
261  | 
next  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
262  | 
  assume ex_min: "\<forall>B\<subseteq>A. B \<noteq> {} \<longrightarrow> (\<exists>z\<in>B. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> B)"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
263  | 
show "wf_on A R "  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
264  | 
proof (rule wf_onI_pf)  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
265  | 
fix B  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
266  | 
assume "B \<subseteq> A" and "B \<subseteq> R `` B"  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
267  | 
    have False if "B \<noteq> {}"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
268  | 
      using ex_min[rule_format, OF \<open>B \<subseteq> A\<close> \<open>B \<noteq> {}\<close>]
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
269  | 
using \<open>B \<subseteq> R `` B\<close> by blast  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
270  | 
    thus "B = {}"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
271  | 
by blast  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
272  | 
qed  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
273  | 
qed  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
274  | 
|
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
275  | 
lemma wf_iff_ex_minimal: "wf R \<longleftrightarrow> (\<forall>B. B \<noteq> {} \<longrightarrow> (\<exists>z \<in> B. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> B))"
 | 
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
276  | 
using wf_on_iff_ex_minimal[of UNIV, simplified] .  | 
| 
79919
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
277  | 
|
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
278  | 
lemma wfp_on_iff_ex_minimal: "wfp_on A R \<longleftrightarrow> (\<forall>B \<subseteq> A. B \<noteq> {} \<longrightarrow> (\<exists>z \<in> B. \<forall>y. R y z \<longrightarrow> y \<notin> B))"
 | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
279  | 
using wf_on_iff_ex_minimal[of A, to_pred] by simp  | 
| 
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
280  | 
|
| 
80019
 
991557e01814
renamed lemma wfP_iff_ex_minimal to wfp_iff_ex_minimal
 
desharna 
parents: 
79999 
diff
changeset
 | 
281  | 
lemma wfp_iff_ex_minimal: "wfp R \<longleftrightarrow> (\<forall>B. B \<noteq> {} \<longrightarrow> (\<exists>z \<in> B. \<forall>y. R y z \<longrightarrow> y \<notin> B))"
 | 
| 
79965
 
233d70cad0cf
redefined wfP as an abbreviation for "wfp_on UNIV"
 
desharna 
parents: 
79963 
diff
changeset
 | 
282  | 
using wfp_on_iff_ex_minimal[of UNIV, simplified] .  | 
| 
79919
 
65e0682cca63
added lemmas wfP_iff_ex_minimal, wf_iff_ex_minimal, wf_onE_pf, wf_onI_pf, wf_on_iff_ex_minimal, and wfp_on_iff_ex_minimal
 
desharna 
parents: 
79917 
diff
changeset
 | 
283  | 
|
| 33216 | 284  | 
lemma wfE_min:  | 
285  | 
assumes wf: "wf R" and Q: "x \<in> Q"  | 
|
286  | 
obtains z where "z \<in> Q" "\<And>y. (y, z) \<in> R \<Longrightarrow> y \<notin> Q"  | 
|
287  | 
using Q wfE_pf[OF wf, of Q] by blast  | 
|
288  | 
||
| 
63099
 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 
eberlm 
parents: 
63088 
diff
changeset
 | 
289  | 
lemma wfE_min':  | 
| 
 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 
eberlm 
parents: 
63088 
diff
changeset
 | 
290  | 
  "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
 | 
291  | 
using wfE_min[of R _ Q] by blast  | 
| 
 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 
eberlm 
parents: 
63088 
diff
changeset
 | 
292  | 
|
| 33216 | 293  | 
lemma wfI_min:  | 
294  | 
assumes a: "\<And>x Q. x \<in> Q \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> Q"  | 
|
295  | 
shows "wf R"  | 
|
296  | 
proof (rule wfI_pf)  | 
|
| 63108 | 297  | 
fix A  | 
298  | 
assume b: "A \<subseteq> R `` A"  | 
|
299  | 
have False if "x \<in> A" for x  | 
|
300  | 
using a[OF that] b by blast  | 
|
301  | 
  then show "A = {}" by blast
 | 
|
| 33216 | 302  | 
qed  | 
303  | 
||
| 63108 | 304  | 
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))"  | 
| 79920 | 305  | 
unfolding wf_iff_ex_minimal by blast  | 
| 33216 | 306  | 
|
| 80322 | 307  | 
lemmas wfp_eq_minimal = wf_eq_minimal [to_pred]  | 
| 33216 | 308  | 
|
| 63108 | 309  | 
|
| 
82056
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
310  | 
subsubsection \<open>Finite characterization of well-foundedness\<close>  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
311  | 
|
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
312  | 
lemma strict_partial_order_wfp_on_finite_set:  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
313  | 
assumes "transp_on \<X> R" and "asymp_on \<X> R" and "finite \<X>"  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
314  | 
shows "wfp_on \<X> R"  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
315  | 
unfolding Wellfounded.wfp_on_iff_ex_minimal  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
316  | 
proof (intro allI impI)  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
317  | 
fix \<W>  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
318  | 
  assume "\<W> \<subseteq> \<X>" and "\<W> \<noteq> {}"
 | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
319  | 
|
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
320  | 
have "finite \<W>"  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
321  | 
using finite_subset[OF \<open>\<W> \<subseteq> \<X>\<close> \<open>finite \<X>\<close>] .  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
322  | 
|
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
323  | 
moreover have "asymp_on \<W> R"  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
324  | 
using asymp_on_subset[OF \<open>asymp_on \<X> R\<close> \<open>\<W> \<subseteq> \<X>\<close>] .  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
325  | 
|
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
326  | 
moreover have "transp_on \<W> R"  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
327  | 
using transp_on_subset[OF \<open>transp_on \<X> R\<close> \<open>\<W> \<subseteq> \<X>\<close>] .  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
328  | 
|
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
329  | 
ultimately have "\<exists>m\<in>\<W>. \<forall>x\<in>\<W>. x \<noteq> m \<longrightarrow> \<not> R x m"  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
330  | 
    using \<open>\<W> \<noteq> {}\<close> Finite_Set.bex_min_element[of \<W> R] by iprover
 | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
331  | 
|
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
332  | 
thus "\<exists>z\<in>\<W>. \<forall>y. R y z \<longrightarrow> y \<notin> \<W>"  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
333  | 
using asymp_onD[OF \<open>asymp_on \<W> R\<close>] by fast  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
334  | 
qed  | 
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
335  | 
|
| 
 
361fbb3e21c8
added lemma strict_partial_order_wfp_on_finite_set
 
desharna 
parents: 
80932 
diff
changeset
 | 
336  | 
|
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
337  | 
subsubsection \<open>Antimonotonicity\<close>  | 
| 
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
338  | 
|
| 
80572
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
339  | 
|
| 82342 | 340  | 
lemma wfp_on_mono_stronger:  | 
| 
80572
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
341  | 
fixes  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
342  | 
A :: "'a set" and B :: "'b set" and  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
343  | 
f :: "'a \<Rightarrow> 'b" and  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
344  | 
R :: "'b \<Rightarrow> 'b \<Rightarrow> bool" and Q :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
345  | 
assumes  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
346  | 
wf: "wfp_on B R" and  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
347  | 
sub: "f ` A \<subseteq> B" and  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
348  | 
mono: "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> Q x y \<Longrightarrow> R (f x) (f y)"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
349  | 
shows "wfp_on A Q"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
350  | 
unfolding wfp_on_iff_ex_minimal  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
351  | 
proof (intro allI impI)  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
352  | 
fix A' :: "'a set"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
353  | 
  assume "A' \<subseteq> A" and "A' \<noteq> {}"
 | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
354  | 
have "f ` A' \<subseteq> B"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
355  | 
using \<open>A' \<subseteq> A\<close> sub by blast  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
356  | 
  moreover have "f ` A' \<noteq> {}"
 | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
357  | 
    using \<open>A' \<noteq> {}\<close> by blast
 | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
358  | 
ultimately have "\<exists>z\<in>f ` A'. \<forall>y. R y z \<longrightarrow> y \<notin> f ` A'"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
359  | 
using wf wfp_on_iff_ex_minimal by blast  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
360  | 
hence "\<exists>z\<in>A'. \<forall>y. R (f y) (f z) \<longrightarrow> y \<notin> A'"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
361  | 
by blast  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
362  | 
thus "\<exists>z\<in>A'. \<forall>y. Q y z \<longrightarrow> y \<notin> A'"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
363  | 
using \<open>A' \<subseteq> A\<close> mono by blast  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
364  | 
qed  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
365  | 
|
| 82342 | 366  | 
lemma wf_on_mono_stronger:  | 
| 
80572
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
367  | 
assumes  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
368  | 
"wf_on B r" and  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
369  | 
"f ` A \<subseteq> B" and  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
370  | 
"(\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> (x, y) \<in> q \<Longrightarrow> (f x, f y) \<in> r)"  | 
| 
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
371  | 
shows "wf_on A q"  | 
| 82342 | 372  | 
using assms wfp_on_mono_stronger[to_set, of B r f A q] by blast  | 
| 
80572
 
6ab6431864b6
added lemmas wfp_on_antimono_stronger and wf_on_antimono_stronger
 
desharna 
parents: 
80397 
diff
changeset
 | 
373  | 
|
| 82342 | 374  | 
lemma wf_on_mono_strong:  | 
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
375  | 
assumes "wf_on B r" and "A \<subseteq> B" and "(\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> (x, y) \<in> q \<Longrightarrow> (x, y) \<in> r)"  | 
| 
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
376  | 
shows "wf_on A q"  | 
| 82342 | 377  | 
using assms wf_on_mono_stronger[of B r "\<lambda>x. x" A q] by blast  | 
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
378  | 
|
| 82342 | 379  | 
lemma wfp_on_mono_strong:  | 
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
380  | 
"wfp_on B R \<Longrightarrow> A \<subseteq> B \<Longrightarrow> (\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> Q x y \<Longrightarrow> R x y) \<Longrightarrow> wfp_on A Q"  | 
| 82342 | 381  | 
using wf_on_mono_strong[of B _ A, to_pred] .  | 
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
382  | 
|
| 82342 | 383  | 
lemma wf_on_mono: "A \<subseteq> B \<Longrightarrow> q \<subseteq> r \<Longrightarrow> wf_on B r \<le> wf_on A q"  | 
384  | 
using wf_on_mono_strong[of B r A q] by auto  | 
|
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
385  | 
|
| 82342 | 386  | 
lemma wfp_on_mono: "A \<subseteq> B \<Longrightarrow> Q \<le> R \<Longrightarrow> wfp_on B R \<le> wfp_on A Q"  | 
387  | 
using wfp_on_mono_strong[of B R A Q] by auto  | 
|
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
388  | 
|
| 
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
389  | 
lemma wf_on_subset: "wf_on B r \<Longrightarrow> A \<subseteq> B \<Longrightarrow> wf_on A r"  | 
| 82342 | 390  | 
using wf_on_mono_strong .  | 
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
391  | 
|
| 
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
392  | 
lemma wfp_on_subset: "wfp_on B R \<Longrightarrow> A \<subseteq> B \<Longrightarrow> wfp_on A R"  | 
| 82342 | 393  | 
using wfp_on_mono_strong .  | 
| 
79922
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
394  | 
|
| 
 
caa9dbffd712
added lemmas wf_on_antimono, wf_on_antimono_strong, wfp_on_antimono, wfp_on_antimono_strong, wf_on_subset, and wfp_on_subset
 
desharna 
parents: 
79920 
diff
changeset
 | 
395  | 
|
| 82241 | 396  | 
subsubsection \<open>Equivalence between \<^const>\<open>wfp_on\<close> and \<^const>\<open>wfp\<close>\<close>  | 
397  | 
||
398  | 
lemma wfp_on_iff_wfp: "wfp_on A R \<longleftrightarrow> wfp (\<lambda>x y. R x y \<and> x \<in> A \<and> y \<in> A)"  | 
|
399  | 
(is "?LHS \<longleftrightarrow> ?RHS")  | 
|
400  | 
proof (rule iffI)  | 
|
401  | 
assume ?LHS  | 
|
402  | 
then show ?RHS  | 
|
403  | 
unfolding wfp_on_iff_ex_minimal  | 
|
404  | 
by force  | 
|
405  | 
next  | 
|
406  | 
assume ?RHS  | 
|
407  | 
thus ?LHS  | 
|
| 82342 | 408  | 
proof (rule wfp_on_mono_strong)  | 
| 82241 | 409  | 
show "A \<subseteq> UNIV"  | 
410  | 
using subset_UNIV .  | 
|
411  | 
next  | 
|
412  | 
show "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> R x y \<Longrightarrow> R x y \<and> x \<in> A \<and> y \<in> A"  | 
|
413  | 
by iprover  | 
|
414  | 
qed  | 
|
415  | 
qed  | 
|
416  | 
||
417  | 
||
| 63108 | 418  | 
subsubsection \<open>Well-foundedness of transitive closure\<close>  | 
| 33216 | 419  | 
|
| 
82244
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
420  | 
lemma bex_rtrancl_min_element_if_wf_on:  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
421  | 
assumes wf: "wf_on A r" and x_in: "x \<in> A"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
422  | 
shows "\<exists>y \<in> A. (y, x) \<in> r\<^sup>* \<and> \<not>(\<exists>z \<in> A. (z, y) \<in> r)"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
423  | 
using wf  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
424  | 
proof (induction x rule: wf_on_induct)  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
425  | 
case in_set  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
426  | 
thus ?case  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
427  | 
using x_in .  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
428  | 
next  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
429  | 
case (less z)  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
430  | 
show ?case  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
431  | 
proof (cases "\<exists>y \<in> A. (y, z) \<in> r")  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
432  | 
case True  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
433  | 
then obtain y where "y \<in> A" and "(y, z) \<in> r"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
434  | 
by blast  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
435  | 
then obtain x where "x \<in> A" and "(x, y) \<in> r\<^sup>*" and "\<not> (\<exists>w\<in>A. (w, x) \<in> r)"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
436  | 
using less.IH by blast  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
437  | 
show ?thesis  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
438  | 
proof (intro bexI conjI)  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
439  | 
show "(x, z) \<in> r\<^sup>*"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
440  | 
using rtrancl.rtrancl_into_rtrancl[of x y r z]  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
441  | 
using \<open>(x, y) \<in> r\<^sup>*\<close> \<open>(y, z) \<in> r\<close> by blast  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
442  | 
next  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
443  | 
show "\<not> (\<exists>z\<in>A. (z, x) \<in> r)"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
444  | 
using \<open>\<not> (\<exists>w\<in>A. (w, x) \<in> r)\<close> .  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
445  | 
next  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
446  | 
show "x \<in> A"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
447  | 
using \<open>x \<in> A\<close> .  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
448  | 
qed  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
449  | 
next  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
450  | 
case False  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
451  | 
show ?thesis  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
452  | 
proof (intro bexI conjI)  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
453  | 
show "(z, z) \<in> r\<^sup>*"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
454  | 
using rtrancl.rtrancl_refl .  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
455  | 
next  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
456  | 
show "\<not> (\<exists>w\<in>A. (w, z) \<in> r)"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
457  | 
using False .  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
458  | 
next  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
459  | 
show "z \<in> A"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
460  | 
using less.hyps .  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
461  | 
qed  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
462  | 
qed  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
463  | 
qed  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
464  | 
|
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
465  | 
lemma bex_rtransclp_min_element_if_wfp_on: "wfp_on A R \<Longrightarrow> x \<in> A \<Longrightarrow> \<exists>y\<in>A. R\<^sup>*\<^sup>* y x \<and> \<not> (\<exists>z\<in>A. R z y)"  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
466  | 
by (rule bex_rtrancl_min_element_if_wf_on[to_pred])  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
467  | 
|
| 
82057
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
468  | 
lemma ex_terminating_rtranclp_strong:  | 
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
469  | 
  assumes wf: "wfp_on {x'. R\<^sup>*\<^sup>* x x'} R\<inverse>\<inverse>"
 | 
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
470  | 
shows "\<exists>y. R\<^sup>*\<^sup>* x y \<and> (\<nexists>z. R y z)"  | 
| 
82244
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
471  | 
proof -  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
472  | 
  have x_in: "x \<in> {x'. R\<^sup>*\<^sup>* x x'}"
 | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
473  | 
by simp  | 
| 
82057
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
474  | 
|
| 
82244
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
475  | 
show ?thesis  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
476  | 
using bex_rtransclp_min_element_if_wfp_on[OF wf x_in]  | 
| 
 
15a5e0922f45
added lemmas bex_rtrancl_min_element_if_wf_on and bex_rtrancl_min_element_if_wfp_on
 
desharna 
parents: 
82242 
diff
changeset
 | 
477  | 
using rtranclp.rtrancl_into_rtrancl[of R x] by blast  | 
| 
82057
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
478  | 
qed  | 
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
479  | 
|
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
480  | 
lemma ex_terminating_rtranclp:  | 
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
481  | 
assumes wf: "wfp R\<inverse>\<inverse>"  | 
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
482  | 
shows "\<exists>y. R\<^sup>*\<^sup>* x y \<and> (\<nexists>z. R y z)"  | 
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
483  | 
using ex_terminating_rtranclp_strong[OF wfp_on_subset[OF wf subset_UNIV]] .  | 
| 
 
ba3220909221
added lemmas ex_terminating_rtranclp_strong and ex_terminating_rtranclp
 
desharna 
parents: 
82056 
diff
changeset
 | 
484  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
485  | 
lemma wf_trancl:  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
486  | 
assumes "wf r"  | 
| 63108 | 487  | 
shows "wf (r\<^sup>+)"  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
488  | 
proof -  | 
| 63108 | 489  | 
have "P x" if induct_step: "\<And>x. (\<And>y. (y, x) \<in> r\<^sup>+ \<Longrightarrow> P y) \<Longrightarrow> P x" for P x  | 
490  | 
proof (rule induct_step)  | 
|
491  | 
show "P y" if "(y, x) \<in> r\<^sup>+" for y  | 
|
492  | 
using \<open>wf r\<close> and that  | 
|
493  | 
proof (induct x arbitrary: y)  | 
|
494  | 
case (less x)  | 
|
495  | 
note hyp = \<open>\<And>x' y'. (x', x) \<in> r \<Longrightarrow> (y', x') \<in> r\<^sup>+ \<Longrightarrow> P y'\<close>  | 
|
496  | 
from \<open>(y, x) \<in> r\<^sup>+\<close> show "P y"  | 
|
497  | 
proof cases  | 
|
498  | 
case base  | 
|
499  | 
show "P y"  | 
|
500  | 
proof (rule induct_step)  | 
|
501  | 
fix y'  | 
|
502  | 
assume "(y', y) \<in> r\<^sup>+"  | 
|
503  | 
with \<open>(y, x) \<in> r\<close> show "P y'"  | 
|
504  | 
by (rule hyp [of y y'])  | 
|
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32704 
diff
changeset
 | 
505  | 
qed  | 
| 63108 | 506  | 
next  | 
507  | 
case step  | 
|
508  | 
then obtain x' where "(x', x) \<in> r" and "(y, x') \<in> r\<^sup>+"  | 
|
509  | 
by simp  | 
|
510  | 
then show "P y" by (rule hyp [of x' y])  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
511  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
512  | 
qed  | 
| 63108 | 513  | 
qed  | 
514  | 
then show ?thesis unfolding wf_def by blast  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
515  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
516  | 
|
| 80322 | 517  | 
lemmas wfp_tranclp = wf_trancl [to_pred]  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
518  | 
|
| 63108 | 519  | 
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
 | 
520  | 
apply (subst trancl_converse [symmetric])  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
521  | 
apply (erule wf_trancl)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
522  | 
done  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
523  | 
|
| 60758 | 524  | 
text \<open>Well-foundedness of subsets\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
525  | 
|
| 63108 | 526  | 
lemma wf_subset: "wf r \<Longrightarrow> p \<subseteq> r \<Longrightarrow> wf p"  | 
| 82342 | 527  | 
using wf_on_mono[OF subset_UNIV, unfolded le_bool_def] ..  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
528  | 
|
| 80322 | 529  | 
lemmas wfp_subset = wf_subset [to_pred]  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
530  | 
|
| 60758 | 531  | 
text \<open>Well-foundedness of the empty relation\<close>  | 
| 33216 | 532  | 
|
| 82300 | 533  | 
lemma wf_on_bot[iff]: "wf_on A \<bottom>"  | 
| 
82298
 
c65013be534b
added lemmas wf_on_bot[simp] and wfp_on_bot[simp]
 
desharna 
parents: 
82244 
diff
changeset
 | 
534  | 
by (simp add: wf_on_def)  | 
| 
 
c65013be534b
added lemmas wf_on_bot[simp] and wfp_on_bot[simp]
 
desharna 
parents: 
82244 
diff
changeset
 | 
535  | 
|
| 82300 | 536  | 
lemma wfp_on_bot[iff]: "wfp_on A \<bottom>"  | 
| 
82298
 
c65013be534b
added lemmas wf_on_bot[simp] and wfp_on_bot[simp]
 
desharna 
parents: 
82244 
diff
changeset
 | 
537  | 
using wf_on_bot[to_pred] .  | 
| 
 
c65013be534b
added lemmas wf_on_bot[simp] and wfp_on_bot[simp]
 
desharna 
parents: 
82244 
diff
changeset
 | 
538  | 
|
| 80322 | 539  | 
lemma wfp_empty [iff]: "wfp (\<lambda>x y. False)"  | 
| 
82298
 
c65013be534b
added lemmas wf_on_bot[simp] and wfp_on_bot[simp]
 
desharna 
parents: 
82244 
diff
changeset
 | 
540  | 
using wfp_on_bot by (simp add: bot_fun_def)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
541  | 
|
| 63572 | 542  | 
lemma wf_Int1: "wf r \<Longrightarrow> wf (r \<inter> r')"  | 
543  | 
by (erule wf_subset) (rule Int_lower1)  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
544  | 
|
| 63572 | 545  | 
lemma wf_Int2: "wf r \<Longrightarrow> wf (r' \<inter> r)"  | 
546  | 
by (erule wf_subset) (rule Int_lower2)  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
547  | 
|
| 63572 | 548  | 
text \<open>Exponentiation.\<close>  | 
| 33216 | 549  | 
lemma wf_exp:  | 
550  | 
assumes "wf (R ^^ n)"  | 
|
551  | 
shows "wf R"  | 
|
552  | 
proof (rule wfI_pf)  | 
|
553  | 
fix A assume "A \<subseteq> R `` A"  | 
|
| 63612 | 554  | 
then have "A \<subseteq> (R ^^ n) `` A"  | 
555  | 
by (induct n) force+  | 
|
556  | 
  with \<open>wf (R ^^ n)\<close> show "A = {}"
 | 
|
557  | 
by (rule wfE_pf)  | 
|
| 33216 | 558  | 
qed  | 
559  | 
||
| 63572 | 560  | 
text \<open>Well-foundedness of \<open>insert\<close>.\<close>  | 
| 68646 | 561  | 
lemma wf_insert [iff]: "wf (insert (y,x) r) \<longleftrightarrow> wf r \<and> (x,y) \<notin> r\<^sup>*" (is "?lhs = ?rhs")  | 
562  | 
proof  | 
|
563  | 
assume ?lhs then show ?rhs  | 
|
564  | 
by (blast elim: wf_trancl [THEN wf_irrefl]  | 
|
565  | 
intro: rtrancl_into_trancl1 wf_subset rtrancl_mono [THEN subsetD])  | 
|
566  | 
next  | 
|
| 71410 | 567  | 
assume R: ?rhs  | 
| 68646 | 568  | 
  then have R': "Q \<noteq> {} \<Longrightarrow> (\<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q)" for Q
 | 
569  | 
by (auto simp: wf_eq_minimal)  | 
|
570  | 
show ?lhs  | 
|
571  | 
unfolding wf_eq_minimal  | 
|
572  | 
proof clarify  | 
|
573  | 
fix Q :: "'a set" and q  | 
|
574  | 
assume "q \<in> Q"  | 
|
575  | 
then obtain a where "a \<in> Q" and a: "\<And>y. (y, a) \<in> r \<Longrightarrow> y \<notin> Q"  | 
|
576  | 
using R by (auto simp: wf_eq_minimal)  | 
|
577  | 
show "\<exists>z\<in>Q. \<forall>y'. (y', z) \<in> insert (y, x) r \<longrightarrow> y' \<notin> Q"  | 
|
578  | 
proof (cases "a=x")  | 
|
579  | 
case True  | 
|
580  | 
show ?thesis  | 
|
581  | 
proof (cases "y \<in> Q")  | 
|
582  | 
case True  | 
|
583  | 
then obtain z where "z \<in> Q" "(z, y) \<in> r\<^sup>*"  | 
|
584  | 
"\<And>z'. (z', z) \<in> r \<longrightarrow> z' \<in> Q \<longrightarrow> (z', y) \<notin> r\<^sup>*"  | 
|
585  | 
          using R' [of "{z \<in> Q. (z,y) \<in> r\<^sup>*}"] by auto
 | 
|
| 
75669
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
586  | 
then have "\<forall>y'. (y', z) \<in> insert (y, x) r \<longrightarrow> y' \<notin> Q"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
587  | 
using R by(blast intro: rtrancl_trans)+  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
588  | 
then show ?thesis  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
589  | 
by (rule bexI) fact  | 
| 68646 | 590  | 
next  | 
591  | 
case False  | 
|
592  | 
then show ?thesis  | 
|
593  | 
using a \<open>a \<in> Q\<close> by blast  | 
|
594  | 
qed  | 
|
595  | 
next  | 
|
596  | 
case False  | 
|
597  | 
with a \<open>a \<in> Q\<close> show ?thesis  | 
|
598  | 
by blast  | 
|
599  | 
qed  | 
|
600  | 
qed  | 
|
601  | 
qed  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
602  | 
|
| 63108 | 603  | 
|
604  | 
subsubsection \<open>Well-foundedness of image\<close>  | 
|
| 33216 | 605  | 
|
| 
68259
 
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
 
nipkow 
parents: 
67399 
diff
changeset
 | 
606  | 
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
 | 
607  | 
  fixes r:: "('a \<times> 'a) set"
 | 
| 
 
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
 
nipkow 
parents: 
67399 
diff
changeset
 | 
608  | 
and f:: "'a \<Rightarrow> 'b"  | 
| 
 
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
 
nipkow 
parents: 
67399 
diff
changeset
 | 
609  | 
assumes wf_r: "wf r"  | 
| 
 
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
 
nipkow 
parents: 
67399 
diff
changeset
 | 
610  | 
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
 | 
611  | 
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
 | 
612  | 
proof (unfold wf_eq_minimal, clarify)  | 
| 68262 | 613  | 
fix B :: "'b set" and b::"'b"  | 
614  | 
assume "b \<in> B"  | 
|
615  | 
define A where "A = f -` B \<inter> Domain r"  | 
|
616  | 
show "\<exists>z\<in>B. \<forall>y. (y, z) \<in> map_prod f f ` r \<longrightarrow> y \<notin> B"  | 
|
617  | 
  proof (cases "A = {}")
 | 
|
| 
68259
 
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
 
nipkow 
parents: 
67399 
diff
changeset
 | 
618  | 
case False  | 
| 68262 | 619  | 
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
 | 
620  | 
using wfE_min[OF wf_r] by auto  | 
| 71410 | 621  | 
thus ?thesis  | 
| 68262 | 622  | 
using inj unfolding A_def  | 
623  | 
by (intro bexI[of _ "f a0"]) auto  | 
|
| 
75669
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
624  | 
qed (use \<open>b \<in> B\<close> in \<open>unfold A_def, auto\<close>)  | 
| 
68259
 
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
 
nipkow 
parents: 
67399 
diff
changeset
 | 
625  | 
qed  | 
| 
 
80df7c90e315
By Andrei Popescu based on an initial version by Kasper F. Brandt
 
nipkow 
parents: 
67399 
diff
changeset
 | 
626  | 
|
| 63108 | 627  | 
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
 | 
628  | 
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
 | 
629  | 
|
| 
80046
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
630  | 
lemma wfp_on_image: "wfp_on (f ` A) R \<longleftrightarrow> wfp_on A (\<lambda>a b. R (f a) (f b))"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
631  | 
proof (rule iffI)  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
632  | 
assume hyp: "wfp_on (f ` A) R"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
633  | 
show "wfp_on A (\<lambda>a b. R (f a) (f b))"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
634  | 
unfolding wfp_on_iff_ex_minimal  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
635  | 
proof (intro allI impI)  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
636  | 
fix B  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
637  | 
    assume "B \<subseteq> A" and "B \<noteq> {}"
 | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
638  | 
    hence "f ` B \<subseteq> f ` A" and "f ` B \<noteq> {}"
 | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
639  | 
unfolding atomize_conj image_is_empty  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
640  | 
using image_mono by iprover  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
641  | 
hence "\<exists>z\<in>f ` B. \<forall>y. R y z \<longrightarrow> y \<notin> f ` B"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
642  | 
using hyp[unfolded wfp_on_iff_ex_minimal, rule_format] by iprover  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
643  | 
then obtain fz where "fz \<in> f ` B" and fz_max: "\<forall>y. R y fz \<longrightarrow> y \<notin> f ` B" ..  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
644  | 
|
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
645  | 
obtain z where "z \<in> B" and "fz = f z"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
646  | 
using \<open>fz \<in> f ` B\<close> unfolding image_iff ..  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
647  | 
|
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
648  | 
show "\<exists>z\<in>B. \<forall>y. R (f y) (f z) \<longrightarrow> y \<notin> B"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
649  | 
proof (intro bexI allI impI)  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
650  | 
show "z \<in> B"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
651  | 
using \<open>z \<in> B\<close> .  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
652  | 
next  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
653  | 
fix y assume "R (f y) (f z)"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
654  | 
hence "f y \<notin> f ` B"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
655  | 
using fz_max \<open>fz = f z\<close> by iprover  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
656  | 
thus "y \<notin> B"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
657  | 
by (rule contrapos_nn) (rule imageI)  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
658  | 
qed  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
659  | 
qed  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
660  | 
next  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
661  | 
assume hyp: "wfp_on A (\<lambda>a b. R (f a) (f b))"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
662  | 
show "wfp_on (f ` A) R"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
663  | 
unfolding wfp_on_iff_ex_minimal  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
664  | 
proof (intro allI impI)  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
665  | 
fix fA  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
666  | 
    assume "fA \<subseteq> f ` A" and "fA \<noteq> {}"
 | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
667  | 
    then obtain A' where "A' \<subseteq> A" and "A' \<noteq> {}" and "fA = f ` A'"
 | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
668  | 
by (auto simp only: subset_image_iff)  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
669  | 
|
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
670  | 
obtain z where "z \<in> A'" and z_max: "\<forall>y. R (f y) (f z) \<longrightarrow> y \<notin> A'"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
671  | 
      using hyp[unfolded wfp_on_iff_ex_minimal, rule_format, OF \<open>A' \<subseteq> A\<close> \<open>A' \<noteq> {}\<close>] by blast
 | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
672  | 
|
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
673  | 
show "\<exists>z\<in>fA. \<forall>y. R y z \<longrightarrow> y \<notin> fA"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
674  | 
proof (intro bexI allI impI)  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
675  | 
show "f z \<in> fA"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
676  | 
unfolding \<open>fA = f ` A'\<close>  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
677  | 
using imageI[OF \<open>z \<in> A'\<close>] .  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
678  | 
next  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
679  | 
show "\<And>y. R y (f z) \<Longrightarrow> y \<notin> fA"  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
680  | 
unfolding \<open>fA = f ` A'\<close>  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
681  | 
using z_max by auto  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
682  | 
qed  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
683  | 
qed  | 
| 
 
38803a6b3357
added lemma wfp_on_image and author name to theory
 
desharna 
parents: 
80019 
diff
changeset
 | 
684  | 
qed  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
685  | 
|
| 60758 | 686  | 
subsection \<open>Well-Foundedness Results for Unions\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
687  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
688  | 
lemma wf_union_compatible:  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
689  | 
assumes "wf R" "wf S"  | 
| 
32235
 
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
 
krauss 
parents: 
32205 
diff
changeset
 | 
690  | 
assumes "R O S \<subseteq> R"  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
691  | 
shows "wf (R \<union> S)"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
692  | 
proof (rule wfI_min)  | 
| 63108 | 693  | 
fix x :: 'a and Q  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
694  | 
  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
 | 
695  | 
assume "x \<in> Q"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
696  | 
obtain a where "a \<in> ?Q'"  | 
| 60758 | 697  | 
by (rule wfE_min [OF \<open>wf R\<close> \<open>x \<in> Q\<close>]) blast  | 
| 63108 | 698  | 
with \<open>wf S\<close> obtain z where "z \<in> ?Q'" and zmin: "\<And>y. (y, z) \<in> S \<Longrightarrow> y \<notin> ?Q'"  | 
699  | 
by (erule wfE_min)  | 
|
| 63572 | 700  | 
have "y \<notin> Q" if "(y, z) \<in> S" for y  | 
701  | 
proof  | 
|
702  | 
from that have "y \<notin> ?Q'" by (rule zmin)  | 
|
703  | 
assume "y \<in> Q"  | 
|
704  | 
with \<open>y \<notin> ?Q'\<close> obtain w where "(w, y) \<in> R" and "w \<in> Q" by auto  | 
|
705  | 
from \<open>(w, y) \<in> R\<close> \<open>(y, z) \<in> S\<close> have "(w, z) \<in> R O S" by (rule relcompI)  | 
|
706  | 
with \<open>R O S \<subseteq> R\<close> have "(w, z) \<in> R" ..  | 
|
707  | 
with \<open>z \<in> ?Q'\<close> have "w \<notin> Q" by blast  | 
|
708  | 
with \<open>w \<in> Q\<close> show False by contradiction  | 
|
709  | 
qed  | 
|
| 60758 | 710  | 
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
 | 
711  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
712  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
713  | 
|
| 63572 | 714  | 
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
 | 
715  | 
|
| 63108 | 716  | 
lemma wf_UN:  | 
| 68646 | 717  | 
assumes r: "\<And>i. i \<in> I \<Longrightarrow> wf (r i)"  | 
718  | 
    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 | 719  | 
shows "wf (\<Union>i\<in>I. r i)"  | 
| 68646 | 720  | 
unfolding wf_eq_minimal  | 
721  | 
proof clarify  | 
|
722  | 
fix A and a :: "'b"  | 
|
723  | 
assume "a \<in> A"  | 
|
| 69275 | 724  | 
show "\<exists>z\<in>A. \<forall>y. (y, z) \<in> \<Union>(r ` I) \<longrightarrow> y \<notin> A"  | 
| 68646 | 725  | 
proof (cases "\<exists>i\<in>I. \<exists>a\<in>A. \<exists>b\<in>A. (b, a) \<in> r i")  | 
726  | 
case True  | 
|
727  | 
then obtain i b c where ibc: "i \<in> I" "b \<in> A" "c \<in> A" "(c,b) \<in> r i"  | 
|
728  | 
by blast  | 
|
729  | 
    have ri: "\<And>Q. Q \<noteq> {} \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> r i \<longrightarrow> y \<notin> Q"
 | 
|
730  | 
using r [OF \<open>i \<in> I\<close>] unfolding wf_eq_minimal by auto  | 
|
731  | 
show ?thesis  | 
|
| 71410 | 732  | 
      using ri [of "{a. a \<in> A \<and> (\<exists>b\<in>A. (b, a) \<in> r i) }"] ibc disj
 | 
| 68646 | 733  | 
by blast  | 
734  | 
next  | 
|
735  | 
case False  | 
|
736  | 
with \<open>a \<in> A\<close> show ?thesis  | 
|
737  | 
by blast  | 
|
738  | 
qed  | 
|
739  | 
qed  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
740  | 
|
| 80322 | 741  | 
lemma wfp_SUP:  | 
742  | 
"\<forall>i. wfp (r i) \<Longrightarrow> \<forall>i j. r i \<noteq> r j \<longrightarrow> inf (Domainp (r i)) (Rangep (r j)) = bot \<Longrightarrow>  | 
|
743  | 
wfp (\<Squnion>(range r))"  | 
|
| 63572 | 744  | 
by (rule wf_UN[to_pred]) simp_all  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
745  | 
|
| 63108 | 746  | 
lemma wf_Union:  | 
747  | 
assumes "\<forall>r\<in>R. wf r"  | 
|
748  | 
    and "\<forall>r\<in>R. \<forall>s\<in>R. r \<noteq> s \<longrightarrow> Domain r \<inter> Range s = {}"
 | 
|
749  | 
shows "wf (\<Union>R)"  | 
|
750  | 
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
 | 
751  | 
|
| 63109 | 752  | 
text \<open>  | 
753  | 
Intuition: We find an \<open>R \<union> S\<close>-min element of a nonempty subset \<open>A\<close> by case distinction.  | 
|
754  | 
\<^enum> There is a step \<open>a \<midarrow>R\<rightarrow> b\<close> with \<open>a, b \<in> A\<close>.  | 
|
755  | 
    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>.
 | 
|
756  | 
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  | 
|
757  | 
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  | 
|
758  | 
have an \<open>S\<close>-successor and is thus \<open>S\<close>-min in \<open>A\<close> as well.  | 
|
759  | 
\<^enum> There is no such step.  | 
|
760  | 
Pick an \<open>S\<close>-min element of \<open>A\<close>. In this case it must be an \<open>R\<close>-min  | 
|
761  | 
element of \<open>A\<close> as well.  | 
|
762  | 
\<close>  | 
|
| 63108 | 763  | 
lemma wf_Un: "wf r \<Longrightarrow> wf s \<Longrightarrow> Domain r \<inter> Range s = {} \<Longrightarrow> wf (r \<union> s)"
 | 
764  | 
using wf_union_compatible[of s r]  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
765  | 
by (auto simp: Un_ac)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
766  | 
|
| 63108 | 767  | 
lemma wf_union_merge: "wf (R \<union> S) = wf (R O R \<union> S O R \<union> S)"  | 
768  | 
(is "wf ?A = wf ?B")  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
769  | 
proof  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
770  | 
assume "wf ?A"  | 
| 63108 | 771  | 
with wf_trancl have wfT: "wf (?A\<^sup>+)" .  | 
772  | 
moreover have "?B \<subseteq> ?A\<^sup>+"  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
773  | 
by (subst trancl_unfold, subst trancl_unfold) blast  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
774  | 
ultimately show "wf ?B" by (rule wf_subset)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
775  | 
next  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
776  | 
assume "wf ?B"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
777  | 
show "wf ?A"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
778  | 
proof (rule wfI_min)  | 
| 63108 | 779  | 
fix Q :: "'a set" and x  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
780  | 
assume "x \<in> Q"  | 
| 63109 | 781  | 
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
 | 
782  | 
by (erule wfE_min)  | 
| 63109 | 783  | 
then have 1: "\<And>y. (y, z) \<in> R O R \<Longrightarrow> y \<notin> Q"  | 
784  | 
and 2: "\<And>y. (y, z) \<in> S O R \<Longrightarrow> y \<notin> Q"  | 
|
785  | 
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
 | 
786  | 
by auto  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
787  | 
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
 | 
788  | 
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
 | 
789  | 
case True  | 
| 63109 | 790  | 
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
 | 
791  | 
next  | 
| 63108 | 792  | 
case False  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
793  | 
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
 | 
794  | 
have "\<forall>y. (y, z') \<in> ?A \<longrightarrow> y \<notin> Q"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
795  | 
proof (intro allI impI)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
796  | 
fix y assume "(y, z') \<in> ?A"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
797  | 
then show "y \<notin> Q"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
798  | 
proof  | 
| 63108 | 799  | 
assume "(y, z') \<in> R"  | 
| 60758 | 800  | 
then have "(y, z) \<in> R O R" using \<open>(z', z) \<in> R\<close> ..  | 
| 63109 | 801  | 
with 1 show "y \<notin> Q" .  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
802  | 
next  | 
| 63108 | 803  | 
assume "(y, z') \<in> S"  | 
| 60758 | 804  | 
then have "(y, z) \<in> S O R" using \<open>(z', z) \<in> R\<close> ..  | 
| 63109 | 805  | 
with 2 show "y \<notin> Q" .  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
806  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
807  | 
qed  | 
| 60758 | 808  | 
with \<open>z' \<in> Q\<close> show ?thesis ..  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
809  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
810  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
811  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
812  | 
|
| 63612 | 813  | 
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
 | 
814  | 
  by (rule wf_union_merge [where S = "{}", simplified])
 | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
815  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
816  | 
|
| 60758 | 817  | 
subsection \<open>Well-Foundedness of Composition\<close>  | 
| 60148 | 818  | 
|
| 
60493
 
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
 
paulson <lp15@cam.ac.uk> 
parents: 
60148 
diff
changeset
 | 
819  | 
text \<open>Bachmair and Dershowitz 1986, Lemma 2. [Provided by Tjark Weber]\<close>  | 
| 60148 | 820  | 
|
| 
60493
 
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
 
paulson <lp15@cam.ac.uk> 
parents: 
60148 
diff
changeset
 | 
821  | 
lemma qc_wf_relto_iff:  | 
| 61799 | 822  | 
assumes "R O S \<subseteq> (R \<union> S)\<^sup>* O R" \<comment> \<open>R quasi-commutes over S\<close>  | 
| 63109 | 823  | 
shows "wf (S\<^sup>* O R O S\<^sup>*) \<longleftrightarrow> wf R"  | 
| 63612 | 824  | 
(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
 | 
825  | 
proof  | 
| 63109 | 826  | 
show "wf R" if "wf ?S"  | 
827  | 
proof -  | 
|
828  | 
have "R \<subseteq> ?S" by auto  | 
|
| 63612 | 829  | 
with wf_subset [of ?S] that show "wf R"  | 
830  | 
by auto  | 
|
| 63109 | 831  | 
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
 | 
832  | 
next  | 
| 63109 | 833  | 
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
 | 
834  | 
proof (rule wfI_pf)  | 
| 63109 | 835  | 
fix A  | 
836  | 
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
 | 
837  | 
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
 | 
838  | 
have *: "R O (R \<union> S)\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R"  | 
| 63109 | 839  | 
proof -  | 
840  | 
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  | 
|
841  | 
using that  | 
|
842  | 
proof (induct y z)  | 
|
843  | 
case rtrancl_refl  | 
|
844  | 
then show ?case by auto  | 
|
845  | 
next  | 
|
846  | 
case (rtrancl_into_rtrancl a b c)  | 
|
847  | 
then have "(x, c) \<in> ((R \<union> S)\<^sup>* O (R \<union> S)\<^sup>*) O R"  | 
|
848  | 
using assms by blast  | 
|
849  | 
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
 | 
850  | 
qed  | 
| 63109 | 851  | 
then show ?thesis by auto  | 
852  | 
qed  | 
|
853  | 
then have "R O S\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R"  | 
|
854  | 
using rtrancl_Un_subset by blast  | 
|
855  | 
then have "?S \<subseteq> (R \<union> S)\<^sup>* O (R \<union> S)\<^sup>* O R"  | 
|
856  | 
by (simp add: relcomp_mono rtrancl_mono)  | 
|
857  | 
also have "\<dots> = (R \<union> S)\<^sup>* O R"  | 
|
858  | 
by (simp add: O_assoc[symmetric])  | 
|
859  | 
finally have "?S O (R \<union> S)\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R O (R \<union> S)\<^sup>*"  | 
|
860  | 
by (simp add: O_assoc[symmetric] relcomp_mono)  | 
|
861  | 
also have "\<dots> \<subseteq> (R \<union> S)\<^sup>* O (R \<union> S)\<^sup>* O R"  | 
|
862  | 
using * by (simp add: relcomp_mono)  | 
|
863  | 
finally have "?S O (R \<union> S)\<^sup>* \<subseteq> (R \<union> S)\<^sup>* O R"  | 
|
864  | 
by (simp add: O_assoc[symmetric])  | 
|
865  | 
then have "(?S O (R \<union> S)\<^sup>*) `` A \<subseteq> ((R \<union> S)\<^sup>* O R) `` A"  | 
|
866  | 
by (simp add: Image_mono)  | 
|
867  | 
moreover have "?X \<subseteq> (?S O (R \<union> S)\<^sup>*) `` A"  | 
|
868  | 
using A by (auto simp: relcomp_Image)  | 
|
869  | 
ultimately have "?X \<subseteq> R `` ?X"  | 
|
870  | 
by (auto simp: relcomp_Image)  | 
|
871  | 
    then have "?X = {}"
 | 
|
872  | 
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
 | 
873  | 
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
 | 
874  | 
    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
 | 
875  | 
qed  | 
| 
 
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
 
paulson <lp15@cam.ac.uk> 
parents: 
60148 
diff
changeset
 | 
876  | 
qed  | 
| 
 
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
 
paulson <lp15@cam.ac.uk> 
parents: 
60148 
diff
changeset
 | 
877  | 
|
| 
 
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
 
paulson <lp15@cam.ac.uk> 
parents: 
60148 
diff
changeset
 | 
878  | 
corollary wf_relcomp_compatible:  | 
| 60148 | 879  | 
assumes "wf R" and "R O S \<subseteq> S O R"  | 
880  | 
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
 | 
881  | 
proof -  | 
| 
 
866f41a869e6
New WF theorem by Tjark Weber. Replaced the proof of the subsequent theorem.
 
paulson <lp15@cam.ac.uk> 
parents: 
60148 
diff
changeset
 | 
882  | 
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
 | 
883  | 
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
 | 
884  | 
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
 | 
885  | 
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
 | 
886  | 
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
 | 
887  | 
by (rule Wellfounded.wf_subset) blast  | 
| 60148 | 888  | 
qed  | 
889  | 
||
890  | 
||
| 60758 | 891  | 
subsection \<open>Acyclic relations\<close>  | 
| 33217 | 892  | 
|
| 63108 | 893  | 
lemma wf_acyclic: "wf r \<Longrightarrow> acyclic r"  | 
| 63572 | 894  | 
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
 | 
895  | 
|
| 80322 | 896  | 
lemmas wfp_acyclicP = wf_acyclic [to_pred]  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
897  | 
|
| 63108 | 898  | 
|
899  | 
subsubsection \<open>Wellfoundedness of finite acyclic relations\<close>  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
900  | 
|
| 68646 | 901  | 
lemma finite_acyclic_wf:  | 
902  | 
assumes "finite r" "acyclic r" shows "wf r"  | 
|
903  | 
using assms  | 
|
904  | 
proof (induction r rule: finite_induct)  | 
|
905  | 
case (insert x r)  | 
|
906  | 
then show ?case  | 
|
907  | 
by (cases x) simp  | 
|
908  | 
qed simp  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
909  | 
|
| 63108 | 910  | 
lemma finite_acyclic_wf_converse: "finite r \<Longrightarrow> acyclic r \<Longrightarrow> wf (r\<inverse>)"  | 
| 63572 | 911  | 
apply (erule finite_converse [THEN iffD2, THEN finite_acyclic_wf])  | 
912  | 
apply (erule acyclic_converse [THEN iffD2])  | 
|
913  | 
done  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
914  | 
|
| 
63088
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
915  | 
text \<open>  | 
| 
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
916  | 
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
 | 
917  | 
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
 | 
918  | 
employ it for well-founded induction.  | 
| 
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
919  | 
\<close>  | 
| 
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
920  | 
lemma wf_converse:  | 
| 
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
921  | 
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
 | 
922  | 
shows "wf (r\<inverse>)"  | 
| 
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
923  | 
proof -  | 
| 
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
924  | 
have "acyclic r"  | 
| 63572 | 925  | 
using \<open>irrefl r\<close> and \<open>trans r\<close>  | 
926  | 
by (simp add: irrefl_def acyclic_irrefl)  | 
|
927  | 
with \<open>finite r\<close> show ?thesis  | 
|
928  | 
by (rule finite_acyclic_wf_converse)  | 
|
| 
63088
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
929  | 
qed  | 
| 
 
f2177f5d2aed
a quasi-recursive characterization of the multiset order (by Christian Sternagel)
 
haftmann 
parents: 
61952 
diff
changeset
 | 
930  | 
|
| 63108 | 931  | 
lemma wf_iff_acyclic_if_finite: "finite r \<Longrightarrow> wf r = acyclic r"  | 
| 63572 | 932  | 
by (blast intro: finite_acyclic_wf wf_acyclic)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
933  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
934  | 
|
| 69593 | 935  | 
subsection \<open>\<^typ>\<open>nat\<close> is well-founded\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
936  | 
|
| 67399 | 937  | 
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
 | 
938  | 
proof (rule ext, rule ext, rule iffI)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
939  | 
fix n m :: nat  | 
| 63108 | 940  | 
show "(\<lambda>m n. n = Suc m)\<^sup>+\<^sup>+ m n" if "m < n"  | 
941  | 
using that  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
942  | 
proof (induct n)  | 
| 63108 | 943  | 
case 0  | 
944  | 
then show ?case by auto  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
945  | 
next  | 
| 63108 | 946  | 
case (Suc n)  | 
947  | 
then show ?case  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
948  | 
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
 | 
949  | 
qed  | 
| 63108 | 950  | 
show "m < n" if "(\<lambda>m n. n = Suc m)\<^sup>+\<^sup>+ m n"  | 
951  | 
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
 | 
952  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
953  | 
|
| 63108 | 954  | 
definition pred_nat :: "(nat \<times> nat) set"  | 
955  | 
  where "pred_nat = {(m, n). n = Suc m}"
 | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
956  | 
|
| 63108 | 957  | 
definition less_than :: "(nat \<times> nat) set"  | 
958  | 
where "less_than = pred_nat\<^sup>+"  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
959  | 
|
| 63108 | 960  | 
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
 | 
961  | 
unfolding less_nat_rel pred_nat_def trancl_def by simp  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
962  | 
|
| 63108 | 963  | 
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
 | 
964  | 
unfolding less_eq rtrancl_eq_or_trancl by auto  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
965  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
966  | 
lemma wf_pred_nat: "wf pred_nat"  | 
| 
75669
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
967  | 
unfolding wf_def  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
968  | 
proof clarify  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
969  | 
fix P x  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
970  | 
assume "\<forall>x'. (\<forall>y. (y, x') \<in> pred_nat \<longrightarrow> P y) \<longrightarrow> P x'"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
971  | 
then show "P x"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
972  | 
unfolding pred_nat_def by (induction x) blast+  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
973  | 
qed  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
974  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
975  | 
lemma wf_less_than [iff]: "wf less_than"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
976  | 
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
 | 
977  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
978  | 
lemma trans_less_than [iff]: "trans less_than"  | 
| 35216 | 979  | 
by (simp add: less_than_def)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
980  | 
|
| 63108 | 981  | 
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
 | 
982  | 
by (simp add: less_than_def less_eq)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
983  | 
|
| 71827 | 984  | 
lemma irrefl_less_than: "irrefl less_than"  | 
985  | 
using irrefl_def by blast  | 
|
986  | 
||
| 
71935
 
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
 
paulson <lp15@cam.ac.uk> 
parents: 
71827 
diff
changeset
 | 
987  | 
lemma asym_less_than: "asym less_than"  | 
| 
76682
 
e260dabc88e6
added predicates asym_on and asymp_on and redefined asym and asymp to be abbreviations
 
desharna 
parents: 
76588 
diff
changeset
 | 
988  | 
by (rule asymI) simp  | 
| 
71935
 
82b00b8f1871
fixed the utterly weird definitions of asym / asymp, and added many asym lemmas
 
paulson <lp15@cam.ac.uk> 
parents: 
71827 
diff
changeset
 | 
989  | 
|
| 
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
 | 
990  | 
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
 | 
991  | 
using total_on_def by force+  | 
| 
71404
 
f2b783abfbe7
A few lemmas connected with orderings
 
paulson <lp15@cam.ac.uk> 
parents: 
69593 
diff
changeset
 | 
992  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
993  | 
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
 | 
994  | 
by (rule Wellfounded.wellorder_class.wf)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
995  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
996  | 
|
| 60758 | 997  | 
subsection \<open>Accessible Part\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
998  | 
|
| 60758 | 999  | 
text \<open>  | 
| 63108 | 1000  | 
Inductive definition of the accessible part \<open>acc r\<close> of a  | 
| 77172 | 1001  | 
relation; see also \<^cite>\<open>"paulin-tlca"\<close>.  | 
| 60758 | 1002  | 
\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1003  | 
|
| 63108 | 1004  | 
inductive_set acc :: "('a \<times> 'a) set \<Rightarrow> 'a set" for r :: "('a \<times> 'a) set"
 | 
1005  | 
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
 | 
1006  | 
|
| 63108 | 1007  | 
abbreviation termip :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> bool"
 | 
1008  | 
where "termip r \<equiv> accp (r\<inverse>\<inverse>)"  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1009  | 
|
| 63108 | 1010  | 
abbreviation termi :: "('a \<times> 'a) set \<Rightarrow> 'a set"
 | 
1011  | 
where "termi r \<equiv> acc (r\<inverse>)"  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1012  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1013  | 
lemmas accpI = accp.accI  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1014  | 
|
| 63108 | 1015  | 
lemma accp_eq_acc [code]: "accp r = (\<lambda>x. x \<in> Wellfounded.acc {(x, y). r x y})"
 | 
| 54295 | 1016  | 
by (simp add: acc_def)  | 
1017  | 
||
1018  | 
||
| 60758 | 1019  | 
text \<open>Induction rules\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1020  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1021  | 
theorem accp_induct:  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1022  | 
assumes major: "accp r a"  | 
| 63108 | 1023  | 
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
 | 
1024  | 
shows "P a"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1025  | 
apply (rule major [THEN accp.induct])  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1026  | 
apply (rule hyp)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1027  | 
apply (rule accp.accI)  | 
| 68646 | 1028  | 
apply auto  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1029  | 
done  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1030  | 
|
| 61337 | 1031  | 
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
 | 
1032  | 
|
| 63108 | 1033  | 
theorem accp_downward: "accp r b \<Longrightarrow> r a b \<Longrightarrow> accp r a"  | 
| 63572 | 1034  | 
by (cases rule: accp.cases)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1035  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1036  | 
lemma not_accp_down:  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1037  | 
assumes na: "\<not> accp R x"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1038  | 
obtains z where "R z x" and "\<not> accp R z"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1039  | 
proof -  | 
| 63572 | 1040  | 
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
 | 
1041  | 
show thesis  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1042  | 
proof (cases "\<forall>z. R z x \<longrightarrow> accp R z")  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1043  | 
case True  | 
| 63108 | 1044  | 
then have "\<And>z. R z x \<Longrightarrow> accp R z" by auto  | 
1045  | 
then have "accp R x" by (rule accp.accI)  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1046  | 
with na show thesis ..  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1047  | 
next  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1048  | 
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
 | 
1049  | 
by auto  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1050  | 
with a show thesis .  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1051  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1052  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1053  | 
|
| 63108 | 1054  | 
lemma accp_downwards_aux: "r\<^sup>*\<^sup>* b a \<Longrightarrow> accp r a \<longrightarrow> accp r b"  | 
| 63612 | 1055  | 
by (erule rtranclp_induct) (blast dest: accp_downward)+  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1056  | 
|
| 63108 | 1057  | 
theorem accp_downwards: "accp r a \<Longrightarrow> r\<^sup>*\<^sup>* b a \<Longrightarrow> accp r b"  | 
| 63572 | 1058  | 
by (blast dest: accp_downwards_aux)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1059  | 
|
| 80321 | 1060  | 
theorem accp_wfpI: "\<forall>x. accp r x \<Longrightarrow> wfp r"  | 
| 80322 | 1061  | 
proof (rule wfpUNIVI)  | 
| 
75669
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1062  | 
fix P x  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1063  | 
assume "\<forall>x. accp r x" "\<forall>x. (\<forall>y. r y x \<longrightarrow> P y) \<longrightarrow> P x"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1064  | 
then show "P x"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1065  | 
using accp_induct[where P = P] by blast  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1066  | 
qed  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1067  | 
|
| 80321 | 1068  | 
theorem accp_wfpD: "wfp r \<Longrightarrow> accp r x"  | 
| 80322 | 1069  | 
apply (erule wfp_induct_rule)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1070  | 
apply (rule accp.accI)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1071  | 
apply blast  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1072  | 
done  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1073  | 
|
| 80316 | 1074  | 
theorem wfp_iff_accp: "wfp r = (\<forall>x. accp r x)"  | 
| 80321 | 1075  | 
by (blast intro: accp_wfpI dest: accp_wfpD)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1076  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1077  | 
|
| 60758 | 1078  | 
text \<open>Smaller relations have bigger accessible parts:\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1079  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1080  | 
lemma accp_subset:  | 
| 63572 | 1081  | 
assumes "R1 \<le> R2"  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1082  | 
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
 | 
1083  | 
proof (rule predicate1I)  | 
| 63572 | 1084  | 
fix x  | 
1085  | 
assume "accp R2 x"  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1086  | 
then show "accp R1 x"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1087  | 
proof (induct x)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1088  | 
fix x  | 
| 63572 | 1089  | 
assume "\<And>y. R2 y x \<Longrightarrow> accp R1 y"  | 
1090  | 
with assms show "accp R1 x"  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1091  | 
by (blast intro: accp.accI)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1092  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1093  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1094  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1095  | 
|
| 60758 | 1096  | 
text \<open>This is a generalized induction theorem that works on  | 
1097  | 
subsets of the accessible part.\<close>  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1098  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1099  | 
lemma accp_subset_induct:  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1100  | 
assumes subset: "D \<le> accp R"  | 
| 63572 | 1101  | 
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
 | 
1102  | 
and "D x"  | 
| 63572 | 1103  | 
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
 | 
1104  | 
shows "P x"  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1105  | 
proof -  | 
| 60758 | 1106  | 
from subset and \<open>D x\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1107  | 
have "accp R x" ..  | 
| 60758 | 1108  | 
then show "P x" using \<open>D x\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1109  | 
proof (induct x)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1110  | 
fix x  | 
| 63572 | 1111  | 
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
 | 
1112  | 
with dcl and istep show "P x" by blast  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1113  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1114  | 
qed  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1115  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1116  | 
|
| 60758 | 1117  | 
text \<open>Set versions of the above theorems\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1118  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1119  | 
lemmas acc_induct = accp_induct [to_set]  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1120  | 
lemmas acc_induct_rule = acc_induct [rule_format, induct set: acc]  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1121  | 
lemmas acc_downward = accp_downward [to_set]  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1122  | 
lemmas not_acc_down = not_accp_down [to_set]  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1123  | 
lemmas acc_downwards_aux = accp_downwards_aux [to_set]  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1124  | 
lemmas acc_downwards = accp_downwards [to_set]  | 
| 80321 | 1125  | 
lemmas acc_wfI = accp_wfpI [to_set]  | 
1126  | 
lemmas acc_wfD = accp_wfpD [to_set]  | 
|
| 80316 | 1127  | 
lemmas wf_iff_acc = wfp_iff_accp [to_set]  | 
| 
46177
 
adac34829e10
pred_subset_eq and SUP_UN_eq2 are now standard pred_set_conv rules
 
berghofe 
parents: 
45970 
diff
changeset
 | 
1128  | 
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
 | 
1129  | 
lemmas acc_subset_induct = accp_subset_induct [to_set]  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1130  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1131  | 
|
| 60758 | 1132  | 
subsection \<open>Tools for building wellfounded relations\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1133  | 
|
| 60758 | 1134  | 
text \<open>Inverse Image\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1135  | 
|
| 71544 | 1136  | 
lemma wf_inv_image [simp,intro!]:  | 
1137  | 
fixes f :: "'a \<Rightarrow> 'b"  | 
|
1138  | 
assumes "wf r"  | 
|
1139  | 
shows "wf (inv_image r f)"  | 
|
| 
75669
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1140  | 
proof -  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1141  | 
have "\<And>x P. x \<in> P \<Longrightarrow> \<exists>z\<in>P. \<forall>y. (f y, f z) \<in> r \<longrightarrow> y \<notin> P"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1142  | 
proof -  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1143  | 
fix P and x::'a  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1144  | 
assume "x \<in> P"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1145  | 
    then obtain w where w: "w \<in> {w. \<exists>x::'a. x \<in> P \<and> f x = w}"
 | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1146  | 
by auto  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1147  | 
have *: "\<And>Q u. u \<in> Q \<Longrightarrow> \<exists>z\<in>Q. \<forall>y. (y, z) \<in> r \<longrightarrow> y \<notin> Q"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1148  | 
using assms by (auto simp add: wf_eq_minimal)  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1149  | 
show "\<exists>z\<in>P. \<forall>y. (f y, f z) \<in> r \<longrightarrow> y \<notin> P"  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1150  | 
using * [OF w] by auto  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1151  | 
qed  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1152  | 
then show ?thesis  | 
| 
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1153  | 
by (clarsimp simp: inv_image_def wf_eq_minimal)  | 
| 71544 | 1154  | 
qed  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1155  | 
|
| 
79999
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1156  | 
lemma wfp_on_inv_imagep:  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1157  | 
assumes wf: "wfp_on (f ` A) R"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1158  | 
shows "wfp_on A (inv_imagep R f)"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1159  | 
unfolding wfp_on_iff_ex_minimal  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1160  | 
proof (intro allI impI)  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1161  | 
  fix B assume "B \<subseteq> A" and "B \<noteq> {}"
 | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1162  | 
hence "\<exists>z\<in>f ` B. \<forall>y. R y z \<longrightarrow> y \<notin> f ` B"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1163  | 
using wf[unfolded wfp_on_iff_ex_minimal, rule_format, of "f ` B"] by blast  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1164  | 
thus "\<exists>z\<in>B. \<forall>y. inv_imagep R f y z \<longrightarrow> y \<notin> B"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1165  | 
unfolding inv_imagep_def  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1166  | 
by auto  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1167  | 
qed  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1168  | 
|
| 
76267
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1169  | 
|
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1170  | 
subsubsection \<open>Conversion to a known well-founded relation\<close>  | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1171  | 
|
| 
79999
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1172  | 
lemma wfp_on_if_convertible_to_wfp_on:  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1173  | 
assumes  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1174  | 
wf: "wfp_on (f ` A) Q" and  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1175  | 
convertible: "(\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> R x y \<Longrightarrow> Q (f x) (f y))"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1176  | 
shows "wfp_on A R"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1177  | 
unfolding wfp_on_iff_ex_minimal  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1178  | 
proof (intro allI impI)  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1179  | 
  fix B assume "B \<subseteq> A" and "B \<noteq> {}"
 | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1180  | 
moreover from wf have "wfp_on A (inv_imagep Q f)"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1181  | 
by (rule wfp_on_inv_imagep)  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1182  | 
ultimately obtain y where "y \<in> B" and "\<And>z. Q (f z) (f y) \<Longrightarrow> z \<notin> B"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1183  | 
unfolding wfp_on_iff_ex_minimal in_inv_imagep  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1184  | 
by blast  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1185  | 
thus "\<exists>z \<in> B. \<forall>y. R y z \<longrightarrow> y \<notin> B"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1186  | 
using \<open>B \<subseteq> A\<close> convertible by blast  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1187  | 
qed  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1188  | 
|
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1189  | 
lemma wf_on_if_convertible_to_wf_on: "wf_on (f ` A) Q \<Longrightarrow> (\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> (x, y) \<in> R \<Longrightarrow> (f x, f y) \<in> Q) \<Longrightarrow> wf_on A R"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1190  | 
using wfp_on_if_convertible_to_wfp_on[to_set] .  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1191  | 
|
| 
76267
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1192  | 
lemma wf_if_convertible_to_wf:  | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1193  | 
fixes r :: "'a rel" and s :: "'b rel" and f :: "'a \<Rightarrow> 'b"  | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1194  | 
assumes "wf s" and convertible: "\<And>x y. (x, y) \<in> r \<Longrightarrow> (f x, f y) \<in> s"  | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1195  | 
shows "wf r"  | 
| 
79999
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1196  | 
proof (rule wf_on_if_convertible_to_wf_on)  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1197  | 
show "wf_on (range f) s"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1198  | 
using wf_on_subset[OF \<open>wf s\<close> subset_UNIV] .  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1199  | 
next  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1200  | 
show "\<And>x y. (x, y) \<in> r \<Longrightarrow> (f x, f y) \<in> s"  | 
| 
 
dca9c237d108
added lemmas wfp_on_inv_imagep, wfp_on_if_convertible_to_wfp_on, and wf_on_if_convertible_to_wf_on
 
desharna 
parents: 
79997 
diff
changeset
 | 
1201  | 
using convertible .  | 
| 
76267
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1202  | 
qed  | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1203  | 
|
| 80317 | 1204  | 
lemma wfp_if_convertible_to_wfp: "wfp S \<Longrightarrow> (\<And>x y. R x y \<Longrightarrow> S (f x) (f y)) \<Longrightarrow> wfp R"  | 
| 
76267
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1205  | 
using wf_if_convertible_to_wf[to_pred, of S R f] by simp  | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1206  | 
|
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1207  | 
text \<open>Converting to @{typ nat} is a very common special case that might be found more easily by
 | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1208  | 
Sledgehammer.\<close>  | 
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1209  | 
|
| 80285 | 1210  | 
lemma wfp_if_convertible_to_nat:  | 
| 
76267
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1211  | 
fixes f :: "_ \<Rightarrow> nat"  | 
| 80317 | 1212  | 
shows "(\<And>x y. R x y \<Longrightarrow> f x < f y) \<Longrightarrow> wfp R"  | 
| 80285 | 1213  | 
by (rule wfp_if_convertible_to_wfp[of "(<) :: nat \<Rightarrow> nat \<Rightarrow> bool", simplified])  | 
| 
76267
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1214  | 
|
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1215  | 
|
| 
 
5ea1f8bfb795
added lemmas wf_if_convertible_to_wf, wfP_if_convertible_to_wfP, and wfP_if_convertible_to_nat
 
desharna 
parents: 
75669 
diff
changeset
 | 
1216  | 
subsubsection \<open>Measure functions into \<^typ>\<open>nat\<close>\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1217  | 
|
| 63108 | 1218  | 
definition measure :: "('a \<Rightarrow> nat) \<Rightarrow> ('a \<times> 'a) set"
 | 
1219  | 
where "measure = inv_image less_than"  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1220  | 
|
| 63108 | 1221  | 
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
 | 
1222  | 
by (simp add:measure_def)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1223  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1224  | 
lemma wf_measure [iff]: "wf (measure f)"  | 
| 63572 | 1225  | 
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
 | 
1226  | 
|
| 63108 | 1227  | 
lemma wf_if_measure: "(\<And>x. P x \<Longrightarrow> f(g x) < f x) \<Longrightarrow> wf {(y,x). P x \<and> y = g x}"
 | 
1228  | 
for f :: "'a \<Rightarrow> nat"  | 
|
| 68646 | 1229  | 
using wf_measure[of f] unfolding measure_def inv_image_def less_than_def less_eq  | 
1230  | 
by (rule wf_subset) auto  | 
|
| 41720 | 1231  | 
|
1232  | 
||
| 63108 | 1233  | 
subsubsection \<open>Lexicographic combinations\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1234  | 
|
| 63108 | 1235  | 
definition lex_prod :: "('a \<times>'a) set \<Rightarrow> ('b \<times> 'b) set \<Rightarrow> (('a \<times> 'b) \<times> ('a \<times> 'b)) set"
 | 
| 
80932
 
261cd8722677
standardize mixfix annotations via "isabelle update -u mixfix_cartouches -l Pure HOL" --- to simplify systematic editing;
 
wenzelm 
parents: 
80572 
diff
changeset
 | 
1236  | 
(infixr \<open><*lex*>\<close> 80)  | 
| 72184 | 1237  | 
    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
 | 
1238  | 
|
| 72184 | 1239  | 
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
 | 
1240  | 
by (auto simp:lex_prod_def)  | 
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1241  | 
|
| 82242 | 1242  | 
lemma wf_on_lex_prod[intro]:  | 
1243  | 
assumes wfA: "wf_on A r\<^sub>A" and wfB: "wf_on B r\<^sub>B"  | 
|
1244  | 
shows "wf_on (A \<times> B) (r\<^sub>A <*lex*> r\<^sub>B)"  | 
|
1245  | 
unfolding wf_on_iff_ex_minimal  | 
|
1246  | 
proof (intro allI impI)  | 
|
1247  | 
  fix AB assume "AB \<subseteq> A \<times> B" and "AB \<noteq> {}"
 | 
|
1248  | 
hence "fst ` AB \<subseteq> A" and "snd ` AB \<subseteq> B"  | 
|
1249  | 
by auto  | 
|
1250  | 
||
1251  | 
  from \<open>fst ` AB \<subseteq> A\<close> \<open>AB \<noteq> {}\<close> obtain a where
 | 
|
1252  | 
a_in: "a \<in> fst ` AB" and  | 
|
1253  | 
a_minimal: "(\<forall>y. (y, a) \<in> r\<^sub>A \<longrightarrow> y \<notin> fst ` AB)"  | 
|
1254  | 
using wfA[unfolded wf_on_iff_ex_minimal, rule_format, of "fst ` AB"]  | 
|
1255  | 
by auto  | 
|
1256  | 
||
1257  | 
  from \<open>snd ` AB \<subseteq> B\<close> \<open>AB \<noteq> {}\<close> a_in obtain b where
 | 
|
1258  | 
    b_in: "b \<in> snd ` {p \<in> AB. fst p = a}" and
 | 
|
1259  | 
    b_minimal: "(\<forall>y. (y, b) \<in> r\<^sub>B \<longrightarrow> y \<notin> snd ` {p \<in> AB. fst p = a})"
 | 
|
1260  | 
    using wfB[unfolded wf_on_iff_ex_minimal, rule_format, of "snd ` {p \<in> AB. fst p = a}"]
 | 
|
1261  | 
by blast  | 
|
1262  | 
||
1263  | 
show "\<exists>z\<in>AB. \<forall>y. (y, z) \<in> r\<^sub>A <*lex*> r\<^sub>B \<longrightarrow> y \<notin> AB"  | 
|
1264  | 
proof (rule bexI)  | 
|
1265  | 
show "(a, b) \<in> AB"  | 
|
1266  | 
using b_in by (simp add: image_iff)  | 
|
1267  | 
next  | 
|
1268  | 
show "\<forall>y. (y, (a, b)) \<in> r\<^sub>A <*lex*> r\<^sub>B \<longrightarrow> y \<notin> AB"  | 
|
1269  | 
proof (intro allI impI)  | 
|
1270  | 
fix p assume "(p, (a, b)) \<in> r\<^sub>A <*lex*> r\<^sub>B"  | 
|
1271  | 
hence "(fst p, a) \<in> r\<^sub>A \<or> fst p = a \<and> (snd p, b) \<in> r\<^sub>B"  | 
|
1272  | 
unfolding lex_prod_def by auto  | 
|
1273  | 
thus "p \<notin> AB"  | 
|
1274  | 
proof (elim disjE conjE)  | 
|
1275  | 
assume "(fst p, a) \<in> r\<^sub>A"  | 
|
1276  | 
hence "fst p \<notin> fst ` AB"  | 
|
1277  | 
using a_minimal by simp  | 
|
1278  | 
thus ?thesis  | 
|
1279  | 
by (rule contrapos_nn) simp  | 
|
1280  | 
next  | 
|
1281  | 
assume "fst p = a" and "(snd p, b) \<in> r\<^sub>B"  | 
|
1282  | 
        hence "snd p \<notin> snd ` {p \<in> AB. fst p = a}"
 | 
|
1283  | 
using b_minimal by simp  | 
|
1284  | 
thus "p \<notin> AB"  | 
|
1285  | 
by (rule contrapos_nn) (simp add: \<open>fst p = a\<close>)  | 
|
1286  | 
qed  | 
|
1287  | 
qed  | 
|
1288  | 
qed  | 
|
1289  | 
qed  | 
|
1290  | 
||
| 71410 | 1291  | 
lemma wf_lex_prod [intro!]:  | 
1292  | 
assumes "wf ra" "wf rb"  | 
|
1293  | 
shows "wf (ra <*lex*> rb)"  | 
|
| 82242 | 1294  | 
using wf_on_lex_prod[OF \<open>wf ra\<close> \<open>wf rb\<close>, unfolded UNIV_Times_UNIV] .  | 
| 71410 | 1295  | 
|
| 76698 | 1296  | 
lemma refl_lex_prod[simp]: "refl r\<^sub>B \<Longrightarrow> refl (r\<^sub>A <*lex*> r\<^sub>B)"  | 
1297  | 
by (auto intro!: reflI dest: refl_onD)  | 
|
1298  | 
||
| 
76694
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1299  | 
lemma irrefl_on_lex_prod[simp]:  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1300  | 
"irrefl_on A r\<^sub>A \<Longrightarrow> irrefl_on B r\<^sub>B \<Longrightarrow> irrefl_on (A \<times> B) (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1301  | 
by (auto intro!: irrefl_onI dest: irrefl_onD)  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1302  | 
|
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1303  | 
lemma irrefl_lex_prod[simp]: "irrefl r\<^sub>A \<Longrightarrow> irrefl r\<^sub>B \<Longrightarrow> irrefl (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1304  | 
by (rule irrefl_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV])  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1305  | 
|
| 
76695
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1306  | 
lemma sym_on_lex_prod[simp]:  | 
| 
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1307  | 
"sym_on A r\<^sub>A \<Longrightarrow> sym_on B r\<^sub>B \<Longrightarrow> sym_on (A \<times> B) (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1308  | 
by (auto intro!: sym_onI dest: sym_onD)  | 
| 
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1309  | 
|
| 
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1310  | 
lemma sym_lex_prod[simp]:  | 
| 
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1311  | 
"sym r\<^sub>A \<Longrightarrow> sym r\<^sub>B \<Longrightarrow> sym (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1312  | 
by (rule sym_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV])  | 
| 
 
e321569ec7a1
added lemmas sym_on_lex_prod[simp] and sym_lex_prod[simp]
 
desharna 
parents: 
76694 
diff
changeset
 | 
1313  | 
|
| 
76696
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1314  | 
lemma asym_on_lex_prod[simp]:  | 
| 
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1315  | 
"asym_on A r\<^sub>A \<Longrightarrow> asym_on B r\<^sub>B \<Longrightarrow> asym_on (A \<times> B) (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1316  | 
by (auto intro!: asym_onI dest: asym_onD)  | 
| 
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1317  | 
|
| 
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1318  | 
lemma asym_lex_prod[simp]:  | 
| 
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1319  | 
"asym r\<^sub>A \<Longrightarrow> asym r\<^sub>B \<Longrightarrow> asym (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1320  | 
by (rule asym_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV])  | 
| 
 
b6b7f3caa74a
added lemmas asym_on_lex_prod[simp] and asym_lex_prod[simp]
 
desharna 
parents: 
76695 
diff
changeset
 | 
1321  | 
|
| 76753 | 1322  | 
lemma trans_on_lex_prod[simp]:  | 
1323  | 
assumes "trans_on A r\<^sub>A" and "trans_on B r\<^sub>B"  | 
|
1324  | 
shows "trans_on (A \<times> B) (r\<^sub>A <*lex*> r\<^sub>B)"  | 
|
1325  | 
proof (rule trans_onI)  | 
|
1326  | 
fix x y z  | 
|
1327  | 
show "x \<in> A \<times> B \<Longrightarrow> y \<in> A \<times> B \<Longrightarrow> z \<in> A \<times> B \<Longrightarrow>  | 
|
1328  | 
(x, y) \<in> r\<^sub>A <*lex*> r\<^sub>B \<Longrightarrow> (y, z) \<in> r\<^sub>A <*lex*> r\<^sub>B \<Longrightarrow> (x, z) \<in> r\<^sub>A <*lex*> r\<^sub>B"  | 
|
1329  | 
using trans_onD[OF \<open>trans_on A r\<^sub>A\<close>, of "fst x" "fst y" "fst z"]  | 
|
1330  | 
using trans_onD[OF \<open>trans_on B r\<^sub>B\<close>, of "snd x" "snd y" "snd z"]  | 
|
1331  | 
by auto  | 
|
1332  | 
qed  | 
|
1333  | 
||
1334  | 
lemma trans_lex_prod [simp,intro!]: "trans r\<^sub>A \<Longrightarrow> trans r\<^sub>B \<Longrightarrow> trans (r\<^sub>A <*lex*> r\<^sub>B)"  | 
|
1335  | 
by (rule trans_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV])  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1336  | 
|
| 
76694
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1337  | 
lemma total_on_lex_prod[simp]:  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1338  | 
"total_on A r\<^sub>A \<Longrightarrow> total_on B r\<^sub>B \<Longrightarrow> total_on (A \<times> B) (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
71404
 
f2b783abfbe7
A few lemmas connected with orderings
 
paulson <lp15@cam.ac.uk> 
parents: 
69593 
diff
changeset
 | 
1339  | 
by (auto simp: total_on_def)  | 
| 
 
f2b783abfbe7
A few lemmas connected with orderings
 
paulson <lp15@cam.ac.uk> 
parents: 
69593 
diff
changeset
 | 
1340  | 
|
| 
76694
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1341  | 
lemma total_lex_prod[simp]: "total r\<^sub>A \<Longrightarrow> total r\<^sub>B \<Longrightarrow> total (r\<^sub>A <*lex*> r\<^sub>B)"  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1342  | 
by (rule total_on_lex_prod[of UNIV _ UNIV, unfolded UNIV_Times_UNIV])  | 
| 
 
2f8219460ac9
added lemmas irrefl_on_lex_prod[simp] and irrefl_lex_prod[simp]
 
desharna 
parents: 
76682 
diff
changeset
 | 
1343  | 
|
| 60758 | 1344  | 
text \<open>lexicographic combinations with measure functions\<close>  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1345  | 
|
| 
80932
 
261cd8722677
standardize mixfix annotations via "isabelle update -u mixfix_cartouches -l Pure HOL" --- to simplify systematic editing;
 
wenzelm 
parents: 
80572 
diff
changeset
 | 
1346  | 
definition mlex_prod :: "('a \<Rightarrow> nat) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set" (infixr \<open><*mlex*>\<close> 80)
 | 
| 63108 | 1347  | 
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
 | 
1348  | 
|
| 66952 | 1349  | 
lemma  | 
1350  | 
wf_mlex: "wf R \<Longrightarrow> wf (f <*mlex*> R)" and  | 
|
1351  | 
mlex_less: "f x < f y \<Longrightarrow> (x, y) \<in> f <*mlex*> R" and  | 
|
1352  | 
mlex_leq: "f x \<le> f y \<Longrightarrow> (x, y) \<in> R \<Longrightarrow> (x, y) \<in> f <*mlex*> R" and  | 
|
1353  | 
mlex_iff: "(x, y) \<in> f <*mlex*> R \<longleftrightarrow> f x < f y \<or> f x = f y \<and> (x, y) \<in> R"  | 
|
| 63572 | 1354  | 
by (auto simp: mlex_prod_def)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1355  | 
|
| 63572 | 1356  | 
text \<open>Proper subset relation on finite sets.\<close>  | 
| 63108 | 1357  | 
definition finite_psubset :: "('a set \<times> 'a set) set"
 | 
| 63572 | 1358  | 
  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
 | 
1359  | 
|
| 63108 | 1360  | 
lemma wf_finite_psubset[simp]: "wf finite_psubset"  | 
1361  | 
apply (unfold finite_psubset_def)  | 
|
1362  | 
apply (rule wf_measure [THEN wf_subset])  | 
|
1363  | 
apply (simp add: measure_def inv_image_def less_than_def less_eq)  | 
|
1364  | 
apply (fast elim!: psubset_card_mono)  | 
|
1365  | 
done  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1366  | 
|
| 
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1367  | 
lemma trans_finite_psubset: "trans finite_psubset"  | 
| 63612 | 1368  | 
by (auto simp: finite_psubset_def less_le trans_def)  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1369  | 
|
| 63572 | 1370  | 
lemma in_finite_psubset[simp]: "(A, B) \<in> finite_psubset \<longleftrightarrow> A \<subset> B \<and> finite B"  | 
| 63108 | 1371  | 
unfolding finite_psubset_def by auto  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1372  | 
|
| 60758 | 1373  | 
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
 | 
1374  | 
|
| 63108 | 1375  | 
inductive_set max_ext :: "('a \<times> 'a) set \<Rightarrow> ('a set \<times> 'a set) set"
 | 
1376  | 
  for R :: "('a \<times> 'a) set"
 | 
|
| 63572 | 1377  | 
where max_extI[intro]:  | 
1378  | 
    "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
 | 
1379  | 
|
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1380  | 
lemma max_ext_wf:  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1381  | 
assumes wf: "wf r"  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1382  | 
shows "wf (max_ext r)"  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1383  | 
proof (rule acc_wfI, intro allI)  | 
| 63915 | 1384  | 
show "M \<in> acc (max_ext r)" (is "_ \<in> ?W") for M  | 
1385  | 
proof (induct M rule: infinite_finite_induct)  | 
|
1386  | 
case empty  | 
|
1387  | 
show ?case  | 
|
1388  | 
by (rule accI) (auto elim: max_ext.cases)  | 
|
1389  | 
next  | 
|
1390  | 
case (insert a M)  | 
|
1391  | 
from wf \<open>M \<in> ?W\<close> \<open>finite M\<close> show "insert a M \<in> ?W"  | 
|
1392  | 
proof (induct arbitrary: M)  | 
|
1393  | 
fix M a  | 
|
1394  | 
assume "M \<in> ?W"  | 
|
1395  | 
assume [intro]: "finite M"  | 
|
1396  | 
assume hyp: "\<And>b M. (b, a) \<in> r \<Longrightarrow> M \<in> ?W \<Longrightarrow> finite M \<Longrightarrow> insert b M \<in> ?W"  | 
|
1397  | 
have add_less: "M \<in> ?W \<Longrightarrow> (\<And>y. y \<in> N \<Longrightarrow> (y, a) \<in> r) \<Longrightarrow> N \<union> M \<in> ?W"  | 
|
1398  | 
if "finite N" "finite M" for N M :: "'a set"  | 
|
1399  | 
using that by (induct N arbitrary: M) (auto simp: hyp)  | 
|
1400  | 
show "insert a M \<in> ?W"  | 
|
1401  | 
proof (rule accI)  | 
|
1402  | 
fix N  | 
|
1403  | 
assume Nless: "(N, insert a M) \<in> max_ext r"  | 
|
1404  | 
then have *: "\<And>x. x \<in> N \<Longrightarrow> (x, a) \<in> r \<or> (\<exists>y \<in> M. (x, y) \<in> r)"  | 
|
1405  | 
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
 | 
1406  | 
|
| 63915 | 1407  | 
        let ?N1 = "{n \<in> N. (n, a) \<in> r}"
 | 
1408  | 
        let ?N2 = "{n \<in> N. (n, a) \<notin> r}"
 | 
|
1409  | 
have N: "?N1 \<union> ?N2 = N" by (rule set_eqI) auto  | 
|
1410  | 
from Nless have "finite N" by (auto elim: max_ext.cases)  | 
|
1411  | 
then have finites: "finite ?N1" "finite ?N2" by auto  | 
|
| 63108 | 1412  | 
|
| 63915 | 1413  | 
have "?N2 \<in> ?W"  | 
1414  | 
        proof (cases "M = {}")
 | 
|
1415  | 
case [simp]: True  | 
|
1416  | 
          have Mw: "{} \<in> ?W" by (rule accI) (auto elim: max_ext.cases)
 | 
|
1417  | 
          from * have "?N2 = {}" by auto
 | 
|
1418  | 
with Mw show "?N2 \<in> ?W" by (simp only:)  | 
|
1419  | 
next  | 
|
1420  | 
case False  | 
|
1421  | 
from * finites have N2: "(?N2, M) \<in> max_ext r"  | 
|
| 
75669
 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 
Fabian Huch <huch@in.tum.de> 
parents: 
74971 
diff
changeset
 | 
1422  | 
            using max_extI[OF _ _ \<open>M \<noteq> {}\<close>, where ?X = ?N2] by auto
 | 
| 63915 | 1423  | 
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
 | 
1424  | 
qed  | 
| 63915 | 1425  | 
with finites have "?N1 \<union> ?N2 \<in> ?W"  | 
1426  | 
by (rule add_less) simp  | 
|
1427  | 
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
 | 
1428  | 
qed  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1429  | 
qed  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1430  | 
next  | 
| 63982 | 1431  | 
case infinite  | 
1432  | 
show ?case  | 
|
1433  | 
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
 | 
1434  | 
qed  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1435  | 
qed  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1436  | 
|
| 63572 | 1437  | 
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 | 1438  | 
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
 | 
1439  | 
|
| 63108 | 1440  | 
definition min_ext :: "('a \<times> 'a) set \<Rightarrow> ('a set \<times> 'a set) set"
 | 
1441  | 
  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
 | 
1442  | 
|
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1443  | 
lemma min_ext_wf:  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1444  | 
assumes "wf r"  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1445  | 
shows "wf (min_ext r)"  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1446  | 
proof (rule wfI_min)  | 
| 66952 | 1447  | 
show "\<exists>m \<in> Q. (\<forall>n. (n, m) \<in> min_ext r \<longrightarrow> n \<notin> Q)" if nonempty: "x \<in> Q"  | 
| 63108 | 1448  | 
for Q :: "'a set set" and x  | 
1449  | 
  proof (cases "Q = {{}}")
 | 
|
1450  | 
case True  | 
|
1451  | 
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
 | 
1452  | 
next  | 
| 63108 | 1453  | 
case False  | 
1454  | 
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
 | 
1455  | 
then have eU: "e \<in> \<Union>Q" by auto  | 
| 63108 | 1456  | 
with \<open>wf r\<close>  | 
1457  | 
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
 | 
1458  | 
by (erule wfE_min)  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1459  | 
from z obtain m where "m \<in> Q" "z \<in> m" by auto  | 
| 63572 | 1460  | 
from \<open>m \<in> Q\<close> show ?thesis  | 
1461  | 
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
 | 
1462  | 
fix n  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1463  | 
assume smaller: "(n, m) \<in> min_ext r"  | 
| 63572 | 1464  | 
with \<open>z \<in> m\<close> obtain y where "y \<in> n" "(y, z) \<in> r"  | 
1465  | 
by (auto simp: min_ext_def)  | 
|
1466  | 
with z(2) show "n \<notin> Q" by auto  | 
|
| 63108 | 1467  | 
qed  | 
| 
28735
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1468  | 
qed  | 
| 
 
bed31381e6b6
min_ext/max_ext lifting wellfounded relations on finite sets. Preserves wf
 
krauss 
parents: 
28562 
diff
changeset
 | 
1469  | 
qed  | 
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1470  | 
|
| 63108 | 1471  | 
|
1472  | 
subsubsection \<open>Bounded increase must terminate\<close>  | 
|
| 43137 | 1473  | 
|
1474  | 
lemma wf_bounded_measure:  | 
|
| 63108 | 1475  | 
fixes ub :: "'a \<Rightarrow> nat"  | 
1476  | 
and f :: "'a \<Rightarrow> nat"  | 
|
1477  | 
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"  | 
|
1478  | 
shows "wf r"  | 
|
| 63572 | 1479  | 
by (rule wf_subset[OF wf_measure[of "\<lambda>a. ub a - f a"]]) (auto dest: assms)  | 
| 43137 | 1480  | 
|
1481  | 
lemma wf_bounded_set:  | 
|
| 63108 | 1482  | 
fixes ub :: "'a \<Rightarrow> 'b set"  | 
1483  | 
and f :: "'a \<Rightarrow> 'b set"  | 
|
1484  | 
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"  | 
|
1485  | 
shows "wf r"  | 
|
| 63572 | 1486  | 
apply (rule wf_bounded_measure[of r "\<lambda>a. card (ub a)" "\<lambda>a. card (f a)"])  | 
1487  | 
apply (drule assms)  | 
|
| 63108 | 1488  | 
apply (blast intro: card_mono finite_subset psubset_card_mono dest: psubset_eq[THEN iffD2])  | 
1489  | 
done  | 
|
| 43137 | 1490  | 
|
| 
63099
 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 
eberlm 
parents: 
63088 
diff
changeset
 | 
1491  | 
lemma finite_subset_wf:  | 
| 
 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 
eberlm 
parents: 
63088 
diff
changeset
 | 
1492  | 
assumes "finite A"  | 
| 66952 | 1493  | 
  shows "wf {(X, Y). X \<subset> Y \<and> Y \<subseteq> A}"
 | 
1494  | 
by (rule wf_subset[OF wf_finite_psubset[unfolded finite_psubset_def]])  | 
|
1495  | 
(auto intro: finite_subset[OF _ assms])  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1496  | 
|
| 54295 | 1497  | 
hide_const (open) acc accp  | 
1498  | 
||
| 
79971
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1499  | 
|
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1500  | 
subsection \<open>Code Generation Setup\<close>  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1501  | 
|
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1502  | 
text \<open>Code equations with \<^const>\<open>wf\<close> or \<^const>\<open>wfp\<close> on the left-hand side are not supported by the  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1503  | 
code generation module because of the \<^const>\<open>UNIV\<close> hidden behind the abbreviations. To sidestep this  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1504  | 
problem, we provide the following wrapper definitions and use @{attribute code_abbrev} to register
 | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1505  | 
the definitions with the pre- and post-processors of the code generator.\<close>  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1506  | 
|
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1507  | 
definition wf_code :: "('a \<times> 'a) set \<Rightarrow> bool" where
 | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1508  | 
[code_abbrev]: "wf_code r \<longleftrightarrow> wf r"  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1509  | 
|
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1510  | 
definition wfp_code :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
 | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1511  | 
[code_abbrev]: "wfp_code R \<longleftrightarrow> wfp R"  | 
| 
 
033f90dc441d
redefined wf as an abbreviation for "wf_on UNIV"
 
desharna 
parents: 
79965 
diff
changeset
 | 
1512  | 
|
| 
26748
 
4d51ddd6aa5c
Merged theories about wellfoundedness into one: Wellfounded.thy
 
krauss 
parents:  
diff
changeset
 | 
1513  | 
end  |