# HG changeset patch # User wenzelm # Date 1378327039 -7200 # Node ID e114f515527c4350bb1c49eb835d15531bf4b0b3 # Parent a67d32e2d26eb3dff7ea28d68afa0acce8ebbfc4 tuned proofs; diff -r a67d32e2d26e -r e114f515527c src/HOL/Multivariate_Analysis/Integration.thy --- a/src/HOL/Multivariate_Analysis/Integration.thy Wed Sep 04 21:25:03 2013 +0200 +++ b/src/HOL/Multivariate_Analysis/Integration.thy Wed Sep 04 22:37:19 2013 +0200 @@ -1982,215 +1982,487 @@ definition "integral i f = (SOME y. (f has_integral y) i)" -lemma integrable_integral[dest]: - "f integrable_on i \ (f has_integral (integral i f)) i" - unfolding integrable_on_def integral_def by(rule someI_ex) +lemma integrable_integral[dest]: "f integrable_on i \ (f has_integral (integral i f)) i" + unfolding integrable_on_def integral_def by (rule someI_ex) lemma has_integral_integrable[intro]: "(f has_integral i) s \ f integrable_on s" unfolding integrable_on_def by auto -lemma has_integral_integral:"f integrable_on s \ (f has_integral (integral s f)) s" +lemma has_integral_integral: "f integrable_on s \ (f has_integral (integral s f)) s" by auto lemma setsum_content_null: - assumes "content({a..b}) = 0" "p tagged_division_of {a..b}" + assumes "content {a..b} = 0" + and "p tagged_division_of {a..b}" shows "setsum (\(x,k). content k *\<^sub>R f x) p = (0::'a::real_normed_vector)" -proof(rule setsum_0',rule) fix y assume y:"y\p" - obtain x k where xk:"y = (x,k)" using surj_pair[of y] by blast +proof (rule setsum_0', rule) + fix y + assume y: "y \ p" + obtain x k where xk: "y = (x, k)" + using surj_pair[of y] by blast note assm = tagged_division_ofD(3-4)[OF assms(2) y[unfolded xk]] - from this(2) guess c .. then guess d .. note c_d=this - have "(\(x, k). content k *\<^sub>R f x) y = content k *\<^sub>R f x" unfolding xk by auto - also have "\ = 0" using content_subset[OF assm(1)[unfolded c_d]] content_pos_le[of c d] - unfolding assms(1) c_d by auto + from this(2) obtain c d where k: "k = {c..d}" by blast + have "(\(x, k). content k *\<^sub>R f x) y = content k *\<^sub>R f x" + unfolding xk by auto + also have "\ = 0" + using content_subset[OF assm(1)[unfolded k]] content_pos_le[of c d] + unfolding assms(1) k + by auto finally show "(\(x, k). content k *\<^sub>R f x) y = 0" . qed + subsection {* Some basic combining lemmas. *} lemma tagged_division_unions_exists: - assumes "finite iset" "\i \ iset. \p. p tagged_division_of i \ d fine p" - "\i1\iset. \i2\iset. ~(i1 = i2) \ (interior(i1) \ interior(i2) = {})" "(\iset = i)" - obtains p where "p tagged_division_of i" "d fine p" -proof- guess pfn using bchoice[OF assms(2)] .. note pfn = conjunctD2[OF this[rule_format]] - show thesis apply(rule_tac p="\(pfn ` iset)" in that) unfolding assms(4)[symmetric] - apply(rule tagged_division_unions[OF assms(1) _ assms(3)]) defer - apply(rule fine_unions) using pfn by auto + assumes "finite iset" + and "\i\iset. \p. p tagged_division_of i \ d fine p" + and "\i1\iset. \i2\iset. i1 \ i2 \ interior i1 \ interior i2 = {}" + and "\iset = i" + obtains p where "p tagged_division_of i" and "d fine p" +proof - + obtain pfn where pfn: + "\x. x \ iset \ pfn x tagged_division_of x" + "\x. x \ iset \ d fine pfn x" + using bchoice[OF assms(2)] by auto + show thesis + apply (rule_tac p="\(pfn ` iset)" in that) + unfolding assms(4)[symmetric] + apply (rule tagged_division_unions[OF assms(1) _ assms(3)]) + defer + apply (rule fine_unions) + using pfn + apply auto + done qed + subsection {* The set we're concerned with must be closed. *} -lemma division_of_closed: "s division_of i \ closed (i::('n::ordered_euclidean_space) set)" +lemma division_of_closed: + fixes i :: "'n::ordered_euclidean_space set" + shows "s division_of i \ closed i" unfolding division_of_def by fastforce subsection {* General bisection principle for intervals; might be useful elsewhere. *} -lemma interval_bisection_step: fixes type::"'a::ordered_euclidean_space" - assumes "P {}" "(\s t. P s \ P t \ interior(s) \ interior(t) = {} \ P(s \ t))" "~(P {a..b::'a})" - obtains c d where "~(P{c..d})" - "\i\Basis. a\i \ c\i \ c\i \ d\i \ d\i \ b\i \ 2 * (d\i - c\i) \ b\i - a\i" -proof- have "{a..b} \ {}" using assms(1,3) by auto - then have ab: "\i. i\Basis \ a \ i \ b \ i" by (auto simp: interval_eq_empty not_le) - { fix f have "finite f \ - (\s\f. P s) \ - (\s\f. \a b. s = {a..b}) \ - (\s\f.\t\f. ~(s = t) \ interior(s) \ interior(t) = {}) \ P(\f)" - proof(induct f rule:finite_induct) - case empty show ?case using assms(1) by auto - next case (insert x f) show ?case unfolding Union_insert apply(rule assms(2)[rule_format]) - apply rule defer apply rule defer apply(rule inter_interior_unions_intervals) - using insert by auto - qed } note * = this - let ?A = "{{c..d} | c d::'a. \i\Basis. (c\i = a\i) \ (d\i = (a\i + b\i) / 2) \ (c\i = (a\i + b\i) / 2) \ (d\i = b\i)}" +lemma interval_bisection_step: + fixes type :: "'a::ordered_euclidean_space" + assumes "P {}" + and "\s t. P s \ P t \ interior(s) \ interior(t) = {} \ P (s \ t)" + and "\ P {a..b::'a}" + obtains c d where "\ P{c..d}" + and "\i\Basis. a\i \ c\i \ c\i \ d\i \ d\i \ b\i \ 2 * (d\i - c\i) \ b\i - a\i" +proof - + have "{a..b} \ {}" + using assms(1,3) by auto + then have ab: "\i. i\Basis \ a \ i \ b \ i" + by (auto simp: interval_eq_empty not_le) + { + fix f + have "finite f \ + \s\f. P s \ + \s\f. \a b. s = {a..b} \ + \s\f.\t\f. s \ t \ interior s \ interior t = {} \ P (\f)" + proof (induct f rule: finite_induct) + case empty + show ?case + using assms(1) by auto + next + case (insert x f) + show ?case + unfolding Union_insert + apply (rule assms(2)[rule_format]) + apply rule + defer + apply rule + defer + apply (rule inter_interior_unions_intervals) + using insert + apply auto + done + qed + } note * = this + let ?A = "{{c..d} | c d::'a. \i\Basis. (c\i = a\i) \ (d\i = (a\i + b\i) / 2) \ + (c\i = (a\i + b\i) / 2) \ (d\i = b\i)}" let ?PP = "\c d. \i\Basis. a\i \ c\i \ c\i \ d\i \ d\i \ b\i \ 2 * (d\i - c\i) \ b\i - a\i" - { presume "\c d. ?PP c d \ P {c..d} \ False" - thus thesis unfolding atomize_not not_all apply-apply(erule exE)+ apply(rule_tac c=x and d=xa in that) by auto } - assume as:"\c d. ?PP c d \ P {c..d}" - have "P (\ ?A)" proof(rule *, rule_tac[2-] ballI, rule_tac[4] ballI, rule_tac[4] impI) + { + presume "\c d. ?PP c d \ P {c..d} \ False" + then show thesis + unfolding atomize_not not_all + apply - + apply (erule exE)+ + apply (rule_tac c=x and d=xa in that) + apply auto + done + } + assume as: "\c d. ?PP c d \ P {c..d}" + have "P (\ ?A)" + apply (rule *) + apply (rule_tac[2-] ballI) + apply (rule_tac[4] ballI) + apply (rule_tac[4] impI) + proof - let ?B = "(\s.{(\i\Basis. (if i \ s then a\i else (a\i + b\i) / 2) *\<^sub>R i)::'a .. (\i\Basis. (if i \ s then (a\i + b\i) / 2 else b\i) *\<^sub>R i)}) ` {s. s \ Basis}" - have "?A \ ?B" proof case goal1 - then guess c unfolding mem_Collect_eq .. then guess d apply- by(erule exE,(erule conjE)+) note c_d=this[rule_format] - have *:"\a b c d. a = c \ b = d \ {a..b} = {c..d}" by auto - show "x\?B" unfolding image_iff - apply(rule_tac x="{i. i\Basis \ c\i = a\i}" in bexI) - unfolding c_d - apply(rule *) + have "?A \ ?B" + proof + case goal1 + then obtain c d where x: "x = {c..d}" + "\i. i \ Basis \ + c \ i = a \ i \ d \ i = (a \ i + b \ i) / 2 \ + c \ i = (a \ i + b \ i) / 2 \ d \ i = b \ i" by blast + have *: "\a b c d. a = c \ b = d \ {a..b} = {c..d}" + by auto + show "x \ ?B" + unfolding image_iff + apply (rule_tac x="{i. i\Basis \ c\i = a\i}" in bexI) + unfolding x + apply (rule *) apply (simp_all only: euclidean_eq_iff[where 'a='a] inner_setsum_left_Basis mem_Collect_eq simp_thms - cong: ball_cong) + cong: ball_cong) apply safe - proof- - fix i :: 'a assume i: "i\Basis" - thus " c \ i = (if c \ i = a \ i then a \ i else (a \ i + b \ i) / 2)" - "d \ i = (if c \ i = a \ i then (a \ i + b \ i) / 2 else b \ i)" - using c_d(2)[of i] ab[OF i] by(auto simp add:field_simps) - qed qed - thus "finite ?A" apply(rule finite_subset) by auto - fix s assume "s\?A" then guess c unfolding mem_Collect_eq .. then guess d apply- by(erule exE,(erule conjE)+) - note c_d=this[rule_format] - show "P s" unfolding c_d apply(rule as[rule_format]) proof- case goal1 thus ?case - using c_d(2)[of i] using ab[OF `i \ Basis`] by auto qed - show "\a b. s = {a..b}" unfolding c_d by auto - fix t assume "t\?A" then guess e unfolding mem_Collect_eq .. then guess f apply- by(erule exE,(erule conjE)+) - note e_f=this[rule_format] - assume "s \ t" hence "\ (c = e \ d = f)" unfolding c_d e_f by auto - then obtain i where "c\i \ e\i \ d\i \ f\i" and i':"i\Basis" + proof - + fix i :: 'a + assume i: "i \ Basis" + then show "c \ i = (if c \ i = a \ i then a \ i else (a \ i + b \ i) / 2)" + and "d \ i = (if c \ i = a \ i then (a \ i + b \ i) / 2 else b \ i)" + using x(2)[of i] ab[OF i] by (auto simp add:field_simps) + qed + qed + then show "finite ?A" + by (rule finite_subset) auto + fix s + assume "s \ ?A" + then obtain c d where s: + "s = {c..d}" + "\i. i \ Basis \ + c \ i = a \ i \ d \ i = (a \ i + b \ i) / 2 \ + c \ i = (a \ i + b \ i) / 2 \ d \ i = b \ i" + by blast + show "P s" + unfolding s + apply (rule as[rule_format]) + proof - + case goal1 + then show ?case + using s(2)[of i] using ab[OF `i \ Basis`] by auto + qed + show "\a b. s = {a..b}" + unfolding s by auto + fix t + assume "t \ ?A" + then obtain e f where t: + "t = {e..f}" + "\i. i \ Basis \ + e \ i = a \ i \ f \ i = (a \ i + b \ i) / 2 \ + e \ i = (a \ i + b \ i) / 2 \ f \ i = b \ i" + by blast + assume "s \ t" + then have "\ (c = e \ d = f)" + unfolding s t by auto + then obtain i where "c\i \ e\i \ d\i \ f\i" and i': "i \ Basis" unfolding euclidean_eq_iff[where 'a='a] by auto - hence i:"c\i \ e\i" "d\i \ f\i" apply- apply(erule_tac[!] disjE) - proof- assume "c\i \ e\i" thus "d\i \ f\i" using c_d(2)[OF i'] e_f(2)[OF i'] by fastforce - next assume "d\i \ f\i" thus "c\i \ e\i" using c_d(2)[OF i'] e_f(2)[OF i'] by fastforce - qed have *:"\s t. (\a. a\s \ a\t \ False) \ s \ t = {}" by auto - show "interior s \ interior t = {}" unfolding e_f c_d interior_closed_interval proof(rule *) - fix x assume "x\{c<..{e<..i < d\i" "e\i < f\i" "c\i < f\i" "e\i < d\i" unfolding mem_interval using i' - apply-apply(erule_tac[!] x=i in ballE)+ by auto - show False using c_d(2)[OF i'] apply- apply(erule_tac disjE) - proof(erule_tac[!] conjE) assume as:"c \ i = a \ i" "d \ i = (a \ i + b \ i) / 2" - show False using e_f(2)[OF i'] and i x unfolding as by(fastforce simp add:field_simps) - next assume as:"c \ i = (a \ i + b \ i) / 2" "d \ i = b \ i" - show False using e_f(2)[OF i'] and i x unfolding as by(fastforce simp add:field_simps) - qed qed qed - also have "\ ?A = {a..b}" proof(rule set_eqI,rule) - fix x assume "x\\?A" then guess Y unfolding Union_iff .. - from this(1) guess c unfolding mem_Collect_eq .. then guess d .. - note c_d = this[THEN conjunct2,rule_format] `x\Y`[unfolded this[THEN conjunct1]] - show "x\{a..b}" unfolding mem_interval proof safe - fix i :: 'a assume i: "i\Basis" thus "a \ i \ x \ i" "x \ i \ b \ i" - using c_d(1)[OF i] c_d(2)[unfolded mem_interval,THEN bspec, OF i] by auto qed - next fix x assume x:"x\{a..b}" - have "\i\Basis. \c d. (c = a\i \ d = (a\i + b\i) / 2 \ c = (a\i + b\i) / 2 \ d = b\i) \ c\x\i \ x\i \ d" - (is "\i\Basis. \c d. ?P i c d") unfolding mem_interval + then have i: "c\i \ e\i" "d\i \ f\i" + apply - + apply(erule_tac[!] disjE) + proof - + assume "c\i \ e\i" + then show "d\i \ f\i" + using s(2)[OF i'] t(2)[OF i'] by fastforce + next + assume "d\i \ f\i" + then show "c\i \ e\i" + using s(2)[OF i'] t(2)[OF i'] by fastforce + qed + have *: "\s t. (\a. a \ s \ a \ t \ False) \ s \ t = {}" + by auto + show "interior s \ interior t = {}" + unfolding s t interior_closed_interval + proof (rule *) + fix x + assume "x \ {c<.. {e<..i < d\i" "e\i < f\i" "c\i < f\i" "e\i < d\i" + unfolding mem_interval using i' + apply - + apply (erule_tac[!] x=i in ballE)+ + apply auto + done + show False + using s(2)[OF i'] + apply - + apply (erule_tac disjE) + apply (erule_tac[!] conjE) + proof - + assume as: "c \ i = a \ i" "d \ i = (a \ i + b \ i) / 2" + show False + using t(2)[OF i'] and i x unfolding as by (fastforce simp add:field_simps) + next + assume as: "c \ i = (a \ i + b \ i) / 2" "d \ i = b \ i" + show False + using t(2)[OF i'] and i x unfolding as by(fastforce simp add:field_simps) + qed + qed + qed + also have "\ ?A = {a..b}" + proof (rule set_eqI,rule) + fix x + assume "x \ \?A" + then obtain c d where x: + "x \ {c..d}" + "\i. i \ Basis \ + c \ i = a \ i \ d \ i = (a \ i + b \ i) / 2 \ + c \ i = (a \ i + b \ i) / 2 \ d \ i = b \ i" by blast + show "x\{a..b}" + unfolding mem_interval + proof safe + fix i :: 'a + assume i: "i \ Basis" + then show "a \ i \ x \ i" "x \ i \ b \ i" + using x(2)[OF i] x(1)[unfolded mem_interval,THEN bspec, OF i] by auto + qed + next + fix x + assume x: "x \ {a..b}" + have "\i\Basis. + \c d. (c = a\i \ d = (a\i + b\i) / 2 \ c = (a\i + b\i) / 2 \ d = b\i) \ c\x\i \ x\i \ d" + (is "\i\Basis. \c d. ?P i c d") + unfolding mem_interval proof - fix i :: 'a assume i: "i \ Basis" + fix i :: 'a + assume i: "i \ Basis" have "?P i (a\i) ((a \ i + b \ i) / 2) \ ?P i ((a \ i + b \ i) / 2) (b\i)" - using x[unfolded mem_interval,THEN bspec, OF i] by auto thus "\c d. ?P i c d" by blast + using x[unfolded mem_interval,THEN bspec, OF i] by auto + then show "\c d. ?P i c d" + by blast qed - thus "x\\?A" + then show "x\\?A" unfolding Union_iff Bex_def mem_Collect_eq choice_Basis_iff - apply-apply(erule exE)+ apply(rule_tac x="{xa..xaa}" in exI) unfolding mem_interval by auto - qed finally show False using assms by auto qed - -lemma interval_bisection: fixes type::"'a::ordered_euclidean_space" - assumes "P {}" "(\s t. P s \ P t \ interior(s) \ interior(t) = {} \ P(s \ t))" "\ P {a..b::'a}" - obtains x where "x \ {a..b}" "\e>0. \c d. x \ {c..d} \ {c..d} \ ball x e \ {c..d} \ {a..b} \ ~P({c..d})" -proof- + apply - + apply (erule exE)+ + apply (rule_tac x="{xa..xaa}" in exI) + unfolding mem_interval + apply auto + done + qed + finally show False + using assms by auto +qed + +lemma interval_bisection: + fixes type :: "'a::ordered_euclidean_space" + assumes "P {}" + and "(\s t. P s \ P t \ interior(s) \ interior(t) = {} \ P(s \ t))" + and "\ P {a..b::'a}" + obtains x where "x \ {a..b}" + and "\e>0. \c d. x \ {c..d} \ {c..d} \ ball x e \ {c..d} \ {a..b} \ \ P {c..d}" +proof - have "\x. \y. \ P {fst x..snd x} \ (\ P {fst y..snd y} \ (\i\Basis. fst x\i \ fst y\i \ fst y\i \ snd y\i \ snd y\i \ snd x\i \ - 2 * (snd y\i - fst y\i) \ snd x\i - fst x\i))" proof case goal1 thus ?case proof- + 2 * (snd y\i - fst y\i) \ snd x\i - fst x\i))" + proof + case goal1 + then show ?case + proof - presume "\ P {fst x..snd x} \ ?thesis" - thus ?thesis apply(cases "P {fst x..snd x}") by auto - next assume as:"\ P {fst x..snd x}" from interval_bisection_step[of P, OF assms(1-2) as] guess c d . - thus ?thesis apply- apply(rule_tac x="(c,d)" in exI) by auto - qed qed then guess f apply-apply(drule choice) by(erule exE) note f=this - def AB \ "\n. (f ^^ n) (a,b)" def A \ "\n. fst(AB n)" and B \ "\n. snd(AB n)" note ab_def = this AB_def + then show ?thesis by (cases "P {fst x..snd x}") auto + next + assume as: "\ P {fst x..snd x}" + obtain c d where "\ P {c..d}" + "\i\Basis. + fst x \ i \ c \ i \ + c \ i \ d \ i \ + d \ i \ snd x \ i \ + 2 * (d \ i - c \ i) \ snd x \ i - fst x \ i" + by (rule interval_bisection_step[of P, OF assms(1-2) as]) + then show ?thesis + apply - + apply (rule_tac x="(c,d)" in exI) + apply auto + done + qed + qed + then guess f + apply - + apply (drule choice) + apply (erule exE) + done + note f = this + def AB \ "\n. (f ^^ n) (a,b)" + def A \ "\n. fst(AB n)" + def B \ "\n. snd(AB n)" + note ab_def = A_def B_def AB_def have "A 0 = a" "B 0 = b" "\n. \ P {A(Suc n)..B(Suc n)} \ (\i\Basis. A(n)\i \ A(Suc n)\i \ A(Suc n)\i \ B(Suc n)\i \ B(Suc n)\i \ B(n)\i \ 2 * (B(Suc n)\i - A(Suc n)\i) \ B(n)\i - A(n)\i)" (is "\n. ?P n") - proof- show "A 0 = a" "B 0 = b" unfolding ab_def by auto - case goal3 note S = ab_def funpow.simps o_def id_apply show ?case - proof(induct n) case 0 thus ?case unfolding S apply(rule f[rule_format]) using assms(3) by auto - next case (Suc n) show ?case unfolding S apply(rule f[rule_format]) using Suc unfolding S by auto - qed qed note AB = this(1-2) conjunctD2[OF this(3),rule_format] - - have interv:"\e. 0 < e \ \n. \x\{A n..B n}. \y\{A n..B n}. dist x y < e" - proof- case goal1 guess n using real_arch_pow2[of "(setsum (\i. b\i - a\i) Basis) / e"] .. note n=this - show ?case apply(rule_tac x=n in exI) proof(rule,rule) - fix x y assume xy:"x\{A n..B n}" "y\{A n..B n}" - have "dist x y \ setsum (\i. abs((x - y)\i)) Basis" unfolding dist_norm by(rule norm_le_l1) + proof - + show "A 0 = a" "B 0 = b" + unfolding ab_def by auto + case goal3 + note S = ab_def funpow.simps o_def id_apply + show ?case + proof (induct n) + case 0 + then show ?case + unfolding S + apply (rule f[rule_format]) using assms(3) + apply auto + done + next + case (Suc n) + show ?case + unfolding S + apply (rule f[rule_format]) + using Suc + unfolding S + apply auto + done + qed + qed + note AB = this(1-2) conjunctD2[OF this(3),rule_format] + + have interv: "\e. 0 < e \ \n. \x\{A n..B n}. \y\{A n..B n}. dist x y < e" + proof - + case goal1 + obtain n where n: "(\i\Basis. b \ i - a \ i) / e < 2 ^ n" + using real_arch_pow2[of "(setsum (\i. b\i - a\i) Basis) / e"] .. + show ?case + apply (rule_tac x=n in exI) + apply rule + apply rule + proof - + fix x y + assume xy: "x\{A n..B n}" "y\{A n..B n}" + have "dist x y \ setsum (\i. abs((x - y)\i)) Basis" + unfolding dist_norm by(rule norm_le_l1) also have "\ \ setsum (\i. B n\i - A n\i) Basis" - proof(rule setsum_mono) - fix i :: 'a assume i: "i \ Basis" show "\(x - y) \ i\ \ B n \ i - A n \ i" - using xy[unfolded mem_interval,THEN bspec, OF i] by (auto simp: inner_diff_left) qed - also have "\ \ setsum (\i. b\i - a\i) Basis / 2^n" unfolding setsum_divide_distrib - proof(rule setsum_mono) case goal1 thus ?case - proof(induct n) case 0 thus ?case unfolding AB by auto - next case (Suc n) have "B (Suc n) \ i - A (Suc n) \ i \ (B n \ i - A n \ i) / 2" + proof (rule setsum_mono) + fix i :: 'a + assume i: "i \ Basis" + show "\(x - y) \ i\ \ B n \ i - A n \ i" + using xy[unfolded mem_interval,THEN bspec, OF i] + by (auto simp: inner_diff_left) + qed + also have "\ \ setsum (\i. b\i - a\i) Basis / 2^n" + unfolding setsum_divide_distrib + proof (rule setsum_mono) + case goal1 + then show ?case + proof (induct n) + case 0 + then show ?case + unfolding AB by auto + next + case (Suc n) + have "B (Suc n) \ i - A (Suc n) \ i \ (B n \ i - A n \ i) / 2" using AB(4)[of i n] using goal1 by auto - also have "\ \ (b \ i - a \ i) / 2 ^ Suc n" using Suc by(auto simp add:field_simps) finally show ?case . - qed qed - also have "\ < e" using n using goal1 by(auto simp add:field_simps) finally show "dist x y < e" . - qed qed - { fix n m :: nat assume "m \ n" then have "{A n..B n} \ {A m..B m}" - proof(induct rule: inc_induct) - case (step i) show ?case + also have "\ \ (b \ i - a \ i) / 2 ^ Suc n" + using Suc by (auto simp add:field_simps) + finally show ?case . + qed + qed + also have "\ < e" + using n using goal1 by (auto simp add:field_simps) + finally show "dist x y < e" . + qed + qed + { + fix n m :: nat + assume "m \ n" + then have "{A n..B n} \ {A m..B m}" + proof (induct rule: inc_induct) + case (step i) + show ?case using AB(4) by (intro order_trans[OF step(2)] subset_interval_imp) auto - qed simp } note ABsubset = this - have "\a. \n. a\{A n..B n}" apply(rule decreasing_closed_nest[rule_format,OF closed_interval _ ABsubset interv]) - proof- fix n show "{A n..B n} \ {}" apply(cases "0{a..b}" using x0[of 0] unfolding AB . - fix e assume "0 < (e::real)" from interv[OF this] guess n .. note n=this + qed simp + } note ABsubset = this + have "\a. \n. a\{A n..B n}" + apply (rule decreasing_closed_nest[rule_format,OF closed_interval _ ABsubset interv]) + proof - + fix n + show "{A n..B n} \ {}" + apply (cases "0 < n") + using AB(3)[of "n - 1"] assms(1,3) AB(1-2) + apply auto + done + qed auto + then obtain x0 where x0: "\n. x0 \ {A n..B n}" + by blast + show thesis + proof (rule that[rule_format, of x0]) + show "x0\{a..b}" + using x0[of 0] unfolding AB . + fix e :: real + assume "e > 0" + from interv[OF this] obtain n + where n: "\x\{A n..B n}. \y\{A n..B n}. dist x y < e" .. show "\c d. x0 \ {c..d} \ {c..d} \ ball x0 e \ {c..d} \ {a..b} \ \ P {c..d}" - apply(rule_tac x="A n" in exI,rule_tac x="B n" in exI) apply(rule,rule x0) apply rule defer - proof show "\ P {A n..B n}" apply(cases "0 ball x0 e" using n using x0[of n] by auto - show "{A n..B n} \ {a..b}" unfolding AB(1-2)[symmetric] apply(rule ABsubset) by auto - qed qed qed + apply (rule_tac x="A n" in exI) + apply (rule_tac x="B n" in exI) + apply rule + apply (rule x0) + apply rule + defer + apply rule + proof - + show "\ P {A n..B n}" + apply (cases "0 < n") + using AB(3)[of "n - 1"] assms(3) AB(1-2) + apply auto + done + show "{A n..B n} \ ball x0 e" + using n using x0[of n] by auto + show "{A n..B n} \ {a..b}" + unfolding AB(1-2)[symmetric] by (rule ABsubset) auto + qed + qed +qed + subsection {* Cousin's lemma. *} -lemma fine_division_exists: assumes "gauge g" - obtains p where "p tagged_division_of {a..b::'a::ordered_euclidean_space}" "g fine p" -proof- presume "\ (\p. p tagged_division_of {a..b} \ g fine p) \ False" - then guess p unfolding atomize_not not_not .. thus thesis apply-apply(rule that[of p]) by auto -next assume as:"\ (\p. p tagged_division_of {a..b} \ g fine p)" +lemma fine_division_exists: + fixes a b :: "'a::ordered_euclidean_space" + assumes "gauge g" + obtains p where "p tagged_division_of {a..b}" "g fine p" +proof - + presume "\ (\p. p tagged_division_of {a..b} \ g fine p) \ False" + then obtain p where "p tagged_division_of {a..b}" "g fine p" by blast + then show thesis .. +next + assume as: "\ (\p. p tagged_division_of {a..b} \ g fine p)" guess x apply(rule interval_bisection[of "\s. \p. p tagged_division_of s \ g fine p",rule_format,OF _ _ as]) - apply(rule_tac x="{}" in exI) defer apply(erule conjE exE)+ - proof- show "{} tagged_division_of {} \ g fine {}" unfolding fine_def by auto + apply(rule_tac x="{}" in exI) + defer apply(erule conjE exE)+ + proof - + show "{} tagged_division_of {} \ g fine {}" unfolding fine_def by auto fix s t p p' assume "p tagged_division_of s" "g fine p" "p' tagged_division_of t" "g fine p'" "interior s \ interior t = {}" - thus "\p. p tagged_division_of s \ t \ g fine p" apply-apply(rule_tac x="p \ p'" in exI) apply rule - apply(rule tagged_division_union) prefer 4 apply(rule fine_union) by auto + then show "\p. p tagged_division_of s \ t \ g fine p" + apply - + apply (rule_tac x="p \ p'" in exI) + apply rule + apply (rule tagged_division_union) + prefer 4 + apply (rule fine_union) + apply auto + done qed note x=this - obtain e where e:"e>0" "ball x e \ g x" using gaugeD[OF assms, of x] unfolding open_contains_ball by auto + obtain e where e:"e > 0" "ball x e \ g x" + using gaugeD[OF assms, of x] unfolding open_contains_ball by auto from x(2)[OF e(1)] guess c d apply-apply(erule exE conjE)+ . note c_d = this - have "g fine {(x, {c..d})}" unfolding fine_def using e using c_d(2) by auto - thus False using tagged_division_of_self[OF c_d(1)] using c_d by auto qed + have "g fine {(x, {c..d})}" + unfolding fine_def using e using c_d(2) by auto + then show False using tagged_division_of_self[OF c_d(1)] using c_d by auto +qed + subsection {* Basic theorems about integrals. *} -lemma has_integral_unique: fixes f::"'n::ordered_euclidean_space \ 'a::real_normed_vector" - assumes "(f has_integral k1) i" "(f has_integral k2) i" shows "k1 = k2" -proof(rule ccontr) let ?e = "norm(k1 - k2) / 2" assume as:"k1 \ k2" hence e:"?e > 0" by auto +lemma has_integral_unique: + fixes f :: "'n::ordered_euclidean_space \ 'a::real_normed_vector" + assumes "(f has_integral k1) i" and "(f has_integral k2) i" + shows "k1 = k2" +proof (rule ccontr) let ?e = "norm(k1 - k2) / 2" assume as:"k1 \ k2" hence e:"?e > 0" by auto have lem:"\f::'n \ 'a. \ a b k1 k2. (f has_integral k1) ({a..b}) \ (f has_integral k2) ({a..b}) \ k1 \ k2 \ False" proof- case goal1 let ?e = "norm(k1 - k2) / 2" from goal1(3) have e:"?e > 0" by auto