# HG changeset patch # User wenzelm # Date 1468574800 -7200 # Node ID 7f0e36eb73b4e956007e2c199353cc306eb55ee0 # Parent d51a0a772094bf71ca220dec4648d08966055a21# Parent b0f8845e349895e843530ce915e93a7c0911fefb merged diff -r d51a0a772094 -r 7f0e36eb73b4 src/HOL/Rat.thy --- a/src/HOL/Rat.thy Thu Jul 14 16:49:22 2016 +0100 +++ b/src/HOL/Rat.thy Fri Jul 15 11:26:40 2016 +0200 @@ -1,11 +1,11 @@ -(* Title: HOL/Rat.thy - Author: Markus Wenzel, TU Muenchen +(* Title: HOL/Rat.thy + Author: Markus Wenzel, TU Muenchen *) section \Rational numbers\ theory Rat -imports GCD Archimedean_Field + imports GCD Archimedean_Field begin subsection \Rational numbers as quotient\ @@ -27,17 +27,17 @@ lemma transp_ratrel: "transp ratrel" proof (rule transpI, unfold split_paired_all) fix a b a' b' a'' b'' :: int - assume A: "ratrel (a, b) (a', b')" - assume B: "ratrel (a', b') (a'', b'')" + assume *: "ratrel (a, b) (a', b')" + assume **: "ratrel (a', b') (a'', b'')" have "b' * (a * b'') = b'' * (a * b')" by simp - also from A have "a * b' = a' * b" by auto + also from * have "a * b' = a' * b" by auto also have "b'' * (a' * b) = b * (a' * b'')" by simp - also from B have "a' * b'' = a'' * b'" by auto + also from ** have "a' * b'' = a'' * b'" by auto also have "b * (a'' * b') = b' * (a'' * b)" by simp finally have "b' * (a * b'') = b' * (a'' * b)" . - moreover from B have "b' \ 0" by auto + moreover from ** have "b' \ 0" by auto ultimately have "a * b'' = a'' * b" by simp - with A B show "ratrel (a, b) (a'', b'')" by auto + with * ** show "ratrel (a, b) (a'', b'')" by auto qed lemma part_equivp_ratrel: "part_equivp ratrel" @@ -120,7 +120,7 @@ lift_definition plus_rat :: "rat \ rat \ rat" is "\x y. (fst x * snd y + fst y * snd x, snd x * snd y)" - by (clarsimp, simp add: distrib_right, simp add: ac_simps) + by (auto simp: distrib_right) (simp add: ac_simps) lemma add_rat [simp]: assumes "b \ 0" and "d \ 0" @@ -139,9 +139,8 @@ definition diff_rat_def: "q - r = q + - r" for q r :: rat lemma diff_rat [simp]: - assumes "b \ 0" and "d \ 0" - shows "Fract a b - Fract c d = Fract (a * d - c * b) (b * d)" - using assms by (simp add: diff_rat_def) + "b \ 0 \ d \ 0 \ Fract a b - Fract c d = Fract (a * d - c * b) (b * d)" + by (simp add: diff_rat_def) lift_definition times_rat :: "rat \ rat \ rat" is "\x y. (fst x * fst y, snd x * snd y)" @@ -150,10 +149,8 @@ lemma mult_rat [simp]: "Fract a b * Fract c d = Fract (a * c) (b * d)" by transfer simp -lemma mult_rat_cancel: - assumes "c \ 0" - shows "Fract (c * a) (c * b) = Fract a b" - using assms by transfer simp +lemma mult_rat_cancel: "c \ 0 \ Fract (c * a) (c * b) = Fract a b" + by transfer simp lift_definition inverse_rat :: "rat \ rat" is "\x. if fst x = 0 then (0, 1) else (snd x, fst x)" @@ -220,7 +217,7 @@ "Fract (- 1) 1 = - 1" "Fract k 0 = 0" using Fract_of_int_eq [of "numeral w"] - using Fract_of_int_eq [of "- numeral w"] + and Fract_of_int_eq [of "- numeral w"] by (simp_all add: Zero_rat_def One_rat_def eq_rat) lemma rat_number_expand: @@ -255,7 +252,8 @@ lemma Fract_coprime: "Fract (a div gcd a b) (b div gcd a b) = Fract a b" proof (cases "b = 0") case True - then show ?thesis by (simp add: eq_rat) + then show ?thesis + by (simp add: eq_rat) next case False moreover have "b div gcd a b * gcd a b = b" @@ -282,28 +280,27 @@ have *: "p * s = q * r" if "p * gcd r s = sgn (q * s) * r * gcd p q" and "q * gcd r s = sgn (q * s) * s * gcd p q" proof - - from that - have "(p * gcd r s) * (sgn (q * s) * s * gcd p q) = (q * gcd r s) * (sgn (q * s) * r * gcd p q)" + from that have "(p * gcd r s) * (sgn (q * s) * s * gcd p q) = + (q * gcd r s) * (sgn (q * s) * r * gcd p q)" by simp with assms show ?thesis by (auto simp add: ac_simps sgn_times sgn_0_0) qed from assms show ?thesis - by (auto simp add: normalize_def Let_def dvd_div_div_eq_mult mult.commute sgn_times + by (auto simp: normalize_def Let_def dvd_div_div_eq_mult mult.commute sgn_times split: if_splits intro: *) qed lemma normalize_eq: "normalize (a, b) = (p, q) \ Fract p q = Fract a b" - by (auto simp add: normalize_def Let_def Fract_coprime dvd_div_neg rat_number_collapse + by (auto simp: normalize_def Let_def Fract_coprime dvd_div_neg rat_number_collapse split: if_split_asm) lemma normalize_denom_pos: "normalize r = (p, q) \ q > 0" - by (auto simp add: normalize_def Let_def dvd_div_neg pos_imp_zdiv_neg_iff nonneg1_imp_zdiv_pos_iff + by (auto simp: normalize_def Let_def dvd_div_neg pos_imp_zdiv_neg_iff nonneg1_imp_zdiv_pos_iff split: if_split_asm) lemma normalize_coprime: "normalize r = (p, q) \ coprime p q" - by (auto simp add: normalize_def Let_def dvd_div_neg div_gcd_coprime - split: if_split_asm) + by (auto simp: normalize_def Let_def dvd_div_neg div_gcd_coprime split: if_split_asm) lemma normalize_stable [simp]: "q > 0 \ coprime p q \ normalize (p, q) = (p, q)" by (simp add: normalize_def) @@ -325,7 +322,8 @@ lemma quotient_of_unique: "\!p. r = Fract (fst p) (snd p) \ snd p > 0 \ coprime (fst p) (snd p)" proof (cases r) case (Fract a b) - then have "r = Fract (fst (a, b)) (snd (a, b)) \ snd (a, b) > 0 \ coprime (fst (a, b)) (snd (a, b))" + then have "r = Fract (fst (a, b)) (snd (a, b)) \ + snd (a, b) > 0 \ coprime (fst (a, b)) (snd (a, b))" by auto then show ?thesis proof (rule ex1I) @@ -453,7 +451,8 @@ lemma positive_add: "positive x \ positive y \ positive (x + y)" apply transfer apply (simp add: zero_less_mult_iff) - apply (elim disjE, simp_all add: add_pos_pos add_neg_neg mult_pos_neg mult_neg_pos mult_neg_neg) + apply (elim disjE) + apply (simp_all add: add_pos_pos add_neg_neg mult_pos_neg mult_neg_pos mult_neg_neg) done lemma positive_mult: "positive x \ positive y \ positive (x * y)" @@ -484,8 +483,8 @@ show "a < b \ a \ b \ \ b \ a" unfolding less_eq_rat_def less_rat_def apply auto - apply (drule (1) positive_add) - apply (simp_all add: positive_zero) + apply (drule (1) positive_add) + apply (simp_all add: positive_zero) done show "a \ a" unfolding less_eq_rat_def by simp @@ -533,15 +532,12 @@ by transfer simp lemma less_rat [simp]: - assumes "b \ 0" and "d \ 0" - shows "Fract a b < Fract c d \ (a * d) * (b * d) < (c * b) * (b * d)" - using assms unfolding less_rat_def - by (simp add: positive_rat algebra_simps) + "b \ 0 \ d \ 0 \ Fract a b < Fract c d \ (a * d) * (b * d) < (c * b) * (b * d)" + by (simp add: less_rat_def positive_rat algebra_simps) lemma le_rat [simp]: - assumes "b \ 0" and "d \ 0" - shows "Fract a b \ Fract c d \ (a * d) * (b * d) \ (c * b) * (b * d)" - using assms unfolding le_less by (simp add: eq_rat) + "b \ 0 \ d \ 0 \ Fract a b \ Fract c d \ (a * d) * (b * d) \ (c * b) * (b * d)" + by (simp add: le_less eq_rat) lemma abs_rat [simp, code]: "\Fract a b\ = Fract \a\ \b\" by (auto simp add: abs_rat_def zabs_def Zero_rat_def not_less le_less eq_rat zero_less_mult_iff) @@ -565,7 +561,8 @@ then show "P (Fract a b)" by (simp add: order_less_imp_not_eq [OF b]) qed - from Fract show "P q" by (auto simp add: linorder_neq_iff step step') + from Fract show "P q" + by (auto simp add: linorder_neq_iff step step') qed lemma zero_less_Fract_iff: "0 < b \ 0 < Fract a b \ 0 < a" @@ -662,9 +659,7 @@ lift_definition of_rat :: "rat \ 'a" is "\x. of_int (fst x) / of_int (snd x)" - apply (clarsimp simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq) - apply (simp only: of_int_mult [symmetric]) - done + by (auto simp: nonzero_divide_eq_eq nonzero_eq_divide_eq) (simp only: of_int_mult [symmetric]) end @@ -779,7 +774,7 @@ by (induct a) (simp add: of_rat_rat Fract_of_int_eq [symmetric]) qed -text \Collapse nested embeddings\ +text \Collapse nested embeddings.\ lemma of_rat_of_nat_eq [simp]: "of_rat (of_nat n) = of_nat n" by (induct n) (simp_all add: of_rat_add) @@ -854,31 +849,36 @@ apply (rule of_rat_mult [symmetric]) done -lemma nonzero_Rats_inverse: "a \ \ \ a \ 0 \ inverse a \ \" for a :: "'a::field_char_0" +lemma nonzero_Rats_inverse: "a \ \ \ a \ 0 \ inverse a \ \" + for a :: "'a::field_char_0" apply (auto simp add: Rats_def) apply (rule range_eqI) apply (erule nonzero_of_rat_inverse [symmetric]) done -lemma Rats_inverse [simp]: "a \ \ \ inverse a \ \" for a :: "'a::{field_char_0,field}" +lemma Rats_inverse [simp]: "a \ \ \ inverse a \ \" + for a :: "'a::{field_char_0,field}" apply (auto simp add: Rats_def) apply (rule range_eqI) apply (rule of_rat_inverse [symmetric]) done -lemma nonzero_Rats_divide: "a \ \ \ b \ \ \ b \ 0 \ a / b \ \" for a b :: "'a::field_char_0" +lemma nonzero_Rats_divide: "a \ \ \ b \ \ \ b \ 0 \ a / b \ \" + for a b :: "'a::field_char_0" apply (auto simp add: Rats_def) apply (rule range_eqI) apply (erule nonzero_of_rat_divide [symmetric]) done -lemma Rats_divide [simp]: "a \ \ \ b \ \ \ a / b \ \" for a b :: "'a::{field_char_0, field}" +lemma Rats_divide [simp]: "a \ \ \ b \ \ \ a / b \ \" + for a b :: "'a::{field_char_0, field}" apply (auto simp add: Rats_def) apply (rule range_eqI) apply (rule of_rat_divide [symmetric]) done -lemma Rats_power [simp]: "a \ \ \ a ^ n \ \" for a :: "'a::field_char_0" +lemma Rats_power [simp]: "a \ \ \ a ^ n \ \" + for a :: "'a::field_char_0" apply (auto simp add: Rats_def) apply (rule range_eqI) apply (rule of_rat_power [symmetric]) @@ -888,7 +888,8 @@ assumes "q \ \" obtains (of_rat) r where "q = of_rat r" proof - - from \q \ \\ have "q \ range of_rat" unfolding Rats_def . + from \q \ \\ have "q \ range of_rat" + by (simp only: Rats_def) then obtain r where "q = of_rat r" .. then show thesis .. qed @@ -1028,7 +1029,8 @@ text \Quickcheck\ definition (in term_syntax) - valterm_fract :: "int \ (unit \ Code_Evaluation.term) \ int \ (unit \ Code_Evaluation.term) \ + valterm_fract :: "int \ (unit \ Code_Evaluation.term) \ + int \ (unit \ Code_Evaluation.term) \ rat \ (unit \ Code_Evaluation.term)" where [code_unfold]: "valterm_fract k l = Code_Evaluation.valtermify Fract {\} k {\} l" diff -r d51a0a772094 -r 7f0e36eb73b4 src/HOL/Real.thy --- a/src/HOL/Real.thy Thu Jul 14 16:49:22 2016 +0100 +++ b/src/HOL/Real.thy Fri Jul 15 11:26:40 2016 +0200 @@ -23,19 +23,24 @@ subsection \Preliminary lemmas\ -lemma inj_add_left [simp]: "inj (op + x)" for x :: "'a::cancel_semigroup_add" +lemma inj_add_left [simp]: "inj (op + x)" + for x :: "'a::cancel_semigroup_add" by (meson add_left_imp_eq injI) -lemma inj_mult_left [simp]: "inj (op * x) \ x \ 0" for x :: "'a::idom" +lemma inj_mult_left [simp]: "inj (op * x) \ x \ 0" + for x :: "'a::idom" by (metis injI mult_cancel_left the_inv_f_f zero_neq_one) -lemma add_diff_add: "(a + c) - (b + d) = (a - b) + (c - d)" for a b c d :: "'a::ab_group_add" +lemma add_diff_add: "(a + c) - (b + d) = (a - b) + (c - d)" + for a b c d :: "'a::ab_group_add" by simp -lemma minus_diff_minus: "- a - - b = - (a - b)" for a b :: "'a::ab_group_add" +lemma minus_diff_minus: "- a - - b = - (a - b)" + for a b :: "'a::ab_group_add" by simp -lemma mult_diff_mult: "(x * y - a * b) = x * (y - b) + (x - a) * b" for x y a b :: "'a::ring" +lemma mult_diff_mult: "(x * y - a * b) = x * (y - b) + (x - a) * b" + for x y a b :: "'a::ring" by (simp add: algebra_simps) lemma inverse_diff_inverse: @@ -68,7 +73,7 @@ lemma vanishes_const [simp]: "vanishes (\n. c) \ c = 0" unfolding vanishes_def apply (cases "c = 0") - apply auto + apply auto apply (rule exI [where x = "\c\"]) apply auto done @@ -93,9 +98,12 @@ proof clarsimp fix n assume n: "i \ n" "j \ n" - have "\X n + Y n\ \ \X n\ + \Y n\" by (rule abs_triangle_ineq) - also have "\ < s + t" by (simp add: add_strict_mono i j n) - finally show "\X n + Y n\ < r" unfolding r . + have "\X n + Y n\ \ \X n\ + \Y n\" + by (rule abs_triangle_ineq) + also have "\ < s + t" + by (simp add: add_strict_mono i j n) + finally show "\X n + Y n\ < r" + by (simp only: r) qed then show "\k. \n\k. \X n + Y n\ < r" .. qed @@ -242,7 +250,8 @@ unfolding abs_mult .. also have "\ < a * t + s * b" by (simp_all add: add_strict_mono mult_strict_mono' a b i j *) - finally show "\X m * Y m - X n * Y n\ < r" by (simp only: r) + finally show "\X m * Y m - X n * Y n\ < r" + by (simp only: r) qed then show "\k. \m\k. \n\k. \X m * Y m - X n * Y n\ < r" .. qed @@ -273,7 +282,7 @@ lemma cauchy_not_vanishes: assumes X: "cauchy X" - assumes nz: "\ vanishes X" + and nz: "\ vanishes X" shows "\b>0. \k. \n\k. b < \X n\" using cauchy_not_vanishes_cases [OF assms] apply clarify @@ -285,7 +294,7 @@ lemma cauchy_inverse [simp]: assumes X: "cauchy X" - assumes nz: "\ vanishes X" + and nz: "\ vanishes X" shows "cauchy (\n. inverse (X n))" proof (rule cauchyI) fix r :: rat @@ -328,8 +337,10 @@ using cauchy_not_vanishes [OF Y] by blast obtain s where s: "0 < s" and "inverse a * s * inverse b = r" proof - show "0 < a * r * b" using a r b by simp - show "inverse a * (a * r * b) * inverse b = r" using a r b by simp + show "0 < a * r * b" + using a r b by simp + show "inverse a * (a * r * b) * inverse b = r" + using a r b by simp qed obtain k where k: "\n\k. \X n - Y n\ < s" using vanishesD [OF XY s] .. @@ -435,16 +446,19 @@ fix X Y assume "realrel X Y" then have X: "cauchy X" and Y: "cauchy Y" and XY: "vanishes (\n. X n - Y n)" - unfolding realrel_def by simp_all + by (simp_all add: realrel_def) have "vanishes X \ vanishes Y" proof assume "vanishes X" - from vanishes_diff [OF this XY] show "vanishes Y" by simp + from vanishes_diff [OF this XY] show "vanishes Y" + by simp next assume "vanishes Y" - from vanishes_add [OF this XY] show "vanishes X" by simp + from vanishes_add [OF this XY] show "vanishes X" + by simp qed - then show "?thesis X Y" by (simp add: vanishes_diff_inverse X Y XY realrel_def) + then show "?thesis X Y" + by (simp add: vanishes_diff_inverse X Y XY realrel_def) qed definition "x - y = x + - y" for x y :: real @@ -495,9 +509,12 @@ apply transfer apply (simp add: realrel_def) apply (rule vanishesI) - apply (frule (1) cauchy_not_vanishes, clarify) - apply (rule_tac x=k in exI, clarify) - apply (drule_tac x=n in spec, simp) + apply (frule (1) cauchy_not_vanishes) + apply clarify + apply (rule_tac x=k in exI) + apply clarify + apply (drule_tac x=n in spec) + apply simp done show "a div b = a * inverse b" by (rule divide_real_def) @@ -567,14 +584,15 @@ apply (rule_tac x = "max i j" in exI) apply clarsimp apply (rule mult_strict_mono) - apply auto + apply auto done lemma positive_minus: "\ positive x \ x \ 0 \ positive (- x)" apply transfer apply (simp add: realrel_def) - apply (drule (1) cauchy_not_vanishes_cases, safe) - apply blast+ + apply (drule (1) cauchy_not_vanishes_cases) + apply safe + apply blast+ done instantiation real :: linordered_field @@ -596,8 +614,8 @@ show "a < b \ a \ b \ \ b \ a" unfolding less_eq_real_def less_real_def apply auto - apply (drule (1) positive_add) - apply (simp_all add: positive_zero) + apply (drule (1) positive_add) + apply (simp_all add: positive_zero) done show "a \ a" unfolding less_eq_real_def by simp @@ -637,7 +655,8 @@ definition "(sup :: real \ real \ real) = max" -instance by standard (auto simp add: inf_real_def sup_real_def max_min_distrib2) +instance + by standard (auto simp add: inf_real_def sup_real_def max_min_distrib2) end @@ -656,15 +675,16 @@ instance real :: archimedean_field proof - fix x :: real - show "\z. x \ of_int z" + show "\z. x \ of_int z" for x :: real apply (induct x) apply (frule cauchy_imp_bounded, clarify) apply (rule_tac x="\b\ + 1" in exI) apply (rule less_imp_le) apply (simp add: of_int_Real less_real_def diff_Real positive_Real) - apply (rule_tac x=1 in exI, simp add: algebra_simps) - apply (rule_tac x=0 in exI, clarsimp) + apply (rule_tac x=1 in exI) + apply (simp add: algebra_simps) + apply (rule_tac x=0 in exI) + apply clarsimp apply (rule le_less_trans [OF abs_ge_self]) apply (rule less_le_trans [OF _ le_of_int_ceiling]) apply simp @@ -687,26 +707,24 @@ subsection \Completeness\ -lemma not_positive_Real: - assumes X: "cauchy X" - shows "\ positive (Real X) \ (\r>0. \k. \n\k. X n \ r)" - unfolding positive_Real [OF X] +lemma not_positive_Real: "\ positive (Real X) \ (\r>0. \k. \n\k. X n \ r)" if "cauchy X" + apply (simp only: positive_Real [OF that]) apply auto - apply (unfold not_less) - apply (erule obtain_pos_sum) - apply (drule_tac x=s in spec) - apply simp - apply (drule_tac r=t in cauchyD [OF X]) - apply clarify - apply (drule_tac x=k in spec) - apply clarsimp - apply (rule_tac x=n in exI) - apply clarify - apply (rename_tac m) - apply (drule_tac x=m in spec) - apply simp - apply (drule_tac x=n in spec) - apply simp + apply (unfold not_less) + apply (erule obtain_pos_sum) + apply (drule_tac x=s in spec) + apply simp + apply (drule_tac r=t in cauchyD [OF that]) + apply clarify + apply (drule_tac x=k in spec) + apply clarsimp + apply (rule_tac x=n in exI) + apply clarify + apply (rename_tac m) + apply (drule_tac x=m in spec) + apply simp + apply (drule_tac x=n in spec) + apply simp apply (drule spec) apply (drule (1) mp) apply clarify @@ -743,9 +761,12 @@ proof clarsimp fix n assume n: "i \ n" "j \ n" - have "X n \ Y i + t" using n j by simp - moreover have "\Y i - Y n\ < s" using n i by simp - ultimately show "X n \ Y n + r" unfolding r by simp + have "X n \ Y i + t" + using n j by simp + moreover have "\Y i - Y n\ < s" + using n i by simp + ultimately show "X n \ Y n + r" + unfolding r by simp qed then show ?thesis .. qed @@ -773,7 +794,7 @@ lemma of_nat_less_two_power [simp]: "of_nat n < (2::'a::linordered_idom) ^ n" apply (induct n) - apply simp + apply simp apply (metis add_le_less_mono mult_2 of_nat_Suc one_le_numeral one_le_power power_Suc) done @@ -821,7 +842,7 @@ have width: "B n - A n = (b - a) / 2^n" for n apply (induct n) - apply (simp_all add: eq_divide_eq) + apply (simp_all add: eq_divide_eq) apply (simp_all add: C_def avg_def algebra_simps) done @@ -833,13 +854,15 @@ apply (rule_tac x=n in exI) apply (erule less_trans) apply (rule mult_strict_right_mono) - apply (rule le_less_trans [OF _ of_nat_less_two_power]) - apply simp + apply (rule le_less_trans [OF _ of_nat_less_two_power]) + apply simp apply assumption done - have PA: "\ P (A n)" for n by (induct n) (simp_all add: a) - have PB: "P (B n)" for n by (induct n) (simp_all add: b) + have PA: "\ P (A n)" for n + by (induct n) (simp_all add: a) + have PB: "P (B n)" for n + by (induct n) (simp_all add: b) have ab: "a < b" using a b unfolding P_def apply (clarsimp simp add: not_le) @@ -847,21 +870,22 @@ apply (drule (1) less_le_trans) apply (simp add: of_rat_less) done - have AB: "A n < B n" for n by (induct n) (simp_all add: ab C_def avg_def) + have AB: "A n < B n" for n + by (induct n) (simp_all add: ab C_def avg_def) have A_mono: "\i j. i \ j \ A i \ A j" apply (auto simp add: le_less [where 'a=nat]) apply (erule less_Suc_induct) - apply (clarsimp simp add: C_def avg_def) - apply (simp add: add_divide_distrib [symmetric]) - apply (rule AB [THEN less_imp_le]) + apply (clarsimp simp add: C_def avg_def) + apply (simp add: add_divide_distrib [symmetric]) + apply (rule AB [THEN less_imp_le]) apply simp done have B_mono: "\i j. i \ j \ B j \ B i" apply (auto simp add: le_less [where 'a=nat]) apply (erule less_Suc_induct) - apply (clarsimp simp add: C_def avg_def) - apply (simp add: add_divide_distrib [symmetric]) - apply (rule AB [THEN less_imp_le]) + apply (clarsimp simp add: C_def avg_def) + apply (simp add: add_divide_distrib [symmetric]) + apply (rule AB [THEN less_imp_le]) apply simp done have cauchy_lemma: "\X. \n. \i\n. A n \ X i \ X i \ B n \ cauchy X" @@ -870,7 +894,7 @@ apply (erule exE) apply (rule_tac x=n in exI, clarify, rename_tac i j) apply (rule_tac y="B n - A n" in le_less_trans) defer - apply (simp add: width) + apply (simp add: width) apply (drule_tac x=n in spec) apply (frule_tac x=i in spec, drule (1) mp) apply (frule_tac x=j in spec, drule (1) mp) @@ -900,11 +924,13 @@ apply clarify apply (erule contrapos_pp) apply (simp add: not_le) - apply (drule less_RealD [OF \cauchy A\], clarify) + apply (drule less_RealD [OF \cauchy A\]) + apply clarify apply (subgoal_tac "\ P (A n)") - apply (simp add: P_def not_le, clarify) - apply (erule rev_bexI) - apply (erule (1) less_trans) + apply (simp add: P_def not_le) + apply clarify + apply (erule rev_bexI) + apply (erule (1) less_trans) apply (simp add: PA) done have "vanishes (\n. (b - a) / 2 ^ n)" @@ -945,13 +971,17 @@ instance proof - show Sup_upper: "x \ Sup X" if "x \ X" "bdd_above X" for x :: real and X :: "real set" + show Sup_upper: "x \ Sup X" + if "x \ X" "bdd_above X" + for x :: real and X :: "real set" proof - from that obtain s where s: "\y\X. y \ s" "\z. \y\X. y \ z \ s \ z" using complete_real[of X] unfolding bdd_above_def by blast - then show ?thesis unfolding Sup_real_def by (rule LeastI2_order) (auto simp: that) + then show ?thesis + unfolding Sup_real_def by (rule LeastI2_order) (auto simp: that) qed - show Sup_least: "Sup X \ z" if "X \ {}" and z: "\x. x \ X \ x \ z" + show Sup_least: "Sup X \ z" + if "X \ {}" and z: "\x. x \ X \ x \ z" for z :: real and X :: "real set" proof - from that obtain s where s: "\y\X. y \ s" "\z. \y\X. y \ z \ s \ z" @@ -962,9 +992,11 @@ by blast finally show ?thesis . qed - show "Inf X \ x" if "x \ X" "bdd_below X" for x :: real and X :: "real set" + show "Inf X \ x" if "x \ X" "bdd_below X" + for x :: real and X :: "real set" using Sup_upper [of "-x" "uminus ` X"] by (auto simp: Inf_real_def that) - show "z \ Inf X" if "X \ {}" "\x. x \ X \ z \ x" for z :: real and X :: "real set" + show "z \ Inf X" if "X \ {}" "\x. x \ X \ z \ x" + for z :: real and X :: "real set" using Sup_least [of "uminus ` X" "- z"] by (force simp: Inf_real_def that) show "\a b::real. a \ b" using zero_neq_one by blast @@ -990,13 +1022,16 @@ text \BH: These lemmas should not be necessary; they should be covered by existing simp rules and simplification procedures.\ -lemma real_mult_less_iff1 [simp]: "0 < z \ x * z < y * z \ x < y" for x y z :: real +lemma real_mult_less_iff1 [simp]: "0 < z \ x * z < y * z \ x < y" + for x y z :: real by simp (* solved by linordered_ring_less_cancel_factor simproc *) -lemma real_mult_le_cancel_iff1 [simp]: "0 < z \ x * z \ y * z \ x \ y" for x y z :: real +lemma real_mult_le_cancel_iff1 [simp]: "0 < z \ x * z \ y * z \ x \ y" + for x y z :: real by simp (* solved by linordered_ring_le_cancel_factor simproc *) -lemma real_mult_le_cancel_iff2 [simp]: "0 < z \ z * x \ z * y \ x \ y" for x y z :: real +lemma real_mult_le_cancel_iff2 [simp]: "0 < z \ z * x \ z * y \ x \ y" + for x y z :: real by simp (* solved by linordered_ring_le_cancel_factor simproc *) @@ -1072,7 +1107,7 @@ lemma real_of_int_div2: "0 \ real_of_int n / real_of_int x - real_of_int (n div x)" apply (cases "x = 0") - apply simp + apply simp apply (cases "0 < x") apply (metis add.left_neutral floor_correct floor_divide_of_int_eq le_diff_eq) apply (metis add.left_neutral floor_correct floor_divide_of_int_eq le_diff_eq) @@ -1096,7 +1131,8 @@ lemma nat_less_real_le: "n < m \ real n + 1 \ real m" by (metis discrete of_nat_1 of_nat_add of_nat_le_iff) -lemma nat_le_real_less: "n \ m \ real n < real m + 1" for m n :: nat +lemma nat_le_real_less: "n \ m \ real n < real m + 1" + for m n :: nat by (meson nat_less_real_le not_le) lemma real_of_nat_div_aux: "real x / real d = real (x div d) + real (x mod d) / real d" @@ -1122,7 +1158,7 @@ lemma real_of_nat_div3: "real n / real x - real (n div x) \ 1" for n x :: nat apply (cases "x = 0") - apply simp + apply simp apply (simp add: algebra_simps) apply (subst real_of_nat_div_aux) apply simp @@ -1138,10 +1174,8 @@ using reals_Archimedean[of e] less_trans[of 0 "1 / real n" e for n::nat] by (auto simp add: field_simps cong: conj_cong simp del: of_nat_Suc) -lemma reals_Archimedean3: - assumes x_greater_zero: "0 < x" - shows "\y. \n. y < real n * x" - using \0 < x\ by (auto intro: ex_less_of_nat_mult) +lemma reals_Archimedean3: "0 < x \ \y. \n. y < real n * x" + by (auto intro: ex_less_of_nat_mult) lemma real_archimedian_rdiv_eq_0: assumes x0: "x \ 0" @@ -1250,7 +1284,7 @@ text \ This density proof is due to Stefan Richter and was ported by TN. The - original source is \emph{Real Analysis} by H.L. Royden. + original source is \<^emph>\Real Analysis\ by H.L. Royden. It employs the Archimedean property of the reals.\ lemma Rats_dense_in_real: @@ -1263,15 +1297,15 @@ by blast define p where "p = \y * real q\ - 1" define r where "r = of_int p / real q" - from q have "x < y - inverse (real q)" by simp - also have "y - inverse (real q) \ r" - unfolding r_def p_def - by (simp add: le_divide_eq left_diff_distrib le_of_int_ceiling \0 < q\) + from q have "x < y - inverse (real q)" + by simp + also from \0 < q\ have "y - inverse (real q) \ r" + by (simp add: r_def p_def le_divide_eq left_diff_distrib) finally have "x < r" . - moreover have "r < y" - unfolding r_def p_def - by (simp add: divide_less_eq diff_less_eq \0 < q\ less_ceiling_iff [symmetric]) - moreover from r_def have "r \ \" by simp + moreover from \0 < q\ have "r < y" + by (simp add: r_def p_def divide_less_eq diff_less_eq less_ceiling_iff [symmetric]) + moreover have "r \ \" + by (simp add: r_def) ultimately show ?thesis by blast qed @@ -1307,19 +1341,24 @@ subsection \Simprules combining \x + y\ and \0\\ (* FIXME ARE THEY NEEDED? *) -lemma real_add_minus_iff [simp]: "x + - a = 0 \ x = a" for x a :: real +lemma real_add_minus_iff [simp]: "x + - a = 0 \ x = a" + for x a :: real by arith -lemma real_add_less_0_iff: "x + y < 0 \ y < - x" for x y :: real +lemma real_add_less_0_iff: "x + y < 0 \ y < - x" + for x y :: real by auto -lemma real_0_less_add_iff: "0 < x + y \ - x < y" for x y :: real +lemma real_0_less_add_iff: "0 < x + y \ - x < y" + for x y :: real by auto -lemma real_add_le_0_iff: "x + y \ 0 \ y \ - x" for x y :: real +lemma real_add_le_0_iff: "x + y \ 0 \ y \ - x" + for x y :: real by auto -lemma real_0_le_add_iff: "0 \ x + y \ - x \ y" for x y :: real +lemma real_0_le_add_iff: "0 \ x + y \ - x \ y" + for x y :: real by auto @@ -1331,10 +1370,12 @@ (* FIXME: declare this [simp] for all types, or not at all *) declare sum_squares_eq_zero_iff [simp] sum_power2_eq_zero_iff [simp] -lemma real_minus_mult_self_le [simp]: "- (u * u) \ x * x" for u x :: real +lemma real_minus_mult_self_le [simp]: "- (u * u) \ x * x" + for u x :: real by (rule order_trans [where y = 0]) auto -lemma realpow_square_minus_le [simp]: "- u\<^sup>2 \ x\<^sup>2" for u x :: real +lemma realpow_square_minus_le [simp]: "- u\<^sup>2 \ x\<^sup>2" + for u x :: real by (auto simp add: power2_eq_square) lemma numeral_power_eq_real_of_int_cancel_iff [simp]: @@ -1396,17 +1437,21 @@ subsection \Density of the Reals\ -lemma real_lbound_gt_zero: "0 < d1 \ 0 < d2 \ \e. 0 < e \ e < d1 \ e < d2" for d1 d2 :: real +lemma real_lbound_gt_zero: "0 < d1 \ 0 < d2 \ \e. 0 < e \ e < d1 \ e < d2" + for d1 d2 :: real by (rule exI [where x = "min d1 d2 / 2"]) (simp add: min_def) text \Similar results are proved in @{theory Fields}\ -lemma real_less_half_sum: "x < y \ x < (x + y) / 2" for x y :: real +lemma real_less_half_sum: "x < y \ x < (x + y) / 2" + for x y :: real by auto -lemma real_gt_half_sum: "x < y \ (x + y) / 2 < y" for x y :: real +lemma real_gt_half_sum: "x < y \ (x + y) / 2 < y" + for x y :: real by auto -lemma real_sum_of_halves: "x / 2 + x / 2 = x" for x :: real +lemma real_sum_of_halves: "x / 2 + x / 2 = x" + for x :: real by simp @@ -1414,13 +1459,16 @@ (* FIXME: theorems for negative numerals. Many duplicates, e.g. from Archimedean_Field.thy. *) -lemma real_of_nat_less_numeral_iff [simp]: "real n < numeral w \ n < numeral w" for n :: nat +lemma real_of_nat_less_numeral_iff [simp]: "real n < numeral w \ n < numeral w" + for n :: nat by (metis of_nat_less_iff of_nat_numeral) -lemma numeral_less_real_of_nat_iff [simp]: "numeral w < real n \ numeral w < n" for n :: nat +lemma numeral_less_real_of_nat_iff [simp]: "numeral w < real n \ numeral w < n" + for n :: nat by (metis of_nat_less_iff of_nat_numeral) -lemma numeral_le_real_of_nat_iff [simp]: "numeral n \ real m \ numeral n \ m" for m :: nat +lemma numeral_le_real_of_nat_iff [simp]: "numeral n \ real m \ numeral n \ m" + for m :: nat by (metis not_le real_of_nat_less_numeral_iff) declare of_int_floor_le [simp] (* FIXME duplicate!? *) @@ -1531,7 +1579,8 @@ and natceiling. \ -lemma nat_floor_neg: "x \ 0 \ nat \x\ = 0" for x :: real +lemma nat_floor_neg: "x \ 0 \ nat \x\ = 0" + for x :: real by linarith lemma le_nat_floor: "real x \ a \ x \ nat \a\" @@ -1547,7 +1596,8 @@ lemma real_nat_ceiling_ge: "x \ real (nat \x\)" by linarith -lemma Rats_no_top_le: "\q \ \. x \ q" for x :: real +lemma Rats_no_top_le: "\q \ \. x \ q" + for x :: real by (auto intro!: bexI[of _ "of_nat (nat \x\)"]) linarith lemma Rats_no_bot_less: "\q \ \. q < x" for x :: real @@ -1616,10 +1666,10 @@ text \Operations\ lemma zero_real_code [code]: "0 = Ratreal 0" -by simp + by simp lemma one_real_code [code]: "1 = Ratreal 1" -by simp + by simp instantiation real :: equal begin @@ -1631,7 +1681,8 @@ lemma real_equal_code [code]: "HOL.equal (Ratreal x) (Ratreal y) \ HOL.equal x y" by (simp add: equal_real_def equal) -lemma [code nbe]: "HOL.equal x x \ True" for x :: real +lemma [code nbe]: "HOL.equal x x \ True" + for x :: real by (rule equal_refl) end diff -r d51a0a772094 -r 7f0e36eb73b4 src/HOL/Topological_Spaces.thy --- a/src/HOL/Topological_Spaces.thy Thu Jul 14 16:49:22 2016 +0100 +++ b/src/HOL/Topological_Spaces.thy Fri Jul 15 11:26:40 2016 +0200 @@ -6,7 +6,7 @@ section \Topological Spaces\ theory Topological_Spaces -imports Main + imports Main begin named_theorems continuous_intros "structural introduction rules for continuity" @@ -22,9 +22,8 @@ assumes open_Union [intro]: "\S\K. open S \ open (\K)" begin -definition - closed :: "'a set \ bool" where - "closed S \ open (- S)" +definition closed :: "'a set \ bool" + where "closed S \ open (- S)" lemma open_empty [continuous_intros, intro, simp]: "open {}" using open_Union [of "{}"] by simp @@ -50,7 +49,7 @@ ultimately show "open S" by simp qed -lemma closed_empty [continuous_intros, intro, simp]: "closed {}" +lemma closed_empty [continuous_intros, intro, simp]: "closed {}" unfolding closed_def by simp lemma closed_Un [continuous_intros, intro]: "closed S \ closed T \ closed (S \ T)" @@ -71,7 +70,8 @@ lemma closed_Union [continuous_intros, intro]: "finite S \ \T\S. closed T \ closed (\S)" by (induct set: finite) auto -lemma closed_UN [continuous_intros, intro]: "finite A \ \x\A. closed (B x) \ closed (\x\A. B x)" +lemma closed_UN [continuous_intros, intro]: + "finite A \ \x\A. closed (B x) \ closed (\x\A. B x)" using closed_Union [of "B ` A"] by simp lemma open_closed: "open S \ closed (- S)" @@ -95,10 +95,14 @@ lemma open_Collect_neg: "closed {x. P x} \ open {x. \ P x}" unfolding Collect_neg_eq by (rule open_Compl) -lemma open_Collect_conj: assumes "open {x. P x}" "open {x. Q x}" shows "open {x. P x \ Q x}" +lemma open_Collect_conj: + assumes "open {x. P x}" "open {x. Q x}" + shows "open {x. P x \ Q x}" using open_Int[OF assms] by (simp add: Int_def) -lemma open_Collect_disj: assumes "open {x. P x}" "open {x. Q x}" shows "open {x. P x \ Q x}" +lemma open_Collect_disj: + assumes "open {x. P x}" "open {x. Q x}" + shows "open {x. P x \ Q x}" using open_Un[OF assms] by (simp add: Un_def) lemma open_Collect_ex: "(\i. open {x. P i x}) \ open {x. \i. P i x}" @@ -113,14 +117,18 @@ lemma closed_Collect_neg: "open {x. P x} \ closed {x. \ P x}" unfolding Collect_neg_eq by (rule closed_Compl) -lemma closed_Collect_conj: assumes "closed {x. P x}" "closed {x. Q x}" shows "closed {x. P x \ Q x}" +lemma closed_Collect_conj: + assumes "closed {x. P x}" "closed {x. Q x}" + shows "closed {x. P x \ Q x}" using closed_Int[OF assms] by (simp add: Int_def) -lemma closed_Collect_disj: assumes "closed {x. P x}" "closed {x. Q x}" shows "closed {x. P x \ Q x}" +lemma closed_Collect_disj: + assumes "closed {x. P x}" "closed {x. Q x}" + shows "closed {x. P x \ Q x}" using closed_Un[OF assms] by (simp add: Un_def) lemma closed_Collect_all: "(\i. closed {x. P i x}) \ closed {x. \i. P i x}" - using closed_INT[of UNIV "\i. {x. P i x}"] unfolding Collect_all_eq by simp + using closed_INT[of UNIV "\i. {x. P i x}"] by (simp add: Collect_all_eq) lemma closed_Collect_imp: "open {x. P x} \ closed {x. Q x} \ closed {x. P x \ Q x}" unfolding imp_conv_disj by (intro closed_Collect_disj closed_Collect_neg) @@ -130,7 +138,8 @@ end -subsection\Hausdorff and other separation properties\ + +subsection \Hausdorff and other separation properties\ class t0_space = topological_space + assumes t0_space: "x \ y \ \U. open U \ \ (x \ U \ y \ U)" @@ -139,37 +148,39 @@ assumes t1_space: "x \ y \ \U. open U \ x \ U \ y \ U" instance t1_space \ t0_space -proof qed (fast dest: t1_space) - -lemma separation_t1: - fixes x y :: "'a::t1_space" - shows "x \ y \ (\U. open U \ x \ U \ y \ U)" + by standard (fast dest: t1_space) + +lemma separation_t1: "x \ y \ (\U. open U \ x \ U \ y \ U)" + for x y :: "'a::t1_space" using t1_space[of x y] by blast -lemma closed_singleton [iff]: - fixes a :: "'a::t1_space" - shows "closed {a}" +lemma closed_singleton [iff]: "closed {a}" + for a :: "'a::t1_space" proof - let ?T = "\{S. open S \ a \ S}" - have "open ?T" by (simp add: open_Union) + have "open ?T" + by (simp add: open_Union) also have "?T = - {a}" - by (simp add: set_eq_iff separation_t1, auto) - finally show "closed {a}" unfolding closed_def . + by (auto simp add: set_eq_iff separation_t1) + finally show "closed {a}" + by (simp only: closed_def) qed lemma closed_insert [continuous_intros, simp]: fixes a :: "'a::t1_space" - assumes "closed S" shows "closed (insert a S)" + assumes "closed S" + shows "closed (insert a S)" proof - - from closed_singleton assms - have "closed ({a} \ S)" by (rule closed_Un) - thus "closed (insert a S)" by simp + from closed_singleton assms have "closed ({a} \ S)" + by (rule closed_Un) + then show "closed (insert a S)" + by simp qed -lemma finite_imp_closed: - fixes S :: "'a::t1_space set" - shows "finite S \ closed S" -by (induct set: finite, simp_all) +lemma finite_imp_closed: "finite S \ closed S" + for S :: "'a::t1_space set" + by (induct pred: finite) simp_all + text \T2 spaces are also known as Hausdorff spaces.\ @@ -177,34 +188,35 @@ assumes hausdorff: "x \ y \ \U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" instance t2_space \ t1_space -proof qed (fast dest: hausdorff) - -lemma separation_t2: - fixes x y :: "'a::t2_space" - shows "x \ y \ (\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {})" - using hausdorff[of x y] by blast - -lemma separation_t0: - fixes x y :: "'a::t0_space" - shows "x \ y \ (\U. open U \ ~(x\U \ y\U))" - using t0_space[of x y] by blast + by standard (fast dest: hausdorff) + +lemma separation_t2: "x \ y \ (\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {})" + for x y :: "'a::t2_space" + using hausdorff [of x y] by blast + +lemma separation_t0: "x \ y \ (\U. open U \ \ (x \ U \ y \ U))" + for x y :: "'a::t0_space" + using t0_space [of x y] by blast + text \A perfect space is a topological space with no isolated points.\ class perfect_space = topological_space + assumes not_open_singleton: "\ open {x}" -lemma UNIV_not_singleton: "UNIV \ {x::'a::perfect_space}" +lemma UNIV_not_singleton: "UNIV \ {x}" + for x :: "'a::perfect_space" by (metis open_UNIV not_open_singleton) subsection \Generators for toplogies\ -inductive generate_topology for S where - UNIV: "generate_topology S UNIV" -| Int: "generate_topology S a \ generate_topology S b \ generate_topology S (a \ b)" -| UN: "(\k. k \ K \ generate_topology S k) \ generate_topology S (\K)" -| Basis: "s \ S \ generate_topology S s" +inductive generate_topology :: "'a set set \ 'a set \ bool" for S :: "'a set set" + where + UNIV: "generate_topology S UNIV" + | Int: "generate_topology S (a \ b)" if "generate_topology S a" and "generate_topology S b" + | UN: "generate_topology S (\K)" if "(\k. k \ K \ generate_topology S k)" + | Basis: "generate_topology S s" if "s \ S" hide_fact (open) UNIV Int UN Basis @@ -212,10 +224,10 @@ "(\k. k \ I \ generate_topology S (K k)) \ generate_topology S (\k\I. K k)" using generate_topology.UN [of "K ` I"] by auto -lemma topological_space_generate_topology: - "class.topological_space (generate_topology S)" +lemma topological_space_generate_topology: "class.topological_space (generate_topology S)" by standard (auto intro: generate_topology.intros) + subsection \Order topologies\ class order_topology = order + "open" + @@ -239,13 +251,16 @@ class linorder_topology = linorder + order_topology -lemma closed_atMost [continuous_intros, simp]: "closed {.. a::'a::linorder_topology}" +lemma closed_atMost [continuous_intros, simp]: "closed {..a}" + for a :: "'a::linorder_topology" by (simp add: closed_open) -lemma closed_atLeast [continuous_intros, simp]: "closed {a::'a::linorder_topology ..}" +lemma closed_atLeast [continuous_intros, simp]: "closed {a..}" + for a :: "'a::linorder_topology" by (simp add: closed_open) -lemma closed_atLeastAtMost [continuous_intros, simp]: "closed {a::'a::linorder_topology .. b}" +lemma closed_atLeastAtMost [continuous_intros, simp]: "closed {a..b}" + for a b :: "'a::linorder_topology" proof - have "{a .. b} = {a ..} \ {.. b}" by auto @@ -264,7 +279,7 @@ then show ?thesis by blast next case False - with \x < y\ have "x \ {..< y} \ y \ {x <..} \ {x <..} \ {..< y} = {}" + with \x < y\ have "x \ {..< y}" "y \ {x <..}" "{x <..} \ {..< y} = {}" by auto then show ?thesis by blast qed @@ -272,56 +287,81 @@ instance linorder_topology \ t2_space proof fix x y :: 'a - from less_separate[of x y] less_separate[of y x] show "x \ y \ \U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" - by (elim neqE) (metis open_lessThan open_greaterThan Int_commute)+ + using less_separate [of x y] less_separate [of y x] + by (elim neqE; metis open_lessThan open_greaterThan Int_commute) qed lemma (in linorder_topology) open_right: - assumes "open S" "x \ S" and gt_ex: "x < y" shows "\b>x. {x ..< b} \ S" + assumes "open S" "x \ S" + and gt_ex: "x < y" + shows "\b>x. {x ..< b} \ S" + using assms unfolding open_generated_order +proof induct + case UNIV + then show ?case by blast +next + case (Int A B) + then obtain a b where "a > x" "{x ..< a} \ A" "b > x" "{x ..< b} \ B" + by auto + then show ?case + by (auto intro!: exI[of _ "min a b"]) +next + case UN + then show ?case by blast +next + case Basis + then show ?case + by (fastforce intro: exI[of _ y] gt_ex) +qed + +lemma (in linorder_topology) open_left: + assumes "open S" "x \ S" + and lt_ex: "y < x" + shows "\b S" using assms unfolding open_generated_order proof induction + case UNIV + then show ?case by blast +next case (Int A B) - then obtain a b where "a > x" "{x ..< a} \ A" "b > x" "{x ..< b} \ B" by auto - then show ?case by (auto intro!: exI[of _ "min a b"]) + then obtain a b where "a < x" "{a <.. x} \ A" "b < x" "{b <.. x} \ B" + by auto + then show ?case + by (auto intro!: exI[of _ "max a b"]) next - case (Basis S) then show ?case by (fastforce intro: exI[of _ y] gt_ex) -qed blast+ - -lemma (in linorder_topology) open_left: - assumes "open S" "x \ S" and lt_ex: "y < x" shows "\b S" - using assms unfolding open_generated_order -proof induction - case (Int A B) - then obtain a b where "a < x" "{a <.. x} \ A" "b < x" "{b <.. x} \ B" by auto - then show ?case by (auto intro!: exI[of _ "max a b"]) + case UN + then show ?case by blast next - case (Basis S) then show ?case by (fastforce intro: exI[of _ y] lt_ex) -qed blast+ + case Basis + then show ?case + by (fastforce intro: exI[of _ y] lt_ex) +qed + subsection \Setup some topologies\ subsubsection \Boolean is an order topology\ -text \It is a discrete topology, but don't have a type class for it (yet).\ - class discrete_topology = topological_space + assumes open_discrete: "\A. open A" instance discrete_topology < t2_space proof - fix x y :: 'a assume "x \ y" then show "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" + fix x y :: 'a + assume "x \ y" + then show "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" by (intro exI[of _ "{_}"]) (auto intro!: open_discrete) qed instantiation bool :: linorder_topology begin -definition open_bool :: "bool set \ bool" where - "open_bool = generate_topology (range (\a. {..< a}) \ range (\a. {a <..}))" +definition open_bool :: "bool set \ bool" + where "open_bool = generate_topology (range (\a. {..< a}) \ range (\a. {a <..}))" instance - proof qed (rule open_bool_def) + by standard (rule open_bool_def) end @@ -339,11 +379,11 @@ instantiation nat :: linorder_topology begin -definition open_nat :: "nat set \ bool" where - "open_nat = generate_topology (range (\a. {..< a}) \ range (\a. {a <..}))" +definition open_nat :: "nat set \ bool" + where "open_nat = generate_topology (range (\a. {..< a}) \ range (\a. {a <..}))" instance - proof qed (rule open_nat_def) + by standard (rule open_nat_def) end @@ -359,9 +399,9 @@ by auto next case (Suc n') - moreover then have "{n} = {.. {n' <..}" + then have "{n} = {.. {n' <..}" by auto - ultimately show ?thesis + with Suc show ?thesis by (auto intro: open_lessThan open_greaterThan) qed then have "open (\a\A. {a})" @@ -373,11 +413,11 @@ instantiation int :: linorder_topology begin -definition open_int :: "int set \ bool" where - "open_int = generate_topology (range (\a. {..< a}) \ range (\a. {a <..}))" +definition open_int :: "int set \ bool" + where "open_int = generate_topology (range (\a. {..< a}) \ range (\a. {a <..}))" instance - proof qed (rule open_int_def) + by standard (rule open_int_def) end @@ -394,31 +434,34 @@ by simp qed + subsubsection \Topological filters\ definition (in topological_space) nhds :: "'a \ 'a filter" where "nhds a = (INF S:{S. open S \ a \ S}. principal S)" -definition (in topological_space) at_within :: "'a \ 'a set \ 'a filter" ("at (_)/ within (_)" [1000, 60] 60) +definition (in topological_space) at_within :: "'a \ 'a set \ 'a filter" + ("at (_)/ within (_)" [1000, 60] 60) where "at a within s = inf (nhds a) (principal (s - {a}))" -abbreviation (in topological_space) at :: "'a \ 'a filter" ("at") where - "at x \ at x within (CONST UNIV)" - -abbreviation (in order_topology) at_right :: "'a \ 'a filter" where - "at_right x \ at x within {x <..}" - -abbreviation (in order_topology) at_left :: "'a \ 'a filter" where - "at_left x \ at x within {..< x}" +abbreviation (in topological_space) at :: "'a \ 'a filter" ("at") + where "at x \ at x within (CONST UNIV)" + +abbreviation (in order_topology) at_right :: "'a \ 'a filter" + where "at_right x \ at x within {x <..}" + +abbreviation (in order_topology) at_left :: "'a \ 'a filter" + where "at_left x \ at x within {..< x}" lemma (in topological_space) nhds_generated_topology: "open = generate_topology T \ nhds x = (INF S:{S\T. x \ S}. principal S)" unfolding nhds_def proof (safe intro!: antisym INF_greatest) - fix S assume "generate_topology T S" "x \ S" + fix S + assume "generate_topology T S" "x \ S" then show "(INF S:{S \ T. x \ S}. principal S) \ principal S" - by induction - (auto intro: INF_lower order_trans simp add: inf_principal[symmetric] simp del: inf_principal) + by induct + (auto intro: INF_lower order_trans simp: inf_principal[symmetric] simp del: inf_principal) qed (auto intro!: INF_lower intro: generate_topology.intros) lemma (in topological_space) eventually_nhds: @@ -429,15 +472,13 @@ "open s \ x \ s \ eventually (\y. y \ s) (nhds x)" by (subst eventually_nhds) blast -lemma eventually_nhds_x_imp_x: - "eventually P (nhds x) \ P x" +lemma eventually_nhds_x_imp_x: "eventually P (nhds x) \ P x" by (subst (asm) eventually_nhds) blast lemma nhds_neq_bot [simp]: "nhds a \ bot" - unfolding trivial_limit_def eventually_nhds by simp - -lemma (in t1_space) t1_space_nhds: - "x \ y \ (\\<^sub>F x in nhds x. x \ y)" + by (simp add: trivial_limit_def eventually_nhds) + +lemma (in t1_space) t1_space_nhds: "x \ y \ (\\<^sub>F x in nhds x. x \ y)" by (drule t1_space) (auto simp: eventually_nhds) lemma (in topological_space) nhds_discrete_open: "open {x} \ nhds x = principal {x}" @@ -450,24 +491,24 @@ unfolding at_within_def nhds_discrete by simp lemma at_within_eq: "at x within s = (INF S:{S. open S \ x \ S}. principal (S \ s - {x}))" - unfolding nhds_def at_within_def by (subst INF_inf_const2[symmetric]) (auto simp add: Diff_Int_distrib) + unfolding nhds_def at_within_def + by (subst INF_inf_const2[symmetric]) (auto simp: Diff_Int_distrib) lemma eventually_at_filter: "eventually P (at a within s) \ eventually (\x. x \ a \ x \ s \ P x) (nhds a)" - unfolding at_within_def eventually_inf_principal by (simp add: imp_conjL[symmetric] conj_commute) + by (simp add: at_within_def eventually_inf_principal imp_conjL[symmetric] conj_commute) lemma at_le: "s \ t \ at x within s \ at x within t" unfolding at_within_def by (intro inf_mono) auto lemma eventually_at_topological: "eventually P (at a within s) \ (\S. open S \ a \ S \ (\x\S. x \ a \ x \ s \ P x))" - unfolding eventually_nhds eventually_at_filter by simp + by (simp add: eventually_nhds eventually_at_filter) lemma at_within_open: "a \ S \ open S \ at a within S = at a" unfolding filter_eq_iff eventually_at_topological by (metis open_Int Int_iff UNIV_I) -lemma at_within_open_NO_MATCH: - "a \ s \ open s \ NO_MATCH UNIV s \ at a within s = at a" +lemma at_within_open_NO_MATCH: "a \ s \ open s \ NO_MATCH UNIV s \ at a within s = at a" by (simp only: at_within_open) lemma at_within_nhd: @@ -490,61 +531,70 @@ lemma at_eq_bot_iff: "at a = bot \ open {a}" unfolding trivial_limit_def eventually_at_topological - by (safe, case_tac "S = {a}", simp, fast, fast) - -lemma at_neq_bot [simp]: "at (a::'a::perfect_space) \ bot" + apply safe + apply (case_tac "S = {a}") + apply simp + apply fast + apply fast + done + +lemma at_neq_bot [simp]: "at a \ bot" + for a :: "'a::perfect_space" by (simp add: at_eq_bot_iff not_open_singleton) -lemma (in order_topology) nhds_order: "nhds x = - inf (INF a:{x <..}. principal {..< a}) (INF a:{..< x}. principal {a <..})" +lemma (in order_topology) nhds_order: + "nhds x = inf (INF a:{x <..}. principal {..< a}) (INF a:{..< x}. principal {a <..})" proof - have 1: "{S \ range lessThan \ range greaterThan. x \ S} = (\a. {..< a}) ` {x <..} \ (\a. {a <..}) ` {..< x}" by auto show ?thesis - unfolding nhds_generated_topology[OF open_generated_order] INF_union 1 INF_image comp_def .. + by (simp only: nhds_generated_topology[OF open_generated_order] INF_union 1 INF_image comp_def) qed lemma filterlim_at_within_If: assumes "filterlim f G (at x within (A \ {x. P x}))" - assumes "filterlim g G (at x within (A \ {x. \P x}))" - shows "filterlim (\x. if P x then f x else g x) G (at x within A)" + and "filterlim g G (at x within (A \ {x. \P x}))" + shows "filterlim (\x. if P x then f x else g x) G (at x within A)" proof (rule filterlim_If) note assms(1) also have "at x within (A \ {x. P x}) = inf (nhds x) (principal (A \ Collect P - {x}))" by (simp add: at_within_def) - also have "A \ Collect P - {x} = (A - {x}) \ Collect P" by blast + also have "A \ Collect P - {x} = (A - {x}) \ Collect P" + by blast also have "inf (nhds x) (principal \) = inf (at x within A) (principal (Collect P))" by (simp add: at_within_def inf_assoc) finally show "filterlim f G (inf (at x within A) (principal (Collect P)))" . next note assms(2) - also have "at x within (A \ {x. \P x}) = inf (nhds x) (principal (A \ {x. \P x} - {x}))" + also have "at x within (A \ {x. \ P x}) = inf (nhds x) (principal (A \ {x. \ P x} - {x}))" by (simp add: at_within_def) - also have "A \ {x. \P x} - {x} = (A - {x}) \ {x. \P x}" by blast - also have "inf (nhds x) (principal \) = inf (at x within A) (principal {x. \P x})" + also have "A \ {x. \ P x} - {x} = (A - {x}) \ {x. \ P x}" + by blast + also have "inf (nhds x) (principal \) = inf (at x within A) (principal {x. \ P x})" by (simp add: at_within_def inf_assoc) - finally show "filterlim g G (inf (at x within A) (principal {x. \P x}))" . + finally show "filterlim g G (inf (at x within A) (principal {x. \ P x}))" . qed lemma filterlim_at_If: assumes "filterlim f G (at x within {x. P x})" - assumes "filterlim g G (at x within {x. \P x})" - shows "filterlim (\x. if P x then f x else g x) G (at x)" + and "filterlim g G (at x within {x. \P x})" + shows "filterlim (\x. if P x then f x else g x) G (at x)" using assms by (intro filterlim_at_within_If) simp_all -lemma (in linorder_topology) at_within_order: "UNIV \ {x} \ - at x within s = inf (INF a:{x <..}. principal ({..< a} \ s - {x})) - (INF a:{..< x}. principal ({a <..} \ s - {x}))" -proof (cases "{x <..} = {}" "{..< x} = {}" rule: case_split[case_product case_split]) - assume "UNIV \ {x}" "{x<..} = {}" "{..< x} = {}" - moreover have "UNIV = {..< x} \ {x} \ {x <..}" +lemma (in linorder_topology) at_within_order: + assumes "UNIV \ {x}" + shows "at x within s = + inf (INF a:{x <..}. principal ({..< a} \ s - {x})) + (INF a:{..< x}. principal ({a <..} \ s - {x}))" +proof (cases "{x <..} = {}" "{..< x} = {}" rule: case_split [case_product case_split]) + case True_True + have "UNIV = {..< x} \ {x} \ {x <..}" by auto - ultimately show ?thesis + with assms True_True show ?thesis by auto -qed (auto simp: at_within_def nhds_order Int_Diff inf_principal[symmetric] INF_inf_const2 - inf_sup_aci[where 'a="'a filter"] - simp del: inf_principal) +qed (auto simp del: inf_principal simp: at_within_def nhds_order Int_Diff + inf_principal[symmetric] INF_inf_const2 inf_sup_aci[where 'a="'a filter"]) lemma (in linorder_topology) at_left_eq: "y < x \ at_left x = (INF a:{..< x}. principal {a <..< x})" @@ -554,7 +604,8 @@ lemma (in linorder_topology) eventually_at_left: "y < x \ eventually P (at_left x) \ (\by>b. y < x \ P y)" - unfolding at_left_eq by (subst eventually_INF_base) (auto simp: eventually_principal Ball_def) + unfolding at_left_eq + by (subst eventually_INF_base) (auto simp: eventually_principal Ball_def) lemma (in linorder_topology) at_right_eq: "x < y \ at_right x = (INF a:{x <..}. principal {x <..< a})" @@ -564,43 +615,47 @@ lemma (in linorder_topology) eventually_at_right: "x < y \ eventually P (at_right x) \ (\b>x. \y>x. y < b \ P y)" - unfolding at_right_eq by (subst eventually_INF_base) (auto simp: eventually_principal Ball_def) + unfolding at_right_eq + by (subst eventually_INF_base) (auto simp: eventually_principal Ball_def) lemma eventually_at_right_less: "\\<^sub>F y in at_right (x::'a::{linorder_topology, no_top}). x < y" using gt_ex[of x] eventually_at_right[of x] by auto -lemma trivial_limit_at_right_top: "at_right (top::_::{order_top, linorder_topology}) = bot" - unfolding filter_eq_iff eventually_at_topological by auto - -lemma trivial_limit_at_left_bot: "at_left (bot::_::{order_bot, linorder_topology}) = bot" - unfolding filter_eq_iff eventually_at_topological by auto - -lemma trivial_limit_at_left_real [simp]: - "\ trivial_limit (at_left (x::'a::{no_bot, dense_order, linorder_topology}))" - using lt_ex[of x] +lemma trivial_limit_at_right_top: "at_right (top::_::{order_top,linorder_topology}) = bot" + by (auto simp: filter_eq_iff eventually_at_topological) + +lemma trivial_limit_at_left_bot: "at_left (bot::_::{order_bot,linorder_topology}) = bot" + by (auto simp: filter_eq_iff eventually_at_topological) + +lemma trivial_limit_at_left_real [simp]: "\ trivial_limit (at_left x)" + for x :: "'a::{no_bot,dense_order,linorder_topology}" + using lt_ex [of x] by safe (auto simp add: trivial_limit_def eventually_at_left dest: dense) -lemma trivial_limit_at_right_real [simp]: - "\ trivial_limit (at_right (x::'a::{no_top, dense_order, linorder_topology}))" +lemma trivial_limit_at_right_real [simp]: "\ trivial_limit (at_right x)" + for x :: "'a::{no_top,dense_order,linorder_topology}" using gt_ex[of x] by safe (auto simp add: trivial_limit_def eventually_at_right dest: dense) -lemma at_eq_sup_left_right: "at (x::'a::linorder_topology) = sup (at_left x) (at_right x)" +lemma at_eq_sup_left_right: "at x = sup (at_left x) (at_right x)" + for x :: "'a::linorder_topology" by (auto simp: eventually_at_filter filter_eq_iff eventually_sup - elim: eventually_elim2 eventually_mono) + elim: eventually_elim2 eventually_mono) lemma eventually_at_split: - "eventually P (at (x::'a::linorder_topology)) \ eventually P (at_left x) \ eventually P (at_right x)" + "eventually P (at x) \ eventually P (at_left x) \ eventually P (at_right x)" + for x :: "'a::linorder_topology" by (subst at_eq_sup_left_right) (simp add: eventually_sup) + subsubsection \Tendsto\ abbreviation (in topological_space) - tendsto :: "('b \ 'a) \ 'a \ 'b filter \ bool" (infixr "\" 55) where - "(f \ l) F \ filterlim f (nhds l) F" - -definition (in t2_space) Lim :: "'f filter \ ('f \ 'a) \ 'a" where - "Lim A f = (THE l. (f \ l) A)" + tendsto :: "('b \ 'a) \ 'a \ 'b filter \ bool" (infixr "\" 55) + where "(f \ l) F \ filterlim f (nhds l) F" + +definition (in t2_space) Lim :: "'f filter \ ('f \ 'a) \ 'a" + where "Lim A f = (THE l. (f \ l) A)" lemma tendsto_eq_rhs: "(f \ x) F \ x = y \ (f \ y) F" by simp @@ -617,11 +672,8 @@ "(f \ l) F \ (\S. open S \ l \ S \ eventually (\x. f x \ S) F)" unfolding nhds_def filterlim_INF filterlim_principal by auto -lemma tendsto_cong: - assumes "eventually (\x. f x = g x) F" - shows "(f \ c) F \ (g \ c) F" - by (rule filterlim_cong[OF refl refl assms]) - +lemma tendsto_cong: "(f \ c) F \ (g \ c) F" if "eventually (\x. f x = g x) F" + by (rule filterlim_cong [OF refl refl that]) lemma tendsto_mono: "F \ F' \ (f \ l) F' \ (f \ l) F" unfolding tendsto_def le_filter_def by fast @@ -630,46 +682,48 @@ by (blast intro: tendsto_mono at_le) lemma filterlim_at: - "(LIM x F. f x :> at b within s) \ (eventually (\x. f x \ s \ f x \ b) F \ (f \ b) F)" + "(LIM x F. f x :> at b within s) \ eventually (\x. f x \ s \ f x \ b) F \ (f \ b) F" by (simp add: at_within_def filterlim_inf filterlim_principal conj_commute) lemma (in topological_space) topological_tendstoI: "(\S. open S \ l \ S \ eventually (\x. f x \ S) F) \ (f \ l) F" - unfolding tendsto_def by auto + by (auto simp: tendsto_def) lemma (in topological_space) topological_tendstoD: "(f \ l) F \ open S \ l \ S \ eventually (\x. f x \ S) F" - unfolding tendsto_def by auto + by (auto simp: tendsto_def) lemma (in order_topology) order_tendsto_iff: "(f \ x) F \ (\lx. l < f x) F) \ (\u>x. eventually (\x. f x < u) F)" - unfolding nhds_order filterlim_inf filterlim_INF filterlim_principal by auto + by (auto simp: nhds_order filterlim_inf filterlim_INF filterlim_principal) lemma (in order_topology) order_tendstoI: "(\a. a < y \ eventually (\x. a < f x) F) \ (\a. y < a \ eventually (\x. f x < a) F) \ (f \ y) F" - unfolding order_tendsto_iff by auto + by (auto simp: order_tendsto_iff) lemma (in order_topology) order_tendstoD: assumes "(f \ y) F" shows "a < y \ eventually (\x. a < f x) F" and "y < a \ eventually (\x. f x < a) F" - using assms unfolding order_tendsto_iff by auto + using assms by (auto simp: order_tendsto_iff) lemma tendsto_bot [simp]: "(f \ a) bot" - unfolding tendsto_def by simp + by (simp add: tendsto_def) lemma (in linorder_topology) tendsto_max: assumes X: "(X \ x) net" - assumes Y: "(Y \ y) net" + and Y: "(Y \ y) net" shows "((\x. max (X x) (Y x)) \ max x y) net" proof (rule order_tendstoI) - fix a assume "a < max x y" + fix a + assume "a < max x y" then show "eventually (\x. a < max (X x) (Y x)) net" using order_tendstoD(1)[OF X, of a] order_tendstoD(1)[OF Y, of a] by (auto simp: less_max_iff_disj elim: eventually_mono) next - fix a assume "max x y < a" + fix a + assume "max x y < a" then show "eventually (\x. max (X x) (Y x) < a) net" using order_tendstoD(2)[OF X, of a] order_tendstoD(2)[OF Y, of a] by (auto simp: eventually_conj_iff) @@ -677,28 +731,32 @@ lemma (in linorder_topology) tendsto_min: assumes X: "(X \ x) net" - assumes Y: "(Y \ y) net" + and Y: "(Y \ y) net" shows "((\x. min (X x) (Y x)) \ min x y) net" proof (rule order_tendstoI) - fix a assume "a < min x y" + fix a + assume "a < min x y" then show "eventually (\x. a < min (X x) (Y x)) net" using order_tendstoD(1)[OF X, of a] order_tendstoD(1)[OF Y, of a] by (auto simp: eventually_conj_iff) next - fix a assume "min x y < a" + fix a + assume "min x y < a" then show "eventually (\x. min (X x) (Y x) < a) net" using order_tendstoD(2)[OF X, of a] order_tendstoD(2)[OF Y, of a] by (auto simp: min_less_iff_disj elim: eventually_mono) qed lemma tendsto_ident_at [tendsto_intros, simp, intro]: "((\x. x) \ a) (at a within s)" - unfolding tendsto_def eventually_at_topological by auto + by (auto simp: tendsto_def eventually_at_topological) lemma (in topological_space) tendsto_const [tendsto_intros, simp, intro]: "((\x. k) \ k) F" by (simp add: tendsto_def) lemma (in t2_space) tendsto_unique: - assumes "F \ bot" and "(f \ a) F" and "(f \ b) F" + assumes "F \ bot" + and "(f \ a) F" + and "(f \ b) F" shows "a = b" proof (rule ccontr) assume "a \ b" @@ -713,7 +771,7 @@ have "eventually (\x. False) F" proof eventually_elim case (elim x) - hence "f x \ U \ V" by simp + then have "f x \ U \ V" by simp with \U \ V = {}\ show ?case by simp qed with \\ trivial_limit F\ show "False" @@ -721,20 +779,22 @@ qed lemma (in t2_space) tendsto_const_iff: - assumes "\ trivial_limit F" shows "((\x. a :: 'a) \ b) F \ a = b" + fixes a b :: 'a + assumes "\ trivial_limit F" + shows "((\x. a) \ b) F \ a = b" by (auto intro!: tendsto_unique [OF assms tendsto_const]) lemma increasing_tendsto: fixes f :: "_ \ 'a::order_topology" assumes bdd: "eventually (\n. f n \ l) F" - and en: "\x. x < l \ eventually (\n. x < f n) F" + and en: "\x. x < l \ eventually (\n. x < f n) F" shows "(f \ l) F" using assms by (intro order_tendstoI) (auto elim!: eventually_mono) lemma decreasing_tendsto: fixes f :: "_ \ 'a::order_topology" assumes bdd: "eventually (\n. l \ f n) F" - and en: "\x. l < x \ eventually (\n. f n < x) F" + and en: "\x. l < x \ eventually (\n. f n < x) F" shows "(f \ l) F" using assms by (intro order_tendstoI) (auto elim!: eventually_mono) @@ -744,40 +804,51 @@ assumes lim: "(f \ c) net" "(h \ c) net" shows "(g \ c) net" proof (rule order_tendstoI) - fix a show "a < c \ eventually (\x. a < g x) net" + fix a + show "a < c \ eventually (\x. a < g x) net" using order_tendstoD[OF lim(1), of a] ev by (auto elim: eventually_elim2) next - fix a show "c < a \ eventually (\x. g x < a) net" + fix a + show "c < a \ eventually (\x. g x < a) net" using order_tendstoD[OF lim(2), of a] ev by (auto elim: eventually_elim2) qed lemma limit_frequently_eq: + fixes c d :: "'a::t1_space" assumes "F \ bot" - assumes "frequently (\x. f x = c) F" - assumes "(f \ d) F" - shows "d = (c :: 'a :: t1_space)" + and "frequently (\x. f x = c) F" + and "(f \ d) F" + shows "d = c" proof (rule ccontr) assume "d \ c" - from t1_space[OF this] obtain U where "open U" "d \ U" "c \ U" by blast - from this assms have "eventually (\x. f x \ U) F" unfolding tendsto_def by blast - hence "eventually (\x. f x \ c) F" by eventually_elim (insert \c \ U\, blast) - with assms(2) show False unfolding frequently_def by contradiction + from t1_space[OF this] obtain U where "open U" "d \ U" "c \ U" + by blast + with assms have "eventually (\x. f x \ U) F" + unfolding tendsto_def by blast + then have "eventually (\x. f x \ c) F" + by eventually_elim (insert \c \ U\, blast) + with assms(2) show False + unfolding frequently_def by contradiction qed lemma tendsto_imp_eventually_ne: - assumes "F \ bot" "(f \ c) F" "c \ (c' :: 'a :: t1_space)" - shows "eventually (\z. f z \ c') F" + fixes c :: "'a::t1_space" + assumes "F \ bot" "(f \ c) F" "c \ c'" + shows "eventually (\z. f z \ c') F" proof (rule ccontr) - assume "\eventually (\z. f z \ c') F" - hence "frequently (\z. f z = c') F" by (simp add: frequently_def) - from limit_frequently_eq[OF assms(1) this assms(2)] and assms(3) show False by contradiction + assume "\ eventually (\z. f z \ c') F" + then have "frequently (\z. f z = c') F" + by (simp add: frequently_def) + from limit_frequently_eq[OF assms(1) this assms(2)] and assms(3) show False + by contradiction qed lemma tendsto_le: fixes f g :: "'a \ 'b::linorder_topology" assumes F: "\ trivial_limit F" - assumes x: "(f \ x) F" and y: "(g \ y) F" - assumes ev: "eventually (\x. g x \ f x) F" + and x: "(f \ x) F" + and y: "(g \ y) F" + and ev: "eventually (\x. g x \ f x) F" shows "y \ x" proof (rule ccontr) assume "\ y \ x" @@ -794,23 +865,24 @@ lemma tendsto_le_const: fixes f :: "'a \ 'b::linorder_topology" assumes F: "\ trivial_limit F" - assumes x: "(f \ x) F" and a: "eventually (\i. a \ f i) F" + and x: "(f \ x) F" + and ev: "eventually (\i. a \ f i) F" shows "a \ x" - using F x tendsto_const a by (rule tendsto_le) + using F x tendsto_const ev by (rule tendsto_le) lemma tendsto_ge_const: fixes f :: "'a \ 'b::linorder_topology" assumes F: "\ trivial_limit F" - assumes x: "(f \ x) F" and a: "eventually (\i. a \ f i) F" + and x: "(f \ x) F" + and ev: "eventually (\i. a \ f i) F" shows "a \ x" - by (rule tendsto_le [OF F tendsto_const x a]) + by (rule tendsto_le [OF F tendsto_const x ev]) subsubsection \Rules about @{const Lim}\ -lemma tendsto_Lim: - "\(trivial_limit net) \ (f \ l) net \ Lim net f = l" - unfolding Lim_def using tendsto_unique[of net f] by auto +lemma tendsto_Lim: "\ trivial_limit net \ (f \ l) net \ Lim net f = l" + unfolding Lim_def using tendsto_unique [of net f] by auto lemma Lim_ident_at: "\ trivial_limit (at x within s) \ Lim (at x within s) (\x. x) = x" by (rule tendsto_Lim[OF _ tendsto_ident_at]) auto @@ -818,20 +890,23 @@ lemma filterlim_at_bot_at_right: fixes f :: "'a::linorder_topology \ 'b::linorder" assumes mono: "\x y. Q x \ Q y \ x \ y \ f x \ f y" - assumes bij: "\x. P x \ f (g x) = x" "\x. P x \ Q (g x)" - assumes Q: "eventually Q (at_right a)" and bound: "\b. Q b \ a < b" - assumes P: "eventually P at_bot" + and bij: "\x. P x \ f (g x) = x" "\x. P x \ Q (g x)" + and Q: "eventually Q (at_right a)" + and bound: "\b. Q b \ a < b" + and P: "eventually P at_bot" shows "filterlim f at_bot (at_right a)" proof - from P obtain x where x: "\y. y \ x \ P y" unfolding eventually_at_bot_linorder by auto show ?thesis proof (intro filterlim_at_bot_le[THEN iffD2] allI impI) - fix z assume "z \ x" + fix z + assume "z \ x" with x have "P z" by auto have "eventually (\x. x \ g z) (at_right a)" using bound[OF bij(2)[OF \P z\]] - unfolding eventually_at_right[OF bound[OF bij(2)[OF \P z\]]] by (auto intro!: exI[of _ "g z"]) + unfolding eventually_at_right[OF bound[OF bij(2)[OF \P z\]]] + by (auto intro!: exI[of _ "g z"]) with Q show "eventually (\x. f x \ z) (at_right a)" by eventually_elim (metis bij \P z\ mono) qed @@ -840,46 +915,55 @@ lemma filterlim_at_top_at_left: fixes f :: "'a::linorder_topology \ 'b::linorder" assumes mono: "\x y. Q x \ Q y \ x \ y \ f x \ f y" - assumes bij: "\x. P x \ f (g x) = x" "\x. P x \ Q (g x)" - assumes Q: "eventually Q (at_left a)" and bound: "\b. Q b \ b < a" - assumes P: "eventually P at_top" + and bij: "\x. P x \ f (g x) = x" "\x. P x \ Q (g x)" + and Q: "eventually Q (at_left a)" + and bound: "\b. Q b \ b < a" + and P: "eventually P at_top" shows "filterlim f at_top (at_left a)" proof - from P obtain x where x: "\y. x \ y \ P y" unfolding eventually_at_top_linorder by auto show ?thesis proof (intro filterlim_at_top_ge[THEN iffD2] allI impI) - fix z assume "x \ z" + fix z + assume "x \ z" with x have "P z" by auto have "eventually (\x. g z \ x) (at_left a)" using bound[OF bij(2)[OF \P z\]] - unfolding eventually_at_left[OF bound[OF bij(2)[OF \P z\]]] by (auto intro!: exI[of _ "g z"]) + unfolding eventually_at_left[OF bound[OF bij(2)[OF \P z\]]] + by (auto intro!: exI[of _ "g z"]) with Q show "eventually (\x. z \ f x) (at_left a)" by eventually_elim (metis bij \P z\ mono) qed qed lemma filterlim_split_at: - "filterlim f F (at_left x) \ filterlim f F (at_right x) \ filterlim f F (at (x::'a::linorder_topology))" + "filterlim f F (at_left x) \ filterlim f F (at_right x) \ + filterlim f F (at x)" + for x :: "'a::linorder_topology" by (subst at_eq_sup_left_right) (rule filterlim_sup) lemma filterlim_at_split: - "filterlim f F (at (x::'a::linorder_topology)) \ filterlim f F (at_left x) \ filterlim f F (at_right x)" + "filterlim f F (at x) \ filterlim f F (at_left x) \ filterlim f F (at_right x)" + for x :: "'a::linorder_topology" by (subst at_eq_sup_left_right) (simp add: filterlim_def filtermap_sup) lemma eventually_nhds_top: - fixes P :: "'a :: {order_top, linorder_topology} \ bool" - assumes "(b::'a) < top" + fixes P :: "'a :: {order_top,linorder_topology} \ bool" + and b :: 'a + assumes "b < top" shows "eventually P (nhds top) \ (\bz. b < z \ P z))" unfolding eventually_nhds proof safe - fix S :: "'a set" assume "open S" "top \ S" + fix S :: "'a set" + assume "open S" "top \ S" note open_left[OF this \b < top\] moreover assume "\s\S. P s" ultimately show "\bz>b. P z" by (auto simp: subset_eq Ball_def) next - fix b assume "b < top" "\z>b. P z" + fix b + assume "b < top" "\z>b. P z" then show "\S. open S \ top \ S \ (\xa\S. P xa)" by (intro exI[of _ "{b <..}"]) auto qed @@ -889,55 +973,54 @@ unfolding tendsto_def eventually_at_filter eventually_inf_principal by (intro ext all_cong imp_cong) (auto elim!: eventually_mono) + subsection \Limits on sequences\ abbreviation (in topological_space) - LIMSEQ :: "[nat \ 'a, 'a] \ bool" - ("((_)/ \ (_))" [60, 60] 60) where - "X \ L \ (X \ L) sequentially" - -abbreviation (in t2_space) lim :: "(nat \ 'a) \ 'a" where - "lim X \ Lim sequentially X" - -definition (in topological_space) convergent :: "(nat \ 'a) \ bool" where - "convergent X = (\L. X \ L)" + LIMSEQ :: "[nat \ 'a, 'a] \ bool" ("((_)/ \ (_))" [60, 60] 60) + where "X \ L \ (X \ L) sequentially" + +abbreviation (in t2_space) lim :: "(nat \ 'a) \ 'a" + where "lim X \ Lim sequentially X" + +definition (in topological_space) convergent :: "(nat \ 'a) \ bool" + where "convergent X = (\L. X \ L)" lemma lim_def: "lim X = (THE L. X \ L)" unfolding Lim_def .. + subsubsection \Monotone sequences and subsequences\ -definition - monoseq :: "(nat \ 'a::order) \ bool" where - \\Definition of monotonicity. - The use of disjunction here complicates proofs considerably. - One alternative is to add a Boolean argument to indicate the direction. - Another is to develop the notions of increasing and decreasing first.\ - "monoseq X = ((\m. \n\m. X m \ X n) \ (\m. \n\m. X n \ X m))" - -abbreviation incseq :: "(nat \ 'a::order) \ bool" where - "incseq X \ mono X" +text \ + Definition of monotonicity. + The use of disjunction here complicates proofs considerably. + One alternative is to add a Boolean argument to indicate the direction. + Another is to develop the notions of increasing and decreasing first. +\ +definition monoseq :: "(nat \ 'a::order) \ bool" + where "monoseq X \ (\m. \n\m. X m \ X n) \ (\m. \n\m. X n \ X m)" + +abbreviation incseq :: "(nat \ 'a::order) \ bool" + where "incseq X \ mono X" lemma incseq_def: "incseq X \ (\m. \n\m. X n \ X m)" unfolding mono_def .. -abbreviation decseq :: "(nat \ 'a::order) \ bool" where - "decseq X \ antimono X" +abbreviation decseq :: "(nat \ 'a::order) \ bool" + where "decseq X \ antimono X" lemma decseq_def: "decseq X \ (\m. \n\m. X n \ X m)" unfolding antimono_def .. -definition - subseq :: "(nat \ nat) \ bool" where - \\Definition of subsequence\ - "subseq f \ (\m. \n>m. f m < f n)" - -lemma incseq_SucI: - "(\n. X n \ X (Suc n)) \ incseq X" - using lift_Suc_mono_le[of X] - by (auto simp: incseq_def) - -lemma incseqD: "\i j. incseq f \ i \ j \ f i \ f j" +text \Definition of subsequence.\ +definition subseq :: "(nat \ nat) \ bool" + where "subseq f \ (\m. \n>m. f m < f n)" + +lemma incseq_SucI: "(\n. X n \ X (Suc n)) \ incseq X" + using lift_Suc_mono_le[of X] by (auto simp: incseq_def) + +lemma incseqD: "incseq f \ i \ j \ f i \ f j" by (auto simp: incseq_def) lemma incseq_SucD: "incseq A \ A i \ A (Suc i)" @@ -949,12 +1032,10 @@ lemma incseq_const[simp, intro]: "incseq (\x. k)" unfolding incseq_def by auto -lemma decseq_SucI: - "(\n. X (Suc n) \ X n) \ decseq X" - using order.lift_Suc_mono_le[OF dual_order, of X] - by (auto simp: decseq_def) - -lemma decseqD: "\i j. decseq f \ i \ j \ f j \ f i" +lemma decseq_SucI: "(\n. X (Suc n) \ X n) \ decseq X" + using order.lift_Suc_mono_le[OF dual_order, of X] by (auto simp: decseq_def) + +lemma decseqD: "decseq f \ i \ j \ f j \ f i" by (auto simp: decseq_def) lemma decseq_SucD: "decseq A \ A (Suc i) \ A i" @@ -969,85 +1050,91 @@ lemma monoseq_iff: "monoseq X \ incseq X \ decseq X" unfolding monoseq_def incseq_def decseq_def .. -lemma monoseq_Suc: - "monoseq X \ (\n. X n \ X (Suc n)) \ (\n. X (Suc n) \ X n)" +lemma monoseq_Suc: "monoseq X \ (\n. X n \ X (Suc n)) \ (\n. X (Suc n) \ X n)" unfolding monoseq_iff incseq_Suc_iff decseq_Suc_iff .. -lemma monoI1: "\m. \ n \ m. X m \ X n ==> monoseq X" -by (simp add: monoseq_def) - -lemma monoI2: "\m. \ n \ m. X n \ X m ==> monoseq X" -by (simp add: monoseq_def) - -lemma mono_SucI1: "\n. X n \ X (Suc n) ==> monoseq X" -by (simp add: monoseq_Suc) - -lemma mono_SucI2: "\n. X (Suc n) \ X n ==> monoseq X" -by (simp add: monoseq_Suc) +lemma monoI1: "\m. \n \ m. X m \ X n \ monoseq X" + by (simp add: monoseq_def) + +lemma monoI2: "\m. \n \ m. X n \ X m \ monoseq X" + by (simp add: monoseq_def) + +lemma mono_SucI1: "\n. X n \ X (Suc n) \ monoseq X" + by (simp add: monoseq_Suc) + +lemma mono_SucI2: "\n. X (Suc n) \ X n \ monoseq X" + by (simp add: monoseq_Suc) lemma monoseq_minus: fixes a :: "nat \ 'a::ordered_ab_group_add" assumes "monoseq a" shows "monoseq (\ n. - a n)" -proof (cases "\ m. \ n \ m. a m \ a n") +proof (cases "\m. \n \ m. a m \ a n") case True - hence "\ m. \ n \ m. - a n \ - a m" by auto - thus ?thesis by (rule monoI2) + then have "\m. \n \ m. - a n \ - a m" by auto + then show ?thesis by (rule monoI2) next case False - hence "\ m. \ n \ m. - a m \ - a n" using \monoseq a\[unfolded monoseq_def] by auto - thus ?thesis by (rule monoI1) + then have "\m. \n \ m. - a m \ - a n" + using \monoseq a\[unfolded monoseq_def] by auto + then show ?thesis by (rule monoI1) qed -text\Subsequence (alternative definition, (e.g. Hoskins)\ - -lemma subseq_Suc_iff: "subseq f = (\n. (f n) < (f (Suc n)))" -apply (simp add: subseq_def) -apply (auto dest!: less_imp_Suc_add) -apply (induct_tac k) -apply (auto intro: less_trans) -done + +text \Subsequence (alternative definition, (e.g. Hoskins)\ + +lemma subseq_Suc_iff: "subseq f \ (\n. f n < f (Suc n))" + apply (simp add: subseq_def) + apply (auto dest!: less_imp_Suc_add) + apply (induct_tac k) + apply (auto intro: less_trans) + done lemma subseq_add: "subseq (\n. n + k)" by (auto simp: subseq_Suc_iff) -text\for any sequence, there is a monotonic subsequence\ +text \For any sequence, there is a monotonic subsequence.\ lemma seq_monosub: - fixes s :: "nat => 'a::linorder" + fixes s :: "nat \ 'a::linorder" shows "\f. subseq f \ monoseq (\n. (s (f n)))" -proof cases - assume "\n. \p>n. \m\p. s m \ s p" +proof (cases "\n. \p>n. \m\p. s m \ s p") + case True then have "\f. \n. (\m\f n. s m \ s (f n)) \ f n < f (Suc n)" by (intro dependent_nat_choice) (auto simp: conj_commute) - then obtain f where "subseq f" and mono: "\n m. f n \ m \ s m \ s (f n)" + then obtain f where f: "subseq f" and mono: "\n m. f n \ m \ s m \ s (f n)" by (auto simp: subseq_Suc_iff) - moreover then have "incseq f" unfolding subseq_Suc_iff incseq_Suc_iff by (auto intro: less_imp_le) then have "monoseq (\n. s (f n))" by (auto simp add: incseq_def intro!: mono monoI2) - ultimately show ?thesis + with f show ?thesis by auto next - assume "\ (\n. \p>n. (\m\p. s m \ s p))" - then obtain N where N: "\p. p > N \ \m>p. s p < s m" by (force simp: not_le le_less) + case False + then obtain N where N: "p > N \ \m>p. s p < s m" for p + by (force simp: not_le le_less) have "\f. \n. N < f n \ f n < f (Suc n) \ s (f n) \ s (f (Suc n))" proof (intro dependent_nat_choice) - fix x assume "N < x" with N[of x] show "\y>N. x < y \ s x \ s y" + fix x + assume "N < x" with N[of x] + show "\y>N. x < y \ s x \ s y" by (auto intro: less_trans) qed auto then show ?thesis by (auto simp: monoseq_iff incseq_Suc_iff subseq_Suc_iff) qed -lemma seq_suble: assumes sf: "subseq f" shows "n \ f n" -proof(induct n) - case 0 thus ?case by simp +lemma seq_suble: + assumes sf: "subseq f" + shows "n \ f n" +proof (induct n) + case 0 + show ?case by simp next case (Suc n) - from sf[unfolded subseq_Suc_iff, rule_format, of n] Suc.hyps - have "n < f (Suc n)" by arith - thus ?case by arith + with sf [unfolded subseq_Suc_iff, rule_format, of n] have "n < f (Suc n)" + by arith + then show ?case by arith qed lemma eventually_subseq: @@ -1055,10 +1142,10 @@ unfolding eventually_sequentially by (metis seq_suble le_trans) lemma not_eventually_sequentiallyD: - assumes P: "\ eventually P sequentially" + assumes "\ eventually P sequentially" shows "\r. subseq r \ (\n. \ P (r n))" proof - - from P have "\n. \m\n. \ P m" + from assms have "\n. \m\n. \ P m" unfolding eventually_sequentially by (simp add: not_less) then obtain r where "\n. r n \ n" "\n. \ P (r n)" by (auto simp: choice_iff) @@ -1073,13 +1160,14 @@ lemma subseq_o: "subseq r \ subseq s \ subseq (r \ s)" unfolding subseq_def by simp -lemma subseq_mono: assumes "subseq r" "m < n" shows "r m < r n" - using assms by (auto simp: subseq_def) +lemma subseq_mono: "subseq r \ m < n \ r m < r n" + by (auto simp: subseq_def) lemma subseq_imp_inj_on: "subseq g \ inj_on g A" proof (rule inj_onI) assume g: "subseq g" - fix x y assume "g x = g y" + fix x y + assume "g x = g y" with subseq_mono[OF g, of x y] subseq_mono[OF g, of y x] show "x = y" by (cases x y rule: linorder_cases) simp_all qed @@ -1093,15 +1181,16 @@ lemma decseq_imp_monoseq: "decseq X \ monoseq X" by (simp add: decseq_def monoseq_def) -lemma decseq_eq_incseq: - fixes X :: "nat \ 'a::ordered_ab_group_add" shows "decseq X = incseq (\n. - X n)" +lemma decseq_eq_incseq: "decseq X = incseq (\n. - X n)" + for X :: "nat \ 'a::ordered_ab_group_add" by (simp add: decseq_def incseq_def) lemma INT_decseq_offset: assumes "decseq F" shows "(\i. F i) = (\i\{n..}. F i)" proof safe - fix x i assume x: "x \ (\i\{n..}. F i)" + fix x i + assume x: "x \ (\i\{n..}. F i)" show "x \ F i" proof cases from x have "x \ F n" by auto @@ -1111,99 +1200,97 @@ qed (insert x, simp) qed auto -lemma LIMSEQ_const_iff: - fixes k l :: "'a::t2_space" - shows "(\n. k) \ l \ k = l" +lemma LIMSEQ_const_iff: "(\n. k) \ l \ k = l" + for k l :: "'a::t2_space" using trivial_limit_sequentially by (rule tendsto_const_iff) -lemma LIMSEQ_SUP: - "incseq X \ X \ (SUP i. X i :: 'a :: {complete_linorder, linorder_topology})" +lemma LIMSEQ_SUP: "incseq X \ X \ (SUP i. X i :: 'a::{complete_linorder,linorder_topology})" by (intro increasing_tendsto) - (auto simp: SUP_upper less_SUP_iff incseq_def eventually_sequentially intro: less_le_trans) - -lemma LIMSEQ_INF: - "decseq X \ X \ (INF i. X i :: 'a :: {complete_linorder, linorder_topology})" + (auto simp: SUP_upper less_SUP_iff incseq_def eventually_sequentially intro: less_le_trans) + +lemma LIMSEQ_INF: "decseq X \ X \ (INF i. X i :: 'a::{complete_linorder,linorder_topology})" by (intro decreasing_tendsto) - (auto simp: INF_lower INF_less_iff decseq_def eventually_sequentially intro: le_less_trans) - -lemma LIMSEQ_ignore_initial_segment: - "f \ a \ (\n. f (n + k)) \ a" - unfolding tendsto_def - by (subst eventually_sequentially_seg[where k=k]) - -lemma LIMSEQ_offset: - "(\n. f (n + k)) \ a \ f \ a" + (auto simp: INF_lower INF_less_iff decseq_def eventually_sequentially intro: le_less_trans) + +lemma LIMSEQ_ignore_initial_segment: "f \ a \ (\n. f (n + k)) \ a" + unfolding tendsto_def by (subst eventually_sequentially_seg[where k=k]) + +lemma LIMSEQ_offset: "(\n. f (n + k)) \ a \ f \ a" unfolding tendsto_def by (subst (asm) eventually_sequentially_seg[where k=k]) lemma LIMSEQ_Suc: "f \ l \ (\n. f (Suc n)) \ l" -by (drule_tac k="Suc 0" in LIMSEQ_ignore_initial_segment, simp) + by (drule LIMSEQ_ignore_initial_segment [where k="Suc 0"]) simp lemma LIMSEQ_imp_Suc: "(\n. f (Suc n)) \ l \ f \ l" -by (rule_tac k="Suc 0" in LIMSEQ_offset, simp) + by (rule LIMSEQ_offset [where k="Suc 0"]) simp lemma LIMSEQ_Suc_iff: "(\n. f (Suc n)) \ l = f \ l" -by (blast intro: LIMSEQ_imp_Suc LIMSEQ_Suc) - -lemma LIMSEQ_unique: - fixes a b :: "'a::t2_space" - shows "\X \ a; X \ b\ \ a = b" + by (blast intro: LIMSEQ_imp_Suc LIMSEQ_Suc) + +lemma LIMSEQ_unique: "X \ a \ X \ b \ a = b" + for a b :: "'a::t2_space" using trivial_limit_sequentially by (rule tendsto_unique) -lemma LIMSEQ_le_const: - "\X \ (x::'a::linorder_topology); \N. \n\N. a \ X n\ \ a \ x" +lemma LIMSEQ_le_const: "X \ x \ \N. \n\N. a \ X n \ a \ x" + for a x :: "'a::linorder_topology" using tendsto_le_const[of sequentially X x a] by (simp add: eventually_sequentially) -lemma LIMSEQ_le: - "\X \ x; Y \ y; \N. \n\N. X n \ Y n\ \ x \ (y::'a::linorder_topology)" +lemma LIMSEQ_le: "X \ x \ Y \ y \ \N. \n\N. X n \ Y n \ x \ y" + for x y :: "'a::linorder_topology" using tendsto_le[of sequentially Y y X x] by (simp add: eventually_sequentially) -lemma LIMSEQ_le_const2: - "\X \ (x::'a::linorder_topology); \N. \n\N. X n \ a\ \ x \ a" +lemma LIMSEQ_le_const2: "X \ x \ \N. \n\N. X n \ a \ x \ a" + for a x :: "'a::linorder_topology" by (rule LIMSEQ_le[of X x "\n. a"]) auto -lemma convergentD: "convergent X ==> \L. (X \ L)" -by (simp add: convergent_def) - -lemma convergentI: "(X \ L) ==> convergent X" -by (auto simp add: convergent_def) - -lemma convergent_LIMSEQ_iff: "convergent X = (X \ lim X)" -by (auto intro: theI LIMSEQ_unique simp add: convergent_def lim_def) +lemma convergentD: "convergent X \ \L. X \ L" + by (simp add: convergent_def) + +lemma convergentI: "X \ L \ convergent X" + by (auto simp add: convergent_def) + +lemma convergent_LIMSEQ_iff: "convergent X \ X \ lim X" + by (auto intro: theI LIMSEQ_unique simp add: convergent_def lim_def) lemma convergent_const: "convergent (\n. c)" - by (rule convergentI, rule tendsto_const) + by (rule convergentI) (rule tendsto_const) lemma monoseq_le: - "monoseq a \ a \ (x::'a::linorder_topology) \ - ((\ n. a n \ x) \ (\m. \n\m. a m \ a n)) \ ((\ n. x \ a n) \ (\m. \n\m. a n \ a m))" + "monoseq a \ a \ x \ + (\n. a n \ x) \ (\m. \n\m. a m \ a n) \ + (\n. x \ a n) \ (\m. \n\m. a n \ a m)" + for x :: "'a::linorder_topology" by (metis LIMSEQ_le_const LIMSEQ_le_const2 decseq_def incseq_def monoseq_iff) -lemma LIMSEQ_subseq_LIMSEQ: - "\ X \ L; subseq f \ \ (X o f) \ L" - unfolding comp_def by (rule filterlim_compose[of X, OF _ filterlim_subseq]) - -lemma convergent_subseq_convergent: - "\convergent X; subseq f\ \ convergent (X o f)" - unfolding convergent_def by (auto intro: LIMSEQ_subseq_LIMSEQ) - -lemma limI: "X \ L ==> lim X = L" +lemma LIMSEQ_subseq_LIMSEQ: "X \ L \ subseq f \ (X \ f) \ L" + unfolding comp_def by (rule filterlim_compose [of X, OF _ filterlim_subseq]) + +lemma convergent_subseq_convergent: "convergent X \ subseq f \ convergent (X \ f)" + by (auto simp: convergent_def intro: LIMSEQ_subseq_LIMSEQ) + +lemma limI: "X \ L \ lim X = L" by (rule tendsto_Lim) (rule trivial_limit_sequentially) -lemma lim_le: "convergent f \ (\n. f n \ (x::'a::linorder_topology)) \ lim f \ x" +lemma lim_le: "convergent f \ (\n. f n \ x) \ lim f \ x" + for x :: "'a::linorder_topology" using LIMSEQ_le_const2[of f "lim f" x] by (simp add: convergent_LIMSEQ_iff) lemma lim_const [simp]: "lim (\m. a) = a" by (simp add: limI) -subsubsection\Increasing and Decreasing Series\ - -lemma incseq_le: "incseq X \ X \ L \ X n \ (L::'a::linorder_topology)" + +subsubsection \Increasing and Decreasing Series\ + +lemma incseq_le: "incseq X \ X \ L \ X n \ L" + for L :: "'a::linorder_topology" by (metis incseq_def LIMSEQ_le_const) -lemma decseq_le: "decseq X \ X \ L \ (L::'a::linorder_topology) \ X n" +lemma decseq_le: "decseq X \ X \ L \ L \ X n" + for L :: "'a::linorder_topology" by (metis decseq_def LIMSEQ_le_const2) + subsection \First countable topologies\ class first_countable_topology = topological_space + @@ -1215,19 +1302,24 @@ "\i. open (A i)" "\i. x \ (A i)" "\S. open S \ x \ S \ eventually (\i. A i \ S) sequentially" proof atomize_elim - from first_countable_basis[of x] obtain A :: "nat \ 'a set" where - nhds: "\i. open (A i)" "\i. x \ A i" - and incl: "\S. open S \ x \ S \ \i. A i \ S" by auto + from first_countable_basis[of x] obtain A :: "nat \ 'a set" + where nhds: "\i. open (A i)" "\i. x \ A i" + and incl: "\S. open S \ x \ S \ \i. A i \ S" + by auto define F where "F n = (\i\n. A i)" for n show "\A. (\i. open (A i)) \ (\i. x \ A i) \ - (\S. open S \ x \ S \ eventually (\i. A i \ S) sequentially)" + (\S. open S \ x \ S \ eventually (\i. A i \ S) sequentially)" proof (safe intro!: exI[of _ F]) fix i - show "open (F i)" using nhds(1) by (auto simp: F_def) - show "x \ F i" using nhds(2) by (auto simp: F_def) + show "open (F i)" + using nhds(1) by (auto simp: F_def) + show "x \ F i" + using nhds(2) by (auto simp: F_def) next - fix S assume "open S" "x \ S" - from incl[OF this] obtain i where "F i \ S" unfolding F_def by auto + fix S + assume "open S" "x \ S" + from incl[OF this] obtain i where "F i \ S" + unfolding F_def by auto moreover have "\j. i \ j \ F j \ F i" by (simp add: Inf_superset_mono F_def image_mono) ultimately show "eventually (\i. F i \ S) sequentially" @@ -1240,22 +1332,23 @@ where "decseq X" "\n. open (X n)" "\n. x \ X n" "nhds x = (INF n. principal (X n))" proof - from first_countable_basis obtain A :: "nat \ 'a set" - where A: "\n. x \ A n" "\n. open (A n)" "\S. open S \ x \ S \ \i. A i \ S" + where *: "\n. x \ A n" "\n. open (A n)" "\S. open S \ x \ S \ \i. A i \ S" by metis show thesis proof show "decseq (\n. \i\n. A i)" by (simp add: antimono_iff_le_Suc atMost_Suc) - show "\n. x \ (\i\n. A i)" "\n. open (\i\n. A i)" - using A by auto + show "x \ (\i\n. A i)" "\n. open (\i\n. A i)" for n + using * by auto show "nhds x = (INF n. principal (\i\n. A i))" - using A unfolding nhds_def + using * + unfolding nhds_def apply - apply (rule INF_eq) - apply simp_all - apply fastforce + apply simp_all + apply fastforce apply (intro exI [of _ "\i\n. A i" for n] conjI open_INT) - apply auto + apply auto done qed qed @@ -1265,17 +1358,15 @@ "\i. open (A i)" "\i. x \ A i" "\F. (\n. F n \ A n) \ F \ x" proof atomize_elim - obtain A :: "nat \ 'a set" where A: + obtain A :: "nat \ 'a set" where *: "\i. open (A i)" "\i. x \ A i" "\S. open S \ x \ S \ eventually (\i. A i \ S) sequentially" by (rule countable_basis_at_decseq) blast - { - fix F S assume "\n. F n \ A n" "open S" "x \ S" - with A(3)[of S] have "eventually (\n. F n \ S) sequentially" - by (auto elim: eventually_mono simp: subset_eq) - } - with A show "\A. (\i. open (A i)) \ (\i. x \ A i) \ (\F. (\n. F n \ A n) \ F \ x)" + have "eventually (\n. F n \ S) sequentially" + if "\n. F n \ A n" "open S" "x \ S" for F S + using *(3)[of S] that by (auto elim: eventually_mono simp: subset_eq) + with * show "\A. (\i. open (A i)) \ (\i. x \ A i) \ (\F. (\n. F n \ A n) \ F \ x)" by (intro exI[of _ A]) (auto simp: tendsto_def) qed @@ -1283,20 +1374,23 @@ assumes "\f. (\n. f n \ s) \ f \ a \ eventually (\n. P (f n)) sequentially" shows "eventually P (inf (nhds a) (principal s))" proof (rule ccontr) - obtain A :: "nat \ 'a set" where A: + obtain A :: "nat \ 'a set" where *: "\i. open (A i)" "\i. a \ A i" "\F. \n. F n \ A n \ F \ a" by (rule countable_basis) blast assume "\ ?thesis" - with A have P: "\F. \n. F n \ s \ F n \ A n \ \ P (F n)" - unfolding eventually_inf_principal eventually_nhds by (intro choice) fastforce - then obtain F where F0: "\n. F n \ s" and F2: "\n. F n \ A n" and F3: "\n. \ P (F n)" + with * have "\F. \n. F n \ s \ F n \ A n \ \ P (F n)" + unfolding eventually_inf_principal eventually_nhds + by (intro choice) fastforce + then obtain F where F: "\n. F n \ s" and "\n. F n \ A n" and F': "\n. \ P (F n)" by blast - with A have "F \ a" by auto - hence "eventually (\n. P (F n)) sequentially" - using assms F0 by simp - thus "False" by (simp add: F3) + with * have "F \ a" + by auto + then have "eventually (\n. P (F n)) sequentially" + using assms F by simp + then show False + by (simp add: F') qed lemma (in first_countable_topology) eventually_nhds_within_iff_sequentially: @@ -1306,7 +1400,9 @@ assume "eventually P (inf (nhds a) (principal s))" then obtain S where "open S" "a \ S" "\x\S. x \ s \ P x" by (auto simp: eventually_inf_principal eventually_nhds) - moreover fix f assume "\n. f n \ s" "f \ a" + moreover + fix f + assume "\n. f n \ s" "f \ a" ultimately show "eventually (\n. P (f n)) sequentially" by (auto dest!: topological_tendstoD elim: eventually_mono) qed @@ -1316,49 +1412,45 @@ using eventually_nhds_within_iff_sequentially[of P a UNIV] by simp lemma tendsto_at_iff_sequentially: - fixes f :: "'a :: first_countable_topology \ _" - shows "(f \ a) (at x within s) \ (\X. (\i. X i \ s - {x}) \ X \ x \ ((f \ X) \ a))" - unfolding filterlim_def[of _ "nhds a"] le_filter_def eventually_filtermap at_within_def eventually_nhds_within_iff_sequentially comp_def + "(f \ a) (at x within s) \ (\X. (\i. X i \ s - {x}) \ X \ x \ ((f \ X) \ a))" + for f :: "'a::first_countable_topology \ _" + unfolding filterlim_def[of _ "nhds a"] le_filter_def eventually_filtermap + at_within_def eventually_nhds_within_iff_sequentially comp_def by metis + subsection \Function limit at a point\ -abbreviation - LIM :: "('a::topological_space \ 'b::topological_space) \ 'a \ 'b \ bool" - ("((_)/ \(_)/\ (_))" [60, 0, 60] 60) where - "f \a\ L \ (f \ L) (at a)" +abbreviation LIM :: "('a::topological_space \ 'b::topological_space) \ 'a \ 'b \ bool" + ("((_)/ \(_)/\ (_))" [60, 0, 60] 60) + where "f \a\ L \ (f \ L) (at a)" lemma tendsto_within_open: "a \ S \ open S \ (f \ l) (at a within S) \ (f \a\ l)" - unfolding tendsto_def by (simp add: at_within_open[where S=S]) + by (simp add: tendsto_def at_within_open[where S = S]) lemma tendsto_within_open_NO_MATCH: - fixes f :: "'a::topological_space \ 'b::topological_space" - shows "a \ S \ NO_MATCH UNIV S \ open S \ (f \ l)(at a within S) \ (f \ l)(at a)" -using tendsto_within_open by blast - -lemma LIM_const_not_eq[tendsto_intros]: - fixes a :: "'a::perfect_space" - fixes k L :: "'b::t2_space" - shows "k \ L \ \ (\x. k) \a\ L" + "a \ S \ NO_MATCH UNIV S \ open S \ (f \ l)(at a within S) \ (f \ l)(at a)" + for f :: "'a::topological_space \ 'b::topological_space" + using tendsto_within_open by blast + +lemma LIM_const_not_eq[tendsto_intros]: "k \ L \ \ (\x. k) \a\ L" + for a :: "'a::perfect_space" and k L :: "'b::t2_space" by (simp add: tendsto_const_iff) lemmas LIM_not_zero = LIM_const_not_eq [where L = 0] -lemma LIM_const_eq: - fixes a :: "'a::perfect_space" - fixes k L :: "'b::t2_space" - shows "(\x. k) \a\ L \ k = L" +lemma LIM_const_eq: "(\x. k) \a\ L \ k = L" + for a :: "'a::perfect_space" and k L :: "'b::t2_space" by (simp add: tendsto_const_iff) -lemma LIM_unique: - fixes a :: "'a::perfect_space" and L M :: "'b::t2_space" - shows "f \a\ L \ f \a\ M \ L = M" +lemma LIM_unique: "f \a\ L \ f \a\ M \ L = M" + for a :: "'a::perfect_space" and L M :: "'b::t2_space" using at_neq_bot by (rule tendsto_unique) -text \Limits are equal for functions equal except at limit point\ - -lemma LIM_equal: "\x. x \ a --> (f x = g x) \ (f \a\ l) \ (g \a\ l)" - unfolding tendsto_def eventually_at_topological by simp + +text \Limits are equal for functions equal except at limit point.\ +lemma LIM_equal: "\x. x \ a \ f x = g x \ (f \a\ l) \ (g \a\ l)" + by (simp add: tendsto_def eventually_at_topological) lemma LIM_cong: "a = b \ (\x. x \ b \ f x = g x) \ l = m \ (f \a\ l) \ (g \b\ m)" by (simp add: LIM_equal) @@ -1366,16 +1458,14 @@ lemma LIM_cong_limit: "f \x\ L \ K = L \ f \x\ K" by simp -lemma tendsto_at_iff_tendsto_nhds: - "g \l\ g l \ (g \ g l) (nhds l)" +lemma tendsto_at_iff_tendsto_nhds: "g \l\ g l \ (g \ g l) (nhds l)" unfolding tendsto_def eventually_at_filter by (intro ext all_cong imp_cong) (auto elim!: eventually_mono) -lemma tendsto_compose: - "g \l\ g l \ (f \ l) F \ ((\x. g (f x)) \ g l) F" +lemma tendsto_compose: "g \l\ g l \ (f \ l) F \ ((\x. g (f x)) \ g l) F" unfolding tendsto_at_iff_tendsto_nhds by (rule filterlim_compose[of g]) -lemma LIM_o: "\g \l\ g l; f \a\ l\ \ (g \ f) \a\ g l" +lemma LIM_o: "g \l\ g l \ f \a\ l \ (g \ f) \a\ g l" unfolding o_def by (rule tendsto_compose) lemma tendsto_compose_eventually: @@ -1383,16 +1473,17 @@ by (rule filterlim_compose[of g _ "at l"]) (auto simp add: filterlim_at) lemma LIM_compose_eventually: - assumes f: "f \a\ b" - assumes g: "g \b\ c" - assumes inj: "eventually (\x. f x \ b) (at a)" + assumes "f \a\ b" + and "g \b\ c" + and "eventually (\x. f x \ b) (at a)" shows "(\x. g (f x)) \a\ c" - using g f inj by (rule tendsto_compose_eventually) + using assms(2,1,3) by (rule tendsto_compose_eventually) lemma tendsto_compose_filtermap: "((g \ f) \ T) F \ (g \ T) (filtermap f F)" by (simp add: filterlim_def filtermap_filtermap comp_def) -subsubsection \Relation of LIM and LIMSEQ\ + +subsubsection \Relation of \LIM\ and \LIMSEQ\\ lemma (in first_countable_topology) sequentially_imp_eventually_within: "(\f. (\n. f n \ s \ f n \ a) \ f \ a \ eventually (\n. P (f n)) sequentially) \ @@ -1416,22 +1507,24 @@ shows "f \a\ l" using assms unfolding tendsto_def [where l=l] by (simp add: sequentially_imp_eventually_at) -lemma LIMSEQ_SEQ_conv: - "(\S. (\n. S n \ a) \ S \ (a::'a::first_countable_topology) \ (\n. X (S n)) \ L) = - (X \a\ (L::'b::topological_space))" +lemma LIMSEQ_SEQ_conv: "(\S. (\n. S n \ a) \ S \ a \ (\n. X (S n)) \ L) \ X \a\ L" + for a :: "'a::first_countable_topology" and L :: "'b::topological_space" using LIMSEQ_SEQ_conv2 LIMSEQ_SEQ_conv1 .. lemma sequentially_imp_eventually_at_left: - fixes a :: "'a :: {linorder_topology, first_countable_topology}" + fixes a :: "'a::{linorder_topology,first_countable_topology}" assumes b[simp]: "b < a" - assumes *: "\f. (\n. b < f n) \ (\n. f n < a) \ incseq f \ f \ a \ eventually (\n. P (f n)) sequentially" + and *: "\f. (\n. b < f n) \ (\n. f n < a) \ incseq f \ f \ a \ + eventually (\n. P (f n)) sequentially" shows "eventually P (at_left a)" proof (safe intro!: sequentially_imp_eventually_within) - fix X assume X: "\n. X n \ {..< a} \ X n \ a" "X \ a" + fix X + assume X: "\n. X n \ {..< a} \ X n \ a" "X \ a" show "eventually (\n. P (X n)) sequentially" proof (rule ccontr) - assume neg: "\ eventually (\n. P (X n)) sequentially" + assume neg: "\ ?thesis" have "\s. \n. (\ P (X (s n)) \ b < X (s n)) \ (X (s n) \ X (s (Suc n)) \ Suc (s n) \ s (Suc n))" + (is "\s. ?P s") proof (rule dependent_nat_choice) have "\ eventually (\n. b < X n \ P (X n)) sequentially" by (intro not_eventually_impI neg order_tendstoD(1) [OF X(2) b]) @@ -1440,36 +1533,47 @@ next fix x n have "\ eventually (\n. Suc x \ n \ b < X n \ X x < X n \ P (X n)) sequentially" - using X by (intro not_eventually_impI order_tendstoD(1)[OF X(2)] eventually_ge_at_top neg) auto + using X + by (intro not_eventually_impI order_tendstoD(1)[OF X(2)] eventually_ge_at_top neg) auto then show "\n. (\ P (X n) \ b < X n) \ (X x \ X n \ Suc x \ n)" by (auto dest!: not_eventuallyD) qed - then guess s .. - then have "\n. b < X (s n)" "\n. X (s n) < a" "incseq (\n. X (s n))" "(\n. X (s n)) \ a" "\n. \ P (X (s n))" - using X by (auto simp: subseq_Suc_iff Suc_le_eq incseq_Suc_iff intro!: LIMSEQ_subseq_LIMSEQ[OF \X \ a\, unfolded comp_def]) - from *[OF this(1,2,3,4)] this(5) show False by auto + then obtain s where "?P s" .. + with X have "b < X (s n)" + and "X (s n) < a" + and "incseq (\n. X (s n))" + and "(\n. X (s n)) \ a" + and "\ P (X (s n))" + for n + by (auto simp: subseq_Suc_iff Suc_le_eq incseq_Suc_iff + intro!: LIMSEQ_subseq_LIMSEQ[OF \X \ a\, unfolded comp_def]) + from *[OF this(1,2,3,4)] this(5) show False + by auto qed qed lemma tendsto_at_left_sequentially: - fixes a :: "_ :: {linorder_topology, first_countable_topology}" + fixes a b :: "'b::{linorder_topology,first_countable_topology}" assumes "b < a" - assumes *: "\S. (\n. S n < a) \ (\n. b < S n) \ incseq S \ S \ a \ (\n. X (S n)) \ L" + assumes *: "\S. (\n. S n < a) \ (\n. b < S n) \ incseq S \ S \ a \ + (\n. X (S n)) \ L" shows "(X \ L) (at_left a)" - using assms unfolding tendsto_def [where l=L] - by (simp add: sequentially_imp_eventually_at_left) + using assms by (simp add: tendsto_def [where l=L] sequentially_imp_eventually_at_left) lemma sequentially_imp_eventually_at_right: - fixes a :: "'a :: {linorder_topology, first_countable_topology}" + fixes a b :: "'a::{linorder_topology,first_countable_topology}" assumes b[simp]: "a < b" - assumes *: "\f. (\n. a < f n) \ (\n. f n < b) \ decseq f \ f \ a \ eventually (\n. P (f n)) sequentially" + assumes *: "\f. (\n. a < f n) \ (\n. f n < b) \ decseq f \ f \ a \ + eventually (\n. P (f n)) sequentially" shows "eventually P (at_right a)" proof (safe intro!: sequentially_imp_eventually_within) - fix X assume X: "\n. X n \ {a <..} \ X n \ a" "X \ a" + fix X + assume X: "\n. X n \ {a <..} \ X n \ a" "X \ a" show "eventually (\n. P (X n)) sequentially" proof (rule ccontr) - assume neg: "\ eventually (\n. P (X n)) sequentially" + assume neg: "\ ?thesis" have "\s. \n. (\ P (X (s n)) \ X (s n) < b) \ (X (s (Suc n)) \ X (s n) \ Suc (s n) \ s (Suc n))" + (is "\s. ?P s") proof (rule dependent_nat_choice) have "\ eventually (\n. X n < b \ P (X n)) sequentially" by (intro not_eventually_impI neg order_tendstoD(2) [OF X(2) b]) @@ -1478,35 +1582,45 @@ next fix x n have "\ eventually (\n. Suc x \ n \ X n < b \ X n < X x \ P (X n)) sequentially" - using X by (intro not_eventually_impI order_tendstoD(2)[OF X(2)] eventually_ge_at_top neg) auto + using X + by (intro not_eventually_impI order_tendstoD(2)[OF X(2)] eventually_ge_at_top neg) auto then show "\n. (\ P (X n) \ X n < b) \ (X n \ X x \ Suc x \ n)" by (auto dest!: not_eventuallyD) qed - then guess s .. - then have "\n. a < X (s n)" "\n. X (s n) < b" "decseq (\n. X (s n))" "(\n. X (s n)) \ a" "\n. \ P (X (s n))" - using X by (auto simp: subseq_Suc_iff Suc_le_eq decseq_Suc_iff intro!: LIMSEQ_subseq_LIMSEQ[OF \X \ a\, unfolded comp_def]) - from *[OF this(1,2,3,4)] this(5) show False by auto + then obtain s where "?P s" .. + with X have "a < X (s n)" + and "X (s n) < b" + and "decseq (\n. X (s n))" + and "(\n. X (s n)) \ a" + and "\ P (X (s n))" + for n + by (auto simp: subseq_Suc_iff Suc_le_eq decseq_Suc_iff + intro!: LIMSEQ_subseq_LIMSEQ[OF \X \ a\, unfolded comp_def]) + from *[OF this(1,2,3,4)] this(5) show False + by auto qed qed lemma tendsto_at_right_sequentially: fixes a :: "_ :: {linorder_topology, first_countable_topology}" assumes "a < b" - assumes *: "\S. (\n. a < S n) \ (\n. S n < b) \ decseq S \ S \ a \ (\n. X (S n)) \ L" + and *: "\S. (\n. a < S n) \ (\n. S n < b) \ decseq S \ S \ a \ + (\n. X (S n)) \ L" shows "(X \ L) (at_right a)" - using assms unfolding tendsto_def [where l=L] - by (simp add: sequentially_imp_eventually_at_right) + using assms by (simp add: tendsto_def [where l=L] sequentially_imp_eventually_at_right) + subsection \Continuity\ subsubsection \Continuity on a set\ -definition continuous_on :: "'a set \ ('a :: topological_space \ 'b :: topological_space) \ bool" where - "continuous_on s f \ (\x\s. (f \ f x) (at x within s))" +definition continuous_on :: "'a set \ ('a::topological_space \ 'b::topological_space) \ bool" + where "continuous_on s f \ (\x\s. (f \ f x) (at x within s))" lemma continuous_on_cong [cong]: "s = t \ (\x. x \ t \ f x = g x) \ continuous_on s f \ continuous_on t g" - unfolding continuous_on_def by (intro ball_cong filterlim_cong) (auto simp: eventually_at_filter) + unfolding continuous_on_def + by (intro ball_cong filterlim_cong) (auto simp: eventually_at_filter) lemma continuous_on_topological: "continuous_on s f \ @@ -1516,7 +1630,8 @@ lemma continuous_on_open_invariant: "continuous_on s f \ (\B. open B \ (\A. open A \ A \ s = f -` B \ s))" proof safe - fix B :: "'b set" assume "continuous_on s f" "open B" + fix B :: "'b set" + assume "continuous_on s f" "open B" then have "\x\f -` B \ s. (\A. open A \ x \ A \ s \ A \ f -` B)" by (auto simp: continuous_on_topological subset_eq Ball_def imp_conjL) then obtain A where "\x\f -` B \ s. open (A x) \ x \ A x \ s \ A x \ f -` B" @@ -1528,8 +1643,10 @@ show "continuous_on s f" unfolding continuous_on_topological proof safe - fix x B assume "x \ s" "open B" "f x \ B" - with B obtain A where A: "open A" "A \ s = f -` B \ s" by auto + fix x B + assume "x \ s" "open B" "f x \ B" + with B obtain A where A: "open A" "A \ s = f -` B \ s" + by auto with \x \ s\ \f x \ B\ show "\A. open A \ x \ A \ (\y\s. y \ A \ f y \ B)" by (intro exI[of _ A]) auto qed @@ -1542,22 +1659,24 @@ corollary continuous_imp_open_vimage: assumes "continuous_on s f" "open s" "open B" "f -` B \ s" - shows "open (f -` B)" -by (metis assms continuous_on_open_vimage le_iff_inf) + shows "open (f -` B)" + by (metis assms continuous_on_open_vimage le_iff_inf) corollary open_vimage[continuous_intros]: - assumes "open s" and "continuous_on UNIV f" + assumes "open s" + and "continuous_on UNIV f" shows "open (f -` s)" - using assms unfolding continuous_on_open_vimage [OF open_UNIV] - by simp + using assms by (simp add: continuous_on_open_vimage [OF open_UNIV]) lemma continuous_on_closed_invariant: "continuous_on s f \ (\B. closed B \ (\A. closed A \ A \ s = f -` B \ s))" proof - - have *: "\P Q::'b set\bool. (\A. P A \ Q (- A)) \ (\A. P A) \ (\A. Q A)" + have *: "(\A. P A \ Q (- A)) \ (\A. P A) \ (\A. Q A)" + for P Q :: "'b set \ bool" by (metis double_compl) show ?thesis - unfolding continuous_on_open_invariant by (intro *) (auto simp: open_closed[symmetric]) + unfolding continuous_on_open_invariant + by (intro *) (auto simp: open_closed[symmetric]) qed lemma continuous_on_closed_vimage: @@ -1566,12 +1685,15 @@ by (metis closed_Int Int_absorb Int_commute[of s] Int_assoc[of _ _ s]) corollary closed_vimage_Int[continuous_intros]: - assumes "closed s" and "continuous_on t f" and t: "closed t" + assumes "closed s" + and "continuous_on t f" + and t: "closed t" shows "closed (f -` s \ t)" - using assms unfolding continuous_on_closed_vimage [OF t] by simp + using assms by (simp add: continuous_on_closed_vimage [OF t]) corollary closed_vimage[continuous_intros]: - assumes "closed s" and "continuous_on UNIV f" + assumes "closed s" + and "continuous_on UNIV f" shows "closed (f -` s)" using closed_vimage_Int [OF assms] by simp @@ -1583,10 +1705,12 @@ lemma continuous_on_open_Union: "(\s. s \ S \ open s) \ (\s. s \ S \ continuous_on s f) \ continuous_on (\S) f" - unfolding continuous_on_def by safe (metis open_Union at_within_open UnionI) + unfolding continuous_on_def + by safe (metis open_Union at_within_open UnionI) lemma continuous_on_open_UN: - "(\s. s \ S \ open (A s)) \ (\s. s \ S \ continuous_on (A s) f) \ continuous_on (\s\S. A s) f" + "(\s. s \ S \ open (A s)) \ (\s. s \ S \ continuous_on (A s) f) \ + continuous_on (\s\S. A s) f" by (rule continuous_on_open_Union) auto lemma continuous_on_open_Un: @@ -1598,9 +1722,11 @@ by (auto simp add: continuous_on_closed_vimage closed_Un Int_Un_distrib) lemma continuous_on_If: - assumes closed: "closed s" "closed t" and cont: "continuous_on s f" "continuous_on t g" + assumes closed: "closed s" "closed t" + and cont: "continuous_on s f" "continuous_on t g" and P: "\x. x \ s \ \ P x \ f x = g x" "\x. x \ t \ P x \ f x = g x" - shows "continuous_on (s \ t) (\x. if P x then f x else g x)" (is "continuous_on _ ?h") + shows "continuous_on (s \ t) (\x. if P x then f x else g x)" + (is "continuous_on _ ?h") proof- from P have "\x\s. f x = ?h x" "\x\t. g x = ?h x" by auto @@ -1623,7 +1749,7 @@ unfolding continuous_on_def by (metis subset_eq tendsto_within_subset) lemma continuous_on_compose[continuous_intros]: - "continuous_on s f \ continuous_on (f ` s) g \ continuous_on s (g o f)" + "continuous_on s f \ continuous_on (f ` s) g \ continuous_on s (g \ f)" unfolding continuous_on_topological by simp metis lemma continuous_on_compose2: @@ -1632,13 +1758,15 @@ lemma continuous_on_generate_topology: assumes *: "open = generate_topology X" - assumes **: "\B. B \ X \ \C. open C \ C \ A = f -` B \ A" + and **: "\B. B \ X \ \C. open C \ C \ A = f -` B \ A" shows "continuous_on A f" unfolding continuous_on_open_invariant proof safe - fix B :: "'a set" assume "open B" then show "\C. open C \ C \ A = f -` B \ A" + fix B :: "'a set" + assume "open B" + then show "\C. open C \ C \ A = f -` B \ A" unfolding * - proof induction + proof induct case (UN K) then obtain C where "\k. k \ K \ open (C k)" "\k. k \ K \ C k \ A = f -` k \ A" by metis @@ -1648,47 +1776,53 @@ qed lemma continuous_onI_mono: - fixes f :: "'a::linorder_topology \ 'b::{dense_order, linorder_topology}" + fixes f :: "'a::linorder_topology \ 'b::{dense_order,linorder_topology}" assumes "open (f`A)" - assumes mono: "\x y. x \ A \ y \ A \ x \ y \ f x \ f y" + and mono: "\x y. x \ A \ y \ A \ x \ y \ f x \ f y" shows "continuous_on A f" proof (rule continuous_on_generate_topology[OF open_generated_order], safe) have monoD: "\x y. x \ A \ y \ A \ f x < f y \ x < y" by (auto simp: not_le[symmetric] mono) - - { fix a b assume "a \ A" "f a < b" - moreover - with open_right[OF \open (f`A)\, of "f a" b] obtain y where "f a < y" "{f a ..< y} \ f`A" + have "\x. x \ A \ f x < b \ a < x" if a: "a \ A" and fa: "f a < b" for a b + proof - + obtain y where "f a < y" "{f a ..< y} \ f`A" + using open_right[OF \open (f`A)\, of "f a" b] a fa by auto - moreover then obtain z where "f a < z" "z < min b y" + obtain z where z: "f a < z" "z < min b y" using dense[of "f a" "min b y"] \f a < y\ \f a < b\ by auto - moreover then obtain c where "z = f c" "c \ A" + then obtain c where "z = f c" "c \ A" using \{f a ..< y} \ f`A\[THEN subsetD, of z] by (auto simp: less_imp_le) - ultimately have "\x. x \ A \ f x < b \ a < x" - by (auto intro!: exI[of _ c] simp: monoD) } + with a z show ?thesis + by (auto intro!: exI[of _ c] simp: monoD) + qed then show "\C. open C \ C \ A = f -` {.. A" for b by (intro exI[of _ "(\x\{x\A. f x < b}. {..< x})"]) (auto intro: le_less_trans[OF mono] less_imp_le) - { fix a b assume "a \ A" "b < f a" + have "\x. x \ A \ b < f x \ x < a" if a: "a \ A" and fa: "b < f a" for a b + proof - + note a fa moreover - with open_left[OF \open (f`A)\, of "f a" b] obtain y where "y < f a" "{y <.. f a} \ f`A" + obtain y where "y < f a" "{y <.. f a} \ f`A" + using open_left[OF \open (f`A)\, of "f a" b] a fa by auto - moreover then obtain z where "max b y < z" "z < f a" + then obtain z where z: "max b y < z" "z < f a" using dense[of "max b y" "f a"] \y < f a\ \b < f a\ by auto - moreover then obtain c where "z = f c" "c \ A" + then obtain c where "z = f c" "c \ A" using \{y <.. f a} \ f`A\[THEN subsetD, of z] by (auto simp: less_imp_le) - ultimately have "\x. x \ A \ b < f x \ x < a" - by (auto intro!: exI[of _ c] simp: monoD) } + with a z show ?thesis + by (auto intro!: exI[of _ c] simp: monoD) + qed then show "\C. open C \ C \ A = f -` {b <..} \ A" for b by (intro exI[of _ "(\x\{x\A. b < f x}. {x <..})"]) (auto intro: less_le_trans[OF _ mono] less_imp_le) qed + subsubsection \Continuity at a point\ -definition continuous :: "'a::t2_space filter \ ('a \ 'b::topological_space) \ bool" where - "continuous F f \ (f \ f (Lim F (\x. x))) F" +definition continuous :: "'a::t2_space filter \ ('a \ 'b::topological_space) \ bool" + where "continuous F f \ (f \ f (Lim F (\x. x))) F" lemma continuous_bot[continuous_intros, simp]: "continuous bot f" unfolding continuous_def by auto @@ -1706,12 +1840,12 @@ lemma continuous_within_compose[continuous_intros]: "continuous (at x within s) f \ continuous (at (f x) within f ` s) g \ - continuous (at x within s) (g o f)" + continuous (at x within s) (g \ f)" by (simp add: continuous_within_topological) metis lemma continuous_within_compose2: "continuous (at x within s) f \ continuous (at (f x) within f ` s) g \ - continuous (at x within s) (\x. g (f x))" + continuous (at x within s) (\x. g (f x))" using continuous_within_compose[of x s f g] by (simp add: comp_def) lemma continuous_at: "continuous (at x) f \ f \x\ f x" @@ -1727,17 +1861,18 @@ "continuous_on s f \ (\x\s. continuous (at x within s) f)" unfolding continuous_on_def continuous_within .. -abbreviation isCont :: "('a::t2_space \ 'b::topological_space) \ 'a \ bool" where - "isCont f a \ continuous (at a) f" +abbreviation isCont :: "('a::t2_space \ 'b::topological_space) \ 'a \ bool" + where "isCont f a \ continuous (at a) f" lemma isCont_def: "isCont f a \ f \a\ f a" by (rule continuous_at) lemma isCont_cong: assumes "eventually (\x. f x = g x) (nhds x)" - shows "isCont f x \ isCont g x" + shows "isCont f x \ isCont g x" proof - - from assms have [simp]: "f x = g x" by (rule eventually_nhds_x_imp_x) + from assms have [simp]: "f x = g x" + by (rule eventually_nhds_x_imp_x) from assms have "eventually (\x. f x = g x) (at x)" by (auto simp: eventually_at_filter elim!: eventually_mono) with assms have "isCont f x \ isCont g x" unfolding isCont_def @@ -1768,9 +1903,9 @@ lemma continuous_on_tendsto_compose: assumes f_cont: "continuous_on s f" - assumes g: "(g \ l) F" - assumes l: "l \ s" - assumes ev: "\\<^sub>F x in F. g x \ s" + and g: "(g \ l) F" + and l: "l \ s" + and ev: "\\<^sub>Fx in F. g x \ s" shows "((\x. f (g x)) \ f l) F" proof - from f_cont l have f: "(f \ f l) (at l within s)" @@ -1788,27 +1923,35 @@ using continuous_at_imp_continuous_at_within continuous_within_compose2 by blast lemma filtermap_nhds_open_map: - assumes cont: "isCont f a" and open_map: "\S. open S \ open (f`S)" + assumes cont: "isCont f a" + and open_map: "\S. open S \ open (f`S)" shows "filtermap f (nhds a) = nhds (f a)" unfolding filter_eq_iff proof safe - fix P assume "eventually P (filtermap f (nhds a))" - then guess S unfolding eventually_filtermap eventually_nhds .. + fix P + assume "eventually P (filtermap f (nhds a))" + then obtain S where "open S" "a \ S" "\x\S. P (f x)" + by (auto simp: eventually_filtermap eventually_nhds) then show "eventually P (nhds (f a))" unfolding eventually_nhds by (intro exI[of _ "f`S"]) (auto intro!: open_map) qed (metis filterlim_iff tendsto_at_iff_tendsto_nhds isCont_def eventually_filtermap cont) lemma continuous_at_split: - "continuous (at (x::'a::linorder_topology)) f = (continuous (at_left x) f \ continuous (at_right x) f)" + "continuous (at x) f \ continuous (at_left x) f \ continuous (at_right x) f" + for x :: "'a::linorder_topology" by (simp add: continuous_within filterlim_at_split) -(* The following open/closed Collect lemmas are ported from Sébastien Gouëzel's Ergodic_Theory *) +text \ + The following open/closed Collect lemmas are ported from + Sébastien Gouëzel's \Ergodic_Theory\. +\ lemma open_Collect_neq: - fixes f g :: "'a :: topological_space \ 'b::t2_space" + fixes f g :: "'a::topological_space \ 'b::t2_space" assumes f: "continuous_on UNIV f" and g: "continuous_on UNIV g" shows "open {x. f x \ g x}" proof (rule openI) - fix t assume "t \ {x. f x \ g x}" + fix t + assume "t \ {x. f x \ g x}" then obtain U V where *: "open U" "open V" "f t \ U" "g t \ V" "U \ V = {}" by (auto simp add: separation_t2) with open_vimage[OF \open U\ f] open_vimage[OF \open V\ g] @@ -1817,26 +1960,27 @@ qed lemma closed_Collect_eq: - fixes f g :: "'a :: topological_space \ 'b::t2_space" + fixes f g :: "'a::topological_space \ 'b::t2_space" assumes f: "continuous_on UNIV f" and g: "continuous_on UNIV g" shows "closed {x. f x = g x}" using open_Collect_neq[OF f g] by (simp add: closed_def Collect_neg_eq) lemma open_Collect_less: - fixes f g :: "'a :: topological_space \ 'b::linorder_topology" + fixes f g :: "'a::topological_space \ 'b::linorder_topology" assumes f: "continuous_on UNIV f" and g: "continuous_on UNIV g" shows "open {x. f x < g x}" proof (rule openI) - fix t assume t: "t \ {x. f x < g x}" + fix t + assume t: "t \ {x. f x < g x}" show "\T. open T \ t \ T \ T \ {x. f x < g x}" - proof (cases) - assume "\z. f t < z \ z < g t" - then obtain z where z: "f t < z \ z < g t" by blast + proof (cases "\z. f t < z \ z < g t") + case True + then obtain z where "f t < z \ z < g t" by blast then show ?thesis using open_vimage[OF _ f, of "{..< z}"] open_vimage[OF _ g, of "{z <..}"] by (intro exI[of _ "f -` {.. g -` {z<..}"]) auto next - assume "\(\z. f t < z \ z < g t)" + case False then have *: "{g t ..} = {f t <..}" "{..< g t} = {.. f t}" using t by (auto intro: leI) show ?thesis @@ -1850,17 +1994,20 @@ lemma closed_Collect_le: fixes f g :: "'a :: topological_space \ 'b::linorder_topology" - assumes f: "continuous_on UNIV f" and g: "continuous_on UNIV g" + assumes f: "continuous_on UNIV f" + and g: "continuous_on UNIV g" shows "closed {x. f x \ g x}" - using open_Collect_less[OF g f] by (simp add: closed_def Collect_neg_eq[symmetric] not_le) + using open_Collect_less [OF g f] + by (simp add: closed_def Collect_neg_eq[symmetric] not_le) + subsubsection \Open-cover compactness\ context topological_space begin -definition compact :: "'a set \ bool" where - compact_eq_heine_borel: \ "This name is used for backwards compatibility" +definition compact :: "'a set \ bool" + where compact_eq_heine_borel: (* This name is used for backwards compatibility *) "compact S \ (\C. (\c\C. open c) \ S \ \C \ (\D\C. finite D \ S \ \D))" lemma compactI: @@ -1872,24 +2019,33 @@ by (auto intro!: compactI) lemma compactE: - assumes "compact s" and "\t\C. open t" and "s \ \C" + assumes "compact s" + and "\t\C. open t" + and "s \ \C" obtains C' where "C' \ C" and "finite C'" and "s \ \C'" using assms unfolding compact_eq_heine_borel by metis lemma compactE_image: - assumes "compact s" and "\t\C. open (f t)" and "s \ (\c\C. f c)" + assumes "compact s" + and "\t\C. open (f t)" + and "s \ (\c\C. f c)" obtains C' where "C' \ C" and "finite C'" and "s \ (\c\C'. f c)" using assms unfolding ball_simps [symmetric] by (metis (lifting) finite_subset_image compact_eq_heine_borel[of s]) lemma compact_Int_closed [intro]: - assumes "compact s" and "closed t" + assumes "compact s" + and "closed t" shows "compact (s \ t)" proof (rule compactI) - fix C assume C: "\c\C. open c" and cover: "s \ t \ \C" - from C \closed t\ have "\c\C \ {-t}. open c" by auto - moreover from cover have "s \ \(C \ {-t})" by auto - ultimately have "\D\C \ {-t}. finite D \ s \ \D" + fix C + assume C: "\c\C. open c" + assume cover: "s \ t \ \C" + from C \closed t\ have "\c\C \ {- t}. open c" + by auto + moreover from cover have "s \ \(C \ {- t})" + by auto + ultimately have "\D\C \ {- t}. finite D \ s \ \D" using \compact s\ unfolding compact_eq_heine_borel by auto then obtain D where "D \ C \ {- t} \ finite D \ s \ \D" .. then show "\D\C. finite D \ s \ t \ \D" @@ -1899,7 +2055,8 @@ lemma inj_setminus: "inj_on uminus (A::'a set set)" by (auto simp: inj_on_def) -subsection\ Finite intersection property\ + +subsection \Finite intersection property\ lemma compact_fip: "compact U \ @@ -1908,13 +2065,13 @@ proof (safe intro!: compact_eq_heine_borel[THEN iffD2]) fix A assume "compact U" - and A: "\a\A. closed a" "U \ \A = {}" - and fi: "\B \ A. finite B \ U \ \B \ {}" + assume A: "\a\A. closed a" "U \ \A = {}" + assume fin: "\B \ A. finite B \ U \ \B \ {}" from A have "(\a\uminus`A. open a) \ U \ \(uminus`A)" by auto with \compact U\ obtain B where "B \ A" "finite (uminus`B)" "U \ \(uminus`B)" unfolding compact_eq_heine_borel by (metis subset_image_iff) - with fi[THEN spec, of B] show False + with fin[THEN spec, of B] show False by (auto dest: finite_imageD intro: inj_setminus) next fix A @@ -1925,15 +2082,15 @@ with \?R\ obtain B where "B \ A" "finite (uminus`B)" "U \ \(uminus`B) = {}" by (metis subset_image_iff) then show "\T\A. finite T \ U \ \T" - by (auto intro!: exI[of _ B] inj_setminus dest: finite_imageD) + by (auto intro!: exI[of _ B] inj_setminus dest: finite_imageD) qed lemma compact_imp_fip: - "\compact S; - \T. T \ F \ closed T; - \F'. \finite F'; F' \ F\ \ S \ (\F') \ {}\ - \ S \ (\F) \ {}" - unfolding compact_fip by auto + assumes "compact S" + and "\T. T \ F \ closed T" + and "\F'. finite F' \ F' \ F \ S \ (\F') \ {}" + shows "S \ (\F) \ {}" + using assms unfolding compact_fip by auto lemma compact_imp_fip_image: assumes "compact s" @@ -1942,55 +2099,66 @@ shows "s \ (\i\I. f i) \ {}" proof - note \compact s\ - moreover from P have "\i \ f ` I. closed i" by blast + moreover from P have "\i \ f ` I. closed i" + by blast moreover have "\A. finite A \ A \ f ` I \ (s \ (\A) \ {})" - proof (rule, rule, erule conjE) + apply rule + apply rule + apply (erule conjE) + proof - fix A :: "'a set set" - assume "finite A" - moreover assume "A \ f ` I" - ultimately obtain B where "B \ I" and "finite B" and "A = f ` B" + assume "finite A" and "A \ f ` I" + then obtain B where "B \ I" and "finite B" and "A = f ` B" using finite_subset_image [of A f I] by blast - with Q [of B] show "s \ \A \ {}" by simp + with Q [of B] show "s \ \A \ {}" + by simp qed - ultimately have "s \ (\(f ` I)) \ {}" by (metis compact_imp_fip) + ultimately have "s \ (\(f ` I)) \ {}" + by (metis compact_imp_fip) then show ?thesis by simp qed end lemma (in t2_space) compact_imp_closed: - assumes "compact s" shows "closed s" -unfolding closed_def + assumes "compact s" + shows "closed s" + unfolding closed_def proof (rule openI) - fix y assume "y \ - s" + fix y + assume "y \ - s" let ?C = "\x\s. {u. open u \ x \ u \ eventually (\y. y \ u) (nhds y)}" note \compact s\ moreover have "\u\?C. open u" by simp moreover have "s \ \?C" proof - fix x assume "x \ s" + fix x + assume "x \ s" with \y \ - s\ have "x \ y" by clarsimp - hence "\u v. open u \ open v \ x \ u \ y \ v \ u \ v = {}" + then have "\u v. open u \ open v \ x \ u \ y \ v \ u \ v = {}" by (rule hausdorff) with \x \ s\ show "x \ \?C" unfolding eventually_nhds by auto qed ultimately obtain D where "D \ ?C" and "finite D" and "s \ \D" by (rule compactE) - from \D \ ?C\ have "\x\D. eventually (\y. y \ x) (nhds y)" by auto + from \D \ ?C\ have "\x\D. eventually (\y. y \ x) (nhds y)" + by auto with \finite D\ have "eventually (\y. y \ \D) (nhds y)" by (simp add: eventually_ball_finite) with \s \ \D\ have "eventually (\y. y \ s) (nhds y)" by (auto elim!: eventually_mono) - thus "\t. open t \ y \ t \ t \ - s" + then show "\t. open t \ y \ t \ t \ - s" by (simp add: eventually_nhds subset_eq) qed lemma compact_continuous_image: - assumes f: "continuous_on s f" and s: "compact s" + assumes f: "continuous_on s f" + and s: "compact s" shows "compact (f ` s)" proof (rule compactI) - fix C assume "\c\C. open c" and cover: "f`s \ \C" + fix C + assume "\c\C. open c" and cover: "f`s \ \C" with f have "\c\C. \A. open A \ A \ s = f -` c \ s" unfolding continuous_on_open_invariant by blast then obtain A where A: "\c\C. open (A c) \ A c \ s = f -` c \ s" @@ -2004,9 +2172,11 @@ lemma continuous_on_inv: fixes f :: "'a::topological_space \ 'b::t2_space" - assumes "continuous_on s f" "compact s" "\x\s. g (f x) = x" + assumes "continuous_on s f" + and "compact s" + and "\x\s. g (f x) = x" shows "continuous_on (f ` s) g" -unfolding continuous_on_topological + unfolding continuous_on_topological proof (clarsimp simp add: assms(3)) fix x :: 'a and B :: "'a set" assume "x \ s" and "open B" and "x \ B" @@ -2020,9 +2190,9 @@ unfolding Diff_eq by (intro compact_Int_closed closed_Compl) ultimately have "compact (f ` (s - B))" by (rule compact_continuous_image) - hence "closed (f ` (s - B))" + then have "closed (f ` (s - B))" by (rule compact_imp_closed) - hence "open (- f ` (s - B))" + then have "open (- f ` (s - B))" by (rule open_Compl) moreover have "f x \ - f ` (s - B)" using \x \ s\ and \x \ B\ by (simp add: 1) @@ -2034,7 +2204,8 @@ lemma continuous_on_inv_into: fixes f :: "'a::topological_space \ 'b::t2_space" - assumes s: "continuous_on s f" "compact s" and f: "inj_on f s" + assumes s: "continuous_on s f" "compact s" + and f: "inj_on f s" shows "continuous_on (f ` s) (the_inv_into s f)" by (rule continuous_on_inv[OF s]) (auto simp: the_inv_into_f_f[OF f]) @@ -2086,6 +2257,7 @@ shows "compact s \ s \ {} \ continuous_on s f \ (\x\s. \y\s. f x \ f y)" using compact_attains_inf[of "f ` s"] compact_continuous_image[of s f] by auto + subsection \Connectedness\ context topological_space @@ -2112,28 +2284,29 @@ end lemma connected_closed: - "connected s \ - ~ (\A B. closed A \ closed B \ s \ A \ B \ A \ B \ s = {} \ A \ s \ {} \ B \ s \ {})" -apply (simp add: connected_def del: ex_simps, safe) -apply (drule_tac x="-A" in spec) -apply (drule_tac x="-B" in spec) -apply (fastforce simp add: closed_def [symmetric]) -apply (drule_tac x="-A" in spec) -apply (drule_tac x="-B" in spec) -apply (fastforce simp add: open_closed [symmetric]) -done + "connected s \ + \ (\A B. closed A \ closed B \ s \ A \ B \ A \ B \ s = {} \ A \ s \ {} \ B \ s \ {})" + apply (simp add: connected_def del: ex_simps, safe) + apply (drule_tac x="-A" in spec) + apply (drule_tac x="-B" in spec) + apply (fastforce simp add: closed_def [symmetric]) + apply (drule_tac x="-A" in spec) + apply (drule_tac x="-B" in spec) + apply (fastforce simp add: open_closed [symmetric]) + done lemma connected_closedD: - "\connected s; A \ B \ s = {}; s \ A \ B; closed A; closed B\ \ A \ s = {} \ B \ s = {}" -by (simp add: connected_closed) + "\connected s; A \ B \ s = {}; s \ A \ B; closed A; closed B\ \ A \ s = {} \ B \ s = {}" + by (simp add: connected_closed) lemma connected_Union: - assumes cs: "\s. s \ S \ connected s" and ne: "\S \ {}" - shows "connected(\S)" + assumes cs: "\s. s \ S \ connected s" + and ne: "\S \ {}" + shows "connected(\S)" proof (rule connectedI) fix A B assume A: "open A" and B: "open B" and Alap: "A \ \S \ {}" and Blap: "B \ \S \ {}" - and disj: "A \ B \ \S = {}" and cover: "\S \ A \ B" + and disj: "A \ B \ \S = {}" and cover: "\S \ A \ B" have disjs:"\s. s \ S \ A \ B \ s = {}" using disj by auto obtain sa where sa: "sa \ S" "A \ sa \ {}" @@ -2151,38 +2324,41 @@ by (metis A B IntI Sup_upper sa sb disjs x cover empty_iff subset_trans) qed -lemma connected_Un: "\connected s; connected t; s \ t \ {}\ \ connected (s \ t)" +lemma connected_Un: "connected s \ connected t \ s \ t \ {} \ connected (s \ t)" using connected_Union [of "{s,t}"] by auto lemma connected_diff_open_from_closed: - assumes st: "s \ t" and tu: "t \ u" and s: "open s" - and t: "closed t" and u: "connected u" and ts: "connected (t - s)" + assumes st: "s \ t" + and tu: "t \ u" + and s: "open s" + and t: "closed t" + and u: "connected u" + and ts: "connected (t - s)" shows "connected(u - s)" proof (rule connectedI) fix A B assume AB: "open A" "open B" "A \ (u - s) \ {}" "B \ (u - s) \ {}" - and disj: "A \ B \ (u - s) = {}" and cover: "u - s \ A \ B" + and disj: "A \ B \ (u - s) = {}" + and cover: "u - s \ A \ B" then consider "A \ (t - s) = {}" | "B \ (t - s) = {}" - using st ts tu connectedD [of "t-s" "A" "B"] - by auto + using st ts tu connectedD [of "t-s" "A" "B"] by auto then show False proof cases case 1 then have "(A - t) \ (B \ s) \ u = {}" using disj st by auto - moreover have "u \ (A - t) \ (B \ s)" using 1 cover by auto + moreover have "u \ (A - t) \ (B \ s)" + using 1 cover by auto ultimately show False - using connectedD [of u "A - t" "B \ s"] AB s t 1 u - by auto + using connectedD [of u "A - t" "B \ s"] AB s t 1 u by auto next case 2 then have "(A \ s) \ (B - t) \ u = {}" - using disj st - by auto - moreover have "u \ (A \ s) \ (B - t)" using 2 cover by auto + using disj st by auto + moreover have "u \ (A \ s) \ (B - t)" + using 2 cover by auto ultimately show False - using connectedD [of u "A \ s" "B - t"] AB s t 2 u - by auto + using connectedD [of u "A \ s" "B - t"] AB s t 2 u by auto qed qed @@ -2190,7 +2366,8 @@ fixes S :: "'a::topological_space set" shows "connected S \ (\P::'a \ bool. continuous_on S P \ (\c. \s\S. P s = c))" proof safe - fix P :: "'a \ bool" assume "connected S" "continuous_on S P" + fix P :: "'a \ bool" + assume "connected S" "continuous_on S P" then have "\b. \A. open A \ A \ S = P -` {b} \ S" unfolding continuous_on_open_invariant by (simp add: open_discrete) from this[of True] this[of False] @@ -2200,17 +2377,20 @@ by (intro connectedD[OF \connected S\]) auto then show "\c. \s\S. P s = c" proof (rule disjE) - assume "t \ S = {}" then show ?thesis + assume "t \ S = {}" + then show ?thesis unfolding * by (intro exI[of _ False]) auto next - assume "f \ S = {}" then show ?thesis + assume "f \ S = {}" + then show ?thesis unfolding * by (intro exI[of _ True]) auto qed next assume P: "\P::'a \ bool. continuous_on S P \ (\c. \s\S. P s = c)" show "connected S" proof (rule connectedI) - fix A B assume *: "open A" "open B" "A \ S \ {}" "B \ S \ {}" "A \ B \ S = {}" "S \ A \ B" + fix A B + assume *: "open A" "open B" "A \ S \ {}" "B \ S \ {}" "A \ B \ S = {}" "S \ A \ B" have "continuous_on S (\x. x \ A)" unfolding continuous_on_open_invariant proof safe @@ -2220,30 +2400,29 @@ with * show "\T. open T \ T \ S = (\x. x \ A) -` C \ S" by (intro exI[of _ "(if True \ C then A else {}) \ (if False \ C then B else {})"]) auto qed - from P[rule_format, OF this] obtain c where "\s. s \ S \ (s \ A) = c" by blast + from P[rule_format, OF this] obtain c where "\s. s \ S \ (s \ A) = c" + by blast with * show False by (cases c) auto qed qed -lemma connectedD_const: - fixes P :: "'a::topological_space \ bool" - shows "connected S \ continuous_on S P \ \c. \s\S. P s = c" - unfolding connected_iff_const by auto +lemma connectedD_const: "connected S \ continuous_on S P \ \c. \s\S. P s = c" + for P :: "'a::topological_space \ bool" + by (auto simp: connected_iff_const) lemma connectedI_const: "(\P::'a::topological_space \ bool. continuous_on S P \ \c. \s\S. P s = c) \ connected S" - unfolding connected_iff_const by auto + by (auto simp: connected_iff_const) lemma connected_local_const: assumes "connected A" "a \ A" "b \ A" - assumes *: "\a\A. eventually (\b. f a = f b) (at a within A)" + and *: "\a\A. eventually (\b. f a = f b) (at a within A)" shows "f a = f b" proof - obtain S where S: "\a. a \ A \ a \ S a" "\a. a \ A \ open (S a)" "\a x. a \ A \ x \ S a \ x \ A \ f a = f x" using * unfolding eventually_at_topological by metis - let ?P = "\b\{b\A. f a = f b}. S b" and ?N = "\b\{b\A. f a \ f b}. S b" have "?P \ A = {} \ ?N \ A = {}" using \connected A\ S \a\A\ @@ -2261,28 +2440,31 @@ qed lemma (in linorder_topology) connectedD_interval: - assumes "connected U" and xy: "x \ U" "y \ U" and "x \ z" "z \ y" + assumes "connected U" + and xy: "x \ U" "y \ U" + and "x \ z" "z \ y" shows "z \ U" proof - have eq: "{.. {z<..} = - {z}" by auto - { assume "z \ U" "x < z" "z < y" - with xy have "\ connected U" - unfolding connected_def simp_thms - apply (rule_tac exI[of _ "{..< z}"]) - apply (rule_tac exI[of _ "{z <..}"]) - apply (auto simp add: eq) - done } + have "\ connected U" if "z \ U" "x < z" "z < y" + using xy that + apply (simp only: connected_def simp_thms) + apply (rule_tac exI[of _ "{..< z}"]) + apply (rule_tac exI[of _ "{z <..}"]) + apply (auto simp add: eq) + done with assms show "z \ U" by (metis less_le) qed lemma connected_continuous_image: assumes *: "continuous_on s f" - assumes "connected s" + and "connected s" shows "connected (f ` s)" proof (rule connectedI_const) - fix P :: "'b \ bool" assume "continuous_on (f ` s) P" + fix P :: "'b \ bool" + assume "continuous_on (f ` s) P" then have "continuous_on s (P \ f)" by (rule continuous_on_compose[OF *]) from connectedD_const[OF \connected s\ this] show "\c. \s\f ` s. P s = c" @@ -2296,7 +2478,8 @@ begin lemma Inf_notin_open: - assumes A: "open A" and bnd: "\a\A. x < a" + assumes A: "open A" + and bnd: "\a\A. x < a" shows "Inf A \ A" proof assume "Inf A \ A" @@ -2305,20 +2488,23 @@ with dense[of b "Inf A"] obtain c where "c < Inf A" "c \ A" by (auto simp: subset_eq) then show False - using cInf_lower[OF \c \ A\] bnd by (metis not_le less_imp_le bdd_belowI) + using cInf_lower[OF \c \ A\] bnd + by (metis not_le less_imp_le bdd_belowI) qed lemma Sup_notin_open: - assumes A: "open A" and bnd: "\a\A. a < x" + assumes A: "open A" + and bnd: "\a\A. a < x" shows "Sup A \ A" proof assume "Sup A \ A" - then obtain b where "Sup A < b" "{Sup A ..< b} \ A" - using open_right[of A "Sup A" x] assms by auto + with assms obtain b where "Sup A < b" "{Sup A ..< b} \ A" + using open_right[of A "Sup A" x] by auto with dense[of "Sup A" b] obtain c where "Sup A < c" "c \ A" by (auto simp: subset_eq) then show False - using cSup_upper[OF \c \ A\] bnd by (metis less_imp_le not_le bdd_aboveI) + using cSup_upper[OF \c \ A\] bnd + by (metis less_imp_le not_le bdd_aboveI) qed end @@ -2328,8 +2514,7 @@ fix x :: 'a obtain y where "x < y \ y < x" using ex_gt_or_lt [of x] .. - with Inf_notin_open[of "{x}" y] Sup_notin_open[of "{x}" y] - show "\ open {x}" + with Inf_notin_open[of "{x}" y] Sup_notin_open[of "{x}" y] show "\ open {x}" by auto qed @@ -2338,8 +2523,11 @@ assumes *: "\x y z. x \ U \ y \ U \ x \ z \ z \ y \ z \ U" shows "connected U" proof (rule connectedI) - { fix A B assume "open A" "open B" "A \ B \ U = {}" "U \ A \ B" - fix x y assume "x < y" "x \ A" "y \ B" "x \ U" "y \ U" + { + fix A B + assume "open A" "open B" "A \ B \ U = {}" "U \ A \ B" + fix x y + assume "x < y" "x \ A" "y \ B" "x \ U" "y \ U" let ?z = "Inf (B \ {x <..})" @@ -2351,8 +2539,8 @@ using \open B\ by (intro Inf_notin_open) auto ultimately have "?z \ A" using \x \ ?z\ \A \ B \ U = {}\ \x \ A\ \U \ A \ B\ by auto - - { assume "?z < y" + have "\b\B. b \ A \ b \ U" if "?z < y" + proof - obtain a where "?z < a" "{?z ..< a} \ A" using open_right[OF \open A\ \?z \ A\ \?z < y\] by auto moreover obtain b where "b \ B" "x < b" "b < min a y" @@ -2364,71 +2552,86 @@ moreover have "b \ U" using \x \ ?z\ \?z \ b\ \b < min a y\ by (intro *[OF \x \ U\ \y \ U\]) (auto simp: less_imp_le) - ultimately have "\b\B. b \ A \ b \ U" - by (intro bexI[of _ b]) auto } + ultimately show ?thesis + by (intro bexI[of _ b]) auto + qed then have False - using \?z \ y\ \?z \ A\ \y \ B\ \y \ U\ \A \ B \ U = {}\ unfolding le_less by blast } + using \?z \ y\ \?z \ A\ \y \ B\ \y \ U\ \A \ B \ U = {}\ + unfolding le_less by blast + } note not_disjoint = this fix A B assume AB: "open A" "open B" "U \ A \ B" "A \ B \ U = {}" moreover assume "A \ U \ {}" then obtain x where x: "x \ U" "x \ A" by auto moreover assume "B \ U \ {}" then obtain y where y: "y \ U" "y \ B" by auto moreover note not_disjoint[of B A y x] not_disjoint[of A B x y] - ultimately show False by (cases x y rule: linorder_cases) auto + ultimately show False + by (cases x y rule: linorder_cases) auto qed -lemma connected_iff_interval: - fixes U :: "'a :: linear_continuum_topology set" - shows "connected U \ (\x\U. \y\U. \z. x \ z \ z \ y \ z \ U)" +lemma connected_iff_interval: "connected U \ (\x\U. \y\U. \z. x \ z \ z \ y \ z \ U)" + for U :: "'a::linear_continuum_topology set" by (auto intro: connectedI_interval dest: connectedD_interval) lemma connected_UNIV[simp]: "connected (UNIV::'a::linear_continuum_topology set)" - unfolding connected_iff_interval by auto - -lemma connected_Ioi[simp]: "connected {a::'a::linear_continuum_topology <..}" - unfolding connected_iff_interval by auto - -lemma connected_Ici[simp]: "connected {a::'a::linear_continuum_topology ..}" - unfolding connected_iff_interval by auto - -lemma connected_Iio[simp]: "connected {..< a::'a::linear_continuum_topology}" - unfolding connected_iff_interval by auto - -lemma connected_Iic[simp]: "connected {.. a::'a::linear_continuum_topology}" + by (simp add: connected_iff_interval) + +lemma connected_Ioi[simp]: "connected {a<..}" + for a :: "'a::linear_continuum_topology" + by (auto simp: connected_iff_interval) + +lemma connected_Ici[simp]: "connected {a..}" + for a :: "'a::linear_continuum_topology" + by (auto simp: connected_iff_interval) + +lemma connected_Iio[simp]: "connected {.. A" "b \ A" shows "{a <..< b} \ A" - using connectedD_interval[OF A] by (simp add: subset_eq Ball_def less_imp_le) + assumes "connected A" "a \ A" "b \ A" shows "{a <..< b} \ A" + using connectedD_interval[OF assms] by (simp add: subset_eq Ball_def less_imp_le) lemma connected_contains_Icc: - assumes "connected (A :: ('a :: {linorder_topology}) set)" "a \ A" "b \ A" - shows "{a..b} \ A" + fixes A :: "'a::linorder_topology set" + assumes "connected A" "a \ A" "b \ A" + shows "{a..b} \ A" proof fix x assume "x \ {a..b}" - hence "x = a \ x = b \ x \ {a<.. A" using assms connected_contains_Ioo[of A a b] by auto + then have "x = a \ x = b \ x \ {a<.. A" + using assms connected_contains_Ioo[of A a b] by auto qed + subsection \Intermediate Value Theorem\ lemma IVT': - fixes f :: "'a :: linear_continuum_topology \ 'b :: linorder_topology" + fixes f :: "'a::linear_continuum_topology \ 'b::linorder_topology" assumes y: "f a \ y" "y \ f b" "a \ b" - assumes *: "continuous_on {a .. b} f" + and *: "continuous_on {a .. b} f" shows "\x. a \ x \ x \ b \ f x = y" proof - have "connected {a..b}" @@ -2441,7 +2644,7 @@ lemma IVT2': fixes f :: "'a :: linear_continuum_topology \ 'b :: linorder_topology" assumes y: "f b \ y" "y \ f a" "a \ b" - assumes *: "continuous_on {a .. b} f" + and *: "continuous_on {a .. b} f" shows "\x. a \ x \ x \ b \ f x = y" proof - have "connected {a..b}" @@ -2452,51 +2655,59 @@ qed lemma IVT: - fixes f :: "'a :: linear_continuum_topology \ 'b :: linorder_topology" - shows "f a \ y \ y \ f b \ a \ b \ (\x. a \ x \ x \ b \ isCont f x) \ \x. a \ x \ x \ b \ f x = y" + fixes f :: "'a::linear_continuum_topology \ 'b::linorder_topology" + shows "f a \ y \ y \ f b \ a \ b \ (\x. a \ x \ x \ b \ isCont f x) \ + \x. a \ x \ x \ b \ f x = y" by (rule IVT') (auto intro: continuous_at_imp_continuous_on) lemma IVT2: - fixes f :: "'a :: linear_continuum_topology \ 'b :: linorder_topology" - shows "f b \ y \ y \ f a \ a \ b \ (\x. a \ x \ x \ b \ isCont f x) \ \x. a \ x \ x \ b \ f x = y" + fixes f :: "'a::linear_continuum_topology \ 'b::linorder_topology" + shows "f b \ y \ y \ f a \ a \ b \ (\x. a \ x \ x \ b \ isCont f x) \ + \x. a \ x \ x \ b \ f x = y" by (rule IVT2') (auto intro: continuous_at_imp_continuous_on) lemma continuous_inj_imp_mono: - fixes f :: "'a::linear_continuum_topology \ 'b :: linorder_topology" + fixes f :: "'a::linear_continuum_topology \ 'b::linorder_topology" assumes x: "a < x" "x < b" - assumes cont: "continuous_on {a..b} f" - assumes inj: "inj_on f {a..b}" + and cont: "continuous_on {a..b} f" + and inj: "inj_on f {a..b}" shows "(f a < f x \ f x < f b) \ (f b < f x \ f x < f a)" proof - note I = inj_on_eq_iff[OF inj] - { assume "f x < f a" "f x < f b" + { + assume "f x < f a" "f x < f b" then obtain s t where "x \ s" "s \ b" "a \ t" "t \ x" "f s = f t" "f x < f s" using IVT'[of f x "min (f a) (f b)" b] IVT2'[of f x "min (f a) (f b)" a] x by (auto simp: continuous_on_subset[OF cont] less_imp_le) - with x I have False by auto } + with x I have False by auto + } moreover - { assume "f a < f x" "f b < f x" + { + assume "f a < f x" "f b < f x" then obtain s t where "x \ s" "s \ b" "a \ t" "t \ x" "f s = f t" "f s < f x" using IVT'[of f a "max (f a) (f b)" x] IVT2'[of f b "max (f a) (f b)" x] x by (auto simp: continuous_on_subset[OF cont] less_imp_le) - with x I have False by auto } + with x I have False by auto + } ultimately show ?thesis - using I[of a x] I[of x b] x less_trans[OF x] by (auto simp add: le_less less_imp_neq neq_iff) + using I[of a x] I[of x b] x less_trans[OF x] + by (auto simp add: le_less less_imp_neq neq_iff) qed lemma continuous_at_Sup_mono: - fixes f :: "'a :: {linorder_topology, conditionally_complete_linorder} \ 'b :: {linorder_topology, conditionally_complete_linorder}" + fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \ + 'b::{linorder_topology,conditionally_complete_linorder}" assumes "mono f" - assumes cont: "continuous (at_left (Sup S)) f" - assumes S: "S \ {}" "bdd_above S" + and cont: "continuous (at_left (Sup S)) f" + and S: "S \ {}" "bdd_above S" shows "f (Sup S) = (SUP s:S. f s)" proof (rule antisym) have f: "(f \ f (Sup S)) (at_left (Sup S))" using cont unfolding continuous_within . - show "f (Sup S) \ (SUP s:S. f s)" proof cases - assume "Sup S \ S" then show ?thesis + assume "Sup S \ S" + then show ?thesis by (rule cSUP_upper) (auto intro: bdd_above_image_mono S \mono f\) next assume "Sup S \ S" @@ -2522,18 +2733,19 @@ qed (intro cSUP_least \mono f\[THEN monoD] cSup_upper S) lemma continuous_at_Sup_antimono: - fixes f :: "'a :: {linorder_topology, conditionally_complete_linorder} \ 'b :: {linorder_topology, conditionally_complete_linorder}" + fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \ + 'b::{linorder_topology,conditionally_complete_linorder}" assumes "antimono f" - assumes cont: "continuous (at_left (Sup S)) f" - assumes S: "S \ {}" "bdd_above S" + and cont: "continuous (at_left (Sup S)) f" + and S: "S \ {}" "bdd_above S" shows "f (Sup S) = (INF s:S. f s)" proof (rule antisym) have f: "(f \ f (Sup S)) (at_left (Sup S))" using cont unfolding continuous_within . - show "(INF s:S. f s) \ f (Sup S)" proof cases - assume "Sup S \ S" then show ?thesis + assume "Sup S \ S" + then show ?thesis by (intro cINF_lower) (auto intro: bdd_below_image_antimono S \antimono f\) next assume "Sup S \ S" @@ -2559,18 +2771,19 @@ qed (intro cINF_greatest \antimono f\[THEN antimonoD] cSup_upper S) lemma continuous_at_Inf_mono: - fixes f :: "'a :: {linorder_topology, conditionally_complete_linorder} \ 'b :: {linorder_topology, conditionally_complete_linorder}" + fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \ + 'b::{linorder_topology,conditionally_complete_linorder}" assumes "mono f" - assumes cont: "continuous (at_right (Inf S)) f" - assumes S: "S \ {}" "bdd_below S" + and cont: "continuous (at_right (Inf S)) f" + and S: "S \ {}" "bdd_below S" shows "f (Inf S) = (INF s:S. f s)" proof (rule antisym) have f: "(f \ f (Inf S)) (at_right (Inf S))" using cont unfolding continuous_within . - show "(INF s:S. f s) \ f (Inf S)" proof cases - assume "Inf S \ S" then show ?thesis + assume "Inf S \ S" + then show ?thesis by (rule cINF_lower[rotated]) (auto intro: bdd_below_image_mono S \mono f\) next assume "Inf S \ S" @@ -2596,18 +2809,19 @@ qed (intro cINF_greatest \mono f\[THEN monoD] cInf_lower \bdd_below S\ \S \ {}\) lemma continuous_at_Inf_antimono: - fixes f :: "'a :: {linorder_topology, conditionally_complete_linorder} \ 'b :: {linorder_topology, conditionally_complete_linorder}" + fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \ + 'b::{linorder_topology,conditionally_complete_linorder}" assumes "antimono f" - assumes cont: "continuous (at_right (Inf S)) f" - assumes S: "S \ {}" "bdd_below S" + and cont: "continuous (at_right (Inf S)) f" + and S: "S \ {}" "bdd_below S" shows "f (Inf S) = (SUP s:S. f s)" proof (rule antisym) have f: "(f \ f (Inf S)) (at_right (Inf S))" using cont unfolding continuous_within . - show "f (Inf S) \ (SUP s:S. f s)" proof cases - assume "Inf S \ S" then show ?thesis + assume "Inf S \ S" + then show ?thesis by (rule cSUP_upper) (auto intro: bdd_above_image_antimono S \antimono f\) next assume "Inf S \ S" @@ -2632,14 +2846,15 @@ qed qed (intro cSUP_least \antimono f\[THEN antimonoD] cInf_lower S) + subsection \Uniform spaces\ class uniformity = fixes uniformity :: "('a \ 'a) filter" begin -abbreviation uniformity_on :: "'a set \ ('a \ 'a) filter" where - "uniformity_on s \ inf uniformity (principal (s\s))" +abbreviation uniformity_on :: "'a set \ ('a \ 'a) filter" + where "uniformity_on s \ inf uniformity (principal (s\s))" end @@ -2649,48 +2864,58 @@ by simp class open_uniformity = "open" + uniformity + - assumes open_uniformity: "\U. open U \ (\x\U. eventually (\(x', y). x' = x \ y \ U) uniformity)" + assumes open_uniformity: + "\U. open U \ (\x\U. eventually (\(x', y). x' = x \ y \ U) uniformity)" class uniform_space = open_uniformity + assumes uniformity_refl: "eventually E uniformity \ E (x, x)" - assumes uniformity_sym: "eventually E uniformity \ eventually (\(x, y). E (y, x)) uniformity" - assumes uniformity_trans: "eventually E uniformity \ \D. eventually D uniformity \ (\x y z. D (x, y) \ D (y, z) \ E (x, z))" + and uniformity_sym: "eventually E uniformity \ eventually (\(x, y). E (y, x)) uniformity" + and uniformity_trans: + "eventually E uniformity \ + \D. eventually D uniformity \ (\x y z. D (x, y) \ D (y, z) \ E (x, z))" begin subclass topological_space - proof qed (force elim: eventually_mono eventually_elim2 simp: split_beta' open_uniformity)+ + by standard (force elim: eventually_mono eventually_elim2 simp: split_beta' open_uniformity)+ lemma uniformity_bot: "uniformity \ bot" using uniformity_refl by auto lemma uniformity_trans': - "eventually E uniformity \ eventually (\((x, y), (y', z)). y = y' \ E (x, z)) (uniformity \\<^sub>F uniformity)" + "eventually E uniformity \ + eventually (\((x, y), (y', z)). y = y' \ E (x, z)) (uniformity \\<^sub>F uniformity)" by (drule uniformity_trans) (auto simp add: eventually_prod_same) lemma uniformity_transE: - assumes E: "eventually E uniformity" + assumes "eventually E uniformity" obtains D where "eventually D uniformity" "\x y z. D (x, y) \ D (y, z) \ E (x, z)" - using uniformity_trans[OF E] by auto + using uniformity_trans [OF assms] by auto lemma eventually_nhds_uniformity: - "eventually P (nhds x) \ eventually (\(x', y). x' = x \ P y) uniformity" (is "_ \ ?N P x") + "eventually P (nhds x) \ eventually (\(x', y). x' = x \ P y) uniformity" + (is "_ \ ?N P x") unfolding eventually_nhds proof safe assume *: "?N P x" - { fix x assume "?N P x" - then guess D by (rule uniformity_transE) note D = this - from D(1) have "?N (?N P) x" - by eventually_elim (insert D, force elim: eventually_mono split: prod.split) } + have "?N (?N P) x" if "?N P x" for x + proof - + from that obtain D where ev: "eventually D uniformity" + and D: "D (a, b) \ D (b, c) \ case (a, c) of (x', y) \ x' = x \ P y" for a b c + by (rule uniformity_transE) simp + from ev show ?thesis + by eventually_elim (insert ev D, force elim: eventually_mono split: prod.split) + qed then have "open {x. ?N P x}" by (simp add: open_uniformity) then show "\S. open S \ x \ S \ (\x\S. P x)" by (intro exI[of _ "{x. ?N P x}"]) (auto dest: uniformity_refl simp: *) qed (force simp add: open_uniformity elim: eventually_mono) + subsubsection \Totally bounded sets\ -definition totally_bounded :: "'a set \ bool" where - "totally_bounded S \ +definition totally_bounded :: "'a set \ bool" + where "totally_bounded S \ (\E. eventually E uniformity \ (\X. finite X \ (\s\S. \x\X. E (x, s))))" lemma totally_bounded_empty[iff]: "totally_bounded {}" @@ -2700,23 +2925,26 @@ by (fastforce simp add: totally_bounded_def) lemma totally_bounded_Union[intro]: - assumes M: "finite M" "\S. S \ M \ totally_bounded S" shows "totally_bounded (\M)" + assumes M: "finite M" "\S. S \ M \ totally_bounded S" + shows "totally_bounded (\M)" unfolding totally_bounded_def proof safe - fix E assume "eventually E uniformity" + fix E + assume "eventually E uniformity" with M obtain X where "\S\M. finite (X S) \ (\s\S. \x\X S. E (x, s))" by (metis totally_bounded_def) with \finite M\ show "\X. finite X \ (\s\\M. \x\X. E (x, s))" by (intro exI[of _ "\S\M. X S"]) force qed + subsubsection \Cauchy filter\ -definition cauchy_filter :: "'a filter \ bool" where - "cauchy_filter F \ F \\<^sub>F F \ uniformity" - -definition Cauchy :: "(nat \ 'a) \ bool" where - Cauchy_uniform: "Cauchy X = cauchy_filter (filtermap X sequentially)" +definition cauchy_filter :: "'a filter \ bool" + where "cauchy_filter F \ F \\<^sub>F F \ uniformity" + +definition Cauchy :: "(nat \ 'a) \ bool" + where Cauchy_uniform: "Cauchy X = cauchy_filter (filtermap X sequentially)" lemma Cauchy_uniform_iff: "Cauchy X \ (\P. eventually P uniformity \ (\N. \n\N. \m\N. P (X n, X m)))" @@ -2724,12 +2952,16 @@ eventually_filtermap eventually_sequentially proof safe let ?U = "\P. eventually P uniformity" - { fix P assume "?U P" "\P. ?U P \ (\Q. (\N. \n\N. Q (X n)) \ (\x y. Q x \ Q y \ P (x, y)))" + { + fix P + assume "?U P" "\P. ?U P \ (\Q. (\N. \n\N. Q (X n)) \ (\x y. Q x \ Q y \ P (x, y)))" then obtain Q N where "\n. n \ N \ Q (X n)" "\x y. Q x \ Q y \ P (x, y)" by metis then show "\N. \n\N. \m\N. P (X n, X m)" - by blast } - { fix P assume "?U P" and P: "\P. ?U P \ (\N. \n\N. \m\N. P (X n, X m))" + by blast + next + fix P + assume "?U P" and P: "\P. ?U P \ (\N. \n\N. \m\N. P (X n, X m))" then obtain Q where "?U Q" and Q: "\x y z. Q (x, y) \ Q (y, z) \ P (x, z)" by (auto elim: uniformity_transE) then have "?U (\x. Q x \ (\(x, y). Q (y, x)) x)" @@ -2739,25 +2971,32 @@ by auto show "\Q. (\N. \n\N. Q (X n)) \ (\x y. Q x \ Q y \ P (x, y))" proof (safe intro!: exI[of _ "\x. \n\N. Q (x, X n) \ Q (X n, x)"] exI[of _ N] N) - fix x y assume "\n\N. Q (x, X n) \ Q (X n, x)" "\n\N. Q (y, X n) \ Q (X n, y)" + fix x y + assume "\n\N. Q (x, X n) \ Q (X n, x)" "\n\N. Q (y, X n) \ Q (X n, y)" then have "Q (x, X N)" "Q (X N, y)" by auto then show "P (x, y)" by (rule Q) - qed } + qed + } qed lemma nhds_imp_cauchy_filter: - assumes *: "F \ nhds x" shows "cauchy_filter F" + assumes *: "F \ nhds x" + shows "cauchy_filter F" proof - have "F \\<^sub>F F \ nhds x \\<^sub>F nhds x" by (intro prod_filter_mono *) also have "\ \ uniformity" unfolding le_filter_def eventually_nhds_uniformity eventually_prod_same proof safe - fix P assume "eventually P uniformity" - then guess Ql by (rule uniformity_transE) note Ql = this - moreover note Ql(1)[THEN uniformity_sym] - ultimately show "\Q. eventually (\(x', y). x' = x \ Q y) uniformity \ (\x y. Q x \ Q y \ P (x, y))" + fix P + assume "eventually P uniformity" + then obtain Ql where ev: "eventually Ql uniformity" + and "Ql (x, y) \ Ql (y, z) \ P (x, z)" for x y z + by (rule uniformity_transE) simp + with ev[THEN uniformity_sym] + show "\Q. eventually (\(x', y). x' = x \ Q y) uniformity \ + (\x y. Q x \ Q y \ P (x, y))" by (rule_tac exI[of _ "\y. Ql (y, x) \ Ql (x, y)"]) (fastforce elim: eventually_elim2) qed finally show ?thesis @@ -2767,7 +3006,9 @@ lemma LIMSEQ_imp_Cauchy: "X \ x \ Cauchy X" unfolding Cauchy_uniform filterlim_def by (intro nhds_imp_cauchy_filter) -lemma Cauchy_subseq_Cauchy: assumes "Cauchy X" "subseq f" shows "Cauchy (X \ f)" +lemma Cauchy_subseq_Cauchy: + assumes "Cauchy X" "subseq f" + shows "Cauchy (X \ f)" unfolding Cauchy_uniform comp_def filtermap_filtermap[symmetric] cauchy_filter_def by (rule order_trans[OF _ \Cauchy X\[unfolded Cauchy_uniform cauchy_filter_def]]) (intro prod_filter_mono filtermap_mono filterlim_subseq[OF \subseq f\, unfolded filterlim_def]) @@ -2775,21 +3016,24 @@ lemma convergent_Cauchy: "convergent X \ Cauchy X" unfolding convergent_def by (erule exE, erule LIMSEQ_imp_Cauchy) -definition complete :: "'a set \ bool" where - complete_uniform: "complete S \ (\F \ principal S. F \ bot \ cauchy_filter F \ (\x\S. F \ nhds x))" +definition complete :: "'a set \ bool" + where complete_uniform: "complete S \ + (\F \ principal S. F \ bot \ cauchy_filter F \ (\x\S. F \ nhds x))" end + subsubsection \Uniformly continuous functions\ -definition uniformly_continuous_on :: "'a set \ ('a::uniform_space \ 'b::uniform_space) \ bool" where - uniformly_continuous_on_uniformity: "uniformly_continuous_on s f \ +definition uniformly_continuous_on :: "'a set \ ('a::uniform_space \ 'b::uniform_space) \ bool" + where uniformly_continuous_on_uniformity: "uniformly_continuous_on s f \ (LIM (x, y) (uniformity_on s). (f x, f y) :> uniformity)" lemma uniformly_continuous_onD: - "uniformly_continuous_on s f \ eventually E uniformity - \ eventually (\(x, y). x \ s \ y \ s \ E (f x, f y)) uniformity" - by (simp add: uniformly_continuous_on_uniformity filterlim_iff eventually_inf_principal split_beta' mem_Times_iff imp_conjL) + "uniformly_continuous_on s f \ eventually E uniformity \ + eventually (\(x, y). x \ s \ y \ s \ E (f x, f y)) uniformity" + by (simp add: uniformly_continuous_on_uniformity filterlim_iff + eventually_inf_principal split_beta' mem_Times_iff imp_conjL) lemma uniformly_continuous_on_const[continuous_intros]: "uniformly_continuous_on s (\x. c)" by (auto simp: uniformly_continuous_on_uniformity filterlim_iff uniformity_refl) @@ -2798,17 +3042,22 @@ by (auto simp: uniformly_continuous_on_uniformity filterlim_def) lemma uniformly_continuous_on_compose[continuous_intros]: - "uniformly_continuous_on s g \ uniformly_continuous_on (g`s) f \ uniformly_continuous_on s (\x. f (g x))" - using filterlim_compose[of "\(x, y). (f x, f y)" uniformity "uniformity_on (g`s)" "\(x, y). (g x, g y)" "uniformity_on s"] - by (simp add: split_beta' uniformly_continuous_on_uniformity filterlim_inf filterlim_principal eventually_inf_principal mem_Times_iff) - -lemma uniformly_continuous_imp_continuous: assumes f: "uniformly_continuous_on s f" shows "continuous_on s f" + "uniformly_continuous_on s g \ uniformly_continuous_on (g`s) f \ + uniformly_continuous_on s (\x. f (g x))" + using filterlim_compose[of "\(x, y). (f x, f y)" uniformity + "uniformity_on (g`s)" "\(x, y). (g x, g y)" "uniformity_on s"] + by (simp add: split_beta' uniformly_continuous_on_uniformity + filterlim_inf filterlim_principal eventually_inf_principal mem_Times_iff) + +lemma uniformly_continuous_imp_continuous: + assumes f: "uniformly_continuous_on s f" + shows "continuous_on s f" by (auto simp: filterlim_iff eventually_at_filter eventually_nhds_uniformity continuous_on_def elim: eventually_mono dest!: uniformly_continuous_onD[OF f]) + section \Product Topology\ - subsection \Product is a topological space\ instantiation prod :: (topological_space, topological_space) topological_space @@ -2821,12 +3070,12 @@ lemma open_prod_elim: assumes "open S" and "x \ S" obtains A B where "open A" and "open B" and "x \ A \ B" and "A \ B \ S" -using assms unfolding open_prod_def by fast + using assms unfolding open_prod_def by fast lemma open_prod_intro: assumes "\x. x \ S \ \A B. open A \ open B \ x \ A \ B \ A \ B \ S" shows "open S" -using assms unfolding open_prod_def by fast + using assms unfolding open_prod_def by fast instance proof @@ -2837,7 +3086,8 @@ assume "open S" "open T" show "open (S \ T)" proof (rule open_prod_intro) - fix x assume x: "x \ S \ T" + fix x + assume x: "x \ S \ T" from x have "x \ S" by simp obtain Sa Sb where A: "open Sa" "open Sb" "x \ Sa \ Sb" "Sa \ Sb \ S" using \open S\ and \x \ S\ by (rule open_prod_elim) @@ -2847,46 +3097,48 @@ let ?A = "Sa \ Ta" and ?B = "Sb \ Tb" have "open ?A \ open ?B \ x \ ?A \ ?B \ ?A \ ?B \ S \ T" using A B by (auto simp add: open_Int) - thus "\A B. open A \ open B \ x \ A \ B \ A \ B \ S \ T" + then show "\A B. open A \ open B \ x \ A \ B \ A \ B \ S \ T" by fast qed next fix K :: "('a \ 'b) set set" - assume "\S\K. open S" thus "open (\K)" + assume "\S\K. open S" + then show "open (\K)" unfolding open_prod_def by fast qed end -declare [[code abort: "open::('a::topological_space*'b::topological_space) set \ bool"]] +declare [[code abort: "open :: ('a::topological_space \ 'b::topological_space) set \ bool"]] lemma open_Times: "open S \ open T \ open (S \ T)" -unfolding open_prod_def by auto + unfolding open_prod_def by auto lemma fst_vimage_eq_Times: "fst -` S = S \ UNIV" -by auto + by auto lemma snd_vimage_eq_Times: "snd -` S = UNIV \ S" -by auto + by auto lemma open_vimage_fst: "open S \ open (fst -` S)" -by (simp add: fst_vimage_eq_Times open_Times) + by (simp add: fst_vimage_eq_Times open_Times) lemma open_vimage_snd: "open S \ open (snd -` S)" -by (simp add: snd_vimage_eq_Times open_Times) + by (simp add: snd_vimage_eq_Times open_Times) lemma closed_vimage_fst: "closed S \ closed (fst -` S)" -unfolding closed_open vimage_Compl [symmetric] -by (rule open_vimage_fst) + unfolding closed_open vimage_Compl [symmetric] + by (rule open_vimage_fst) lemma closed_vimage_snd: "closed S \ closed (snd -` S)" -unfolding closed_open vimage_Compl [symmetric] -by (rule open_vimage_snd) + unfolding closed_open vimage_Compl [symmetric] + by (rule open_vimage_snd) lemma closed_Times: "closed S \ closed T \ closed (S \ T)" proof - - have "S \ T = (fst -` S) \ (snd -` T)" by auto - thus "closed S \ closed T \ closed (S \ T)" + have "S \ T = (fst -` S) \ (snd -` T)" + by auto + then show "closed S \ closed T \ closed (S \ T)" by (simp add: closed_vimage_fst closed_vimage_snd closed_Int) qed @@ -2896,49 +3148,66 @@ lemma subset_snd_imageI: "A \ B \ S \ x \ A \ B \ snd ` S" unfolding image_def subset_eq by force -lemma open_image_fst: assumes "open S" shows "open (fst ` S)" +lemma open_image_fst: + assumes "open S" + shows "open (fst ` S)" proof (rule openI) - fix x assume "x \ fst ` S" - then obtain y where "(x, y) \ S" by auto + fix x + assume "x \ fst ` S" + then obtain y where "(x, y) \ S" + by auto then obtain A B where "open A" "open B" "x \ A" "y \ B" "A \ B \ S" using \open S\ unfolding open_prod_def by auto - from \A \ B \ S\ \y \ B\ have "A \ fst ` S" by (rule subset_fst_imageI) - with \open A\ \x \ A\ have "open A \ x \ A \ A \ fst ` S" by simp - then show "\T. open T \ x \ T \ T \ fst ` S" by - (rule exI) + from \A \ B \ S\ \y \ B\ have "A \ fst ` S" + by (rule subset_fst_imageI) + with \open A\ \x \ A\ have "open A \ x \ A \ A \ fst ` S" + by simp + then show "\T. open T \ x \ T \ T \ fst ` S" .. qed -lemma open_image_snd: assumes "open S" shows "open (snd ` S)" +lemma open_image_snd: + assumes "open S" + shows "open (snd ` S)" proof (rule openI) - fix y assume "y \ snd ` S" - then obtain x where "(x, y) \ S" by auto + fix y + assume "y \ snd ` S" + then obtain x where "(x, y) \ S" + by auto then obtain A B where "open A" "open B" "x \ A" "y \ B" "A \ B \ S" using \open S\ unfolding open_prod_def by auto - from \A \ B \ S\ \x \ A\ have "B \ snd ` S" by (rule subset_snd_imageI) - with \open B\ \y \ B\ have "open B \ y \ B \ B \ snd ` S" by simp - then show "\T. open T \ y \ T \ T \ snd ` S" by - (rule exI) + from \A \ B \ S\ \x \ A\ have "B \ snd ` S" + by (rule subset_snd_imageI) + with \open B\ \y \ B\ have "open B \ y \ B \ B \ snd ` S" + by simp + then show "\T. open T \ y \ T \ T \ snd ` S" .. qed lemma nhds_prod: "nhds (a, b) = nhds a \\<^sub>F nhds b" unfolding nhds_def proof (subst prod_filter_INF, auto intro!: antisym INF_greatest simp: principal_prod_principal) - fix S T assume "open S" "a \ S" "open T" "b \ T" + fix S T + assume "open S" "a \ S" "open T" "b \ T" then show "(INF x : {S. open S \ (a, b) \ S}. principal x) \ principal (S \ T)" by (intro INF_lower) (auto intro!: open_Times) next - fix S' assume "open S'" "(a, b) \ S'" + fix S' + assume "open S'" "(a, b) \ S'" then obtain S T where "open S" "a \ S" "open T" "b \ T" "S \ T \ S'" by (auto elim: open_prod_elim) - then show "(INF x : {S. open S \ a \ S}. INF y : {S. open S \ b \ S}. principal (x \ y)) \ principal S'" + then show "(INF x : {S. open S \ a \ S}. INF y : {S. open S \ b \ S}. + principal (x \ y)) \ principal S'" by (auto intro!: INF_lower2) qed + subsubsection \Continuity of operations\ lemma tendsto_fst [tendsto_intros]: assumes "(f \ a) F" shows "((\x. fst (f x)) \ fst a) F" proof (rule topological_tendstoI) - fix S assume "open S" and "fst a \ S" + fix S + assume "open S" and "fst a \ S" then have "open (fst -` S)" and "a \ fst -` S" by (simp_all add: open_vimage_fst) with assms have "eventually (\x. f x \ fst -` S) F" @@ -2951,7 +3220,8 @@ assumes "(f \ a) F" shows "((\x. snd (f x)) \ snd a) F" proof (rule topological_tendstoI) - fix S assume "open S" and "snd a \ S" + fix S + assume "open S" and "snd a \ S" then have "open (snd -` S)" and "a \ snd -` S" by (simp_all add: open_vimage_snd) with assms have "eventually (\x. f x \ snd -` S) F" @@ -2964,7 +3234,8 @@ assumes "(f \ a) F" and "(g \ b) F" shows "((\x. (f x, g x)) \ (a, b)) F" proof (rule topological_tendstoI) - fix S assume "open S" and "(a, b) \ S" + fix S + assume "open S" and "(a, b) \ S" then obtain A B where "open A" "open B" "a \ A" "b \ B" "A \ B \ S" unfolding open_prod_def by fast have "eventually (\x. f x \ A) F" @@ -2986,26 +3257,31 @@ lemma continuous_snd[continuous_intros]: "continuous F f \ continuous F (\x. snd (f x))" unfolding continuous_def by (rule tendsto_snd) -lemma continuous_Pair[continuous_intros]: "continuous F f \ continuous F g \ continuous F (\x. (f x, g x))" +lemma continuous_Pair[continuous_intros]: + "continuous F f \ continuous F g \ continuous F (\x. (f x, g x))" unfolding continuous_def by (rule tendsto_Pair) -lemma continuous_on_fst[continuous_intros]: "continuous_on s f \ continuous_on s (\x. fst (f x))" +lemma continuous_on_fst[continuous_intros]: + "continuous_on s f \ continuous_on s (\x. fst (f x))" unfolding continuous_on_def by (auto intro: tendsto_fst) -lemma continuous_on_snd[continuous_intros]: "continuous_on s f \ continuous_on s (\x. snd (f x))" +lemma continuous_on_snd[continuous_intros]: + "continuous_on s f \ continuous_on s (\x. snd (f x))" unfolding continuous_on_def by (auto intro: tendsto_snd) -lemma continuous_on_Pair[continuous_intros]: "continuous_on s f \ continuous_on s g \ continuous_on s (\x. (f x, g x))" +lemma continuous_on_Pair[continuous_intros]: + "continuous_on s f \ continuous_on s g \ continuous_on s (\x. (f x, g x))" unfolding continuous_on_def by (auto intro: tendsto_Pair) lemma continuous_on_swap[continuous_intros]: "continuous_on A prod.swap" - by (simp add: prod.swap_def continuous_on_fst continuous_on_snd continuous_on_Pair continuous_on_id) + by (simp add: prod.swap_def continuous_on_fst continuous_on_snd + continuous_on_Pair continuous_on_id) lemma continuous_on_swap_args: assumes "continuous_on (A\B) (\(x,y). d x y)" shows "continuous_on (B\A) (\(x,y). d y x)" proof - - have "(\(x,y). d y x) = (\(x,y). d x y) o prod.swap" + have "(\(x,y). d y x) = (\(x,y). d x y) \ prod.swap" by force then show ?thesis apply (rule ssubst) @@ -3024,32 +3300,36 @@ lemma isCont_Pair [simp]: "\isCont f a; isCont g a\ \ isCont (\x. (f x, g x)) a" by (fact continuous_Pair) + subsubsection \Separation axioms\ instance prod :: (t0_space, t0_space) t0_space proof - fix x y :: "'a \ 'b" assume "x \ y" - hence "fst x \ fst y \ snd x \ snd y" + fix x y :: "'a \ 'b" + assume "x \ y" + then have "fst x \ fst y \ snd x \ snd y" by (simp add: prod_eq_iff) - thus "\U. open U \ (x \ U) \ (y \ U)" + then show "\U. open U \ (x \ U) \ (y \ U)" by (fast dest: t0_space elim: open_vimage_fst open_vimage_snd) qed instance prod :: (t1_space, t1_space) t1_space proof - fix x y :: "'a \ 'b" assume "x \ y" - hence "fst x \ fst y \ snd x \ snd y" + fix x y :: "'a \ 'b" + assume "x \ y" + then have "fst x \ fst y \ snd x \ snd y" by (simp add: prod_eq_iff) - thus "\U. open U \ x \ U \ y \ U" + then show "\U. open U \ x \ U \ y \ U" by (fast dest: t1_space elim: open_vimage_fst open_vimage_snd) qed instance prod :: (t2_space, t2_space) t2_space proof - fix x y :: "'a \ 'b" assume "x \ y" - hence "fst x \ fst y \ snd x \ snd y" + fix x y :: "'a \ 'b" + assume "x \ y" + then have "fst x \ fst y \ snd x \ snd y" by (simp add: prod_eq_iff) - thus "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" + then show "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" by (fast dest: hausdorff elim: open_vimage_fst open_vimage_snd) qed