# HG changeset patch # User wenzelm # Date 1730064902 -3600 # Node ID c1e418161aceae593f7ae6fa4ded6cea8c3f1b76 # Parent e92487b348092f52f9770b2f7975512a407aeffb tuned proofs; diff -r e92487b34809 -r c1e418161ace src/HOL/Library/Cardinality.thy --- a/src/HOL/Library/Cardinality.thy Sun Oct 27 20:11:08 2024 +0100 +++ b/src/HOL/Library/Cardinality.thy Sun Oct 27 22:35:02 2024 +0100 @@ -74,8 +74,9 @@ lemma card_fun: "CARD('a \ 'b) = (if CARD('a) \ 0 \ CARD('b) \ 0 \ CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)" proof - - { assume "0 < CARD('a)" and "0 < CARD('b)" - hence fina: "finite (UNIV :: 'a set)" and finb: "finite (UNIV :: 'b set)" + have "CARD('a \ 'b) = CARD('b) ^ CARD('a)" if "0 < CARD('a)" and "0 < CARD('b)" + proof - + from that have fina: "finite (UNIV :: 'a set)" and finb: "finite (UNIV :: 'b set)" by(simp_all only: card_ge_0_finite) from finite_distinct_list[OF finb] obtain bs where bs: "set bs = (UNIV :: 'b set)" and distb: "distinct bs" by blast @@ -113,19 +114,23 @@ qed hence "card (set ?xs) = length ?xs" by(simp only: distinct_card) moreover have "length ?xs = length bs ^ length as" by(simp add: length_n_lists) - ultimately have "CARD('a \ 'b) = CARD('b) ^ CARD('a)" using cb ca by simp } - moreover { - assume cb: "CARD('b) = 1" - then obtain b where b: "UNIV = {b :: 'b}" by(auto simp add: card_Suc_eq) + ultimately show ?thesis using cb ca by simp + qed + moreover have "CARD('a \ 'b) = 1" if "CARD('b) = 1" + proof - + from that obtain b where b: "UNIV = {b :: 'b}" by(auto simp add: card_Suc_eq) have eq: "UNIV = {\x :: 'a. b ::'b}" proof(rule UNIV_eq_I) fix x :: "'a \ 'b" - { fix y + have "x y = b" for y + proof - have "x y \ UNIV" .. - hence "x y = b" unfolding b by simp } + thus ?thesis unfolding b by simp + qed thus "x \ {\x. b}" by(auto) qed - have "CARD('a \ 'b) = 1" unfolding eq by simp } + show ?thesis unfolding eq by simp + qed ultimately show ?thesis by(auto simp del: One_nat_def)(auto simp add: card_eq_0_iff dest: finite_fun_UNIVD2 finite_fun_UNIVD1) qed diff -r e92487b34809 -r c1e418161ace src/HOL/Library/Complete_Partial_Order2.thy --- a/src/HOL/Library/Complete_Partial_Order2.thy Sun Oct 27 20:11:08 2024 +0100 +++ b/src/HOL/Library/Complete_Partial_Order2.thy Sun Oct 27 22:35:02 2024 +0100 @@ -4,8 +4,8 @@ section \Formalisation of chain-complete partial orders, continuity and admissibility\ -theory Complete_Partial_Order2 imports - Main +theory Complete_Partial_Order2 + imports Main begin unbundle lattice_syntax @@ -604,7 +604,7 @@ and mcont: "\f. mcont lub (\) Sup (\) f \ mcont lub (\) Sup (\) (F f)" shows "mcont lub (\) Sup (\) (ccpo.fixp (fun_lub Sup) (fun_ord (\)) F)" (is "mcont _ _ _ _ ?fixp") -unfolding mcont_def + unfolding mcont_def proof(intro conjI monotoneI contI) have mono: "monotone (fun_ord (\)) (fun_ord (\)) F" by(rule monotoneI)(auto simp add: fun_ord_def intro: monotoneD[OF mono]) @@ -612,36 +612,33 @@ have chain: "\x. Complete_Partial_Order.chain (\) ((\f. f x) ` ?iter)" by(rule chain_imageI[OF ccpo.chain_iterates[OF ccpo_fun mono]])(simp add: fun_ord_def) - { - fix x y - assume "x \ y" - show "?fixp x \ ?fixp y" - apply (simp only: ccpo.fixp_def[OF ccpo_fun] fun_lub_apply) - using chain - proof(rule ccpo_Sup_least) - fix x' - assume "x' \ (\f. f x) ` ?iter" - then obtain f where "f \ ?iter" "x' = f x" by blast note this(2) - also from _ \x \ y\ have "f x \ f y" - by(rule mcont_monoD[OF iterates_mcont[OF \f \ ?iter\ mcont]]) - also have "f y \ \((\f. f y) ` ?iter)" using chain - by(rule ccpo_Sup_upper)(simp add: \f \ ?iter\) - finally show "x' \ \" . - qed - next - fix Y - assume chain: "Complete_Partial_Order.chain (\) Y" - and Y: "Y \ {}" - { fix f - assume "f \ ?iter" - hence "f (\Y) = \(f ` Y)" - using mcont chain Y by(rule mcont_contD[OF iterates_mcont]) } + show "?fixp x \ ?fixp y" if "x \ y" for x y + apply (simp only: ccpo.fixp_def[OF ccpo_fun] fun_lub_apply) + using chain + proof(rule ccpo_Sup_least) + fix x' + assume "x' \ (\f. f x) ` ?iter" + then obtain f where "f \ ?iter" "x' = f x" by blast note this(2) + also from _ \x \ y\ have "f x \ f y" + by(rule mcont_monoD[OF iterates_mcont[OF \f \ ?iter\ mcont]]) + also have "f y \ \((\f. f y) ` ?iter)" using chain + by(rule ccpo_Sup_upper)(simp add: \f \ ?iter\) + finally show "x' \ \" . + qed + + show "?fixp (\Y) = \(?fixp ` Y)" + if chain: "Complete_Partial_Order.chain (\) Y" and Y: "Y \ {}" for Y + proof - + have "f (\Y) = \(f ` Y)" if "f \ ?iter" for f + using that mcont chain Y + by (rule mcont_contD[OF iterates_mcont]) moreover have "\((\f. \(f ` Y)) ` ?iter) = \((\x. \((\f. f x) ` ?iter)) ` Y)" using chain ccpo.chain_iterates[OF ccpo_fun mono] - by(rule swap_Sup)(rule mcont_mono[OF iterates_mcont[OF _ mcont]]) - ultimately show "?fixp (\Y) = \(?fixp ` Y)" unfolding ccpo.fixp_def[OF ccpo_fun] - by(simp add: fun_lub_apply cong: image_cong) - } + by (rule swap_Sup)(rule mcont_mono[OF iterates_mcont[OF _ mcont]]) + ultimately show ?thesis + unfolding ccpo.fixp_def[OF ccpo_fun] + by (simp add: fun_lub_apply cong: image_cong) + qed qed end @@ -1753,12 +1750,14 @@ from A obtain z where "z \ A" by blast with * have z: "\ flat_ord x y z" .. hence y: "x \ y" "y \ z" by(auto simp add: flat_ord_def) - { assume "\ A \ {x}" - then obtain z' where "z' \ A" "z' \ x" by auto + have "y \ (THE z. z \ A - {x})" if "\ A \ {x}" + proof - + from that obtain z' where "z' \ A" "z' \ x" by auto then have "(THE z. z \ A - {x}) = z'" by(intro the_equality)(auto dest: chainD[OF chain] simp add: flat_ord_def) moreover have "z' \ y" using \z' \ A\ * by(auto simp add: flat_ord_def) - ultimately have "y \ (THE z. z \ A - {x})" by simp } + ultimately show ?thesis by simp + qed with z show "\ flat_ord x y (flat_lub x A)" by(simp add: flat_ord_def flat_lub_def) qed