diff --git a/thys/Irrational_Series_Erdos_Straus/Irrational_Series_Erdos_Straus.thy b/thys/Irrational_Series_Erdos_Straus/Irrational_Series_Erdos_Straus.thy --- a/thys/Irrational_Series_Erdos_Straus/Irrational_Series_Erdos_Straus.thy +++ b/thys/Irrational_Series_Erdos_Straus/Irrational_Series_Erdos_Straus.thy @@ -1,2008 +1,2003 @@ (* Title: Irrational_Series_Erdos_Straus.thy Author: Angeliki Koutsoukou-Argyraki and Wenda Li, University of Cambridge, UK. We formalise certain irrationality criteria for infinite series by P. Erdos and E.G. Straus. In particular, we formalise Theorem 2.1, Corollary 2.10 and Theorem 3.1 in [1]. The latter is an application of Theorem 2.1 involving the prime numbers. References: [1] P. Erdos and E.G. Straus, On the irrationality of certain series, Pacific Journal of Mathematics, Vol. 55, No 1, 1974 https://projecteuclid.org/euclid.pjm/1102911140 *) theory "Irrational_Series_Erdos_Straus" imports Prime_Number_Theorem.Prime_Number_Theorem Prime_Distribution_Elementary.PNT_Consequences begin section \Miscellaneous\ lemma suminf_comparison: assumes "summable f" and gf: "\n. norm (g n) \ f n" shows "suminf g \ suminf f" proof (rule suminf_le) show "g n \ f n" for n using gf[of n] by auto show "summable g" using assms summable_comparison_test' by blast show "summable f" using assms(1) . qed lemma tendsto_of_int_diff_0: assumes "(\n. f n - of_int(g n)) \ (0::real)" "\\<^sub>F n in sequentially. f n > 0" shows "\\<^sub>F n in sequentially. 0 \ g n" proof - have "\\<^sub>F n in sequentially. \f n - of_int(g n)\ < 1 / 2" using assms(1)[unfolded tendsto_iff,rule_format,of "1/2"] by auto then show ?thesis using assms(2) apply eventually_elim by linarith qed lemma eventually_mono_sequentially: assumes "eventually P sequentially" assumes "\x. P (x+k) \ Q (x+k)" shows "eventually Q sequentially" using sequentially_offset[OF assms(1),of k] apply (subst eventually_sequentially_seg[symmetric,of _ k]) apply (elim eventually_mono) by fact lemma frequently_eventually_at_top: fixes P Q::"'a::linorder \ bool" assumes "frequently P at_top" "eventually Q at_top" shows "frequently (\x. P x \ (\y\x. Q y) ) at_top" using assms unfolding frequently_def eventually_at_top_linorder by (metis (mono_tags, hide_lams) le_cases order_trans) lemma eventually_at_top_mono: fixes P Q::"'a::linorder \ bool" assumes event_P:"eventually P at_top" assumes PQ_imp:"\x. x\z \ \y\x. P y \ Q x" shows "eventually Q at_top" proof - obtain N where N_P:"\n\N. P n" using event_P[unfolded eventually_at_top_linorder] by auto define N' where "N' = max N z" have "Q x" when "x\N'" for x apply (rule PQ_imp) using N_P that unfolding N'_def by auto then show ?thesis unfolding eventually_at_top_linorder by auto qed lemma frequently_at_top_elim: fixes P Q::"'a::linorder \ bool" assumes "\\<^sub>Fx in at_top. P x" assumes "\i. P i \ \j>i. Q j" shows "\\<^sub>Fx in at_top. Q x" using assms unfolding frequently_def eventually_at_top_linorder by (meson leD le_cases less_le_trans) lemma less_Liminf_iff: fixes X :: "_ \ _ :: complete_linorder" shows "Liminf F X < C \ (\yx. y \ X x) F)" apply (subst Not_eq_iff[symmetric]) apply (simp add:not_less not_frequently not_le le_Liminf_iff) by force lemma sequentially_even_odd_imp: assumes "\\<^sub>F N in sequentially. P (2*N)" "\\<^sub>F N in sequentially. P (2*N+1)" shows "\\<^sub>F n in sequentially. P n" proof - obtain N where N_P:"\x\N. P (2 * x) \ P (2 * x + 1)" using eventually_conj[OF assms] unfolding eventually_at_top_linorder by auto define N' where "N'=2*N " have "P n" when "n\2*N" for n proof - define n' where "n'= n div 2" then have "n'\N" using that by auto then have "P (2 * n') \ P (2 * n' + 1)" using N_P by auto then show ?thesis unfolding n'_def apply (cases "even n") by auto qed then show ?thesis unfolding eventually_at_top_linorder by auto qed section \Theorem 2.1 and Corollary 2.10\ context fixes a b ::"nat\int " assumes a_pos:"\ n. a n >0 " and a_large:"\\<^sub>F n in sequentially. a n > 1" and ab_tendsto: "(\n. \b n\ / (a (n-1)*a n)) \ 0" begin private lemma aux_series_summable: "summable (\n. b n / (\k\n. a k))" proof - have "\e>0. \\<^sub>F x in sequentially. \b x\ / (a (x-1) * a x) < e" using ab_tendsto[unfolded tendsto_iff] apply (simp add:of_int_abs[symmetric] abs_mult del:of_int_abs) by (subst (asm) (2) abs_of_pos,use \\ n. a n > 0\ in auto)+ from this[rule_format,of 1] have "\\<^sub>F x in sequentially. \real_of_int(b x)\ < (a (x-1) * a x)" using \\ n. a n >0\ by auto moreover have "\n. (\k\n. real_of_int (a k)) > 0" using a_pos by (auto intro!:linordered_semidom_class.prod_pos) ultimately have "\\<^sub>F n in sequentially. \b n\ / (\k\n. a k) < (a (n-1) * a n) / (\k\n. a k)" apply (elim eventually_mono) by (auto simp add:field_simps) moreover have "\b n\ / (\k\n. a k) = norm (b n / (\k\n. a k))" for n using \\n. (\k\n. real_of_int (a k)) > 0\[rule_format,of n] by auto ultimately have "\\<^sub>F n in sequentially. norm (b n / (\k\n. a k)) < (a (n-1) * a n) / (\k\n. a k)" by algebra moreover have "summable (\n. (a (n-1) * a n) / (\k\n. a k))" proof - obtain s where a_gt_1:"\ n\s. a n >1" using a_large[unfolded eventually_at_top_linorder] by auto define cc where "cc= (\k0" unfolding cc_def apply (rule linordered_semidom_class.prod_pos) using a_pos by auto have "(\k\n+s. a k) \ cc * 2^n" for n proof - have "prod a {s.. 2^n" proof (induct n) case 0 then show ?case using a_gt_1 by auto next case (Suc n) moreover have "a (s + Suc n) \ 2" using a_gt_1 by (smt le_add1) ultimately show ?case apply (subst prod.atLeastLessThan_Suc,simp) using mult_mono'[of 2 "a (Suc (s + n))" " 2 ^ n" "prod a {s..cc>0\ unfolding cc_def by (simp add: atLeast0AtMost) qed then have "1/(\k\n+s. a k) \ 1/(cc * 2^n)" for n proof - assume asm:"\n. cc * 2 ^ n \ prod a {..n + s}" then have "real_of_int (cc * 2 ^ n) \ prod a {..n + s}" using of_int_le_iff by blast moreover have "prod a {..n + s} >0" using \cc>0\ by (simp add: a_pos prod_pos) ultimately show ?thesis using \cc>0\ by (auto simp:field_simps simp del:of_int_prod) qed moreover have "summable (\n. 1/(cc * 2^n))" proof - have "summable (\n. 1/(2::int)^n)" using summable_geometric[of "1/(2::int)"] by (simp add:power_one_over) from summable_mult[OF this,of "1/cc"] show ?thesis by auto qed ultimately have "summable (\n. 1 / (\k\n+s. a k))" apply (elim summable_comparison_test'[where N=0]) apply (unfold real_norm_def, subst abs_of_pos) by (auto simp add: \\n. 0 < (\k\n. real_of_int (a k))\) then have "summable (\n. 1 / (\k\n. a k))" apply (subst summable_iff_shift[where k=s,symmetric]) by simp then have "summable (\n. (a (n+1) * a (n+2)) / (\k\n+2. a k))" proof - assume asm:"summable (\n. 1 / real_of_int (prod a {..n}))" have "1 / real_of_int (prod a {..n}) = (a (n+1) * a (n+2)) / (\k\n+2. a k)" for n proof - have "a (Suc (Suc n)) \ 0" "a (Suc n) \0" using a_pos by (metis less_irrefl)+ then show ?thesis by (simp add: atLeast0_atMost_Suc atMost_atLeast0) qed then show ?thesis using asm by auto qed then show "summable (\n. (a (n-1) * a n) / (\k\n. a k))" apply (subst summable_iff_shift[symmetric,of _ 2]) by auto qed ultimately show ?thesis apply (elim summable_comparison_test_ev[rotated]) by (simp add: eventually_mono) qed private fun get_c::"(nat \ int) \ (nat \ int) \ int \ nat \ (nat \ int)" where "get_c a' b' B N 0 = round (B * b' N / a' N)"| "get_c a' b' B N (Suc n) = get_c a' b' B N n * a' (n+N) - B * b' (n+N)" lemma ab_rationality_imp: assumes ab_rational:"(\n. (b n / (\i \ n. a i))) \ \" shows "\ (B::int)>0. \ c::nat\ int. (\\<^sub>F n in sequentially. B*b n = c n * a n - c(n+1) \ \c(n+1)\ (\n. c (Suc n) / a n) \ 0" proof - have [simp]:"a n \ 0" for n using a_pos by (metis less_numeral_extra(3)) obtain A::int and B::int where AB_eq:"(\n. real_of_int (b n) / real_of_int (prod a {..n})) = A / B" and "B>0" proof - obtain q::rat where "(\n. real_of_int (b n) / real_of_int (prod a {..n})) = real_of_rat q" using ab_rational by (rule Rats_cases) simp moreover obtain A::int and B::int where "q = Rat.Fract A B" "B > 0" "coprime A B" by (rule Rat_cases) auto ultimately show ?thesis by (auto intro!: that[of A B] simp:of_rat_rat) qed define f where "f = (\n. b n / real_of_int (prod a {..n}))" define R where "R = (\N. (\n. B*b (n+N+1) / prod a {N..n+N+1}))" have all_e_ubound:"\e>0. \\<^sub>F M in sequentially. \n. \B*b (n+M+1) / prod a {M..n+M+1}\ < e/4 * 1/2^n" proof safe fix e::real assume "e>0" obtain N where N_a2: "\n \ N. a n \ 2" and N_ba: "\n \ N. \b n\ / (a (n-1) * a n) < e/(4*B)" proof - have "\\<^sub>F n in sequentially. \b n\ / (a (n - 1) * a n) < e/(4*B)" using order_topology_class.order_tendstoD[OF ab_tendsto,of "e/(4*B)"] \B>0\ \e>0\ by auto moreover have "\\<^sub>F n in sequentially. a n \ 2" using a_large by (auto elim: eventually_mono) ultimately have "\\<^sub>F n in sequentially. \b n\ / (a (n - 1) * a n) < e/(4*B) \ a n \ 2" by eventually_elim auto then show ?thesis unfolding eventually_at_top_linorder using that by auto qed have geq_N_bound:"\B*b (n+M+1) / prod a {M..n+M+1}\ < e/4 * 1/2^n" when "M\N" for n M proof - define D where "D = B*b (n+M+1)/ (a (n+M) * a (n+M+1))" have "\B*b (n+M+1) / prod a {M..n+M+1}\ = \D / prod a {M.." proof - have "{M..n+M+1} = {M.. {n+M,n+M+1}" by auto then have "prod a {M..n+M+1} = a (n+M) * a (n+M+1)* prod a {M..e/4 * (1/prod a {M.." proof - have "\D\ < e/ 4" unfolding D_def using N_ba[rule_format, of "n+M+1"] \B>0\ \M \ N\ \e>0\ a_pos by (auto simp:field_simps abs_mult abs_of_pos) from mult_strict_right_mono[OF this,of "1/prod a {M..e>0\ show ?thesis apply (auto simp:abs_prod abs_mult prod_pos) by (subst (2) abs_of_pos,auto)+ qed also have "... \ e/4 * 1/2^n" proof - have "prod a {M.. 2^n" proof (induct n) case 0 then show ?case by simp next case (Suc n) then show ?case using \M\N\ by (simp add: N_a2 mult.commute mult_mono' prod.atLeastLessThan_Suc) qed then have "real_of_int (prod a {M.. 2^n" using numeral_power_le_of_int_cancel_iff by blast then show ?thesis using \e>0\ by (auto simp add:divide_simps) qed finally show ?thesis . qed show "\\<^sub>F M in sequentially. \n. \real_of_int (B * b (n + M + 1)) / real_of_int (prod a {M..n + M + 1})\ < e / 4 * 1 / 2 ^ n" apply (rule eventually_sequentiallyI[of N]) using geq_N_bound by blast qed have R_tendsto_0:"R \ 0" proof (rule tendstoI) fix e::real assume "e>0" show "\\<^sub>F x in sequentially. dist (R x) 0 < e" using all_e_ubound[rule_format,OF \e>0\] proof eventually_elim case (elim M) define g where "g = (\n. B*b (n+M+1) / prod a {M..n+M+1})" have g_lt:"\g n\ < e/4 * 1/2^n" for n using elim unfolding g_def by auto - have g_abs_summable:"summable (\n. \g n\)" - proof - - have "summable (\n. e/4 * 1/2^n)" - using summable_geometric[of "1/2",THEN summable_mult,of "e/4",simplified] - by (auto simp add:algebra_simps power_divide) - then show ?thesis - apply (elim summable_comparison_test') - using g_lt less_eq_real_def by auto - qed + have \
: "summable (\n. (e/4) * (1/2)^n)" + by simp + then have g_abs_summable:"summable (\n. \g n\)" + apply (elim summable_comparison_test') + by (metis abs_idempotent g_lt less_eq_real_def power_one_over real_norm_def times_divide_eq_right) have "\\n. g n\ \ (\n. \g n\)" by (rule summable_rabs[OF g_abs_summable]) also have "... \(\n. e/4 * 1/2^n)" proof (rule suminf_comparison) show "summable (\n. e/4 * 1/2^n)" - using summable_geometric[of "1/2",THEN summable_mult,of "e/4",simplified] - by (auto simp add:algebra_simps power_divide) + using \
unfolding power_divide by simp show "\n. norm \g n\ \ e / 4 * 1 / 2 ^ n" using g_lt less_eq_real_def by auto qed also have "... = (e/4) * (\n. (1/2)^n)" apply (subst suminf_mult[symmetric]) subgoal apply (rule complete_algebra_summable_geometric) by simp subgoal by (auto simp:algebra_simps power_divide) done also have "... = e/2" by (simp add:suminf_geometric[of "1/2"]) finally have "\\n. g n\ \ e / 2" . then show "dist (R M) 0 < e" unfolding R_def g_def using \e>0\ by auto qed qed obtain N where R_N_bound:"\M \ N. \R M\ \ 1 / 4" and N_geometric:"\M\N. \n. \real_of_int (B * b (n + M + 1)) / (prod a {M..n + M + 1})\ < 1 / 2 ^ n" proof - obtain N1 where N1:"\M \ N1. \R M\ \ 1 / 4" using metric_LIMSEQ_D[OF R_tendsto_0,of "1/4"] all_e_ubound[rule_format,of 4,unfolded eventually_sequentially] by (auto simp:less_eq_real_def) obtain N2 where N2:"\M\N2. \n. \real_of_int (B * b (n + M + 1)) / (prod a {M..n + M + 1})\ < 1 / 2 ^ n" using all_e_ubound[rule_format,of 4,unfolded eventually_sequentially] by (auto simp:less_eq_real_def) define N where "N=max N1 N2" show ?thesis using that[of N] N1 N2 unfolding N_def by simp qed define C where "C = B * prod a {..nn. f n)" unfolding AB_eq f_def using \B>0\ by auto also have "... = B * prod a {..nn. f (n+N+1)))" using suminf_split_initial_segment[OF \summable f\, of "N+1"] by auto also have "... = B * prod a {..nn. f (n+N+1)))" using sum.atLeast0_lessThan_Suc by simp also have "... = C + B * b N / a N + (\n. B*b (n+N+1) / prod a {N..n+N+1})" proof - have "B * prod a {.. {N}" using ivl_disj_un_singleton(2) by blast then show ?thesis unfolding f_def by auto qed moreover have "B * prod a {..n. f (n+N+1)) = (\n. B*b (n+N+1) / prod a {N..n+N+1})" proof - have "summable (\n. f (n + N + 1))" using \summable f\ summable_iff_shift[of f "N+1"] by auto moreover have "prod a {.. {N..n + N + 1}" by auto then show ?thesis unfolding f_def apply simp apply (subst prod.union_disjoint) by auto qed ultimately show ?thesis apply (subst suminf_mult[symmetric]) by (auto simp add: mult.commute mult.left_commute) qed ultimately show ?thesis unfolding C_def by (auto simp:algebra_simps) qed also have "... = C +B * b N / a N + R N" unfolding R_def by simp finally show ?thesis . qed have R_bound:"\R M\ \ 1 / 4" and R_Suc:"R (Suc M) = a M * R M - B * b (Suc M) / a (Suc M)" when "M \ N" for M proof - define g where "g = (\n. B*b (n+M+1) / prod a {M..n+M+1})" have g_abs_summable:"summable (\n. \g n\)" proof - have "summable (\n. (1/2::real) ^ n)" by simp moreover have "\g n\ < 1/2^n" for n using N_geometric[rule_format,OF that] unfolding g_def by simp ultimately show ?thesis apply (elim summable_comparison_test') by (simp add: less_eq_real_def power_one_over) qed show "\R M\ \ 1 / 4" using R_N_bound[rule_format,OF that] . have "R M = (\n. g n)" unfolding R_def g_def by simp also have "... = g 0 + (\n. g (Suc n))" apply (subst suminf_split_head) using summable_rabs_cancel[OF g_abs_summable] by auto also have "... = g 0 + 1/a M * (\n. a M * g (Suc n))" apply (subst suminf_mult) by (auto simp add: g_abs_summable summable_Suc_iff summable_rabs_cancel) also have "... = g 0 + 1/a M * R (Suc M)" proof - have "a M * g (Suc n) = B * b (n + M + 2) / prod a {Suc M..n + M + 2}" for n proof - have "{M..Suc (Suc (M + n))} = {M} \ {Suc M..Suc (Suc (M + n))}" by auto then show ?thesis unfolding g_def using \B>0\ by (auto simp add:algebra_simps) qed then have "(\n. a M * g (Suc n)) = R (Suc M)" unfolding R_def by auto then show ?thesis by auto qed finally have "R M = g 0 + 1 / a M * R (Suc M)" . then have "R (Suc M) = a M * R M - g 0 * a M" by (auto simp add:algebra_simps) moreover have "{M..Suc M} = {M,Suc M}" by auto ultimately show "R (Suc M) = a M * R M - B * b (Suc M) / a (Suc M)" unfolding g_def by auto qed define c where "c = (\n. if n\N then get_c a b B N (n-N) else undefined)" have c_rec:"c (n+1) = c n * a n - B * b n" when "n \ N" for n unfolding c_def using that by (auto simp:Suc_diff_le) have c_R:"c (Suc n) / a n = R n" when "n \ N" for n using that proof (induct rule:nat_induct_at_least) case base have "\ c (N+1) / a N \ \ 1/2" proof - have "c N = round (B * b N / a N)" unfolding c_def by simp moreover have "c (N+1) / a N = c N - B * b N / a N" using a_pos[rule_format,of N] by (auto simp add:c_rec[of N,simplified] divide_simps) ultimately show ?thesis using of_int_round_abs_le by auto qed moreover have "\R N\ \ 1 / 4" using R_bound[of N] by simp ultimately have "\c (N+1) / a N - R N \ < 1" by linarith moreover have "c (N+1) / a N - R N \ \" proof - have "c (N+1) / a N = c N - B * b N / a N" using a_pos[rule_format,of N] by (auto simp add:c_rec[of N,simplified] divide_simps) moreover have " B * b N / a N + R N \ \" proof - have "C = B * (\nn {..n}" if "nB>0\ apply simp apply (subst prod.union_disjoint) by auto qed finally have "C = real_of_int (B * (\n \" using Ints_of_int by blast moreover note \A * prod a {.. ultimately show ?thesis by (metis Ints_diff Ints_of_int add.assoc add_diff_cancel_left') qed ultimately show ?thesis by (simp add: diff_diff_add) qed ultimately have "c (N+1) / a N - R N = 0" by (metis Ints_cases less_irrefl of_int_0 of_int_lessD) then show ?case by simp next case (Suc n) have "c (Suc (Suc n)) / a (Suc n) = c (Suc n) - B * b (Suc n) / a (Suc n)" apply (subst c_rec[of "Suc n",simplified]) using \N \ n\ by (auto simp add: divide_simps) also have "... = a n * R n - B * b (Suc n) / a (Suc n)" using Suc by (auto simp: divide_simps) also have "... = R (Suc n)" using R_Suc[OF \N \ n\] by simp finally show ?case . qed have ca_tendsto_zero:"(\n. c (Suc n) / a n) \ 0" using R_tendsto_0 apply (elim filterlim_mono_eventually) using c_R by (auto intro!:eventually_sequentiallyI[of N]) have ca_bound:"\c (n + 1)\ < a n / 2" when "n \ N" for n proof - have "\c (Suc n)\ / a n = \c (Suc n) / a n\" using a_pos[rule_format,of n] by auto also have "... = \R n\" using c_R[OF that] by auto also have "... < 1/2" using R_bound[OF that] by auto finally have "\c (Suc n)\ / a n < 1/2" . then show ?thesis using a_pos[rule_format,of n] by auto qed (* (* the following part corresponds to (2.7) (2.8) in the original paper, but turns out to be not necessary. *) have c_round:"c n = round (B * b n / a n)" when "n \ N" for n proof (cases "n=N") case True then show ?thesis unfolding c_def by simp next case False with \n\N\ obtain n' where n_Suc:"n=Suc n'" and "n' \ N" by (metis le_eq_less_or_eq lessE less_imp_le_nat) have "B * b n / a n = c n - R n" proof - have "R n = c n - B * b n / a n" using c_R[OF \n'\N\,symmetric,folded n_Suc] R_Suc[OF \n'\N\,folded n_Suc] by (auto simp:field_simps) then show ?thesis by (auto simp:field_simps) qed then have "\B * b n / a n - c n\ = \R n\" by auto then have "\B * b n / a n - c n\ < 1/2" using R_bound[OF \n \ N\] by auto from round_unique'[OF this] show ?thesis by auto qed *) show "\B>0. \c. (\\<^sub>F n in sequentially. B * b n = c n * a n - c (n + 1) \ real_of_int \c (n + 1)\ < a n / 2) \ (\n. c (Suc n) / a n) \ 0" unfolding eventually_at_top_linorder apply (rule exI[of _ B],use \B>0\ in simp) apply (intro exI[of _c] exI[of _ N]) using c_rec ca_bound ca_tendsto_zero by fastforce qed private lemma imp_ab_rational: assumes "\ (B::int)>0. \ c::nat\ int. (\\<^sub>F n in sequentially. B*b n = c n * a n - c(n+1) \ \c(n+1)\n. (b n / (\i \ n. a i))) \ \" proof - obtain B::int and c::"nat\int" and N::nat where "B>0" and large_n:"\n\N. B * b n = c n * a n - c (n + 1) \ real_of_int \c (n + 1)\ < a n / 2 \ a n\2" proof - obtain B c where "B>0" and event1:"\\<^sub>F n in sequentially. B * b n = c n * a n - c (n + 1) \ real_of_int \c (n + 1)\ < real_of_int (a n) / 2" using assms by auto from eventually_conj[OF event1 a_large,unfolded eventually_at_top_linorder] obtain N where "\n\N. (B * b n = c n * a n - c (n + 1) \ real_of_int \c (n + 1)\ < real_of_int (a n) / 2) \ 2 \ a n" by fastforce then show ?thesis using that[of B N c] \B>0\ by auto qed define f where "f=(\n. real_of_int (b n) / real_of_int (prod a {..n}))" define S where "S = (\n. f n)" have "summable f" unfolding f_def by (rule aux_series_summable) define C where "C=B*prod a {..nn. (c (n+N) * a (n+N)) / prod a {N..n+N})" define h2 where "h2 = (\n. c (n+N+1) / prod a {N..n+N})" have f_h12:"B*prod a {..n. B * b (n+N))" define g2 where "g2 = (\n. prod a {.. {N..n + N}) = prod a {.. {N..n + N}) = prod a {..n+N}" by (simp add: ivl_disj_un_one(4)) ultimately show ?thesis unfolding g2_def apply simp using a_pos by (metis less_irrefl) qed ultimately have "B*prod a {..nn. f (n+N)))" using suminf_split_initial_segment[OF \summable f\,of N] unfolding S_def by (auto simp:algebra_simps) also have "... = C + B*prod a {..n. f (n+N))" unfolding C_def by (auto simp:algebra_simps) also have "... = C + (\n. h1 n - h2 n)" apply (subst suminf_mult[symmetric]) subgoal using \summable f\ by (simp add: summable_iff_shift) subgoal using f_h12 by auto done also have "... = C + h1 0" proof - have "(\n. \i\n. h1 i - h2 i) \ (\i. h1 i - h2 i)" proof (rule summable_LIMSEQ') have "(\i. h1 i - h2 i) = (\i. real_of_int (B * prod a {..i. h1 i - h2 i)" using \summable f\ by (simp add: summable_iff_shift summable_mult) qed moreover have "(\i\n. h1 i - h2 i) = h1 0 - h2 n" for n proof (induct n) case 0 then show ?case by simp next case (Suc n) have "(\i\Suc n. h1 i - h2 i) = (\i\n. h1 i - h2 i) + h1 (n+1) - h2 (n+1)" by auto also have "... = h1 0 - h2 n + h1 (n+1) - h2 (n+1)" using Suc by auto also have "... = h1 0 - h2 (n+1)" proof - have "h2 n = h1 (n+1)" unfolding h2_def h1_def apply (auto simp:prod.nat_ivl_Suc') using a_pos by (metis less_numeral_extra(3)) then show ?thesis by auto qed finally show ?case by simp qed ultimately have "(\n. h1 0 - h2 n) \ (\i. h1 i - h2 i)" by simp then have "h2 \ (h1 0 - (\i. h1 i - h2 i))" apply (elim metric_tendsto_imp_tendsto) by (auto intro!:eventuallyI simp add:dist_real_def) moreover have "h2 \ 0" proof - have h2_n:"\h2 n\ < (1 / 2)^(n+1)" for n proof - have "\h2 n\ = \c (n + N + 1)\ / prod a {N..n + N}" unfolding h2_def abs_divide using a_pos by (simp add: abs_of_pos prod_pos) also have "... < (a (N+n) / 2) / prod a {N..n + N}" unfolding h2_def apply (rule divide_strict_right_mono) subgoal using large_n[rule_format,of "N+n"] by (auto simp add:algebra_simps) subgoal using a_pos by (simp add: prod_pos) done also have "... = 1 / (2*prod a {N.. (1/2)^(n+1)" proof (induct n) case 0 then show ?case by auto next case (Suc n) define P where "P=1 / real_of_int (2 * prod a {N.. ( (1 / 2) ^ (n + 1) ) / a (n+N) " apply (rule divide_right_mono) subgoal unfolding P_def using Suc by auto subgoal by (simp add: a_pos less_imp_le) done also have "... \ ( (1 / 2) ^ (n + 1) ) / 2 " apply (rule divide_left_mono) using large_n[rule_format,of "n+N",simplified] by auto also have "... = (1 / 2) ^ (n + 2)" by auto finally show ?case by simp qed finally show ?thesis . qed have "(\n. (1 / 2)^(n+1)) \ (0::real)" using tendsto_mult_right_zero[OF LIMSEQ_abs_realpow_zero2[of "1/2",simplified],of "1/2"] by auto then show ?thesis apply (elim Lim_null_comparison[rotated]) using h2_n less_eq_real_def by (auto intro!:eventuallyI) qed ultimately have "(\i. h1 i - h2 i) = h1 0" using LIMSEQ_unique by fastforce then show ?thesis by simp qed also have "... = C + c N" unfolding h1_def using a_pos by auto (metis less_irrefl) finally show ?thesis . qed then have "S = (C + real_of_int (c N)) / (B*prod a {..0 < B\ a_pos less_irrefl mult.commute mult_pos_pos nonzero_mult_div_cancel_right of_int_eq_0_iff prod_pos) moreover have "... \ \" unfolding C_def f_def by (intro Rats_divide Rats_add Rats_mult Rats_of_int Rats_sum) ultimately show "S \ \" by auto qed theorem theorem_2_1_Erdos_Straus : "(\n. (b n / (\i \ n. a i))) \ \ \ (\ (B::int)>0. \ c::nat\ int. (\\<^sub>F n in sequentially. B*b n = c n * a n - c(n+1) \ \c(n+1)\The following is a Corollary to Theorem 2.1. \ corollary corollary_2_10_Erdos_Straus: assumes ab_event:"\\<^sub>F n in sequentially. b n > 0 \ a (n+1) \ a n" and ba_lim_leq:"lim (\n. (b(n+1) - b n )/a n) \ 0" and ba_lim_exist:"convergent (\n. (b(n+1) - b n )/a n)" and "liminf (\n. a n / b n) = 0 " shows "(\n. (b n / (\i \ n. a i))) \ \" proof assume "(\n. (b n / (\i \ n. a i))) \ \" then obtain B c where "B>0" and abc_event:"\\<^sub>F n in sequentially. B * b n = c n * a n - c (n + 1) \ \c (n + 1)\ < a n / 2" and ca_vanish: "(\n. c (Suc n) / a n) \ 0" using ab_rationality_imp by auto have bac_close:"(\n. B * b n / a n - c n) \ 0" proof - have "\\<^sub>F n in sequentially. B * b n - c n * a n + c (n + 1) = 0" using abc_event by (auto elim!:eventually_mono) then have "\\<^sub>F n in sequentially. (B * b n - c n * a n + c (n+1)) / a n = 0 " apply eventually_elim by auto then have "\\<^sub>F n in sequentially. B * b n / a n - c n + c (n + 1) / a n = 0" apply eventually_elim using a_pos by (auto simp:divide_simps) (metis less_irrefl) then have "(\n. B * b n / a n - c n + c (n + 1) / a n) \ 0" by (simp add: eventually_mono tendsto_iff) from tendsto_diff[OF this ca_vanish] show ?thesis by auto qed have c_pos:"\\<^sub>F n in sequentially. c n > 0" proof - from bac_close have *:"\\<^sub>F n in sequentially. c n \ 0" apply (elim tendsto_of_int_diff_0) using ab_event a_large apply (eventually_elim) using \B>0\ by auto show ?thesis proof (rule ccontr) assume "\ (\\<^sub>F n in sequentially. c n > 0)" moreover have "\\<^sub>F n in sequentially. c (Suc n) \ 0 \ c n\0" using * eventually_sequentially_Suc[of "\n. c n\0"] by (metis (mono_tags, lifting) eventually_at_top_linorder le_Suc_eq) ultimately have "\\<^sub>F n in sequentially. c n = 0 \ c (Suc n) \ 0" using eventually_elim2 frequently_def by fastforce moreover have "\\<^sub>F n in sequentially. b n > 0 \ B * b n = c n * a n - c (n + 1)" using ab_event abc_event by eventually_elim auto ultimately have "\\<^sub>F n in sequentially. c n = 0 \ c (Suc n) \ 0 \ b n > 0 \ B * b n = c n * a n - c (n + 1)" using frequently_eventually_frequently by fastforce from frequently_ex[OF this] obtain n where "c n = 0" "c (Suc n) \ 0" "b n > 0" "B * b n = c n * a n - c (n + 1)" by auto then have "B * b n \ 0" by auto then show False using \b n>0\ \B > 0\ using mult_pos_pos not_le by blast qed qed have bc_epsilon:"\\<^sub>F n in sequentially. b (n+1) / b n > (c (n+1) - \) / c n" when "\>0" "\<1" for \::real proof - have "\\<^sub>F x in sequentially. \c (Suc x) / a x\ < \ / 2" using ca_vanish[unfolded tendsto_iff,rule_format, of "\/2"] \\>0\ by auto moreover then have "\\<^sub>F x in sequentially. \c (x+2) / a (x+1)\ < \ / 2" apply (subst (asm) eventually_sequentially_Suc[symmetric]) by simp moreover have "\\<^sub>F n in sequentially. B * b (n+1) = c (n+1) * a (n+1) - c (n + 2)" using abc_event apply (subst (asm) eventually_sequentially_Suc[symmetric]) by (auto elim:eventually_mono) moreover have "\\<^sub>F n in sequentially. c n > 0 \ c (n+1) > 0 \ c (n+2) > 0" proof - have "\\<^sub>F n in sequentially. 0 < c (Suc n)" using c_pos by (subst eventually_sequentially_Suc) simp moreover then have "\\<^sub>F n in sequentially. 0 < c (Suc (Suc n))" using c_pos by (subst eventually_sequentially_Suc) simp ultimately show ?thesis using c_pos by eventually_elim auto qed ultimately show ?thesis using ab_event abc_event proof eventually_elim case (elim n) define \\<^sub>0 \\<^sub>1 where "\\<^sub>0 = c (n+1) / a n" and "\\<^sub>1 = c (n+2) / a (n+1)" have "\\<^sub>0 > 0" "\\<^sub>1 > 0" "\\<^sub>0 < \/2" "\\<^sub>1 < \/2" using a_pos elim by (auto simp add: \\<^sub>0_def \\<^sub>1_def) have "(\ - \\<^sub>1) * c n > 0" apply (rule mult_pos_pos) using \\\<^sub>1 > 0\ \\\<^sub>1 < \/2\ \\>0\ elim by auto moreover have "\\<^sub>0 * (c (n+1) - \) > 0" apply (rule mult_pos_pos[OF \\\<^sub>0 > 0\]) using elim(4) that(2) by linarith ultimately have "(\ - \\<^sub>1) * c n + \\<^sub>0 * (c (n+1) - \) > 0" by auto moreover have "c n - \\<^sub>0 > 0" using \\\<^sub>0 < \ / 2\ elim(4) that(2) by linarith moreover have "c n > 0" by (simp add: elim(4)) ultimately have "(c (n+1) - \) / c n < (c (n+1) - \\<^sub>1) / (c n - \\<^sub>0)" by (auto simp add: field_simps) also have "... \ (c (n+1) - \\<^sub>1) / (c n - \\<^sub>0) * (a (n+1) / a n)" proof - have "(c (n+1) - \\<^sub>1) / (c n - \\<^sub>0) > 0" by (smt \0 < (\ - \\<^sub>1) * real_of_int (c n)\ \0 < real_of_int (c n) - \\<^sub>0\ divide_pos_pos elim(4) mult_le_0_iff of_int_less_1_iff that(2)) moreover have "(a (n+1) / a n) \ 1" using a_pos elim(5) by auto ultimately show ?thesis by (metis mult_cancel_left1 mult_le_cancel_iff2) qed also have "... = (B * b (n+1)) / (B * b n)" proof - have "B * b n = c n * a n - c (n + 1)" using elim by auto also have "... = a n * (c n - \\<^sub>0)" using a_pos[rule_format,of n] unfolding \\<^sub>0_def by (auto simp:field_simps) finally have "B * b n = a n * (c n - \\<^sub>0)" . moreover have "B * b (n+1) = a (n+1) * (c (n+1) - \\<^sub>1)" unfolding \\<^sub>1_def using a_pos[rule_format,of "n+1"] apply (subst \B * b (n + 1) = c (n + 1) * a (n + 1) - c (n + 2)\) by (auto simp:field_simps) ultimately show ?thesis by (simp add: mult.commute) qed also have "... = b (n+1) / b n" using \B>0\ by auto finally show ?case . qed qed have eq_2_11:"\\<^sub>F n in sequentially. b (n+1) > b n + (1 - \)^2 * a n / B" when "\>0" "\<1" "\ (\\<^sub>F n in sequentially. c (n+1) \ c n)" for \::real proof - have "\\<^sub>F x in sequentially. c x < c (Suc x) " using that(3) by (simp add:not_eventually frequently_elim1) moreover have "\\<^sub>F x in sequentially. \c (Suc x) / a x\ < \" using ca_vanish[unfolded tendsto_iff,rule_format, of \] \\>0\ by auto moreover have "\\<^sub>F n in sequentially. c n > 0 \ c (n+1) > 0" proof - have "\\<^sub>F n in sequentially. 0 < c (Suc n)" using c_pos by (subst eventually_sequentially_Suc) simp then show ?thesis using c_pos by eventually_elim auto qed ultimately show ?thesis using ab_event abc_event bc_epsilon[OF \\>0\ \\<1\] proof (elim frequently_rev_mp,eventually_elim) case (elim n) then have "c (n+1) / a n < \" using a_pos[rule_format,of n] by auto also have "... \ \ * c n" using elim(7) that(1) by auto finally have "c (n+1) / a n < \ * c n" . then have "c (n+1) / c n < \ * a n" using a_pos[rule_format,of n] elim by (auto simp:field_simps) then have "(1 - \) * a n < a n - c (n+1) / c n" by (auto simp:algebra_simps) then have "(1 - \)^2 * a n / B < (1 - \) * (a n - c (n+1) / c n) / B" apply (subst (asm) mult_less_iff1[symmetric, of "(1-\)/B"]) using \\<1\ \B>0\ by (auto simp: divide_simps power2_eq_square mult_less_iff1) then have "b n + (1 - \)^2 * a n / B < b n + (1 - \) * (a n - c (n+1) / c n) / B" using \B>0\ by auto also have "... = b n + (1 - \) * ((c n *a n - c (n+1)) / c n) / B" using elim by (auto simp:field_simps) also have "... = b n + (1 - \) * (b n / c n)" proof - have "B * b n = c n * a n - c (n + 1)" using elim by auto from this[symmetric] show ?thesis using \B>0\ by simp qed also have "... = (1+(1-\)/c n) * b n" by (auto simp:algebra_simps) also have "... = ((c n+1-\)/c n) * b n" using elim by (auto simp:divide_simps) also have "... \ ((c (n+1) -\)/c n) * b n" proof - define cp where "cp = c n+1" have "c (n+1) \ cp" unfolding cp_def using \c n < c (Suc n)\ by auto moreover have "c n>0" "b n>0" using elim by auto ultimately show ?thesis apply (fold cp_def) by (auto simp:divide_simps) qed also have "... < b (n+1)" using elim by (auto simp:divide_simps) finally show ?case . qed qed have "\\<^sub>F n in sequentially. c (n+1) \ c n" proof (rule ccontr) assume "\ (\\<^sub>F n in sequentially. c (n + 1) \ c n)" from eq_2_11[OF _ _ this,of "1/2"] have "\\<^sub>F n in sequentially. b (n+1) > b n + 1/4 * a n / B" by (auto simp:algebra_simps power2_eq_square) then have *:"\\<^sub>F n in sequentially. (b (n+1) - b n) / a n > 1 / (B * 4)" apply (elim frequently_elim1) subgoal for n using a_pos[rule_format,of n] by (auto simp:field_simps) done define f where "f = (\n. (b (n+1) - b n) / a n)" have "f \ lim f" using convergent_LIMSEQ_iff ba_lim_exist unfolding f_def by auto from this[unfolded tendsto_iff,rule_format, of "1 / (B*4)"] have "\\<^sub>F x in sequentially. \f x - lim f\ < 1 / (B * 4)" using \B>0\ by (auto simp:dist_real_def) moreover have "\\<^sub>F n in sequentially. f n > 1 / (B * 4)" using * unfolding f_def by auto ultimately have "\\<^sub>F n in sequentially. f n > 1 / (B * 4) \ \f n - lim f\ < 1 / (B * 4)" by (auto elim:frequently_eventually_frequently[rotated]) from frequently_ex[OF this] obtain n where "f n > 1 / (B * 4)" "\f n - lim f\ < 1 / (B * 4)" by auto moreover have "lim f \ 0" using ba_lim_leq unfolding f_def by auto ultimately show False by linarith qed then obtain N where N_dec:"\n\N. c (n+1) \ c n" by (meson eventually_at_top_linorder) define max_c where "max_c = (MAX n \ {..N}. c n)" have max_c:"c n \ max_c" for n proof (cases "n\N") case True then show ?thesis unfolding max_c_def by simp next case False then have "n\N" by auto then have "c n\c N" proof (induct rule:nat_induct_at_least) case base then show ?case by simp next case (Suc n) then have "c (n+1) \ c n" using N_dec by auto then show ?case using \c n \ c N\ by auto qed moreover have "c N \ max_c" unfolding max_c_def by auto ultimately show ?thesis by auto qed have "max_c > 0 " proof - obtain N where "\n\N. 0 < c n" using c_pos[unfolded eventually_at_top_linorder] by auto then have "c N > 0" by auto then show ?thesis using max_c[of N] by simp qed have ba_limsup_bound:"1/(B*(B+1)) \ limsup (\n. b n/a n)" "limsup (\n. b n/a n) \ max_c / B + 1 / (B+1)" proof - define f where "f = (\n. b n/a n)" from tendsto_mult_right_zero[OF bac_close,of "1/B"] have "(\n. f n - c n / B) \ 0" unfolding f_def using \B>0\ by (auto simp:algebra_simps) from this[unfolded tendsto_iff,rule_format,of "1/(B+1)"] have "\\<^sub>F x in sequentially. \f x - c x / B\ < 1 / (B+1)" using \B>0\ by auto then have *:"\\<^sub>F n in sequentially. 1/(B*(B+1)) \ ereal (f n) \ ereal (f n) \ max_c / B + 1 / (B+1)" using c_pos proof eventually_elim case (elim n) then have "f n - c n / B < 1 / (B+1)" by auto then have "f n < c n / B + 1 / (B+1)" by simp also have "... \ max_c / B + 1 / (B+1)" using max_c[of n] using \B>0\ by (auto simp:divide_simps) finally have *:"f n < max_c / B + 1 / (B+1)" . have "1/(B*(B+1)) = 1/B - 1 / (B+1)" using \B>0\ by (auto simp:divide_simps) also have "... \ c n/B - 1 / (B+1)" using \0 < c n\ \B>0\ by (auto,auto simp:divide_simps) also have "... < f n" using elim by auto finally have "1/(B*(B+1)) < f n" . with * show ?case by simp qed show "limsup f \ max_c / B + 1 / (B+1)" apply (rule Limsup_bounded) using * by (auto elim:eventually_mono) have "1/(B*(B+1)) \ liminf f" apply (rule Liminf_bounded) using * by (auto elim:eventually_mono) also have "liminf f \ limsup f" by (simp add: Liminf_le_Limsup) finally show "1/(B*(B+1)) \ limsup f" . qed have "0 < inverse (ereal (max_c / B + 1 / (B+1)))" using \max_c > 0\ \B>0\ by (simp add: pos_add_strict) also have "... \ inverse (limsup (\n. b n/a n))" proof (rule ereal_inverse_antimono[OF _ ba_limsup_bound(2)]) have "0<1/(B*(B+1))" using \B>0\ by auto also have "... \ limsup (\n. b n/a n)" using ba_limsup_bound(1) . finally show "0\limsup (\n. b n/a n)" using zero_ereal_def by auto qed also have "... = liminf (\n. inverse (ereal ( b n/a n)))" apply (subst Liminf_inverse_ereal[symmetric]) using a_pos ab_event by (auto elim!:eventually_mono simp:divide_simps) also have "... = liminf (\n. ( a n/b n))" apply (rule Liminf_eq) using a_pos ab_event apply (auto elim!:eventually_mono) by (metis less_int_code(1)) finally have "liminf (\n. ( a n/b n)) > 0" . then show False using \liminf (\n. a n / b n) = 0\ by simp qed end section\Some auxiliary results on the prime numbers. \ lemma nth_prime_nonzero[simp]:"nth_prime n \ 0" by (simp add: prime_gt_0_nat prime_nth_prime) lemma nth_prime_gt_zero[simp]:"nth_prime n >0" by (simp add: prime_gt_0_nat prime_nth_prime) lemma ratio_of_consecutive_primes: "(\n. nth_prime (n+1)/nth_prime n) \1" proof - define f where "f=(\x. real (nth_prime (Suc x)) /real (nth_prime x))" define g where "g=(\x. (real x * ln (real x)) / (real (Suc x) * ln (real (Suc x))))" have p_n:"(\x. real (nth_prime x) / (real x * ln (real x))) \ 1" using nth_prime_asymptotics[unfolded asymp_equiv_def,simplified] . moreover have p_sn:"(\n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \ 1" using nth_prime_asymptotics[unfolded asymp_equiv_def,simplified ,THEN LIMSEQ_Suc] . ultimately have "(\x. f x * g x) \ 1" using tendsto_divide[OF p_sn p_n] unfolding f_def g_def by (auto simp:algebra_simps) moreover have "g \ 1" unfolding g_def by real_asymp ultimately have "(\x. if g x = 0 then 0 else f x) \ 1" apply (drule_tac tendsto_divide[OF _ \g \ 1\]) by auto then have "f \ 1" proof (elim filterlim_mono_eventually) have "\\<^sub>F x in sequentially. (if g (x+3) = 0 then 0 else f (x+3)) = f (x+3)" unfolding g_def by auto then show "\\<^sub>F x in sequentially. (if g x = 0 then 0 else f x) = f x" apply (subst (asm) eventually_sequentially_seg) by simp qed auto then show ?thesis unfolding f_def by auto qed lemma nth_prime_double_sqrt_less: assumes "\ > 0" shows "\\<^sub>F n in sequentially. (nth_prime (2*n) - nth_prime n) / sqrt (nth_prime n) < n powr (1/2+\)" proof - define pp ll where "pp=(\n. (nth_prime (2*n) - nth_prime n) / sqrt (nth_prime n))" and "ll=(\x::nat. x * ln x)" have pp_pos:"pp (n+1) > 0" for n unfolding pp_def by simp have "(\x. nth_prime (2 * x)) \[sequentially] (\x. (2 * x) * ln (2 * x))" using nth_prime_asymptotics[THEN asymp_equiv_compose ,of "(*) 2" sequentially,unfolded comp_def] using mult_nat_left_at_top pos2 by blast also have "... \[sequentially] (\x. 2 *x * ln x)" by real_asymp finally have "(\x. nth_prime (2 * x)) \[sequentially] (\x. 2 *x * ln x)" . from this[unfolded asymp_equiv_def, THEN tendsto_mult_left,of 2] have "(\x. nth_prime (2 * x) / (x * ln x)) \ 2" unfolding asymp_equiv_def by auto moreover have *:"(\x. nth_prime x / (x * ln x)) \ 1" using nth_prime_asymptotics unfolding asymp_equiv_def by auto ultimately have "(\x. (nth_prime (2 * x) - nth_prime x) / ll x) \ 1" unfolding ll_def apply - apply (drule (1) tendsto_diff) apply (subst of_nat_diff,simp) by (subst diff_divide_distrib,simp) moreover have "(\x. sqrt (nth_prime x) / sqrt (ll x)) \ 1" unfolding ll_def using tendsto_real_sqrt[OF *] by (auto simp: real_sqrt_divide) ultimately have "(\x. pp x * (sqrt (ll x) / (ll x))) \ 1" apply - apply (drule (1) tendsto_divide,simp) by (auto simp:field_simps of_nat_diff pp_def) moreover have "\\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1/sqrt (ll x)" apply (subst eventually_sequentially_Suc[symmetric]) by (auto intro!:eventuallyI simp:ll_def divide_simps) ultimately have "(\x. pp x / sqrt (ll x)) \ 1" apply (elim filterlim_mono_eventually) by (auto elim!:eventually_mono) (metis mult.right_neutral times_divide_eq_right) moreover have "(\x. sqrt (ll x) / x powr (1/2+\)) \ 0" unfolding ll_def using \\>0\ by real_asymp ultimately have "(\x. pp x / x powr (1/2+\) * (sqrt (ll x) / sqrt (ll x))) \ 0" apply - apply (drule (1) tendsto_mult) by (auto elim:filterlim_mono_eventually) moreover have "\\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1" apply (subst eventually_sequentially_Suc[symmetric]) by (auto intro!:eventuallyI simp:ll_def ) ultimately have "(\x. pp x / x powr (1/2+\)) \ 0" apply (elim filterlim_mono_eventually) by (auto elim:eventually_mono) from tendstoD[OF this, of 1,simplified] show "\\<^sub>F x in sequentially. pp x < x powr (1 / 2 + \)" apply (elim eventually_mono_sequentially[of _ 1]) using pp_pos by auto qed section \Theorem 3.1\ text\Theorem 3.1 is an application of Theorem 2.1 with the sequences considered involving the prime numbers.\ theorem theorem_3_10_Erdos_Straus: fixes a::"nat \ int" assumes a_pos:"\ n. a n >0" and "mono a" and nth_1:"(\n. nth_prime n / (a n)^2) \ 0" and nth_2:"liminf (\n. a n / nth_prime n) = 0" shows "(\n. (nth_prime n / (\i \ n. a i))) \ \" proof assume asm:"(\n. (nth_prime n / (\i \ n. a i))) \ \" have a2_omega:"(\n. (a n)^2) \ \(\x. x * ln x)" proof - have "(\n. real (nth_prime n)) \ o(\n. real_of_int ((a n)\<^sup>2))" apply (rule smalloI_tendsto[OF nth_1]) using a_pos by (metis (mono_tags, lifting) less_int_code(1) not_eventuallyD of_int_0_eq_iff zero_eq_power2) moreover have "(\x. real (nth_prime x)) \ \(\x. real x * ln (real x))" using nth_prime_bigtheta by blast ultimately show ?thesis using landau_omega.small_big_trans smallo_imp_smallomega by blast qed have a_gt_1:"\\<^sub>F n in sequentially. 1 < a n" proof - have "\\<^sub>F x in sequentially. \x * ln x\ \ (a x)\<^sup>2" using a2_omega[unfolded smallomega_def,simplified,rule_format,of 1] by auto then have "\\<^sub>F x in sequentially. \(x+3) * ln (x+3)\ \ (a (x+3))\<^sup>2" apply (subst (asm) eventually_sequentially_seg[symmetric, of _ 3]) by simp then have "\\<^sub>F n in sequentially. 1 < a ( n+3)" proof (elim eventually_mono) fix x assume "\real (x + 3) * ln (real (x + 3))\ \ real_of_int ((a (x + 3))\<^sup>2)" moreover have "\real (x + 3) * ln (real (x + 3))\ > 3" proof - have "ln (real (x + 3)) > 1" apply simp using ln3_gt_1 ln_gt_1 by force moreover have "real(x+3) \ 3" by simp ultimately have "(x+3)*ln (real (x + 3)) > 3*1 " apply (rule_tac mult_le_less_imp_less) by auto then show ?thesis by auto qed ultimately have "real_of_int ((a (x + 3))\<^sup>2) > 3" by auto then show "1 < a (x + 3)" by (smt Suc3_eq_add_3 a_pos add.commute of_int_1 one_power2) qed then show ?thesis apply (subst eventually_sequentially_seg[symmetric, of _ 3]) by auto qed obtain B::int and c where "B>0" and Bc_large:"\\<^sub>F n in sequentially. B * nth_prime n = c n * a n - c (n + 1) \ \c (n + 1)\ < a n / 2" and ca_vanish: "(\n. c (Suc n) / real_of_int (a n)) \ 0" proof - note a_gt_1 moreover have "(\n. real_of_int \int (nth_prime n)\ / real_of_int (a (n - 1) * a n)) \ 0" proof - define f where "f=(\n. nth_prime (n+1) / (a n * a (n+1)))" define g where "g=(\n. 2*nth_prime n / (a n)^2)" have "\\<^sub>F x in sequentially. norm (f x) \ g x" proof - have "\\<^sub>F n in sequentially. nth_prime (n+1) < 2*nth_prime n" using ratio_of_consecutive_primes[unfolded tendsto_iff ,rule_format,of 1,simplified] apply (elim eventually_mono) by (auto simp :divide_simps dist_norm) moreover have "\\<^sub>F n in sequentially. real_of_int (a n * a (n+1)) \ (a n)^2" apply (rule eventuallyI) using \mono a\ by (auto simp:power2_eq_square a_pos incseq_SucD) ultimately show ?thesis unfolding f_def g_def apply eventually_elim apply (subst norm_divide) apply (rule_tac linordered_field_class.frac_le) using a_pos[rule_format, THEN order.strict_implies_not_eq ] by auto qed moreover have "g \ 0 " using nth_1[THEN tendsto_mult_right_zero,of 2] unfolding g_def by auto ultimately have "f \ 0" using Lim_null_comparison[of f g sequentially] by auto then show ?thesis unfolding f_def by (rule_tac LIMSEQ_imp_Suc) auto qed moreover have "(\n. real_of_int (int (nth_prime n)) / real_of_int (prod a {..n})) \ \" using asm by simp ultimately have "\B>0. \c. (\\<^sub>F n in sequentially. B * int (nth_prime n) = c n * a n - c (n + 1) \ real_of_int \c (n + 1)\ < real_of_int (a n) / 2) \ (\n. real_of_int (c (Suc n)) / real_of_int (a n)) \ 0" using ab_rationality_imp[OF a_pos,of nth_prime] by fast then show thesis apply clarify apply (rule_tac c=c and B=B in that) by auto qed have bac_close:"(\n. B * nth_prime n / a n - c n) \ 0" proof - have "\\<^sub>F n in sequentially. B * nth_prime n - c n * a n + c (n + 1) = 0" using Bc_large by (auto elim!:eventually_mono) then have "\\<^sub>F n in sequentially. (B * nth_prime n - c n * a n + c (n+1)) / a n = 0 " by eventually_elim auto then have "\\<^sub>F n in sequentially. B * nth_prime n / a n - c n + c (n + 1) / a n = 0" apply eventually_elim using a_pos by (auto simp:divide_simps) (metis less_irrefl) then have "(\n. B * nth_prime n / a n - c n + c (n + 1) / a n) \ 0" by (simp add: eventually_mono tendsto_iff) from tendsto_diff[OF this ca_vanish] show ?thesis by auto qed have c_pos:"\\<^sub>F n in sequentially. c n > 0" proof - from bac_close have *:"\\<^sub>F n in sequentially. c n \ 0" apply (elim tendsto_of_int_diff_0) using a_gt_1 apply (eventually_elim) using \B>0\ by auto show ?thesis proof (rule ccontr) assume "\ (\\<^sub>F n in sequentially. c n > 0)" moreover have "\\<^sub>F n in sequentially. c (Suc n) \ 0 \ c n\0" using * eventually_sequentially_Suc[of "\n. c n\0"] by (metis (mono_tags, lifting) eventually_at_top_linorder le_Suc_eq) ultimately have "\\<^sub>F n in sequentially. c n = 0 \ c (Suc n) \ 0" using eventually_elim2 frequently_def by fastforce moreover have "\\<^sub>F n in sequentially. nth_prime n > 0 \ B * nth_prime n = c n * a n - c (n + 1)" using Bc_large by eventually_elim auto ultimately have "\\<^sub>F n in sequentially. c n = 0 \ c (Suc n) \ 0 \ B * nth_prime n = c n * a n - c (n + 1)" using frequently_eventually_frequently by fastforce from frequently_ex[OF this] obtain n where "c n = 0" "c (Suc n) \ 0" "B * nth_prime n = c n * a n - c (n + 1)" by auto then have "B * nth_prime n \ 0" by auto then show False using \B > 0\ by (simp add: mult_le_0_iff) qed qed have B_nth_prime:"\\<^sub>F n in sequentially. nth_prime n > B" proof - have "\\<^sub>F x in sequentially. B+1 \ nth_prime x" using nth_prime_at_top[unfolded filterlim_at_top_ge[where c="nat B+1"] ,rule_format,of "nat B + 1",simplified] apply (elim eventually_mono) using \B>0\ by auto then show ?thesis by (auto elim: eventually_mono) qed have bc_epsilon:"\\<^sub>F n in sequentially. nth_prime (n+1) / nth_prime n > (c (n+1) - \) / c n" when "\>0" "\<1" for \::real proof - have "\\<^sub>F x in sequentially. \c (Suc x) / a x\ < \ / 2" using ca_vanish[unfolded tendsto_iff,rule_format, of "\/2"] \\>0\ by auto moreover then have "\\<^sub>F x in sequentially. \c (x+2) / a (x+1)\ < \ / 2" apply (subst (asm) eventually_sequentially_Suc[symmetric]) by simp moreover have "\\<^sub>F n in sequentially. B * nth_prime (n+1) = c (n+1) * a (n+1) - c (n + 2)" using Bc_large apply (subst (asm) eventually_sequentially_Suc[symmetric]) by (auto elim:eventually_mono) moreover have "\\<^sub>F n in sequentially. c n > 0 \ c (n+1) > 0 \ c (n+2) > 0" proof - have "\\<^sub>F n in sequentially. 0 < c (Suc n)" using c_pos by (subst eventually_sequentially_Suc) simp moreover then have "\\<^sub>F n in sequentially. 0 < c (Suc (Suc n))" using c_pos by (subst eventually_sequentially_Suc) simp ultimately show ?thesis using c_pos by eventually_elim auto qed ultimately show ?thesis using Bc_large proof eventually_elim case (elim n) define \\<^sub>0 \\<^sub>1 where "\\<^sub>0 = c (n+1) / a n" and "\\<^sub>1 = c (n+2) / a (n+1)" have "\\<^sub>0 > 0" "\\<^sub>1 > 0" "\\<^sub>0 < \/2" "\\<^sub>1 < \/2" using a_pos elim \mono a\ by (auto simp add: \\<^sub>0_def \\<^sub>1_def abs_of_pos) have "(\ - \\<^sub>1) * c n > 0" using \\\<^sub>1 > 0\ \\\<^sub>1 < \/2\ \\>0\ elim by auto moreover have "\\<^sub>0 * (c (n+1) - \) > 0" using \\\<^sub>0 > 0\ elim(4) that(2) by force ultimately have "(\ - \\<^sub>1) * c n + \\<^sub>0 * (c (n+1) - \) > 0" by auto moreover have "c n - \\<^sub>0 > 0" using \\\<^sub>0 < \ / 2\ elim(4) that(2) by linarith moreover have "c n > 0" by (simp add: elim(4)) ultimately have "(c (n+1) - \) / c n < (c (n+1) - \\<^sub>1) / (c n - \\<^sub>0)" by (auto simp add:field_simps) also have "... \ (c (n+1) - \\<^sub>1) / (c n - \\<^sub>0) * (a (n+1) / a n)" proof - have "(c (n+1) - \\<^sub>1) / (c n - \\<^sub>0) > 0" by (smt \0 < (\ - \\<^sub>1) * real_of_int (c n)\ \0 < real_of_int (c n) - \\<^sub>0\ divide_pos_pos elim(4) mult_le_0_iff of_int_less_1_iff that(2)) moreover have "(a (n+1) / a n) \ 1" using a_pos \mono a\ by (simp add: mono_def) ultimately show ?thesis by (metis mult_cancel_left1 mult_le_cancel_iff2) qed also have "... = (B * nth_prime (n+1)) / (B * nth_prime n)" proof - have "B * nth_prime n = c n * a n - c (n + 1)" using elim by auto also have "... = a n * (c n - \\<^sub>0)" using a_pos[rule_format,of n] unfolding \\<^sub>0_def by (auto simp:field_simps) finally have "B * nth_prime n = a n * (c n - \\<^sub>0)" . moreover have "B * nth_prime (n+1) = a (n+1) * (c (n+1) - \\<^sub>1)" unfolding \\<^sub>1_def using a_pos[rule_format,of "n+1"] apply (subst \B * nth_prime (n + 1) = c (n + 1) * a (n + 1) - c (n + 2)\) by (auto simp:field_simps) ultimately show ?thesis by (simp add: mult.commute) qed also have "... = nth_prime (n+1) / nth_prime n" using \B>0\ by auto finally show ?case . qed qed have c_ubound:"\x. \n. c n > x" proof (rule ccontr) assume " \ (\x. \n. x < c n)" then obtain ub where "\n. c n \ ub" "ub > 0" by (meson dual_order.trans int_one_le_iff_zero_less le_cases not_le) define pa where "pa = (\n. nth_prime n / a n)" have pa_pos:"\n. pa n > 0" unfolding pa_def by (simp add: a_pos) have "liminf (\n. 1 / pa n) = 0" using nth_2 unfolding pa_def by auto then have "(\y\<^sub>F x in sequentially. ereal (1 / pa x) \ y)" apply (subst less_Liminf_iff[symmetric]) using \0 < B\ \0 < ub\ by auto then have "\\<^sub>F x in sequentially. 1 / pa x < B/(ub+1)" by (meson frequently_mono le_less_trans less_ereal.simps(1)) then have "\\<^sub>F x in sequentially. B*pa x > (ub+1)" apply (elim frequently_elim1) by (metis \0 < ub\ mult.left_neutral of_int_0_less_iff pa_pos pos_divide_less_eq pos_less_divide_eq times_divide_eq_left zless_add1_eq) moreover have "\\<^sub>F x in sequentially. c x \ ub" using \\n. c n \ ub\ by simp ultimately have "\\<^sub>F x in sequentially. B*pa x - c x > 1" by (elim frequently_rev_mp eventually_mono) linarith moreover have "(\n. B * pa n - c n) \0" unfolding pa_def using bac_close by auto from tendstoD[OF this,of 1] have "\\<^sub>F n in sequentially. \B * pa n - c n\ < 1" by auto ultimately have "\\<^sub>F x in sequentially. B*pa x - c x > 1 \ \B * pa x - c x\ < 1" using frequently_eventually_frequently by blast then show False by (simp add: frequently_def) qed have eq_2_11:"\\<^sub>F n in sequentially. c (n+1)>c n \ nth_prime (n+1) > nth_prime n + (1 - \)^2 * a n / B" when "\>0" "\<1" for \::real proof - have "\\<^sub>F x in sequentially. \c (Suc x) / a x\ < \" using ca_vanish[unfolded tendsto_iff,rule_format, of \] \\>0\ by auto moreover have "\\<^sub>F n in sequentially. c n > 0 \ c (n+1) > 0" proof - have "\\<^sub>F n in sequentially. 0 < c (Suc n)" using c_pos by (subst eventually_sequentially_Suc) simp then show ?thesis using c_pos by eventually_elim auto qed ultimately show ?thesis using Bc_large bc_epsilon[OF \\>0\ \\<1\] proof (eventually_elim, rule_tac impI) case (elim n) assume "c n < c (n + 1)" have "c (n+1) / a n < \" using a_pos[rule_format,of n] using elim(1,2) by auto also have "... \ \ * c n" using elim(2) that(1) by auto finally have "c (n+1) / a n < \ * c n" . then have "c (n+1) / c n < \ * a n" using a_pos[rule_format,of n] elim by (auto simp:field_simps) then have "(1 - \) * a n < a n - c (n+1) / c n" by (auto simp:algebra_simps) then have "(1 - \)^2 * a n / B < (1 - \) * (a n - c (n+1) / c n) / B" apply (subst (asm) mult_less_iff1[symmetric, of "(1-\)/B"]) using \\<1\ \B>0\ by (auto simp: divide_simps power2_eq_square mult_less_iff1) then have "nth_prime n + (1 - \)^2 * a n / B < nth_prime n + (1 - \) * (a n - c (n+1) / c n) / B" using \B>0\ by auto also have "... = nth_prime n + (1 - \) * ((c n *a n - c (n+1)) / c n) / B" using elim by (auto simp:field_simps) also have "... = nth_prime n + (1 - \) * (nth_prime n / c n)" proof - have "B * nth_prime n = c n * a n - c (n + 1)" using elim by auto from this[symmetric] show ?thesis using \B>0\ by simp qed also have "... = (1+(1-\)/c n) * nth_prime n" by (auto simp:algebra_simps) also have "... = ((c n+1-\)/c n) * nth_prime n" using elim by (auto simp:divide_simps) also have "... \ ((c (n+1) -\)/c n) * nth_prime n" proof - define cp where "cp = c n+1" have "c (n+1) \ cp" unfolding cp_def using \c n < c (n + 1)\ by auto moreover have "c n>0" "nth_prime n>0" using elim by auto ultimately show ?thesis apply (fold cp_def) by (auto simp:divide_simps) qed also have "... < nth_prime (n+1)" using elim by (auto simp:divide_simps) finally show "real (nth_prime n) + (1 - \)\<^sup>2 * real_of_int (a n) / real_of_int B < real (nth_prime (n + 1))" . qed qed have c_neq_large:"\\<^sub>F n in sequentially. c (n+1) \ c n" proof (rule ccontr) assume "\ (\\<^sub>F n in sequentially. c (n + 1) \ c n)" then have that:"\\<^sub>F n in sequentially. c (n + 1) = c n" unfolding frequently_def . have "\\<^sub>F x in sequentially. (B * int (nth_prime x) = c x * a x - c (x + 1) \ \real_of_int (c (x + 1))\ < real_of_int (a x) / 2) \ 0 < c x \ B < int (nth_prime x) \ (c (x+1)>c x \ nth_prime (x+1) > nth_prime x + a x / (2* B))" using Bc_large c_pos B_nth_prime eq_2_11[of "1-1/ sqrt 2",simplified] by eventually_elim (auto simp:divide_simps) then have "\\<^sub>F m in sequentially. nth_prime (m+1) > (1+1/(2*B))*nth_prime m" proof (elim frequently_eventually_at_top[OF that, THEN frequently_at_top_elim]) fix n assume "c (n + 1) = c n \ (\y\n. (B * int (nth_prime y) = c y * a y - c (y + 1) \ \real_of_int (c (y + 1))\ < real_of_int (a y) / 2) \ 0 < c y \ B < int (nth_prime y) \ (c y < c (y + 1) \ real (nth_prime y) + real_of_int (a y) / real_of_int (2 * B) < real (nth_prime (y + 1))))" then have "c (n + 1) = c n" and Bc_eq:"\y\n. B * int (nth_prime y) = c y * a y - c (y + 1) \ 0 < c y \ \real_of_int (c (y + 1))\ < real_of_int (a y) / 2 \ B < int (nth_prime y) \ (c y < c (y + 1) \ real (nth_prime y) + real_of_int (a y) / real_of_int (2 * B) < real (nth_prime (y + 1)))" by auto obtain m where "n c n" "c nN. N > n \ c N > c n" using c_ubound[rule_format, of "MAX x\{..n}. c x"] by (metis Max_ge atMost_iff dual_order.trans finite_atMost finite_imageI image_eqI linorder_not_le order_refl) then obtain N where "N>n" "c N>c n" by auto define A m where "A={m. n (m+1)\N \ c (m+1) > c n}" and "m = Min A" have "finite A" unfolding A_def by (metis (no_types, lifting) A_def add_leE finite_nat_set_iff_bounded_le mem_Collect_eq) moreover have "N-1\A" unfolding A_def using \c n < c N\ \n < N\ \c (n + 1) = c n\ by (smt Suc_diff_Suc Suc_eq_plus1 Suc_leI Suc_pred add.commute add_diff_inverse_nat add_leD1 diff_is_0_eq' mem_Collect_eq nat_add_left_cancel_less zero_less_one) ultimately have "m\A" using Min_in unfolding m_def by auto then have "n0" unfolding m_def A_def by auto moreover have "c m \ c n" proof (rule ccontr) assume " \ c m \ c n" then have "m-1\A" using \m\A\ \c (n + 1) = c n\ unfolding A_def by auto (smt One_nat_def Suc_eq_plus1 Suc_lessI less_diff_conv) from Min_le[OF \finite A\ this,folded m_def] \m>0\ show False by auto qed ultimately show ?thesis using that[of m] by auto qed have "(1 + 1 / (2 * B)) * nth_prime m < nth_prime m + a m / (2*B)" proof - have "nth_prime m < a m" proof - have "B * int (nth_prime m) < c m * (a m - 1)" using Bc_eq[rule_format,of m] \c m \ c n\ \c n < c (m + 1)\ \n < m\ by (auto simp:algebra_simps) also have "... \ c n * (a m - 1)" by (simp add: \c m \ c n\ a_pos mult_right_mono) finally have "B * int (nth_prime m) < c n * (a m - 1)" . moreover have "c n\B" proof - have " B * int (nth_prime n) = c n * (a n - 1)" "B < int (nth_prime n)" and c_a:"\real_of_int (c (n + 1))\ < real_of_int (a n) / 2" using Bc_eq[rule_format,of n] \c (n + 1) = c n\ by (auto simp:algebra_simps) from this(1) have " c n dvd (B * int (nth_prime n))" by simp moreover have "coprime (c n) (int (nth_prime n))" proof - have "c n < int (nth_prime n)" proof (rule ccontr) assume "\ c n < int (nth_prime n)" then have asm:"c n \ int (nth_prime n)" by auto then have "a n > 2 * nth_prime n" using c_a \c (n + 1) = c n\ by auto then have "a n -1 \ 2 * nth_prime n" by simp then have "a n - 1 > 2 * B" using \B < int (nth_prime n)\ by auto from mult_le_less_imp_less[OF asm this] \B>0\ have "int (nth_prime n) * (2 * B) < c n * (a n - 1)" by auto then show False using \B * int (nth_prime n) = c n * (a n - 1)\ by (smt \0 < B\ \B < int (nth_prime n)\ combine_common_factor mult.commute mult_pos_pos) qed then have "\ nth_prime n dvd c n" by (simp add: Bc_eq zdvd_not_zless) then have "coprime (int (nth_prime n)) (c n)" by (auto intro!:prime_imp_coprime_int) then show ?thesis using coprime_commute by blast qed ultimately have "c n dvd B" using coprime_dvd_mult_left_iff by auto then show ?thesis using \0 < B\ zdvd_imp_le by blast qed moreover have "c n > 0 " using Bc_eq by blast ultimately show ?thesis using \B>0\ by (smt a_pos mult_mono) qed then show ?thesis using \B>0\ by (auto simp:field_simps) qed also have "... < nth_prime (m+1)" using Bc_eq[rule_format, of m] \n \c m \ c n\ \c n < c (m+1)\ by linarith finally show "\j>n. (1 + 1 / real_of_int (2 * B)) * real (nth_prime j) < real (nth_prime (j + 1))" using \m>n\ by auto qed then have "\\<^sub>F m in sequentially. nth_prime (m+1)/nth_prime m > (1+1/(2*B))" by (auto elim:frequently_elim1 simp:field_simps) moreover have "\\<^sub>F m in sequentially. nth_prime (m+1)/nth_prime m < (1+1/(2*B))" using ratio_of_consecutive_primes[unfolded tendsto_iff,rule_format,of "1/(2*B)"] \B>0\ unfolding dist_real_def by (auto elim!:eventually_mono simp:algebra_simps) ultimately show False by (simp add: eventually_mono frequently_def) qed have c_gt_half:"\\<^sub>F N in sequentially. card {n\{N..<2*N}. c n > c (n+1)} > N / 2" proof - define h where "h=(\n. (nth_prime (2*n) - nth_prime n) / sqrt (nth_prime n))" have "\\<^sub>F n in sequentially. h n < n / 2" proof - have "\\<^sub>F n in sequentially. h n < n powr (5/6)" using nth_prime_double_sqrt_less[of "1/3"] unfolding h_def by auto moreover have "\\<^sub>F n in sequentially. n powr (5/6) < (n /2)" by real_asymp ultimately show ?thesis by eventually_elim auto qed moreover have "\\<^sub>F n in sequentially. sqrt (nth_prime n) / a n < 1 / (2*B)" using nth_1[THEN tendsto_real_sqrt,unfolded tendsto_iff ,rule_format,of "1/(2*B)"] \B>0\ a_pos by (auto simp:real_sqrt_divide abs_of_pos) ultimately have "\\<^sub>F x in sequentially. c (x+1) \ c x \ sqrt (nth_prime x) / a x < 1 / (2*B) \ h x < x / 2 \ (c (x+1)>c x \ nth_prime (x+1) > nth_prime x + a x / (2* B))" using c_neq_large B_nth_prime eq_2_11[of "1-1/ sqrt 2",simplified] by eventually_elim (auto simp:divide_simps) then show ?thesis proof (elim eventually_at_top_mono) fix N assume "N\1" and N_asm:"\y\N. c (y + 1) \ c y \ sqrt (real (nth_prime y)) / real_of_int (a y) < 1 / real_of_int (2 * B) \ h y < y / 2 \ (c y < c (y + 1) \ real (nth_prime y) + real_of_int (a y) / real_of_int (2 * B) < real (nth_prime (y + 1)))" define S where "S={n \ {N..<2 * N}. c n < c (n + 1)}" define g where "g=(\n. (nth_prime (n+1) - nth_prime n) / sqrt (nth_prime n))" define f where "f=(\n. nth_prime (n+1) - nth_prime n)" have g_gt_1:"g n>1" when "n\N" "c n < c (n + 1)" for n proof - have "nth_prime n + sqrt (nth_prime n) < nth_prime (n+1)" proof - have "nth_prime n + sqrt (nth_prime n) < nth_prime n + a n / (2*B)" using N_asm[rule_format,OF \n\N\] a_pos by (auto simp:field_simps) also have "... < nth_prime (n+1)" using N_asm[rule_format,OF \n\N\] \c n < c (n + 1)\ by auto finally show ?thesis . qed then show ?thesis unfolding g_def using \c n < c (n + 1)\ by auto qed have g_geq_0:"g n \ 0" for n unfolding g_def by auto have "finite S" "\x\S. x\N \ c x sum g S" proof (induct S) case empty then show ?case by auto next case (insert x F) moreover have "g x>1" proof - have "c x < c (x+1)" "x\N" using insert(4) by auto then show ?thesis using g_gt_1 by auto qed ultimately show ?case by simp qed also have "... \ sum g {N..<2*N}" apply (rule sum_mono2) unfolding S_def using g_geq_0 by auto also have "... \ sum (\n. f n/sqrt (nth_prime N)) {N..<2*N}" unfolding f_def g_def by (auto intro!:sum_mono divide_left_mono) also have "... = sum f {N..<2*N} / sqrt (nth_prime N)" unfolding sum_divide_distrib[symmetric] by auto also have "... = (nth_prime (2*N) - nth_prime N) / sqrt (nth_prime N)" proof - have "sum f {N..<2 * N} = nth_prime (2 * N) - nth_prime N" proof (induct N) case 0 then show ?case by simp next case (Suc N) have ?case if "N=0" proof - have "sum f {Suc N..<2 * Suc N} = sum f {1}" using that by (simp add: numeral_2_eq_2) also have "... = nth_prime 2 - nth_prime 1" unfolding f_def by (simp add:numeral_2_eq_2) also have "... = nth_prime (2 * Suc N) - nth_prime (Suc N)" using that by auto finally show ?thesis . qed moreover have ?case if "N\0" proof - have "sum f {Suc N..<2 * Suc N} = sum f {N..<2 * Suc N} - f N" apply (subst (2) sum.atLeast_Suc_lessThan) using that by auto also have "... = sum f {N..<2 * N}+ f (2*N) + f(2*N+1) - f N" by auto also have "... = nth_prime (2 * Suc N) - nth_prime (Suc N)" using Suc unfolding f_def by auto finally show ?thesis . qed ultimately show ?case by blast qed then show ?thesis by auto qed also have "... = h N" unfolding h_def by auto also have "... < N/2" using N_asm by auto finally have "card S < N/2" . define T where "T={n \ {N..<2 * N}. c n > c (n + 1)}" have "T \ S = {N..<2 * N}" "T \ S = {}" "finite T" unfolding T_def S_def using N_asm by fastforce+ then have "card T + card S = card {N..<2 * N}" using card_Un_disjoint \finite S\ by metis also have "... = N" by simp finally have "card T + card S = N" . with \card S < N/2\ show "card T > N/2" by linarith qed qed text\Inequality (3.5) in the original paper required a slight modification: \ have a_gt_plus:"\\<^sub>F n in sequentially. c n > c (n+1) \a (n+1) > a n + (a n - c(n+1) - 1) / c (n+1)" proof - note a_gt_1[THEN eventually_all_ge_at_top] c_pos[THEN eventually_all_ge_at_top] moreover have "\\<^sub>F n in sequentially. B * int (nth_prime (n+1)) = c (n+1) * a (n+1) - c (n + 2)" using Bc_large apply (subst (asm) eventually_sequentially_Suc[symmetric]) by (auto elim:eventually_mono) moreover have "\\<^sub>F n in sequentially. B * int (nth_prime n) = c n * a n - c (n + 1) \ \c (n + 1)\ < a n / 2" using Bc_large by (auto elim:eventually_mono) ultimately show ?thesis apply (eventually_elim) proof (rule impI) fix n assume "\y\n. 1 < a y" "\y\n. 0 < c y" and Suc_n_eq:"B * int (nth_prime (n + 1)) = c (n + 1) * a (n + 1) - c (n + 2)" and "B * int (nth_prime n) = c n * a n - c (n + 1) \ real_of_int \c (n + 1)\ < real_of_int (a n) / 2" and "c (n + 1) < c n" then have n_eq:"B * int (nth_prime n) = c n * a n - c (n + 1)" and c_less_a: "real_of_int \c (n + 1)\ < real_of_int (a n) / 2" by auto from \\y\n. 1 < a y\ \\y\n. 0 < c y\ have *:"a n>1" "a (n+1) > 1" "c n > 0" "c (n+1) > 0" "c (n+2) > 0" by auto then have "(1+1/c (n+1))* (a n - 1)/a (n+1) = (c (n+1)+1) * ((a n - 1) / (c (n+1) * a (n+1)))" by (auto simp:field_simps) also have "... \ c n * ((a n - 1) / (c (n+1) * a (n+1)))" apply (rule mult_right_mono) subgoal using \c (n + 1) < c n\ by auto subgoal by (smt \0 < c (n + 1)\ a_pos divide_nonneg_pos mult_pos_pos of_int_0_le_iff of_int_0_less_iff) done also have "... = (c n * (a n - 1)) / (c (n+1) * a (n+1))" by auto also have "... < (c n * (a n - 1)) / (c (n+1) * a (n+1) - c (n+2))" apply (rule divide_strict_left_mono) subgoal using \c (n+2) > 0\ by auto unfolding Suc_n_eq[symmetric] using * \B>0\ by auto also have "... < (c n * a n - c (n+1)) / (c (n+1) * a (n+1) - c (n+2))" apply (rule frac_less) unfolding Suc_n_eq[symmetric] using * \B>0\ \c (n + 1) < c n\ by (auto simp:algebra_simps) also have "... = nth_prime n / nth_prime (n+1)" unfolding Suc_n_eq[symmetric] n_eq[symmetric] using \B>0\ by auto also have "... < 1" by auto finally have "(1 + 1 / real_of_int (c (n + 1))) * real_of_int (a n - 1) / real_of_int (a (n + 1)) < 1 " . then show "a n + (a n - c (n + 1) - 1) / (c (n + 1)) < (a (n + 1))" using * by (auto simp:field_simps) qed qed have a_gt_1:"\\<^sub>F n in sequentially. c n > c (n+1) \ a (n+1) > a n + 1" using Bc_large a_gt_plus c_pos[THEN eventually_all_ge_at_top] apply eventually_elim proof (rule impI) fix n assume "c (n + 1) < c n \ a n + (a n - c (n + 1) - 1) / c (n + 1) < a (n + 1)" "c (n + 1) < c n" and B_eq:"B * int (nth_prime n) = c n * a n - c (n + 1) \ \real_of_int (c (n + 1))\ < real_of_int (a n) / 2" and c_pos:"\y\n. 0 < c y" from this(1,2) have "a n + (a n - c (n + 1) - 1) / c (n + 1) < a (n + 1)" by auto moreover have "a n - 2 * c (n+1) > 0" using B_eq c_pos[rule_format,of "n+1"] by auto then have "a n - 2 * c (n+1) \ 1" by simp then have "(a n - c (n + 1) - 1) / c (n + 1) \ 1" using c_pos[rule_format,of "n+1"] by (auto simp:field_simps) ultimately show "a n + 1 < a (n + 1)" by auto qed text\The following corresponds to inequality (3.6) in the paper, which had to be slightly corrected: \ have a_gt_sqrt:"\\<^sub>F n in sequentially. c n > c (n+1) \ a (n+1) > a n + (sqrt n - 2)" proof - have a_2N:"\\<^sub>F N in sequentially. a (2*N) \ N /2 +1" using c_gt_half a_gt_1[THEN eventually_all_ge_at_top] proof eventually_elim case (elim N) define S where "S={n \ {N..<2 * N}. c (n + 1) < c n}" define f where "f = (\n. a (Suc n) - a n)" have f_1:"\x\S. f x\1" and f_0:"\x. f x\0" subgoal using elim unfolding S_def f_def by auto subgoal using \mono a\[THEN incseq_SucD] unfolding f_def by auto done have "N / 2 < card S" using elim unfolding S_def by auto also have "... \ sum f S" unfolding of_int_sum apply (rule sum_bounded_below[of _ 1,simplified]) using f_1 by auto also have "... \ sum f {N..<2 * N}" unfolding of_int_sum apply (rule sum_mono2) unfolding S_def using f_0 by auto also have "... = a (2*N) - a N" unfolding of_int_sum f_def of_int_diff apply (rule sum_Suc_diff') by auto finally have "N / 2 < a (2*N) - a N" . then show ?case using a_pos[rule_format,of N] by linarith qed have a_n4:"\\<^sub>F n in sequentially. a n > n/4" proof - obtain N where a_N:"\n\N. a (2*n) \ n /2+1" using a_2N unfolding eventually_at_top_linorder by auto have "a n>n/4" when "n\2*N" for n proof - define n' where "n'=n div 2" have "n'\N" unfolding n'_def using that by auto have "n/4 < n' /2+1" unfolding n'_def by auto also have "... \ a (2*n')" using a_N \n'\N\ by auto also have "... \a n" unfolding n'_def apply (cases "even n") subgoal by simp subgoal by (simp add: assms(2) incseqD) done finally show ?thesis . qed then show ?thesis unfolding eventually_at_top_linorder by auto qed have c_sqrt:"\\<^sub>F n in sequentially. c n < sqrt n / 4" proof - have "\\<^sub>F x in sequentially. x>1" by simp moreover have "\\<^sub>F x in sequentially. real (nth_prime x) / (real x * ln (real x)) < 2" using nth_prime_asymptotics[unfolded asymp_equiv_def,THEN order_tendstoD(2),of 2] by simp ultimately have "\\<^sub>F n in sequentially. c n < B*8 *ln n + 1" using a_n4 Bc_large proof eventually_elim case (elim n) from this(4) have "c n=(B*nth_prime n+c (n+1))/a n" using a_pos[rule_format,of n] by (auto simp:divide_simps) also have "... = (B*nth_prime n)/a n+c (n+1)/a n" by (auto simp:divide_simps) also have "... < (B*nth_prime n)/a n + 1" proof - have "c (n+1)/a n < 1" using elim(4) by auto then show ?thesis by auto qed also have "... < B*8 * ln n + 1" proof - have "B*nth_prime n < 2*B*n*ln n" using \real (nth_prime n) / (real n * ln (real n)) < 2\ \B>0\ \ 1 < n\ by (auto simp:divide_simps) moreover have "real n / 4 < real_of_int (a n)" by fact ultimately have "(B*nth_prime n) / a n < (2*B*n*ln n) / (n/4)" apply (rule_tac frac_less) using \B>0\ \ 1 < n\ by auto also have "... = B*8 * ln n" using \ 1 < n\ by auto finally show ?thesis by auto qed finally show ?case . qed moreover have "\\<^sub>F n in sequentially. B*8 *ln n + 1 < sqrt n / 4" by real_asymp ultimately show ?thesis by eventually_elim auto qed have "\\<^sub>F n in sequentially. 0 < c (n+1)" "\\<^sub>F n in sequentially. c (n+1) < sqrt (n+1) / 4" "\\<^sub>F n in sequentially. n > 4" "\\<^sub>F n in sequentially. (n - 4) / sqrt (n + 1) + 1 > sqrt n" subgoal using c_pos[THEN eventually_all_ge_at_top] by eventually_elim auto subgoal using c_sqrt[THEN eventually_all_ge_at_top] by eventually_elim (use le_add1 in blast) subgoal by simp subgoal by real_asymp done then show ?thesis using a_gt_plus a_n4 apply eventually_elim proof (rule impI) fix n assume asm:"0 < c (n + 1)" "c (n + 1) < sqrt (real (n + 1)) / 4" and a_ineq:"c (n + 1) < c n \ a n + (a n - c (n + 1) - 1) / c (n + 1) < a (n + 1)" "c (n + 1) < c n" and "n / 4 < a n" "n > 4" and n_neq:" sqrt (real n) < real (n - 4) / sqrt (real (n + 1)) + 1" have "(n-4) / sqrt(n+1) = (n/4 - 1)/ (sqrt (real (n + 1)) / 4)" using \n>4\ by (auto simp:divide_simps) also have "... < (a n - 1) / c (n + 1)" apply (rule frac_less) using \n > 4\ \n / 4 < a n\ \0 < c (n + 1)\ \c (n + 1) < sqrt (real (n + 1)) / 4\ by auto also have "... - 1 = (a n - c (n + 1) - 1) / c (n + 1)" using \0 < c (n + 1)\ by (auto simp:field_simps) also have "a n + ... < a (n+1)" using a_ineq by auto finally have "a n + ((n - 4) / sqrt (n + 1) - 1) < a (n + 1)" by simp moreover have "(n - 4) / sqrt (n + 1) - 1 > sqrt n - 2" using n_neq[THEN diff_strict_right_mono,of 2] \n>4\ by (auto simp:algebra_simps of_nat_diff) ultimately show "real_of_int (a n) + (sqrt (real n) - 2) < real_of_int (a (n + 1))" by argo qed qed text\The following corresponds to inequality $ a_{2N} > N^{3/2}/2$ in the paper, which had to be slightly corrected: \ have a_2N_sqrt:"\\<^sub>F N in sequentially. a (2*N) > real N * (sqrt (real N)/2 - 1)" using c_gt_half a_gt_sqrt[THEN eventually_all_ge_at_top] eventually_gt_at_top[of 4] proof eventually_elim case (elim N) define S where "S={n \ {N..<2 * N}. c (n + 1) < c n}" define f where "f = (\n. a (Suc n) - a n)" have f_N:"\x\S. f x\sqrt N - 2" proof fix x assume "x\S" then have "sqrt (real x) - 2 < f x" "x\N" using elim unfolding S_def f_def by auto moreover have "sqrt x - 2 \ sqrt N - 2" using \x\N\ by simp ultimately show "sqrt (real N) - 2 \ real_of_int (f x)" by argo qed have f_0:"\x. f x\0" using \mono a\[THEN incseq_SucD] unfolding f_def by auto have "(N / 2) * (sqrt N - 2) < card S * (sqrt N - 2)" apply (rule mult_strict_right_mono) subgoal using elim unfolding S_def by auto subgoal using \N>4\ by (metis diff_gt_0_iff_gt numeral_less_real_of_nat_iff real_sqrt_four real_sqrt_less_iff) done also have "... \ sum f S" unfolding of_int_sum apply (rule sum_bounded_below) using f_N by auto also have "... \ sum f {N..<2 * N}" unfolding of_int_sum apply (rule sum_mono2) unfolding S_def using f_0 by auto also have "... = a (2*N) - a N" unfolding of_int_sum f_def of_int_diff apply (rule sum_Suc_diff') by auto finally have "real N / 2 * (sqrt (real N) - 2) < real_of_int (a (2 * N) - a N)" . then have "real N / 2 * (sqrt (real N) - 2) < a (2 * N)" using a_pos[rule_format,of N] by linarith then show ?case by (auto simp:field_simps) qed text\The following part is required to derive the final contradiction of the proof.\ have a_n_sqrt:"\\<^sub>F n in sequentially. a n > (((n-1)/2) powr (3/2) - (n-1)) /2" proof (rule sequentially_even_odd_imp) define f where "f=(\N. ((real (2 * N - 1) / 2) powr (3 / 2) - real (2 * N - 1)) / 2)" define g where "g=(\N. real N * (sqrt (real N) / 2 - 1))" have "\\<^sub>F N in sequentially. g N > f N" unfolding f_def g_def by real_asymp moreover have "\\<^sub>F N in sequentially. a (2 * N) > g N" unfolding g_def using a_2N_sqrt . ultimately show "\\<^sub>F N in sequentially. f N < a (2 * N)" by eventually_elim auto next define f where "f=(\N. ((real (2 * N + 1 - 1) / 2) powr (3 / 2) - real (2 * N + 1 - 1)) / 2)" define g where "g=(\N. real N * (sqrt (real N) / 2 - 1))" have "\\<^sub>F N in sequentially. g N = f N" using eventually_gt_at_top[of 0] apply eventually_elim unfolding f_def g_def by (auto simp:algebra_simps powr_half_sqrt[symmetric] powr_mult_base) moreover have "\\<^sub>F N in sequentially. a (2 * N) > g N" unfolding g_def using a_2N_sqrt . moreover have "\\<^sub>F N in sequentially. a (2 * N + 1) \ a (2*N)" apply (rule eventuallyI) using \mono a\ by (simp add: incseqD) ultimately show "\\<^sub>F N in sequentially. f N < (a (2 * N + 1))" by eventually_elim auto qed have a_nth_prime_gt:"\\<^sub>F n in sequentially. a n / nth_prime n > 1" proof - define f where "f=(\n::nat. (((n-1)/2) powr (3/2) - (n-1)) /2)" have "\\<^sub>F x in sequentially. real (nth_prime x) / (real x * ln (real x)) < 2" using nth_prime_asymptotics[unfolded asymp_equiv_def,THEN order_tendstoD(2),of 2] by simp from this eventually_gt_at_top[of 1] have "\\<^sub>F n in sequentially. real (nth_prime n) < 2*(real n * ln n)" by eventually_elim (auto simp:field_simps) moreover have *:"\\<^sub>F N in sequentially. f N >0 " unfolding f_def by real_asymp moreover have " \\<^sub>F n in sequentially. f n < a n" using a_n_sqrt unfolding f_def . ultimately have "\\<^sub>F n in sequentially. a n / nth_prime n > f n / (2*(real n * ln n))" apply eventually_elim apply (rule frac_less2) by auto moreover have "\\<^sub>F n in sequentially. (f n)/ (2*(real n * ln n)) > 1" unfolding f_def by real_asymp ultimately show ?thesis by eventually_elim argo qed have a_nth_prime_lt:"\\<^sub>F n in sequentially. a n / nth_prime n < 1" proof - have "liminf (\x. a x / nth_prime x) < 1" using nth_2 by auto from this[unfolded less_Liminf_iff] show ?thesis apply (auto elim!:frequently_elim1) by (meson divide_less_eq_1 ereal_less_eq(7) leD leI nth_prime_nonzero of_nat_eq_0_iff of_nat_less_0_iff order.trans) qed from a_nth_prime_gt a_nth_prime_lt show False by (simp add: eventually_mono frequently_def) qed section\Acknowledgements\ text\A.K.-A. and W.L. were supported by the ERC Advanced Grant ALEXANDRIA (Project 742178) funded by the European Research Council and led by Professor Lawrence Paulson at the University of Cambridge, UK.\ end \ No newline at end of file diff --git a/thys/Irrationality_J_Hancl/Irrationality_J_Hancl.thy b/thys/Irrationality_J_Hancl/Irrationality_J_Hancl.thy --- a/thys/Irrationality_J_Hancl/Irrationality_J_Hancl.thy +++ b/thys/Irrationality_J_Hancl/Irrationality_J_Hancl.thy @@ -1,1066 +1,1062 @@ (* File: Irrationality_J_Hancl.thy Authors: Angeliki Koutsoukou-Argyraki and Wenda Li, Computer Laboratory, University of Cambridge, UK. Email: ak2110@cam.ac.uk, wl302@cam.ac.uk *) section \Irrational Rapidly Convergent Series\ theory Irrationality_J_Hancl imports "HOL-Analysis.Analysis" "HOL-Decision_Procs.Approximation" begin text \This is the formalisation of a proof by J. Hancl, in particular of the proof of his Theorem 3 in the paper: Irrational Rapidly Convergent Series, Rend. Sem. Mat. Univ. Padova, Vol 107 (2002). The statement asserts the irrationality of the sum of a series consisting of rational numbers defined using sequences that fulfill certain properties. Even though the statement is number-theoretic, the proof uses only arguments from introductory Analysis.\ text \We show the central result (theorem Hancl3) by proof by contradiction, by making use of some of the auxiliary lemmas. To this end, assuming that the sum is a rational number, for a quantity $\textrm{ALPHA}(n)$ we show that $\textrm{ALPHA}(n) \geq 1$ for all $n \in \mathbb{N}$. After that we show that we can find an $n \in \mathbb{N}$ for which $\textrm{ALPHA}(n) < 1$ which yields a contradiction and we thus conclude that the sum of the series is a rational number. We finally give an immediate application of theorem Hancl3 for a specific series (corollary Hancl3corollary, requiring lemma summable\_ln\_plus) which corresponds to Corollary 2 in the original paper by J. Hancl. \ hide_const floatarith.Max subsection \Misc\ lemma filterlim_sequentially_iff: "filterlim f F1 sequentially \ filterlim (\x. f (x+k)) F1 sequentially" unfolding filterlim_iff apply (subst eventually_sequentially_seg) by auto lemma filterlim_realpow_sequentially_at_top: "(x::real) > 1 \ filterlim ((^) x) at_top sequentially" apply (rule LIMSEQ_divide_realpow_zero[THEN filterlim_inverse_at_top,of _ 1,simplified]) by auto lemma filterlim_at_top_powr_real: fixes g::"'b \ real" assumes "filterlim f at_top F" "(g \ g') F" "g'>1" shows "filterlim (\x. g x powr f x) at_top F" proof - have "filterlim (\x. ((g'+1)/2) powr f x) at_top F" proof (subst filterlim_at_top_gt[of _ _ 1],rule+) fix Z assume "Z>(1::real)" have "\\<^sub>F x in F. ln Z \ ln (((g' + 1) / 2) powr f x)" using assms(1)[unfolded filterlim_at_top,rule_format,of "ln Z / ln ((g' + 1) / 2)"] apply (eventually_elim) using \g'>1\ by (auto simp:ln_powr divide_simps) then show "\\<^sub>F x in F. Z \ ((g' + 1) / 2) powr f x" apply (eventually_elim) apply (subst (asm) ln_le_cancel_iff) using \Z>1\ \g'>1\ by auto qed moreover have "\\<^sub>F x in F. ((g'+1)/2) powr f x \ g x powr f x" proof - have "\\<^sub>F x in F. g x > (g'+1)/2" apply (rule order_tendstoD[OF assms(2)]) using \g'>1\ by auto moreover have "\\<^sub>F x in F. f x>0" using assms(1)[unfolded filterlim_at_top_dense,rule_format,of 0] . ultimately show ?thesis apply eventually_elim using \g'>1\ by (auto intro!: powr_mono2) qed ultimately show ?thesis using filterlim_at_top_mono by fast qed lemma powrfinitesum: fixes a::real and s::nat assumes "s \ n" shows " (\j=s..(n::nat).(a powr (2^j))) = a powr (\j=s..(n::nat).(2^j)) " using \s \ n\ proof(induct n) case 0 then show ?case by auto next case (Suc n) have ?case when "s\n" using Suc.hyps by (metis Suc.prems add.commute linorder_not_le powr_add prod.nat_ivl_Suc' sum.cl_ivl_Suc that) moreover have ?case when "s=Suc n" proof- have "(\j = s..Suc n. a powr 2 ^ j) =(a powr 2 ^(Suc n)) " using \s=Suc n\ by simp also have "(a powr 2 ^(Suc n) ) = a powr sum ((^) 2) {s..Suc n} " using that by auto ultimately show " (\j = s..Suc n. a powr 2 ^ j) = a powr sum ((^) 2) {s..Suc n}" using \s\Suc n\ by linarith qed ultimately show ?case using \s\Suc n\ by linarith qed lemma summable_ratio_test_tendsto: fixes f :: "nat \ 'a::banach" assumes "c < 1" and "\n. f n\0" and "(\n. norm (f (Suc n)) / norm (f n)) \ c" shows "summable f" proof - obtain N where N_dist:"\n\N. dist (norm (f (Suc n)) / norm (f n)) c < (1-c)/2" using assms unfolding tendsto_iff eventually_sequentially by (meson diff_gt_0_iff_gt zero_less_divide_iff zero_less_numeral) have "norm (f (Suc n)) / norm (f n) \ (1+c)/2" when "n\N" for n using N_dist[rule_format,OF that] \c<1\ apply (auto simp add:field_simps dist_norm) by argo then have "norm (f (Suc n)) \ (1+c)/2 * norm (f n)" when "n\N" for n using that assms(2)[rule_format, of n] by (auto simp add:divide_simps) moreover have "(1+c)/2 < 1" using \c<1\ by auto ultimately show ?thesis using summable_ratio_test[of _ N f] by blast qed lemma summable_ln_plus: fixes f::"nat \ real" assumes "summable f" "\n. f n>0" shows "summable (\n. ln (1+f n))" proof (rule summable_comparison_test_ev[OF _ assms(1)]) have "ln (1 + f n) > 0" for n by (simp add: assms(2) ln_gt_zero) moreover have "ln (1 + f n) \ f n" for n apply (rule ln_add_one_self_le_self2) using assms(2)[rule_format,of n] by auto ultimately show "\\<^sub>F n in sequentially. norm (ln (1 + f n)) \ f n" by (auto intro!: eventuallyI simp add:less_imp_le) qed lemma suminf_real_offset_le: fixes f :: "nat \ real" assumes f: "\i. 0 \ f i" and "summable f" shows "(\i. f (i + k)) \ suminf f" proof - have "(\n. \i (\i. f (i + k))" using summable_sums[OF \summable f\] by (simp add: assms(2) summable_LIMSEQ summable_ignore_initial_segment) moreover have "(\n. \i (\i. f i)" using summable_sums[OF \summable f\] by (simp add: sums_def atLeast0LessThan f) then have "(\n. \i (\i. f i)" by (rule LIMSEQ_ignore_initial_segment) ultimately show ?thesis proof (rule LIMSEQ_le, safe intro!: exI[of _ k]) fix n assume "k \ n" have "(\ii (\i. i + k)) i)" by simp also have "\ = (\i\(\i. i + k) ` {.. \ sum f {..i sum f {.. n" shows " (\i=s..n. 2^i) < (2^(n+1) :: real) " using assms proof (induct n) case 0 show ?case by auto next case (Suc n) have ?case when "s=n+1" using that by auto moreover have ?case when "s \ n+1" proof - have"(\i=s..(n+1). 2^i ) = (\i=s..n. 2^i ) + (2::real)^(n+1) " using sum.cl_ivl_Suc \s \ Suc n \ by (auto simp add:add.commute) also have "... < (2) ^ (n +1) + (2)^(n+1)" proof - have "s \n" using that \s \ Suc n \ by auto then show ?thesis using Suc.hyps \s \ n\ by linarith qed also have "... = 2^(n+2)" by simp finally show "(\i=s..(Suc n). 2^i )< (2::real)^(Suc n+1)" by auto qed ultimately show ?case by blast qed subsection \Auxiliary lemmas and the main proof\ lemma showpre7: fixes a b ::"nat\int " and q p::int assumes "q>0" and "p>0"and a: "\n. a n>0" and "\n. b n>0" and assumerational:"(\ n. b (n+1) / a (n+1) ) sums (p/q)" shows "q*((\j=1..n. of_int( a j)))*(suminf (\(j::nat). (b (j+n+1)/ a (j+n+1 )))) = ((\j=1..n. of_int( a j)))*(p -q* (\j=1..n. b j / a j)) " proof - define aa where "aa=(\j = 1..n. real_of_int (a j))" define ff where "ff=(\i. real_of_int (b (i+1)) / real_of_int (a (i+1)))" have "(\j. ff (j+n)) = (\n. ff n) - sum ff {..j=1..n. ff (j-1))" proof - have "sum ff {..j=1..n. ff (j-1))" apply (subst sum_bounds_lt_plus1[symmetric]) by simp then show ?thesis unfolding ff_def by auto qed finally have "(\j. ff (j + n)) = p / q - (\j = 1..n. ff (j - 1))" . then have "q*(\j. ff (j + n)) = p - q*(\j = 1..n. ff (j - 1))" using \q>0\ by (auto simp add:field_simps) then have "aa*q*(\j. ff (j + n)) = aa*(p - q*(\j = 1..n. ff (j - 1)))" by auto then show ?thesis unfolding aa_def ff_def by auto qed lemma show7: fixes d::"nat\real" and a b::"nat\int " and q p::int assumes "q \1" and "p \ 1" and a: "\n. a n \ 1" and "\n. b n \ 1" and assumerational:"(\ n. b (n+1) / a (n+1) ) sums (p/q)" shows "q*((\j=1..n. of_int( a j)))*( suminf (\ (j::nat). (b (j+n+1)/ a (j+n+1 )))) \ 1 " (is "?L \ _") proof- define LL where "LL=?L" define aa where "aa=(\j = 1..n. real_of_int (a j))" define ff where "ff=(\i. real_of_int (b (i+1)) / real_of_int (a (i+1)))" have "?L > 0" proof - have "aa > 0" unfolding aa_def using a apply (induct n,auto) by (simp add: int_one_le_iff_zero_less prod_pos) moreover have "(\j. ff (j + n)) > 0" proof (rule suminf_pos) have "summable ff" unfolding ff_def using assumerational using summable_def by blast then show " summable (\j. ff (j + n))" using summable_iff_shift[of ff n] by auto show "\i. 0 < ff (i + n)" unfolding ff_def using a assms(4) int_one_le_iff_zero_less by auto qed ultimately show ?thesis unfolding aa_def ff_def using \q\1\ by auto qed moreover have "?L \ \" proof - have "?L = aa *(p -q* ( \j=1..n. b j / a j))" unfolding aa_def apply (rule showpre7) using assms int_one_le_iff_zero_less by auto also have "... = aa * p - q * (\j=1..n. aa * b j / a j)" by (auto simp add:algebra_simps sum_distrib_left) also have "... = prod a {1..n} * p - q * (\j = 1..n. b j * prod a ({1..n} - {j}))" proof - have "(\j=1..n. aa * b j / a j) = (\j=1..n. b j * prod a ({1..n} - {j}))" unfolding of_int_sum proof (rule sum.cong) fix x assume "x \ {1..n}" then have "(\i = 1..n. real_of_int (a i)) = a x * (\i\{1..n} - {x}. real_of_int (a i))" apply (rule_tac prod.remove) by auto then have "aa / real_of_int (a x) = prod a ({1..n} - {x})" unfolding aa_def using a[rule_format,of x] by (auto simp add:field_simps) then show "aa * b x / a x = b x * prod a ({1..n} - {x})" by (metis mult.commute of_int_mult times_divide_eq_right) qed simp moreover have "aa * p = (\j = 1..n. (a j)) * p" unfolding aa_def by auto ultimately show ?thesis by force qed also have "... \ \" using Ints_of_int by blast finally show ?thesis . qed ultimately show ?thesis apply (fold LL_def) by (metis Ints_cases int_one_le_iff_zero_less not_less of_int_0_less_iff of_int_less_1_iff) qed lemma show8: fixes d ::"nat\real " and a :: "nat\int" and s k::nat assumes "A > 1" and d: "\n. d n> 1" and a:"\n. a n>0" and "s>0" and "convergent_prod d" and assu2: "\n \ s. ( A/ (of_int (a n)) powr(1/of_int (2^n)))> prodinf (\j. d(n +j))" shows "\n\s. prodinf (\j. d(j+n)) < A/(Max ((\(j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..n}))" proof (intro strip) fix n assume "s \ n" define sp where "sp = (\n. prodinf (\j. d(j+n)))" define ff where "ff = (\(j::nat). (real_of_int (a j)) powr(1 /of_int (2^j)))" have "sp i \ sp n" when "i\n" for i proof - have "(\j. d (j + i)) = (\ia. d (ia + (n - i) + i)) * (\iaj. d (j + i))" using \convergent_prod d\ convergent_prod_iff_shift[of d i] by simp show "\j. j < n - i \ d (j + i) \ 0" by (metis d not_one_less_zero) qed then have "sp i = sp n * (\jn\i\ by (auto simp:algebra_simps) moreover have "sp i>1" "sp n>1" unfolding sp_def using convergent_prod_iff_shift \convergent_prod d\ d by (auto intro!:less_1_prodinf) moreover have "(\j 1" using d less_imp_le by (auto intro: prod_ge_1) ultimately show ?thesis by auto qed moreover have "\j\s. A / ff j > sp j" unfolding ff_def sp_def using assu2 by (auto simp:algebra_simps) ultimately have "\j. s\j \ j\n \ A / ff j > sp n" by force then show "sp n< A / Max (ff ` {s..n})" by (metis (mono_tags, hide_lams) Max_in \n\s\ atLeastAtMost_iff empty_iff finite_atLeastAtMost finite_imageI imageE image_is_empty order_refl) qed lemma auxiliary1_9: fixes d ::"nat\real" and a::"nat\int " and s m::nat assumes d: "\n. d n> 1" and a: "\n. a n>0" and "s>0" and "n \ m" and " m \ s" and auxifalse_assu: "\n\m. (of_int (a (n+1))) powr(1 /of_int (2^(n+1))) < (d (n+1))* (Max ((\ (j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..n} ))" shows "(of_int (a (n+1))) powr(1 /of_int (2^(n+1))) < (\j=(m+1)..(n+1). d j) * (Max ((\ (j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..m}))" proof- define ff where "ff = (\(j::nat). (real_of_int (a j)) powr(1 /of_int (2^j)))" have [simp]:"ff j > 0" for j unfolding ff_def by (metis a less_numeral_extra(3) of_int_0_less_iff powr_gt_zero) have ff_asm:"ff (n+1) < d (n+1) * Max (ff ` {s..n})" when "n\m" for n using auxifalse_assu that unfolding ff_def by simp from \n\m\ have Q: "(Max( ff ` {s..n} )) \ (\j=(m+1)..n. d j)* (Max (ff ` {s..m}))" proof(induct n) case 0 then show ?case using \m\s\ by simp next case (Suc n) have ?case when "m=Suc n" using that by auto moreover have ?case when "m\Suc n" proof - have "m \ n" using that Suc(2) by simp then have IH:"Max (ff ` {s..n}) \ prod d {m + 1..n} * Max (ff ` {s..m})" using Suc(1) by linarith have "Max (ff ` {s..Suc n}) = Max (ff ` {s..n} \ {ff (Suc n)})" using Suc.prems assms(5) atLeastAtMostSuc_conv by auto also have "... = max (Max (ff ` {s..n})) (ff (Suc n))" using Suc.prems assms(5) max_def sup_assoc that by auto also have "... \ max (Max (ff ` {s..n})) (d (n+1) * Max (ff ` {s..n}))" using \m \ n\ ff_asm by fastforce also have "... \ Max (ff ` {s..n}) * max 1 (d (n+1))" proof - have "Max (ff ` {s..n}) \ 0" by (metis (mono_tags, hide_lams) Max_in \\j. 0 < ff j\ \m \ n\ assms(5) atLeastAtMost_iff empty_iff finite_atLeastAtMost finite_imageI imageE image_is_empty less_eq_real_def) then show ?thesis using max_mult_distrib_right by (simp add: max_mult_distrib_right mult.commute) qed also have "... = Max (ff ` {s..n}) * d (n+1)" using d[rule_format, of "n+1"] by auto also have "... \ prod d {m + 1..n} * Max (ff ` {s..m}) * d (n+1)" using IH d[rule_format, of "n+1"] by auto also have "... = prod d {m + 1..n+1} * Max (ff ` {s..m})" using \n\m\ by (simp add:prod.nat_ivl_Suc' algebra_simps) finally show ?case by simp qed ultimately show ?case by blast qed then have "d (n+1) * Max (ff ` {s..n} ) \ (\j=(m+1)..(n+1). d j)* (Max (ff ` {s..m}))" using \m\n\ d[rule_format,of "Suc n"] by (simp add:prod.nat_ivl_Suc') then show ?thesis using ff_asm[of n] \s\m\ \m\n\ unfolding ff_def by auto qed lemma show9: fixes d ::"nat\real " and a :: "nat\int " and s ::nat and A::real assumes "A > 1" and d: "\n. d n> 1" and a: "\n. a n>0" and "s>0" and assu1: "(( \ n. (of_int (a n)) powr(1 /of_int (2^n)))\ A) sequentially " and "convergent_prod d" and 8: "\n\s. prodinf (\j. d( n+j)) < A/(Max ((\(j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..n})) " shows "\m \s. \n\m. ( (of_int (a (n+1))) powr(1 /of_int (2^(n+1))) \ (d (n+1))* (Max ( ( \ (j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..n} )))" proof (rule ccontr) define ff where "ff = (\(j::nat). (real_of_int (a j)) powr(1 /of_int (2^j)))" assume assumptioncontra: " \ (\m \s. \n\m. ( (ff (n+1)) \ (d (n+1))* (Max ( ff ` {s..n}))))" then obtain t where "t\s" and ttt: " \n\t. ( (ff (n+1)) < (d (n+1))* (Max ( ff ` {s..n} ) ))" by fastforce define B where "B=prodinf (\j. d(t+1+j))" have "B>0" unfolding B_def proof (rule less_0_prodinf) show "convergent_prod (\j. d (t + 1 + j))" using convergent_prod_iff_shift[of d "t+1"] \convergent_prod d\ by (auto simp: algebra_simps) show "\i. 0 < d (t + 1 + i)" using d le_less_trans zero_le_one by blast qed have "A \ B * Max ( ff ` {s..t})" proof (rule tendsto_le[of sequentially "\n. (\j=(t+1)..(n+1). d j) * Max ( ff ` {s..t})" _ "\n. ff (n+1)"]) show "(\n. ff (n + 1)) \ A" using assu1[folded ff_def] LIMSEQ_ignore_initial_segment by blast have "(\n. prod d {t + 1..n + 1}) \ B" proof - have "convergent_prod (\j. d (t + 1 + j))" using \convergent_prod d\ convergent_prod_iff_shift[of d "t+1"] by (simp add:algebra_simps) then have "(\n. \i\n. d (t + 1 + i)) \ B" using B_def convergent_prod_LIMSEQ by blast then have "(\n. \i\{0..n}. d (i+(t + 1))) \ B" using atLeast0AtMost by (auto simp:algebra_simps) then have "(\n. prod d {(t + 1)..n + (t + 1)}) \ B" apply (subst (asm) prod.shift_bounds_cl_nat_ivl[symmetric]) by simp from seq_offset_neg[OF this,of "t"] show "(\n. prod d {t + 1..n+1}) \ B" apply (elim Lim_transform) apply (rule LIMSEQ_I) apply (rule exI[where x="t+1"]) by auto qed then show "(\n. prod d {t + 1..n + 1} * Max (ff ` {s..t})) \ B * Max (ff ` {s..t})" by (auto intro:tendsto_eq_intros) have "\\<^sub>F n in sequentially. (ff (n+1)) < (\j=(t+1)..(n+1). d j) * (Max ( ff ` {s..t}))" unfolding eventually_sequentially ff_def using auxiliary1_9[OF d a \s>0\ _ \t\s\ ttt[unfolded ff_def]] by blast then show "\\<^sub>F n in sequentially. (ff (n+1)) \ (\j=(t+1)..(n+1). d j) * (Max ( ff ` {s..t}))" by (eventually_elim,simp) qed simp also have "... \ B * Max ( ff ` {s..t+1})" proof - have "Max (ff ` {s..t}) \ Max (ff ` {s..t + 1})" apply (rule Max_mono) using \t\s\ by auto then show ?thesis using \B>0\ by auto qed finally have "A \ B * Max (ff ` {s..t + 1})" unfolding B_def . moreover have "B < A / Max (ff ` {s..t + 1})" using 8[rule_format, of "t+1",folded ff_def B_def] \s\t\ by auto moreover have "Max (ff ` {s..t+1})>0" using \A \ B * Max (ff ` {s..t + 1})\ \B>0\ \A>1\ zero_less_mult_pos [of B "Max (ff ` {s..Suc t})"] by simp ultimately show False by (auto simp add:field_simps) qed lemma show10: fixes d ::"nat\real " and a ::"nat\int " and s::nat assumes d: "\n. d n> 1" and a: "\n. a n>0" and " s>0" and 9: "\m \s. \n\m. ((of_int (a (n+1))) powr(1 /of_int (2^(n+1))) \ (d (n+1))* (Max ((\(j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..n} )))" shows "\m\s. \n\m. (((d (n+1))powr(2^(n+1))) * (\j=1..n. of_int( a j)) * (1/ (\j=1..s-1. (of_int( a j) )))) \ (a (n+1)) " proof (rule,rule) fix m assume "s \ m" from 9[rule_format,OF this] obtain n where "n\m" and asm_9:"( (of_int (a (n+1))) powr(1 /of_int (2^(n+1))) \ (d (n+1))* (Max ( ( \ (j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..n} )))" by auto with \s\m\ have "s\n" by auto have prod:"(\j=1..n. real_of_int( a j)) * ( 1/ (\j=1..s-1. (of_int( a j) ))) = (\j=s..n. of_int( a j))" proof - define f where "f= (\j. real_of_int( a j))" have "{Suc 0..n}= {Suc 0..s - Suc 0} \ {s..n}" using \n\s\ \s >0\ by auto then have "(\j=1..n. f j) = (\j=1..s-1. f j) * (\j=s..n. f j)" apply (subst prod.union_disjoint[symmetric]) by auto moreover have "(\j=1..s-1. f j) > 0 " by (metis a f_def of_int_0_less_iff prod_pos) then have "(\j=1..s-1. f j) \ 0" by argo ultimately show ?thesis unfolding f_def by auto qed then have "d (n+1) powr 2 ^ (n+1) * (\j = 1..n. of_int (a j)) * (1 / (\j = 1..s - 1. of_int (a j))) = d (n+1) powr 2 ^ (n+1) * (\j = s..n. of_int (a j))" by (metis mult.assoc prod) also have "... \ ((d (n+1))powr(2^(n+1) ) * (\i=s..n. (Max(( \ (j::nat). ( of_int( a j) powr(1 /real_of_int (2^j)) )) ` {s..n } )) powr(2^i)) )" proof (rule mult_left_mono) show "0 \ (d (n + 1)) powr 2 ^ (n + 1)" by auto show "(\j = s..n. real_of_int (a j)) \ (\i = s..n. Max ((\j. real_of_int (a j) powr (1 / real_of_int (2 ^ j))) ` {s..n}) powr 2 ^ i)" proof (rule prod_mono) fix i assume i: "i \ {s..n}" have "real_of_int (a i) = (real_of_int (a i) powr (1 / real_of_int (2 ^ i))) powr 2 ^ i" unfolding powr_powr by (simp add: a less_eq_real_def) also have "\ \ (Max(( \ (j::nat). ( real_of_int( a j) powr(1 /real_of_int (2^j)))) ` {s..n}))powr(2^i)" proof (rule powr_mono2) show "real_of_int (a i) powr (1 / real_of_int (2 ^ i)) \ Max ((\j. real_of_int (a j) powr (1 / real_of_int (2 ^ j))) ` {s..n})" using i by force qed simp_all finally have "real_of_int (a i) \ Max ((\j. real_of_int (a j) powr (1 / real_of_int (2 ^ j))) ` {s..n}) powr 2 ^ i" . then show "0 \ real_of_int (a i) \ real_of_int (a i) \ (MAX j\{s..n}. of_int (a j) powr (1 / of_int (2 ^ j))) powr 2 ^ i" using a i by (metis \real_of_int (a i) = (real_of_int (a i) powr (1 / real_of_int (2 ^ i))) powr 2 ^ i\ powr_ge_pzero) qed qed also have "... = ((d (n+1))powr(2^(n+1) )) * (Max(( \ (j::nat). ( of_int( a j) powr (1 /of_int (2^j)) )) ` {s..n } )) powr (\i=s..n. 2^i ) " proof- have "((d (n+1))powr(2^(n+1) ))\1 " by (metis Transcendental.log_one d le_powr_iff zero_le_numeral zero_le_power zero_less_one) moreover have "(\i=s..n. (Max(( \ (j::nat). ( of_int( a j) powr(1 /real_of_int (2^j)) )) ` {s..n } ) ) powr(2^i)) = (Max(( \ (j::nat). ( of_int( a j) powr(1 /of_int (2^j)) )) ` {s..n } )) powr (\i=s..n. 2^i ) " using \s\n\ powrfinitesum by auto ultimately show ?thesis by auto qed also have "... \ ((d (n+1))powr(2^(n+1) )) * (Max(( \ (j::nat).( of_int( a j) powr(1 /of_int (2^j)) )) ` {s..n })) powr(2^(n+1)) " proof - define ff where "ff \ (MAX j\{s..n}. real_of_int (a j) powr (1 / real_of_int (2 ^ j)))" have " sum ((^) 2) {s..n} < (2::real) ^ (n + 1)" using factt \s\n\ by auto moreover have "1 \ ff" proof - define S where "S=(\(j::nat). ( of_int( a j) powr(1 /real_of_int (2^j)) )) ` {s..n }" have "finite S" unfolding S_def by auto moreover have "S\{}" unfolding S_def using \s\n\ by auto moreover have "\x\S. x\1" proof- have "a s powr (1 / (2^s)) \ 1" proof (rule ge_one_powr_ge_zero) show "1 \ real_of_int (a s)" by (simp add: a int_one_le_iff_zero_less) qed auto moreover have "of_int( a s) powr(1 /real_of_int (2^s)) \ S" unfolding S_def using \s\n\ by auto ultimately show ?thesis by auto qed ultimately show ?thesis using Max_ge_iff[of S 1] unfolding S_def ff_def by blast qed moreover have "0 \ (d (n + 1)) powr 2 ^ (n + 1)" by auto ultimately show ?thesis by (simp add: mult_left_mono powr_mono ff_def) qed also have "... = ((d (n+1)) * (Max((\j. (of_int( a j) powr(1 /of_int (2^j)))) ` {s..n}))) powr(2^(n+1))" proof - define ss where "ss = (\j. real_of_int (a j) powr (1 / real_of_int (2 ^ j))) ` {s..n}" have "d (n + 1) \0" using d[rule_format,of "n+1"] by argo moreover have "Max ss \0" proof - have "(a s) powr (1 / (2 ^ s)) \ 0" by auto moreover have "(a s) powr (1 / (2 ^ s)) \ ss" unfolding ss_def using \s\n\ by auto moreover have "finite ss" "ss \ {}" unfolding ss_def using \s\n\ by auto ultimately show ?thesis using Max_ge_iff[of ss 0] by blast qed ultimately show ?thesis unfolding ss_def using powr_mult by auto qed also have "... \ (real_of_int (a (n + 1)) powr (1 / real_of_int (2 ^ (n + 1)))) powr 2 ^ (n + 1)" proof - define ss where "ss = (\j. real_of_int (a j) powr (1 / real_of_int (2 ^ j))) ` {s..n}" show ?thesis proof (fold ss_def,rule powr_mono2) have "Max ss \0" \ \NOTE: we are repeating the same proof, so it may be a good idea to put this conclusion in an outer block so that it can be reused (without reproving).\ proof - have "(a s) powr (1 / (2 ^ s)) \ 0" by auto moreover have "(a s) powr (1 / (2 ^ s)) \ ss" unfolding ss_def using \s\n\ by auto moreover have "finite ss" "ss \ {}" unfolding ss_def using \s\n\ by auto ultimately show ?thesis using Max_ge_iff[of ss 0] by blast qed moreover have "d (n + 1) \0" using d[rule_format,of "n+1"] by argo ultimately show "0 \ (d (n + 1)) * Max ss" by auto show "(d (n + 1)) * Max ss \ real_of_int (a (n + 1)) powr (1 / real_of_int (2 ^ (n + 1)))" using asm_9[folded ss_def] . qed simp qed also have "... = (of_int (a (n+1)))" by (simp add: a less_eq_real_def pos_add_strict powr_powr) finally show "\n\m. d (n + 1) powr 2 ^ (n + 1) * (\j = 1..n. real_of_int (a j)) * (1 / (\j = 1..s - 1. real_of_int (a j))) \ real_of_int (a (n + 1))" using \n\m\ \m\s\ by force qed lemma lasttoshow: fixes d ::"nat\real " and a b ::"nat\int " and q::int and s::nat assumes d: "\n. d n> 1" and a:"\n. a n>0" and "s>0" and "q>0" and "A > 1" and b:"\n. b n>0" and 9: "\m\s. \n\m. ((of_int (a (n+1))) powr(1 /of_int (2^(n+1))) \ (d (n+1))* (Max ((\(j::nat). (of_int (a j)) powr(1 /of_int (2^j))) ` {s..n} )))" and assu3: "filterlim( \ n. (d n)^(2^n)/ b n) at_top sequentially " and 5: "\\<^sub>F n in sequentially. (\j. (b (n + j)) / (a (n + j))) \ 2 * b n / a n" shows "\n. q*((\j=1..n. real_of_int(a j))) * suminf (\(j::nat). (b (j+n+1)/ a (j+n+1)))<1" proof- define as where "as=(\j = 1..s - 1. real_of_int (a j))" obtain n where "n\s" and n_def1:"real_of_int q * as * 2 * real_of_int (b (n + 1)) / d (n + 1) powr 2 ^ (n + 1) < 1" and n_def2:"d (n + 1) powr 2 ^ (n + 1) * (\j = 1..n. real_of_int (a j)) * (1 / as) \ real_of_int (a (n + 1))" and n_def3:"(\j. (b (n+1 + j)) / (a (n+1 + j))) \ 2 * b (n+1) / a (n+1)" proof - have *:"(\n. real_of_int (b n) / d n ^ 2 ^ n) \ 0" using tendsto_inverse_0_at_top[OF assu3] by auto then have "(\n. real_of_int (b n) / d n powr 2 ^ n) \ 0" proof - have "d n ^ 2 ^ n = d n powr (of_nat (2 ^ n))" for n apply (subst powr_realpow) using d[rule_format, of n] by auto then show ?thesis using * by auto qed from tendsto_mult_right_zero[OF this,of "q * as * 2"] have "(\n. q * as * 2 * b n / d n powr 2 ^ n) \ 0" by auto then have "\\<^sub>F n in sequentially. q * as * 2 * b n / d n powr 2 ^ n < 1" by (elim order_tendstoD) simp then have "\\<^sub>F n in sequentially. q * as * 2 * b n / d n powr 2 ^ n < 1 \ (\j. (b (n + j)) / (a (n + j))) \ 2 * b n / a n" using 5 by eventually_elim auto then obtain N where N_def:"\n\N. q * as * 2 * b n / d n powr 2 ^ n < 1 \ (\j. (b (n + j)) / (a (n + j))) \ 2 * b n / a n" unfolding eventually_sequentially by auto obtain n where "n\s" and "n\N" and n_def:"d (n + 1) powr 2 ^ (n + 1) * (\j = 1..n. of_int (a j)) * (1 / as) \ real_of_int (a (n + 1))" using show10[OF d a \s>0\ 9,folded as_def,rule_format,of "max s N"] by auto with N_def[rule_format, of "n+1"] that[of n] show ?thesis by auto qed define pa where "pa = (\j = 1..n. real_of_int (a j))" define dn where "dn = d (n + 1) powr 2 ^ (n + 1)" have [simp]:"dn >0" "as > 0" subgoal unfolding dn_def by (metis d not_le numeral_One powr_gt_zero zero_le_numeral) subgoal unfolding as_def by (simp add: a prod_pos) done have [simp]:"pa>0" unfolding pa_def using a by (simp add: prod_pos) have K: "q* (\j=1..n. real_of_int (a j)) * suminf (\ (j::nat). (b (j+n+1)/ a (j+n+1))) \q* (\j=1..n. real_of_int (a j)) *2* (b (n+1))/(a( n+1))" apply (fold pa_def) using mult_left_mono[OF n_def3,of "real_of_int q * pa"] \n\s\ \pa>0\ \q>0\ by (auto simp add:algebra_simps) also have KK:"... \ 2*q* (\j=1..n. real_of_int (a j)) * (b(n+1))* ((\j=1..s-1. real_of_int( a j))/((d (n+1))powr(2^(n+1)) * (\j=1..n. real_of_int ( a j))))" proof - have " dn * pa * (1 / as) \ real_of_int (a (n + 1))" using n_def2 unfolding dn_def pa_def . then show ?thesis apply (fold pa_def dn_def as_def) using \pa>0\ \q>0\ a[rule_format, of "Suc n"] b[rule_format, of "Suc n"] by (auto simp add:divide_simps algebra_simps) qed also have KKK: "... = (q* ((\j=1..(s-1). real_of_int( a j)))*2 * (b (n+1)))/ ((d (n+1))powr(2^(n+1)))" apply (fold as_def pa_def dn_def) apply simp using \0 < pa\ by blast also have KKKK: "... < 1" using n_def1 unfolding as_def by simp finally show ?thesis by auto qed lemma fixes d ::"nat\real " and a b ::"nat\int " and A::real assumes "A > 1" and d: "\n. d n> 1" and a: "\n. a n>0" and b:"\n. b n>0" and assu1: "(( \ n. (of_int (a n)) powr(1 /of_int (2^n)))\ A) sequentially " and assu3: "filterlim ( \ n. (d n)^(2^n)/ b n) at_top sequentially" and "convergent_prod d" shows issummable: "summable (\j. b j / a j)" and show5: "\\<^sub>F n in sequentially. (\j. (b (n + j)) / (a (n + j))) \ 2 * b n / a n" proof- define c where "c = (\j. b j / a j)" have c_pos:"c j>0" for j using a b unfolding c_def by simp have c_ratio_tendsto:"(\n. c (n+1) / c n ) \ 0" proof - define nn where "nn=(\n. (2::int)^ (Suc n))" define ff where "ff=(\ n. (a n / a (Suc n)) powr(1 /nn n)*(d(Suc n)))" have nn_pos:"nn n>0" and ff_pos:"ff n>0" for n subgoal unfolding nn_def by simp subgoal unfolding ff_def using d[rule_format, of "Suc n"] a[rule_format, of n] a[rule_format, of "Suc n"] by auto done have ff_tendsto:"ff \ 1/ sqrt A" proof - have "(of_int (a n)) powr(1 / (nn n)) = sqrt(of_int (a n) powr(1 /of_int (2^n)))" for n unfolding nn_def using a by (simp add: powr_half_sqrt [symmetric] powr_powr ac_simps) moreover have "(( \ n. sqrt(of_int (a n) powr(1 /of_int (2^n))))\ sqrt A) sequentially " using assu1 tendsto_real_sqrt by blast ultimately have "(( \ n. (of_int (a n)) powr(1 /of_int (nn n)))\ sqrt A) sequentially " by auto from tendsto_divide[OF this assu1[THEN LIMSEQ_ignore_initial_segment[where k=1]]] have "(\n. (a n / a (Suc n)) powr(1 /nn n)) \ 1/sqrt A" using \A>1\ a unfolding nn_def by (auto simp add:powr_divide less_imp_le inverse_eq_divide sqrt_divide_self_eq) moreover have "(\n. d (Suc n))\ 1" apply (rule convergent_prod_imp_LIMSEQ) using convergent_prod_iff_shift[of d 1] \convergent_prod d\ by auto ultimately show ?thesis unfolding ff_def by (auto intro:tendsto_eq_intros) qed have "(\n. (ff n) powr nn n) \ 0" proof - define aa where "aa=(1+1/sqrt A) / 2" have "eventually (\n. ff nA>1\ by (auto simp add:field_simps) moreover have "(\n. aa powr nn n) \ 0" proof - have "(\y. aa ^ (nat \ nn) y) \ 0" apply (rule tendsto_power_zero) subgoal unfolding nn_def comp_def apply (rule filterlim_subseq) by (auto intro:strict_monoI) subgoal unfolding aa_def using \A>1\ by auto done then show ?thesis proof (elim filterlim_mono_eventually) have "aa>0" unfolding aa_def using \A>1\ by (auto simp add:field_simps pos_add_strict) then show " \\<^sub>F x in sequentially. aa ^ (nat \ nn) x = aa powr real_of_int (nn x)" by (auto simp: powr_int order.strict_implies_order[OF nn_pos]) qed auto qed ultimately show ?thesis apply (elim metric_tendsto_imp_tendsto) apply (auto intro!:powr_mono2 elim!:eventually_mono) using nn_pos ff_pos by (meson le_cases not_le)+ qed then have "(\n. (d (Suc n))^(nat (nn n)) * (a n / a (Suc n))) \ 0" proof (elim filterlim_mono_eventually) show "\\<^sub>F x in sequentially. ff x powr (nn x) = d (Suc x) ^ nat (nn x) * (a x / a (Suc x))" apply (rule eventuallyI) subgoal for x unfolding ff_def using a[rule_format,of x] a[rule_format,of "Suc x"] d[rule_format,of "Suc x"] nn_pos[of x] apply (auto simp add:field_simps powr_divide powr_powr powr_mult ) by (simp add: powr_int) done qed auto moreover have "(\n. b (Suc n) / (d (Suc n))^(nat (nn n))) \ 0" using tendsto_inverse_0_at_top[OF assu3,THEN LIMSEQ_ignore_initial_segment[where k=1]] unfolding nn_def by (auto simp add:field_simps nat_mult_distrib nat_power_eq) ultimately have "(\n. b (Suc n) * (a n / a (Suc n))) \ 0" apply - subgoal premises asm using tendsto_mult[OF asm,simplified] apply (elim filterlim_mono_eventually) using d by (auto simp add:algebra_simps,metis (mono_tags, lifting) always_eventually not_one_less_zero) done then have "(\n. (b (Suc n) / b n) * (a n / a (Suc n))) \ 0" apply (elim Lim_transform_bound[rotated]) apply (rule eventuallyI) subgoal for x using a[rule_format, of x] a[rule_format, of "Suc x"] b[rule_format, of x] b[rule_format, of "Suc x"] by (auto simp add:field_simps) done then show ?thesis unfolding c_def by (auto simp add:algebra_simps) qed from c_ratio_tendsto have "(\n. norm (b (Suc n) / a (Suc n)) / norm (b n / a n)) \ 0" unfolding c_def using a b by (force simp add:divide_simps abs_of_pos intro: Lim_transform_eventually) from summable_ratio_test_tendsto[OF _ _ this] a b show "summable c" unfolding c_def by (metis c_def c_pos less_irrefl zero_less_one) have "\\<^sub>F n in sequentially. (\j. c (n + j)) \ 2 * c n" proof - obtain N where N_ratio:"\n\N. c (n + 1) / c n < 1 / 2" proof - have "eventually (\n. c (n+1) / c n < 1/2) sequentially" using c_ratio_tendsto[unfolded tendsto_iff,rule_format, of "1/2",simplified] apply eventually_elim subgoal for n using c_pos[of n] c_pos[of "Suc n"] by auto done then show ?thesis using that unfolding eventually_sequentially by auto qed have "(\j. c (j + n)) \ 2 * c n" when "n\N" for n proof - have "(\j 2*c n * (1 - 1 / 2^(m+1))" for m proof (induct m) case 0 then show ?case using c_pos[of n] by simp next case (Suc m) have "(\ji c n + (\i c (i + n) / 2" for i using N_ratio[rule_format,of "i+n"] \n\N\ c_pos[of "i+n"] by simp then show ?thesis by (auto intro:sum_mono) qed also have "... = c n + (\i c n + c n * (1 - 1 / 2 ^ (m + 1))" using Suc by auto also have "... = 2 * c n * (1 - 1 / 2 ^ (Suc m + 1))" by (auto simp add:field_simps) finally show ?case . qed then have "(\j 2*c n" for m using c_pos[of n] by (smt divide_le_eq_1_pos divide_pos_pos nonzero_mult_div_cancel_left zero_less_power) moreover have "summable (\j. c (j + n))" using \summable c\ by (simp add: summable_iff_shift) ultimately show ?thesis using suminf_le_const[of "\j. c (j+n)" "2*c n"] by auto qed then show ?thesis unfolding eventually_sequentially by (auto simp add:algebra_simps) qed then show "\\<^sub>F n in sequentially. (\j. (b (n + j)) / (a (n + j))) \ 2 * b n / a n" unfolding c_def by simp qed theorem Hancl3: fixes d ::"nat\real " and a b ::"nat\int " assumes "A > 1" and d:"\n. d n> 1" and a: "\n. a n>0" and b:"\n. b n>0" and "s>0" and assu1: "(( \ n. (of_int (a n)) powr(1 /of_int (2^n)))\ A) sequentially " and assu2: "\n \ s. (A/ (of_int (a n)) powr(1 /of_int (2^n)))> prodinf (\j. d(n +j))" and assu3: "filterlim (\ n. (d n)^(2^n)/ b n) at_top sequentially" and "convergent_prod d" shows "suminf(\ n. b n / a n ) \ Rats" proof(rule ccontr) assume asm:"\ (suminf(\ n. b n / a n ) \ Rats)" have ab_sum:"summable (\j. b j / a j)" using issummable[OF \A>1\ d a b assu1 assu3 \convergent_prod d\] . obtain p q ::int where "q>0" and pq_def:"(\ n. b (n+1) / a (n+1) ) sums (p/q)" proof - from asm have "suminf(\ n. b n / a n ) \ Rats" by auto then have "suminf(\ n. b (n+1) / a (n+1)) \ Rats" apply (subst suminf_minus_initial_segment[OF ab_sum,of 1]) by auto then obtain p' q' ::int where "q'\0" and pq_def:"(\ n. b (n+1) / a (n+1) ) sums (p'/q')" unfolding Rats_eq_int_div_int using summable_ignore_initial_segment[OF ab_sum,of 1,THEN summable_sums] by force define p q where "p=(if q'<0 then - p' else p')" and "q=(if q'<0 then - q' else q')" have "p'/q'=p/q" "q>0" using \q'\0\ unfolding p_def q_def by auto then show ?thesis using that[of q p] pq_def by auto qed define ALPHA where "ALPHA = (\n. (of_int q)*((\j=1..n. of_int(a j)))*(suminf (\ (j::nat). (b (j+n+1)/a (j+n+1)))))" have "ALPHA n \ 1" for n proof - have "suminf(\ n. b (n+1) / a (n+1)) > 0" apply (rule suminf_pos) subgoal using summable_ignore_initial_segment[OF ab_sum,of 1] by auto subgoal using a b by simp done then have "p/q > 0" using sums_unique[OF pq_def,symmetric] by auto then have "q\1" "p\1" using \q>0\ by (auto simp add:divide_simps) moreover have "\n. 1 \ a n" "\n. 1 \ b n" using a b by (auto simp add: int_one_le_iff_zero_less) ultimately show ?thesis unfolding ALPHA_def using show7[OF _ _ _ _ pq_def] by auto qed moreover have "\n. ALPHA n < 1" unfolding ALPHA_def proof (rule lasttoshow[OF d a \s>0\ \q>0\ \A>1\ b _ assu3]) show "\\<^sub>F n in sequentially. (\j. real_of_int (b (n + j)) / real_of_int (a (n + j))) \ real_of_int (2 * b n) / real_of_int (a n)" using show5[OF \A>1\ d a b assu1 assu3 \convergent_prod d\] by simp show "\m\s. \n\m. d (n + 1) * Max ((\j. real_of_int (a j) powr (1 / real_of_int (2 ^ j))) ` {s..n}) \ real_of_int (a (n + 1)) powr (1 / real_of_int (2 ^ (n + 1)))" apply (rule show9[OF \A>1\ d a \s>0\ assu1 \convergent_prod d\]) using show8[OF \A>1\ d a \s>0\ \convergent_prod d\ assu2] by (simp add:algebra_simps) qed ultimately show False using not_le by blast qed corollary Hancl3corollary: fixes A::real and a b ::"nat\int " assumes "A > 1" and a: "\n. a n>0" and b:"\n. b n>0" and assu1: "((\ n. (of_int (a n)) powr(1 /of_int (2^n)))\ A) sequentially " and asscor2: "\n \6. (of_int (a n)) powr(1 /of_int (2^n ))*(1+ 4*(2/3)^n) \ A \ (b n \2 powr((4/3)^(n-1)) ) " shows "suminf(\ n. b n / a n ) \ Rats" proof- define d::"nat\real" where "d= (\ n. 1+(2/3)^(n+1))" have dgt1:"\n. 1 < d n " unfolding d_def by auto moreover have "convergent_prod d" unfolding d_def apply (rule abs_convergent_prod_imp_convergent_prod) apply (rule summable_imp_abs_convergent_prod) - using summable_ignore_initial_segment[OF complete_algebra_summable_geometric - [of "2/3::real",simplified],of 1] by simp + by simp moreover have "\n\6. (\j. d (n + j)) < A / real_of_int (a n) powr (1 / real_of_int (2 ^ n))" - proof rule+ + proof (intro strip) fix n::nat assume "6 \ n" have d_sum:"summable (\j. ln (d j))" unfolding d_def - apply (rule summable_ln_plus) - apply (rule summable_ignore_initial_segment[OF complete_algebra_summable_geometric - [of "2/3::real",simplified],of 1]) - by simp + by (auto intro: summable_ln_plus) have "(\j. ln (d (n + j))) < ln (1+4 * (2 / 3) ^ n)" proof - define c::real where "c=(2 / 3) ^ n" have "0n\6\ apply (subst power_add[symmetric]) by auto also have "... \ (2 / 3)^6" by (auto intro:power_le_one) also have "... < 1/8" by (auto simp add:field_simps) finally show "c<1/8" . qed (simp add:c_def) have "(\j. ln (d (n + j))) \ (\j. (2 / 3) ^ (n + j + 1))" proof (rule suminf_le) show "\j. ln (d (n + j)) \ (2 / 3) ^ (n + j + 1)" unfolding d_def by (metis divide_pos_pos less_eq_real_def ln_add_one_self_le_self zero_less_numeral zero_less_power) show "summable (\j. ln (d (n + j)))" using summable_ignore_initial_segment[OF d_sum] by (force simp add: algebra_simps) show "summable (\j. (2 / 3::real) ^ (n + j + 1))" using summable_geometric[THEN summable_ignore_initial_segment,of "2/3" "n+1"] by (auto simp add:algebra_simps) qed also have "... = (\j. (2 / 3)^(n+1)*(2 / 3) ^ j)" by (auto simp add:algebra_simps power_add) also have "... = (2 / 3)^(n+1) * (\j. (2 / 3) ^ j)" by (force intro!: summable_geometric suminf_mult) also have "... = 2 * c" unfolding c_def apply (subst suminf_geometric) by auto also have "... < 4 * c - (4 * c)\<^sup>2" using \0 \c<1/8\ by (sos "((((A<0 * A<1) * R<1) + ((A<=0 * R<1) * (R<1/16 * [1]^2))))") also have "... \ ln (1 + 4 * c)" apply (rule ln_one_plus_pos_lower_bound) using \0 \c<1/8\ by auto finally show ?thesis unfolding c_def by simp qed then have "exp (\j. ln (d (n + j))) < 1 + 4 * (2 / 3) ^ n" by (metis Groups.mult_ac(2) add.right_neutral add_mono_thms_linordered_field(5) divide_inverse divide_less_eq_numeral1(1) divide_pos_pos exp_gt_zero less_eq_real_def ln_exp ln_less_cancel_iff mult_zero_left rel_simps(27) rel_simps(76) zero_less_one zero_less_power) moreover have "exp (\j. ln (d (n + j))) = (\j. d (n + j))" proof (subst exp_suminf_prodinf_real [symmetric]) show "\k. 0 \ ln (d (n + k))" using dgt1 by (simp add: less_imp_le) show "abs_convergent_prod (\na. exp (ln (d (n + na))))" apply (subst exp_ln) subgoal for j using dgt1[rule_format,of "n+j"] by auto subgoal unfolding abs_convergent_prod_def real_norm_def apply (subst abs_of_nonneg) using convergent_prod_iff_shift[of d n] \convergent_prod d\ by (auto simp add: dgt1 less_imp_le algebra_simps) done show "(\na. exp (ln (d (n + na)))) = (\j. d (n + j))" apply (subst exp_ln) subgoal using dgt1 le_less_trans zero_le_one by blast subgoal by simp done qed ultimately have "(\j. d (n + j)) < 1 + 4 * (2 / 3) ^ n" by simp also have "... \ A / (a n) powr (1 / of_int (2 ^ n))" proof - have "a n powr (1 / real_of_int (2 ^ n)) > 0" using a[rule_format,of n] by auto then show ?thesis using asscor2[rule_format,OF \6\n\] by (auto simp add:field_simps) qed finally show "(\j. d (n + j)) < A / real_of_int (a n) powr (1 / of_int (2 ^ n))" . qed moreover have "LIM n sequentially. d n ^ 2 ^ n / real_of_int (b n) :> at_top" proof - have "LIM n sequentially. d n ^ 2 ^ n / 2 powr((4/3)^(n-1)) :> at_top" proof - define n1 where "n1=(\n. (2::real)* (3/2)^(n-1))" define n2 where "n2=(\n. ((4::real)/3)^(n-1))" have "LIM n sequentially. (((1+(8/9)/(n1 n)) powr (n1 n))/2) powr (n2 n) :> at_top" proof (rule filterlim_at_top_powr_real[where g'="exp (8/9) / (2::real)"]) define e1 where "e1=exp (8/9) / (2::real)" show "e1>1" unfolding e1_def by (approximation 4) show "(\n. ((1+(8/9)/(n1 n)) powr (n1 n))/2) \ e1" proof - have "(\n. (1+(8/9)/(n1 n)) powr (n1 n)) \ exp (8/9)" apply (rule filterlim_compose[OF tendsto_exp_limit_at_top]) unfolding n1_def by (auto intro!: filterlim_tendsto_pos_mult_at_top filterlim_realpow_sequentially_at_top simp:filterlim_sequentially_iff[of "\x. (3 / 2) ^ (x - Suc 0)" _ 1]) then show ?thesis unfolding e1_def by (intro tendsto_intros,auto) qed show "filterlim n2 at_top sequentially" unfolding n2_def apply (subst filterlim_sequentially_iff[of "\n. (4 / 3) ^ (n - 1)" _ 1]) by (auto intro:filterlim_realpow_sequentially_at_top) qed moreover have "\\<^sub>F n in sequentially. (((1+(8/9)/(n1 n)) powr (n1 n))/2) powr (n2 n) = d n ^ 2 ^ n / 2 powr((4/3)^(n-1))" proof (rule eventually_sequentiallyI[of 1]) fix x assume "x\(1::nat)" have " ((1 + 8 / 9 / n1 x) powr n1 x / 2) powr n2 x = (((1 + 8 / 9 / n1 x) powr n1 x) powr n2 x) / 2 powr (4 / 3) ^ (x - 1)" by (simp add:n1_def n2_def powr_divide) also have "... = (1 + 8 / 9 / n1 x) powr (n1 x * n2 x) / 2 powr (4 / 3) ^ (x - 1)" by (simp add: powr_powr) also have "... = (1 + 8 / 9 / n1 x) powr (2 ^ x) / 2 powr (4 / 3) ^ (x - 1)" proof - have "n1 x * n2 x = 2 ^ x" unfolding n1_def n2_def apply (subst mult.assoc) apply (subst power_mult_distrib[symmetric]) using \x\1\ by (auto simp flip:power_Suc) then show ?thesis by simp qed also have "... = (1 + 8 / 9 / n1 x) ^ (2 ^ x) / 2 powr (4 / 3) ^ (x - 1)" apply (subst (3) powr_realpow[symmetric]) apply (simp_all add: n1_def) by (smt zero_le_divide_iff zero_le_power) also have "... = d x ^ 2 ^ x / 2 powr (4 / 3) ^ (x - 1)" proof - define x1 where "x1=x-1" have *:"x=x1+1" unfolding x1_def using \x\1\ by simp have **: "8 / 9 / n1 x = (2 / 3) ^ (x + 1)" unfolding n1_def using \x\1\ apply (fold x1_def *[symmetric]) by (auto simp add:divide_simps) then show ?thesis unfolding d_def apply (subst **) by auto qed finally show "((1 + 8 / 9 / n1 x) powr n1 x / 2) powr n2 x = d x ^ 2 ^ x / 2 powr (4 / 3) ^ (x - 1) " . qed ultimately show ?thesis using filterlim_cong by fast qed moreover have "\\<^sub>F n in sequentially. d n ^ 2 ^ n / 2 powr((4/3)^(n-1)) \ d n ^ 2 ^ n / real_of_int (b n)" apply (rule eventually_sequentiallyI[of 6]) apply (rule divide_left_mono) subgoal for x using asscor2[rule_format,of x] by auto subgoal for x using \\n. 1 < d n\[rule_format, of x] by auto subgoal for x using b by auto done ultimately show ?thesis by (auto elim: filterlim_at_top_mono) qed ultimately show ?thesis using Hancl3[OF \A>1\ _ a b _ assu1,of d 6] by force qed end