src/HOL/Multivariate_Analysis/PolyRoots.thy
author paulson <lp15@cam.ac.uk>
Wed Mar 19 14:54:45 2014 +0000 (2014-03-19)
changeset 56215 fcf90317383d
child 57129 7edb7550663e
permissions -rw-r--r--
New complex analysis material
lp15@56215
     1
header {* polynomial functions: extremal behaviour and root counts *}
lp15@56215
     2
lp15@56215
     3
(*  Author: John Harrison and Valentina Bruno
lp15@56215
     4
    Ported from "hol_light/Multivariate/complexes.ml" by L C Paulson
lp15@56215
     5
*)
lp15@56215
     6
lp15@56215
     7
theory PolyRoots
lp15@56215
     8
imports Complex_Main
lp15@56215
     9
lp15@56215
    10
begin
lp15@56215
    11
lp15@56215
    12
subsection{*Geometric progressions*}
lp15@56215
    13
lp15@56215
    14
lemma setsum_gp_basic:
lp15@56215
    15
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    16
  shows "(1 - x) * (\<Sum>i\<le>n. x^i) = 1 - x^Suc n"
lp15@56215
    17
  by (simp only: one_diff_power_eq [of "Suc n" x] lessThan_Suc_atMost)
lp15@56215
    18
lp15@56215
    19
lemma setsum_gp0:
lp15@56215
    20
 fixes x :: "'a::{comm_ring,division_ring_inverse_zero}"
lp15@56215
    21
 shows   "(\<Sum>i\<le>n. x^i) = (if x = 1 then of_nat(n + 1) else (1 - x^Suc n) / (1 - x))"
lp15@56215
    22
using setsum_gp_basic[of x n]
lp15@56215
    23
apply (simp add: real_of_nat_def)
lp15@56215
    24
by (metis eq_iff_diff_eq_0 mult_commute nonzero_eq_divide_eq)
lp15@56215
    25
lp15@56215
    26
lemma setsum_power_shift:
lp15@56215
    27
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    28
  assumes "m \<le> n"
lp15@56215
    29
  shows "(\<Sum>i=m..n. x^i) = x^m * (\<Sum>i\<le>n-m. x^i)"
lp15@56215
    30
proof -
lp15@56215
    31
  have "(\<Sum>i=m..n. x^i) = x^m * (\<Sum>i=m..n. x^(i-m))"
lp15@56215
    32
    by (simp add: setsum_right_distrib power_add [symmetric])
lp15@56215
    33
  also have "... = x^m * (\<Sum>i\<le>n-m. x^i)"
lp15@56215
    34
    apply (subst setsum_reindex_cong [where f = "%i. i+m" and A = "{..n-m}"])
lp15@56215
    35
    apply (auto simp: image_def)
lp15@56215
    36
    apply (rule_tac x="x-m" in bexI, auto)
lp15@56215
    37
    by (metis assms ordered_cancel_comm_monoid_diff_class.le_diff_conv2)
lp15@56215
    38
  finally show ?thesis .
lp15@56215
    39
qed
lp15@56215
    40
lp15@56215
    41
lemma setsum_gp_multiplied:
lp15@56215
    42
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    43
  assumes "m \<le> n"
lp15@56215
    44
  shows "(1 - x) * (\<Sum>i=m..n. x^i) = x^m - x^Suc n"
lp15@56215
    45
proof -
lp15@56215
    46
  have  "(1 - x) * (\<Sum>i=m..n. x^i) = x^m * (1 - x) * (\<Sum>i\<le>n-m. x^i)"
lp15@56215
    47
    by (metis ab_semigroup_mult_class.mult_ac(1) assms mult_commute setsum_power_shift)
lp15@56215
    48
  also have "... =x^m * (1 - x^Suc(n-m))"
lp15@56215
    49
    by (metis ab_semigroup_mult_class.mult_ac(1) setsum_gp_basic)
lp15@56215
    50
  also have "... = x^m - x^Suc n"
lp15@56215
    51
    using assms
lp15@56215
    52
    by (simp add: algebra_simps) (metis le_add_diff_inverse power_add)
lp15@56215
    53
  finally show ?thesis .
lp15@56215
    54
qed
lp15@56215
    55
lp15@56215
    56
lemma setsum_gp:
lp15@56215
    57
  fixes x :: "'a::{comm_ring,division_ring_inverse_zero}"
lp15@56215
    58
  shows   "(\<Sum>i=m..n. x^i) =
lp15@56215
    59
               (if n < m then 0
lp15@56215
    60
                else if x = 1 then of_nat((n + 1) - m)
lp15@56215
    61
                else (x^m - x^Suc n) / (1 - x))"
lp15@56215
    62
using setsum_gp_multiplied [of m n x] 
lp15@56215
    63
apply (auto simp: real_of_nat_def)
lp15@56215
    64
by (metis eq_iff_diff_eq_0 mult_commute nonzero_divide_eq_eq)
lp15@56215
    65
lp15@56215
    66
lemma setsum_gp_offset:
lp15@56215
    67
  fixes x :: "'a::{comm_ring,division_ring_inverse_zero}"
lp15@56215
    68
  shows   "(\<Sum>i=m..m+n. x^i) =
lp15@56215
    69
       (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))"
lp15@56215
    70
  using setsum_gp [of x m "m+n"]
lp15@56215
    71
  by (auto simp: power_add algebra_simps)
lp15@56215
    72
lp15@56215
    73
subsection{*Basics about polynomial functions: extremal behaviour and root counts.*}
lp15@56215
    74
lp15@56215
    75
lemma sub_polyfun:
lp15@56215
    76
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    77
  shows   "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = 
lp15@56215
    78
           (x - y) * (\<Sum>j<n. \<Sum>k= Suc j..n. a k * y^(k - Suc j) * x^j)"
lp15@56215
    79
proof -
lp15@56215
    80
  have "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = 
lp15@56215
    81
        (\<Sum>i\<le>n. a i * (x^i - y^i))"
lp15@56215
    82
    by (simp add: algebra_simps setsum_subtractf [symmetric])
lp15@56215
    83
  also have "... = (\<Sum>i\<le>n. a i * (x - y) * (\<Sum>j<i. y^(i - Suc j) * x^j))"
lp15@56215
    84
    by (simp add: power_diff_sumr2 mult_ac)
lp15@56215
    85
  also have "... = (x - y) * (\<Sum>i\<le>n. (\<Sum>j<i. a i * y^(i - Suc j) * x^j))"
lp15@56215
    86
    by (simp add: setsum_right_distrib mult_ac)
lp15@56215
    87
  also have "... = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - Suc j) * x^j))"
lp15@56215
    88
    by (simp add: nested_setsum_swap')
lp15@56215
    89
  finally show ?thesis .
lp15@56215
    90
qed
lp15@56215
    91
lp15@56215
    92
lemma sub_polyfun_alt:
lp15@56215
    93
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    94
  shows   "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = 
lp15@56215
    95
           (x - y) * (\<Sum>j<n. \<Sum>k<n-j. a (j+k+1) * y^k * x^j)"
lp15@56215
    96
proof -
lp15@56215
    97
  { fix j
lp15@56215
    98
    assume "j < n"
lp15@56215
    99
    have "(\<Sum>k = Suc j..n. a k * y^(k - Suc j) * x^j) =
lp15@56215
   100
          (\<Sum>k <n - j. a (Suc (j + k)) * y^k * x^j)"
lp15@56215
   101
      apply (rule_tac f = "\<lambda>i. Suc j + i" in setsum_reindex_cong)
lp15@56215
   102
      apply (auto simp: inj_on_def image_def atLeastLessThan_def lessThan_def)
lp15@56215
   103
      apply (metis Suc_le_eq diff_add_inverse diff_less_mono le_add1 less_imp_Suc_add)
lp15@56215
   104
      done }
lp15@56215
   105
  then show ?thesis
lp15@56215
   106
    by (simp add: sub_polyfun)
lp15@56215
   107
qed
lp15@56215
   108
lp15@56215
   109
lemma polyfun_linear_factor:
lp15@56215
   110
  fixes a :: "'a::{comm_ring,monoid_mult}"
lp15@56215
   111
  shows  "\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z^i) = 
lp15@56215
   112
                  (z-a) * (\<Sum>i<n. b i * z^i) + (\<Sum>i\<le>n. c i * a^i)"
lp15@56215
   113
proof -
lp15@56215
   114
  { fix z
lp15@56215
   115
    have "(\<Sum>i\<le>n. c i * z^i) - (\<Sum>i\<le>n. c i * a^i) = 
lp15@56215
   116
          (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a^(k - Suc j)) * z^j)"
lp15@56215
   117
      by (simp add: sub_polyfun setsum_left_distrib)
lp15@56215
   118
    then have "(\<Sum>i\<le>n. c i * z^i) = 
lp15@56215
   119
          (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a^(k - Suc j)) * z^j)
lp15@56215
   120
          + (\<Sum>i\<le>n. c i * a^i)"
lp15@56215
   121
      by (simp add: algebra_simps) }
lp15@56215
   122
  then show ?thesis
lp15@56215
   123
    by (intro exI allI) 
lp15@56215
   124
qed
lp15@56215
   125
lp15@56215
   126
lemma polyfun_linear_factor_root:
lp15@56215
   127
  fixes a :: "'a::{comm_ring,monoid_mult}"
lp15@56215
   128
  assumes "(\<Sum>i\<le>n. c i * a^i) = 0"
lp15@56215
   129
  shows  "\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z^i) = (z-a) * (\<Sum>i<n. b i * z^i)"
lp15@56215
   130
  using polyfun_linear_factor [of c n a] assms
lp15@56215
   131
  by simp
lp15@56215
   132
lp15@56215
   133
lemma adhoc_norm_triangle: "a + norm(y) \<le> b ==> norm(x) \<le> a ==> norm(x + y) \<le> b"
lp15@56215
   134
  by (metis norm_triangle_mono order.trans order_refl)
lp15@56215
   135
lp15@56215
   136
lemma polyfun_extremal_lemma:
lp15@56215
   137
  fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
lp15@56215
   138
  assumes "e > 0"
lp15@56215
   139
    shows "\<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm(\<Sum>i\<le>n. c i * z^i) \<le> e * norm(z) ^ Suc n"
lp15@56215
   140
proof (induction n)
lp15@56215
   141
  case 0
lp15@56215
   142
  show ?case 
lp15@56215
   143
    by (rule exI [where x="norm (c 0) / e"]) (auto simp: mult_commute pos_divide_le_eq assms)
lp15@56215
   144
next
lp15@56215
   145
  case (Suc n)
lp15@56215
   146
  then obtain M where M: "\<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z^i) \<le> e * norm z ^ Suc n" ..
lp15@56215
   147
  show ?case
lp15@56215
   148
  proof (rule exI [where x="max 1 (max M ((e + norm(c(Suc n))) / e))"], clarify)
lp15@56215
   149
    fix z::'a
lp15@56215
   150
    assume "max 1 (max M ((e + norm (c (Suc n))) / e)) \<le> norm z"
lp15@56215
   151
    then have norm1: "0 < norm z" "M \<le> norm z" "(e + norm (c (Suc n))) / e \<le> norm z"
lp15@56215
   152
      by auto
lp15@56215
   153
    then have norm2: "(e + norm (c (Suc n))) \<le> e * norm z"  "(norm z * norm z ^ n) > 0"
lp15@56215
   154
      apply (metis assms less_divide_eq mult_commute not_le) 
lp15@56215
   155
      using norm1 apply (metis mult_pos_pos zero_less_power)
lp15@56215
   156
      done
lp15@56215
   157
    have "e * (norm z * norm z ^ n) + norm (c (Suc n) * (z * z ^ n)) =
lp15@56215
   158
          (e + norm (c (Suc n))) * (norm z * norm z ^ n)"
lp15@56215
   159
      by (simp add: norm_mult norm_power algebra_simps)
lp15@56215
   160
    also have "... \<le> (e * norm z) * (norm z * norm z ^ n)"
lp15@56215
   161
      using norm2 by (metis real_mult_le_cancel_iff1) 
lp15@56215
   162
    also have "... = e * (norm z * (norm z * norm z ^ n))"
lp15@56215
   163
      by (simp add: algebra_simps)
lp15@56215
   164
    finally have "e * (norm z * norm z ^ n) + norm (c (Suc n) * (z * z ^ n))
lp15@56215
   165
                  \<le> e * (norm z * (norm z * norm z ^ n))" .
lp15@56215
   166
    then show "norm (\<Sum>i\<le>Suc n. c i * z^i) \<le> e * norm z ^ Suc (Suc n)" using M norm1
lp15@56215
   167
      by (drule_tac x=z in spec) (auto simp: intro!: adhoc_norm_triangle)
lp15@56215
   168
    qed
lp15@56215
   169
qed
lp15@56215
   170
lp15@56215
   171
lemma norm_lemma_xy: "\<lbrakk>abs b + 1 \<le> norm(y) - a; norm(x) \<le> a\<rbrakk> \<Longrightarrow> b \<le> norm(x + y)"
lp15@56215
   172
  by (metis abs_add_one_not_less_self add_commute diff_le_eq dual_order.trans le_less_linear 
lp15@56215
   173
         norm_diff_ineq)
lp15@56215
   174
lp15@56215
   175
lemma polyfun_extremal:
lp15@56215
   176
  fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
lp15@56215
   177
  assumes "\<exists>k. k \<noteq> 0 \<and> k \<le> n \<and> c k \<noteq> 0"
lp15@56215
   178
    shows "eventually (\<lambda>z. norm(\<Sum>i\<le>n. c i * z^i) \<ge> B) at_infinity"
lp15@56215
   179
using assms
lp15@56215
   180
proof (induction n)
lp15@56215
   181
  case 0 then show ?case
lp15@56215
   182
    by simp
lp15@56215
   183
next
lp15@56215
   184
  case (Suc n)
lp15@56215
   185
  show ?case
lp15@56215
   186
  proof (cases "c (Suc n) = 0")
lp15@56215
   187
    case True
lp15@56215
   188
    with Suc show ?thesis
lp15@56215
   189
      by auto (metis diff_is_0_eq diffs0_imp_equal less_Suc_eq_le not_less_eq)
lp15@56215
   190
  next
lp15@56215
   191
    case False
lp15@56215
   192
    with polyfun_extremal_lemma [of "norm(c (Suc n)) / 2" c n]
lp15@56215
   193
    obtain M where M: "\<And>z. M \<le> norm z \<Longrightarrow> 
lp15@56215
   194
               norm (\<Sum>i\<le>n. c i * z^i) \<le> norm (c (Suc n)) / 2 * norm z ^ Suc n"
lp15@56215
   195
      by auto
lp15@56215
   196
    show ?thesis
lp15@56215
   197
    unfolding eventually_at_infinity
lp15@56215
   198
    proof (rule exI [where x="max M (max 1 ((abs B + 1) / (norm (c (Suc n)) / 2)))"], clarsimp)
lp15@56215
   199
      fix z::'a
lp15@56215
   200
      assume les: "M \<le> norm z"  "1 \<le> norm z"  "(\<bar>B\<bar> * 2 + 2) / norm (c (Suc n)) \<le> norm z"
lp15@56215
   201
      then have "\<bar>B\<bar> * 2 + 2 \<le> norm z * norm (c (Suc n))"
lp15@56215
   202
        by (metis False pos_divide_le_eq zero_less_norm_iff)
lp15@56215
   203
      then have "\<bar>B\<bar> * 2 + 2 \<le> norm z ^ (Suc n) * norm (c (Suc n))" 
lp15@56215
   204
        by (metis `1 \<le> norm z` order.trans mult_right_mono norm_ge_zero self_le_power zero_less_Suc)
lp15@56215
   205
      then show "B \<le> norm ((\<Sum>i\<le>n. c i * z^i) + c (Suc n) * (z * z ^ n))" using M les
lp15@56215
   206
        apply auto
lp15@56215
   207
        apply (rule norm_lemma_xy [where a = "norm (c (Suc n)) * norm z ^ (Suc n) / 2"])
lp15@56215
   208
        apply (simp_all add: norm_mult norm_power)
lp15@56215
   209
        done
lp15@56215
   210
    qed
lp15@56215
   211
  qed
lp15@56215
   212
qed
lp15@56215
   213
lp15@56215
   214
lemma polyfun_rootbound:
lp15@56215
   215
 fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   216
 assumes "\<exists>k. k \<le> n \<and> c k \<noteq> 0"
lp15@56215
   217
   shows "finite {z. (\<Sum>i\<le>n. c i * z^i) = 0} \<and> card {z. (\<Sum>i\<le>n. c i * z^i) = 0} \<le> n"
lp15@56215
   218
using assms
lp15@56215
   219
proof (induction n arbitrary: c)
lp15@56215
   220
 case (Suc n) show ?case
lp15@56215
   221
 proof (cases "{z. (\<Sum>i\<le>Suc n. c i * z^i) = 0} = {}")
lp15@56215
   222
   case False
lp15@56215
   223
   then obtain a where a: "(\<Sum>i\<le>Suc n. c i * a^i) = 0"
lp15@56215
   224
     by auto
lp15@56215
   225
   from polyfun_linear_factor_root [OF this]
lp15@56215
   226
   obtain b where "\<And>z. (\<Sum>i\<le>Suc n. c i * z^i) = (z - a) * (\<Sum>i< Suc n. b i * z^i)"
lp15@56215
   227
     by auto
lp15@56215
   228
   then have b: "\<And>z. (\<Sum>i\<le>Suc n. c i * z^i) = (z - a) * (\<Sum>i\<le>n. b i * z^i)"
lp15@56215
   229
     by (metis lessThan_Suc_atMost)
lp15@56215
   230
   then have ins_ab: "{z. (\<Sum>i\<le>Suc n. c i * z^i) = 0} = insert a {z. (\<Sum>i\<le>n. b i * z^i) = 0}"
lp15@56215
   231
     by auto
lp15@56215
   232
   have c0: "c 0 = - (a * b 0)" using  b [of 0]
lp15@56215
   233
     by simp
lp15@56215
   234
   then have extr_prem: "~ (\<exists>k\<le>n. b k \<noteq> 0) \<Longrightarrow> \<exists>k. k \<noteq> 0 \<and> k \<le> Suc n \<and> c k \<noteq> 0"
lp15@56215
   235
     by (metis Suc.prems le0 minus_zero mult_zero_right)
lp15@56215
   236
   have "\<exists>k\<le>n. b k \<noteq> 0" 
lp15@56215
   237
     apply (rule ccontr)
lp15@56215
   238
     using polyfun_extremal [OF extr_prem, of 1]
lp15@56215
   239
     apply (auto simp: eventually_at_infinity b simp del: setsum_atMost_Suc)
lp15@56215
   240
     apply (drule_tac x="of_real ba" in spec, simp)
lp15@56215
   241
     done
lp15@56215
   242
   then show ?thesis using Suc.IH [of b] ins_ab
lp15@56215
   243
     by (auto simp: card_insert_if)
lp15@56215
   244
   qed simp
lp15@56215
   245
qed simp
lp15@56215
   246
lp15@56215
   247
corollary
lp15@56215
   248
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   249
  assumes "\<exists>k. k \<le> n \<and> c k \<noteq> 0"
lp15@56215
   250
    shows polyfun_rootbound_finite: "finite {z. (\<Sum>i\<le>n. c i * z^i) = 0}"
lp15@56215
   251
      and polyfun_rootbound_card:   "card {z. (\<Sum>i\<le>n. c i * z^i) = 0} \<le> n"
lp15@56215
   252
using polyfun_rootbound [OF assms] by auto
lp15@56215
   253
lp15@56215
   254
lemma polyfun_finite_roots:
lp15@56215
   255
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   256
    shows  "finite {z. (\<Sum>i\<le>n. c i * z^i) = 0} \<longleftrightarrow> (\<exists>k. k \<le> n \<and> c k \<noteq> 0)"
lp15@56215
   257
proof (cases " \<exists>k\<le>n. c k \<noteq> 0")
lp15@56215
   258
  case True then show ?thesis 
lp15@56215
   259
    by (blast intro: polyfun_rootbound_finite)
lp15@56215
   260
next
lp15@56215
   261
  case False then show ?thesis 
lp15@56215
   262
    by (auto simp: infinite_UNIV_char_0)
lp15@56215
   263
qed
lp15@56215
   264
lp15@56215
   265
lemma polyfun_eq_0:
lp15@56215
   266
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   267
    shows  "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = 0) \<longleftrightarrow> (\<forall>k. k \<le> n \<longrightarrow> c k = 0)"
lp15@56215
   268
proof (cases "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = 0)")
lp15@56215
   269
  case True
lp15@56215
   270
  then have "~ finite {z. (\<Sum>i\<le>n. c i * z^i) = 0}"
lp15@56215
   271
    by (simp add: infinite_UNIV_char_0)
lp15@56215
   272
  with True show ?thesis
lp15@56215
   273
    by (metis (poly_guards_query) polyfun_rootbound_finite)
lp15@56215
   274
next
lp15@56215
   275
  case False
lp15@56215
   276
  then show ?thesis
lp15@56215
   277
    by auto
lp15@56215
   278
qed
lp15@56215
   279
lp15@56215
   280
lemma polyfun_eq_const:
lp15@56215
   281
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   282
    shows  "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = k) \<longleftrightarrow> c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = 0)"
lp15@56215
   283
proof -
lp15@56215
   284
  {fix z
lp15@56215
   285
    have "(\<Sum>i\<le>n. c i * z^i) = (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z^i) + k"
lp15@56215
   286
      by (induct n) auto
lp15@56215
   287
  } then
lp15@56215
   288
  have "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = k) \<longleftrightarrow> (\<forall>z. (\<Sum>i\<le>n. (if i = 0 then c 0 - k else c i) * z^i) = 0)"
lp15@56215
   289
    by auto
lp15@56215
   290
  also have "... \<longleftrightarrow>  c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = 0)"
lp15@56215
   291
    by (auto simp: polyfun_eq_0)
lp15@56215
   292
  finally show ?thesis .
lp15@56215
   293
qed
lp15@56215
   294
lp15@56215
   295
end
lp15@56215
   296