# HG changeset patch # User hoelzl # Date 1359628287 -3600 # Node ID 3de230ed05479067f5aff0347228a4c6324a7304 # Parent 501200635659a5c40d23013881270256310d44c4 introduce order topology diff -r 501200635659 -r 3de230ed0547 src/HOL/Limits.thy --- a/src/HOL/Limits.thy Thu Jan 31 11:31:22 2013 +0100 +++ b/src/HOL/Limits.thy Thu Jan 31 11:31:27 2013 +0100 @@ -469,6 +469,12 @@ apply (erule le_less_trans [OF dist_triangle]) done +lemma eventually_nhds_order: + "eventually P (nhds (a::'a::linorder_topology)) \ + (\S. open_interval S \ a \ S \ (\z\S. P z))" + (is "_ \ ?rhs") + unfolding eventually_nhds by (auto dest!: open_orderD dest: open_interval_imp_open) + lemma nhds_neq_bot [simp]: "nhds a \ bot" unfolding trivial_limit_def eventually_nhds by simp @@ -901,6 +907,36 @@ using le_less_trans by (rule eventually_elim2) qed +lemma increasing_tendsto: + fixes f :: "_ \ 'a::linorder_topology" + assumes bdd: "eventually (\n. f n \ l) F" + and en: "\x. x < l \ eventually (\n. x < f n) F" + shows "(f ---> l) F" +proof (rule topological_tendstoI) + fix S assume "open S" "l \ S" + then show "eventually (\x. f x \ S) F" + proof (induct rule: open_order_induct) + case (greaterThanLessThan a b) with en bdd show ?case + by (auto elim!: eventually_elim2) + qed (insert en bdd, auto elim!: eventually_elim1) +qed + +lemma decreasing_tendsto: + fixes f :: "_ \ 'a::linorder_topology" + assumes bdd: "eventually (\n. l \ f n) F" + and en: "\x. l < x \ eventually (\n. f n < x) F" + shows "(f ---> l) F" +proof (rule topological_tendstoI) + fix S assume "open S" "l \ S" + then show "eventually (\x. f x \ S) F" + proof (induct rule: open_order_induct) + case (greaterThanLessThan a b) + with en have "eventually (\n. f n < b) F" by auto + with bdd show ?case + by eventually_elim (insert greaterThanLessThan, auto) + qed (insert en bdd, auto elim!: eventually_elim1) +qed + subsubsection {* Distance and norms *} lemma tendsto_dist [tendsto_intros]: @@ -1002,22 +1038,25 @@ by (simp add: tendsto_const) qed -lemma real_tendsto_sandwich: - fixes f g h :: "'a \ real" +lemma tendsto_sandwich: + fixes f g h :: "'a \ 'b::linorder_topology" assumes ev: "eventually (\n. f n \ g n) net" "eventually (\n. g n \ h n) net" assumes lim: "(f ---> c) net" "(h ---> c) net" shows "(g ---> c) net" -proof - - have "((\n. g n - f n) ---> 0) net" - proof (rule metric_tendsto_imp_tendsto) - show "eventually (\n. dist (g n - f n) 0 \ dist (h n - f n) 0) net" - using ev by (rule eventually_elim2) (simp add: dist_real_def) - show "((\n. h n - f n) ---> 0) net" - using tendsto_diff[OF lim(2,1)] by simp - qed - from tendsto_add[OF this lim(1)] show ?thesis by simp +proof (rule topological_tendstoI) + fix S assume "open S" "c \ S" + from open_orderD[OF this] obtain T where "open_interval T" "c \ T" "T \ S" by auto + with lim[THEN topological_tendstoD, of T] + have "eventually (\x. f x \ T) net" "eventually (\x. h x \ T) net" + by (auto dest: open_interval_imp_open) + with ev have "eventually (\x. g x \ T) net" + by eventually_elim (insert `open_interval T`, auto dest: open_intervalD) + with `T \ S` show "eventually (\x. g x \ S) net" + by (auto elim: eventually_elim1) qed +lemmas real_tendsto_sandwich = tendsto_sandwich[where 'b=real] + subsubsection {* Linear operators and multiplication *} lemma (in bounded_linear) tendsto: @@ -1082,29 +1121,33 @@ by (simp add: tendsto_const) qed -lemma tendsto_le_const: - fixes f :: "_ \ real" +lemma tendsto_le: + fixes f g :: "'a \ 'b::linorder_topology" assumes F: "\ trivial_limit F" - assumes x: "(f ---> x) F" and a: "eventually (\x. a \ f x) F" - shows "a \ x" + assumes x: "(f ---> x) F" and y: "(g ---> y) F" + assumes ev: "eventually (\x. g x \ f x) F" + shows "y \ x" proof (rule ccontr) - assume "\ a \ x" - with x have "eventually (\x. f x < a) F" - by (auto simp add: tendsto_def elim!: allE[of _ "{..< a}"]) - with a have "eventually (\x. False) F" - by eventually_elim auto + assume "\ y \ x" + then have "x < y" by simp + from less_separate[OF this] obtain a b where xy: "x \ {.. {b <..}" "{.. {b<..} = {}" + by auto + then have less: "\x y. x < a \ b < y \ x < y" + by auto + from x[THEN topological_tendstoD, of "{..x. f x \ {..x. g x \ {b <..}) F" by auto + with ev have "eventually (\x. False) F" + by eventually_elim (auto dest!: less) with F show False by (simp add: eventually_False) qed -lemma tendsto_le: - fixes f g :: "_ \ real" +lemma tendsto_le_const: + fixes f :: "'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" - shows "y \ x" - using tendsto_le_const[OF F tendsto_diff[OF x y], of 0] ev - by (simp add: sign_simps) + assumes x: "(f ---> x) F" and a: "eventually (\x. a \ f x) F" + shows "a \ x" + using F x tendsto_const a by (rule tendsto_le) subsubsection {* Inverse and division *} diff -r 501200635659 -r 3de230ed0547 src/HOL/RealVector.thy --- a/src/HOL/RealVector.thy Thu Jan 31 11:31:22 2013 +0100 +++ b/src/HOL/RealVector.thy Thu Jan 31 11:31:27 2013 +0100 @@ -508,6 +508,110 @@ end +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" + +hide_fact (open) UNIV Int UN Basis + +lemma generate_topology_Union: + "(\k. k \ I \ generate_topology S (K k)) \ generate_topology S (\k\I. K k)" + unfolding SUP_def by (intro generate_topology.UN) auto + +lemma topological_space_generate_topology: + "class.topological_space (generate_topology S)" + by default (auto intro: generate_topology.intros) + +class order_topology = order + "open" + + assumes open_generated_order: "open = generate_topology (range (\a. {..< a}) \ range (\a. {a <..}))" +begin + +subclass topological_space + unfolding open_generated_order + by (rule topological_space_generate_topology) + +lemma open_greaterThan [simp]: "open {a <..}" + unfolding open_generated_order by (auto intro: generate_topology.Basis) + +lemma open_lessThan [simp]: "open {..< a}" + unfolding open_generated_order by (auto intro: generate_topology.Basis) + +lemma open_greaterThanLessThan [simp]: "open {a <..< b}" + unfolding greaterThanLessThan_eq by (simp add: open_Int) + +end + +class linorder_topology = linorder + order_topology + +lemma closed_atMost [simp]: "closed {.. a::'a::linorder_topology}" + by (simp add: closed_open) + +lemma closed_atLeast [simp]: "closed {a::'a::linorder_topology ..}" + by (simp add: closed_open) + +lemma closed_atLeastAtMost [simp]: "closed {a::'a::linorder_topology .. b}" +proof - + have "{a .. b} = {a ..} \ {.. b}" + by auto + then show ?thesis + by (simp add: closed_Int) +qed + +inductive open_interval :: "'a::order set \ bool" where + empty[intro]: "open_interval {}" | + UNIV[intro]: "open_interval UNIV" | + greaterThan[intro]: "open_interval {a <..}" | + lessThan[intro]: "open_interval {..< b}" | + greaterThanLessThan[intro]: "open_interval {a <..< b}" +hide_fact (open) empty UNIV greaterThan lessThan greaterThanLessThan + +lemma open_intervalD: + "open_interval S \ x \ S \ y \ S \ x \ z \ z \ y \ z \ S" + by (cases rule: open_interval.cases) auto + +lemma open_interval_Int[intro]: + fixes S T :: "'a :: linorder set" + assumes S: "open_interval S" and T: "open_interval T" + shows "open_interval (S \ T)" +proof - + { fix a b :: 'a have "{.. {a<..} = { a <..} \ {..< b }" by auto } note this[simp] + { fix a b :: 'a and A have "{a <..} \ ({b <..} \ A) = {max a b <..} \ A" by auto } note this[simp] + { fix a b :: 'a and A have "{.. (A \ {.. {.. {..< b})" + unfolding greaterThanLessThan_eq[symmetric] by auto } note this[simp] + show ?thesis + by (cases rule: open_interval.cases[OF S, case_product open_interval.cases[OF T]]) + (auto simp: greaterThanLessThan_eq lessThan_Int_lessThan greaterThan_Int_greaterThan Int_assoc) +qed + +lemma open_interval_imp_open: "open_interval S \ open (S::'a::order_topology set)" + by (cases S rule: open_interval.cases) auto + +lemma open_orderD: + "open (S::'a::linorder_topology set) \ x \ S \ \T. open_interval T \ T \ S \ x \ T" + unfolding open_generated_order +proof (induct rule: generate_topology.induct) + case (UN K) then obtain k where "k \ K" "x \ k" by auto + with UN(2)[of k] show ?case by auto +qed auto + +lemma open_order_induct[consumes 2, case_names subset UNIV lessThan greaterThan greaterThanLessThan]: + fixes S :: "'a::linorder_topology set" + assumes S: "open S" "x \ S" + assumes subset: "\S T. P S \ S \ T \ P T" + assumes univ: "P UNIV" + assumes lt: "\a. x < a \ P {..< a}" + assumes gt: "\a. a < x \ P {a <..}" + assumes lgt: "\a b. a < x \ x < b \ P {a <..< b}" + shows "P S" +proof - + from open_orderD[OF S] obtain T where "open_interval T" "T \ S" "x \ T" + by auto + then show "P S" + by induct (auto intro: univ subset lt gt lgt) +qed subsection {* Metric spaces *} @@ -859,46 +963,46 @@ end -lemma open_real_lessThan [simp]: - fixes a :: real shows "open {.. (\y. \y - x\ < a - x \ y \ {..e>0. \y. \y - x\ < e \ y \ {.. (\y. \y - x\ < x - a \ y \ {a<..})" by auto - thus "\e>0. \y. \y - x\ < e \ y \ {a<..}" .. +instance real :: linorder_topology +proof + show "(open :: real set \ bool) = generate_topology (range lessThan \ range greaterThan)" + proof (rule ext, safe) + fix S :: "real set" assume "open S" + then guess f unfolding open_real_def bchoice_iff .. + then have *: "S = (\x\S. {x - f x <..} \ {..< x + f x})" + by (fastforce simp: dist_real_def) + show "generate_topology (range lessThan \ range greaterThan) S" + apply (subst *) + apply (intro generate_topology_Union generate_topology.Int) + apply (auto intro: generate_topology.Basis) + done + next + fix S :: "real set" assume "generate_topology (range lessThan \ range greaterThan) S" + moreover have "\a::real. open {.. (\y. \y - x\ < a - x \ y \ {..e>0. \y. \y - x\ < e \ y \ {..a::real. open {a <..}" + unfolding open_real_def dist_real_def + proof clarify + fix x a :: real assume "a < x" + hence "0 < x - a \ (\y. \y - x\ < x - a \ y \ {a<..})" by auto + thus "\e>0. \y. \y - x\ < e \ y \ {a<..}" .. + qed + ultimately show "open S" + by induct auto + qed qed -lemma open_real_greaterThanLessThan [simp]: - fixes a b :: real shows "open {a<.. {.. {..b}" by auto - thus "closed {a..b}" by (simp add: closed_Int) -qed - +lemmas open_real_greaterThan = open_greaterThan[where 'a=real] +lemmas open_real_lessThan = open_lessThan[where 'a=real] +lemmas open_real_greaterThanLessThan = open_greaterThanLessThan[where 'a=real] +lemmas closed_real_atMost = closed_atMost[where 'a=real] +lemmas closed_real_atLeast = closed_atLeast[where 'a=real] +lemmas closed_real_atLeastAtMost = closed_atLeastAtMost[where 'a=real] subsection {* Extra type constraints *} @@ -1172,6 +1276,30 @@ instance t2_space \ t1_space proof qed (fast dest: hausdorff) +lemma (in linorder) less_separate: + assumes "x < y" + shows "\a b. x \ {..< a} \ y \ {b <..} \ {..< a} \ {b <..} = {}" +proof cases + assume "\z. x < z \ z < y" + then guess z .. + then have "x \ {..< z} \ y \ {z <..} \ {z <..} \ {..< z} = {}" + by auto + then show ?thesis by blast +next + assume "\ (\z. x < z \ z < y)" + with `x < y` have "x \ {..< y} \ y \ {x <..} \ {x <..} \ {..< y} = {}" + by auto + then show ?thesis by blast +qed + +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)+ +qed + instance metric_space \ t2_space proof fix x y :: "'a::metric_space" diff -r 501200635659 -r 3de230ed0547 src/HOL/SEQ.thy --- a/src/HOL/SEQ.thy Thu Jan 31 11:31:22 2013 +0100 +++ b/src/HOL/SEQ.thy Thu Jan 31 11:31:27 2013 +0100 @@ -368,19 +368,16 @@ and bdd: "\n. f n \ l" and en: "\e. 0 < e \ \n. l \ f n + e" shows "f ----> l" - unfolding LIMSEQ_def -proof safe - fix r :: real assume "0 < r" - with bdd en[of "r / 2"] obtain n where n: "dist (f n) l \ r / 2" - by (auto simp add: field_simps dist_real_def) - { fix N assume "n \ N" - then have "dist (f N) l \ dist (f n) l" - using incseq_SucI[of f] inc bdd by (auto dest!: incseqD simp: dist_real_def) - then have "dist (f N) l < r" - using `0 < r` n by simp } - with `0 < r` show "\no. \n\no. dist (f n) l < r" - by (auto simp add: LIMSEQ_def field_simps intro!: exI[of _ n]) -qed +proof (rule increasing_tendsto) + fix x assume "x < l" + with dense[of 0 "l - x"] obtain e where "0 < e" "e < l - x" + by auto + from en[OF `0 < e`] obtain n where "l - e \ f n" + by (auto simp: field_simps) + with `e < l - x` `0 < e` have "x < f n" by simp + with incseq_SucI[of f, OF inc] show "eventually (\n. x < f n) sequentially" + by (auto simp: eventually_sequentially incseq_def intro: less_le_trans) +qed (insert bdd, auto) lemma Bseq_inverse_lemma: fixes x :: "'a::real_normed_div_algebra" @@ -437,15 +434,15 @@ by auto lemma LIMSEQ_le_const: - "\X ----> (x::real); \N. \n\N. a \ X n\ \ a \ x" + "\X ----> (x::'a::linorder_topology); \N. \n\N. a \ X n\ \ a \ x" 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::real)" + "\X ----> x; Y ----> y; \N. \n\N. X n \ Y n\ \ 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::real); \N. \n\N. X n \ a\ \ x \ a" + "\X ----> (x::'a::linorder_topology); \N. \n\N. X n \ a\ \ x \ a" by (rule LIMSEQ_le[of X x "\n. a"]) (auto simp: tendsto_const) subsection {* Convergence *} diff -r 501200635659 -r 3de230ed0547 src/HOL/Series.thy --- a/src/HOL/Series.thy Thu Jan 31 11:31:22 2013 +0100 +++ b/src/HOL/Series.thy Thu Jan 31 11:31:27 2013 +0100 @@ -367,7 +367,7 @@ lemma pos_summable: fixes f:: "nat \ real" - assumes pos: "!!n. 0 \ f n" and le: "!!n. setsum f {0.. x" + assumes pos: "\n. 0 \ f n" and le: "\n. setsum f {0.. x" shows "summable f" proof - have "convergent (\n. setsum f {0.. real" + fixes f :: "nat \ 'a::{ordered_comm_monoid_add, linorder_topology}" shows "\summable f; \m\n. 0 \ f m\ \ setsum f {0.. suminf f" -apply (drule summable_sums) -apply (simp add: sums_def) -apply (cut_tac k = "setsum f {0.. real" + fixes f :: "nat \ 'a::{ordered_ab_semigroup_add_imp_le, ordered_comm_monoid_add, linorder_topology}" shows "\summable f; \m\n. 0 < f m\ \ setsum f {0.. 'a::{ordered_comm_monoid_add, linorder_topology}" + shows "\summable f; \n. 0 \ f n\ \ suminf f = 0 \ (\n. f n = 0)" +proof + assume "summable f" "suminf f = 0" and pos: "\n. 0 \ f n" + then have "f sums 0" + by (simp add: sums_iff) + then have f: "(\n. \i 0" + by (simp add: sums_def atLeast0LessThan) + have "\i. (\n\{i}. f n) \ 0" + proof (rule LIMSEQ_le_const[OF f]) + fix i show "\N. \n\N. (\n\{i}. f n) \ setsum f {..n. f n = 0" + by (auto intro!: antisym) +next + assume "\n. f n = 0" + then have "f = (\n. 0)" + by auto + then show "suminf f = 0" + by simp +qed + +lemma suminf_gt_zero_iff: + fixes f :: "nat \ 'a::{ordered_comm_monoid_add, linorder_topology}" + shows "\summable f; \n. 0 \ f n\ \ 0 < suminf f \ (\i. 0 < f i)" + using series_pos_le[of f 0] suminf_eq_zero_iff[of f] + by (simp add: less_le) lemma suminf_gt_zero: - fixes f :: "nat \ real" + fixes f :: "nat \ 'a::{ordered_comm_monoid_add, linorder_topology}" shows "\summable f; \n. 0 < f n\ \ 0 < suminf f" -by (drule_tac n="0" in series_pos_less, simp_all) + using suminf_gt_zero_iff[of f] by (simp add: less_imp_le) lemma suminf_ge_zero: - fixes f :: "nat \ real" + fixes f :: "nat \ 'a::{ordered_comm_monoid_add, linorder_topology}" shows "\summable f; \n. 0 \ f n\ \ 0 \ suminf f" -by (drule_tac n="0" in series_pos_le, simp_all) + by (drule_tac n="0" in series_pos_le, simp_all) lemma sumr_pos_lt_pair: fixes f :: "nat \ real" @@ -493,9 +523,14 @@ done lemma suminf_le: - fixes x :: real + fixes x :: "'a :: {ordered_comm_monoid_add, linorder_topology}" shows "summable f \ (!!n. setsum f {0.. x) \ suminf f \ x" - by (simp add: summable_convergent_sumr_iff suminf_eq_lim lim_le) + apply (drule summable_sums) + apply (simp add: sums_def) + apply (rule LIMSEQ_le_const2) + apply assumption + apply auto + done lemma summable_Cauchy: "summable (f::nat \ 'a::banach) = @@ -575,7 +610,7 @@ text{*Limit comparison property for series (c.f. jrh)*} lemma summable_le: - fixes f g :: "nat \ real" + fixes f g :: "nat \ 'a::{ordered_comm_monoid_add, linorder_topology}" shows "\\n. f n \ g n; summable f; summable g\ \ suminf f \ suminf g" apply (drule summable_sums)+ apply (simp only: sums_def, erule (1) LIMSEQ_le) @@ -597,15 +632,7 @@ fixes f::"nat\real" assumes gt0: "\n. 0 \ f n" and sm: "summable f" shows "0 \ suminf f" -proof - - let ?g = "(\n. (0::real))" - from gt0 have "\n. ?g n \ f n" by simp - moreover have "summable ?g" by (rule summable_zero) - moreover from sm have "summable f" . - ultimately have "suminf ?g \ suminf f" by (rule summable_le) - then show "0 \ suminf f" by simp -qed - + using suminf_ge_zero[OF sm gt0] by simp text{*Absolute convergence imples normal convergence*} lemma summable_norm_cancel: diff -r 501200635659 -r 3de230ed0547 src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Thu Jan 31 11:31:22 2013 +0100 +++ b/src/HOL/Set_Interval.thy Thu Jan 31 11:31:27 2013 +0100 @@ -117,6 +117,11 @@ lemma atMost_Int_atLeast: "!!n:: 'a::order. atMost n Int atLeast n = {n}" by (blast intro: order_antisym) +lemma (in linorder) lessThan_Int_lessThan: "{ a <..} \ { b <..} = { max a b <..}" + by auto + +lemma (in linorder) greaterThan_Int_greaterThan: "{..< a} \ {..< b} = {..< min a b}" + by auto subsection {* Logical Equivalences for Set Inclusion and Equality *} @@ -190,6 +195,9 @@ breaks many proofs. Since it only helps blast, it is better to leave well alone *} +lemma greaterThanLessThan_eq: "{ a <..< b} = { a <..} \ {..< b }" + by auto + end subsubsection{* Emptyness, singletons, subset *}