src/HOL/Library/Fundamental_Theorem_Algebra.thy
author haftmann
Fri, 04 Jul 2014 20:18:47 +0200
changeset 57512 cc97b347b301
parent 56889 48a745e1bde7
child 57514 bdc2c6b40bf2
permissions -rw-r--r--
reduced name variants for assoc and commute on plus and mult
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29197
6d4cb27ed19c adapted HOL source structure to distribution layout
haftmann
parents: 28952
diff changeset
     1
(* Author: Amine Chaieb, TU Muenchen *)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     2
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     3
header{*Fundamental Theorem of Algebra*}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     4
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     5
theory Fundamental_Theorem_Algebra
51537
abcd6d5f7508 more standard imports;
wenzelm
parents: 50636
diff changeset
     6
imports Polynomial Complex_Main
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     7
begin
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     8
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
     9
subsection {* More lemmas about module of complex numbers *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    10
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    11
text{* The triangle inequality for cmod *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    12
lemma complex_mod_triangle_sub: "cmod w \<le> cmod (w + z) + norm z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    13
  using complex_mod_triangle_ineq2[of "w + z" "-z"] by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    14
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    15
subsection {* Basic lemmas about polynomials *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    16
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    17
lemma poly_bound_exists:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    18
  fixes p :: "'a::{comm_semiring_0,real_normed_div_algebra} poly"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    19
  shows "\<exists>m. m > 0 \<and> (\<forall>z. norm z \<le> r \<longrightarrow> norm (poly p z) \<le> m)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    20
proof (induct p)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    21
  case 0
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    22
  then show ?case by (rule exI[where x=1]) simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    23
next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    24
  case (pCons c cs)
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
    25
  from pCons.hyps obtain m where m: "\<forall>z. norm z \<le> r \<longrightarrow> norm (poly cs z) \<le> m"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    26
    by blast
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
    27
  let ?k = " 1 + norm c + \<bar>r * m\<bar>"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
    28
  have kp: "?k > 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
    29
    using abs_ge_zero[of "r*m"] norm_ge_zero[of c] by arith
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    30
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    31
    fix z :: 'a
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
    32
    assume H: "norm z \<le> r"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    33
    from m H have th: "norm (poly cs z) \<le> m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    34
      by blast
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
    35
    from H have rp: "r \<ge> 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
    36
      using norm_ge_zero[of z] by arith
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
    37
    have "norm (poly (pCons c cs) z) \<le> norm c + norm (z * poly cs z)"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    38
      using norm_triangle_ineq[of c "z* poly cs z"] by simp
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    39
    also have "\<dots> \<le> norm c + r * m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    40
      using mult_mono[OF H th rp norm_ge_zero[of "poly cs z"]]
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
    41
      by (simp add: norm_mult)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    42
    also have "\<dots> \<le> ?k"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    43
      by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    44
    finally have "norm (poly (pCons c cs) z) \<le> ?k" .
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    45
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    46
  with kp show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    47
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    48
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    49
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    50
text{* Offsetting the variable in a polynomial gives another of same degree *}
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    51
52380
3cc46b8cca5e lifting for primitive definitions;
haftmann
parents: 51541
diff changeset
    52
definition offset_poly :: "'a::comm_semiring_0 poly \<Rightarrow> 'a \<Rightarrow> 'a poly"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    53
  where "offset_poly p h = fold_coeffs (\<lambda>a q. smult h q + pCons a q) p 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    54
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    55
lemma offset_poly_0: "offset_poly 0 h = 0"
52380
3cc46b8cca5e lifting for primitive definitions;
haftmann
parents: 51541
diff changeset
    56
  by (simp add: offset_poly_def)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    57
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    58
lemma offset_poly_pCons:
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    59
  "offset_poly (pCons a p) h =
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    60
    smult h (offset_poly p h) + pCons a (offset_poly p h)"
52380
3cc46b8cca5e lifting for primitive definitions;
haftmann
parents: 51541
diff changeset
    61
  by (cases "p = 0 \<and> a = 0") (auto simp add: offset_poly_def)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    62
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    63
lemma offset_poly_single: "offset_poly [:a:] h = [:a:]"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    64
  by (simp add: offset_poly_pCons offset_poly_0)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    65
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    66
lemma poly_offset_poly: "poly (offset_poly p h) x = poly p (h + x)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    67
  apply (induct p)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    68
  apply (simp add: offset_poly_0)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    69
  apply (simp add: offset_poly_pCons algebra_simps)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    70
  done
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    71
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    72
lemma offset_poly_eq_0_lemma: "smult c p + pCons a p = 0 \<Longrightarrow> p = 0"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    73
  by (induct p arbitrary: a) (simp, force)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    74
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    75
lemma offset_poly_eq_0_iff: "offset_poly p h = 0 \<longleftrightarrow> p = 0"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    76
  apply (safe intro!: offset_poly_0)
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
    77
  apply (induct p)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
    78
  apply simp
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    79
  apply (simp add: offset_poly_pCons)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    80
  apply (frule offset_poly_eq_0_lemma, simp)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    81
  done
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    82
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    83
lemma degree_offset_poly: "degree (offset_poly p h) = degree p"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    84
  apply (induct p)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    85
  apply (simp add: offset_poly_0)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    86
  apply (case_tac "p = 0")
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    87
  apply (simp add: offset_poly_0 offset_poly_pCons)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    88
  apply (simp add: offset_poly_pCons)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    89
  apply (subst degree_add_eq_right)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    90
  apply (rule le_less_trans [OF degree_smult_le])
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    91
  apply (simp add: offset_poly_eq_0_iff)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    92
  apply (simp add: offset_poly_eq_0_iff)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    93
  done
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    94
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
    95
definition "psize p = (if p = 0 then 0 else Suc (degree p))"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    96
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
    97
lemma psize_eq_0_iff [simp]: "psize p = 0 \<longleftrightarrow> p = 0"
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
    98
  unfolding psize_def by simp
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    99
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   100
lemma poly_offset:
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   101
  fixes p :: "'a::comm_ring_1 poly"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   102
  shows "\<exists>q. psize q = psize p \<and> (\<forall>x. poly q x = poly p (a + x))"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   103
proof (intro exI conjI)
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   104
  show "psize (offset_poly p a) = psize p"
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   105
    unfolding psize_def
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   106
    by (simp add: offset_poly_eq_0_iff degree_offset_poly)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   107
  show "\<forall>x. poly (offset_poly p a) x = poly p (a + x)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   108
    by (simp add: poly_offset_poly)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   109
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   110
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   111
text{* An alternative useful formulation of completeness of the reals *}
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   112
lemma real_sup_exists:
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   113
  assumes ex: "\<exists>x. P x"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   114
    and bz: "\<exists>z. \<forall>x. P x \<longrightarrow> x < z"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   115
  shows "\<exists>s::real. \<forall>y. (\<exists>x. P x \<and> y < x) \<longleftrightarrow> y < s"
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
   116
proof
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
   117
  from bz have "bdd_above (Collect P)"
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
   118
    by (force intro: less_imp_le)
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
   119
  then show "\<forall>y. (\<exists>x. P x \<and> y < x) \<longleftrightarrow> y < Sup (Collect P)"
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
   120
    using ex bz by (subst less_cSup_iff) auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   121
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   122
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
   123
subsection {* Fundamental theorem of algebra *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   124
lemma  unimodular_reduce_norm:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   125
  assumes md: "cmod z = 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   126
  shows "cmod (z + 1) < 1 \<or> cmod (z - 1) < 1 \<or> cmod (z + ii) < 1 \<or> cmod (z - ii) < 1"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   127
proof -
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   128
  obtain x y where z: "z = Complex x y "
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   129
    by (cases z) auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   130
  from md z have xy: "x\<^sup>2 + y\<^sup>2 = 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   131
    by (simp add: cmod_def)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   132
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   133
    assume C: "cmod (z + 1) \<ge> 1" "cmod (z - 1) \<ge> 1" "cmod (z + ii) \<ge> 1" "cmod (z - ii) \<ge> 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   134
    from C z xy have "2 * x \<le> 1" "2 * x \<ge> -1" "2 * y \<le> 1" "2 * y \<ge> -1"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   135
      by (simp_all add: cmod_def power2_eq_square algebra_simps)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   136
    then have "abs (2 * x) \<le> 1" "abs (2 * y) \<le> 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   137
      by simp_all
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   138
    then have "(abs (2 * x))\<^sup>2 \<le> 1\<^sup>2" "(abs (2 * y))\<^sup>2 \<le> 1\<^sup>2"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   139
      by - (rule power_mono, simp, simp)+
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   140
    then have th0: "4 * x\<^sup>2 \<le> 1" "4 * y\<^sup>2 \<le> 1"
51541
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
   141
      by (simp_all add: power_mult_distrib)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   142
    from add_mono[OF th0] xy have False by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   143
  }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   144
  then show ?thesis
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   145
    unfolding linorder_not_le[symmetric] by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   146
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   147
26135
01f4e5d21eaf fixed document;
wenzelm
parents: 26123
diff changeset
   148
text{* Hence we can always reduce modulus of @{text "1 + b z^n"} if nonzero *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   149
lemma reduce_poly_simple:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   150
  assumes b: "b \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   151
    and n: "n \<noteq> 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   152
  shows "\<exists>z. cmod (1 + b * z^n) < 1"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   153
  using n
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   154
proof (induct n rule: nat_less_induct)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   155
  fix n
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   156
  assume IH: "\<forall>m<n. m \<noteq> 0 \<longrightarrow> (\<exists>z. cmod (1 + b * z ^ m) < 1)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   157
  assume n: "n \<noteq> 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   158
  let ?P = "\<lambda>z n. cmod (1 + b * z ^ n) < 1"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   159
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   160
    assume e: "even n"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   161
    then have "\<exists>m. n = 2 * m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   162
      by presburger
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   163
    then obtain m where m: "n = 2 * m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   164
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   165
    from n m have "m \<noteq> 0" "m < n"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   166
      by presburger+
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   167
    with IH[rule_format, of m] obtain z where z: "?P z m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   168
      by blast
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   169
    from z have "?P (csqrt z) n"
56889
48a745e1bde7 avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents: 56795
diff changeset
   170
      by (simp add: m power_mult power2_csqrt)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   171
    then have "\<exists>z. ?P z n" ..
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   172
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   173
  moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   174
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   175
    assume o: "odd n"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   176
    have th0: "cmod (complex_of_real (cmod b) / b) = 1"
36975
fa6244be5215 simplify proof
huffman
parents: 36778
diff changeset
   177
      using b by (simp add: norm_divide)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   178
    from o have "\<exists>m. n = Suc (2 * m)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   179
      by presburger+
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   180
    then obtain m where m: "n = Suc (2 * m)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   181
      by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   182
    from unimodular_reduce_norm[OF th0] o
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   183
    have "\<exists>v. cmod (complex_of_real (cmod b) / b + v^n) < 1"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   184
      apply (cases "cmod (complex_of_real (cmod b) / b + 1) < 1")
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   185
      apply (rule_tac x="1" in exI)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   186
      apply simp
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   187
      apply (cases "cmod (complex_of_real (cmod b) / b - 1) < 1")
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   188
      apply (rule_tac x="-1" in exI)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   189
      apply simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   190
      apply (cases "cmod (complex_of_real (cmod b) / b + ii) < 1")
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   191
      apply (cases "even m")
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   192
      apply (rule_tac x="ii" in exI)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   193
      apply (simp add: m power_mult)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   194
      apply (rule_tac x="- ii" in exI)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   195
      apply (simp add: m power_mult)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   196
      apply (cases "even m")
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   197
      apply (rule_tac x="- ii" in exI)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   198
      apply (simp add: m power_mult)
54489
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
   199
      apply (auto simp add: m power_mult)
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
   200
      apply (rule_tac x="ii" in exI)
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
   201
      apply (auto simp add: m power_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   202
      done
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   203
    then obtain v where v: "cmod (complex_of_real (cmod b) / b + v^n) < 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   204
      by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   205
    let ?w = "v / complex_of_real (root n (cmod b))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   206
    from odd_real_root_pow[OF o, of "cmod b"]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   207
    have th1: "?w ^ n = v^n / complex_of_real (cmod b)"
56889
48a745e1bde7 avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
hoelzl
parents: 56795
diff changeset
   208
      by (simp add: power_divide of_real_power[symmetric])
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   209
    have th2:"cmod (complex_of_real (cmod b) / b) = 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   210
      using b by (simp add: norm_divide)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   211
    then have th3: "cmod (complex_of_real (cmod b) / b) \<ge> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   212
      by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   213
    have th4: "cmod (complex_of_real (cmod b) / b) *
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   214
        cmod (1 + b * (v ^ n / complex_of_real (cmod b))) <
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   215
        cmod (complex_of_real (cmod b) / b) * 1"
49962
a8cc904a6820 Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents: 46240
diff changeset
   216
      apply (simp only: norm_mult[symmetric] distrib_left)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   217
      using b v
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   218
      apply (simp add: th2)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   219
      done
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   220
    from mult_less_imp_less_left[OF th4 th3]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   221
    have "?P ?w n" unfolding th1 .
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   222
    then have "\<exists>z. ?P z n" ..
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   223
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   224
  ultimately show "\<exists>z. ?P z n" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   225
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   226
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   227
text{* Bolzano-Weierstrass type property for closed disc in complex plane. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   228
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   229
lemma metric_bound_lemma: "cmod (x - y) \<le> \<bar>Re x - Re y\<bar> + \<bar>Im x - Im y\<bar>"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   230
  using real_sqrt_sum_squares_triangle_ineq[of "Re x - Re y" 0 0 "Im x - Im y"]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   231
  unfolding cmod_def by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   232
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   233
lemma bolzano_weierstrass_complex_disc:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   234
  assumes r: "\<forall>n. cmod (s n) \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   235
  shows "\<exists>f z. subseq f \<and> (\<forall>e >0. \<exists>N. \<forall>n \<ge> N. cmod (s (f n) - z) < e)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   236
proof-
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   237
  from seq_monosub[of "Re \<circ> s"]
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   238
  obtain f where f: "subseq f" "monoseq (\<lambda>n. Re (s (f n)))"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   239
    unfolding o_def by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   240
  from seq_monosub[of "Im \<circ> s \<circ> f"]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   241
  obtain g where g: "subseq g" "monoseq (\<lambda>n. Im (s (f (g n))))"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   242
    unfolding o_def by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   243
  let ?h = "f \<circ> g"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   244
  from r[rule_format, of 0] have rp: "r \<ge> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   245
    using norm_ge_zero[of "s 0"] by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   246
  have th: "\<forall>n. r + 1 \<ge> \<bar>Re (s n)\<bar>"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   247
  proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   248
    fix n
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   249
    from abs_Re_le_cmod[of "s n"] r[rule_format, of n]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   250
    show "\<bar>Re (s n)\<bar> \<le> r + 1" by arith
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   251
  qed
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   252
  have conv1: "convergent (\<lambda>n. Re (s (f n)))"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   253
    apply (rule Bseq_monoseq_convergent)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   254
    apply (simp add: Bseq_def)
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   255
    apply (metis gt_ex le_less_linear less_trans order.trans th)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   256
    apply (rule f(2))
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   257
    done
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   258
  have th: "\<forall>n. r + 1 \<ge> \<bar>Im (s n)\<bar>"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   259
  proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   260
    fix n
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   261
    from abs_Im_le_cmod[of "s n"] r[rule_format, of n]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   262
    show "\<bar>Im (s n)\<bar> \<le> r + 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   263
      by arith
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   264
  qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   265
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   266
  have conv2: "convergent (\<lambda>n. Im (s (f (g n))))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   267
    apply (rule Bseq_monoseq_convergent)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   268
    apply (simp add: Bseq_def)
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   269
    apply (metis gt_ex le_less_linear less_trans order.trans th)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   270
    apply (rule g(2))
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   271
    done
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   272
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   273
  from conv1[unfolded convergent_def] obtain x where "LIMSEQ (\<lambda>n. Re (s (f n))) x"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   274
    by blast
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   275
  then have x: "\<forall>r>0. \<exists>n0. \<forall>n\<ge>n0. \<bar>Re (s (f n)) - x\<bar> < r"
31337
a9ed5fcc5e39 LIMSEQ_def -> LIMSEQ_iff
huffman
parents: 31021
diff changeset
   276
    unfolding LIMSEQ_iff real_norm_def .
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   277
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   278
  from conv2[unfolded convergent_def] obtain y where "LIMSEQ (\<lambda>n. Im (s (f (g n)))) y"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   279
    by blast
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   280
  then have y: "\<forall>r>0. \<exists>n0. \<forall>n\<ge>n0. \<bar>Im (s (f (g n))) - y\<bar> < r"
31337
a9ed5fcc5e39 LIMSEQ_def -> LIMSEQ_iff
huffman
parents: 31021
diff changeset
   281
    unfolding LIMSEQ_iff real_norm_def .
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   282
  let ?w = "Complex x y"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   283
  from f(1) g(1) have hs: "subseq ?h"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   284
    unfolding subseq_def by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   285
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   286
    fix e :: real
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   287
    assume ep: "e > 0"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   288
    then have e2: "e/2 > 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   289
      by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   290
    from x[rule_format, OF e2] y[rule_format, OF e2]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   291
    obtain N1 N2 where N1: "\<forall>n\<ge>N1. \<bar>Re (s (f n)) - x\<bar> < e / 2"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   292
      and N2: "\<forall>n\<ge>N2. \<bar>Im (s (f (g n))) - y\<bar> < e / 2"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   293
      by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   294
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   295
      fix n
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   296
      assume nN12: "n \<ge> N1 + N2"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   297
      then have nN1: "g n \<ge> N1" and nN2: "n \<ge> N2"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   298
        using seq_suble[OF g(1), of n] by arith+
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   299
      from add_strict_mono[OF N1[rule_format, OF nN1] N2[rule_format, OF nN2]]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   300
      have "cmod (s (?h n) - ?w) < e"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   301
        using metric_bound_lemma[of "s (f (g n))" ?w] by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   302
    }
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   303
    then have "\<exists>N. \<forall>n\<ge>N. cmod (s (?h n) - ?w) < e"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   304
      by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   305
  }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   306
  with hs show ?thesis by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   307
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   308
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   309
text{* Polynomial is continuous. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   310
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   311
lemma poly_cont:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   312
  fixes p :: "'a::{comm_semiring_0,real_normed_div_algebra} poly"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   313
  assumes ep: "e > 0"
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
   314
  shows "\<exists>d >0. \<forall>w. 0 < norm (w - z) \<and> norm (w - z) < d \<longrightarrow> norm (poly p w - poly p z) < e"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   315
proof -
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   316
  obtain q where q: "degree q = degree p" "\<And>x. poly q x = poly p (z + x)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   317
  proof
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   318
    show "degree (offset_poly p z) = degree p"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   319
      by (rule degree_offset_poly)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   320
    show "\<And>x. poly (offset_poly p z) x = poly p (z + x)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   321
      by (rule poly_offset_poly)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   322
  qed
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   323
  have th: "\<And>w. poly q (w - z) = poly p w"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   324
    using q(2)[of "w - z" for w] by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   325
  show ?thesis unfolding th[symmetric]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   326
  proof (induct q)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   327
    case 0
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   328
    then show ?case
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   329
      using ep by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   330
  next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   331
    case (pCons c cs)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   332
    from poly_bound_exists[of 1 "cs"]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   333
    obtain m where m: "m > 0" "\<And>z. norm z \<le> 1 \<Longrightarrow> norm (poly cs z) \<le> m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   334
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   335
    from ep m(1) have em0: "e/m > 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   336
      by (simp add: field_simps)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   337
    have one0: "1 > (0::real)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   338
      by arith
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   339
    from real_lbound_gt_zero[OF one0 em0]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   340
    obtain d where d: "d > 0" "d < 1" "d < e / m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   341
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   342
    from d(1,3) m(1) have dm: "d * m > 0" "d * m < e"
56544
b60d5d119489 made mult_pos_pos a simp rule
nipkow
parents: 56403
diff changeset
   343
      by (simp_all add: field_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   344
    show ?case
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   345
    proof (rule ex_forward[OF real_lbound_gt_zero[OF one0 em0]], clarsimp simp add: norm_mult)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   346
      fix d w
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   347
      assume H: "d > 0" "d < 1" "d < e/m" "w \<noteq> z" "norm (w - z) < d"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   348
      then have d1: "norm (w-z) \<le> 1" "d \<ge> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   349
        by simp_all
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   350
      from H(3) m(1) have dme: "d*m < e"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   351
        by (simp add: field_simps)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   352
      from H have th: "norm (w - z) \<le> d"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   353
        by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   354
      from mult_mono[OF th m(2)[OF d1(1)] d1(2) norm_ge_zero] dme
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   355
      show "norm (w - z) * norm (poly cs (w - z)) < e"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   356
        by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   357
    qed
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   358
  qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   359
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   360
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   361
text{* Hence a polynomial attains minimum on a closed disc
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   362
  in the complex plane. *}
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   363
lemma poly_minimum_modulus_disc: "\<exists>z. \<forall>w. cmod w \<le> r \<longrightarrow> cmod (poly p z) \<le> cmod (poly p w)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   364
proof -
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   365
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   366
    assume "\<not> r \<ge> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   367
    then have ?thesis
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   368
      by (metis norm_ge_zero order.trans)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   369
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   370
  moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   371
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   372
    assume rp: "r \<ge> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   373
    from rp have "cmod 0 \<le> r \<and> cmod (poly p 0) = - (- cmod (poly p 0))"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   374
      by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   375
    then have mth1: "\<exists>x z. cmod z \<le> r \<and> cmod (poly p z) = - x"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   376
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   377
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   378
      fix x z
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   379
      assume H: "cmod z \<le> r" "cmod (poly p z) = - x" "\<not> x < 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   380
      then have "- x < 0 "
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   381
        by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   382
      with H(2) norm_ge_zero[of "poly p z"] have False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   383
        by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   384
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   385
    then have mth2: "\<exists>z. \<forall>x. (\<exists>z. cmod z \<le> r \<and> cmod (poly p z) = - x) \<longrightarrow> x < z"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   386
      by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   387
    from real_sup_exists[OF mth1 mth2] obtain s where
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   388
      s: "\<forall>y. (\<exists>x. (\<exists>z. cmod z \<le> r \<and> cmod (poly p z) = - x) \<and> y < x) \<longleftrightarrow> y < s" by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   389
    let ?m = "- s"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   390
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   391
      fix y
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   392
      from s[rule_format, of "-y"]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   393
      have "(\<exists>z x. cmod z \<le> r \<and> - (- cmod (poly p z)) < y) \<longleftrightarrow> ?m < y"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   394
        unfolding minus_less_iff[of y ] equation_minus_iff by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   395
    }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   396
    note s1 = this[unfolded minus_minus]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   397
    from s1[of ?m] have s1m: "\<And>z x. cmod z \<le> r \<Longrightarrow> cmod (poly p z) \<ge> ?m"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   398
      by auto
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   399
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   400
      fix n :: nat
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   401
      from s1[rule_format, of "?m + 1/real (Suc n)"]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   402
      have "\<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   403
        by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   404
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   405
    then have th: "\<forall>n. \<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)" ..
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   406
    from choice[OF th] obtain g where
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   407
        g: "\<forall>n. cmod (g n) \<le> r" "\<forall>n. cmod (poly p (g n)) <?m + 1 /real(Suc n)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   408
      by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   409
    from bolzano_weierstrass_complex_disc[OF g(1)]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   410
    obtain f z where fz: "subseq f" "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. cmod (g (f n) - z) < e"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   411
      by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   412
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   413
      fix w
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   414
      assume wr: "cmod w \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   415
      let ?e = "\<bar>cmod (poly p z) - ?m\<bar>"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   416
      {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   417
        assume e: "?e > 0"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   418
        then have e2: "?e/2 > 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   419
          by simp
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   420
        from poly_cont[OF e2, of z p] obtain d where
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   421
            d: "d > 0" "\<forall>w. 0<cmod (w - z)\<and> cmod(w - z) < d \<longrightarrow> cmod(poly p w - poly p z) < ?e/2"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   422
          by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   423
        {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   424
          fix w
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   425
          assume w: "cmod (w - z) < d"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   426
          have "cmod(poly p w - poly p z) < ?e / 2"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   427
            using d(2)[rule_format, of w] w e by (cases "w = z") simp_all
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   428
        }
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   429
        note th1 = this
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   430
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   431
        from fz(2) d(1) obtain N1 where N1: "\<forall>n\<ge>N1. cmod (g (f n) - z) < d"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   432
          by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   433
        from reals_Archimedean2[of "2/?e"] obtain N2 :: nat where N2: "2/?e < real N2"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   434
          by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   435
        have th2: "cmod (poly p (g (f (N1 + N2))) - poly p z) < ?e/2"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   436
          using N1[rule_format, of "N1 + N2"] th1 by simp
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   437
        {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   438
          fix a b e2 m :: real
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   439
          have "a < e2 \<Longrightarrow> \<bar>b - m\<bar> < e2 \<Longrightarrow> 2 * e2 \<le> \<bar>b - m\<bar> + a \<Longrightarrow> False"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   440
            by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   441
        }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   442
        note th0 = this
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   443
        have ath: "\<And>m x e::real. m \<le> x \<Longrightarrow> x < m + e \<Longrightarrow> \<bar>x - m\<bar> < e"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   444
          by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   445
        from s1m[OF g(1)[rule_format]] have th31: "?m \<le> cmod(poly p (g (f (N1 + N2))))" .
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   446
        from seq_suble[OF fz(1), of "N1 + N2"]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   447
        have th00: "real (Suc (N1 + N2)) \<le> real (Suc (f (N1 + N2)))"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   448
          by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   449
        have th000: "0 \<le> (1::real)" "(1::real) \<le> 1" "real (Suc (N1 + N2)) > 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   450
          using N2 by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   451
        from frac_le[OF th000 th00]
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   452
        have th00: "?m + 1 / real (Suc (f (N1 + N2))) \<le> ?m + 1 / real (Suc (N1 + N2))"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   453
          by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   454
        from g(2)[rule_format, of "f (N1 + N2)"]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   455
        have th01:"cmod (poly p (g (f (N1 + N2)))) < - s + 1 / real (Suc (f (N1 + N2)))" .
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   456
        from order_less_le_trans[OF th01 th00]
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   457
        have th32: "cmod (poly p (g (f (N1 + N2)))) < ?m + (1/ real(Suc (N1 + N2)))" .
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   458
        from N2 have "2/?e < real (Suc (N1 + N2))"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   459
          by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   460
        with e2 less_imp_inverse_less[of "2/?e" "real (Suc (N1 + N2))"]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   461
        have "?e/2 > 1/ real (Suc (N1 + N2))"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   462
          by (simp add: inverse_eq_divide)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   463
        with ath[OF th31 th32]
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   464
        have thc1: "\<bar>cmod (poly p (g (f (N1 + N2)))) - ?m\<bar> < ?e/2"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   465
          by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   466
        have ath2: "\<And>a b c m::real. \<bar>a - b\<bar> \<le> c \<Longrightarrow> \<bar>b - m\<bar> \<le> \<bar>a - m\<bar> + c"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   467
          by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   468
        have th22: "\<bar>cmod (poly p (g (f (N1 + N2)))) - cmod (poly p z)\<bar> \<le>
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   469
            cmod (poly p (g (f (N1 + N2))) - poly p z)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   470
          by (simp add: norm_triangle_ineq3)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   471
        from ath2[OF th22, of ?m]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   472
        have thc2: "2 * (?e/2) \<le>
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   473
            \<bar>cmod(poly p (g (f (N1 + N2)))) - ?m\<bar> + cmod (poly p (g (f (N1 + N2))) - poly p z)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   474
          by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   475
        from th0[OF th2 thc1 thc2] have False .
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   476
      }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   477
      then have "?e = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   478
        by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   479
      then have "cmod (poly p z) = ?m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   480
        by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   481
      with s1m[OF wr] have "cmod (poly p z) \<le> cmod (poly p w)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   482
        by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   483
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   484
    then have ?thesis by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   485
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   486
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   487
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   488
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   489
text {* Nonzero polynomial in z goes to infinity as z does. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   490
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   491
lemma poly_infinity:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   492
  fixes p:: "'a::{comm_semiring_0,real_normed_div_algebra} poly"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   493
  assumes ex: "p \<noteq> 0"
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
   494
  shows "\<exists>r. \<forall>z. r \<le> norm z \<longrightarrow> d \<le> norm (poly (pCons a p) z)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   495
  using ex
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   496
proof (induct p arbitrary: a d)
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   497
  case 0
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   498
  then show ?case by simp
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   499
next
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   500
  case (pCons c cs a d)
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   501
  show ?case
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   502
  proof (cases "cs = 0")
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   503
    case False
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   504
    with pCons.hyps obtain r where r: "\<forall>z. r \<le> norm z \<longrightarrow> d + norm a \<le> norm (poly (pCons c cs) z)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   505
      by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   506
    let ?r = "1 + \<bar>r\<bar>"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   507
    {
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   508
      fix z :: 'a
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   509
      assume h: "1 + \<bar>r\<bar> \<le> norm z"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   510
      have r0: "r \<le> norm z"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   511
        using h by arith
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   512
      from r[rule_format, OF r0] have th0: "d + norm a \<le> 1 * norm(poly (pCons c cs) z)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   513
        by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   514
      from h have z1: "norm z \<ge> 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   515
        by arith
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   516
      from order_trans[OF th0 mult_right_mono[OF z1 norm_ge_zero[of "poly (pCons c cs) z"]]]
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
   517
      have th1: "d \<le> norm(z * poly (pCons c cs) z) - norm a"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   518
        unfolding norm_mult by (simp add: algebra_simps)
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
   519
      from norm_diff_ineq[of "z * poly (pCons c cs) z" a]
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   520
      have th2: "norm (z * poly (pCons c cs) z) - norm a \<le> norm (poly (pCons a (pCons c cs)) z)"
51541
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
   521
        by (simp add: algebra_simps)
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   522
      from th1 th2 have "d \<le> norm (poly (pCons a (pCons c cs)) z)"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   523
        by arith
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   524
    }
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   525
    then show ?thesis by blast
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   526
  next
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   527
    case True
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   528
    with pCons.prems have c0: "c \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   529
      by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   530
    {
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   531
      fix z :: 'a
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
   532
      assume h: "(\<bar>d\<bar> + norm a) / norm c \<le> norm z"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   533
      from c0 have "norm c > 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   534
        by simp
56403
ae4f904c98b0 tuned spaces
blanchet
parents: 55735
diff changeset
   535
      from h c0 have th0: "\<bar>d\<bar> + norm a \<le> norm (z * c)"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   536
        by (simp add: field_simps norm_mult)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   537
      have ath: "\<And>mzh mazh ma. mzh \<le> mazh + ma \<Longrightarrow> \<bar>d\<bar> + ma \<le> mzh \<Longrightarrow> d \<le> mazh"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   538
        by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   539
      from norm_diff_ineq[of "z * c" a] have th1: "norm (z * c) \<le> norm (a + z * c) + norm a"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   540
        by (simp add: algebra_simps)
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
   541
      from ath[OF th1 th0] have "d \<le> norm (poly (pCons a (pCons c cs)) z)"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   542
        using True by simp
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   543
    }
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   544
    then show ?thesis by blast
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   545
  qed
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   546
qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   547
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   548
text {* Hence polynomial's modulus attains its minimum somewhere. *}
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   549
lemma poly_minimum_modulus: "\<exists>z.\<forall>w. cmod (poly p z) \<le> cmod (poly p w)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   550
proof (induct p)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   551
  case 0
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   552
  then show ?case by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   553
next
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   554
  case (pCons c cs)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   555
  show ?case
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   556
  proof (cases "cs = 0")
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   557
    case False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   558
    from poly_infinity[OF False, of "cmod (poly (pCons c cs) 0)" c]
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   559
    obtain r where r: "\<And>z. r \<le> cmod z \<Longrightarrow> cmod (poly (pCons c cs) 0) \<le> cmod (poly (pCons c cs) z)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   560
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   561
    have ath: "\<And>z r. r \<le> cmod z \<or> cmod z \<le> \<bar>r\<bar>"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   562
      by arith
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   563
    from poly_minimum_modulus_disc[of "\<bar>r\<bar>" "pCons c cs"]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   564
    obtain v where v: "\<And>w. cmod w \<le> \<bar>r\<bar> \<Longrightarrow> cmod (poly (pCons c cs) v) \<le> cmod (poly (pCons c cs) w)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   565
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   566
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   567
      fix z
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   568
      assume z: "r \<le> cmod z"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   569
      from v[of 0] r[OF z] have "cmod (poly (pCons c cs) v) \<le> cmod (poly (pCons c cs) z)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   570
        by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   571
    }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   572
    note v0 = this
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   573
    from v0 v ath[of r] show ?thesis
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   574
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   575
  next
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   576
    case True
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   577
    with pCons.hyps show ?thesis by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   578
  qed
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   579
qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   580
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   581
text{* Constant function (non-syntactic characterization). *}
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   582
definition "constant f \<longleftrightarrow> (\<forall>x y. f x = f y)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   583
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   584
lemma nonconstant_length: "\<not> constant (poly p) \<Longrightarrow> psize p \<ge> 2"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   585
  by (induct p) (auto simp: constant_def psize_def)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   586
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   587
lemma poly_replicate_append: "poly (monom 1 n * p) (x::'a::comm_ring_1) = x^n * poly p x"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   588
  by (simp add: poly_monom)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   589
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   590
text {* Decomposition of polynomial, skipping zero coefficients
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   591
  after the first.  *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   592
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   593
lemma poly_decompose_lemma:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   594
  assumes nz: "\<not> (\<forall>z. z \<noteq> 0 \<longrightarrow> poly p z = (0::'a::idom))"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   595
  shows "\<exists>k a q. a \<noteq> 0 \<and> Suc (psize q + k) = psize p \<and> (\<forall>z. poly p z = z^k * poly (pCons a q) z)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   596
  unfolding psize_def
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   597
  using nz
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   598
proof (induct p)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   599
  case 0
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   600
  then show ?case by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   601
next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   602
  case (pCons c cs)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   603
  show ?case
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   604
  proof (cases "c = 0")
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   605
    case True
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   606
    from pCons.hyps pCons.prems True show ?thesis
32456
341c83339aeb tuned the simp rules for Int involving insert and intervals.
nipkow
parents: 31337
diff changeset
   607
      apply (auto)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   608
      apply (rule_tac x="k+1" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   609
      apply (rule_tac x="a" in exI, clarsimp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   610
      apply (rule_tac x="q" in exI)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   611
      apply auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   612
      done
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   613
  next
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   614
    case False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   615
    show ?thesis
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   616
      apply (rule exI[where x=0])
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   617
      apply (rule exI[where x=c], auto simp add: False)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   618
      done
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   619
  qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   620
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   621
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   622
lemma poly_decompose:
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   623
  assumes nc: "\<not> constant (poly p)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   624
  shows "\<exists>k a q. a \<noteq> (0::'a::idom) \<and> k \<noteq> 0 \<and>
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   625
               psize q + k + 1 = psize p \<and>
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   626
              (\<forall>z. poly p z = poly p 0 + z^k * poly (pCons a q) z)"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   627
  using nc
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   628
proof (induct p)
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   629
  case 0
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   630
  then show ?case
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   631
    by (simp add: constant_def)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   632
next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   633
  case (pCons c cs)
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   634
  {
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   635
    assume C: "\<forall>z. z \<noteq> 0 \<longrightarrow> poly cs z = 0"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   636
    {
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   637
      fix x y
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   638
      from C have "poly (pCons c cs) x = poly (pCons c cs) y"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   639
        by (cases "x = 0") auto
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   640
    }
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   641
    with pCons.prems have False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   642
      by (auto simp add: constant_def)
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   643
  }
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   644
  then have th: "\<not> (\<forall>z. z \<noteq> 0 \<longrightarrow> poly cs z = 0)" ..
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   645
  from poly_decompose_lemma[OF th]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   646
  show ?case
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   647
    apply clarsimp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   648
    apply (rule_tac x="k+1" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   649
    apply (rule_tac x="a" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   650
    apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   651
    apply (rule_tac x="q" in exI)
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   652
    apply (auto simp add: psize_def split: if_splits)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   653
    done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   654
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   655
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 32960
diff changeset
   656
text{* Fundamental theorem of algebra *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   657
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   658
lemma fundamental_theorem_of_algebra:
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   659
  assumes nc: "\<not> constant (poly p)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   660
  shows "\<exists>z::complex. poly p z = 0"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   661
  using nc
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   662
proof (induct "psize p" arbitrary: p rule: less_induct)
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 32960
diff changeset
   663
  case less
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   664
  let ?p = "poly p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   665
  let ?ths = "\<exists>z. ?p z = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   666
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 32960
diff changeset
   667
  from nonconstant_length[OF less(2)] have n2: "psize p \<ge> 2" .
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   668
  from poly_minimum_modulus obtain c where c: "\<forall>w. cmod (?p c) \<le> cmod (?p w)"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   669
    by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   670
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   671
  show ?ths
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   672
  proof (cases "?p c = 0")
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   673
    case True
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   674
    then show ?thesis by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   675
  next
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   676
    case False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   677
    note pc0 = this
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   678
    from poly_offset[of p c] obtain q where q: "psize q = psize p" "\<forall>x. poly q x = ?p (c + x)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   679
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   680
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   681
      assume h: "constant (poly q)"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   682
      from q(2) have th: "\<forall>x. poly q (x - c) = ?p x"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   683
        by auto
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   684
      {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   685
        fix x y
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   686
        from th have "?p x = poly q (x - c)"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   687
          by auto
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   688
        also have "\<dots> = poly q (y - c)"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   689
          using h unfolding constant_def by blast
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   690
        also have "\<dots> = ?p y"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   691
          using th by auto
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   692
        finally have "?p x = ?p y" .
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   693
      }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   694
      with less(2) have False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   695
        unfolding constant_def by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   696
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   697
    then have qnc: "\<not> constant (poly q)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   698
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   699
    from q(2) have pqc0: "?p c = poly q 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   700
      by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   701
    from c pqc0 have cq0: "\<forall>w. cmod (poly q 0) \<le> cmod (?p w)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   702
      by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   703
    let ?a0 = "poly q 0"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   704
    from pc0 pqc0 have a00: "?a0 \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   705
      by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   706
    from a00 have qr: "\<forall>z. poly q z = poly (smult (inverse ?a0) q) z * ?a0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   707
      by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   708
    let ?r = "smult (inverse ?a0) q"
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   709
    have lgqr: "psize q = psize ?r"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   710
      using a00
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   711
      unfolding psize_def degree_def
52380
3cc46b8cca5e lifting for primitive definitions;
haftmann
parents: 51541
diff changeset
   712
      by (simp add: poly_eq_iff)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   713
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   714
      assume h: "\<And>x y. poly ?r x = poly ?r y"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   715
      {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   716
        fix x y
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   717
        from qr[rule_format, of x] have "poly q x = poly ?r x * ?a0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   718
          by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   719
        also have "\<dots> = poly ?r y * ?a0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   720
          using h by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   721
        also have "\<dots> = poly q y"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   722
          using qr[rule_format, of y] by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   723
        finally have "poly q x = poly q y" .
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   724
      }
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   725
      with qnc have False
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   726
        unfolding constant_def by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   727
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   728
    then have rnc: "\<not> constant (poly ?r)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   729
      unfolding constant_def by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   730
    from qr[rule_format, of 0] a00 have r01: "poly ?r 0 = 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   731
      by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   732
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   733
      fix w
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   734
      have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w / ?a0) < 1"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   735
        using qr[rule_format, of w] a00 by (simp add: divide_inverse mult_ac)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   736
      also have "\<dots> \<longleftrightarrow> cmod (poly q w) < cmod ?a0"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   737
        using a00 unfolding norm_divide by (simp add: field_simps)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   738
      finally have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w) < cmod ?a0" .
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   739
    }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   740
    note mrmq_eq = this
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   741
    from poly_decompose[OF rnc] obtain k a s where
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   742
      kas: "a \<noteq> 0" "k \<noteq> 0" "psize s + k + 1 = psize ?r"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   743
        "\<forall>z. poly ?r z = poly ?r 0 + z^k* poly (pCons a s) z" by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   744
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   745
      assume "psize p = k + 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   746
      with kas(3) lgqr[symmetric] q(1) have s0: "s = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   747
        by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   748
      {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   749
        fix w
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   750
        have "cmod (poly ?r w) = cmod (1 + a * w ^ k)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   751
          using kas(4)[rule_format, of w] s0 r01 by (simp add: algebra_simps)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   752
      }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   753
      note hth = this [symmetric]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   754
      from reduce_poly_simple[OF kas(1,2)] have "\<exists>w. cmod (poly ?r w) < 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   755
        unfolding hth by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   756
    }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   757
    moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   758
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   759
      assume kn: "psize p \<noteq> k + 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   760
      from kn kas(3) q(1) lgqr have k1n: "k + 1 < psize p"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   761
        by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   762
      have th01: "\<not> constant (poly (pCons 1 (monom a (k - 1))))"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   763
        unfolding constant_def poly_pCons poly_monom
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   764
        using kas(1)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   765
        apply simp
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   766
        apply (rule exI[where x=0])
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   767
        apply (rule exI[where x=1])
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   768
        apply simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   769
        done
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   770
      from kas(1) kas(2) have th02: "k + 1 = psize (pCons 1 (monom a (k - 1)))"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   771
        by (simp add: psize_def degree_monom_eq)
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 32960
diff changeset
   772
      from less(1) [OF k1n [simplified th02] th01]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   773
      obtain w where w: "1 + w^k * a = 0"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   774
        unfolding poly_pCons poly_monom
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   775
        using kas(2) by (cases k) (auto simp add: algebra_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   776
      from poly_bound_exists[of "cmod w" s] obtain m where
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   777
        m: "m > 0" "\<forall>z. cmod z \<le> cmod w \<longrightarrow> cmod (poly s z) \<le> m" by blast
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   778
      have w0: "w \<noteq> 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   779
        using kas(2) w by (auto simp add: power_0_left)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   780
      from w have "(1 + w ^ k * a) - 1 = 0 - 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   781
        by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   782
      then have wm1: "w^k * a = - 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   783
        by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   784
      have inv0: "0 < inverse (cmod w ^ (k + 1) * m)"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   785
        using norm_ge_zero[of w] w0 m(1)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   786
        by (simp add: inverse_eq_divide zero_less_mult_iff)
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   787
      with real_lbound_gt_zero[OF zero_less_one] obtain t where
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   788
        t: "t > 0" "t < 1" "t < inverse (cmod w ^ (k + 1) * m)" by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   789
      let ?ct = "complex_of_real t"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   790
      let ?w = "?ct * w"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   791
      have "1 + ?w^k * (a + ?w * poly s ?w) = 1 + ?ct^k * (w^k * a) + ?w^k * ?w * poly s ?w"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   792
        using kas(1) by (simp add: algebra_simps power_mult_distrib)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   793
      also have "\<dots> = complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   794
        unfolding wm1 by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   795
      finally have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) =
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   796
        cmod (complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w)"
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   797
        by metis
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   798
      with norm_triangle_ineq[of "complex_of_real (1 - t^k)" "?w^k * ?w * poly s ?w"]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   799
      have th11: "cmod (1 + ?w^k * (a + ?w * poly s ?w)) \<le> \<bar>1 - t^k\<bar> + cmod (?w^k * ?w * poly s ?w)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   800
        unfolding norm_of_real by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   801
      have ath: "\<And>x t::real. 0 \<le> x \<Longrightarrow> x < t \<Longrightarrow> t \<le> 1 \<Longrightarrow> \<bar>1 - t\<bar> + x < 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   802
        by arith
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   803
      have "t * cmod w \<le> 1 * cmod w"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   804
        apply (rule mult_mono)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   805
        using t(1,2)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   806
        apply auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   807
        done
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   808
      then have tw: "cmod ?w \<le> cmod w"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   809
        using t(1) by (simp add: norm_mult)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   810
      from t inv0 have "t * (cmod w ^ (k + 1) * m) < 1"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   811
        by (simp add: inverse_eq_divide field_simps)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   812
      with zero_less_power[OF t(1), of k] have th30: "t^k * (t* (cmod w ^ (k + 1) * m)) < t^k * 1"
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   813
        by (metis comm_mult_strict_left_mono)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   814
      have "cmod (?w^k * ?w * poly s ?w) = t^k * (t* (cmod w ^ (k + 1) * cmod (poly s ?w)))"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   815
        using w0 t(1)
51541
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
   816
        by (simp add: algebra_simps power_mult_distrib norm_power norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   817
      then have "cmod (?w^k * ?w * poly s ?w) \<le> t^k * (t* (cmod w ^ (k + 1) * m))"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   818
        using t(1,2) m(2)[rule_format, OF tw] w0
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   819
        by auto
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   820
      with th30 have th120: "cmod (?w^k * ?w * poly s ?w) < t^k"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   821
        by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   822
      from power_strict_mono[OF t(2), of k] t(1) kas(2) have th121: "t^k \<le> 1"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   823
        by auto
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   824
      from ath[OF norm_ge_zero[of "?w^k * ?w * poly s ?w"] th120 th121]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   825
      have th12: "\<bar>1 - t^k\<bar> + cmod (?w^k * ?w * poly s ?w) < 1" .
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   826
      from th11 th12 have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) < 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   827
        by arith
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   828
      then have "cmod (poly ?r ?w) < 1"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   829
        unfolding kas(4)[rule_format, of ?w] r01 by simp
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   830
      then have "\<exists>w. cmod (poly ?r w) < 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   831
        by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   832
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   833
    ultimately have cr0_contr: "\<exists>w. cmod (poly ?r w) < 1"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   834
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   835
    from cr0_contr cq0 q(2) show ?thesis
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   836
      unfolding mrmq_eq not_less[symmetric] by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   837
  qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   838
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   839
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   840
text {* Alternative version with a syntactic notion of constant polynomial. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   841
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   842
lemma fundamental_theorem_of_algebra_alt:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   843
  assumes nc: "\<not> (\<exists>a l. a \<noteq> 0 \<and> l = 0 \<and> p = pCons a l)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   844
  shows "\<exists>z. poly p z = (0::complex)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   845
  using nc
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   846
proof (induct p)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   847
  case 0
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   848
  then show ?case by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   849
next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   850
  case (pCons c cs)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   851
  show ?case
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   852
  proof (cases "c = 0")
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   853
    case True
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   854
    then show ?thesis by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   855
  next
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   856
    case False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   857
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   858
      assume nc: "constant (poly (pCons c cs))"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   859
      from nc[unfolded constant_def, rule_format, of 0]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   860
      have "\<forall>w. w \<noteq> 0 \<longrightarrow> poly cs w = 0" by auto
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   861
      then have "cs = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   862
      proof (induct cs)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   863
        case 0
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   864
        then show ?case by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   865
      next
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   866
        case (pCons d ds)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   867
        show ?case
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   868
        proof (cases "d = 0")
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   869
          case True
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   870
          then show ?thesis using pCons.prems pCons.hyps by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   871
        next
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   872
          case False
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   873
          from poly_bound_exists[of 1 ds] obtain m where
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   874
            m: "m > 0" "\<forall>z. \<forall>z. cmod z \<le> 1 \<longrightarrow> cmod (poly ds z) \<le> m" by blast
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   875
          have dm: "cmod d / m > 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   876
            using False m(1) by (simp add: field_simps)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   877
          from real_lbound_gt_zero[OF dm zero_less_one] obtain x where
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   878
            x: "x > 0" "x < cmod d / m" "x < 1" by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   879
          let ?x = "complex_of_real x"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   880
          from x have cx: "?x \<noteq> 0"  "cmod ?x \<le> 1"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   881
            by simp_all
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   882
          from pCons.prems[rule_format, OF cx(1)]
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   883
          have cth: "cmod (?x*poly ds ?x) = cmod d"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   884
            by (simp add: eq_diff_eq[symmetric])
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   885
          from m(2)[rule_format, OF cx(2)] x(1)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   886
          have th0: "cmod (?x*poly ds ?x) \<le> x*m"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   887
            by (simp add: norm_mult)
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   888
          from x(2) m(1) have "x * m < cmod d"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   889
            by (simp add: field_simps)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   890
          with th0 have "cmod (?x*poly ds ?x) \<noteq> cmod d"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   891
            by auto
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   892
          with cth show ?thesis
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   893
            by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   894
        qed
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   895
      qed
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   896
    }
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   897
    then have nc: "\<not> constant (poly (pCons c cs))"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   898
      using pCons.prems False by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   899
    from fundamental_theorem_of_algebra[OF nc] show ?thesis .
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   900
  qed
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   901
qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   902
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   903
37093
8808a1aa12a2 Typo fixed.
webertj
parents: 36975
diff changeset
   904
subsection{* Nullstellensatz, degrees and divisibility of polynomials *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   905
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   906
lemma nullstellensatz_lemma:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   907
  fixes p :: "complex poly"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   908
  assumes "\<forall>x. poly p x = 0 \<longrightarrow> poly q x = 0"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   909
    and "degree p = n"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   910
    and "n \<noteq> 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   911
  shows "p dvd (q ^ n)"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   912
  using assms
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   913
proof (induct n arbitrary: p q rule: nat_less_induct)
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   914
  fix n :: nat
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
   915
  fix p q :: "complex poly"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   916
  assume IH: "\<forall>m<n. \<forall>p q.
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   917
                 (\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longrightarrow>
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   918
                 degree p = m \<longrightarrow> m \<noteq> 0 \<longrightarrow> p dvd (q ^ m)"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   919
    and pq0: "\<forall>x. poly p x = 0 \<longrightarrow> poly q x = 0"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   920
    and dpn: "degree p = n"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   921
    and n0: "n \<noteq> 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   922
  from dpn n0 have pne: "p \<noteq> 0" by auto
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   923
  let ?ths = "p dvd (q ^ n)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   924
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   925
    fix a
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   926
    assume a: "poly p a = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   927
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   928
      assume oa: "order a p \<noteq> 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   929
      let ?op = "order a p"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   930
      from pne have ap: "([:- a, 1:] ^ ?op) dvd p" "\<not> [:- a, 1:] ^ (Suc ?op) dvd p"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   931
        using order by blast+
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   932
      note oop = order_degree[OF pne, unfolded dpn]
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   933
      {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   934
        assume q0: "q = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   935
        then have ?ths using n0
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   936
          by (simp add: power_0_left)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   937
      }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   938
      moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   939
      {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   940
        assume q0: "q \<noteq> 0"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   941
        from pq0[rule_format, OF a, unfolded poly_eq_0_iff_dvd]
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   942
        obtain r where r: "q = [:- a, 1:] * r" by (rule dvdE)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   943
        from ap(1) obtain s where s: "p = [:- a, 1:] ^ ?op * s"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   944
          by (rule dvdE)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   945
        have sne: "s \<noteq> 0" using s pne by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   946
        {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   947
          assume ds0: "degree s = 0"
51541
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
   948
          from ds0 obtain k where kpn: "s = [:k:]"
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
   949
            by (cases s) (auto split: if_splits)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   950
          from sne kpn have k: "k \<noteq> 0" by simp
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   951
          let ?w = "([:1/k:] * ([:-a,1:] ^ (n - ?op))) * (r ^ n)"
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
   952
          have "q ^ n = p * ?w"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   953
            apply (subst r)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   954
            apply (subst s)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   955
            apply (subst kpn)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   956
            using k oop [of a]
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   957
            apply (subst power_mult_distrib)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   958
            apply simp
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   959
            apply (subst power_add [symmetric])
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   960
            apply simp
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   961
            done
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   962
          then have ?ths
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   963
            unfolding dvd_def by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   964
        }
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   965
        moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   966
        {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   967
          assume ds0: "degree s \<noteq> 0"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   968
          from ds0 sne dpn s oa
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   969
            have dsn: "degree s < n"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   970
              apply auto
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   971
              apply (erule ssubst)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   972
              apply (simp add: degree_mult_eq degree_linear_power)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   973
              done
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   974
            {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   975
              fix x assume h: "poly s x = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   976
              {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   977
                assume xa: "x = a"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   978
                from h[unfolded xa poly_eq_0_iff_dvd] obtain u where u: "s = [:- a, 1:] * u"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   979
                  by (rule dvdE)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   980
                have "p = [:- a, 1:] ^ (Suc ?op) * u"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   981
                  apply (subst s)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   982
                  apply (subst u)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   983
                  apply (simp only: power_Suc mult_ac)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   984
                  done
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   985
                with ap(2)[unfolded dvd_def] have False
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   986
                  by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   987
              }
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   988
              note xa = this
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   989
              from h have "poly p x = 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   990
                by (subst s) simp
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   991
              with pq0 have "poly q x = 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   992
                by blast
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   993
              with r xa have "poly r x = 0"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   994
                by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
   995
            }
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   996
            note impth = this
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
   997
            from IH[rule_format, OF dsn, of s r] impth ds0
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   998
            have "s dvd (r ^ (degree s))"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
   999
              by blast
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  1000
            then obtain u where u: "r ^ (degree s) = s * u" ..
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1001
            then have u': "\<And>x. poly s x * poly u x = poly r x ^ degree s"
29470
1851088a1f87 convert Deriv.thy to use new Polynomial library (incomplete)
huffman
parents: 29464
diff changeset
  1002
              by (simp only: poly_mult[symmetric] poly_power[symmetric])
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  1003
            let ?w = "(u * ([:-a,1:] ^ (n - ?op))) * (r ^ (n - degree s))"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  1004
            from oop[of a] dsn have "q ^ n = p * ?w"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1005
              apply -
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1006
              apply (subst s)
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1007
              apply (subst r)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1008
              apply (simp only: power_mult_distrib)
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56889
diff changeset
  1009
              apply (subst mult.assoc [where b=s])
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56889
diff changeset
  1010
              apply (subst mult.assoc [where a=u])
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 56889
diff changeset
  1011
              apply (subst mult.assoc [where b=u, symmetric])
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1012
              apply (subst u [symmetric])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1013
              apply (simp add: mult_ac power_add [symmetric])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1014
              done
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1015
            then have ?ths
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1016
              unfolding dvd_def by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1017
        }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1018
        ultimately have ?ths by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1019
      }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1020
      ultimately have ?ths by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1021
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1022
    then have ?ths using a order_root pne by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1023
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1024
  moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1025
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1026
    assume exa: "\<not> (\<exists>a. poly p a = 0)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1027
    from fundamental_theorem_of_algebra_alt[of p] exa
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1028
    obtain c where ccs: "c \<noteq> 0" "p = pCons c 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1029
      by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1030
    then have pp: "\<And>x. poly p x = c"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1031
      by simp
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1032
    let ?w = "[:1/c:] * (q ^ n)"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1033
    from ccs have "(q ^ n) = (p * ?w)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1034
      by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1035
    then have ?ths
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1036
      unfolding dvd_def by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1037
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1038
  ultimately show ?ths by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1039
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1040
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1041
lemma nullstellensatz_univariate:
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1042
  "(\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longleftrightarrow>
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1043
    p dvd (q ^ (degree p)) \<or> (p = 0 \<and> q = 0)"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1044
proof -
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1045
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1046
    assume pe: "p = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1047
    then have eq: "(\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longleftrightarrow> q = 0"
52380
3cc46b8cca5e lifting for primitive definitions;
haftmann
parents: 51541
diff changeset
  1048
      by (auto simp add: poly_all_0_iff_0)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1049
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1050
      assume "p dvd (q ^ (degree p))"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1051
      then obtain r where r: "q ^ (degree p) = p * r" ..
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1052
      from r pe have False by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1053
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1054
    with eq pe have ?thesis by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1055
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1056
  moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1057
  {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1058
    assume pe: "p \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1059
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1060
      assume dp: "degree p = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1061
      then obtain k where k: "p = [:k:]" "k \<noteq> 0" using pe
51541
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
  1062
        by (cases p) (simp split: if_splits)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1063
      then have th1: "\<forall>x. poly p x \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1064
        by simp
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1065
      from k dp have "q ^ (degree p) = p * [:1/k:]"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1066
        by (simp add: one_poly_def)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1067
      then have th2: "p dvd (q ^ (degree p))" ..
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1068
      from th1 th2 pe have ?thesis
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1069
        by blast
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1070
    }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1071
    moreover
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1072
    {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1073
      assume dp: "degree p \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1074
      then obtain n where n: "degree p = Suc n "
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1075
        by (cases "degree p") auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1076
      {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1077
        assume "p dvd (q ^ (Suc n))"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  1078
        then obtain u where u: "q ^ (Suc n) = p * u" ..
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1079
        {
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1080
          fix x
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1081
          assume h: "poly p x = 0" "poly q x \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1082
          then have "poly (q ^ (Suc n)) x \<noteq> 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1083
            by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1084
          then have False using u h(1)
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1085
            by (simp only: poly_mult) simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1086
        }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1087
      }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1088
      with n nullstellensatz_lemma[of p q "degree p"] dp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1089
      have ?thesis by auto
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1090
    }
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1091
    ultimately have ?thesis by blast
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1092
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1093
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1094
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1095
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1096
text {* Useful lemma *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1097
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1098
lemma constant_degree:
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1099
  fixes p :: "'a::{idom,ring_char_0} poly"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1100
  shows "constant (poly p) \<longleftrightarrow> degree p = 0" (is "?lhs = ?rhs")
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1101
proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1102
  assume l: ?lhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1103
  from l[unfolded constant_def, rule_format, of _ "0"]
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1104
  have th: "poly p = poly [:poly p 0:]"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1105
    by auto
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1106
  then have "p = [:poly p 0:]"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1107
    by (simp add: poly_eq_poly_eq_iff)
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1108
  then have "degree p = degree [:poly p 0:]"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1109
    by simp
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1110
  then show ?rhs
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1111
    by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1112
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1113
  assume r: ?rhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1114
  then obtain k where "p = [:k:]"
51541
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
  1115
    by (cases p) (simp split: if_splits)
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1116
  then show ?lhs
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1117
    unfolding constant_def by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1118
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1119
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1120
lemma divides_degree:
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1121
  assumes pq: "p dvd (q:: complex poly)"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1122
  shows "degree p \<le> degree q \<or> q = 0"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1123
  by (metis dvd_imp_degree_le pq)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1124
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1125
text {* Arithmetic operations on multivariate polynomials. *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1126
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1127
lemma mpoly_base_conv:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1128
  fixes x :: "'a::comm_ring_1"
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
  1129
  shows "0 = poly 0 x" "c = poly [:c:] x" "x = poly [:0,1:] x"
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
  1130
  by simp_all
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1131
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1132
lemma mpoly_norm_conv:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1133
  fixes x :: "'a::comm_ring_1"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1134
  shows "poly [:0:] x = poly 0 x" "poly [:poly 0 y:] x = poly 0 x"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1135
  by simp_all
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1136
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1137
lemma mpoly_sub_conv:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1138
  fixes x :: "'a::comm_ring_1"
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
  1139
  shows "poly p x - poly q x = poly p x + -1 * poly q x"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53077
diff changeset
  1140
  by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1141
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1142
lemma poly_pad_rule: "poly p x = 0 \<Longrightarrow> poly (pCons 0 p) x = 0"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1143
  by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1144
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
  1145
lemma poly_cancel_eq_conv:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1146
  fixes x :: "'a::field"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1147
  shows "x = 0 \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> y = 0 \<longleftrightarrow> a * y - b * x = 0"
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
  1148
  by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1149
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1150
lemma poly_divides_pad_rule:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1151
  fixes p:: "('a::comm_ring_1) poly"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1152
  assumes pq: "p dvd q"
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1153
  shows "p dvd (pCons 0 q)"
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1154
proof -
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1155
  have "pCons 0 q = q * [:0,1:]" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1156
  then have "q dvd (pCons 0 q)" ..
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1157
  with pq show ?thesis by (rule dvd_trans)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1158
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1159
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1160
lemma poly_divides_conv0:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1161
  fixes p:: "'a::field poly"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1162
  assumes lgpq: "degree q < degree p"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1163
    and lq: "p \<noteq> 0"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1164
  shows "p dvd q \<longleftrightarrow> q = 0" (is "?lhs \<longleftrightarrow> ?rhs")
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1165
proof
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1166
  assume r: ?rhs
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1167
  then have "q = p * 0" by simp
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1168
  then show ?lhs ..
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1169
next
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1170
  assume l: ?lhs
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1171
  show ?rhs
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1172
  proof (cases "q = 0")
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1173
    case True
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1174
    then show ?thesis by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1175
  next
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1176
    assume q0: "q \<noteq> 0"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1177
    from l q0 have "degree p \<le> degree q"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1178
      by (rule dvd_imp_degree_le)
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1179
    with lgpq show ?thesis by simp
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1180
  qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1181
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1182
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1183
lemma poly_divides_conv1:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1184
  fixes p :: "'a::field poly"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1185
  assumes a0: "a \<noteq> 0"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1186
    and pp': "p dvd p'"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1187
    and qrp': "smult a q - p' = r"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1188
  shows "p dvd q \<longleftrightarrow> p dvd r" (is "?lhs \<longleftrightarrow> ?rhs")
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1189
proof
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1190
  from pp' obtain t where t: "p' = p * t" ..
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1191
  {
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1192
    assume l: ?lhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1193
    then obtain u where u: "q = p * u" ..
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1194
    have "r = p * (smult a u - t)"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1195
      using u qrp' [symmetric] t by (simp add: algebra_simps)
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1196
    then show ?rhs ..
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1197
  next
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1198
    assume r: ?rhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1199
    then obtain u where u: "r = p * u" ..
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1200
    from u [symmetric] t qrp' [symmetric] a0
51541
e7b6b61b7be2 tuned proofs;
wenzelm
parents: 51537
diff changeset
  1201
    have "q = p * smult (1/a) (u + t)" by (simp add: algebra_simps)
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1202
    then show ?lhs ..
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1203
  }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1204
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1205
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1206
lemma basic_cqe_conv1:
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1207
  "(\<exists>x. poly p x = 0 \<and> poly 0 x \<noteq> 0) \<longleftrightarrow> False"
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1208
  "(\<exists>x. poly 0 x \<noteq> 0) \<longleftrightarrow> False"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1209
  "(\<exists>x. poly [:c:] x \<noteq> 0) \<longleftrightarrow> c \<noteq> 0"
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1210
  "(\<exists>x. poly 0 x = 0) \<longleftrightarrow> True"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1211
  "(\<exists>x. poly [:c:] x = 0) \<longleftrightarrow> c = 0"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1212
  by simp_all
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1213
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1214
lemma basic_cqe_conv2:
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1215
  assumes l: "p \<noteq> 0"
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1216
  shows "\<exists>x. poly (pCons a (pCons b p)) x = (0::complex)"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1217
proof -
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1218
  {
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1219
    fix h t
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1220
    assume h: "h \<noteq> 0" "t = 0" and "pCons a (pCons b p) = pCons h t"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1221
    with l have False by simp
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1222
  }
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1223
  then have th: "\<not> (\<exists> h t. h \<noteq> 0 \<and> t = 0 \<and> pCons a (pCons b p) = pCons h t)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1224
    by blast
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1225
  from fundamental_theorem_of_algebra_alt[OF th] show ?thesis
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1226
    by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1227
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1228
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1229
lemma  basic_cqe_conv_2b: "(\<exists>x. poly p x \<noteq> (0::complex)) \<longleftrightarrow> p \<noteq> 0"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1230
  by (metis poly_all_0_iff_0)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1231
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1232
lemma basic_cqe_conv3:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1233
  fixes p q :: "complex poly"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1234
  assumes l: "p \<noteq> 0"
56795
e8cce2bd23e5 tuned proofs;
wenzelm
parents: 56778
diff changeset
  1235
  shows "(\<exists>x. poly (pCons a p) x = 0 \<and> poly q x \<noteq> 0) \<longleftrightarrow> \<not> (pCons a p) dvd (q ^ psize p)"
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1236
proof -
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1237
  from l have dp: "degree (pCons a p) = psize p"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1238
    by (simp add: psize_def)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1239
  from nullstellensatz_univariate[of "pCons a p" q] l
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1240
  show ?thesis
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1241
    by (metis dp pCons_eq_0_iff)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1242
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1243
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1244
lemma basic_cqe_conv4:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1245
  fixes p q :: "complex poly"
55358
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1246
  assumes h: "\<And>x. poly (q ^ n) x = poly r x"
85d81bc281d0 Simplified some proofs, deleting a lot of strange unused material at the end of the theory.
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1247
  shows "p dvd (q ^ n) \<longleftrightarrow> p dvd r"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1248
proof -
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1249
  from h have "poly (q ^ n) = poly r"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1250
    by auto
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1251
  then have "(q ^ n) = r"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1252
    by (simp add: poly_eq_poly_eq_iff)
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1253
  then show "p dvd (q ^ n) \<longleftrightarrow> p dvd r"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1254
    by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1255
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1256
55735
81ba62493610 generalised some results using type classes
paulson <lp15@cam.ac.uk>
parents: 55734
diff changeset
  1257
lemma poly_const_conv:
56778
cb0929421ca6 tuned proofs;
wenzelm
parents: 56776
diff changeset
  1258
  fixes x :: "'a::comm_ring_1"
56776
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1259
  shows "poly [:c:] x = y \<longleftrightarrow> c = y"
309e1a61ee7c tuned proofs;
wenzelm
parents: 56544
diff changeset
  1260
  by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1261
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1262
end