# HG changeset patch # User paulson # Date 1501447463 -3600 # Node ID 1b4aa3e3e4e69de2caaec5766c7b5d5bb1cc1caf # Parent 5ff9fe3fee664f7e506d50b4c3a07866bffffa2a partial cleanup of the horrible Tagged_Division diff -r 5ff9fe3fee66 -r 1b4aa3e3e4e6 src/HOL/Analysis/Henstock_Kurzweil_Integration.thy --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Fri Jul 28 15:36:32 2017 +0100 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Sun Jul 30 21:44:23 2017 +0100 @@ -6020,25 +6020,20 @@ next case 3 then show ?case - apply (rule inter_interior_unions_intervals) - apply fact - apply rule - apply rule + proof (rule Int_interior_Union_intervals [OF \finite r\]) + show "open (interior (UNION p snd))" + by blast + show "\T. T \ r \ \a b. T = cbox a b" apply (rule q') - defer - apply rule - apply (subst Int_commute) - apply (rule inter_interior_unions_intervals) - apply (rule finite_imageI) - apply (rule p') - apply rule - defer - apply rule - apply (rule q') - using q(1) p' - unfolding r_def - apply auto - done + using r_def by blast + have "finite (snd ` p)" + by (simp add: p'(1)) + then show "\T. T \ r \ interior (UNION p snd) \ interior T = {}" + apply (subst Int_commute) + apply (rule Int_interior_Union_intervals) + using \r \ q - snd ` p\ q'(5) q(1) apply auto + by (simp add: p'(4)) + qed qed moreover have "\(snd ` p) \ \r = cbox a b" and "{qq i |i. i \ r} = qq ` r" unfolding Union_Un_distrib[symmetric] r_def diff -r 5ff9fe3fee66 -r 1b4aa3e3e4e6 src/HOL/Analysis/Tagged_Division.thy --- a/src/HOL/Analysis/Tagged_Division.thy Fri Jul 28 15:36:32 2017 +0100 +++ b/src/HOL/Analysis/Tagged_Division.thy Sun Jul 30 21:44:23 2017 +0100 @@ -10,7 +10,7 @@ Topology_Euclidean_Space begin -lemma finite_product_dependent: +lemma finite_product_dependent: (*FIXME DELETE*) assumes "finite s" and "\x. x \ s \ finite (t x)" shows "finite {(i, j) |i j. i \ s \ j \ t i}" @@ -77,19 +77,17 @@ assumes "i = cbox a b" and "j = cbox c d" and "interior j \ {}" - and "i \ j \ s" + and "i \ j \ S" and "interior i \ interior j = {}" - shows "interior i \ interior s" + shows "interior i \ interior S" proof - have "box a b \ cbox c d = {}" - using inter_interval_mixed_eq_empty[of c d a b] and assms(3,5) - unfolding assms(1,2) interior_cbox by auto + using inter_interval_mixed_eq_empty[of c d a b] assms + unfolding interior_cbox by auto moreover - have "box a b \ cbox c d \ s" + have "box a b \ cbox c d \ S" apply (rule order_trans,rule box_subset_cbox) - using assms(4) unfolding assms(1,2) - apply auto - done + using assms by auto ultimately show ?thesis unfolding assms interior_cbox @@ -132,9 +130,10 @@ finally show ?thesis . qed -lemma inter_interior_unions_intervals: - "finite f \ open s \ \t\f. \a b. t = cbox a b \ \t\f. s \ (interior t) = {} \ s \ interior (\f) = {}" - using interior_Union_subset_cbox[of f "UNIV - s"] by auto +lemma Int_interior_Union_intervals: + "\finite \; open S; \T. T\\ \ \a b. T = cbox a b; \T. T\\ \ S \ (interior T) = {}\ + \ S \ interior (\\) = {}" + using interior_Union_subset_cbox[of \ "UNIV - S"] by auto lemma interval_split: fixes a :: "'a::euclidean_space" @@ -142,11 +141,7 @@ shows "cbox a b \ {x. x\k \ c} = cbox a (\i\Basis. (if i = k then min (b\k) c else b\i) *\<^sub>R i)" "cbox a b \ {x. x\k \ c} = cbox (\i\Basis. (if i = k then max (a\k) c else a\i) *\<^sub>R i) b" - apply (rule_tac[!] set_eqI) - unfolding Int_iff mem_box mem_Collect_eq - using assms - apply auto - done + using assms by (rule_tac set_eqI; auto simp: mem_box)+ lemma interval_not_empty: "\i\Basis. a\i \ b\i \ cbox a b \ {}" by (simp add: box_ne_empty) @@ -242,17 +237,17 @@ unfolding gauge_def by auto lemma gauge_reflect: - fixes \ :: "'a::euclidean_space \ 'a set" - shows "gauge \ \ gauge (\x. uminus ` \ (- x))" + fixes \ :: "'a::euclidean_space \ 'a set" + shows "gauge \ \ gauge (\x. uminus ` \ (- x))" using equation_minus_iff by (auto simp: gauge_def surj_def intro!: open_surjective_linear_image linear_uminus) lemma gauge_Inter: - assumes "finite s" - and "\d. d\s \ gauge (f d)" - shows "gauge (\x. \{f d x | d. d \ s})" + assumes "finite S" + and "\d. d\S \ gauge (f d)" + shows "gauge (\x. \{f d x | d. d \ S})" proof - - have *: "\x. {f d x |d. d \ s} = (\d. f d x) ` s" + have *: "\x. {f d x |d. d \ S} = (\d. f d x) ` S" by auto show ?thesis unfolding gauge_def unfolding * @@ -266,16 +261,9 @@ subsection \Attempt a systematic general set of "offset" results for components.\ lemma gauge_modify: - assumes "(\s. open s \ open {x. f(x) \ s})" "gauge d" + assumes "(\S. open S \ open {x. f(x) \ S})" "gauge d" shows "gauge (\x. {y. f y \ d (f x)})" - using assms - unfolding gauge_def - apply safe - defer - apply (erule_tac x="f x" in allE) - apply (erule_tac x="d (f x)" in allE) - apply auto - done + using assms unfolding gauge_def by force subsection \Divisions.\ @@ -671,24 +659,19 @@ qed obtain q where q: "\x. x \ p \ q x division_of cbox a b" "\x. x \ p \ x \ q x" using bchoice[OF div_cbox] by blast - { fix x - assume x: "x \ p" - have "q x division_of \q x" - apply (rule division_ofI) - using division_ofD[OF q(1)[OF x]] - apply auto - done } - then have "\x. x \ p \ \d. d division_of \(q x - {x})" + have "q x division_of \q x" if x: "x \ p" for x + apply (rule division_ofI) + using division_ofD[OF q(1)[OF x]] by auto + then have di: "\x. x \ p \ \d. d division_of \(q x - {x})" by (meson Diff_subset division_of_subset) - then have "\d. d division_of \((\i. \(q i - {i})) ` p)" - apply - + have "\d. d division_of \((\i. \(q i - {i})) ` p)" apply (rule elementary_inters [OF finite_imageI[OF p(1)]]) - apply (auto simp: False elementary_inters [OF finite_imageI[OF p(1)]]) + apply (auto dest: di simp: False elementary_inters [OF finite_imageI[OF p(1)]]) done then obtain d where d: "d division_of \((\i. \(q i - {i})) ` p)" .. have "d \ p division_of cbox a b" proof - - have te: "\s f t. s \ {} \ \i\s. f i \ i = t \ t = \(f ` s) \ \s" by auto + have te: "\S f T. S \ {} \ \i\S. f i \ i = T \ T = \(f ` S) \ \S" by auto have cbox_eq: "cbox a b = \((\i. \(q i - {i})) ` p) \ \p" proof (rule te[OF False], clarify) fix i @@ -696,27 +679,23 @@ show "\(q i - {i}) \ i = cbox a b" using division_ofD(6)[OF q(1)[OF i]] using q(2)[OF i] by auto qed - { fix k - assume k: "k \ p" - have *: "\u t s. t \ s = {} \ u \ s \ u \ t = {}" + { fix K + assume K: "K \ p" + note qk=division_ofD[OF q(1)[OF K]] + have *: "\u T S. T \ S = {} \ u \ S \ u \ T = {}" by auto - have "interior (\i\p. \(q i - {i})) \ interior k = {}" - proof (rule *[OF inter_interior_unions_intervals]) - note qk=division_ofD[OF q(1)[OF k]] - show "finite (q k - {k})" "open (interior k)" "\t\q k - {k}. \a b. t = cbox a b" - using qk by auto - show "\t\q k - {k}. interior k \ interior t = {}" - using qk(5) using q(2)[OF k] by auto - show "interior (\i\p. \(q i - {i})) \ interior (\(q k - {k}))" + have "interior (\i\p. \(q i - {i})) \ interior K = {}" + proof (rule *[OF Int_interior_Union_intervals]) + show "\T. T\q K - {K} \ interior K \ interior T = {}" + using qk(5) using q(2)[OF K] by auto + show "interior (\i\p. \(q i - {i})) \ interior (\(q K - {K}))" apply (rule interior_mono)+ - using k - apply auto - done - qed } note [simp] = this + using K by auto + qed (use qk in auto)} note [simp] = this show "d \ p division_of (cbox a b)" unfolding cbox_eq apply (rule division_disjoint_union[OF d assms(1)]) - apply (rule inter_interior_unions_intervals) + apply (rule Int_interior_Union_intervals) apply (rule p open_interior ballI)+ apply simp_all done @@ -726,12 +705,12 @@ qed lemma elementary_bounded[dest]: - fixes s :: "'a::euclidean_space set" - shows "p division_of s \ bounded s" + fixes S :: "'a::euclidean_space set" + shows "p division_of S \ bounded S" unfolding division_of_def by (metis bounded_Union bounded_cbox) lemma elementary_subset_cbox: - "p division_of s \ \a b. s \ cbox a (b::'a::euclidean_space)" + "p division_of S \ \a b. S \ cbox a (b::'a::euclidean_space)" by (meson elementary_bounded bounded_subset_cbox) lemma division_union_intervals_exists: @@ -758,16 +737,16 @@ obtain u v where uv: "cbox a b \ cbox c d = cbox u v" unfolding Int_interval by auto have uv_sub: "cbox u v \ cbox c d" using uv by auto - obtain p where "p division_of cbox c d" "cbox u v \ p" + obtain p where pd: "p division_of cbox c d" and "cbox u v \ p" by (rule partial_division_extend_1[OF uv_sub False[unfolded uv]]) - note p = this division_ofD[OF this(1)] + note p = this division_ofD[OF pd] have "interior (cbox a b \ \(p - {cbox u v})) = interior(cbox u v \ \(p - {cbox u v}))" apply (rule arg_cong[of _ _ interior]) using p(8) uv by auto also have "\ = {}" unfolding interior_Int - apply (rule inter_interior_unions_intervals) - using p(6) p(7)[OF p(2)] p(3) + apply (rule Int_interior_Union_intervals) + using p(6) p(7)[OF p(2)] \finite p\ apply auto done finally have [simp]: "interior (cbox a b) \ interior (\(p - {cbox u v})) = {}" by simp @@ -784,59 +763,45 @@ qed qed -lemma division_of_unions: +lemma division_of_Union: assumes "finite f" and "\p. p \ f \ p division_of (\p)" and "\k1 k2. k1 \ \f \ k2 \ \f \ k1 \ k2 \ interior k1 \ interior k2 = {}" shows "\f division_of \\f" - using assms - by (auto intro!: division_ofI) + using assms by (auto intro!: division_ofI) lemma elementary_union_interval: fixes a b :: "'a::euclidean_space" assumes "p division_of \p" obtains q where "q division_of (cbox a b \ \p)" -proof - - note assm = division_ofD[OF assms] - have lem1: "\f s. \\(f ` s) = \((\x. \(f x)) ` s)" - by auto - have lem2: "\f s. f \ {} \ \{s \ t |t. t \ f} = s \ \f" +proof (cases "p = {} \ cbox a b = {}") + case True + obtain p where "p division_of (cbox a b)" + by (rule elementary_interval) + then show thesis + using True assms that by auto +next + case False + then have "p \ {}" "cbox a b \ {}" by auto - { - presume "p = {} \ thesis" - "cbox a b = {} \ thesis" - "cbox a b \ {} \ interior (cbox a b) = {} \ thesis" - "p \ {} \ interior (cbox a b)\{} \ cbox a b \ {} \ thesis" - then show thesis by auto + note pdiv = division_ofD[OF assms] + show ?thesis + proof (cases "interior (cbox a b) = {}") + case True + show ?thesis + apply (rule that [of "insert (cbox a b) p", OF division_ofI]) + using pdiv(1-4) True False apply auto + apply (metis IntI equals0D pdiv(5)) + by (metis disjoint_iff_not_equal pdiv(5)) next - assume as: "p = {}" - obtain p where "p division_of (cbox a b)" - by (rule elementary_interval) - then show thesis - using as that by auto - next - assume as: "cbox a b = {}" - show thesis - using as assms that by auto - next - assume as: "interior (cbox a b) = {}" "cbox a b \ {}" - show thesis - apply (rule that[of "insert (cbox a b) p"],rule division_ofI) - unfolding finite_insert - apply (rule assm(1)) unfolding Union_insert - using assm(2-4) as - apply - - apply (fast dest: assm(5))+ - done - next - assume as: "p \ {}" "interior (cbox a b) \ {}" "cbox a b \ {}" + case False have "\k\p. \q. (insert (cbox a b) q) division_of (cbox a b \ k)" proof fix k assume kp: "k \ p" - from assm(4)[OF kp] obtain c d where "k = cbox c d" by blast + from pdiv(4)[OF kp] obtain c d where "k = cbox c d" by blast then show "\q. (insert (cbox a b) q) division_of (cbox a b \ k)" - by (meson as(3) division_union_intervals_exists) + by (meson \cbox a b \ {}\ division_union_intervals_exists) qed from bchoice[OF this] obtain q where "\x\p. insert (cbox a b) (q x) division_of (cbox a b) \ x" .. note q = division_ofD[OF this[rule_format]] @@ -846,69 +811,59 @@ have *: "{insert (cbox a b) (q k) |k. k \ p} = (\k. insert (cbox a b) (q k)) ` p" by auto show "finite ?D" - using "*" assm(1) q(1) by auto + using "*" pdiv(1) q(1) by auto + have lem1: "\f s. \\(f ` s) = \((\x. \(f x)) ` s)" + by auto + have lem2: "\f s. f \ {} \ \{s \ t |t. t \ f} = s \ \f" + by auto show "\?D = cbox a b \ \p" unfolding * lem1 - unfolding lem2[OF as(1), of "cbox a b", symmetric] - using q(6) - by auto - fix k - assume k: "k \ ?D" - then show "k \ cbox a b \ \p" - using q(2) by auto - show "k \ {}" - using q(3) k by auto - show "\a b. k = cbox a b" - using q(4) k by auto - fix k' - assume k': "k' \ ?D" "k \ k'" + unfolding lem2[OF \p \ {}\, of "cbox a b", symmetric] + using q(6) by auto + show "k \ cbox a b \ \p" "k \ {}" if "k \ ?D" for k + using q that by blast+ + show "\a b. k = cbox a b" if "k \ ?D" for k + using q(4) that by auto + next + fix k' k + assume k: "k \ ?D" and k': "k' \ ?D" "k \ k'" obtain x where x: "k \ insert (cbox a b) (q x)" "x\p" using k by auto obtain x' where x': "k'\insert (cbox a b) (q x')" "x'\p" using k' by auto show "interior k \ interior k' = {}" - proof (cases "x = x'") + proof (cases "x = x' \ k = cbox a b \ k' = cbox a b") case True - show ?thesis + then show ?thesis using True k' q(5) x' x by auto next case False - { - presume "k = cbox a b \ ?thesis" - and "k' = cbox a b \ ?thesis" - and "k \ cbox a b \ k' \ cbox a b \ ?thesis" - then show ?thesis by linarith - next - assume as': "k = cbox a b" - show ?thesis - using as' k' q(5) x' by blast - next - assume as': "k' = cbox a b" - show ?thesis - using as' k'(2) q(5) x by blast - } - assume as': "k \ cbox a b" "k' \ cbox a b" + then have as': "k \ cbox a b" "k' \ cbox a b" + by auto obtain c d where k: "k = cbox c d" using q(4)[OF x(2,1)] by blast have "interior k \ interior (cbox a b) = {}" using as' k'(2) q(5) x by blast then have "interior k \ interior x" - using interior_subset_union_intervals - by (metis as(2) k q(2) x interior_subset_union_intervals) + by (metis \interior (cbox a b) \ {}\ k q(2) x interior_subset_union_intervals) moreover obtain c d where c_d: "k' = cbox c d" using q(4)[OF x'(2,1)] by blast have "interior k' \ interior (cbox a b) = {}" using as'(2) q(5) x' by blast then have "interior k' \ interior x'" - by (metis as(2) c_d interior_subset_union_intervals q(2) x'(1) x'(2)) + by (metis \interior (cbox a b) \ {}\ c_d interior_subset_union_intervals q(2) x'(1) x'(2)) + moreover have "interior x \ interior x' = {}" + by (meson False assms division_ofD(5) x'(2) x(2)) ultimately show ?thesis - using assm(5)[OF x(2) x'(2) False] by auto + using \interior k \ interior x\ \interior k' \ interior x'\ by auto qed qed - } + qed qed + + lemma elementary_unions_intervals: assumes fin: "finite f" and "\s. s \ f \ \a b. s = cbox a (b::'a::euclidean_space)" @@ -993,26 +948,20 @@ apply(rule assms r2)+ proof - have "interior s \ interior (\(r1-p)) = {}" - proof (rule inter_interior_unions_intervals) - show "finite (r1 - p)" and "open (interior s)" and "\t\r1-p. \a b. t = cbox a b" - using r1 by auto + proof (rule Int_interior_Union_intervals) have *: "\s. (\x. x \ s \ False) \ s = {}" by auto - show "\t\r1-p. interior s \ interior t = {}" - proof - fix m x - assume as: "m \ r1 - p" + show "interior s \ interior m = {}" if "m \ r1 - p" for m + proof - have "interior m \ interior (\p) = {}" - proof (rule inter_interior_unions_intervals) - show "finite p" and "open (interior m)" and "\t\p. \a b. t = cbox a b" - using divp by auto - show "\t\p. interior m \ interior t = {}" - by (metis DiffD1 DiffD2 as r1(1) r1(7) set_rev_mp) - qed + proof (rule Int_interior_Union_intervals) + show "\t. t\p \ interior m \ interior t = {}" + by (metis DiffD1 DiffD2 that r1(1) r1(7) set_rev_mp) + qed (use divp in auto) then show "interior s \ interior m = {}" unfolding divp by auto - qed - qed + qed + qed (use r1 in auto) then show "interior s \ interior (\(r1-p) \ (\q)) = {}" using interior_subset by auto qed auto @@ -2023,7 +1972,7 @@ show ?case unfolding Union_insert apply (rule assms(2)[rule_format]) - using inter_interior_unions_intervals [of f "interior x"] + using Int_interior_Union_intervals [of f "interior x"] apply (auto simp: insert) by (metis IntI empty_iff insert.hyps(2) insert.prems(3) insert_iff) qed @@ -2434,9 +2383,8 @@ apply auto done then have int: "interior (cbox u v) \ interior (\{k. \x. (x, k) \ p}) = {}" - apply (rule inter_interior_unions_intervals) + apply (rule Int_interior_Union_intervals) apply (rule open_interior) - apply (rule_tac[!] ballI) unfolding mem_Collect_eq apply (erule_tac[!] exE) apply (drule p(4)[OF insertI2])