src/HOL/Multivariate_Analysis/PolyRoots.thy
author haftmann
Sat Jul 05 11:01:53 2014 +0200 (2014-07-05)
changeset 57514 bdc2c6b40bf2
parent 57512 cc97b347b301
child 58877 262572d90bc6
permissions -rw-r--r--
prefer ac_simps collections over separate name bindings for add and mult
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)
haftmann@57512
    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])
hoelzl@57129
    33
  also have "(\<Sum>i=m..n. x^(i-m)) = (\<Sum>i\<le>n-m. x^i)"
hoelzl@57129
    34
    using `m \<le> n` by (intro setsum.reindex_bij_witness[where j="\<lambda>i. i - m" and i="\<lambda>i. i + m"]) auto
lp15@56215
    35
  finally show ?thesis .
lp15@56215
    36
qed
lp15@56215
    37
lp15@56215
    38
lemma setsum_gp_multiplied:
lp15@56215
    39
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    40
  assumes "m \<le> n"
lp15@56215
    41
  shows "(1 - x) * (\<Sum>i=m..n. x^i) = x^m - x^Suc n"
lp15@56215
    42
proof -
lp15@56215
    43
  have  "(1 - x) * (\<Sum>i=m..n. x^i) = x^m * (1 - x) * (\<Sum>i\<le>n-m. x^i)"
haftmann@57514
    44
    by (metis mult.assoc mult.commute assms setsum_power_shift)
lp15@56215
    45
  also have "... =x^m * (1 - x^Suc(n-m))"
haftmann@57514
    46
    by (metis mult.assoc setsum_gp_basic)
lp15@56215
    47
  also have "... = x^m - x^Suc n"
lp15@56215
    48
    using assms
lp15@56215
    49
    by (simp add: algebra_simps) (metis le_add_diff_inverse power_add)
lp15@56215
    50
  finally show ?thesis .
lp15@56215
    51
qed
lp15@56215
    52
lp15@56215
    53
lemma setsum_gp:
lp15@56215
    54
  fixes x :: "'a::{comm_ring,division_ring_inverse_zero}"
lp15@56215
    55
  shows   "(\<Sum>i=m..n. x^i) =
lp15@56215
    56
               (if n < m then 0
lp15@56215
    57
                else if x = 1 then of_nat((n + 1) - m)
lp15@56215
    58
                else (x^m - x^Suc n) / (1 - x))"
lp15@56215
    59
using setsum_gp_multiplied [of m n x] 
lp15@56215
    60
apply (auto simp: real_of_nat_def)
haftmann@57512
    61
by (metis eq_iff_diff_eq_0 mult.commute nonzero_divide_eq_eq)
lp15@56215
    62
lp15@56215
    63
lemma setsum_gp_offset:
lp15@56215
    64
  fixes x :: "'a::{comm_ring,division_ring_inverse_zero}"
lp15@56215
    65
  shows   "(\<Sum>i=m..m+n. x^i) =
lp15@56215
    66
       (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))"
lp15@56215
    67
  using setsum_gp [of x m "m+n"]
lp15@56215
    68
  by (auto simp: power_add algebra_simps)
lp15@56215
    69
lp15@56215
    70
subsection{*Basics about polynomial functions: extremal behaviour and root counts.*}
lp15@56215
    71
lp15@56215
    72
lemma sub_polyfun:
lp15@56215
    73
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    74
  shows   "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = 
lp15@56215
    75
           (x - y) * (\<Sum>j<n. \<Sum>k= Suc j..n. a k * y^(k - Suc j) * x^j)"
lp15@56215
    76
proof -
lp15@56215
    77
  have "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = 
lp15@56215
    78
        (\<Sum>i\<le>n. a i * (x^i - y^i))"
lp15@56215
    79
    by (simp add: algebra_simps setsum_subtractf [symmetric])
lp15@56215
    80
  also have "... = (\<Sum>i\<le>n. a i * (x - y) * (\<Sum>j<i. y^(i - Suc j) * x^j))"
haftmann@57514
    81
    by (simp add: power_diff_sumr2 ac_simps)
lp15@56215
    82
  also have "... = (x - y) * (\<Sum>i\<le>n. (\<Sum>j<i. a i * y^(i - Suc j) * x^j))"
haftmann@57514
    83
    by (simp add: setsum_right_distrib ac_simps)
lp15@56215
    84
  also have "... = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - Suc j) * x^j))"
lp15@56215
    85
    by (simp add: nested_setsum_swap')
lp15@56215
    86
  finally show ?thesis .
lp15@56215
    87
qed
lp15@56215
    88
lp15@56215
    89
lemma sub_polyfun_alt:
lp15@56215
    90
  fixes x :: "'a::{comm_ring,monoid_mult}"
lp15@56215
    91
  shows   "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = 
lp15@56215
    92
           (x - y) * (\<Sum>j<n. \<Sum>k<n-j. a (j+k+1) * y^k * x^j)"
lp15@56215
    93
proof -
lp15@56215
    94
  { fix j
lp15@56215
    95
    have "(\<Sum>k = Suc j..n. a k * y^(k - Suc j) * x^j) =
lp15@56215
    96
          (\<Sum>k <n - j. a (Suc (j + k)) * y^k * x^j)"
hoelzl@57129
    97
      by (rule setsum.reindex_bij_witness[where i="\<lambda>i. i + Suc j" and j="\<lambda>i. i - Suc j"]) auto }
lp15@56215
    98
  then show ?thesis
lp15@56215
    99
    by (simp add: sub_polyfun)
lp15@56215
   100
qed
lp15@56215
   101
lp15@56215
   102
lemma polyfun_linear_factor:
lp15@56215
   103
  fixes a :: "'a::{comm_ring,monoid_mult}"
lp15@56215
   104
  shows  "\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z^i) = 
lp15@56215
   105
                  (z-a) * (\<Sum>i<n. b i * z^i) + (\<Sum>i\<le>n. c i * a^i)"
lp15@56215
   106
proof -
lp15@56215
   107
  { fix z
lp15@56215
   108
    have "(\<Sum>i\<le>n. c i * z^i) - (\<Sum>i\<le>n. c i * a^i) = 
lp15@56215
   109
          (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a^(k - Suc j)) * z^j)"
lp15@56215
   110
      by (simp add: sub_polyfun setsum_left_distrib)
lp15@56215
   111
    then have "(\<Sum>i\<le>n. c i * z^i) = 
lp15@56215
   112
          (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a^(k - Suc j)) * z^j)
lp15@56215
   113
          + (\<Sum>i\<le>n. c i * a^i)"
lp15@56215
   114
      by (simp add: algebra_simps) }
lp15@56215
   115
  then show ?thesis
lp15@56215
   116
    by (intro exI allI) 
lp15@56215
   117
qed
lp15@56215
   118
lp15@56215
   119
lemma polyfun_linear_factor_root:
lp15@56215
   120
  fixes a :: "'a::{comm_ring,monoid_mult}"
lp15@56215
   121
  assumes "(\<Sum>i\<le>n. c i * a^i) = 0"
lp15@56215
   122
  shows  "\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z^i) = (z-a) * (\<Sum>i<n. b i * z^i)"
lp15@56215
   123
  using polyfun_linear_factor [of c n a] assms
lp15@56215
   124
  by simp
lp15@56215
   125
lp15@56215
   126
lemma adhoc_norm_triangle: "a + norm(y) \<le> b ==> norm(x) \<le> a ==> norm(x + y) \<le> b"
lp15@56215
   127
  by (metis norm_triangle_mono order.trans order_refl)
lp15@56215
   128
lp15@56215
   129
lemma polyfun_extremal_lemma:
lp15@56215
   130
  fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
lp15@56215
   131
  assumes "e > 0"
lp15@56215
   132
    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
   133
proof (induction n)
lp15@56215
   134
  case 0
lp15@56215
   135
  show ?case 
haftmann@57512
   136
    by (rule exI [where x="norm (c 0) / e"]) (auto simp: mult.commute pos_divide_le_eq assms)
lp15@56215
   137
next
lp15@56215
   138
  case (Suc n)
lp15@56215
   139
  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
   140
  show ?case
lp15@56215
   141
  proof (rule exI [where x="max 1 (max M ((e + norm(c(Suc n))) / e))"], clarify)
lp15@56215
   142
    fix z::'a
lp15@56215
   143
    assume "max 1 (max M ((e + norm (c (Suc n))) / e)) \<le> norm z"
lp15@56215
   144
    then have norm1: "0 < norm z" "M \<le> norm z" "(e + norm (c (Suc n))) / e \<le> norm z"
lp15@56215
   145
      by auto
lp15@56215
   146
    then have norm2: "(e + norm (c (Suc n))) \<le> e * norm z"  "(norm z * norm z ^ n) > 0"
haftmann@57512
   147
      apply (metis assms less_divide_eq mult.commute not_le) 
lp15@56215
   148
      using norm1 apply (metis mult_pos_pos zero_less_power)
lp15@56215
   149
      done
lp15@56215
   150
    have "e * (norm z * norm z ^ n) + norm (c (Suc n) * (z * z ^ n)) =
lp15@56215
   151
          (e + norm (c (Suc n))) * (norm z * norm z ^ n)"
lp15@56215
   152
      by (simp add: norm_mult norm_power algebra_simps)
lp15@56215
   153
    also have "... \<le> (e * norm z) * (norm z * norm z ^ n)"
lp15@56215
   154
      using norm2 by (metis real_mult_le_cancel_iff1) 
lp15@56215
   155
    also have "... = e * (norm z * (norm z * norm z ^ n))"
lp15@56215
   156
      by (simp add: algebra_simps)
lp15@56215
   157
    finally have "e * (norm z * norm z ^ n) + norm (c (Suc n) * (z * z ^ n))
lp15@56215
   158
                  \<le> e * (norm z * (norm z * norm z ^ n))" .
lp15@56215
   159
    then show "norm (\<Sum>i\<le>Suc n. c i * z^i) \<le> e * norm z ^ Suc (Suc n)" using M norm1
lp15@56215
   160
      by (drule_tac x=z in spec) (auto simp: intro!: adhoc_norm_triangle)
lp15@56215
   161
    qed
lp15@56215
   162
qed
lp15@56215
   163
lp15@56215
   164
lemma norm_lemma_xy: "\<lbrakk>abs b + 1 \<le> norm(y) - a; norm(x) \<le> a\<rbrakk> \<Longrightarrow> b \<le> norm(x + y)"
haftmann@57512
   165
  by (metis abs_add_one_not_less_self add.commute diff_le_eq dual_order.trans le_less_linear 
lp15@56215
   166
         norm_diff_ineq)
lp15@56215
   167
lp15@56215
   168
lemma polyfun_extremal:
lp15@56215
   169
  fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
lp15@56215
   170
  assumes "\<exists>k. k \<noteq> 0 \<and> k \<le> n \<and> c k \<noteq> 0"
lp15@56215
   171
    shows "eventually (\<lambda>z. norm(\<Sum>i\<le>n. c i * z^i) \<ge> B) at_infinity"
lp15@56215
   172
using assms
lp15@56215
   173
proof (induction n)
lp15@56215
   174
  case 0 then show ?case
lp15@56215
   175
    by simp
lp15@56215
   176
next
lp15@56215
   177
  case (Suc n)
lp15@56215
   178
  show ?case
lp15@56215
   179
  proof (cases "c (Suc n) = 0")
lp15@56215
   180
    case True
lp15@56215
   181
    with Suc show ?thesis
lp15@56215
   182
      by auto (metis diff_is_0_eq diffs0_imp_equal less_Suc_eq_le not_less_eq)
lp15@56215
   183
  next
lp15@56215
   184
    case False
lp15@56215
   185
    with polyfun_extremal_lemma [of "norm(c (Suc n)) / 2" c n]
lp15@56215
   186
    obtain M where M: "\<And>z. M \<le> norm z \<Longrightarrow> 
lp15@56215
   187
               norm (\<Sum>i\<le>n. c i * z^i) \<le> norm (c (Suc n)) / 2 * norm z ^ Suc n"
lp15@56215
   188
      by auto
lp15@56215
   189
    show ?thesis
lp15@56215
   190
    unfolding eventually_at_infinity
lp15@56215
   191
    proof (rule exI [where x="max M (max 1 ((abs B + 1) / (norm (c (Suc n)) / 2)))"], clarsimp)
lp15@56215
   192
      fix z::'a
lp15@56215
   193
      assume les: "M \<le> norm z"  "1 \<le> norm z"  "(\<bar>B\<bar> * 2 + 2) / norm (c (Suc n)) \<le> norm z"
lp15@56215
   194
      then have "\<bar>B\<bar> * 2 + 2 \<le> norm z * norm (c (Suc n))"
lp15@56215
   195
        by (metis False pos_divide_le_eq zero_less_norm_iff)
lp15@56215
   196
      then have "\<bar>B\<bar> * 2 + 2 \<le> norm z ^ (Suc n) * norm (c (Suc n))" 
lp15@56215
   197
        by (metis `1 \<le> norm z` order.trans mult_right_mono norm_ge_zero self_le_power zero_less_Suc)
lp15@56215
   198
      then show "B \<le> norm ((\<Sum>i\<le>n. c i * z^i) + c (Suc n) * (z * z ^ n))" using M les
lp15@56215
   199
        apply auto
lp15@56215
   200
        apply (rule norm_lemma_xy [where a = "norm (c (Suc n)) * norm z ^ (Suc n) / 2"])
lp15@56215
   201
        apply (simp_all add: norm_mult norm_power)
lp15@56215
   202
        done
lp15@56215
   203
    qed
lp15@56215
   204
  qed
lp15@56215
   205
qed
lp15@56215
   206
lp15@56215
   207
lemma polyfun_rootbound:
lp15@56215
   208
 fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   209
 assumes "\<exists>k. k \<le> n \<and> c k \<noteq> 0"
lp15@56215
   210
   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
   211
using assms
lp15@56215
   212
proof (induction n arbitrary: c)
lp15@56215
   213
 case (Suc n) show ?case
lp15@56215
   214
 proof (cases "{z. (\<Sum>i\<le>Suc n. c i * z^i) = 0} = {}")
lp15@56215
   215
   case False
lp15@56215
   216
   then obtain a where a: "(\<Sum>i\<le>Suc n. c i * a^i) = 0"
lp15@56215
   217
     by auto
lp15@56215
   218
   from polyfun_linear_factor_root [OF this]
lp15@56215
   219
   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
   220
     by auto
lp15@56215
   221
   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
   222
     by (metis lessThan_Suc_atMost)
lp15@56215
   223
   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
   224
     by auto
lp15@56215
   225
   have c0: "c 0 = - (a * b 0)" using  b [of 0]
lp15@56215
   226
     by simp
lp15@56215
   227
   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
   228
     by (metis Suc.prems le0 minus_zero mult_zero_right)
lp15@56215
   229
   have "\<exists>k\<le>n. b k \<noteq> 0" 
lp15@56215
   230
     apply (rule ccontr)
lp15@56215
   231
     using polyfun_extremal [OF extr_prem, of 1]
lp15@56215
   232
     apply (auto simp: eventually_at_infinity b simp del: setsum_atMost_Suc)
lp15@56215
   233
     apply (drule_tac x="of_real ba" in spec, simp)
lp15@56215
   234
     done
lp15@56215
   235
   then show ?thesis using Suc.IH [of b] ins_ab
lp15@56215
   236
     by (auto simp: card_insert_if)
lp15@56215
   237
   qed simp
lp15@56215
   238
qed simp
lp15@56215
   239
lp15@56215
   240
corollary
lp15@56215
   241
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   242
  assumes "\<exists>k. k \<le> n \<and> c k \<noteq> 0"
lp15@56215
   243
    shows polyfun_rootbound_finite: "finite {z. (\<Sum>i\<le>n. c i * z^i) = 0}"
lp15@56215
   244
      and polyfun_rootbound_card:   "card {z. (\<Sum>i\<le>n. c i * z^i) = 0} \<le> n"
lp15@56215
   245
using polyfun_rootbound [OF assms] by auto
lp15@56215
   246
lp15@56215
   247
lemma polyfun_finite_roots:
lp15@56215
   248
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   249
    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
   250
proof (cases " \<exists>k\<le>n. c k \<noteq> 0")
lp15@56215
   251
  case True then show ?thesis 
lp15@56215
   252
    by (blast intro: polyfun_rootbound_finite)
lp15@56215
   253
next
lp15@56215
   254
  case False then show ?thesis 
lp15@56215
   255
    by (auto simp: infinite_UNIV_char_0)
lp15@56215
   256
qed
lp15@56215
   257
lp15@56215
   258
lemma polyfun_eq_0:
lp15@56215
   259
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   260
    shows  "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = 0) \<longleftrightarrow> (\<forall>k. k \<le> n \<longrightarrow> c k = 0)"
lp15@56215
   261
proof (cases "(\<forall>z. (\<Sum>i\<le>n. c i * z^i) = 0)")
lp15@56215
   262
  case True
lp15@56215
   263
  then have "~ finite {z. (\<Sum>i\<le>n. c i * z^i) = 0}"
lp15@56215
   264
    by (simp add: infinite_UNIV_char_0)
lp15@56215
   265
  with True show ?thesis
lp15@56215
   266
    by (metis (poly_guards_query) polyfun_rootbound_finite)
lp15@56215
   267
next
lp15@56215
   268
  case False
lp15@56215
   269
  then show ?thesis
lp15@56215
   270
    by auto
lp15@56215
   271
qed
lp15@56215
   272
lp15@56215
   273
lemma polyfun_eq_const:
lp15@56215
   274
  fixes c :: "nat \<Rightarrow> 'a::{comm_ring,real_normed_div_algebra}"
lp15@56215
   275
    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
   276
proof -
lp15@56215
   277
  {fix z
lp15@56215
   278
    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
   279
      by (induct n) auto
lp15@56215
   280
  } then
lp15@56215
   281
  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
   282
    by auto
lp15@56215
   283
  also have "... \<longleftrightarrow>  c 0 = k \<and> (\<forall>k. k \<noteq> 0 \<and> k \<le> n \<longrightarrow> c k = 0)"
lp15@56215
   284
    by (auto simp: polyfun_eq_0)
lp15@56215
   285
  finally show ?thesis .
lp15@56215
   286
qed
lp15@56215
   287
lp15@56215
   288
end
lp15@56215
   289