# HG changeset patch # User Andreas Lochbihler # Date 1378134891 -7200 # Node ID f6629734dd2b5c36b697d2c608b869aafbb3f7d1 # Parent 735e078a64e74fec1171c074868af59e6f08a5ca# Parent 7ffc4a746a73791e4f6993be0ca0e764d5ac4e98 merged diff -r 7ffc4a746a73 -r f6629734dd2b NEWS --- a/NEWS Mon Sep 02 15:13:00 2013 +0200 +++ b/NEWS Mon Sep 02 17:14:51 2013 +0200 @@ -265,6 +265,11 @@ Code_Target_Nat and Code_Target_Numeral. See the tutorial on code generation for details. INCOMPATIBILITY. +* Complete_Partial_Order.admissible is defined outside the type +class ccpo, but with mandatory prefix ccpo. Admissibility theorems +lose the class predicate assumption or sort constraint when possible. +INCOMPATIBILITY. + * Introduce type class "conditionally_complete_lattice": Like a complete lattice but does not assume the existence of the top and bottom elements. Allows to generalize some lemmas about reals and diff -r 7ffc4a746a73 -r f6629734dd2b src/HOL/Codegenerator_Test/Generate_Efficient_Datastructures.thy --- a/src/HOL/Codegenerator_Test/Generate_Efficient_Datastructures.thy Mon Sep 02 15:13:00 2013 +0200 +++ b/src/HOL/Codegenerator_Test/Generate_Efficient_Datastructures.thy Mon Sep 02 17:14:51 2013 +0200 @@ -53,13 +53,6 @@ (* If the compilation fails with an error "ambiguous implicit values", read \
7.1 in the Code Generation Manual *) -class ccpo_linorder = ccpo + linorder - -lemma [code]: - "(Complete_Partial_Order.admissible :: ('a :: ccpo_linorder \ bool) \ bool) P = - (\A. Complete_Partial_Order.chain (op \) A \ (\x\A. P x) \ P (Sup A))" -unfolding admissible_def by blast - lemma [code]: "(gfp :: ('a :: complete_linorder \ 'a) \ 'a) f = Sup {u. u \ f u}" unfolding gfp_def by blast diff -r 7ffc4a746a73 -r f6629734dd2b src/HOL/Complete_Partial_Order.thy --- a/src/HOL/Complete_Partial_Order.thy Mon Sep 02 15:13:00 2013 +0200 +++ b/src/HOL/Complete_Partial_Order.thy Mon Sep 02 17:14:51 2013 +0200 @@ -155,67 +155,72 @@ qed (auto intro: ccpo_Sup_least) qed +end subsection {* Fixpoint induction *} -definition - admissible :: "('a \ bool) \ bool" -where - "admissible P = (\A. chain (op \) A \ (\x\A. P x) \ P (Sup A))" +setup {* Sign.map_naming (Name_Space.mandatory_path "ccpo") *} + +definition admissible :: "('a set \ 'a) \ ('a \ 'a \ bool) \ ('a \ bool) \ bool" +where "admissible lub ord P = (\A. chain ord A \ (\x\A. P x) \ P (lub A))" lemma admissibleI: - assumes "\A. chain (op \) A \ \x\A. P x \ P (Sup A)" - shows "admissible P" -using assms unfolding admissible_def by fast + assumes "\A. chain ord A \ \x\A. P x \ P (lub A)" + shows "ccpo.admissible lub ord P" +using assms unfolding ccpo.admissible_def by fast lemma admissibleD: - assumes "admissible P" - assumes "chain (op \) A" + assumes "ccpo.admissible lub ord P" + assumes "chain ord A" assumes "\x. x \ A \ P x" - shows "P (Sup A)" -using assms by (auto simp: admissible_def) + shows "P (lub A)" +using assms by (auto simp: ccpo.admissible_def) -lemma fixp_induct: - assumes adm: "admissible P" +setup {* Sign.map_naming Name_Space.parent_path *} + +lemma (in ccpo) fixp_induct: + assumes adm: "ccpo.admissible Sup (op \) P" assumes mono: "monotone (op \) (op \) f" assumes step: "\x. P x \ P (f x)" shows "P (fixp f)" unfolding fixp_def using adm chain_iterates[OF mono] -proof (rule admissibleD) +proof (rule ccpo.admissibleD) fix x assume "x \ iterates f" thus "P x" by (induct rule: iterates.induct) - (auto intro: step admissibleD adm) + (auto intro: step ccpo.admissibleD adm) qed -lemma admissible_True: "admissible (\x. True)" -unfolding admissible_def by simp +lemma admissible_True: "ccpo.admissible lub ord (\x. True)" +unfolding ccpo.admissible_def by simp -lemma admissible_False: "\ admissible (\x. False)" -unfolding admissible_def chain_def by simp +lemma admissible_False: "\ ccpo.admissible lub ord (\x. False)" +unfolding ccpo.admissible_def chain_def by simp -lemma admissible_const: "admissible (\x. t) = t" +lemma admissible_const: "ccpo.admissible lub ord (\x. t) = t" by (cases t, simp_all add: admissible_True admissible_False) lemma admissible_conj: - assumes "admissible (\x. P x)" - assumes "admissible (\x. Q x)" - shows "admissible (\x. P x \ Q x)" -using assms unfolding admissible_def by simp + assumes "ccpo.admissible lub ord (\x. P x)" + assumes "ccpo.admissible lub ord (\x. Q x)" + shows "ccpo.admissible lub ord (\x. P x \ Q x)" +using assms unfolding ccpo.admissible_def by simp lemma admissible_all: - assumes "\y. admissible (\x. P x y)" - shows "admissible (\x. \y. P x y)" -using assms unfolding admissible_def by fast + assumes "\y. ccpo.admissible lub ord (\x. P x y)" + shows "ccpo.admissible lub ord (\x. \y. P x y)" +using assms unfolding ccpo.admissible_def by fast lemma admissible_ball: - assumes "\y. y \ A \ admissible (\x. P x y)" - shows "admissible (\x. \y\A. P x y)" -using assms unfolding admissible_def by fast + assumes "\y. y \ A \ ccpo.admissible lub ord (\x. P x y)" + shows "ccpo.admissible lub ord (\x. \y\A. P x y)" +using assms unfolding ccpo.admissible_def by fast -lemma chain_compr: "chain (op \) A \ chain (op \) {x \ A. P x}" +lemma chain_compr: "chain ord A \ chain ord {x \ A. P x}" unfolding chain_def by fast +context ccpo begin + lemma admissible_disj_lemma: assumes A: "chain (op \)A" assumes P: "\x\A. \y\A. x \ y \ P y" @@ -238,10 +243,10 @@ lemma admissible_disj: fixes P Q :: "'a \ bool" - assumes P: "admissible (\x. P x)" - assumes Q: "admissible (\x. Q x)" - shows "admissible (\x. P x \ Q x)" -proof (rule admissibleI) + assumes P: "ccpo.admissible Sup (op \) (\x. P x)" + assumes Q: "ccpo.admissible Sup (op \) (\x. Q x)" + shows "ccpo.admissible Sup (op \) (\x. P x \ Q x)" +proof (rule ccpo.admissibleI) fix A :: "'a set" assume A: "chain (op \) A" assume "\x\A. P x \ Q x" hence "(\x\A. \y\A. x \ y \ P y) \ (\x\A. \y\A. x \ y \ Q y)" @@ -250,8 +255,8 @@ using admissible_disj_lemma [OF A] by fast thus "P (Sup A) \ Q (Sup A)" apply (rule disjE, simp_all) - apply (rule disjI1, rule admissibleD [OF P chain_compr [OF A]], simp) - apply (rule disjI2, rule admissibleD [OF Q chain_compr [OF A]], simp) + apply (rule disjI1, rule ccpo.admissibleD [OF P chain_compr [OF A]], simp) + apply (rule disjI2, rule ccpo.admissibleD [OF Q chain_compr [OF A]], simp) done qed @@ -271,6 +276,6 @@ by (rule fixp_lowerbound [OF f'], subst lfp_unfold [OF f], rule order_refl) qed -hide_const (open) iterates fixp admissible +hide_const (open) iterates fixp end diff -r 7ffc4a746a73 -r f6629734dd2b src/HOL/Imperative_HOL/Heap_Monad.thy --- a/src/HOL/Imperative_HOL/Heap_Monad.thy Mon Sep 02 15:13:00 2013 +0200 +++ b/src/HOL/Imperative_HOL/Heap_Monad.thy Mon Sep 02 17:14:51 2013 +0200 @@ -432,7 +432,7 @@ lemma heap_step_admissible: "option.admissible (\f:: 'a => ('b * 'c) option. \h h' r. f h = Some (r, h') \ P x h h' r)" -proof (rule ccpo.admissibleI[OF option.ccpo]) +proof (rule ccpo.admissibleI) fix A :: "('a \ ('b * 'c) option) set" assume ch: "Complete_Partial_Order.chain option.le_fun A" and IH: "\f\A. \h h' r. f h = Some (r, h') \ P x h h' r" diff -r 7ffc4a746a73 -r f6629734dd2b src/HOL/Partial_Function.thy --- a/src/HOL/Partial_Function.thy Mon Sep 02 15:13:00 2013 +0200 +++ b/src/HOL/Partial_Function.thy Mon Sep 02 17:14:51 2013 +0200 @@ -250,7 +250,7 @@ lemma tailrec_admissible: "ccpo.admissible (fun_lub (flat_lub undefined)) (fun_ord tailrec_ord) (\a. \x. a x \ undefined \ P x (a x))" -proof(intro ccpo.admissibleI[OF tailrec.ccpo] strip) +proof(intro ccpo.admissibleI strip) fix A x assume chain: "Complete_Partial_Order.chain (fun_ord tailrec_ord) A" and P [rule_format]: "\f\A. \x. f x \ undefined \ P x (f x)" @@ -290,13 +290,13 @@ assumes inj: "\x y. f x = f y \ x = y" assumes inv: "\x. f (g x) = x" shows "ccpo.admissible (img_lub f g lub) (img_ord f le) P" -proof (rule ccpo.admissibleI, rule ccpo, rule partial_function_image, fact pfun, fact inj, fact inv) +proof (rule ccpo.admissibleI) fix A assume "chain (img_ord f le) A" then have ch': "chain le (f ` A)" by (auto simp: img_ord_def intro: chainI dest: chainD) assume P_A: "\x\A. P x" - have "(P o g) (lub (f ` A))" - proof (rule ccpo.admissibleD[OF ccpo, OF pfun adm ch']) + have "(P o g) (lub (f ` A))" using adm ch' + proof (rule ccpo.admissibleD) fix x assume "x \ f ` A" with P_A show "(P o g) x" by (auto simp: inj[OF inv]) qed @@ -307,13 +307,13 @@ assumes pfun: "partial_function_definitions le lub" assumes adm: "\x. ccpo.admissible lub le (Q x)" shows "ccpo.admissible (fun_lub lub) (fun_ord le) (\f. \x. Q x (f x))" -proof (rule ccpo.admissibleI, rule ccpo, rule partial_function_lift, rule pfun) +proof (rule ccpo.admissibleI) fix A :: "('b \ 'a) set" assume Q: "\f\A. \x. Q x (f x)" assume ch: "chain (fun_ord le) A" show "\x. Q x (fun_lub lub A x)" unfolding fun_lub_def - by (rule allI, rule ccpo.admissibleD[OF ccpo, OF pfun adm chain_fun[OF ch]]) + by (rule allI, rule ccpo.admissibleD[OF adm chain_fun[OF ch]]) (auto simp: Q) qed @@ -360,7 +360,7 @@ lemma option_admissible: "option.admissible (%(f::'a \ 'b option). (\x y. f x = Some y \ P x y))" -proof (rule ccpo.admissibleI[OF option.ccpo]) +proof (rule ccpo.admissibleI) fix A :: "('a \ 'b option) set" assume ch: "chain option.le_fun A" and IH: "\f\A. \x y. f x = Some y \ P x y"