src/HOL/Library/NthRoot_Limits.thy
changeset 57025 e7fd64f82876
child 59667 651ea265d568
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Library/NthRoot_Limits.thy	Tue May 20 19:24:39 2014 +0200
     1.3 @@ -0,0 +1,94 @@
     1.4 +theory NthRoot_Limits
     1.5 +  imports Complex_Main "~~/src/HOL/Number_Theory/Binomial"
     1.6 +begin
     1.7 +
     1.8 +text {*
     1.9 +
    1.10 +This does not fit into @{text Complex_Main}, as it depends on @{text Binomial}
    1.11 +
    1.12 +*}
    1.13 +
    1.14 +lemma LIMSEQ_root: "(\<lambda>n. root n n) ----> 1"
    1.15 +proof -
    1.16 +  def x \<equiv> "\<lambda>n. root n n - 1"
    1.17 +  have "x ----> sqrt 0"
    1.18 +  proof (rule tendsto_sandwich[OF _ _ tendsto_const])
    1.19 +    show "(\<lambda>x. sqrt (2 / x)) ----> sqrt 0"
    1.20 +      by (intro tendsto_intros tendsto_divide_0[OF tendsto_const] filterlim_mono[OF filterlim_real_sequentially])
    1.21 +         (simp_all add: at_infinity_eq_at_top_bot)
    1.22 +    { fix n :: nat assume "2 < n"
    1.23 +      have "1 + (real (n - 1) * n) / 2 * x n^2 = 1 + of_nat (n choose 2) * x n^2"
    1.24 +        using `2 < n` unfolding gbinomial_def binomial_gbinomial
    1.25 +        by (simp add: atLeast0AtMost atMost_Suc field_simps real_of_nat_diff numeral_2_eq_2 real_eq_of_nat[symmetric])
    1.26 +      also have "\<dots> \<le> (\<Sum>k\<in>{0, 2}. of_nat (n choose k) * x n^k)"
    1.27 +        by (simp add: x_def)
    1.28 +      also have "\<dots> \<le> (\<Sum>k=0..n. of_nat (n choose k) * x n^k)"
    1.29 +        using `2 < n` by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq)
    1.30 +      also have "\<dots> = (x n + 1) ^ n"
    1.31 +        by (simp add: binomial_ring)
    1.32 +      also have "\<dots> = n"
    1.33 +        using `2 < n` by (simp add: x_def)
    1.34 +      finally have "real (n - 1) * (real n / 2 * (x n)\<^sup>2) \<le> real (n - 1) * 1"
    1.35 +        by simp
    1.36 +      then have "(x n)\<^sup>2 \<le> 2 / real n"
    1.37 +        using `2 < n` unfolding mult_le_cancel_left by (simp add: field_simps)
    1.38 +      from real_sqrt_le_mono[OF this] have "x n \<le> sqrt (2 / real n)"
    1.39 +        by simp }
    1.40 +    then show "eventually (\<lambda>n. x n \<le> sqrt (2 / real n)) sequentially"
    1.41 +      by (auto intro!: exI[of _ 3] simp: eventually_sequentially)
    1.42 +    show "eventually (\<lambda>n. sqrt 0 \<le> x n) sequentially"
    1.43 +      by (auto intro!: exI[of _ 1] simp: eventually_sequentially le_diff_eq x_def)
    1.44 +  qed
    1.45 +  from tendsto_add[OF this tendsto_const[of 1]] show ?thesis
    1.46 +    by (simp add: x_def)
    1.47 +qed
    1.48 +
    1.49 +lemma LIMSEQ_root_const:
    1.50 +  assumes "0 < c"
    1.51 +  shows "(\<lambda>n. root n c) ----> 1"
    1.52 +proof -
    1.53 +  { fix c :: real assume "1 \<le> c"
    1.54 +    def x \<equiv> "\<lambda>n. root n c - 1"
    1.55 +    have "x ----> 0"
    1.56 +    proof (rule tendsto_sandwich[OF _ _ tendsto_const])
    1.57 +      show "(\<lambda>n. c / n) ----> 0"
    1.58 +        by (intro tendsto_divide_0[OF tendsto_const] filterlim_mono[OF filterlim_real_sequentially])
    1.59 +           (simp_all add: at_infinity_eq_at_top_bot)
    1.60 +      { fix n :: nat assume "1 < n"
    1.61 +        have "1 + x n * n = 1 + of_nat (n choose 1) * x n^1"
    1.62 +          using `1 < n` unfolding gbinomial_def binomial_gbinomial by (simp add: real_eq_of_nat[symmetric])
    1.63 +        also have "\<dots> \<le> (\<Sum>k\<in>{0, 1}. of_nat (n choose k) * x n^k)"
    1.64 +          by (simp add: x_def)
    1.65 +        also have "\<dots> \<le> (\<Sum>k=0..n. of_nat (n choose k) * x n^k)"
    1.66 +          using `1 < n` `1 \<le> c` by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq)
    1.67 +        also have "\<dots> = (x n + 1) ^ n"
    1.68 +          by (simp add: binomial_ring)
    1.69 +        also have "\<dots> = c"
    1.70 +          using `1 < n` `1 \<le> c` by (simp add: x_def)
    1.71 +        finally have "x n \<le> c / n"
    1.72 +          using `1 \<le> c` `1 < n` by (simp add: field_simps) }
    1.73 +      then show "eventually (\<lambda>n. x n \<le> c / n) sequentially"
    1.74 +        by (auto intro!: exI[of _ 3] simp: eventually_sequentially)
    1.75 +      show "eventually (\<lambda>n. 0 \<le> x n) sequentially"
    1.76 +        using `1 \<le> c` by (auto intro!: exI[of _ 1] simp: eventually_sequentially le_diff_eq x_def)
    1.77 +    qed
    1.78 +    from tendsto_add[OF this tendsto_const[of 1]] have "(\<lambda>n. root n c) ----> 1"
    1.79 +      by (simp add: x_def) }
    1.80 +  note ge_1 = this
    1.81 +
    1.82 +  show ?thesis
    1.83 +  proof cases
    1.84 +    assume "1 \<le> c" with ge_1 show ?thesis by blast
    1.85 +  next
    1.86 +    assume "\<not> 1 \<le> c"
    1.87 +    with `0 < c` have "1 \<le> 1 / c"
    1.88 +      by simp
    1.89 +    then have "(\<lambda>n. 1 / root n (1 / c)) ----> 1 / 1"
    1.90 +      by (intro tendsto_divide tendsto_const ge_1 `1 \<le> 1 / c` one_neq_zero)
    1.91 +    then show ?thesis
    1.92 +      by (rule filterlim_cong[THEN iffD1, rotated 3])
    1.93 +         (auto intro!: exI[of _ 1] simp: eventually_sequentially real_root_divide)
    1.94 +  qed
    1.95 +qed
    1.96 +
    1.97 +end