# HG changeset patch # User hoelzl # Date 1383683022 -3600 # Node ID b01057e722336083373264a4d38f4bf1ced47a49 # Parent 23c0049e7c409e342cc3f720cbde73ff9fef7302 int and nat are conditionally_complete_lattices diff -r 23c0049e7c40 -r b01057e72233 src/HOL/Archimedean_Field.thy --- a/src/HOL/Archimedean_Field.thy Wed Nov 06 14:50:50 2013 +0100 +++ b/src/HOL/Archimedean_Field.thy Tue Nov 05 21:23:42 2013 +0100 @@ -129,12 +129,8 @@ fix y z assume "of_int y \ x \ x < of_int (y + 1)" "of_int z \ x \ x < of_int (z + 1)" - then have - "of_int y \ x" "x < of_int (y + 1)" - "of_int z \ x" "x < of_int (z + 1)" - by simp_all - from le_less_trans [OF `of_int y \ x` `x < of_int (z + 1)`] - le_less_trans [OF `of_int z \ x` `x < of_int (y + 1)`] + with le_less_trans [of "of_int y" "x" "of_int (z + 1)"] + le_less_trans [of "of_int z" "x" "of_int (y + 1)"] show "y = z" by (simp del: of_int_add) qed diff -r 23c0049e7c40 -r b01057e72233 src/HOL/Conditionally_Complete_Lattices.thy --- a/src/HOL/Conditionally_Complete_Lattices.thy Wed Nov 06 14:50:50 2013 +0100 +++ b/src/HOL/Conditionally_Complete_Lattices.thy Tue Nov 05 21:23:42 2013 +0100 @@ -471,4 +471,92 @@ end +instantiation nat :: conditionally_complete_linorder +begin + +definition "Sup (X::nat set) = Max X" +definition "Inf (X::nat set) = (LEAST n. n \ X)" + +lemma bdd_above_nat: "bdd_above X \ finite (X::nat set)" +proof + assume "bdd_above X" + then obtain z where "X \ {.. z}" + by (auto simp: bdd_above_def) + then show "finite X" + by (rule finite_subset) simp +qed simp + +instance +proof + fix x :: nat and X :: "nat set" + { assume "x \ X" "bdd_below X" then show "Inf X \ x" + by (simp add: Inf_nat_def Least_le) } + { assume "X \ {}" "\y. y \ X \ x \ y" then show "x \ Inf X" + unfolding Inf_nat_def ex_in_conv[symmetric] by (rule LeastI2_ex) } + { assume "x \ X" "bdd_above X" then show "x \ Sup X" + by (simp add: Sup_nat_def bdd_above_nat) } + { assume "X \ {}" "\y. y \ X \ y \ x" + moreover then have "bdd_above X" + by (auto simp: bdd_above_def) + ultimately show "Sup X \ x" + by (simp add: Sup_nat_def bdd_above_nat) } +qed end + +instantiation int :: conditionally_complete_linorder +begin + +definition "Sup (X::int set) = (THE x. x \ X \ (\y\X. y \ x))" +definition "Inf (X::int set) = - (Sup (uminus ` X))" + +instance +proof + { fix x :: int and X :: "int set" assume "X \ {}" "bdd_above X" + then obtain x y where "X \ {..y}" "x \ X" + by (auto simp: bdd_above_def) + then have *: "finite (X \ {x..y})" "X \ {x..y} \ {}" and "x \ y" + by (auto simp: subset_eq) + have "\!x\X. (\y\X. y \ x)" + proof + { fix z assume "z \ X" + have "z \ Max (X \ {x..y})" + proof cases + assume "x \ z" with `z \ X` `X \ {..y}` *(1) show ?thesis + by (auto intro!: Max_ge) + next + assume "\ x \ z" + then have "z < x" by simp + also have "x \ Max (X \ {x..y})" + using `x \ X` *(1) `x \ y` by (intro Max_ge) auto + finally show ?thesis by simp + qed } + note le = this + with Max_in[OF *] show ex: "Max (X \ {x..y}) \ X \ (\z\X. z \ Max (X \ {x..y}))" by auto + + fix z assume *: "z \ X \ (\y\X. y \ z)" + with le have "z \ Max (X \ {x..y})" + by auto + moreover have "Max (X \ {x..y}) \ z" + using * ex by auto + ultimately show "z = Max (X \ {x..y})" + by auto + qed + then have "Sup X \ X \ (\y\X. y \ Sup X)" + unfolding Sup_int_def by (rule theI') } + note Sup_int = this + + { fix x :: int and X :: "int set" assume "x \ X" "bdd_above X" then show "x \ Sup X" + using Sup_int[of X] by auto } + note le_Sup = this + { fix x :: int and X :: "int set" assume "X \ {}" "\y. y \ X \ y \ x" then show "Sup X \ x" + using Sup_int[of X] by (auto simp: bdd_above_def) } + note Sup_le = this + + { fix x :: int and X :: "int set" assume "x \ X" "bdd_below X" then show "Inf X \ x" + using le_Sup[of "-x" "uminus ` X"] by (auto simp: Inf_int_def) } + { fix x :: int and X :: "int set" assume "X \ {}" "\y. y \ X \ x \ y" then show "x \ Inf X" + using Sup_le[of "uminus ` X" "-x"] by (force simp: Inf_int_def) } +qed +end + +end diff -r 23c0049e7c40 -r b01057e72233 src/HOL/Real.thy --- a/src/HOL/Real.thy Wed Nov 06 14:50:50 2013 +0100 +++ b/src/HOL/Real.thy Tue Nov 05 21:23:42 2013 +0100 @@ -924,11 +924,8 @@ subsection{*Supremum of a set of reals*} -definition - Sup_real_def: "Sup X \ LEAST z::real. \x\X. x\z" - -definition - Inf_real_def: "Inf (X::real set) \ - Sup (uminus ` X)" +definition "Sup X = (LEAST z::real. \x\X. x \ z)" +definition "Inf (X::real set) = - Sup (uminus ` X)" instance proof @@ -951,20 +948,10 @@ finally show "Sup X \ z" . } note Sup_least = this - { fix x z :: real and X :: "real set" - assume x: "x \ X" and [simp]: "bdd_below X" - have "-x \ Sup (uminus ` X)" - by (rule Sup_upper) (auto simp add: image_iff x) - then show "Inf X \ x" - by (auto simp add: Inf_real_def) } - - { fix z :: real and X :: "real set" - assume x: "X \ {}" and z: "\x. x \ X \ z \ x" - have "Sup (uminus ` X) \ -z" - using x z by (force intro: Sup_least) - then show "z \ Inf X" - by (auto simp add: Inf_real_def) } - + { fix x :: real and X :: "real set" assume x: "x \ X" "bdd_below X" then show "Inf X \ x" + using Sup_upper[of "-x" "uminus ` X"] by (auto simp: Inf_real_def) } + { fix z :: real and X :: "real set" assume "X \ {}" "\x. x \ X \ z \ x" then show "z \ Inf X" + using Sup_least[of "uminus ` X" "- z"] by (force simp: Inf_real_def) } show "\a b::real. a \ b" using zero_neq_one by blast qed