# HG changeset patch # User paulson # Date 1501511901 -3600 # Node ID 829f1f62b08700197a301125b2400d47e7b7684c # Parent 1b4aa3e3e4e69de2caaec5766c7b5d5bb1cc1caf more cleanup of Tagged_Division diff -r 1b4aa3e3e4e6 -r 829f1f62b087 src/HOL/Analysis/Tagged_Division.thy --- a/src/HOL/Analysis/Tagged_Division.thy Sun Jul 30 21:44:23 2017 +0100 +++ b/src/HOL/Analysis/Tagged_Division.thy Mon Jul 31 15:38:21 2017 +0100 @@ -795,20 +795,20 @@ by (metis disjoint_iff_not_equal pdiv(5)) next case False - have "\k\p. \q. (insert (cbox a b) q) division_of (cbox a b \ k)" + have "\K\p. \q. (insert (cbox a b) q) division_of (cbox a b \ K)" proof - fix k - assume kp: "k \ p" - 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)" + fix K + assume kp: "K \ p" + 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 \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]] - let ?D = "\{insert (cbox a b) (q k) | k. k \ p}" + let ?D = "\{insert (cbox a b) (q K) | K. K \ p}" show thesis proof (rule that[OF division_ofI]) - have *: "{insert (cbox a b) (q k) |k. k \ p} = (\k. insert (cbox a b) (q k)) ` p" + have *: "{insert (cbox a b) (q K) |K. K \ p} = (\K. insert (cbox a b) (q K)) ` p" by auto show "finite ?D" using "*" pdiv(1) q(1) by auto @@ -820,43 +820,43 @@ unfolding * lem1 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 + 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 + 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' \ k = cbox a b \ k' = cbox a b") + 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' \ K = cbox a b \ K' = cbox a b") case True then show ?thesis - using True k' q(5) x' x by auto + using True K' q(5) x' x by auto next case False - then have 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" - by (metis \interior (cbox a b) \ {}\ k q(2) x interior_subset_union_intervals) + obtain c d where K: "K = cbox c d" + using q(4) x by blast + have "interior K \ interior (cbox a b) = {}" + using as' K'(2) q(5) x by blast + then have "interior K \ interior x" + 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" + 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) = {}" + have "interior K' \ interior (cbox a b) = {}" using as'(2) q(5) x' by blast - then have "interior k' \ interior x'" + then have "interior K' \ interior x'" 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 \interior k \ interior x\ \interior k' \ interior x'\ by auto + using \interior K \ interior x\ \interior K' \ interior x'\ by auto qed qed qed @@ -888,11 +888,11 @@ qed lemma elementary_union: - fixes s t :: "'a::euclidean_space set" - assumes "ps division_of s" "pt division_of t" - obtains p where "p division_of (s \ t)" + fixes S T :: "'a::euclidean_space set" + assumes "ps division_of S" "pt division_of T" + obtains p where "p division_of (S \ T)" proof - - have *: "s \ t = \ps \ \pt" + have *: "S \ T = \ps \ \pt" using assms unfolding division_of_def by auto show ?thesis apply (rule elementary_unions_intervals[of "ps \ pt"]) @@ -901,14 +901,14 @@ qed lemma partial_division_extend: - fixes t :: "'a::euclidean_space set" - assumes "p division_of s" - and "q division_of t" - and "s \ t" - obtains r where "p \ r" and "r division_of t" + fixes T :: "'a::euclidean_space set" + assumes "p division_of S" + and "q division_of T" + and "S \ T" + obtains r where "p \ r" and "r division_of T" proof - note divp = division_ofD[OF assms(1)] and divq = division_ofD[OF assms(2)] - obtain a b where ab: "t \ cbox a b" + obtain a b where ab: "T \ cbox a b" using elementary_subset_cbox[OF assms(2)] by auto obtain r1 where "p \ r1" "r1 division_of (cbox a b)" using assms @@ -917,54 +917,49 @@ obtain p' where "p' division_of \(r1 - p)" apply (rule elementary_unions_intervals[of "r1 - p"]) using r1(3,6) - apply auto + apply auto done then obtain r2 where r2: "r2 division_of (\(r1 - p)) \ (\q)" by (metis assms(2) divq(6) elementary_inter) { fix x - assume x: "x \ t" "x \ s" - then have "x\\r1" - unfolding r1 using ab by auto - then obtain r where r: "r \ r1" "x \ r" - unfolding Union_iff .. - moreover - have "r \ p" + assume x: "x \ T" "x \ S" + then obtain R where r: "R \ r1" "x \ R" + unfolding r1 using ab + by (meson division_contains r1(2) subsetCE) + moreover have "R \ p" proof - assume "r \ p" - then have "x \ s" using divp(2) r by auto + assume "R \ p" + then have "x \ S" using divp(2) r by auto then show False using x by auto qed ultimately have "x\\(r1 - p)" by auto } - then have *: "t = \p \ (\(r1 - p) \ \q)" + then have Teq: "T = \p \ (\(r1 - p) \ \q)" unfolding divp divq using assms(3) by auto + have "interior S \ interior (\(r1-p)) = {}" + proof (rule Int_interior_Union_intervals) + have *: "\S. (\x. x \ S \ False) \ S = {}" + by auto + show "interior S \ interior m = {}" if "m \ r1 - p" for m + proof - + have "interior m \ interior (\p) = {}" + 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 (use r1 in auto) + then have "interior S \ interior (\(r1-p) \ (\q)) = {}" + using interior_subset by auto + then have div: "p \ r2 division_of \p \ \(r1 - p) \ \q" + by (simp add: assms(1) division_disjoint_union divp(6) r2) show ?thesis apply (rule that[of "p \ r2"]) - unfolding * - defer - apply (rule division_disjoint_union) - unfolding divp(6) - apply(rule assms r2)+ - proof - - have "interior s \ interior (\(r1-p)) = {}" - proof (rule Int_interior_Union_intervals) - have *: "\s. (\x. x \ s \ False) \ s = {}" - by auto - show "interior s \ interior m = {}" if "m \ r1 - p" for m - proof - - have "interior m \ interior (\p) = {}" - 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 (use r1 in auto) - then show "interior s \ interior (\(r1-p) \ (\q)) = {}" - using interior_subset by auto - qed auto + apply (auto simp: div Teq) + done qed @@ -983,45 +978,51 @@ show "\?p1 = ?I1" "\?p2 = ?I2" unfolding p(6)[symmetric] by auto { - fix k - assume "k \ ?p1" - then guess l unfolding mem_Collect_eq by (elim exE conjE) note l=this - guess u v using p(4)[OF l(2)] by (elim exE) note uv=this - show "k \ ?I1" + fix K + assume "K \ ?p1" + then obtain l where l: "K = l \ {x. x \ k \ c}" "l \ p" "l \ {x. x \ k \ c} \ {}" + by blast + obtain u v where uv: "l = cbox u v" + using assms(1) l(2) by blast + show "K \ ?I1" using l p(2) uv by force - show "k \ {}" + show "K \ {}" by (simp add: l) - show "\a b. k = cbox a b" + show "\a b. K = cbox a b" apply (simp add: l uv p(2-3)[OF l(2)]) apply (subst interval_split[OF k]) apply (auto intro: order.trans) done - fix k' - assume "k' \ ?p1" - then guess l' unfolding mem_Collect_eq by (elim exE conjE) note l'=this - assume "k \ k'" - then show "interior k \ interior k' = {}" + fix K' + assume "K' \ ?p1" + then obtain l' where l': "K' = l' \ {x. x \ k \ c}" "l' \ p" "l' \ {x. x \ k \ c} \ {}" + by blast + assume "K \ K'" + then show "interior K \ interior K' = {}" unfolding l l' using p(5)[OF l(2) l'(2)] by auto } { - fix k - assume "k \ ?p2" - then guess l unfolding mem_Collect_eq by (elim exE conjE) note l=this - guess u v using p(4)[OF l(2)] by (elim exE) note uv=this - show "k \ ?I2" + fix K + assume "K \ ?p2" + then obtain l where l: "K = l \ {x. c \ x \ k}" "l \ p" "l \ {x. c \ x \ k} \ {}" + by blast + obtain u v where uv: "l = cbox u v" + using l(2) p(4) by blast + show "K \ ?I2" using l p(2) uv by force - show "k \ {}" + show "K \ {}" by (simp add: l) - show "\a b. k = cbox a b" + show "\a b. K = cbox a b" apply (simp add: l uv p(2-3)[OF l(2)]) apply (subst interval_split[OF k]) apply (auto intro: order.trans) done - fix k' - assume "k' \ ?p2" - then guess l' unfolding mem_Collect_eq by (elim exE conjE) note l'=this - assume "k \ k'" - then show "interior k \ interior k' = {}" + fix K' + assume "K' \ ?p2" + then obtain l' where l': "K' = l' \ {x. c \ x \ k}" "l' \ p" "l' \ {x. c \ x \ k} \ {}" + by blast + assume "K \ K'" + then show "interior K \ interior K' = {}" unfolding l l' using p(5)[OF l(2) l'(2)] by auto } qed @@ -1070,10 +1071,7 @@ and "(\{K. \x. (x,K) \ s} = i)" shows "s tagged_division_of i" unfolding tagged_division_of - using assms - apply auto - apply fastforce+ - done + using assms by fastforce lemma tagged_division_ofD[dest]: (*FIXME USE A LOCALE*) assumes "s tagged_division_of i" @@ -1325,67 +1323,58 @@ "\i\Basis. (\i\Basis. (if i = k then max (a \ k) c else a \ i) *\<^sub>R i) \ i \ b\i" "min (b \ k) c = c" "max (a \ k) c = c" using assms using less_imp_le by auto - show ?t1 (*FIXME a horrible mess*) + have "\i\d. interval_lowerbound i \ x = y \ interval_upperbound i \ x = y" + if "a \ x < y" "y < (if x = k then c else b \ x)" + "interval_lowerbound i \ x = y \ interval_upperbound i \ x = y" + "i = l \ {x. x \ k \ c}" "l \ d" "l \ {x. x \ k \ c} \ {}" + "x \ Basis" for i l x y + proof - + obtain u v where l: "l = cbox u v" + using \l \ d\ assms(1) by blast + have *: "\i\Basis. u \ i \ (\i\Basis. (if i = k then min (v \ k) c else v \ i) *\<^sub>R i) \ i" + using that(6) unfolding l interval_split[OF k] box_ne_empty that . + have **: "\i\Basis. u\i \ v\i" + using l using that(6) unfolding box_ne_empty[symmetric] by auto + show ?thesis + apply (rule bexI[OF _ \l \ d\]) + using that(1-3,5) \x \ Basis\ + unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] that + apply (auto split: if_split_asm) + done + qed + moreover have "\x y. \y < (if x = k then c else b \ x)\ \ y < b \ x" + using \c < b\k\ by (auto split: if_split_asm) + ultimately show ?t1 + unfolding division_points_def interval_split[OF k, of a b] + unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)] + unfolding * by force + have "\x y i l. (if x = k then c else a \ x) < y \ a \ x < y" + using \a\k < c\ by (auto split: if_split_asm) + moreover have "\i\d. interval_lowerbound i \ x = y \ + interval_upperbound i \ x = y" + if "(if x = k then c else a \ x) < y" "y < b \ x" + "interval_lowerbound i \ x = y \ interval_upperbound i \ x = y" + "i = l \ {x. c \ x \ k}" "l \ d" "l \ {x. c \ x \ k} \ {}" + "x \ Basis" for x y i l + proof - + obtain u v where l: "l = cbox u v" + using \l \ d\ assm(4) by blast + have *: "\i\Basis. (\i\Basis. (if i = k then max (u \ k) c else u \ i) *\<^sub>R i) \ i \ v \ i" + using that(6) unfolding l interval_split[OF k] box_ne_empty that . + have **: "\i\Basis. u\i \ v\i" + using l using that(6) unfolding box_ne_empty[symmetric] by auto + show "\i\d. interval_lowerbound i \ x = y \ interval_upperbound i \ x = y" + apply (rule bexI[OF _ \l \ d\]) + using that(1-3,5) \x \ Basis\ + unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] that + apply (auto split: if_split_asm) + done + qed + ultimately show ?t2 unfolding division_points_def interval_split[OF k, of a b] unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)] unfolding * - apply (rule subsetI) - unfolding mem_Collect_eq split_beta - apply (erule bexE conjE)+ - apply (simp add: ) - apply (erule exE conjE)+ - proof - fix i l x - assume as: - "a \ fst x < snd x" "snd x < (if fst x = k then c else b \ fst x)" - "interval_lowerbound i \ fst x = snd x \ interval_upperbound i \ fst x = snd x" - "i = l \ {x. x \ k \ c}" "l \ d" "l \ {x. x \ k \ c} \ {}" - and fstx: "fst x \ Basis" - from assm(4)[OF this(5)] guess u v apply-by(erule exE)+ note l=this - have *: "\i\Basis. u \ i \ (\i\Basis. (if i = k then min (v \ k) c else v \ i) *\<^sub>R i) \ i" - using as(6) unfolding l interval_split[OF k] box_ne_empty as . - have **: "\i\Basis. u\i \ v\i" - using l using as(6) unfolding box_ne_empty[symmetric] by auto - show "\i\d. interval_lowerbound i \ fst x = snd x \ interval_upperbound i \ fst x = snd x" - apply (rule bexI[OF _ \l \ d\]) - using as(1-3,5) fstx - unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as - apply (auto split: if_split_asm) - done - show "snd x < b \ fst x" - using as(2) \c < b\k\ by (auto split: if_split_asm) - qed - show ?t2 - unfolding division_points_def interval_split[OF k, of a b] - unfolding interval_bounds[OF *(1)] interval_bounds[OF *(2)] interval_bounds[OF *(3)] - unfolding * - unfolding subset_eq - apply rule - unfolding mem_Collect_eq split_beta - apply (erule bexE conjE)+ - apply (simp only: mem_Collect_eq inner_sum_left_Basis simp_thms) - apply (erule exE conjE)+ - proof - fix i l x - assume as: - "(if fst x = k then c else a \ fst x) < snd x" "snd x < b \ fst x" - "interval_lowerbound i \ fst x = snd x \ interval_upperbound i \ fst x = snd x" - "i = l \ {x. c \ x \ k}" "l \ d" "l \ {x. c \ x \ k} \ {}" - and fstx: "fst x \ Basis" - from assm(4)[OF this(5)] guess u v by (elim exE) note l=this - have *: "\i\Basis. (\i\Basis. (if i = k then max (u \ k) c else u \ i) *\<^sub>R i) \ i \ v \ i" - using as(6) unfolding l interval_split[OF k] box_ne_empty as . - have **: "\i\Basis. u\i \ v\i" - using l using as(6) unfolding box_ne_empty[symmetric] by auto - show "\i\d. interval_lowerbound i \ fst x = snd x \ interval_upperbound i \ fst x = snd x" - apply (rule bexI[OF _ \l \ d\]) - using as(1-3,5) fstx - unfolding l interval_bounds[OF **] interval_bounds[OF *] interval_split[OF k] as - apply (auto split: if_split_asm) - done - show "a \ fst x < snd x" - using as(1) \a\k < c\ by (auto split: if_split_asm) - qed + by force qed lemma division_points_psubset: @@ -1393,7 +1382,7 @@ assumes "d division_of (cbox a b)" and "\i\Basis. a\i < b\i" "a\k < c" "c < b\k" and "l \ d" - and "interval_lowerbound l\k = c \ interval_upperbound l\k = c" + and disj: "interval_lowerbound l\k = c \ interval_upperbound l\k = c" and k: "k \ Basis" shows "division_points (cbox a b \ {x. x\k \ c}) {l \ {x. x\k \ c} | l. l\d \ l \ {x. x\k \ c} \ {}} \ division_points (cbox a b) d" (is "?D1 \ ?D") @@ -1571,8 +1560,12 @@ have "(1/2) *\<^sub>R (a+b) \ cbox a b" unfolding mem_box using ab by (auto simp: inner_simps) note this[unfolded division_ofD(6)[OF \d division_of cbox a b\,symmetric] Union_iff] - then guess i .. note i=this - guess u v using d'[rule_format,OF i(1)] by (elim exE conjE) note uv=this + then obtain i where i: "i \ d" "(1 / 2) *\<^sub>R (a + b) \ i" .. + obtain u v where uv: "i = cbox u v" + "\j\Basis. u \ j = a \ j \ v \ j = a \ j \ + u \ j = b \ j \ v \ j = b \ j \ + u \ j = a \ j \ v \ j = b \ j" + using d' i(1) by auto have "cbox a b \ d" proof - have "u = a" "v = b" @@ -1595,7 +1588,11 @@ assume x: "x \ d - {cbox a b}" then have "x\d" by auto note d'[rule_format,OF this] - then guess u v by (elim exE conjE) note uv=this + then obtain u v where uv: "x = cbox u v" + "\j\Basis. u \ j = a \ j \ v \ j = a \ j \ + u \ j = b \ j \ v \ j = b \ j \ + u \ j = a \ j \ v \ j = b \ j" + by blast have "u \ a \ v \ b" using x[unfolded uv] by auto then obtain j where "u\j \ a\j \ v\j \ b\j" and j: "j \ Basis" @@ -1637,7 +1634,8 @@ done { fix l y assume as: "l \ d" "y \ d" "l \ {x. x \ k \ c} = y \ {x. x \ k \ c}" "l \ y" - from division_ofD(4)[OF \d division_of cbox a b\ this(1)] guess u v by (elim exE) note leq=this + then obtain u v where leq: "l = cbox u v" + by (meson cbox_division_memE less.prems) have "g (l \ {x. x \ k \ c}) = \<^bold>1" unfolding leq interval_split[OF kc(4)] apply (rule operativeD[OF g]) @@ -1646,7 +1644,8 @@ } note fxk_le = this { fix l y assume as: "l \ d" "y \ d" "l \ {x. c \ x \ k} = y \ {x. c \ x \ k}" "l \ y" - from division_ofD(4)[OF \d division_of cbox a b\ this(1)] guess u v by (elim exE) note leq=this + then obtain u v where leq: "l = cbox u v" + by (meson cbox_division_memE less.prems) have "g (l \ {x. x \ k \ c}) = \<^bold>1" unfolding leq interval_split[OF kc(4)] apply (rule operativeD(1)[OF g]) @@ -2340,13 +2339,11 @@ unfolding tagged_division_of_def by auto presume "\p. finite p \ ?P p" - from this[rule_format,OF * assms(2)] guess q .. note q=this - then show ?thesis - apply - - apply (rule that[of q]) - unfolding tagged_division_ofD[OF assms(1)] - apply auto - done + from this[rule_format,OF * assms(2)] + obtain q where q: "q tagged_division_of \{k. \x. (x, k) \ p}" "d fine q" "(\(x, k)\p. k \ d x \ (x, k) \ q)" + by auto + with that[of q] show ?thesis + using assms(1) by auto } fix p :: "('a::euclidean_space \ ('a::euclidean_space set)) set" assume as: "finite p"