src/HOL/Analysis/Integral_Test.thy
author Manuel Eberl <eberlm@in.tum.de>
Mon, 22 Oct 2018 19:03:47 +0200
changeset 69180 922833cc6839
parent 68643 3db6c9338ec1
child 70136 f03a01a18c6e
permissions -rw-r--r--
Tagged some theories in HOL-Analysis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63627
6ddb43c6b711 rename HOL-Multivariate_Analysis to HOL-Analysis.
hoelzl
parents: 63594
diff changeset
     1
(*  Title:    HOL/Analysis/Integral_Test.thy
62055
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
     2
    Author:   Manuel Eberl, TU München
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
     3
*)
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
     4
62055
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
     5
section \<open>Integral Test for Summability\<close>
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
     6
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
     7
theory Integral_Test
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
     8
imports Henstock_Kurzweil_Integration
62055
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
     9
begin
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
    10
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
    11
text \<open>
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
    12
  The integral test for summability. We show here that for a decreasing non-negative
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
    13
  function, the infinite sum over that function evaluated at the natural numbers
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    14
  converges iff the corresponding integral converges.
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
    15
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    16
  As a useful side result, we also provide some results on the difference between
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    17
  the integral and the partial sum. (This is useful e.g. for the definition of the
62174
fae6233c5f37 eliminated spurious Unicode;
wenzelm
parents: 62055
diff changeset
    18
  Euler-Mascheroni constant)
62055
755fda743c49 Multivariate-Analysis: fixed headers and a LaTex error (c.f. Isabelle b0f941e207cf)
hoelzl
parents: 62049
diff changeset
    19
\<close>
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    20
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    21
(* TODO: continuous_in \<rightarrow> integrable_on *)
68643
3db6c9338ec1 Tagged some more files in HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 64267
diff changeset
    22
locale%important antimono_fun_sum_integral_diff =
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    23
  fixes f :: "real \<Rightarrow> real"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    24
  assumes dec: "\<And>x y. x \<ge> 0 \<Longrightarrow> x \<le> y \<Longrightarrow> f x \<ge> f y"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    25
  assumes nonneg: "\<And>x. x \<ge> 0 \<Longrightarrow> f x \<ge> 0"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    26
  assumes cont: "continuous_on {0..} f"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    27
begin
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    28
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    29
definition "sum_integral_diff_series n = (\<Sum>k\<le>n. f (of_nat k)) - (integral {0..of_nat n} f)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    30
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    31
lemma sum_integral_diff_series_nonneg:
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    32
  "sum_integral_diff_series n \<ge> 0"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    33
proof -
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    34
  note int = integrable_continuous_real[OF continuous_on_subset[OF cont]]
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    35
  let ?int = "\<lambda>a b. integral {of_nat a..of_nat b} f"
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
    36
  have "-sum_integral_diff_series n = ?int 0 n - (\<Sum>k\<le>n. f (of_nat k))"
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    37
    by (simp add: sum_integral_diff_series_def)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    38
  also have "?int 0 n = (\<Sum>k<n. ?int k (Suc k))"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    39
  proof (induction n)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    40
    case (Suc n)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    41
    have "?int 0 (Suc n) = ?int 0 n + ?int n (Suc n)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    42
      by (intro integral_combine[symmetric] int) simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    43
    with Suc show ?case by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    44
  qed simp_all
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    45
  also have "... \<le> (\<Sum>k<n. integral {of_nat k..of_nat (Suc k)} (\<lambda>_::real. f (of_nat k)))"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63627
diff changeset
    46
    by (intro sum_mono integral_le int) (auto intro: dec)
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    47
  also have "... = (\<Sum>k<n. f (of_nat k))" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    48
  also have "\<dots> - (\<Sum>k\<le>n. f (of_nat k)) = -(\<Sum>k\<in>{..n} - {..<n}. f (of_nat k))"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 63627
diff changeset
    49
    by (subst sum_diff) auto
b9a1486e79be setsum -> sum
nipkow
parents: 63627
diff changeset
    50
  also have "\<dots> \<le> 0" by (auto intro!: sum_nonneg nonneg)
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    51
  finally show "sum_integral_diff_series n \<ge> 0" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    52
qed
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    53
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    54
lemma sum_integral_diff_series_antimono:
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    55
  assumes "m \<le> n"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    56
  shows   "sum_integral_diff_series m \<ge> sum_integral_diff_series n"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    57
proof -
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    58
  let ?int = "\<lambda>a b. integral {of_nat a..of_nat b} f"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    59
  note int = integrable_continuous_real[OF continuous_on_subset[OF cont]]
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    60
  have d_mono: "sum_integral_diff_series (Suc n) \<le> sum_integral_diff_series n" for n
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    61
  proof -
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    62
    fix n :: nat
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
    63
    have "sum_integral_diff_series (Suc n) - sum_integral_diff_series n =
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    64
            f (of_nat (Suc n)) + (?int 0 n - ?int 0 (Suc n))"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    65
      unfolding sum_integral_diff_series_def by (simp add: algebra_simps)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    66
    also have "?int 0 n - ?int 0 (Suc n) = -?int n (Suc n)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    67
      by (subst integral_combine [symmetric, of "of_nat 0" "of_nat n" "of_nat (Suc n)"])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    68
         (auto intro!: int simp: algebra_simps)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    69
    also have "?int n (Suc n) \<ge> integral {of_nat n..of_nat (Suc n)} (\<lambda>_::real. f (of_nat (Suc n)))"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    70
      by (intro integral_le int) (auto intro: dec)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    71
    hence "f (of_nat (Suc n)) + -?int n (Suc n) \<le> 0" by (simp add: algebra_simps)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    72
    finally show "sum_integral_diff_series (Suc n) \<le> sum_integral_diff_series n" by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    73
  qed
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    74
  with assms show ?thesis
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    75
    by (induction rule: inc_induct) (auto intro: order.trans[OF _ d_mono])
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    76
qed
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    77
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    78
lemma sum_integral_diff_series_Bseq: "Bseq sum_integral_diff_series"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    79
proof -
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
    80
  from sum_integral_diff_series_nonneg and sum_integral_diff_series_antimono
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    81
    have "norm (sum_integral_diff_series n) \<le> sum_integral_diff_series 0" for n by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    82
  thus "Bseq sum_integral_diff_series" by (rule BseqI')
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    83
qed
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    84
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    85
lemma sum_integral_diff_series_monoseq: "monoseq sum_integral_diff_series"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    86
  using sum_integral_diff_series_antimono unfolding monoseq_def by blast
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    87
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    88
lemma sum_integral_diff_series_convergent: "convergent sum_integral_diff_series"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    89
  using sum_integral_diff_series_Bseq sum_integral_diff_series_monoseq
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    90
  by (blast intro!: Bseq_monoseq_convergent)
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    91
68643
3db6c9338ec1 Tagged some more files in HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 64267
diff changeset
    92
theorem integral_test:
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    93
  "summable (\<lambda>n. f (of_nat n)) \<longleftrightarrow> convergent (\<lambda>n. integral {0..of_nat n} f)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    94
proof -
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    95
  have "summable (\<lambda>n. f (of_nat n)) \<longleftrightarrow> convergent (\<lambda>n. \<Sum>k\<le>n. f (of_nat k))"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    96
    by (simp add: summable_iff_convergent')
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    97
  also have "... \<longleftrightarrow> convergent (\<lambda>n. integral {0..of_nat n} f)"
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    98
  proof
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
    99
    assume "convergent (\<lambda>n. \<Sum>k\<le>n. f (of_nat k))"
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
   100
    from convergent_diff[OF this sum_integral_diff_series_convergent]
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
   101
      show "convergent (\<lambda>n. integral {0..of_nat n} f)"
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   102
        unfolding sum_integral_diff_series_def by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   103
  next
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   104
    assume "convergent (\<lambda>n. integral {0..of_nat n} f)"
63594
bd218a9320b5 HOL-Multivariate_Analysis: rename theories for more descriptive names
hoelzl
parents: 62390
diff changeset
   105
    from convergent_add[OF this sum_integral_diff_series_convergent]
62049
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   106
      show "convergent (\<lambda>n. \<Sum>k\<le>n. f (of_nat k))" unfolding sum_integral_diff_series_def by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   107
  qed
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   108
  finally show ?thesis by simp
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   109
qed
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   110
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   111
end
b0f941e207cf Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
eberlm
parents:
diff changeset
   112
62390
842917225d56 more canonical names
nipkow
parents: 62174
diff changeset
   113
end