153 fix x assume "x \<le> z" with f have "f x \<le> f z" by (rule monotoneD) |
153 fix x assume "x \<le> z" with f have "f x \<le> f z" by (rule monotoneD) |
154 also note z finally show "f x \<le> z" . |
154 also note z finally show "f x \<le> z" . |
155 qed (auto intro: ccpo_Sup_least) |
155 qed (auto intro: ccpo_Sup_least) |
156 qed |
156 qed |
157 |
157 |
|
158 end |
158 |
159 |
159 subsection {* Fixpoint induction *} |
160 subsection {* Fixpoint induction *} |
160 |
161 |
161 definition |
162 setup {* Sign.map_naming (Name_Space.mandatory_path "ccpo") *} |
162 admissible :: "('a \<Rightarrow> bool) \<Rightarrow> bool" |
163 |
163 where |
164 definition admissible :: "('a set \<Rightarrow> 'a) \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" |
164 "admissible P = (\<forall>A. chain (op \<le>) A \<longrightarrow> (\<forall>x\<in>A. P x) \<longrightarrow> P (Sup A))" |
165 where "admissible lub ord P = (\<forall>A. chain ord A \<longrightarrow> (\<forall>x\<in>A. P x) \<longrightarrow> P (lub A))" |
165 |
166 |
166 lemma admissibleI: |
167 lemma admissibleI: |
167 assumes "\<And>A. chain (op \<le>) A \<Longrightarrow> \<forall>x\<in>A. P x \<Longrightarrow> P (Sup A)" |
168 assumes "\<And>A. chain ord A \<Longrightarrow> \<forall>x\<in>A. P x \<Longrightarrow> P (lub A)" |
168 shows "admissible P" |
169 shows "ccpo.admissible lub ord P" |
169 using assms unfolding admissible_def by fast |
170 using assms unfolding ccpo.admissible_def by fast |
170 |
171 |
171 lemma admissibleD: |
172 lemma admissibleD: |
172 assumes "admissible P" |
173 assumes "ccpo.admissible lub ord P" |
173 assumes "chain (op \<le>) A" |
174 assumes "chain ord A" |
174 assumes "\<And>x. x \<in> A \<Longrightarrow> P x" |
175 assumes "\<And>x. x \<in> A \<Longrightarrow> P x" |
175 shows "P (Sup A)" |
176 shows "P (lub A)" |
176 using assms by (auto simp: admissible_def) |
177 using assms by (auto simp: ccpo.admissible_def) |
177 |
178 |
178 lemma fixp_induct: |
179 setup {* Sign.map_naming Name_Space.parent_path *} |
179 assumes adm: "admissible P" |
180 |
|
181 lemma (in ccpo) fixp_induct: |
|
182 assumes adm: "ccpo.admissible Sup (op \<le>) P" |
180 assumes mono: "monotone (op \<le>) (op \<le>) f" |
183 assumes mono: "monotone (op \<le>) (op \<le>) f" |
181 assumes step: "\<And>x. P x \<Longrightarrow> P (f x)" |
184 assumes step: "\<And>x. P x \<Longrightarrow> P (f x)" |
182 shows "P (fixp f)" |
185 shows "P (fixp f)" |
183 unfolding fixp_def using adm chain_iterates[OF mono] |
186 unfolding fixp_def using adm chain_iterates[OF mono] |
184 proof (rule admissibleD) |
187 proof (rule ccpo.admissibleD) |
185 fix x assume "x \<in> iterates f" |
188 fix x assume "x \<in> iterates f" |
186 thus "P x" |
189 thus "P x" |
187 by (induct rule: iterates.induct) |
190 by (induct rule: iterates.induct) |
188 (auto intro: step admissibleD adm) |
191 (auto intro: step ccpo.admissibleD adm) |
189 qed |
192 qed |
190 |
193 |
191 lemma admissible_True: "admissible (\<lambda>x. True)" |
194 lemma admissible_True: "ccpo.admissible lub ord (\<lambda>x. True)" |
192 unfolding admissible_def by simp |
195 unfolding ccpo.admissible_def by simp |
193 |
196 |
194 lemma admissible_False: "\<not> admissible (\<lambda>x. False)" |
197 lemma admissible_False: "\<not> ccpo.admissible lub ord (\<lambda>x. False)" |
195 unfolding admissible_def chain_def by simp |
198 unfolding ccpo.admissible_def chain_def by simp |
196 |
199 |
197 lemma admissible_const: "admissible (\<lambda>x. t) = t" |
200 lemma admissible_const: "ccpo.admissible lub ord (\<lambda>x. t) = t" |
198 by (cases t, simp_all add: admissible_True admissible_False) |
201 by (cases t, simp_all add: admissible_True admissible_False) |
199 |
202 |
200 lemma admissible_conj: |
203 lemma admissible_conj: |
201 assumes "admissible (\<lambda>x. P x)" |
204 assumes "ccpo.admissible lub ord (\<lambda>x. P x)" |
202 assumes "admissible (\<lambda>x. Q x)" |
205 assumes "ccpo.admissible lub ord (\<lambda>x. Q x)" |
203 shows "admissible (\<lambda>x. P x \<and> Q x)" |
206 shows "ccpo.admissible lub ord (\<lambda>x. P x \<and> Q x)" |
204 using assms unfolding admissible_def by simp |
207 using assms unfolding ccpo.admissible_def by simp |
205 |
208 |
206 lemma admissible_all: |
209 lemma admissible_all: |
207 assumes "\<And>y. admissible (\<lambda>x. P x y)" |
210 assumes "\<And>y. ccpo.admissible lub ord (\<lambda>x. P x y)" |
208 shows "admissible (\<lambda>x. \<forall>y. P x y)" |
211 shows "ccpo.admissible lub ord (\<lambda>x. \<forall>y. P x y)" |
209 using assms unfolding admissible_def by fast |
212 using assms unfolding ccpo.admissible_def by fast |
210 |
213 |
211 lemma admissible_ball: |
214 lemma admissible_ball: |
212 assumes "\<And>y. y \<in> A \<Longrightarrow> admissible (\<lambda>x. P x y)" |
215 assumes "\<And>y. y \<in> A \<Longrightarrow> ccpo.admissible lub ord (\<lambda>x. P x y)" |
213 shows "admissible (\<lambda>x. \<forall>y\<in>A. P x y)" |
216 shows "ccpo.admissible lub ord (\<lambda>x. \<forall>y\<in>A. P x y)" |
214 using assms unfolding admissible_def by fast |
217 using assms unfolding ccpo.admissible_def by fast |
215 |
218 |
216 lemma chain_compr: "chain (op \<le>) A \<Longrightarrow> chain (op \<le>) {x \<in> A. P x}" |
219 lemma chain_compr: "chain ord A \<Longrightarrow> chain ord {x \<in> A. P x}" |
217 unfolding chain_def by fast |
220 unfolding chain_def by fast |
|
221 |
|
222 context ccpo begin |
218 |
223 |
219 lemma admissible_disj_lemma: |
224 lemma admissible_disj_lemma: |
220 assumes A: "chain (op \<le>)A" |
225 assumes A: "chain (op \<le>)A" |
221 assumes P: "\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> P y" |
226 assumes P: "\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> P y" |
222 shows "Sup A = Sup {x \<in> A. P x}" |
227 shows "Sup A = Sup {x \<in> A. P x}" |
236 done |
241 done |
237 qed |
242 qed |
238 |
243 |
239 lemma admissible_disj: |
244 lemma admissible_disj: |
240 fixes P Q :: "'a \<Rightarrow> bool" |
245 fixes P Q :: "'a \<Rightarrow> bool" |
241 assumes P: "admissible (\<lambda>x. P x)" |
246 assumes P: "ccpo.admissible Sup (op \<le>) (\<lambda>x. P x)" |
242 assumes Q: "admissible (\<lambda>x. Q x)" |
247 assumes Q: "ccpo.admissible Sup (op \<le>) (\<lambda>x. Q x)" |
243 shows "admissible (\<lambda>x. P x \<or> Q x)" |
248 shows "ccpo.admissible Sup (op \<le>) (\<lambda>x. P x \<or> Q x)" |
244 proof (rule admissibleI) |
249 proof (rule ccpo.admissibleI) |
245 fix A :: "'a set" assume A: "chain (op \<le>) A" |
250 fix A :: "'a set" assume A: "chain (op \<le>) A" |
246 assume "\<forall>x\<in>A. P x \<or> Q x" |
251 assume "\<forall>x\<in>A. P x \<or> Q x" |
247 hence "(\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> P y) \<or> (\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> Q y)" |
252 hence "(\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> P y) \<or> (\<forall>x\<in>A. \<exists>y\<in>A. x \<le> y \<and> Q y)" |
248 using chainD[OF A] by blast |
253 using chainD[OF A] by blast |
249 hence "Sup A = Sup {x \<in> A. P x} \<or> Sup A = Sup {x \<in> A. Q x}" |
254 hence "Sup A = Sup {x \<in> A. P x} \<or> Sup A = Sup {x \<in> A. Q x}" |
250 using admissible_disj_lemma [OF A] by fast |
255 using admissible_disj_lemma [OF A] by fast |
251 thus "P (Sup A) \<or> Q (Sup A)" |
256 thus "P (Sup A) \<or> Q (Sup A)" |
252 apply (rule disjE, simp_all) |
257 apply (rule disjE, simp_all) |
253 apply (rule disjI1, rule admissibleD [OF P chain_compr [OF A]], simp) |
258 apply (rule disjI1, rule ccpo.admissibleD [OF P chain_compr [OF A]], simp) |
254 apply (rule disjI2, rule admissibleD [OF Q chain_compr [OF A]], simp) |
259 apply (rule disjI2, rule ccpo.admissibleD [OF Q chain_compr [OF A]], simp) |
255 done |
260 done |
256 qed |
261 qed |
257 |
262 |
258 end |
263 end |
259 |
264 |