42 by (simp add: wfP_def) |
42 by (simp add: wfP_def) |
43 |
43 |
44 |
44 |
45 subsection \<open>Induction Principles\<close> |
45 subsection \<open>Induction Principles\<close> |
46 |
46 |
47 lemma wf_on_induct[consumes 2, case_names less, induct set: wf]: |
47 lemma wf_on_induct[consumes 2, case_names less, induct set: wf_on]: |
48 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" |
48 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" |
49 shows "P x" |
49 shows "P x" |
50 using assms(2,3) by (auto intro: \<open>wf_on A r\<close>[unfolded wf_on_def, rule_format]) |
50 using assms(2,3) by (auto intro: \<open>wf_on A r\<close>[unfolded wf_on_def, rule_format]) |
51 |
51 |
52 lemma wfp_on_induct[consumes 2, case_names less, induct pred: wfp_on]: |
52 lemma wfp_on_induct[consumes 2, case_names less, induct pred: wfp_on]: |
130 |
130 |
131 |
131 |
132 subsection \<open>Basic Results\<close> |
132 subsection \<open>Basic Results\<close> |
133 |
133 |
134 text \<open>Point-free characterization of well-foundedness\<close> |
134 text \<open>Point-free characterization of well-foundedness\<close> |
|
135 |
|
136 lemma wf_onE_pf: |
|
137 assumes wf: "wf_on A r" and "B \<subseteq> A" and "B \<subseteq> r `` B" |
|
138 shows "B = {}" |
|
139 proof - |
|
140 have "x \<notin> B" if "x \<in> A" for x |
|
141 using wf that |
|
142 proof (induction x rule: wf_on_induct) |
|
143 case (less x) |
|
144 have "x \<notin> r `` B" |
|
145 using less.IH \<open>B \<subseteq> A\<close> by blast |
|
146 thus ?case |
|
147 using \<open>B \<subseteq> r `` B\<close> by blast |
|
148 qed |
|
149 with \<open>B \<subseteq> A\<close> show ?thesis |
|
150 by blast |
|
151 qed |
135 |
152 |
136 lemma wfE_pf: |
153 lemma wfE_pf: |
137 assumes wf: "wf R" |
154 assumes wf: "wf R" |
138 and a: "A \<subseteq> R `` A" |
155 and a: "A \<subseteq> R `` A" |
139 shows "A = {}" |
156 shows "A = {}" |
145 with a show "x \<notin> A" by blast |
162 with a show "x \<notin> A" by blast |
146 qed |
163 qed |
147 then show ?thesis by auto |
164 then show ?thesis by auto |
148 qed |
165 qed |
149 |
166 |
|
167 lemma wf_onI_pf: |
|
168 assumes "\<And>B. B \<subseteq> A \<Longrightarrow> B \<subseteq> R `` B \<Longrightarrow> B = {}" |
|
169 shows "wf_on A R" |
|
170 unfolding wf_on_def |
|
171 proof (intro allI impI ballI) |
|
172 fix P :: "'a \<Rightarrow> bool" and x :: 'a |
|
173 let ?B = "{x \<in> A. \<not> P x}" |
|
174 assume "\<forall>x\<in>A. (\<forall>y\<in>A. (y, x) \<in> R \<longrightarrow> P y) \<longrightarrow> P x" |
|
175 hence "?B \<subseteq> R `` ?B" by blast |
|
176 hence "{x \<in> A. \<not> P x} = {}" |
|
177 using assms(1)[of ?B] by simp |
|
178 moreover assume "x \<in> A" |
|
179 ultimately show "P x" |
|
180 by simp |
|
181 qed |
|
182 |
150 lemma wfI_pf: |
183 lemma wfI_pf: |
151 assumes a: "\<And>A. A \<subseteq> R `` A \<Longrightarrow> A = {}" |
184 assumes a: "\<And>A. A \<subseteq> R `` A \<Longrightarrow> A = {}" |
152 shows "wf R" |
185 shows "wf R" |
153 proof (rule wfUNIVI) |
186 proof (rule wfUNIVI) |
154 fix P :: "'a \<Rightarrow> bool" and x |
187 fix P :: "'a \<Rightarrow> bool" and x |
158 with a show "P x" by blast |
191 with a show "P x" by blast |
159 qed |
192 qed |
160 |
193 |
161 |
194 |
162 subsubsection \<open>Minimal-element characterization of well-foundedness\<close> |
195 subsubsection \<open>Minimal-element characterization of well-foundedness\<close> |
|
196 |
|
197 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))" |
|
198 proof (intro iffI allI impI) |
|
199 fix B |
|
200 assume "wf_on A R" and "B \<subseteq> A" and "B \<noteq> {}" |
|
201 show "\<exists>z \<in> B. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> B" |
|
202 using wf_onE_pf[OF \<open>wf_on A R\<close> \<open>B \<subseteq> A\<close>] \<open>B \<noteq> {}\<close> by blast |
|
203 next |
|
204 assume ex_min: "\<forall>B\<subseteq>A. B \<noteq> {} \<longrightarrow> (\<exists>z\<in>B. \<forall>y. (y, z) \<in> R \<longrightarrow> y \<notin> B)" |
|
205 show "wf_on A R " |
|
206 proof (rule wf_onI_pf) |
|
207 fix B |
|
208 assume "B \<subseteq> A" and "B \<subseteq> R `` B" |
|
209 have False if "B \<noteq> {}" |
|
210 using ex_min[rule_format, OF \<open>B \<subseteq> A\<close> \<open>B \<noteq> {}\<close>] |
|
211 using \<open>B \<subseteq> R `` B\<close> by blast |
|
212 thus "B = {}" |
|
213 by blast |
|
214 qed |
|
215 qed |
|
216 |
|
217 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))" |
|
218 using wf_on_iff_ex_minimal[of UNIV, unfolded wf_on_UNIV, simplified] . |
|
219 |
|
220 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))" |
|
221 using wf_on_iff_ex_minimal[of A, to_pred] by simp |
|
222 |
|
223 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))" |
|
224 using wfp_on_iff_ex_minimal[of UNIV, unfolded wfp_on_UNIV, simplified] . |
163 |
225 |
164 lemma wfE_min: |
226 lemma wfE_min: |
165 assumes wf: "wf R" and Q: "x \<in> Q" |
227 assumes wf: "wf R" and Q: "x \<in> Q" |
166 obtains z where "z \<in> Q" "\<And>y. (y, z) \<in> R \<Longrightarrow> y \<notin> Q" |
228 obtains z where "z \<in> Q" "\<And>y. (y, z) \<in> R \<Longrightarrow> y \<notin> Q" |
167 using Q wfE_pf[OF wf, of Q] by blast |
229 using Q wfE_pf[OF wf, of Q] by blast |