# HG changeset patch # User hoelzl # Date 1363945303 -3600 # Node ID ebf9d4fd00ba84ab425d9562f483beb94a29af5f # Parent 1e9e68247ad1af5d48bd35784d494e7d842770d9 introduct the conditional_complete_lattice type class; generalize theorems about real Sup and Inf to it diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Fri Mar 22 10:41:43 2013 +0100 @@ -3491,11 +3491,11 @@ apply(rule,rule) defer apply(rule) unfolding inner_minus_left and neg_less_iff_less proof- from ab have "((\x. inner a x) ` t) *<= (inner a y - b)" apply(erule_tac x=y in ballE) apply(rule setleI) using `y\s` by auto - hence k:"isLub UNIV ((\x. inner a x) ` t) k" unfolding k_def apply(rule_tac Sup) using assms(5) by auto + hence k:"isLub UNIV ((\x. inner a x) ` t) k" unfolding k_def apply(rule_tac isLub_cSup) using assms(5) by auto fix x assume "x\t" thus "inner a x < (k + b / 2)" using `0s" - hence "k \ inner a x - b" unfolding k_def apply(rule_tac Sup_least) using assms(5) + hence "k \ inner a x - b" unfolding k_def apply(rule_tac cSup_least) using assms(5) using ab[THEN bspec[where x=x]] by auto thus "k + b / 2 < inner a x" using `0 < b` by auto qed @@ -3544,9 +3544,9 @@ thus ?thesis apply(rule_tac x=a in exI, rule_tac x="Sup ((\x. inner a x) ` s)" in exI) using `a\0` apply auto - apply (rule Sup[THEN isLubD2]) + apply (rule isLub_cSup[THEN isLubD2]) prefer 4 - apply (rule Sup_least) + apply (rule cSup_least) using assms(3-5) apply (auto simp add: setle_def) apply metis done @@ -6208,7 +6208,7 @@ using interior_subset[of I] `x \ interior I` by auto have "Inf (?F x) \ (f x - f y) / (x - y)" - proof (rule Inf_lower2) + proof (rule cInf_lower2) show "(f x - f t) / (x - t) \ ?F x" using `t \ I` `x < t` by auto show "(f x - f t) / (x - t) \ (f x - f y) / (x - y)" @@ -6231,7 +6231,7 @@ with `x \ interior I` e interior_subset[of I] have "t \ I" "x \ I" by auto have "(f x - f y) / (x - y) \ Inf (?F x)" - proof (rule Inf_greatest) + proof (rule cInf_greatest) have "(f x - f y) / (x - y) = (f y - f x) / (y - x)" using `y < x` by (auto simp: field_simps) also diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy --- a/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Fri Mar 22 10:41:43 2013 +0100 @@ -523,7 +523,7 @@ proof - { assume "S ~= {}" { assume ex: "EX B. ALL x:S. B<=x" - then have *: "ALL x:S. Inf S <= x" using Inf_lower_EX[of _ S] ex by metis + then have *: "ALL x:S. Inf S <= x" using cInf_lower_EX[of _ S] ex by metis then have "Inf S : S" apply (subst closed_contains_Inf) using ex `S ~= {}` `closed S` by auto then have "ALL x. (Inf S <= x <-> x:S)" using mono[rule_format, of "Inf S"] * by auto then have "S = {Inf S ..}" by auto diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Multivariate_Analysis/Fashoda.thy --- a/src/HOL/Multivariate_Analysis/Fashoda.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Fashoda.thy Fri Mar 22 10:41:43 2013 +0100 @@ -18,7 +18,7 @@ subsection {*Fashoda meet theorem. *} lemma infnorm_2: "infnorm (x::real^2) = max (abs(x$1)) (abs(x$2))" - unfolding infnorm_cart UNIV_2 apply(rule Sup_eq) by auto + unfolding infnorm_cart UNIV_2 apply(rule cSup_eq) by auto lemma infnorm_eq_1_2: "infnorm (x::real^2) = 1 \ (abs(x$1) \ 1 \ abs(x$2) \ 1 \ (x$1 = -1 \ x$1 = 1 \ x$2 = -1 \ x$2 = 1))" diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Multivariate_Analysis/Integration.thy --- a/src/HOL/Multivariate_Analysis/Integration.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Integration.thy Fri Mar 22 10:41:43 2013 +0100 @@ -8,6 +8,45 @@ "~~/src/HOL/Library/Indicator_Function" begin +lemma cSup_finite_ge_iff: + fixes S :: "real set" + assumes fS: "finite S" and Se: "S \ {}" + shows "a \ Sup S \ (\ x \ S. a \ x)" +by (metis Max_ge Se cSup_eq_Max Max_in fS linorder_not_le less_le_trans) + +lemma cSup_finite_le_iff: + fixes S :: "real set" + assumes fS: "finite S" and Se: "S \ {}" + shows "a \ Sup S \ (\ x \ S. a \ x)" +by (metis Max_ge Se cSup_eq_Max Max_in fS order_trans) + +lemma Inf: (* rename *) + fixes S :: "real set" + shows "S \ {} ==> (\b. b <=* S) ==> isGlb UNIV S (Inf S)" +by (auto simp add: isLb_def setle_def setge_def isGlb_def greatestP_def intro: cInf_lower cInf_greatest) + +lemma real_le_inf_subset: + assumes "t \ {}" "t \ s" "\b. b <=* s" + shows "Inf s <= Inf (t::real set)" + apply (rule isGlb_le_isLb) + apply (rule Inf[OF assms(1)]) + apply (insert assms) + apply (erule exE) + apply (rule_tac x = b in exI) + apply (auto simp: isLb_def setge_def intro: cInf_lower cInf_greatest) + done + +lemma real_ge_sup_subset: + assumes "t \ {}" "t \ s" "\b. s *<= b" + shows "Sup s >= Sup (t::real set)" + apply (rule isLub_le_isUb) + apply (rule isLub_cSup[OF assms(1)]) + apply (insert assms) + apply (erule exE) + apply (rule_tac x = b in exI) + apply (auto simp: isUb_def setle_def intro: cSup_upper cSup_least) + done + (*declare not_less[simp] not_le[simp]*) lemmas scaleR_simps = scaleR_zero_left scaleR_minus_left scaleR_left_diff_distrib @@ -49,33 +88,6 @@ shows "bounded_linear f" unfolding bounded_linear_def additive_def bounded_linear_axioms_def using assms by auto -lemma Inf: (* rename *) - fixes S :: "real set" - shows "S \ {} ==> (\b. b <=* S) ==> isGlb UNIV S (Inf S)" -by (auto simp add: isLb_def setle_def setge_def isGlb_def greatestP_def) - -lemma real_le_inf_subset: - assumes "t \ {}" "t \ s" "\b. b <=* s" - shows "Inf s <= Inf (t::real set)" - apply (rule isGlb_le_isLb) - apply (rule Inf[OF assms(1)]) - apply (insert assms) - apply (erule exE) - apply (rule_tac x = b in exI) - apply (auto simp: isLb_def setge_def) - done - -lemma real_ge_sup_subset: - assumes "t \ {}" "t \ s" "\b. s *<= b" - shows "Sup s >= Sup (t::real set)" - apply (rule isLub_le_isUb) - apply (rule Sup[OF assms(1)]) - apply (insert assms) - apply (erule exE) - apply (rule_tac x = b in exI) - apply (auto simp: isUb_def setle_def) - done - lemma bounded_linear_component [intro]: "bounded_linear (\x::'a::euclidean_space. x \ k)" by (rule bounded_linear_inner_left) @@ -387,14 +399,14 @@ interval_upperbound {a..b} = (b::'a::ordered_euclidean_space)" unfolding interval_upperbound_def euclidean_representation_setsum by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setle_def - intro!: Sup_unique) + intro!: cSup_unique) lemma interval_lowerbound[simp]: "\i\Basis. a\i \ b\i \ interval_lowerbound {a..b} = (a::'a::ordered_euclidean_space)" unfolding interval_lowerbound_def euclidean_representation_setsum by (auto simp del: ex_simps simp add: Bex_def ex_simps[symmetric] eucl_le[where 'a='a] setge_def - intro!: Inf_unique) + intro!: cInf_unique) lemmas interval_bounds = interval_upperbound interval_lowerbound @@ -3201,7 +3213,7 @@ let ?goal = "norm ((\(x, k)\p. content k *\<^sub>R f x) - 0) < e" { presume "p\{} \ ?goal" thus ?goal apply(cases "p={}") using goal1 by auto } assume as':"p \ {}" from real_arch_simple[of "Sup((\(x,k). norm(f x)) ` p)"] guess N .. - hence N:"\x\(\(x, k). norm (f x)) ` p. x \ real N" apply(subst(asm) Sup_finite_le_iff) using as as' by auto + hence N:"\x\(\(x, k). norm (f x)) ` p. x \ real N" apply(subst(asm) cSup_finite_le_iff) using as as' by auto have "\i. \q. q tagged_division_of {a..b} \ (d i) fine q \ (\(x, k)\p. k \ (d i) x \ (x, k) \ q)" apply(rule,rule tagged_division_finer[OF as(1) d(1)]) by auto from choice[OF this] guess q .. note q=conjunctD3[OF this[rule_format]] @@ -5480,7 +5492,7 @@ "\d. d division_of {a..b} \ setsum (\k. norm(integral k f)) d \ B" shows "f absolutely_integrable_on {a..b}" proof- let ?S = "(\d. setsum (\k. norm(integral k f)) d) ` {d. d division_of {a..b} }" def i \ "Sup ?S" - have i:"isLub UNIV ?S i" unfolding i_def apply(rule Sup) + have i:"isLub UNIV ?S i" unfolding i_def apply(rule isLub_cSup) apply(rule elementary_interval) defer apply(rule_tac x=B in exI) apply(rule setleI) using assms(2) by auto show ?thesis apply(rule,rule assms) apply rule apply(subst has_integral[of _ i]) @@ -5693,7 +5705,7 @@ shows "f absolutely_integrable_on UNIV" proof(rule absolutely_integrable_onI,fact,rule) let ?S = "(\d. setsum (\k. norm(integral k f)) d) ` {d. d division_of (\d)}" def i \ "Sup ?S" - have i:"isLub UNIV ?S i" unfolding i_def apply(rule Sup) + have i:"isLub UNIV ?S i" unfolding i_def apply(rule isLub_cSup) apply(rule elementary_interval) defer apply(rule_tac x=B in exI) apply(rule setleI) using assms(2) by auto have f_int:"\a b. f absolutely_integrable_on {a..b}" @@ -6044,7 +6056,7 @@ prefer 5 unfolding real_norm_def apply rule - apply (rule Inf_abs_ge) + apply (rule cInf_abs_ge) prefer 5 apply rule apply (rule_tac g = h in absolutely_integrable_integrable_bound_real) @@ -6065,11 +6077,11 @@ fix x assume x: "x \ s" show "Inf {f j x |j. j \ {m..m + Suc k}} \ Inf {f j x |j. j \ {m..m + k}}" - apply (rule Inf_ge) + apply (rule cInf_ge) unfolding setge_def defer apply rule - apply (subst Inf_finite_le_iff) + apply (subst cInf_finite_le_iff) prefer 3 apply (rule_tac x=xa in bexI) apply auto @@ -6119,7 +6131,7 @@ prefer 3 apply (rule,rule isGlbD1[OF i]) prefer 3 - apply (subst Inf_finite_le_iff) + apply (subst cInf_finite_le_iff) prefer 3 apply (rule_tac x=y in bexI) using N goal1 @@ -6146,7 +6158,7 @@ apply(rule absolutely_integrable_sup_real) prefer 5 unfolding real_norm_def apply rule - apply (rule Sup_abs_le) + apply (rule cSup_abs_le) prefer 5 apply rule apply (rule_tac g=h in absolutely_integrable_integrable_bound_real) @@ -6167,11 +6179,11 @@ fix x assume x: "x\s" show "Sup {f j x |j. j \ {m..m + Suc k}} \ Sup {f j x |j. j \ {m..m + k}}" - apply (rule Sup_le) + apply (rule cSup_le) unfolding setle_def defer apply rule - apply (subst Sup_finite_ge_iff) + apply (subst cSup_finite_ge_iff) prefer 3 apply (rule_tac x=y in bexI) apply auto @@ -6183,7 +6195,7 @@ case goal1 note r=this have i: "isLub UNIV ?S i" unfolding i_def - apply (rule Sup) + apply (rule isLub_cSup) defer apply (rule_tac x="h x" in exI) unfolding setle_def @@ -6221,7 +6233,7 @@ prefer 3 apply (rule, rule isLubD1[OF i]) prefer 3 - apply (subst Sup_finite_ge_iff) + apply (subst cSup_finite_ge_iff) prefer 3 apply (rule_tac x = y in bexI) using N goal1 @@ -6246,7 +6258,7 @@ apply fact+ unfolding real_norm_def apply rule - apply (rule Inf_abs_ge) + apply (rule cInf_abs_ge) using assms(3) apply auto done @@ -6276,7 +6288,7 @@ apply (rule_tac x=N in exI,safe) unfolding real_norm_def apply (rule le_less_trans[of _ "r/2"]) - apply (rule Inf_asclose) + apply (rule cInf_asclose) apply safe defer apply (rule less_imp_le) @@ -6302,7 +6314,7 @@ apply fact+ unfolding real_norm_def apply rule - apply (rule Sup_abs_le) + apply (rule cSup_abs_le) using assms(3) apply auto done @@ -6330,7 +6342,7 @@ apply (rule_tac x=N in exI,safe) unfolding real_norm_def apply (rule le_less_trans[of _ "r/2"]) - apply (rule Sup_asclose) + apply (rule cSup_asclose) apply safe defer apply (rule less_imp_le) @@ -6364,7 +6376,7 @@ assume x: "x \ s" have *: "\x y::real. x \ - y \ - x \ y" by auto show "Inf {f j x |j. n \ j} \ f n x" - apply (rule Inf_lower[where z="- h x"]) + apply (rule cInf_lower[where z="- h x"]) defer apply (rule *) using assms(3)[rule_format,OF x] @@ -6377,7 +6389,7 @@ fix x assume x: "x \ s" show "f n x \ Sup {f j x |j. n \ j}" - apply (rule Sup_upper[where z="h x"]) + apply (rule cSup_upper[where z="h x"]) defer using assms(3)[rule_format,OF x] unfolding real_norm_def abs_le_iff diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Multivariate_Analysis/Linear_Algebra.thy --- a/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Mar 22 10:41:43 2013 +0100 @@ -2498,6 +2498,9 @@ "{ abs ((x::'a::euclidean_space) \ i) |i. i \ Basis} = (\i. abs(x \ i)) ` Basis" by blast +lemma infnorm_Max: "infnorm (x::'a::euclidean_space) = Max ((\i. abs(x \ i)) ` Basis)" + by (simp add: infnorm_def infnorm_set_image cSup_eq_Max) + lemma infnorm_set_lemma: shows "finite {abs((x::'a::euclidean_space) \ i) |i. i \ Basis}" and "{abs(x \ i) |i. i \ Basis} \ {}" @@ -2505,41 +2508,22 @@ by auto lemma infnorm_pos_le: "0 \ infnorm (x::'a::euclidean_space)" - unfolding infnorm_def - unfolding Sup_finite_ge_iff[ OF infnorm_set_lemma] - unfolding infnorm_set_image - by (auto simp: ex_in_conv) + by (simp add: infnorm_Max Max_ge_iff ex_in_conv) lemma infnorm_triangle: "infnorm ((x::'a::euclidean_space) + y) \ infnorm x + infnorm y" proof - - have th: "\x y (z::real). x - y <= z \ x - z <= y" by arith - have th1: "\S f. f ` S = { f i| i. i \ S}" by blast - have th2: "\x (y::real). abs(x + y) - abs(x) <= abs(y)" by arith + have *: "\a b c d :: real. \a\ \ c \ \b\ \ d \ \a + b\ \ c + d" + by simp show ?thesis - unfolding infnorm_def - unfolding Sup_finite_le_iff[ OF infnorm_set_lemma[where 'a='a]] - apply (subst diff_le_eq[symmetric]) - unfolding Sup_finite_ge_iff[ OF infnorm_set_lemma] - unfolding infnorm_set_image bex_simps - apply (subst th) - unfolding th1 - unfolding Sup_finite_ge_iff[ OF infnorm_set_lemma[where 'a='a]] - unfolding infnorm_set_image ball_simps bex_simps - apply (simp add: inner_add_left) - apply (metis th2) - done + by (auto simp: infnorm_Max inner_add_left intro!: *) qed lemma infnorm_eq_0: "infnorm x = 0 \ (x::_::euclidean_space) = 0" proof - - have "infnorm x <= 0 \ x = 0" - unfolding infnorm_def - unfolding Sup_finite_le_iff[OF infnorm_set_lemma] - unfolding infnorm_set_image ball_simps - apply (subst (1) euclidean_eq_iff) - apply auto - done - then show ?thesis using infnorm_pos_le[of x] by simp + have "infnorm x \ 0 \ x = 0" + unfolding infnorm_Max by (simp add: euclidean_all_zero_iff) + then show ?thesis + using infnorm_pos_le[of x] by simp qed lemma infnorm_0: "infnorm 0 = 0" @@ -2573,40 +2557,24 @@ using infnorm_pos_le[of x] by arith lemma Basis_le_infnorm: - assumes b: "b \ Basis" shows "\x \ b\ \ infnorm (x::'a::euclidean_space)" - unfolding infnorm_def -proof (subst Sup_finite_ge_iff) - let ?S = "{\x \ i\ |i. i \ Basis}" - show "finite ?S" by (rule infnorm_set_lemma) - show "?S \ {}" by auto - show "Bex ?S (op \ \x \ b\)" - using b by (auto intro!: exI[of _ b]) -qed - -lemma infnorm_mul_lemma: "infnorm(a *\<^sub>R x) <= \a\ * infnorm x" - apply (subst infnorm_def) - unfolding Sup_finite_le_iff[OF infnorm_set_lemma] - unfolding infnorm_set_image ball_simps inner_scaleR abs_mult - using Basis_le_infnorm[of _ x] - apply (auto intro: mult_mono) - done + "b \ Basis \ \x \ b\ \ infnorm (x::'a::euclidean_space)" + by (simp add: infnorm_Max) lemma infnorm_mul: "infnorm(a *\<^sub>R x) = abs a * infnorm x" -proof - - { assume a0: "a = 0" then have ?thesis by (simp add: infnorm_0) } - moreover - { assume a0: "a \ 0" - from a0 have th: "(1/a) *\<^sub>R (a *\<^sub>R x) = x" by simp - from a0 have ap: "\a\ > 0" by arith - from infnorm_mul_lemma[of "1/a" "a *\<^sub>R x"] - have "infnorm x \ 1/\a\ * infnorm (a*\<^sub>R x)" - unfolding th by simp - with ap have "\a\ * infnorm x \ \a\ * (1/\a\ * infnorm (a *\<^sub>R x))" by (simp add: field_simps) - then have "\a\ * infnorm x \ infnorm (a*\<^sub>R x)" - using ap by (simp add: field_simps) - with infnorm_mul_lemma[of a x] have ?thesis by arith } - ultimately show ?thesis by blast -qed + unfolding infnorm_Max +proof (safe intro!: Max_eqI) + let ?B = "(\i. \x \ i\) ` Basis" + show "\b :: 'a. b \ Basis \ \a *\<^sub>R x \ b\ \ \a\ * Max ?B" + by (simp add: abs_mult mult_left_mono) + + from Max_in[of ?B] obtain b where "b \ Basis" "Max ?B = \x \ b\" + by (auto simp del: Max_in) + then show "\a\ * Max ((\i. \x \ i\) ` Basis) \ (\i. \a *\<^sub>R x \ i\) ` Basis" + by (intro image_eqI[where x=b]) (auto simp: abs_mult) +qed simp + +lemma infnorm_mul_lemma: "infnorm(a *\<^sub>R x) \ \a\ * infnorm x" + unfolding infnorm_mul .. lemma infnorm_pos_lt: "infnorm x > 0 \ x \ 0" using infnorm_pos_le[of x] infnorm_eq_0[of x] by arith @@ -2614,15 +2582,13 @@ text {* Prove that it differs only up to a bound from Euclidean norm. *} lemma infnorm_le_norm: "infnorm x \ norm x" - unfolding infnorm_def Sup_finite_le_iff[OF infnorm_set_lemma] - unfolding infnorm_set_image ball_simps - by (metis Basis_le_norm) + by (simp add: Basis_le_norm infnorm_Max) lemma euclidean_inner: "inner x y = (\b\Basis. (x \ b) * (y \ b))" by (subst (1 2) euclidean_representation[symmetric, where 'a='a]) (simp add: inner_setsum_left inner_setsum_right setsum_cases inner_Basis ac_simps if_distrib) -lemma norm_le_infnorm: "norm(x) <= sqrt DIM('a) * infnorm(x::'a::euclidean_space)" +lemma norm_le_infnorm: "norm x \ sqrt DIM('a) * infnorm(x::'a::euclidean_space)" proof - let ?d = "DIM('a)" have "real ?d \ 0" by simp @@ -2639,10 +2605,7 @@ apply (auto simp add: power2_eq_square[symmetric]) apply (subst power2_abs[symmetric]) apply (rule power_mono) - unfolding infnorm_def Sup_finite_ge_iff[OF infnorm_set_lemma] - unfolding infnorm_set_image bex_simps - apply (rule_tac x=i in bexI) - apply auto + apply (auto simp: infnorm_Max) done from real_le_lsqrt[OF inner_ge_zero th th1] show ?thesis unfolding norm_eq_sqrt_inner id_def . diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Multivariate_Analysis/Operator_Norm.thy --- a/src/HOL/Multivariate_Analysis/Operator_Norm.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Operator_Norm.thy Fri Mar 22 10:41:43 2013 +0100 @@ -58,7 +58,7 @@ hence Se: "?S \ {}" by auto from linear_bounded[OF lf] have b: "\ b. ?S *<= b" unfolding norm_bound_generalize[OF lf, symmetric] by (auto simp add: setle_def) - {from Sup[OF Se b, unfolded onorm_def[symmetric]] + { from isLub_cSup[OF Se b, unfolded onorm_def[symmetric]] show "norm (f x) <= onorm f * norm x" apply - apply (rule spec[where x = x]) @@ -66,7 +66,7 @@ by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)} { show "\x. norm (f x) <= b * norm x \ onorm f <= b" - using Sup[OF Se b, unfolded onorm_def[symmetric]] + using isLub_cSup[OF Se b, unfolded onorm_def[symmetric]] unfolding norm_bound_generalize[OF lf, symmetric] by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)} } @@ -93,7 +93,7 @@ by (auto simp: SOME_Basis intro!: exI[of _ "SOME i. i \ Basis"]) show ?thesis unfolding onorm_def th - apply (rule Sup_unique) by (simp_all add: setle_def) + apply (rule cSup_unique) by (simp_all add: setle_def) qed lemma onorm_pos_lt: assumes lf: "linear (f::'a::euclidean_space \ 'b::euclidean_space)" diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Fri Mar 22 10:41:43 2013 +0100 @@ -1401,7 +1401,7 @@ show "(\n. f (S n)) ----> Inf (f ` ({x<..} \ I))" proof (rule LIMSEQ_I, rule ccontr) fix r :: real assume "0 < r" - with Inf_close[of "f ` ({x<..} \ I)" r] + with cInf_close[of "f ` ({x<..} \ I)" r] obtain y where y: "x < y" "y \ I" "f y < Inf (f ` ({x <..} \ I)) + r" by auto from `x < y` have "0 < y - x" by auto from S(2)[THEN LIMSEQ_D, OF this] @@ -1409,7 +1409,7 @@ assume "\ (\N. \n\N. norm (f (S n) - Inf (f ` ({x<..} \ I))) < r)" moreover have "\n. Inf (f ` ({x<..} \ I)) \ f (S n)" - using S bnd by (intro Inf_lower[where z=K]) auto + using S bnd by (intro cInf_lower[where z=K]) auto ultimately obtain n where n: "N \ n" "r + Inf (f ` ({x<..} \ I)) \ f (S n)" by (auto simp: not_less field_simps) with N[OF n(1)] mono[OF _ `y \ I`, of "S n"] S(1)[THEN spec, of n] y @@ -1727,11 +1727,11 @@ unfolding closure_approachable proof safe have *: "\x\S. Inf S \ x" - using Inf_lower_EX[of _ S] assms by metis + using cInf_lower_EX[of _ S] assms by metis fix e :: real assume "0 < e" then obtain x where x: "x \ S" "x < Inf S + e" - using Inf_close `S \ {}` by auto + using cInf_close `S \ {}` by auto moreover then have "x > Inf S - e" using * by auto ultimately have "abs (x - Inf S) < e" by (simp add: abs_diff_less_iff) then show "\x\S. dist x (Inf S) < e" @@ -1785,13 +1785,13 @@ lemma infdist_nonneg: shows "0 \ infdist x A" - using assms by (auto simp add: infdist_def) + using assms by (auto simp add: infdist_def intro: cInf_greatest) lemma infdist_le: assumes "a \ A" assumes "d = dist x a" shows "infdist x A \ d" - using assms by (auto intro!: SupInf.Inf_lower[where z=0] simp add: infdist_def) + using assms by (auto intro!: cInf_lower[where z=0] simp add: infdist_def) lemma infdist_zero[simp]: assumes "a \ A" shows "infdist a A = 0" @@ -1807,13 +1807,13 @@ next assume "A \ {}" then obtain a where "a \ A" by auto have "infdist x A \ Inf {dist x y + dist y a |a. a \ A}" - proof + proof (rule cInf_greatest) from `A \ {}` show "{dist x y + dist y a |a. a \ A} \ {}" by simp fix d assume "d \ {dist x y + dist y a |a. a \ A}" then obtain a where d: "d = dist x y + dist y a" "a \ A" by auto show "infdist x A \ d" unfolding infdist_notempty[OF `A \ {}`] - proof (rule Inf_lower2) + proof (rule cInf_lower2) show "dist x a \ {dist x a |a. a \ A}" using `a \ A` by auto show "dist x a \ d" unfolding d by (rule dist_triangle) fix d assume "d \ {dist x a |a. a \ A}" @@ -1822,20 +1822,19 @@ qed qed also have "\ = dist x y + infdist y A" - proof (rule Inf_eq, safe) + proof (rule cInf_eq, safe) fix a assume "a \ A" thus "dist x y + infdist y A \ dist x y + dist y a" by (auto intro: infdist_le) next fix i assume inf: "\d. d \ {dist x y + dist y a |a. a \ A} \ i \ d" hence "i - dist x y \ infdist y A" unfolding infdist_notempty[OF `A \ {}`] using `a \ A` - by (intro Inf_greatest) (auto simp: field_simps) + by (intro cInf_greatest) (auto simp: field_simps) thus "i \ dist x y + infdist y A" by simp qed finally show ?thesis by simp qed -lemma - in_closure_iff_infdist_zero: +lemma in_closure_iff_infdist_zero: assumes "A \ {}" shows "x \ closure A \ infdist x A = 0" proof @@ -1859,13 +1858,12 @@ assume "\ (\y\A. dist y x < e)" hence "infdist x A \ e" using `a \ A` unfolding infdist_def - by (force simp: dist_commute) + by (force simp: dist_commute intro: cInf_greatest) with x `0 < e` show False by auto qed qed -lemma - in_closed_iff_infdist_zero: +lemma in_closed_iff_infdist_zero: assumes "closed A" "A \ {}" shows "x \ A \ infdist x A = 0" proof - @@ -2326,16 +2324,19 @@ proof fix x assume "x\S" thus "x \ Sup S" - by (metis SupInf.Sup_upper abs_le_D1 assms(1) bounded_real) + by (metis cSup_upper abs_le_D1 assms(1) bounded_real) next show "\b. (\x\S. x \ b) \ Sup S \ b" using assms - by (metis SupInf.Sup_least) + by (metis cSup_least) qed lemma Sup_insert: fixes S :: "real set" shows "bounded S ==> Sup(insert x S) = (if S = {} then x else max x (Sup S))" -by auto (metis Int_absorb Sup_insert_nonempty assms bounded_has_Sup(1) disjoint_iff_not_equal) + apply (subst cSup_insert_If) + apply (rule bounded_has_Sup(1)[of S, rule_format]) + apply (auto simp: sup_max) + done lemma Sup_insert_finite: fixes S :: "real set" @@ -2352,16 +2353,19 @@ fix x assume "x\S" from assms(1) obtain a where a:"\x\S. \x\ \ a" unfolding bounded_real by auto thus "x \ Inf S" using `x\S` - by (metis Inf_lower_EX abs_le_D2 minus_le_iff) + by (metis cInf_lower_EX abs_le_D2 minus_le_iff) next show "\b. (\x\S. x >= b) \ Inf S \ b" using assms - by (metis SupInf.Inf_greatest) + by (metis cInf_greatest) qed lemma Inf_insert: fixes S :: "real set" shows "bounded S ==> Inf(insert x S) = (if S = {} then x else min x (Inf S))" -by auto (metis Int_absorb Inf_insert_nonempty bounded_has_Inf(1) disjoint_iff_not_equal) + apply (subst cInf_insert_if) + apply (rule bounded_has_Inf(1)[of S, rule_format]) + apply (auto simp: inf_min) + done lemma Inf_insert_finite: fixes S :: "real set" @@ -3125,7 +3129,7 @@ lemma cauchy_def: "Cauchy s \ (\e>0. \N. \m n. m \ N \ n \ N --> dist(s m)(s n) < e)" -unfolding Cauchy_def by blast +unfolding Cauchy_def by metis fun helper_1::"('a::metric_space set) \ real \ nat \ 'a" where "helper_1 s e n = (SOME y::'a. y \ s \ (\m (dist (helper_1 s e m) y < e)))" @@ -5197,7 +5201,7 @@ from s obtain z d where z: "\x. x \ s \ dist z x \ d" unfolding bounded_def by auto have "dist x y \ Sup ?D" - proof (rule Sup_upper, safe) + proof (rule cSup_upper, safe) fix a b assume "a \ s" "b \ s" with z[of a] z[of b] dist_triangle[of a b z] show "dist a b \ 2 * d" @@ -5219,7 +5223,7 @@ by (auto simp: diameter_def) then have "?D \ {}" by auto ultimately have "Sup ?D \ d" - by (intro Sup_least) (auto simp: not_less) + by (intro cSup_least) (auto simp: not_less) with `d < diameter s` `s \ {}` show False by (auto simp: diameter_def) qed @@ -5239,7 +5243,7 @@ then obtain x y where xys:"x\s" "y\s" and xy:"\u\s. \v\s. dist u v \ dist x y" using compact_sup_maxdistance[OF assms] by auto hence "diameter s \ dist x y" - unfolding diameter_def by clarsimp (rule Sup_least, fast+) + unfolding diameter_def by clarsimp (rule cSup_least, fast+) thus ?thesis by (metis b diameter_bounded_bound order_antisym xys) qed @@ -6675,5 +6679,4 @@ declare tendsto_const [intro] (* FIXME: move *) - end diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/Probability/Probability_Measure.thy --- a/src/HOL/Probability/Probability_Measure.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/Probability/Probability_Measure.thy Fri Mar 22 10:41:43 2013 +0100 @@ -159,11 +159,11 @@ moreover { fix y assume y: "y \ I" with q(2) `open I` have "Sup ((\x. q x + ?F x * (y - x)) ` I) = q y" - by (auto intro!: Sup_eq_maximum convex_le_Inf_differential image_eqI[OF _ y] simp: interior_open) } + by (auto intro!: cSup_eq_maximum convex_le_Inf_differential image_eqI[OF _ y] simp: interior_open) } ultimately have "q (expectation X) = Sup ((\x. q x + ?F x * (expectation X - x)) ` I)" by simp also have "\ \ expectation (\w. q (X w))" - proof (rule Sup_least) + proof (rule cSup_least) show "(\x. q x + ?F x * (expectation X - x)) ` I \ {}" using `I \ {}` by auto next diff -r 1e9e68247ad1 -r ebf9d4fd00ba src/HOL/SupInf.thy --- a/src/HOL/SupInf.thy Fri Mar 22 10:41:43 2013 +0100 +++ b/src/HOL/SupInf.thy Fri Mar 22 10:41:43 2013 +0100 @@ -6,210 +6,341 @@ imports RComplete begin -instantiation real :: Sup +lemma Sup_fin_eq_Max: "finite X \ X \ {} \ Sup_fin X = Max X" + by (induct X rule: finite_ne_induct) (simp_all add: sup_max) + +lemma Inf_fin_eq_Min: "finite X \ X \ {} \ Inf_fin X = Min X" + by (induct X rule: finite_ne_induct) (simp_all add: inf_min) + +text {* + +To avoid name classes with the @{class complete_lattice}-class we prefix @{const Sup} and +@{const Inf} in theorem names with c. + +*} + +class conditional_complete_lattice = lattice + Sup + Inf + + assumes cInf_lower: "x \ X \ (\a. a \ X \ z \ a) \ Inf X \ x" + and cInf_greatest: "X \ {} \ (\x. x \ X \ z \ x) \ z \ Inf X" + assumes cSup_upper: "x \ X \ (\a. a \ X \ a \ z) \ x \ Sup X" + and cSup_least: "X \ {} \ (\x. x \ X \ x \ z) \ Sup X \ z" begin -definition - Sup_real_def: "Sup X == (LEAST z::real. \x\X. x\z)" + +lemma cSup_eq_maximum: (*REAL_SUP_MAX in HOL4*) + "z \ X \ (\x. x \ X \ x \ z) \ Sup X = z" + by (blast intro: antisym cSup_upper cSup_least) + +lemma cInf_eq_minimum: (*REAL_INF_MIN in HOL4*) + "z \ X \ (\x. x \ X \ z \ x) \ Inf X = z" + by (intro antisym cInf_lower[of z X z] cInf_greatest[of X z]) auto + +lemma cSup_le_iff: "S \ {} \ (\a. a \ S \ a \ z) \ Sup S \ a \ (\x\S. x \ a)" + by (metis order_trans cSup_upper cSup_least) + +lemma le_cInf_iff: "S \ {} \ (\a. a \ S \ z \ a) \ a \ Inf S \ (\x\S. a \ x)" + by (metis order_trans cInf_lower cInf_greatest) + +lemma cSup_singleton [simp]: "Sup {x} = x" + by (intro cSup_eq_maximum) auto + +lemma cInf_singleton [simp]: "Inf {x} = x" + by (intro cInf_eq_minimum) auto + +lemma cSup_upper2: (*REAL_IMP_LE_SUP in HOL4*) + "x \ X \ y \ x \ (\x. x \ X \ x \ z) \ y \ Sup X" + by (metis cSup_upper order_trans) + +lemma cInf_lower2: + "x \ X \ x \ y \ (\x. x \ X \ z \ x) \ Inf X \ y" + by (metis cInf_lower order_trans) + +lemma cSup_upper_EX: "x \ X \ \z. \x. x \ X \ x \ z \ x \ Sup X" + by (blast intro: cSup_upper) + +lemma cInf_lower_EX: "x \ X \ \z. \x. x \ X \ z \ x \ Inf X \ x" + by (blast intro: cInf_lower) + +lemma cSup_eq_non_empty: + assumes 1: "X \ {}" + assumes 2: "\x. x \ X \ x \ a" + assumes 3: "\y. (\x. x \ X \ x \ y) \ a \ y" + shows "Sup X = a" + by (intro 3 1 antisym cSup_least) (auto intro: 2 1 cSup_upper) + +lemma cInf_eq_non_empty: + assumes 1: "X \ {}" + assumes 2: "\x. x \ X \ a \ x" + assumes 3: "\y. (\x. x \ X \ y \ x) \ y \ a" + shows "Inf X = a" + by (intro 3 1 antisym cInf_greatest) (auto intro: 2 1 cInf_lower) + +lemma cSup_insert: + assumes x: "X \ {}" + and z: "\x. x \ X \ x \ z" + shows "Sup (insert a X) = sup a (Sup X)" +proof (intro cSup_eq_non_empty) + fix y assume "\x. x \ insert a X \ x \ y" with x show "sup a (Sup X) \ y" by (auto intro: cSup_least) +qed (auto intro: le_supI2 z cSup_upper) -instance .. +lemma cInf_insert: + assumes x: "X \ {}" + and z: "\x. x \ X \ z \ x" + shows "Inf (insert a X) = inf a (Inf X)" +proof (intro cInf_eq_non_empty) + fix y assume "\x. x \ insert a X \ y \ x" with x show "y \ inf a (Inf X)" by (auto intro: cInf_greatest) +qed (auto intro: le_infI2 z cInf_lower) + +lemma cSup_insert_If: + "(\x. x \ X \ x \ z) \ Sup (insert a X) = (if X = {} then a else sup a (Sup X))" + using cSup_insert[of X z] by simp + +lemma cInf_insert_if: + "(\x. x \ X \ z \ x) \ Inf (insert a X) = (if X = {} then a else inf a (Inf X))" + using cInf_insert[of X z] by simp + +lemma le_cSup_finite: "finite X \ x \ X \ x \ Sup X" +proof (induct X arbitrary: x rule: finite_induct) + case (insert x X y) then show ?case + apply (cases "X = {}") + apply simp + apply (subst cSup_insert[of _ "Sup X"]) + apply (auto intro: le_supI2) + done +qed simp + +lemma cInf_le_finite: "finite X \ x \ X \ Inf X \ x" +proof (induct X arbitrary: x rule: finite_induct) + case (insert x X y) then show ?case + apply (cases "X = {}") + apply simp + apply (subst cInf_insert[of _ "Inf X"]) + apply (auto intro: le_infI2) + done +qed simp + +lemma cSup_eq_Sup_fin: "finite X \ X \ {} \ Sup X = Sup_fin X" +proof (induct X rule: finite_ne_induct) + case (insert x X) then show ?case + using cSup_insert[of X "Sup_fin X" x] le_cSup_finite[of X] by simp +qed simp + +lemma cInf_eq_Inf_fin: "finite X \ X \ {} \ Inf X = Inf_fin X" +proof (induct X rule: finite_ne_induct) + case (insert x X) then show ?case + using cInf_insert[of X "Inf_fin X" x] cInf_le_finite[of X] by simp +qed simp + +lemma cSup_atMost[simp]: "Sup {..x} = x" + by (auto intro!: cSup_eq_maximum) + +lemma cSup_greaterThanAtMost[simp]: "y < x \ Sup {y<..x} = x" + by (auto intro!: cSup_eq_maximum) + +lemma cSup_atLeastAtMost[simp]: "y \ x \ Sup {y..x} = x" + by (auto intro!: cSup_eq_maximum) + +lemma cInf_atLeast[simp]: "Inf {x..} = x" + by (auto intro!: cInf_eq_minimum) + +lemma cInf_atLeastLessThan[simp]: "y < x \ Inf {y.. x \ Inf {y..x} = y" + by (auto intro!: cInf_eq_minimum) + end -instantiation real :: Inf +instance complete_lattice \ conditional_complete_lattice + by default (auto intro: Sup_upper Sup_least Inf_lower Inf_greatest) + +lemma isLub_cSup: + "(S::'a :: conditional_complete_lattice set) \ {} \ (\b. S *<= b) \ isLub UNIV S (Sup S)" + by (auto simp add: isLub_def setle_def leastP_def isUb_def + intro!: setgeI intro: cSup_upper cSup_least) + +lemma cSup_eq: + fixes a :: "'a :: {conditional_complete_lattice, no_bot}" + assumes upper: "\x. x \ X \ x \ a" + assumes least: "\y. (\x. x \ X \ x \ y) \ a \ y" + shows "Sup X = a" +proof cases + assume "X = {}" with lt_ex[of a] least show ?thesis by (auto simp: less_le_not_le) +qed (intro cSup_eq_non_empty assms) + +lemma cInf_eq: + fixes a :: "'a :: {conditional_complete_lattice, no_top}" + assumes upper: "\x. x \ X \ a \ x" + assumes least: "\y. (\x. x \ X \ y \ x) \ y \ a" + shows "Inf X = a" +proof cases + assume "X = {}" with gt_ex[of a] least show ?thesis by (auto simp: less_le_not_le) +qed (intro cInf_eq_non_empty assms) + +lemma cSup_le: "(S::'a::conditional_complete_lattice set) \ {} \ S *<= b \ Sup S \ b" + by (metis cSup_least setle_def) + +lemma cInf_ge: "(S::'a :: conditional_complete_lattice set) \ {} \ b <=* S \ Inf S \ b" + by (metis cInf_greatest setge_def) + +class conditional_complete_linorder = conditional_complete_lattice + linorder begin + +lemma less_cSup_iff : (*REAL_SUP_LE in HOL4*) + "X \ {} \ (\x. x \ X \ x \ z) \ y < Sup X \ (\x\X. y < x)" + by (rule iffI) (metis cSup_least not_less, metis cSup_upper less_le_trans) + +lemma cInf_less_iff: "X \ {} \ (\x. x \ X \ z \ x) \ Inf X < y \ (\x\X. x < y)" + by (rule iffI) (metis cInf_greatest not_less, metis cInf_lower le_less_trans) + +lemma less_cSupE: + assumes "y < Sup X" "X \ {}" obtains x where "x \ X" "y < x" + by (metis cSup_least assms not_le that) + +lemma complete_interval: + assumes "a < b" and "P a" and "\ P b" + shows "\c. a \ c \ c \ b \ (\x. a \ x \ x < c \ P x) \ + (\d. (\x. a \ x \ x < d \ P x) \ d \ c)" +proof (rule exI [where x = "Sup {d. \x. a \ x & x < d --> P x}"], auto) + show "a \ Sup {d. \c. a \ c \ c < d \ P c}" + by (rule cSup_upper [where z=b], auto) + (metis `a < b` `\ P b` linear less_le) +next + show "Sup {d. \c. a \ c \ c < d \ P c} \ b" + apply (rule cSup_least) + apply auto + apply (metis less_le_not_le) + apply (metis `a x" and lt: "x < Sup {d. \c. a \ c \ c < d \ P c}" + show "P x" + apply (rule less_cSupE [OF lt], auto) + apply (metis less_le_not_le) + apply (metis x) + done +next + fix d + assume 0: "\x. a \ x \ x < d \ P x" + thus "d \ Sup {d. \c. a \ c \ c < d \ P c}" + by (rule_tac z="b" in cSup_upper, auto) + (metis `a (\b'x\S. b' < x) \ Sup S = b" + by (rule cSup_eq) (auto simp: not_le[symmetric] setle_def) + +lemma cInf_unique: "b <=* (S::'a :: {conditional_complete_linorder, no_top} set) \ (\b'>b. \x\S. b' > x) \ Inf S = b" + by (rule cInf_eq) (auto simp: not_le[symmetric] setge_def) + +lemma cSup_eq_Max: "finite (X::'a::conditional_complete_linorder set) \ X \ {} \ Sup X = Max X" + using cSup_eq_Sup_fin[of X] Sup_fin_eq_Max[of X] by simp + +lemma cInf_eq_Min: "finite (X::'a::conditional_complete_linorder set) \ X \ {} \ Inf X = Min X" + using cInf_eq_Inf_fin[of X] Inf_fin_eq_Min[of X] by simp + +lemma cSup_lessThan[simp]: "Sup {.. Sup {y<.. Sup {y.. Inf {y<..x::'a::{conditional_complete_linorder, dense_linorder}} = y" + by (auto intro!: cInf_eq intro: dense_ge_bounded) + +lemma cInf_greaterThanLessThan[simp]: "y < x \ Inf {y<.. LEAST z::real. \x\X. x\z" + +definition + Inf_real_def: "Inf (X::real set) \ - Sup (uminus ` X)" + +instance +proof + { fix z x :: real and X :: "real set" + assume x: "x \ X" and z: "!!x. x \ X \ x \ z" + show "x \ Sup X" + proof (auto simp add: Sup_real_def) + from complete_real[of X] + obtain s where s: "(\y\X. y \ s) & (\z. ((\y\X. y \ z) --> s \ z))" + by (blast intro: x z) + hence "x \ s" + by (blast intro: x z) + also with s have "... = (LEAST z. \x\X. x \ z)" + by (fast intro: Least_equality [symmetric]) + finally show "x \ (LEAST z. \x\X. x \ z)" . + qed } + note Sup_upper = this -instance .. + { fix z :: real and X :: "real set" + assume x: "X \ {}" + and z: "\x. x \ X \ x \ z" + show "Sup X \ z" + proof (auto simp add: Sup_real_def) + from complete_real x + obtain s where s: "(\y\X. y \ s) & (\z. ((\y\X. y \ z) --> s \ z))" + by (blast intro: z) + hence "(LEAST z. \x\X. x \ z) = s" + by (best intro: Least_equality) + also with s z have "... \ z" + by blast + finally show "(LEAST z. \x\X. x \ z) \ z" . + qed } + note Sup_least = this + + { fix x z :: real and X :: "real set" + assume x: "x \ X" and z: "!!x. x \ X \ z \ x" + show "Inf X \ x" + proof - + have "-x \ Sup (uminus ` X)" + by (rule Sup_upper[of _ _ "- z"]) (auto simp add: image_iff x z) + thus ?thesis + by (auto simp add: Inf_real_def) + qed } + + { fix z :: real and X :: "real set" + assume x: "X \ {}" + and z: "\x. x \ X \ z \ x" + show "z \ Inf X" + proof - + have "Sup (uminus ` X) \ -z" + using x z by (force intro: Sup_least) + hence "z \ - Sup (uminus ` X)" + by simp + thus ?thesis + by (auto simp add: Inf_real_def) + qed } +qed end subsection{*Supremum of a set of reals*} -lemma Sup_upper [intro]: (*REAL_SUP_UBOUND in HOL4*) - fixes x :: real - assumes x: "x \ X" - and z: "!!x. x \ X \ x \ z" - shows "x \ Sup X" -proof (auto simp add: Sup_real_def) - from complete_real - obtain s where s: "(\y\X. y \ s) & (\z. ((\y\X. y \ z) --> s \ z))" - by (blast intro: x z) - hence "x \ s" - by (blast intro: x z) - also with s have "... = (LEAST z. \x\X. x \ z)" - by (fast intro: Least_equality [symmetric]) - finally show "x \ (LEAST z. \x\X. x \ z)" . -qed - -lemma Sup_least [intro]: (*REAL_IMP_SUP_LE in HOL4*) - fixes z :: real - assumes x: "X \ {}" - and z: "\x. x \ X \ x \ z" - shows "Sup X \ z" -proof (auto simp add: Sup_real_def) - from complete_real x - obtain s where s: "(\y\X. y \ s) & (\z. ((\y\X. y \ z) --> s \ z))" - by (blast intro: z) - hence "(LEAST z. \x\X. x \ z) = s" - by (best intro: Least_equality) - also with s z have "... \ z" - by blast - finally show "(LEAST z. \x\X. x \ z) \ z" . -qed - -lemma less_SupE: - fixes y :: real - assumes "y < Sup X" "X \ {}" - obtains x where "x\X" "y < x" -by (metis SupInf.Sup_least assms linorder_not_less that) - -lemma Sup_singleton [simp]: "Sup {x::real} = x" - by (force intro: Least_equality simp add: Sup_real_def) - -lemma Sup_eq_maximum: (*REAL_SUP_MAX in HOL4*) - fixes z :: real - assumes X: "z \ X" and z: "!!x. x \ X \ x \ z" - shows "Sup X = z" - by (force intro: Least_equality X z simp add: Sup_real_def) - -lemma Sup_upper2: (*REAL_IMP_LE_SUP in HOL4*) - fixes x :: real - shows "x \ X \ y \ x \ (!!x. x \ X \ x \ z) \ y \ Sup X" - by (metis Sup_upper order_trans) - -lemma Sup_real_iff : (*REAL_SUP_LE in HOL4*) - fixes z :: real - shows "X ~= {} ==> (!!x. x \ X ==> x \ z) ==> (\x\X. y y < Sup X" - by (rule iffI, metis less_le_trans Sup_upper, metis Sup_least not_less) - -lemma Sup_eq: - fixes a :: real - shows "(!!x. x \ X \ x \ a) - \ (!!y. (!!x. x \ X \ x \ y) \ a \ y) \ Sup X = a" - by (metis Sup_least Sup_upper add_le_cancel_left diff_add_cancel insert_absorb - insert_not_empty order_antisym) - -lemma Sup_le: - fixes S :: "real set" - shows "S \ {} \ S *<= b \ Sup S \ b" -by (metis SupInf.Sup_least setle_def) - -lemma Sup_upper_EX: - fixes x :: real - shows "x \ X \ \z. \x. x \ X \ x \ z \ x \ Sup X" - by blast - -lemma Sup_insert_nonempty: - fixes x :: real - assumes x: "x \ X" - and z: "!!x. x \ X \ x \ z" - shows "Sup (insert a X) = max a (Sup X)" -proof (cases "Sup X \ a") - case True - thus ?thesis - apply (simp add: max_def) - apply (rule Sup_eq_maximum) - apply (rule insertI1) - apply (metis Sup_upper [OF _ z] insertE linear order_trans) - done -next - case False - hence 1:"a < Sup X" by simp - have "Sup X \ Sup (insert a X)" - apply (rule Sup_least) - apply (metis ex_in_conv x) - apply (rule Sup_upper_EX) - apply blast - apply (metis insert_iff linear order_trans z) - done - moreover - have "Sup (insert a X) \ Sup X" - apply (rule Sup_least) - apply blast - apply (metis False Sup_upper insertE linear z) - done - ultimately have "Sup (insert a X) = Sup X" - by (blast intro: antisym ) - thus ?thesis - by (metis 1 min_max.le_iff_sup less_le) -qed - -lemma Sup_insert_if: - fixes X :: "real set" - assumes z: "!!x. x \ X \ x \ z" - shows "Sup (insert a X) = (if X={} then a else max a (Sup X))" -by auto (metis Sup_insert_nonempty z) - -lemma Sup: - fixes S :: "real set" - shows "S \ {} \ (\b. S *<= b) \ isLub UNIV S (Sup S)" -by (auto simp add: isLub_def setle_def leastP_def isUb_def intro!: setgeI) - -lemma Sup_finite_Max: - fixes S :: "real set" - assumes fS: "finite S" and Se: "S \ {}" - shows "Sup S = Max S" -using fS Se -proof- - let ?m = "Max S" - from Max_ge[OF fS] have Sm: "\ x\ S. x \ ?m" by metis - with Sup[OF Se] have lub: "isLub UNIV S (Sup S)" by (metis setle_def) - from Max_in[OF fS Se] lub have mrS: "?m \ Sup S" - by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def) - moreover - have "Sup S \ ?m" using Sm lub - by (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def) - ultimately show ?thesis by arith -qed - -lemma Sup_finite_in: - fixes S :: "real set" - assumes fS: "finite S" and Se: "S \ {}" - shows "Sup S \ S" - using Sup_finite_Max[OF fS Se] Max_in[OF fS Se] by metis - -lemma Sup_finite_ge_iff: - fixes S :: "real set" - assumes fS: "finite S" and Se: "S \ {}" - shows "a \ Sup S \ (\ x \ S. a \ x)" -by (metis Max_ge Se Sup_finite_Max Sup_finite_in fS linorder_not_le less_le_trans) - -lemma Sup_finite_le_iff: - fixes S :: "real set" - assumes fS: "finite S" and Se: "S \ {}" - shows "a \ Sup S \ (\ x \ S. a \ x)" -by (metis Max_ge Se Sup_finite_Max Sup_finite_in fS order_trans) - -lemma Sup_finite_gt_iff: - fixes S :: "real set" - assumes fS: "finite S" and Se: "S \ {}" - shows "a < Sup S \ (\ x \ S. a < x)" -by (metis Se Sup_finite_le_iff fS linorder_not_less) - -lemma Sup_finite_lt_iff: - fixes S :: "real set" - assumes fS: "finite S" and Se: "S \ {}" - shows "a > Sup S \ (\ x \ S. a > x)" -by (metis Se Sup_finite_ge_iff fS linorder_not_less) - -lemma Sup_unique: - fixes S :: "real set" - shows "S *<= b \ (\b' < b. \x \ S. b' < x) \ Sup S = b" -unfolding setle_def -apply (rule Sup_eq, auto) -apply (metis linorder_not_less) -done - -lemma Sup_abs_le: +lemma cSup_abs_le: fixes S :: "real set" shows "S \ {} \ (\x\S. \x\ \ a) \ \Sup S\ \ a" -by (auto simp add: abs_le_interval_iff) (metis Sup_upper2) +by (auto simp add: abs_le_interval_iff intro: cSup_least) (metis cSup_upper2) -lemma Sup_bounds: +lemma cSup_bounds: fixes S :: "real set" assumes Se: "S \ {}" and l: "a <=* S" and u: "S *<= b" shows "a \ Sup S \ Sup S \ b" proof- - from Sup[OF Se] u have lub: "isLub UNIV S (Sup S)" by blast + from isLub_cSup[OF Se] u have lub: "isLub UNIV S (Sup S)" by blast hence b: "Sup S \ b" using u by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def) from Se obtain y where y: "y \ S" by blast @@ -219,203 +350,66 @@ with b show ?thesis by blast qed -lemma Sup_asclose: +lemma cSup_asclose: fixes S :: "real set" assumes S:"S \ {}" and b: "\x\S. \x - l\ \ e" shows "\Sup S - l\ \ e" proof- have th: "\(x::real) l e. \x - l\ \ e \ l - e \ x \ x \ l + e" by arith - thus ?thesis using S b Sup_bounds[of S "l - e" "l+e"] unfolding th + thus ?thesis using S b cSup_bounds[of S "l - e" "l+e"] unfolding th by (auto simp add: setge_def setle_def) qed -lemma Sup_lessThan[simp]: "Sup {.. Sup {y<.. Sup {y.. Sup {y<..x} = (x::real)" - by (auto intro!: Sup_eq_maximum) - -lemma Sup_atLeastAtMost[simp]: "y \ x \ Sup {y..x} = (x::real)" - by (auto intro!: Sup_eq_maximum) - - subsection{*Infimum of a set of reals*} -lemma Inf_lower [intro]: - fixes z :: real - assumes x: "x \ X" - and z: "!!x. x \ X \ z \ x" - shows "Inf X \ x" -proof - - have "-x \ Sup (uminus ` X)" - by (rule Sup_upper [where z = "-z"]) (auto simp add: image_iff x z) - thus ?thesis - by (auto simp add: Inf_real_def) -qed - -lemma Inf_greatest [intro]: +lemma cInf_greater: fixes z :: real - assumes x: "X \ {}" - and z: "\x. x \ X \ z \ x" - shows "z \ Inf X" -proof - - have "Sup (uminus ` X) \ -z" using x z by force - hence "z \ - Sup (uminus ` X)" - by simp - thus ?thesis - by (auto simp add: Inf_real_def) -qed - -lemma Inf_singleton [simp]: "Inf {x::real} = x" - by (simp add: Inf_real_def) - -lemma Inf_eq_minimum: (*REAL_INF_MIN in HOL4*) - fixes z :: real - assumes x: "z \ X" and z: "!!x. x \ X \ z \ x" - shows "Inf X = z" -proof - - have "Sup (uminus ` X) = -z" using x z - by (force intro: Sup_eq_maximum x z) - thus ?thesis - by (simp add: Inf_real_def) -qed - -lemma Inf_lower2: - fixes x :: real - shows "x \ X \ x \ y \ (!!x. x \ X \ z \ x) \ Inf X \ y" - by (metis Inf_lower order_trans) - -lemma Inf_real_iff: - fixes z :: real - shows "X \ {} \ (!!x. x \ X \ z \ x) \ (\x\X. x Inf X < y" - by (metis Inf_greatest Inf_lower less_le_not_le linear - order_less_le_trans) + shows "X \ {} \ Inf X < z \ \x\X. x < z" + by (metis cInf_less_iff not_leE) -lemma Inf_eq: - fixes a :: real - shows "(!!x. x \ X \ a \ x) \ (!!y. (!!x. x \ X \ y \ x) \ y \ a) \ Inf X = a" - by (metis Inf_greatest Inf_lower add_le_cancel_left diff_add_cancel - insert_absorb insert_not_empty order_antisym) - -lemma Inf_ge: - fixes S :: "real set" - shows "S \ {} \ b <=* S \ Inf S \ b" -by (metis SupInf.Inf_greatest setge_def) - -lemma Inf_lower_EX: - fixes x :: real - shows "x \ X \ \z. \x. x \ X \ z \ x \ Inf X \ x" - by blast - -lemma Inf_insert_nonempty: - fixes x :: real - assumes x: "x \ X" - and z: "!!x. x \ X \ z \ x" - shows "Inf (insert a X) = min a (Inf X)" -proof (cases "a \ Inf X") - case True - thus ?thesis - by (simp add: min_def) - (blast intro: Inf_eq_minimum order_trans z) -next - case False - hence 1:"Inf X < a" by simp - have "Inf (insert a X) \ Inf X" - apply (rule Inf_greatest) - apply (metis ex_in_conv x) - apply (rule Inf_lower_EX) - apply (erule insertI2) - apply (metis insert_iff linear order_trans z) - done - moreover - have "Inf X \ Inf (insert a X)" - apply (rule Inf_greatest) - apply blast - apply (metis False Inf_lower insertE linear z) - done - ultimately have "Inf (insert a X) = Inf X" - by (blast intro: antisym ) - thus ?thesis - by (metis False min_max.inf_absorb2 linear) -qed - -lemma Inf_insert_if: - fixes X :: "real set" - assumes z: "!!x. x \ X \ z \ x" - shows "Inf (insert a X) = (if X={} then a else min a (Inf X))" -by auto (metis Inf_insert_nonempty z) - -lemma Inf_greater: - fixes z :: real - shows "X \ {} \ Inf X < z \ \x \ X. x < z" - by (metis Inf_real_iff not_leE) - -lemma Inf_close: +lemma cInf_close: fixes e :: real shows "X \ {} \ 0 < e \ \x \ X. x < Inf X + e" - by (metis add_strict_increasing add_commute Inf_greater linorder_not_le pos_add_strict) + by (metis add_strict_increasing add_commute cInf_greater linorder_not_le pos_add_strict) -lemma Inf_finite_Min: - fixes S :: "real set" - shows "finite S \ S \ {} \ Inf S = Min S" -by (simp add: Inf_real_def Sup_finite_Max image_image) - -lemma Inf_finite_in: +lemma cInf_finite_in: fixes S :: "real set" assumes fS: "finite S" and Se: "S \ {}" shows "Inf S \ S" - using Inf_finite_Min[OF fS Se] Min_in[OF fS Se] by metis + using cInf_eq_Min[OF fS Se] Min_in[OF fS Se] by metis -lemma Inf_finite_ge_iff: +lemma cInf_finite_ge_iff: fixes S :: "real set" shows "finite S \ S \ {} \ a \ Inf S \ (\ x \ S. a \ x)" -by (metis Inf_finite_Min Inf_finite_in Min_le order_trans) +by (metis cInf_eq_Min cInf_finite_in Min_le order_trans) -lemma Inf_finite_le_iff: +lemma cInf_finite_le_iff: fixes S :: "real set" shows "finite S \ S \ {} \ a \ Inf S \ (\ x \ S. a \ x)" -by (metis Inf_finite_Min Inf_finite_ge_iff Inf_finite_in Min_le - order_antisym linear) +by (metis cInf_eq_Min cInf_finite_ge_iff cInf_finite_in Min_le order_antisym linear) -lemma Inf_finite_gt_iff: +lemma cInf_finite_gt_iff: fixes S :: "real set" shows "finite S \ S \ {} \ a < Inf S \ (\ x \ S. a < x)" -by (metis Inf_finite_le_iff linorder_not_less) +by (metis cInf_finite_le_iff linorder_not_less) -lemma Inf_finite_lt_iff: +lemma cInf_finite_lt_iff: fixes S :: "real set" shows "finite S \ S \ {} \ a > Inf S \ (\ x \ S. a > x)" -by (metis Inf_finite_ge_iff linorder_not_less) +by (metis cInf_finite_ge_iff linorder_not_less) -lemma Inf_unique: - fixes S :: "real set" - shows "b <=* S \ (\b' > b. \x \ S. b' > x) \ Inf S = b" -unfolding setge_def -apply (rule Inf_eq, auto) -apply (metis less_le_not_le linorder_not_less) -done - -lemma Inf_abs_ge: +lemma cInf_abs_ge: fixes S :: "real set" shows "S \ {} \ (\x\S. \x\ \ a) \ \Inf S\ \ a" -by (simp add: Inf_real_def) (rule Sup_abs_le, auto) +by (simp add: Inf_real_def) (rule cSup_abs_le, auto) -lemma Inf_asclose: +lemma cInf_asclose: fixes S :: "real set" assumes S:"S \ {}" and b: "\x\S. \x - l\ \ e" shows "\Inf S - l\ \ e" proof - have "\- Sup (uminus ` S) - l\ = \Sup (uminus ` S) - (-l)\" by auto also have "... \ e" - apply (rule Sup_asclose) + apply (rule cSup_asclose) apply (auto simp add: S) apply (metis abs_minus_add_cancel b add_commute diff_minus) done @@ -424,73 +418,16 @@ by (simp add: Inf_real_def) qed -lemma Inf_greaterThanLessThan[simp]: "y < x \ Inf {y<.. Inf {y.. Inf {y<..x} = (y::real)" - by (simp add: Inf_real_def) - -lemma Inf_atLeastAtMost[simp]: "y \ x \ Inf {y..x} = (y::real)" - by (simp add: Inf_real_def) - subsection{*Relate max and min to Sup and Inf.*} -lemma real_max_Sup: +lemma real_max_cSup: fixes x :: real shows "max x y = Sup {x,y}" -proof- - have "Sup {x,y} \ max x y" by (simp add: Sup_finite_le_iff) - moreover - have "max x y \ Sup {x,y}" by (simp add: linorder_linear Sup_finite_ge_iff) - ultimately show ?thesis by arith -qed + by (subst cSup_insert[of _ y]) (simp_all add: sup_max) -lemma real_min_Inf: +lemma real_min_cInf: fixes x :: real shows "min x y = Inf {x,y}" -proof- - have "Inf {x,y} \ min x y" by (simp add: linorder_linear Inf_finite_le_iff) - moreover - have "min x y \ Inf {x,y}" by (simp add: Inf_finite_ge_iff) - ultimately show ?thesis by arith -qed - -lemma reals_complete_interval: - fixes a::real and b::real - assumes "a < b" and "P a" and "~P b" - shows "\c. a \ c & c \ b & (\x. a \ x & x < c --> P x) & - (\d. (\x. a \ x & x < d --> P x) --> d \ c)" -proof (rule exI [where x = "Sup {d. \x. a \ x & x < d --> P x}"], auto) - show "a \ Sup {d. \c. a \ c \ c < d \ P c}" - by (rule SupInf.Sup_upper [where z=b], auto) - (metis `a < b` `\ P b` linear less_le) -next - show "Sup {d. \c. a \ c \ c < d \ P c} \ b" - apply (rule SupInf.Sup_least) - apply (auto simp add: ) - apply (metis less_le_not_le) - apply (metis `a x" and lt: "x < Sup {d. \c. a \ c \ c < d \ P c}" - show "P x" - apply (rule less_SupE [OF lt], auto) - apply (metis less_le_not_le) - apply (metis x) - done -next - fix d - assume 0: "\x. a \ x \ x < d \ P x" - thus "d \ Sup {d. \c. a \ c \ c < d \ P c}" - by (rule_tac z="b" in SupInf.Sup_upper, auto) - (metis `a