# HG changeset patch # User haftmann # Date 1613980191 0 # Node ID 05a873f90655aff0c823b54718512cf7c03738cb # Parent e2d03448d5b5ab07d4fe162b5f0c4d73c8dd03e6 dedicated locale for preorder and abstract bdd operation diff -r e2d03448d5b5 -r 05a873f90655 src/HOL/Conditionally_Complete_Lattices.thy --- a/src/HOL/Conditionally_Complete_Lattices.thy Mon Feb 22 07:49:48 2021 +0000 +++ b/src/HOL/Conditionally_Complete_Lattices.thy Mon Feb 22 07:49:51 2021 +0000 @@ -10,47 +10,93 @@ imports Finite_Set Lattices_Big Set_Interval begin +locale preordering_bdd = preordering +begin + +definition bdd :: \'a set \ bool\ + where unfold: \bdd A \ (\M. \x \ A. x \<^bold>\ M)\ + +lemma empty [simp, intro]: + \bdd {}\ + by (simp add: unfold) + +lemma I [intro]: + \bdd A\ if \\x. x \ A \ x \<^bold>\ M\ + using that by (auto simp add: unfold) + +lemma E: + assumes \bdd A\ + obtains M where \\x. x \ A \ x \<^bold>\ M\ + using assms that by (auto simp add: unfold) + +lemma I2: + \bdd (f ` A)\ if \\x. x \ A \ f x \<^bold>\ M\ + using that by (auto simp add: unfold) + +lemma mono: + \bdd A\ if \bdd B\ \A \ B\ + using that by (auto simp add: unfold) + +lemma Int1 [simp]: + \bdd (A \ B)\ if \bdd A\ + using mono that by auto + +lemma Int2 [simp]: + \bdd (A \ B)\ if \bdd B\ + using mono that by auto + +end + context preorder begin -definition "bdd_above A \ (\M. \x \ A. x \ M)" -definition "bdd_below A \ (\m. \x \ A. m \ x)" +sublocale bdd_above: preordering_bdd \(\)\ \(<)\ + defines bdd_above_primitive_def: bdd_above = bdd_above.bdd .. + +sublocale bdd_below: preordering_bdd \(\)\ \(>)\ + defines bdd_below_primitive_def: bdd_below = bdd_below.bdd .. + +lemma bdd_above_def: \bdd_above A \ (\M. \x \ A. x \ M)\ + by (fact bdd_above.unfold) -lemma bdd_aboveI[intro]: "(\x. x \ A \ x \ M) \ bdd_above A" - by (auto simp: bdd_above_def) +lemma bdd_below_def: \bdd_below A \ (\M. \x \ A. M \ x)\ + by (fact bdd_below.unfold) -lemma bdd_belowI[intro]: "(\x. x \ A \ m \ x) \ bdd_below A" - by (auto simp: bdd_below_def) +lemma bdd_aboveI: "(\x. x \ A \ x \ M) \ bdd_above A" + by (fact bdd_above.I) + +lemma bdd_belowI: "(\x. x \ A \ m \ x) \ bdd_below A" + by (fact bdd_below.I) lemma bdd_aboveI2: "(\x. x \ A \ f x \ M) \ bdd_above (f`A)" - by force + by (fact bdd_above.I2) lemma bdd_belowI2: "(\x. x \ A \ m \ f x) \ bdd_below (f`A)" - by force + by (fact bdd_below.I2) -lemma bdd_above_empty [simp, intro]: "bdd_above {}" - unfolding bdd_above_def by auto +lemma bdd_above_empty: "bdd_above {}" + by (fact bdd_above.empty) -lemma bdd_below_empty [simp, intro]: "bdd_below {}" - unfolding bdd_below_def by auto +lemma bdd_below_empty: "bdd_below {}" + by (fact bdd_below.empty) lemma bdd_above_mono: "bdd_above B \ A \ B \ bdd_above A" - by (metis (full_types) bdd_above_def order_class.le_neq_trans psubsetD) + by (fact bdd_above.mono) lemma bdd_below_mono: "bdd_below B \ A \ B \ bdd_below A" - by (metis bdd_below_def order_class.le_neq_trans psubsetD) + by (fact bdd_below.mono) -lemma bdd_above_Int1 [simp]: "bdd_above A \ bdd_above (A \ B)" - using bdd_above_mono by auto +lemma bdd_above_Int1: "bdd_above A \ bdd_above (A \ B)" + by (fact bdd_above.Int1) -lemma bdd_above_Int2 [simp]: "bdd_above B \ bdd_above (A \ B)" - using bdd_above_mono by auto +lemma bdd_above_Int2: "bdd_above B \ bdd_above (A \ B)" + by (fact bdd_above.Int2) -lemma bdd_below_Int1 [simp]: "bdd_below A \ bdd_below (A \ B)" - using bdd_below_mono by auto +lemma bdd_below_Int1: "bdd_below A \ bdd_below (A \ B)" + by (fact bdd_below.Int1) -lemma bdd_below_Int2 [simp]: "bdd_below B \ bdd_below (A \ B)" - using bdd_below_mono by auto +lemma bdd_below_Int2: "bdd_below B \ bdd_below (A \ B)" + by (fact bdd_below.Int2) lemma bdd_above_Ioo [simp, intro]: "bdd_above {a <..< b}" by (auto simp add: bdd_above_def intro!: exI[of _ b] less_imp_le) @@ -90,11 +136,21 @@ end -lemma (in order_top) bdd_above_top[simp, intro!]: "bdd_above A" - by (rule bdd_aboveI[of _ top]) simp +context order_top +begin + +lemma bdd_above_top [simp, intro!]: "bdd_above A" + by (rule bdd_aboveI [of _ top]) simp + +end -lemma (in order_bot) bdd_above_bot[simp, intro!]: "bdd_below A" - by (rule bdd_belowI[of _ bot]) simp +context order_bot +begin + +lemma bdd_below_bot [simp, intro!]: "bdd_below A" + by (rule bdd_belowI [of _ bot]) simp + +end lemma bdd_above_image_mono: "mono f \ bdd_above A \ bdd_above (f`A)" by (auto simp: bdd_above_def mono_def) diff -r e2d03448d5b5 -r 05a873f90655 src/HOL/Orderings.thy --- a/src/HOL/Orderings.thy Mon Feb 22 07:49:48 2021 +0000 +++ b/src/HOL/Orderings.thy Mon Feb 22 07:49:51 2021 +0000 @@ -13,114 +13,160 @@ subsection \Abstract ordering\ -locale ordering = - fixes less_eq :: "'a \ 'a \ bool" (infix "\<^bold>\" 50) - and less :: "'a \ 'a \ bool" (infix "\<^bold><" 50) - assumes strict_iff_order: "a \<^bold>< b \ a \<^bold>\ b \ a \ b" - assumes refl: "a \<^bold>\ a" \ \not \iff\: makes problems due to multiple (dual) interpretations\ - and antisym: "a \<^bold>\ b \ b \<^bold>\ a \ a = b" - and trans: "a \<^bold>\ b \ b \<^bold>\ c \ a \<^bold>\ c" +locale partial_preordering = + fixes less_eq :: \'a \ 'a \ bool\ (infix \\<^bold>\\ 50) + assumes refl: \a \<^bold>\ a\ \ \not \iff\: makes problems due to multiple (dual) interpretations\ + and trans: \a \<^bold>\ b \ b \<^bold>\ c \ a \<^bold>\ c\ + +locale preordering = partial_preordering + + fixes less :: \'a \ 'a \ bool\ (infix \\<^bold><\ 50) + assumes strict_iff_not: \a \<^bold>< b \ a \<^bold>\ b \ \ b \<^bold>\ a\ begin lemma strict_implies_order: - "a \<^bold>< b \ a \<^bold>\ b" - by (simp add: strict_iff_order) + \a \<^bold>< b \ a \<^bold>\ b\ + by (simp add: strict_iff_not) + +lemma irrefl: \ \not \iff\: makes problems due to multiple (dual) interpretations\ + \\ a \<^bold>< a\ + by (simp add: strict_iff_not) + +lemma asym: + \a \<^bold>< b \ b \<^bold>< a \ False\ + by (auto simp add: strict_iff_not) + +lemma strict_trans1: + \a \<^bold>\ b \ b \<^bold>< c \ a \<^bold>< c\ + by (auto simp add: strict_iff_not intro: trans) + +lemma strict_trans2: + \a \<^bold>< b \ b \<^bold>\ c \ a \<^bold>< c\ + by (auto simp add: strict_iff_not intro: trans) + +lemma strict_trans: + \a \<^bold>< b \ b \<^bold>< c \ a \<^bold>< c\ + by (auto intro: strict_trans1 strict_implies_order) + +end + +lemma preordering_strictI: \ \Alternative introduction rule with bias towards strict order\ + fixes less_eq (infix \\<^bold>\\ 50) + and less (infix \\<^bold><\ 50) + assumes less_eq_less: \\a b. a \<^bold>\ b \ a \<^bold>< b \ a = b\ + assumes asym: \\a b. a \<^bold>< b \ \ b \<^bold>< a\ + assumes irrefl: \\a. \ a \<^bold>< a\ + assumes trans: \\a b c. a \<^bold>< b \ b \<^bold>< c \ a \<^bold>< c\ + shows \preordering (\<^bold>\) (\<^bold><)\ +proof + fix a b + show \a \<^bold>< b \ a \<^bold>\ b \ \ b \<^bold>\ a\ + by (auto simp add: less_eq_less asym irrefl) +next + fix a + show \a \<^bold>\ a\ + by (auto simp add: less_eq_less) +next + fix a b c + assume \a \<^bold>\ b\ and \b \<^bold>\ c\ then show \a \<^bold>\ c\ + by (auto simp add: less_eq_less intro: trans) +qed + +lemma preordering_dualI: + fixes less_eq (infix \\<^bold>\\ 50) + and less (infix \\<^bold><\ 50) + assumes \preordering (\a b. b \<^bold>\ a) (\a b. b \<^bold>< a)\ + shows \preordering (\<^bold>\) (\<^bold><)\ +proof - + from assms interpret preordering \\a b. b \<^bold>\ a\ \\a b. b \<^bold>< a\ . + show ?thesis + by standard (auto simp: strict_iff_not refl intro: trans) +qed + +locale ordering = partial_preordering + + fixes less :: \'a \ 'a \ bool\ (infix \\<^bold><\ 50) + assumes strict_iff_order: \a \<^bold>< b \ a \<^bold>\ b \ a \ b\ + assumes antisym: \a \<^bold>\ b \ b \<^bold>\ a \ a = b\ +begin + +sublocale preordering \(\<^bold>\)\ \(\<^bold><)\ +proof + show \a \<^bold>< b \ a \<^bold>\ b \ \ b \<^bold>\ a\ for a b + by (auto simp add: strict_iff_order intro: antisym) +qed lemma strict_implies_not_eq: - "a \<^bold>< b \ a \ b" + \a \<^bold>< b \ a \ b\ by (simp add: strict_iff_order) lemma not_eq_order_implies_strict: - "a \ b \ a \<^bold>\ b \ a \<^bold>< b" + \a \ b \ a \<^bold>\ b \ a \<^bold>< b\ by (simp add: strict_iff_order) lemma order_iff_strict: - "a \<^bold>\ b \ a \<^bold>< b \ a = b" + \a \<^bold>\ b \ a \<^bold>< b \ a = b\ by (auto simp add: strict_iff_order refl) -lemma irrefl: \ \not \iff\: makes problems due to multiple (dual) interpretations\ - "\ a \<^bold>< a" - by (simp add: strict_iff_order) - -lemma asym: - "a \<^bold>< b \ b \<^bold>< a \ False" - by (auto simp add: strict_iff_order intro: antisym) - -lemma strict_trans1: - "a \<^bold>\ b \ b \<^bold>< c \ a \<^bold>< c" - by (auto simp add: strict_iff_order intro: trans antisym) - -lemma strict_trans2: - "a \<^bold>< b \ b \<^bold>\ c \ a \<^bold>< c" - by (auto simp add: strict_iff_order intro: trans antisym) - -lemma strict_trans: - "a \<^bold>< b \ b \<^bold>< c \ a \<^bold>< c" - by (auto intro: strict_trans1 strict_implies_order) - -lemma eq_iff: "a = b \ a \<^bold>\ b \ b \<^bold>\ a" +lemma eq_iff: \a = b \ a \<^bold>\ b \ b \<^bold>\ a\ by (auto simp add: refl intro: antisym) end -text \Alternative introduction rule with bias towards strict order\ - -lemma ordering_strictI: - fixes less_eq (infix "\<^bold>\" 50) - and less (infix "\<^bold><" 50) - assumes less_eq_less: "\a b. a \<^bold>\ b \ a \<^bold>< b \ a = b" - assumes asym: "\a b. a \<^bold>< b \ \ b \<^bold>< a" - assumes irrefl: "\a. \ a \<^bold>< a" - assumes trans: "\a b c. a \<^bold>< b \ b \<^bold>< c \ a \<^bold>< c" - shows "ordering less_eq less" +lemma ordering_strictI: \ \Alternative introduction rule with bias towards strict order\ + fixes less_eq (infix \\<^bold>\\ 50) + and less (infix \\<^bold><\ 50) + assumes less_eq_less: \\a b. a \<^bold>\ b \ a \<^bold>< b \ a = b\ + assumes asym: \\a b. a \<^bold>< b \ \ b \<^bold>< a\ + assumes irrefl: \\a. \ a \<^bold>< a\ + assumes trans: \\a b c. a \<^bold>< b \ b \<^bold>< c \ a \<^bold>< c\ + shows \ordering (\<^bold>\) (\<^bold><)\ proof fix a b - show "a \<^bold>< b \ a \<^bold>\ b \ a \ b" + show \a \<^bold>< b \ a \<^bold>\ b \ a \ b\ by (auto simp add: less_eq_less asym irrefl) next fix a - show "a \<^bold>\ a" + show \a \<^bold>\ a\ by (auto simp add: less_eq_less) next fix a b c - assume "a \<^bold>\ b" and "b \<^bold>\ c" then show "a \<^bold>\ c" + assume \a \<^bold>\ b\ and \b \<^bold>\ c\ then show \a \<^bold>\ c\ by (auto simp add: less_eq_less intro: trans) next fix a b - assume "a \<^bold>\ b" and "b \<^bold>\ a" then show "a = b" + assume \a \<^bold>\ b\ and \b \<^bold>\ a\ then show \a = b\ by (auto simp add: less_eq_less asym) qed lemma ordering_dualI: - fixes less_eq (infix "\<^bold>\" 50) - and less (infix "\<^bold><" 50) - assumes "ordering (\a b. b \<^bold>\ a) (\a b. b \<^bold>< a)" - shows "ordering less_eq less" + fixes less_eq (infix \\<^bold>\\ 50) + and less (infix \\<^bold><\ 50) + assumes \ordering (\a b. b \<^bold>\ a) (\a b. b \<^bold>< a)\ + shows \ordering (\<^bold>\) (\<^bold><)\ proof - - from assms interpret ordering "\a b. b \<^bold>\ a" "\a b. b \<^bold>< a" . + from assms interpret ordering \\a b. b \<^bold>\ a\ \\a b. b \<^bold>< a\ . show ?thesis by standard (auto simp: strict_iff_order refl intro: antisym trans) qed locale ordering_top = ordering + - fixes top :: "'a" ("\<^bold>\") - assumes extremum [simp]: "a \<^bold>\ \<^bold>\" + fixes top :: \'a\ (\\<^bold>\\) + assumes extremum [simp]: \a \<^bold>\ \<^bold>\\ begin lemma extremum_uniqueI: - "\<^bold>\ \<^bold>\ a \ a = \<^bold>\" + \\<^bold>\ \<^bold>\ a \ a = \<^bold>\\ by (rule antisym) auto lemma extremum_unique: - "\<^bold>\ \<^bold>\ a \ a = \<^bold>\" + \\<^bold>\ \<^bold>\ a \ a = \<^bold>\\ by (auto intro: antisym) lemma extremum_strict [simp]: - "\ (\<^bold>\ \<^bold>< a)" + \\ (\<^bold>\ \<^bold>< a)\ using extremum [of a] by (auto simp add: order_iff_strict intro: asym irrefl) lemma not_eq_extremum: - "a \ \<^bold>\ \ a \<^bold>< \<^bold>\" + \a \ \<^bold>\ \ a \<^bold>< \<^bold>\\ by (auto simp add: order_iff_strict intro: not_eq_order_implies_strict extremum) end @@ -165,6 +211,16 @@ and order_trans: "x \ y \ y \ z \ x \ z" begin +sublocale order: preordering less_eq less + dual_order: preordering greater_eq greater +proof - + interpret preordering less_eq less + by standard (auto intro: order_trans simp add: less_le_not_le) + show \preordering less_eq less\ + by (fact preordering_axioms) + then show \preordering greater_eq greater\ + by (rule preordering_dualI) +qed + text \Reflexivity.\ lemma eq_refl: "x = y \ x \ y" @@ -217,7 +273,7 @@ text \Dual order\ lemma dual_preorder: - "class.preorder (\) (>)" + \class.preorder (\) (>)\ by standard (auto simp add: less_le_not_le intro: order_trans) end