src/HOL/Complex/Fundamental_Theorem_Algebra.thy
author chaieb
Mon, 21 Jul 2008 13:36:59 +0200
changeset 27668 6eb20b2cecf8
parent 27514 6fcf6864d703
child 28313 1742947952f8
permissions -rw-r--r--
Tuned and simplified proofs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     1
(*  Title:       Fundamental_Theorem_Algebra.thy
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     2
    ID:          $Id$
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     3
    Author:      Amine Chaieb
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
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     6
header{*Fundamental Theorem of Algebra*}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     7
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     8
theory Fundamental_Theorem_Algebra
27108
e447b3107696 whitespace tuning
haftmann
parents: 26162
diff changeset
     9
imports Univ_Poly Dense_Linear_Order Complex
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    10
begin
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    11
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
    12
subsection {* Square root of complex numbers *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    13
definition csqrt :: "complex \<Rightarrow> complex" where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    14
"csqrt z = (if Im z = 0 then
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    15
            if 0 \<le> Re z then Complex (sqrt(Re z)) 0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    16
            else Complex 0 (sqrt(- Re z))
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    17
           else Complex (sqrt((cmod z + Re z) /2))
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    18
                        ((Im z / abs(Im z)) * sqrt((cmod z - Re z) /2)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    19
27668
6eb20b2cecf8 Tuned and simplified proofs
chaieb
parents: 27514
diff changeset
    20
lemma csqrt[algebra]: "csqrt z ^ 2 = z"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    21
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    22
  obtain x y where xy: "z = Complex x y" by (cases z, simp_all)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    23
  {assume y0: "y = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    24
    {assume x0: "x \<ge> 0" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    25
      then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    26
	by (simp add: csqrt_def power2_eq_square)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    27
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    28
    {assume "\<not> x \<ge> 0" hence x0: "- x \<ge> 0" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    29
      then have ?thesis using y0 xy real_sqrt_pow2[OF x0] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    30
	by (simp add: csqrt_def power2_eq_square) }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    31
    ultimately have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    32
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    33
  {assume y0: "y\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    34
    {fix x y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    35
      let ?z = "Complex x y"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    36
      from abs_Re_le_cmod[of ?z] have tha: "abs x \<le> cmod ?z" by auto
27668
6eb20b2cecf8 Tuned and simplified proofs
chaieb
parents: 27514
diff changeset
    37
      hence "cmod ?z - x \<ge> 0" "cmod ?z + x \<ge> 0" by arith+ 
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    38
      hence "(sqrt (x * x + y * y) + x) / 2 \<ge> 0" "(sqrt (x * x + y * y) - x) / 2 \<ge> 0" by (simp_all add: power2_eq_square) }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    39
    note th = this
27668
6eb20b2cecf8 Tuned and simplified proofs
chaieb
parents: 27514
diff changeset
    40
    have sq4: "\<And>x::real. x^2 / 4 = (x / 2) ^ 2" 
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    41
      by (simp add: power2_eq_square) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    42
    from th[of x y]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    43
    have sq4': "sqrt (((sqrt (x * x + y * y) + x)^2 / 4)) = (sqrt (x * x + y * y) + x) / 2" "sqrt (((sqrt (x * x + y * y) - x)^2 / 4)) = (sqrt (x * x + y * y) - x) / 2" unfolding sq4 by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    44
    then have th1: "sqrt ((sqrt (x * x + y * y) + x) * (sqrt (x * x + y * y) + x) / 4) - sqrt ((sqrt (x * x + y * y) - x) * (sqrt (x * x + y * y) - x) / 4) = x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    45
      unfolding power2_eq_square by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    46
    have "sqrt 4 = sqrt (2^2)" by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    47
    hence sqrt4: "sqrt 4 = 2" by (simp only: real_sqrt_abs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    48
    have th2: "2 *(y * sqrt ((sqrt (x * x + y * y) - x) * (sqrt (x * x + y * y) + x) / 4)) / \<bar>y\<bar> = y"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    49
      using iffD2[OF real_sqrt_pow2_iff sum_power2_ge_zero[of x y]] y0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    50
      unfolding power2_eq_square 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    51
      by (simp add: ring_simps real_sqrt_divide sqrt4)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    52
     from y0 xy have ?thesis  apply (simp add: csqrt_def power2_eq_square)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    53
       apply (simp add: real_sqrt_sum_squares_mult_ge_zero[of x y] real_sqrt_pow2[OF th(1)[of x y], unfolded power2_eq_square] real_sqrt_pow2[OF th(2)[of x y], unfolded power2_eq_square] real_sqrt_mult[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    54
      using th1 th2  ..}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    55
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    56
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    57
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    58
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
    59
subsection{* More lemmas about module of complex numbers *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    60
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    61
lemma complex_of_real_power: "complex_of_real x ^ n = complex_of_real (x^n)"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    62
  by (rule of_real_power [symmetric])
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    63
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    64
lemma real_down2: "(0::real) < d1 \<Longrightarrow> 0 < d2 ==> EX e. 0 < e & e < d1 & e < d2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    65
  apply ferrack apply arith done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    66
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    67
text{* The triangle inequality for cmod *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    68
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
    69
  using complex_mod_triangle_ineq2[of "w + z" "-z"] by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    70
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
    71
subsection{* Basic lemmas about complex polynomials *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    72
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    73
lemma poly_bound_exists:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    74
  shows "\<exists>m. m > 0 \<and> (\<forall>z. cmod z <= r \<longrightarrow> cmod (poly p z) \<le> m)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    75
proof(induct p)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    76
  case Nil thus ?case by (rule exI[where x=1], simp) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    77
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    78
  case (Cons c cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    79
  from Cons.hyps obtain m where m: "\<forall>z. cmod z \<le> r \<longrightarrow> cmod (poly cs z) \<le> m"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    80
    by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    81
  let ?k = " 1 + cmod c + \<bar>r * m\<bar>"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    82
  have kp: "?k > 0" using abs_ge_zero[of "r*m"] norm_ge_zero[of c] by arith
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    83
  {fix z
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    84
    assume H: "cmod z \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    85
    from m H have th: "cmod (poly cs z) \<le> m" by blast
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    86
    from H have rp: "r \<ge> 0" using norm_ge_zero[of z] by arith
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    87
    have "cmod (poly (c # cs) z) \<le> cmod c + cmod (z* poly cs z)"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    88
      using norm_triangle_ineq[of c "z* poly cs z"] by simp
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    89
    also have "\<dots> \<le> cmod c + r*m" using mult_mono[OF H th rp norm_ge_zero[of "poly cs z"]] by (simp add: norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    90
    also have "\<dots> \<le> ?k" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    91
    finally have "cmod (poly (c # cs) z) \<le> ?k" .}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    92
  with kp show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    93
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    94
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    95
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    96
text{* Offsetting the variable in a polynomial gives another of same degree *}
26135
01f4e5d21eaf fixed document;
wenzelm
parents: 26123
diff changeset
    97
  (* FIXME : Lemma holds also in locale --- fix it later *)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    98
lemma  poly_offset_lemma:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    99
  shows "\<exists>b q. (length q = length p) \<and> (\<forall>x. poly (b#q) (x::complex) = (a + x) * poly p x)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   100
proof(induct p)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   101
  case Nil thus ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   102
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   103
  case (Cons c cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   104
  from Cons.hyps obtain b q where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   105
    bq: "length q = length cs" "\<forall>x. poly (b # q) x = (a + x) * poly cs x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   106
    by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   107
  let ?b = "a*c"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   108
  let ?q = "(b+c)#q"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   109
  have lg: "length ?q = length (c#cs)" using bq(1) by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   110
  {fix x
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   111
    from bq(2)[rule_format, of x]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   112
    have "x*poly (b # q) x = x*((a + x) * poly cs x)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   113
    hence "poly (?b# ?q) x = (a + x) * poly (c # cs) x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   114
      by (simp add: ring_simps)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   115
  with lg  show ?case by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   116
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   117
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   118
    (* FIXME : This one too*)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   119
lemma poly_offset: "\<exists> q. length q = length p \<and> (\<forall>x. poly q (x::complex) = poly p (a + x))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   120
proof (induct p)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   121
  case Nil thus ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   122
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   123
  case (Cons c cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   124
  from Cons.hyps obtain q where q: "length q = length cs" "\<forall>x. poly q x = poly cs (a + x)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   125
  from poly_offset_lemma[of q a] obtain b p where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   126
    bp: "length p = length q" "\<forall>x. poly (b # p) x = (a + x) * poly q x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   127
    by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   128
  thus ?case using q bp by - (rule exI[where x="(c + b)#p"], simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   129
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   130
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   131
text{* An alternative useful formulation of completeness of the reals *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   132
lemma real_sup_exists: assumes ex: "\<exists>x. P x" and bz: "\<exists>z. \<forall>x. P x \<longrightarrow> x < z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   133
  shows "\<exists>(s::real). \<forall>y. (\<exists>x. P x \<and> y < x) \<longleftrightarrow> y < s"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   134
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   135
  from ex bz obtain x Y where x: "P x" and Y: "\<And>x. P x \<Longrightarrow> x < Y"  by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   136
  from ex have thx:"\<exists>x. x \<in> Collect P" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   137
  from bz have thY: "\<exists>Y. isUb UNIV (Collect P) Y" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   138
    by(auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def order_le_less)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   139
  from reals_complete[OF thx thY] obtain L where L: "isLub UNIV (Collect P) L"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   140
    by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   141
  from Y[OF x] have xY: "x < Y" .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   142
  from L have L': "\<forall>x. P x \<longrightarrow> x \<le> L" by (auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def)  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   143
  from Y have Y': "\<forall>x. P x \<longrightarrow> x \<le> Y" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   144
    apply (clarsimp, atomize (full)) by auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   145
  from L Y' have "L \<le> Y" by (auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   146
  {fix y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   147
    {fix z assume z: "P z" "y < z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   148
      from L' z have "y < L" by auto }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   149
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   150
    {assume yL: "y < L" "\<forall>z. P z \<longrightarrow> \<not> y < z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   151
      hence nox: "\<forall>z. P z \<longrightarrow> y \<ge> z" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   152
      from nox L have "y \<ge> L" by (auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   153
      with yL(1) have False  by arith}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   154
    ultimately have "(\<exists>x. P x \<and> y < x) \<longleftrightarrow> y < L" by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   155
  thus ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   156
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   157
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   158
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
   159
subsection{* Some theorems about Sequences*}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   160
text{* Given a binary function @{text "f:: nat \<Rightarrow> 'a \<Rightarrow> 'a"}, its values are uniquely determined by a function g *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   161
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   162
lemma num_Axiom: "EX! g. g 0 = e \<and> (\<forall>n. g (Suc n) = f n (g n))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   163
  unfolding Ex1_def
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   164
  apply (rule_tac x="nat_rec e f" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   165
  apply (rule conjI)+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   166
apply (rule def_nat_rec_0, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   167
apply (rule allI, rule def_nat_rec_Suc, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   168
apply (rule allI, rule impI, rule ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   169
apply (erule conjE)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   170
apply (induct_tac x)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   171
apply (simp add: nat_rec_0)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   172
apply (erule_tac x="n" in allE)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   173
apply (simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   174
done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   175
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   176
 text{* An equivalent formulation of monotony -- Not used here, but might be useful *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   177
lemma mono_Suc: "mono f = (\<forall>n. (f n :: 'a :: order) \<le> f (Suc n))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   178
unfolding mono_def
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   179
proof auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   180
  fix A B :: nat
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   181
  assume H: "\<forall>n. f n \<le> f (Suc n)" "A \<le> B"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   182
  hence "\<exists>k. B = A + k" apply -  apply (thin_tac "\<forall>n. f n \<le> f (Suc n)") 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   183
    by presburger
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   184
  then obtain k where k: "B = A + k" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   185
  {fix a k
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   186
    have "f a \<le> f (a + k)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   187
    proof (induct k)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   188
      case 0 thus ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   189
    next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   190
      case (Suc k)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   191
      from Suc.hyps H(1)[rule_format, of "a + k"] show ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   192
    qed}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   193
  with k show "f A \<le> f B" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   194
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   195
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   196
text{* for any sequence, there is a mootonic subsequence *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   197
lemma seq_monosub: "\<exists>f. subseq f \<and> monoseq (\<lambda> n. (s (f n)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   198
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   199
  {assume H: "\<forall>n. \<exists>p >n. \<forall> m\<ge>p. s m \<le> s p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   200
    let ?P = "\<lambda> p n. p > n \<and> (\<forall>m \<ge> p. s m \<le> s p)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   201
    from num_Axiom[of "SOME p. ?P p 0" "\<lambda>p n. SOME p. ?P p n"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   202
    obtain f where f: "f 0 = (SOME p. ?P p 0)" "\<forall>n. f (Suc n) = (SOME p. ?P p (f n))" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   203
    have "?P (f 0) 0"  unfolding f(1) some_eq_ex[of "\<lambda>p. ?P p 0"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   204
      using H apply - 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   205
      apply (erule allE[where x=0], erule exE, rule_tac x="p" in exI) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   206
      unfolding order_le_less by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   207
    hence f0: "f 0 > 0" "\<forall>m \<ge> f 0. s m \<le> s (f 0)" by blast+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   208
    {fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   209
      have "?P (f (Suc n)) (f n)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   210
	unfolding f(2)[rule_format, of n] some_eq_ex[of "\<lambda>p. ?P p (f n)"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   211
	using H apply - 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   212
      apply (erule allE[where x="f n"], erule exE, rule_tac x="p" in exI) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   213
      unfolding order_le_less by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   214
    hence "f (Suc n) > f n" "\<forall>m \<ge> f (Suc n). s m \<le> s (f (Suc n))" by blast+}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   215
  note fSuc = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   216
    {fix p q assume pq: "p \<ge> f q"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   217
      have "s p \<le> s(f(q))"  using f0(2)[rule_format, of p] pq fSuc
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   218
	by (cases q, simp_all) }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   219
    note pqth = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   220
    {fix q
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   221
      have "f (Suc q) > f q" apply (induct q) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   222
	using f0(1) fSuc(1)[of 0] apply simp by (rule fSuc(1))}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   223
    note fss = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   224
    from fss have th1: "subseq f" unfolding subseq_Suc_iff ..
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   225
    {fix a b 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   226
      have "f a \<le> f (a + b)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   227
      proof(induct b)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   228
	case 0 thus ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   229
      next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   230
	case (Suc b)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   231
	from fSuc(1)[of "a + b"] Suc.hyps show ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   232
      qed}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   233
    note fmon0 = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   234
    have "monoseq (\<lambda>n. s (f n))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   235
    proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   236
      {fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   237
	have "s (f n) \<ge> s (f (Suc n))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   238
	proof(cases n)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   239
	  case 0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   240
	  assume n0: "n = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   241
	  from fSuc(1)[of 0] have th0: "f 0 \<le> f (Suc 0)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   242
	  from f0(2)[rule_format, OF th0] show ?thesis  using n0 by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   243
	next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   244
	  case (Suc m)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   245
	  assume m: "n = Suc m"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   246
	  from fSuc(1)[of n] m have th0: "f (Suc m) \<le> f (Suc (Suc m))" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   247
	  from m fSuc(2)[rule_format, OF th0] show ?thesis by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   248
	qed}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   249
      thus "monoseq (\<lambda>n. s (f n))" unfolding monoseq_Suc by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   250
    qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   251
    with th1 have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   252
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   253
  {fix N assume N: "\<forall>p >N. \<exists> m\<ge>p. s m > s p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   254
    {fix p assume p: "p \<ge> Suc N" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   255
      hence pN: "p > N" by arith with N obtain m where m: "m \<ge> p" "s m > s p" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   256
      have "m \<noteq> p" using m(2) by auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   257
      with m have "\<exists>m>p. s p < s m" by - (rule exI[where x=m], auto)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   258
    note th0 = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   259
    let ?P = "\<lambda>m x. m > x \<and> s x < s m"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   260
    from num_Axiom[of "SOME x. ?P x (Suc N)" "\<lambda>m x. SOME y. ?P y x"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   261
    obtain f where f: "f 0 = (SOME x. ?P x (Suc N))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   262
      "\<forall>n. f (Suc n) = (SOME m. ?P m (f n))" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   263
    have "?P (f 0) (Suc N)"  unfolding f(1) some_eq_ex[of "\<lambda>p. ?P p (Suc N)"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   264
      using N apply - 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   265
      apply (erule allE[where x="Suc N"], clarsimp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   266
      apply (rule_tac x="m" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   267
      apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   268
      apply (subgoal_tac "Suc N \<noteq> m")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   269
      apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   270
      apply (rule ccontr, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   271
      done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   272
    hence f0: "f 0 > Suc N" "s (Suc N) < s (f 0)" by blast+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   273
    {fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   274
      have "f n > N \<and> ?P (f (Suc n)) (f n)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   275
	unfolding f(2)[rule_format, of n] some_eq_ex[of "\<lambda>p. ?P p (f n)"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   276
      proof (induct n)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   277
	case 0 thus ?case
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   278
	  using f0 N apply auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   279
	  apply (erule allE[where x="f 0"], clarsimp) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   280
	  apply (rule_tac x="m" in exI, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   281
	  by (subgoal_tac "f 0 \<noteq> m", auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   282
      next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   283
	case (Suc n)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   284
	from Suc.hyps have Nfn: "N < f n" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   285
	from Suc.hyps obtain m where m: "m > f n" "s (f n) < s m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   286
	with Nfn have mN: "m > N" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   287
	note key = Suc.hyps[unfolded some_eq_ex[of "\<lambda>p. ?P p (f n)", symmetric] f(2)[rule_format, of n, symmetric]]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   288
	
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   289
	from key have th0: "f (Suc n) > N" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   290
	from N[rule_format, OF th0]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   291
	obtain m' where m': "m' \<ge> f (Suc n)" "s (f (Suc n)) < s m'" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   292
	have "m' \<noteq> f (Suc (n))" apply (rule ccontr) using m'(2) by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   293
	hence "m' > f (Suc n)" using m'(1) by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   294
	with key m'(2) show ?case by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   295
      qed}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   296
    note fSuc = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   297
    {fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   298
      have "f n \<ge> Suc N \<and> f(Suc n) > f n \<and> s(f n) < s(f(Suc n))" using fSuc[of n] by auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   299
      hence "f n \<ge> Suc N" "f(Suc n) > f n" "s(f n) < s(f(Suc n))" by blast+}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   300
    note thf = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   301
    have sqf: "subseq f" unfolding subseq_Suc_iff using thf by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   302
    have "monoseq (\<lambda>n. s (f n))"  unfolding monoseq_Suc using thf
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   303
      apply -
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   304
      apply (rule disjI1)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   305
      apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   306
      apply (rule order_less_imp_le)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   307
      apply blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   308
      done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   309
    then have ?thesis  using sqf by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   310
  ultimately show ?thesis unfolding linorder_not_less[symmetric] by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   311
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   312
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   313
lemma seq_suble: assumes sf: "subseq f" shows "n \<le> f n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   314
proof(induct n)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   315
  case 0 thus ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   316
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   317
  case (Suc n)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   318
  from sf[unfolded subseq_Suc_iff, rule_format, of n] Suc.hyps
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   319
  have "n < f (Suc n)" by arith 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   320
  thus ?case by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   321
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   322
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
   323
subsection {* Fundamental theorem of algebra *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   324
lemma  unimodular_reduce_norm:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   325
  assumes md: "cmod z = 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   326
  shows "cmod (z + 1) < 1 \<or> cmod (z - 1) < 1 \<or> cmod (z + ii) < 1 \<or> cmod (z - ii) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   327
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   328
  obtain x y where z: "z = Complex x y " by (cases z, auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   329
  from md z have xy: "x^2 + y^2 = 1" by (simp add: cmod_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   330
  {assume C: "cmod (z + 1) \<ge> 1" "cmod (z - 1) \<ge> 1" "cmod (z + ii) \<ge> 1" "cmod (z - ii) \<ge> 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   331
    from C z xy have "2*x \<le> 1" "2*x \<ge> -1" "2*y \<le> 1" "2*y \<ge> -1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   332
      by (simp_all add: cmod_def power2_eq_square ring_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   333
    hence "abs (2*x) \<le> 1" "abs (2*y) \<le> 1" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   334
    hence "(abs (2 * x))^2 <= 1^2" "(abs (2 * y)) ^2 <= 1^2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   335
      by - (rule power_mono, simp, simp)+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   336
    hence th0: "4*x^2 \<le> 1" "4*y^2 \<le> 1" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   337
      by (simp_all  add: power2_abs power_mult_distrib)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   338
    from add_mono[OF th0] xy have False by simp }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   339
  thus ?thesis unfolding linorder_not_le[symmetric] by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   340
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   341
26135
01f4e5d21eaf fixed document;
wenzelm
parents: 26123
diff changeset
   342
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
   343
lemma reduce_poly_simple:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   344
 assumes b: "b \<noteq> 0" and n: "n\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   345
  shows "\<exists>z. cmod (1 + b * z^n) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   346
using n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   347
proof(induct n rule: nat_less_induct)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   348
  fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   349
  assume IH: "\<forall>m<n. m \<noteq> 0 \<longrightarrow> (\<exists>z. cmod (1 + b * z ^ m) < 1)" and n: "n \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   350
  let ?P = "\<lambda>z n. cmod (1 + b * z ^ n) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   351
  {assume e: "even n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   352
    hence "\<exists>m. n = 2*m" by presburger
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   353
    then obtain m where m: "n = 2*m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   354
    from n m have "m\<noteq>0" "m < n" by presburger+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   355
    with IH[rule_format, of m] obtain z where z: "?P z m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   356
    from z have "?P (csqrt z) n" by (simp add: m power_mult csqrt)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   357
    hence "\<exists>z. ?P z n" ..}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   358
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   359
  {assume o: "odd n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   360
    from b have b': "b^2 \<noteq> 0" unfolding power2_eq_square by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   361
    have "Im (inverse b) * (Im (inverse b) * \<bar>Im b * Im b + Re b * Re b\<bar>) +
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   362
    Re (inverse b) * (Re (inverse b) * \<bar>Im b * Im b + Re b * Re b\<bar>) = 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   363
    ((Re (inverse b))^2 + (Im (inverse b))^2) * \<bar>Im b * Im b + Re b * Re b\<bar>" by algebra
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   364
    also have "\<dots> = cmod (inverse b) ^2 * cmod b ^ 2" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   365
      apply (simp add: cmod_def) using realpow_two_le_add_order[of "Re b" "Im b"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   366
      by (simp add: power2_eq_square)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   367
    finally 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   368
    have th0: "Im (inverse b) * (Im (inverse b) * \<bar>Im b * Im b + Re b * Re b\<bar>) +
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   369
    Re (inverse b) * (Re (inverse b) * \<bar>Im b * Im b + Re b * Re b\<bar>) =
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   370
    1" 
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   371
      apply (simp add: power2_eq_square norm_mult[symmetric] norm_inverse[symmetric])
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   372
      using right_inverse[OF b']
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   373
      by (simp add: power2_eq_square[symmetric] power_inverse[symmetric] ring_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   374
    have th0: "cmod (complex_of_real (cmod b) / b) = 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   375
      apply (simp add: complex_Re_mult cmod_def power2_eq_square Re_complex_of_real Im_complex_of_real divide_inverse ring_simps )
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   376
      by (simp add: real_sqrt_mult[symmetric] th0)        
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   377
    from o have "\<exists>m. n = Suc (2*m)" by presburger+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   378
    then obtain m where m: "n = Suc (2*m)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   379
    from unimodular_reduce_norm[OF th0] o
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   380
    have "\<exists>v. cmod (complex_of_real (cmod b) / b + v^n) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   381
      apply (cases "cmod (complex_of_real (cmod b) / b + 1) < 1", rule_tac x="1" in exI, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   382
      apply (cases "cmod (complex_of_real (cmod b) / b - 1) < 1", rule_tac x="-1" in exI, simp add: diff_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   383
      apply (cases "cmod (complex_of_real (cmod b) / b + ii) < 1")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   384
      apply (cases "even m", rule_tac x="ii" in exI, simp add: m power_mult)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   385
      apply (rule_tac x="- ii" in exI, simp add: m power_mult)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   386
      apply (cases "even m", rule_tac x="- ii" in exI, simp add: m power_mult diff_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   387
      apply (rule_tac x="ii" in exI, simp add: m power_mult diff_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   388
      done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   389
    then obtain v where v: "cmod (complex_of_real (cmod b) / b + v^n) < 1" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   390
    let ?w = "v / complex_of_real (root n (cmod b))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   391
    from odd_real_root_pow[OF o, of "cmod b"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   392
    have th1: "?w ^ n = v^n / complex_of_real (cmod b)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   393
      by (simp add: power_divide complex_of_real_power)
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   394
    have th2:"cmod (complex_of_real (cmod b) / b) = 1" using b by (simp add: norm_divide)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   395
    hence th3: "cmod (complex_of_real (cmod b) / b) \<ge> 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   396
    have th4: "cmod (complex_of_real (cmod b) / b) *
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   397
   cmod (1 + b * (v ^ n / complex_of_real (cmod b)))
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   398
   < cmod (complex_of_real (cmod b) / b) * 1"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   399
      apply (simp only: norm_mult[symmetric] right_distrib)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   400
      using b v by (simp add: th2)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   401
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   402
    from mult_less_imp_less_left[OF th4 th3]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   403
    have "?P ?w n" unfolding th1 . 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   404
    hence "\<exists>z. ?P z n" .. }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   405
  ultimately show "\<exists>z. ?P z n" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   406
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   407
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   408
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   409
text{* Bolzano-Weierstrass type property for closed disc in complex plane. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   410
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   411
lemma metric_bound_lemma: "cmod (x - y) <= \<bar>Re x - Re y\<bar> + \<bar>Im x - Im y\<bar>"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   412
  using real_sqrt_sum_squares_triangle_ineq[of "Re x - Re y" 0 0 "Im x - Im y" ]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   413
  unfolding cmod_def by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   414
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   415
lemma bolzano_weierstrass_complex_disc:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   416
  assumes r: "\<forall>n. cmod (s n) \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   417
  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
   418
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   419
  from seq_monosub[of "Re o s"] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   420
  obtain f g where f: "subseq f" "monoseq (\<lambda>n. Re (s (f n)))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   421
    unfolding o_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   422
  from seq_monosub[of "Im o s o f"] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   423
  obtain g where g: "subseq g" "monoseq (\<lambda>n. Im (s(f(g n))))" unfolding o_def by blast  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   424
  let ?h = "f o g"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   425
  from r[rule_format, of 0] have rp: "r \<ge> 0" using norm_ge_zero[of "s 0"] by arith 
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   426
  have th:"\<forall>n. r + 1 \<ge> \<bar> Re (s n)\<bar>" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   427
  proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   428
    fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   429
    from abs_Re_le_cmod[of "s n"] r[rule_format, of n]  show "\<bar>Re (s n)\<bar> \<le> r + 1" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   430
  qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   431
  have conv1: "convergent (\<lambda>n. Re (s ( f n)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   432
    apply (rule Bseq_monoseq_convergent)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   433
    apply (simp add: Bseq_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   434
    apply (rule exI[where x= "r + 1"])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   435
    using th rp apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   436
    using f(2) .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   437
  have th:"\<forall>n. r + 1 \<ge> \<bar> Im (s n)\<bar>" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   438
  proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   439
    fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   440
    from abs_Im_le_cmod[of "s n"] r[rule_format, of n]  show "\<bar>Im (s n)\<bar> \<le> r + 1" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   441
  qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   442
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   443
  have conv2: "convergent (\<lambda>n. Im (s (f (g n))))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   444
    apply (rule Bseq_monoseq_convergent)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   445
    apply (simp add: Bseq_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   446
    apply (rule exI[where x= "r + 1"])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   447
    using th rp apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   448
    using g(2) .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   449
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   450
  from conv1[unfolded convergent_def] obtain x where "LIMSEQ (\<lambda>n. Re (s (f n))) x" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   451
    by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   452
  hence  x: "\<forall>r>0. \<exists>n0. \<forall>n\<ge>n0. \<bar> Re (s (f n)) - x \<bar> < r" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   453
    unfolding LIMSEQ_def real_norm_def .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   454
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   455
  from conv2[unfolded convergent_def] obtain y where "LIMSEQ (\<lambda>n. Im (s (f (g n)))) y" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   456
    by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   457
  hence  y: "\<forall>r>0. \<exists>n0. \<forall>n\<ge>n0. \<bar> Im (s (f (g n))) - y \<bar> < r" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   458
    unfolding LIMSEQ_def real_norm_def .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   459
  let ?w = "Complex x y"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   460
  from f(1) g(1) have hs: "subseq ?h" unfolding subseq_def by auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   461
  {fix e assume ep: "e > (0::real)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   462
    hence e2: "e/2 > 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   463
    from x[rule_format, OF e2] y[rule_format, OF e2]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   464
    obtain N1 N2 where N1: "\<forall>n\<ge>N1. \<bar>Re (s (f n)) - x\<bar> < e / 2" and N2: "\<forall>n\<ge>N2. \<bar>Im (s (f (g n))) - y\<bar> < e / 2" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   465
    {fix n assume nN12: "n \<ge> N1 + N2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   466
      hence nN1: "g n \<ge> N1" and nN2: "n \<ge> N2" using seq_suble[OF g(1), of n] by arith+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   467
      from add_strict_mono[OF N1[rule_format, OF nN1] N2[rule_format, OF nN2]]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   468
      have "cmod (s (?h n) - ?w) < e" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   469
	using metric_bound_lemma[of "s (f (g n))" ?w] by simp }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   470
    hence "\<exists>N. \<forall>n\<ge>N. cmod (s (?h n) - ?w) < e" by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   471
  with hs show ?thesis  by blast  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   472
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   473
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   474
text{* Polynomial is continuous. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   475
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   476
lemma poly_cont:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   477
  assumes ep: "e > 0" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   478
  shows "\<exists>d >0. \<forall>w. 0 < cmod (w - z) \<and> cmod (w - z) < d \<longrightarrow> cmod (poly p w - poly p z) < e"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   479
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   480
  from poly_offset[of p z] obtain q where q: "length q = length p" "\<And>x. poly q x = poly p (z + x)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   481
  {fix w
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   482
    note q(2)[of "w - z", simplified]}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   483
  note th = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   484
  show ?thesis unfolding th[symmetric]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   485
  proof(induct q)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   486
    case Nil thus ?case  using ep by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   487
  next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   488
    case (Cons c cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   489
    from poly_bound_exists[of 1 "cs"] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   490
    obtain m where m: "m > 0" "\<And>z. cmod z \<le> 1 \<Longrightarrow> cmod (poly cs z) \<le> m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   491
    from ep m(1) have em0: "e/m > 0" by (simp add: field_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   492
    have one0: "1 > (0::real)"  by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   493
    from real_lbound_gt_zero[OF one0 em0] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   494
    obtain d where d: "d >0" "d < 1" "d < e / m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   495
    from d(1,3) m(1) have dm: "d*m > 0" "d*m < e" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   496
      by (simp_all add: field_simps real_mult_order)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   497
    show ?case 
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   498
      proof(rule ex_forward[OF real_lbound_gt_zero[OF one0 em0]], clarsimp simp add: norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   499
	fix d w
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   500
	assume H: "d > 0" "d < 1" "d < e/m" "w\<noteq>z" "cmod (w-z) < d"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   501
	hence d1: "cmod (w-z) \<le> 1" "d \<ge> 0" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   502
	from H(3) m(1) have dme: "d*m < e" by (simp add: field_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   503
	from H have th: "cmod (w-z) \<le> d" by simp 
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   504
	from mult_mono[OF th m(2)[OF d1(1)] d1(2) norm_ge_zero] dme
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   505
	show "cmod (w - z) * cmod (poly cs (w - z)) < e" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   506
      qed  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   507
    qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   508
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   509
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   510
text{* Hence a polynomial attains minimum on a closed disc 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   511
  in the complex plane. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   512
lemma  poly_minimum_modulus_disc:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   513
  "\<exists>z. \<forall>w. cmod w \<le> r \<longrightarrow> cmod (poly p z) \<le> cmod (poly p w)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   514
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   515
  {assume "\<not> r \<ge> 0" hence ?thesis unfolding linorder_not_le
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   516
      apply -
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   517
      apply (rule exI[where x=0]) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   518
      apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   519
      apply (subgoal_tac "cmod w < 0")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   520
      apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   521
      apply arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   522
      done }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   523
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   524
  {assume rp: "r \<ge> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   525
    from rp have "cmod 0 \<le> r \<and> cmod (poly p 0) = - (- cmod (poly p 0))" by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   526
    hence mth1: "\<exists>x z. cmod z \<le> r \<and> cmod (poly p z) = - x"  by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   527
    {fix x z
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   528
      assume H: "cmod z \<le> r" "cmod (poly p z) = - x" "\<not>x < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   529
      hence "- x < 0 " by arith
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   530
      with H(2) norm_ge_zero[of "poly p z"]  have False by simp }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   531
    then have mth2: "\<exists>z. \<forall>x. (\<exists>z. cmod z \<le> r \<and> cmod (poly p z) = - x) \<longrightarrow> x < z" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   532
    from real_sup_exists[OF mth1 mth2] obtain s where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   533
      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
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   534
    let ?m = "-s"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   535
    {fix y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   536
      from s[rule_format, of "-y"] have 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   537
    "(\<exists>z x. cmod z \<le> r \<and> -(- cmod (poly p z)) < y) \<longleftrightarrow> ?m < y" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   538
	unfolding minus_less_iff[of y ] equation_minus_iff by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   539
    note s1 = this[unfolded minus_minus]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   540
    from s1[of ?m] have s1m: "\<And>z x. cmod z \<le> r \<Longrightarrow> cmod (poly p z) \<ge> ?m" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   541
      by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   542
    {fix n::nat
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   543
      from s1[rule_format, of "?m + 1/real (Suc n)"] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   544
      have "\<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   545
	by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   546
    hence th: "\<forall>n. \<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)" ..
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   547
    from choice[OF th] obtain g where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   548
      g: "\<forall>n. cmod (g n) \<le> r" "\<forall>n. cmod (poly p (g n)) <?m+1 /real(Suc n)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   549
      by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   550
    from bolzano_weierstrass_complex_disc[OF g(1)] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   551
    obtain f z where fz: "subseq f" "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. cmod (g (f n) - z) < e"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   552
      by blast    
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   553
    {fix w 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   554
      assume wr: "cmod w \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   555
      let ?e = "\<bar>cmod (poly p z) - ?m\<bar>"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   556
      {assume e: "?e > 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   557
	hence e2: "?e/2 > 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   558
	from poly_cont[OF e2, of z p] obtain d where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   559
	  d: "d>0" "\<forall>w. 0<cmod (w - z)\<and> cmod(w - z) < d \<longrightarrow> cmod(poly p w - poly p z) < ?e/2" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   560
	{fix w assume w: "cmod (w - z) < d"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   561
	  have "cmod(poly p w - poly p z) < ?e / 2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   562
	    using d(2)[rule_format, of w] w e by (cases "w=z", simp_all)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   563
	note th1 = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   564
	
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   565
	from fz(2)[rule_format, OF d(1)] obtain N1 where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   566
	  N1: "\<forall>n\<ge>N1. cmod (g (f n) - z) < d" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   567
	from reals_Archimedean2[of "2/?e"] obtain N2::nat where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   568
	  N2: "2/?e < real N2" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   569
	have th2: "cmod(poly p (g(f(N1 + N2))) - poly p z) < ?e/2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   570
	  using N1[rule_format, of "N1 + N2"] th1 by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   571
	{fix a b e2 m :: real
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   572
	have "a < e2 \<Longrightarrow> abs(b - m) < e2 \<Longrightarrow> 2 * e2 <= abs(b - m) + a
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   573
          ==> False" by arith}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   574
      note th0 = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   575
      have ath: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   576
	"\<And>m x e. m <= x \<Longrightarrow>  x < m + e ==> abs(x - m::real) < e" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   577
      from s1m[OF g(1)[rule_format]]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   578
      have th31: "?m \<le> cmod(poly p (g (f (N1 + N2))))" .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   579
      from seq_suble[OF fz(1), of "N1+N2"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   580
      have th00: "real (Suc (N1+N2)) \<le> real (Suc (f (N1+N2)))" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   581
      have th000: "0 \<le> (1::real)" "(1::real) \<le> 1" "real (Suc (N1+N2)) > 0"  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   582
	using N2 by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   583
      from frac_le[OF th000 th00] have th00: "?m +1 / real (Suc (f (N1 + N2))) \<le> ?m + 1 / real (Suc (N1 + N2))" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   584
      from g(2)[rule_format, of "f (N1 + N2)"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   585
      have th01:"cmod (poly p (g (f (N1 + N2)))) < - s + 1 / real (Suc (f (N1 + N2)))" .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   586
      from order_less_le_trans[OF th01 th00]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   587
      have th32: "cmod(poly p (g (f (N1 + N2)))) < ?m + (1/ real(Suc (N1 + N2)))" .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   588
      from N2 have "2/?e < real (Suc (N1 + N2))" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   589
      with e2 less_imp_inverse_less[of "2/?e" "real (Suc (N1 + N2))"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   590
      have "?e/2 > 1/ real (Suc (N1 + N2))" by (simp add: inverse_eq_divide)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   591
      with ath[OF th31 th32]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   592
      have thc1:"\<bar>cmod(poly p (g (f (N1 + N2)))) - ?m\<bar>< ?e/2" by arith  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   593
      have ath2: "\<And>(a::real) b c m. \<bar>a - b\<bar> <= c ==> \<bar>b - m\<bar> <= \<bar>a - m\<bar> + c" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   594
	by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   595
      have th22: "\<bar>cmod (poly p (g (f (N1 + N2)))) - cmod (poly p z)\<bar>
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   596
\<le> cmod (poly p (g (f (N1 + N2))) - poly p z)" 
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   597
	by (simp add: norm_triangle_ineq3)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   598
      from ath2[OF th22, of ?m]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   599
      have thc2: "2*(?e/2) \<le> \<bar>cmod(poly p (g (f (N1 + N2)))) - ?m\<bar> + cmod (poly p (g (f (N1 + N2))) - poly p z)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   600
      from th0[OF th2 thc1 thc2] have False .}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   601
      hence "?e = 0" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   602
      then have "cmod (poly p z) = ?m" by simp  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   603
      with s1m[OF wr]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   604
      have "cmod (poly p z) \<le> cmod (poly p w)" by simp }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   605
    hence ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   606
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   607
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   608
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   609
lemma "(rcis (sqrt (abs r)) (a/2)) ^ 2 = rcis (abs r) a"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   610
  unfolding power2_eq_square
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   611
  apply (simp add: rcis_mult)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   612
  apply (simp add: power2_eq_square[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   613
  done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   614
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   615
lemma cispi: "cis pi = -1" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   616
  unfolding cis_def
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   617
  by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   618
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   619
lemma "(rcis (sqrt (abs r)) ((pi + a)/2)) ^ 2 = rcis (- abs r) a"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   620
  unfolding power2_eq_square
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   621
  apply (simp add: rcis_mult add_divide_distrib)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   622
  apply (simp add: power2_eq_square[symmetric] rcis_def cispi cis_mult[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   623
  done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   624
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   625
text {* Nonzero polynomial in z goes to infinity as z does. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   626
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   627
instance complex::idom_char_0 by (intro_classes)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   628
instance complex :: recpower_idom_char_0 by intro_classes
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   629
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   630
lemma poly_infinity:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   631
  assumes ex: "list_ex (\<lambda>c. c \<noteq> 0) p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   632
  shows "\<exists>r. \<forall>z. r \<le> cmod z \<longrightarrow> d \<le> cmod (poly (a#p) z)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   633
using ex
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   634
proof(induct p arbitrary: a d)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   635
  case (Cons c cs a d) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   636
  {assume H: "list_ex (\<lambda>c. c\<noteq>0) cs"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   637
    with Cons.hyps obtain r where r: "\<forall>z. r \<le> cmod z \<longrightarrow> d + cmod a \<le> cmod (poly (c # cs) z)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   638
    let ?r = "1 + \<bar>r\<bar>"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   639
    {fix z assume h: "1 + \<bar>r\<bar> \<le> cmod z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   640
      have r0: "r \<le> cmod z" using h by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   641
      from r[rule_format, OF r0]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   642
      have th0: "d + cmod a \<le> 1 * cmod(poly (c#cs) z)" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   643
      from h have z1: "cmod z \<ge> 1" by arith
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   644
      from order_trans[OF th0 mult_right_mono[OF z1 norm_ge_zero[of "poly (c#cs) z"]]]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   645
      have th1: "d \<le> cmod(z * poly (c#cs) z) - cmod a"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   646
	unfolding norm_mult by (simp add: ring_simps)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   647
      from complex_mod_triangle_sub[of "z * poly (c#cs) z" a]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   648
      have th2: "cmod(z * poly (c#cs) z) - cmod a \<le> cmod (poly (a#c#cs) z)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   649
	by (simp add: diff_le_eq ring_simps) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   650
      from th1 th2 have "d \<le> cmod (poly (a#c#cs) z)"  by arith}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   651
    hence ?case by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   652
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   653
  {assume cs0: "\<not> (list_ex (\<lambda>c. c \<noteq> 0) cs)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   654
    with Cons.prems have c0: "c \<noteq> 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   655
    from cs0 have cs0': "list_all (\<lambda>c. c = 0) cs" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   656
      by (auto simp add: list_all_iff list_ex_iff)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   657
    {fix z
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   658
      assume h: "(\<bar>d\<bar> + cmod a) / cmod c \<le> cmod z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   659
      from c0 have "cmod c > 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   660
      from h c0 have th0: "\<bar>d\<bar> + cmod a \<le> cmod (z*c)" 
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   661
	by (simp add: field_simps norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   662
      have ath: "\<And>mzh mazh ma. mzh <= mazh + ma ==> abs(d) + ma <= mzh ==> d <= mazh" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   663
      from complex_mod_triangle_sub[of "z*c" a ]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   664
      have th1: "cmod (z * c) \<le> cmod (a + z * c) + cmod a"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   665
	by (simp add: ring_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   666
      from ath[OF th1 th0] have "d \<le> cmod (poly (a # c # cs) z)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   667
	using poly_0[OF cs0'] by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   668
    then have ?case  by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   669
  ultimately show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   670
qed simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   671
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   672
text {* Hence polynomial's modulus attains its minimum somewhere. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   673
lemma poly_minimum_modulus:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   674
  "\<exists>z.\<forall>w. cmod (poly p z) \<le> cmod (poly p w)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   675
proof(induct p)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   676
  case (Cons c cs) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   677
  {assume cs0: "list_ex (\<lambda>c. c \<noteq> 0) cs"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   678
    from poly_infinity[OF cs0, of "cmod (poly (c#cs) 0)" c]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   679
    obtain r where r: "\<And>z. r \<le> cmod z \<Longrightarrow> cmod (poly (c # cs) 0) \<le> cmod (poly (c # cs) z)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   680
    have ath: "\<And>z r. r \<le> cmod z \<or> cmod z \<le> \<bar>r\<bar>" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   681
    from poly_minimum_modulus_disc[of "\<bar>r\<bar>" "c#cs"] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   682
    obtain v where v: "\<And>w. cmod w \<le> \<bar>r\<bar> \<Longrightarrow> cmod (poly (c # cs) v) \<le> cmod (poly (c # cs) w)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   683
    {fix z assume z: "r \<le> cmod z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   684
      from v[of 0] r[OF z] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   685
      have "cmod (poly (c # cs) v) \<le> cmod (poly (c # cs) z)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   686
	by simp }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   687
    note v0 = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   688
    from v0 v ath[of r] have ?case by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   689
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   690
  {assume cs0: "\<not> (list_ex (\<lambda>c. c\<noteq>0) cs)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   691
    hence th:"list_all (\<lambda>c. c = 0) cs" by (simp add: list_all_iff list_ex_iff)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   692
    from poly_0[OF th] Cons.hyps have ?case by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   693
  ultimately show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   694
qed simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   695
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   696
text{* Constant function (non-syntactic characterization). *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   697
definition "constant f = (\<forall>x y. f x = f y)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   698
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   699
lemma nonconstant_length: "\<not> (constant (poly p)) \<Longrightarrow> length p \<ge> 2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   700
  unfolding constant_def
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   701
  apply (induct p, auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   702
  apply (unfold not_less[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   703
  apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   704
  apply (rule ccontr)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   705
  apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   706
  done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   707
 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   708
lemma poly_replicate_append:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   709
  "poly ((replicate n 0)@p) (x::'a::{recpower, comm_ring}) = x^n * poly p x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   710
  by(induct n, auto simp add: power_Suc ring_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   711
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   712
text {* Decomposition of polynomial, skipping zero coefficients 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   713
  after the first.  *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   714
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   715
lemma poly_decompose_lemma:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   716
 assumes nz: "\<not>(\<forall>z. z\<noteq>0 \<longrightarrow> poly p z = (0::'a::{recpower,idom}))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   717
  shows "\<exists>k a q. a\<noteq>0 \<and> Suc (length q + k) = length p \<and> 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   718
                 (\<forall>z. poly p z = z^k * poly (a#q) z)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   719
using nz
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   720
proof(induct p)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   721
  case Nil thus ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   722
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   723
  case (Cons c cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   724
  {assume c0: "c = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   725
    
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   726
    from Cons.hyps Cons.prems c0 have ?case apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   727
      apply (rule_tac x="k+1" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   728
      apply (rule_tac x="a" in exI, clarsimp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   729
      apply (rule_tac x="q" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   730
      by (auto simp add: power_Suc)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   731
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   732
  {assume c0: "c\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   733
    hence ?case apply-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   734
      apply (rule exI[where x=0])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   735
      apply (rule exI[where x=c], clarsimp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   736
      apply (rule exI[where x=cs])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   737
      apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   738
      done}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   739
  ultimately show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   740
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   741
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   742
lemma poly_decompose:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   743
  assumes nc: "~constant(poly p)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   744
  shows "\<exists>k a q. a\<noteq>(0::'a::{recpower,idom}) \<and> k\<noteq>0 \<and>
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   745
               length q + k + 1 = length p \<and> 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   746
              (\<forall>z. poly p z = poly p 0 + z^k * poly (a#q) z)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   747
using nc 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   748
proof(induct p)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   749
  case Nil thus ?case by (simp add: constant_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   750
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   751
  case (Cons c cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   752
  {assume C:"\<forall>z. z \<noteq> 0 \<longrightarrow> poly cs z = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   753
    {fix x y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   754
      from C have "poly (c#cs) x = poly (c#cs) y" by (cases "x=0", auto)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   755
    with Cons.prems have False by (auto simp add: constant_def)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   756
  hence th: "\<not> (\<forall>z. z \<noteq> 0 \<longrightarrow> poly cs z = 0)" ..
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   757
  from poly_decompose_lemma[OF th] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   758
  show ?case 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   759
    apply clarsimp    
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   760
    apply (rule_tac x="k+1" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   761
    apply (rule_tac x="a" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   762
    apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   763
    apply (rule_tac x="q" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   764
    apply (auto simp add: power_Suc)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   765
    done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   766
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   767
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   768
text{* Fundamental theorem of algebral *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   769
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   770
lemma fundamental_theorem_of_algebra:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   771
  assumes nc: "~constant(poly p)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   772
  shows "\<exists>z::complex. poly p z = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   773
using nc
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   774
proof(induct n\<equiv> "length p" arbitrary: p rule: nat_less_induct)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   775
  fix n fix p :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   776
  let ?p = "poly p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   777
  assume H: "\<forall>m<n. \<forall>p. \<not> constant (poly p) \<longrightarrow> m = length p \<longrightarrow> (\<exists>(z::complex). poly p z = 0)" and nc: "\<not> constant ?p" and n: "n = length p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   778
  let ?ths = "\<exists>z. ?p z = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   779
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   780
  from nonconstant_length[OF nc] have n2: "n\<ge> 2" by (simp add: n)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   781
  from poly_minimum_modulus obtain c where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   782
    c: "\<forall>w. cmod (?p c) \<le> cmod (?p w)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   783
  {assume pc: "?p c = 0" hence ?ths by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   784
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   785
  {assume pc0: "?p c \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   786
    from poly_offset[of p c] obtain q where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   787
      q: "length q = length p" "\<forall>x. poly q x = ?p (c+x)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   788
    {assume h: "constant (poly q)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   789
      from q(2) have th: "\<forall>x. poly q (x - c) = ?p x" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   790
      {fix x y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   791
	from th have "?p x = poly q (x - c)" by auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   792
	also have "\<dots> = poly q (y - c)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   793
	  using h unfolding constant_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   794
	also have "\<dots> = ?p y" using th by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   795
	finally have "?p x = ?p y" .}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   796
      with nc have False unfolding constant_def by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   797
    hence qnc: "\<not> constant (poly q)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   798
    from q(2) have pqc0: "?p c = poly q 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   799
    from c pqc0 have cq0: "\<forall>w. cmod (poly q 0) \<le> cmod (?p w)" by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   800
    let ?a0 = "poly q 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   801
    from pc0 pqc0 have a00: "?a0 \<noteq> 0" by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   802
    from a00 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   803
    have qr: "\<forall>z. poly q z = poly (map (op * (inverse ?a0)) q) z * ?a0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   804
      by (simp add: poly_cmult_map)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   805
    let ?r = "map (op * (inverse ?a0)) q"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   806
    have lgqr: "length q = length ?r" by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   807
    {assume h: "\<And>x y. poly ?r x = poly ?r y"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   808
      {fix x y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   809
	from qr[rule_format, of x] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   810
	have "poly q x = poly ?r x * ?a0" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   811
	also have "\<dots> = poly ?r y * ?a0" using h by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   812
	also have "\<dots> = poly q y" using qr[rule_format, of y] by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   813
	finally have "poly q x = poly q y" .} 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   814
      with qnc have False unfolding constant_def by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   815
    hence rnc: "\<not> constant (poly ?r)" unfolding constant_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   816
    from qr[rule_format, of 0] a00  have r01: "poly ?r 0 = 1" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   817
    {fix w 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   818
      have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w / ?a0) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   819
	using qr[rule_format, of w] a00 by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   820
      also have "\<dots> \<longleftrightarrow> cmod (poly q w) < cmod ?a0"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   821
	using a00 unfolding norm_divide by (simp add: field_simps)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   822
      finally have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w) < cmod ?a0" .}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   823
    note mrmq_eq = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   824
    from poly_decompose[OF rnc] obtain k a s where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   825
      kas: "a\<noteq>0" "k\<noteq>0" "length s + k + 1 = length ?r" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   826
      "\<forall>z. poly ?r z = poly ?r 0 + z^k* poly (a#s) z" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   827
    {assume "k + 1 = n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   828
      with kas(3) lgqr[symmetric] q(1) n[symmetric] have s0:"s=[]" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   829
      {fix w
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   830
	have "cmod (poly ?r w) = cmod (1 + a * w ^ k)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   831
	  using kas(4)[rule_format, of w] s0 r01 by (simp add: ring_simps)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   832
      note hth = this [symmetric]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   833
	from reduce_poly_simple[OF kas(1,2)] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   834
      have "\<exists>w. cmod (poly ?r w) < 1" unfolding hth by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   835
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   836
    {assume kn: "k+1 \<noteq> n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   837
      from kn kas(3) q(1) n[symmetric] have k1n: "k + 1 < n" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   838
      have th01: "\<not> constant (poly (1#((replicate (k - 1) 0)@[a])))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   839
	unfolding constant_def poly_Nil poly_Cons poly_replicate_append
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   840
	using kas(1) apply simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   841
	by (rule exI[where x=0], rule exI[where x=1], simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   842
      from kas(2) have th02: "k+1 = length (1#((replicate (k - 1) 0)@[a]))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   843
	by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   844
      from H[rule_format, OF k1n th01 th02]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   845
      obtain w where w: "1 + w^k * a = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   846
	unfolding poly_Nil poly_Cons poly_replicate_append
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   847
	using kas(2) by (auto simp add: power_Suc[symmetric, of _ "k - Suc 0"] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   848
	  mult_assoc[of _ _ a, symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   849
      from poly_bound_exists[of "cmod w" s] obtain m where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   850
	m: "m > 0" "\<forall>z. cmod z \<le> cmod w \<longrightarrow> cmod (poly s z) \<le> m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   851
      have w0: "w\<noteq>0" using kas(2) w by (auto simp add: power_0_left)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   852
      from w have "(1 + w ^ k * a) - 1 = 0 - 1" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   853
      then have wm1: "w^k * a = - 1" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   854
      have inv0: "0 < inverse (cmod w ^ (k + 1) * m)" 
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   855
	using norm_ge_zero[of w] w0 m(1)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   856
	  by (simp add: inverse_eq_divide zero_less_mult_iff)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   857
      with real_down2[OF zero_less_one] obtain t where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   858
	t: "t > 0" "t < 1" "t < inverse (cmod w ^ (k + 1) * m)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   859
      let ?ct = "complex_of_real t"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   860
      let ?w = "?ct * w"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   861
      have "1 + ?w^k * (a + ?w * poly s ?w) = 1 + ?ct^k * (w^k * a) + ?w^k * ?w * poly s ?w" using kas(1) by (simp add: ring_simps power_mult_distrib)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   862
      also have "\<dots> = complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   863
	unfolding wm1 by (simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   864
      finally have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) = cmod (complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   865
	apply -
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   866
	apply (rule cong[OF refl[of cmod]])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   867
	apply assumption
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   868
	done
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   869
      with norm_triangle_ineq[of "complex_of_real (1 - t^k)" "?w^k * ?w * poly s ?w"] 
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   870
      have th11: "cmod (1 + ?w^k * (a + ?w * poly s ?w)) \<le> \<bar>1 - t^k\<bar> + cmod (?w^k * ?w * poly s ?w)" unfolding norm_of_real by simp 
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   871
      have ath: "\<And>x (t::real). 0\<le> x \<Longrightarrow> x < t \<Longrightarrow> t\<le>1 \<Longrightarrow> \<bar>1 - t\<bar> + x < 1" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   872
      have "t *cmod w \<le> 1 * cmod w" apply (rule mult_mono) using t(1,2) by auto
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   873
      then have tw: "cmod ?w \<le> cmod w" using t(1) by (simp add: norm_mult) 
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   874
      from t inv0 have "t* (cmod w ^ (k + 1) * m) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   875
	by (simp add: inverse_eq_divide field_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   876
      with zero_less_power[OF t(1), of k] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   877
      have th30: "t^k * (t* (cmod w ^ (k + 1) * m)) < t^k * 1" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   878
	apply - apply (rule mult_strict_left_mono) by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   879
      have "cmod (?w^k * ?w * poly s ?w) = t^k * (t* (cmod w ^ (k+1) * cmod (poly s ?w)))"  using w0 t(1)
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   880
	by (simp add: ring_simps power_mult_distrib norm_of_real norm_power norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   881
      then have "cmod (?w^k * ?w * poly s ?w) \<le> t^k * (t* (cmod w ^ (k + 1) * m))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   882
	using t(1,2) m(2)[rule_format, OF tw] w0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   883
	apply (simp only: )
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   884
	apply auto
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   885
	apply (rule mult_mono, simp_all add: norm_ge_zero)+
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   886
	apply (simp add: zero_le_mult_iff zero_le_power)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   887
	done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   888
      with th30 have th120: "cmod (?w^k * ?w * poly s ?w) < t^k" by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   889
      from power_strict_mono[OF t(2), of k] t(1) kas(2) have th121: "t^k \<le> 1" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   890
	by auto
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   891
      from ath[OF norm_ge_zero[of "?w^k * ?w * poly s ?w"] th120 th121]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   892
      have th12: "\<bar>1 - t^k\<bar> + cmod (?w^k * ?w * poly s ?w) < 1" . 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   893
      from th11 th12
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   894
      have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) < 1"  by arith 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   895
      then have "cmod (poly ?r ?w) < 1" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   896
	unfolding kas(4)[rule_format, of ?w] r01 by simp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   897
      then have "\<exists>w. cmod (poly ?r w) < 1" by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   898
    ultimately have cr0_contr: "\<exists>w. cmod (poly ?r w) < 1" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   899
    from cr0_contr cq0 q(2)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   900
    have ?ths unfolding mrmq_eq not_less[symmetric] by auto}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   901
  ultimately show ?ths by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   902
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   903
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   904
text {* Alternative version with a syntactic notion of constant polynomial. *}
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 fundamental_theorem_of_algebra_alt:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   907
  assumes nc: "~(\<exists>a l. a\<noteq> 0 \<and> list_all(\<lambda>b. b = 0) l \<and> p = a#l)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   908
  shows "\<exists>z. poly p z = (0::complex)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   909
using nc
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   910
proof(induct p)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   911
  case (Cons c cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   912
  {assume "c=0" hence ?case by auto}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   913
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   914
  {assume c0: "c\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   915
    {assume nc: "constant (poly (c#cs))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   916
      from nc[unfolded constant_def, rule_format, of 0] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   917
      have "\<forall>w. w \<noteq> 0 \<longrightarrow> poly cs w = 0" by auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   918
      hence "list_all (\<lambda>c. c=0) cs"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   919
	proof(induct cs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   920
	  case (Cons d ds)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   921
	  {assume "d=0" hence ?case using Cons.prems Cons.hyps by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   922
	  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   923
	  {assume d0: "d\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   924
	    from poly_bound_exists[of 1 ds] obtain m where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   925
	      m: "m > 0" "\<forall>z. \<forall>z. cmod z \<le> 1 \<longrightarrow> cmod (poly ds z) \<le> m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   926
	    have dm: "cmod d / m > 0" using d0 m(1) by (simp add: field_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   927
	    from real_down2[OF dm zero_less_one] obtain x where 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   928
	      x: "x > 0" "x < cmod d / m" "x < 1" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   929
	    let ?x = "complex_of_real x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   930
	    from x have cx: "?x \<noteq> 0"  "cmod ?x \<le> 1" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   931
	    from Cons.prems[rule_format, OF cx(1)]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   932
	    have cth: "cmod (?x*poly ds ?x) = cmod d" by (simp add: eq_diff_eq[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   933
	    from m(2)[rule_format, OF cx(2)] x(1)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   934
	    have th0: "cmod (?x*poly ds ?x) \<le> x*m"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   935
	      by (simp add: norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   936
	    from x(2) m(1) have "x*m < cmod d" by (simp add: field_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   937
	    with th0 have "cmod (?x*poly ds ?x) \<noteq> cmod d" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   938
	    with cth  have ?case by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   939
	  ultimately show ?case by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   940
	qed simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   941
      then have nc: "\<not> constant (poly (c#cs))" using Cons.prems c0 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   942
	by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   943
      from fundamental_theorem_of_algebra[OF nc] have ?case .}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   944
  ultimately show ?case by blast  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   945
qed simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   946
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
   947
subsection{* Nullstellenstatz, degrees and divisibility of polynomials *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   948
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   949
lemma nullstellensatz_lemma:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   950
  fixes p :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   951
  assumes "\<forall>x. poly p x = 0 \<longrightarrow> poly q x = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   952
  and "degree p = n" and "n \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   953
  shows "p divides (pexp q n)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   954
using prems
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   955
proof(induct n arbitrary: p q rule: nat_less_induct)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   956
  fix n::nat fix p q :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   957
  assume IH: "\<forall>m<n. \<forall>p q.
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   958
                 (\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longrightarrow>
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   959
                 degree p = m \<longrightarrow> m \<noteq> 0 \<longrightarrow> p divides (q %^ m)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   960
    and pq0: "\<forall>x. poly p x = 0 \<longrightarrow> poly q x = 0" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   961
    and dpn: "degree p = n" and n0: "n \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   962
  let ?ths = "p divides (q %^ n)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   963
  {fix a assume a: "poly p a = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   964
    {assume p0: "poly p = poly []" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   965
      hence ?ths unfolding divides_def  using pq0 n0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   966
	apply - apply (rule exI[where x="[]"], rule ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   967
	by (auto simp add: poly_mult poly_exp)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   968
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   969
    {assume p0: "poly p \<noteq> poly []" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   970
      and oa: "order  a p \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   971
      from p0 have pne: "p \<noteq> []" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   972
      let ?op = "order a p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   973
      from p0 have ap: "([- a, 1] %^ ?op) divides p" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   974
	"\<not> pexp [- a, 1] (Suc ?op) divides p" using order by blast+ 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   975
      note oop = order_degree[OF p0, unfolded dpn]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   976
      {assume q0: "q = []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   977
	hence ?ths using n0 unfolding divides_def 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   978
	  apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   979
	  apply (rule exI[where x="[]"], rule ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   980
	  by (simp add: divides_def poly_exp poly_mult)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   981
      moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   982
      {assume q0: "q\<noteq>[]"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   983
	from pq0[rule_format, OF a, unfolded poly_linear_divides] q0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   984
	obtain r where r: "q = pmult [- a, 1] r" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   985
	from ap[unfolded divides_def] obtain s where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   986
	  s: "poly p = poly (pmult (pexp [- a, 1] ?op) s)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   987
	have s0: "poly s \<noteq> poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   988
	  using s p0 by (simp add: poly_entire)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   989
	hence pns0: "poly (pnormalize s) \<noteq> poly []" and sne: "s\<noteq>[]" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   990
	{assume ds0: "degree s = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   991
	  from ds0 pns0 have "\<exists>k. pnormalize s = [k]" unfolding degree_def 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   992
	    by (cases "pnormalize s", auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   993
	  then obtain k where kpn: "pnormalize s = [k]" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   994
	  from pns0[unfolded poly_zero] kpn have k: "k \<noteq>0" "poly s = poly [k]"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   995
	    using poly_normalize[of s] by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   996
	  let ?w = "pmult (pmult [1/k] (pexp [-a,1] (n - ?op))) (pexp r n)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   997
	  from k r s oop have "poly (pexp q n) = poly (pmult p ?w)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   998
	    by - (rule ext, simp add: poly_mult poly_exp poly_cmult poly_add power_add[symmetric] ring_simps power_mult_distrib[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   999
	  hence ?ths unfolding divides_def by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1000
	moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1001
	{assume ds0: "degree s \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1002
	  from ds0 s0 dpn degree_unique[OF s, unfolded linear_pow_mul_degree] oa
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1003
	    have dsn: "degree s < n" by auto 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1004
	    {fix x assume h: "poly s x = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1005
	      {assume xa: "x = a"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1006
		from h[unfolded xa poly_linear_divides] sne obtain u where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1007
		  u: "s = pmult [- a, 1] u" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1008
		have "poly p = poly (pmult (pexp [- a, 1] (Suc ?op)) u)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1009
		  unfolding s u
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1010
		  apply (rule ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1011
		  by (simp add: ring_simps power_mult_distrib[symmetric] poly_mult poly_cmult poly_add poly_exp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1012
		with ap(2)[unfolded divides_def] have False by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1013
	      note xa = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1014
	      from h s have "poly p x = 0" by (simp add: poly_mult)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1015
	      with pq0 have "poly q x = 0" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1016
	      with r xa have "poly r x = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1017
		by (auto simp add: poly_mult poly_add poly_cmult eq_diff_eq[symmetric])}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1018
	    note impth = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1019
	    from IH[rule_format, OF dsn, of s r] impth ds0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1020
	    have "s divides (pexp r (degree s))" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1021
	    then obtain u where u: "poly (pexp r (degree s)) = poly (pmult s u)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1022
	      unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1023
	    hence u': "\<And>x. poly s x * poly u x = poly r x ^ degree s"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1024
	      by (simp add: poly_mult[symmetric] poly_exp[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1025
	    let ?w = "pmult (pmult u (pexp [-a,1] (n - ?op))) (pexp r (n - degree s))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1026
	    from u' s r oop[of a] dsn have "poly (pexp q n) = poly (pmult p ?w)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1027
	      apply - apply (rule ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1028
	      apply (simp only:  power_mult_distrib power_add[symmetric] poly_add poly_mult poly_exp poly_cmult ring_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1029
	      
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1030
	      apply (simp add:  power_mult_distrib power_add[symmetric] poly_add poly_mult poly_exp poly_cmult mult_assoc[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1031
	      done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1032
	    hence ?ths unfolding divides_def by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1033
      ultimately have ?ths by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1034
      ultimately have ?ths by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1035
    ultimately have ?ths using a order_root by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1036
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1037
  {assume exa: "\<not> (\<exists>a. poly p a = 0)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1038
    from fundamental_theorem_of_algebra_alt[of p] exa obtain c cs where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1039
      ccs: "c\<noteq>0" "list_all (\<lambda>c. c = 0) cs" "p = c#cs" by blast
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
    from poly_0[OF ccs(2)] ccs(3) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1042
    have pp: "\<And>x. poly p x =  c" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1043
    let ?w = "pmult [1/c] (pexp q n)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1044
    from pp ccs(1) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1045
    have "poly (pexp q n) = poly (pmult p ?w) "
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1046
      apply - apply (rule ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1047
      unfolding poly_mult_assoc[symmetric] by (simp add: poly_mult)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1048
    hence ?ths unfolding divides_def by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1049
  ultimately show ?ths by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1050
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1051
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1052
lemma nullstellensatz_univariate:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1053
  "(\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longleftrightarrow> 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1054
    p divides (q %^ (degree p)) \<or> (poly p = poly [] \<and> poly q = poly [])"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1055
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1056
  {assume pe: "poly p = poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1057
    hence eq: "(\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longleftrightarrow> poly q = poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1058
      apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1059
      by (rule ext, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1060
    {assume "p divides (pexp q (degree p))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1061
      then obtain r where r: "poly (pexp q (degree p)) = poly (pmult p r)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1062
	unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1063
      from cong[OF r refl] pe degree_unique[OF pe]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1064
      have False by (simp add: poly_mult degree_def)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1065
    with eq pe have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1066
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1067
  {assume pe: "poly p \<noteq> poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1068
    have p0: "poly [0] = poly []" by (rule ext, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1069
    {assume dp: "degree p = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1070
      then obtain k where "pnormalize p = [k]" using pe poly_normalize[of p]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1071
	unfolding degree_def by (cases "pnormalize p", auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1072
      hence k: "pnormalize p = [k]" "poly p = poly [k]" "k\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1073
	using pe poly_normalize[of p] by (auto simp add: p0)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1074
      hence th1: "\<forall>x. poly p x \<noteq> 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1075
      from k(2,3) dp have "poly (pexp q (degree p)) = poly (pmult p [1/k]) "
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1076
	by - (rule ext, simp add: poly_mult poly_exp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1077
      hence th2: "p divides (pexp q (degree p))" unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1078
      from th1 th2 pe have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1079
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1080
    {assume dp: "degree p \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1081
      then obtain n where n: "degree p = Suc n " by (cases "degree p", auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1082
      {assume "p divides (pexp q (Suc n))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1083
	then obtain u where u: "poly (pexp q (Suc n)) = poly (pmult p u)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1084
	  unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1085
	hence u' :"\<And>x. poly (pexp q (Suc n)) x = poly (pmult p u) x" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1086
	{fix x assume h: "poly p x = 0" "poly q x \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1087
	  hence "poly (pexp q (Suc n)) x \<noteq> 0" by (simp only: poly_exp) simp	  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1088
	  hence False using u' h(1) by (simp only: poly_mult poly_exp) simp}}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1089
	with n nullstellensatz_lemma[of p q "degree p"] dp 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1090
	have ?thesis by auto}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1091
    ultimately have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1092
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1093
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1094
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1095
text{* Useful lemma *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1096
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1097
lemma (in idom_char_0) constant_degree: "constant (poly p) \<longleftrightarrow> degree p = 0" (is "?lhs = ?rhs")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1098
proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1099
  assume l: ?lhs
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1100
  from l[unfolded constant_def, rule_format, of _ "zero"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1101
  have th: "poly p = poly [poly p 0]" apply - by (rule ext, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1102
  from degree_unique[OF th] show ?rhs by (simp add: degree_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1103
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1104
  assume r: ?rhs
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1105
  from r have "pnormalize p = [] \<or> (\<exists>k. pnormalize p = [k])"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1106
    unfolding degree_def by (cases "pnormalize p", auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1107
  then show ?lhs unfolding constant_def poly_normalize[of p, symmetric]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1108
    by (auto simp del: poly_normalize)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1109
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1110
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1111
(* It would be nicer to prove this without using algebraic closure...        *)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1112
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1113
lemma divides_degree_lemma: assumes dpn: "degree (p::complex list) = n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1114
  shows "n \<le> degree (p *** q) \<or> poly (p *** q) = poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1115
  using dpn
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1116
proof(induct n arbitrary: p q)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1117
  case 0 thus ?case by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1118
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1119
  case (Suc n p q)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1120
  from Suc.prems fundamental_theorem_of_algebra[of p] constant_degree[of p]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1121
  obtain a where a: "poly p a = 0" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1122
  then obtain r where r: "p = pmult [-a, 1] r" unfolding poly_linear_divides
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1123
    using Suc.prems by (auto simp add: degree_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1124
  {assume h: "poly (pmult r q) = poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1125
    hence "poly (pmult p q) = poly []" using r
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1126
      apply - apply (rule ext)  by (auto simp add: poly_entire poly_mult poly_add poly_cmult) hence ?case by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1127
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1128
  {assume h: "poly (pmult r q) \<noteq> poly []" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1129
    hence r0: "poly r \<noteq> poly []" and q0: "poly q \<noteq> poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1130
      by (auto simp add: poly_entire)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1131
    have eq: "poly (pmult p q) = poly (pmult [-a, 1] (pmult r q))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1132
      apply - apply (rule ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1133
      by (simp add: r poly_mult poly_add poly_cmult ring_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1134
    from linear_mul_degree[OF h, of "- a"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1135
    have dqe: "degree (pmult p q) = degree (pmult r q) + 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1136
      unfolding degree_unique[OF eq] .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1137
    from linear_mul_degree[OF r0, of "- a", unfolded r[symmetric]] r Suc.prems 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1138
    have dr: "degree r = n" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1139
    from  Suc.hyps[OF dr, of q] have "Suc n \<le> degree (pmult p q)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1140
      unfolding dqe using h by (auto simp del: poly.simps) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1141
    hence ?case by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1142
  ultimately show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1143
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1144
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1145
lemma divides_degree: assumes pq: "p divides (q:: complex list)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1146
  shows "degree p \<le> degree q \<or> poly q = poly []"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1147
using pq  divides_degree_lemma[OF refl, of p]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1148
apply (auto simp add: divides_def poly_entire)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1149
apply atomize
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1150
apply (erule_tac x="qa" in allE, auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1151
apply (subgoal_tac "degree q = degree (p *** qa)", simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1152
apply (rule degree_unique, simp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1153
done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1154
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1155
(* Arithmetic operations on multivariate polynomials.                        *)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1156
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1157
lemma mpoly_base_conv: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1158
  "(0::complex) \<equiv> poly [] x" "c \<equiv> poly [c] x" "x \<equiv> poly [0,1] x" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1159
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1160
lemma mpoly_norm_conv: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1161
  "poly [0] (x::complex) \<equiv> poly [] x" "poly [poly [] y] x \<equiv> poly [] x" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1162
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1163
lemma mpoly_sub_conv: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1164
  "poly p (x::complex) - poly q x \<equiv> poly p x + -1 * poly q x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1165
  by (simp add: diff_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1166
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1167
lemma poly_pad_rule: "poly p x = 0 ==> poly (0#p) x = (0::complex)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1168
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1169
lemma poly_cancel_eq_conv: "p = (0::complex) \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> (q = 0) \<equiv> (a * q - b * p = 0)" apply (atomize (full)) by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1170
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1171
lemma resolve_eq_raw:  "poly [] x \<equiv> 0" "poly [c] x \<equiv> (c::complex)" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1172
lemma  resolve_eq_then: "(P \<Longrightarrow> (Q \<equiv> Q1)) \<Longrightarrow> (\<not>P \<Longrightarrow> (Q \<equiv> Q2))
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1173
  \<Longrightarrow> Q \<equiv> P \<and> Q1 \<or> \<not>P\<and> Q2" apply (atomize (full)) by blast 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1174
lemma expand_ex_beta_conv: "list_ex P [c] \<equiv> P c" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1175
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1176
lemma poly_divides_pad_rule: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1177
  fixes p q :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1178
  assumes pq: "p divides q"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1179
  shows "p divides ((0::complex)#q)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1180
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1181
  from pq obtain r where r: "poly q = poly (p *** r)" unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1182
  hence "poly (0#q) = poly (p *** ([0,1] *** r))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1183
    by - (rule ext, simp add: poly_mult poly_cmult poly_add)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1184
  thus ?thesis unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1185
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1186
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1187
lemma poly_divides_pad_const_rule: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1188
  fixes p q :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1189
  assumes pq: "p divides q"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1190
  shows "p divides (a %* q)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1191
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1192
  from pq obtain r where r: "poly q = poly (p *** r)" unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1193
  hence "poly (a %* q) = poly (p *** (a %* r))" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1194
    by - (rule ext, simp add: poly_mult poly_cmult poly_add)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1195
  thus ?thesis unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1196
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1197
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1198
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1199
lemma poly_divides_conv0:  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1200
  fixes p :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1201
  assumes lgpq: "length q < length p" and lq:"last p \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1202
  shows "p divides q \<equiv> (\<not> (list_ex (\<lambda>c. c \<noteq> 0) q))" (is "?lhs \<equiv> ?rhs")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1203
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1204
  {assume r: ?rhs 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1205
    hence eq: "poly q = poly []" unfolding poly_zero 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1206
      by (simp add: list_all_iff list_ex_iff)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1207
    hence "poly q = poly (p *** [])" by - (rule ext, simp add: poly_mult)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1208
    hence ?lhs unfolding divides_def  by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1209
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1210
  {assume l: ?lhs
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1211
    have ath: "\<And>lq lp dq::nat. lq < lp ==> lq \<noteq> 0 \<Longrightarrow> dq <= lq - 1 ==> dq < lp - 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1212
      by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1213
    {assume q0: "length q = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1214
      hence "q = []" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1215
      hence ?rhs by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1216
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1217
    {assume lgq0: "length q \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1218
      from pnormalize_length[of q] have dql: "degree q \<le> length q - 1" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1219
	unfolding degree_def by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1220
      from ath[OF lgpq lgq0 dql, unfolded pnormal_degree[OF lq, symmetric]] divides_degree[OF l] have "poly q = poly []" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1221
      hence ?rhs unfolding poly_zero by (simp add: list_all_iff list_ex_iff)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1222
    ultimately have ?rhs by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1223
  ultimately show "?lhs \<equiv> ?rhs" by - (atomize (full), blast) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1224
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1225
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1226
lemma poly_divides_conv1: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1227
  assumes a0: "a\<noteq> (0::complex)" and pp': "(p::complex list) divides p'"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1228
  and qrp': "\<And>x. a * poly q x - poly p' x \<equiv> poly r x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1229
  shows "p divides q \<equiv> p divides (r::complex list)" (is "?lhs \<equiv> ?rhs")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1230
proof-
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
  from pp' obtain t where t: "poly p' = poly (p *** t)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1233
    unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1234
  {assume l: ?lhs
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1235
    then obtain u where u: "poly q = poly (p *** u)" unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1236
     have "poly r = poly (p *** ((a %* u) +++ (-- t)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1237
       using u qrp' t
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1238
       by - (rule ext, 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1239
	 simp add: poly_add poly_mult poly_cmult poly_minus ring_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1240
     then have ?rhs unfolding divides_def by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1241
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1242
  {assume r: ?rhs
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1243
    then obtain u where u: "poly r = poly (p *** u)" unfolding divides_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1244
    from u t qrp' a0 have "poly q = poly (p *** ((1/a) %* (u +++ t)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1245
      by - (rule ext, atomize (full), simp add: poly_mult poly_add poly_cmult field_simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1246
    hence ?lhs  unfolding divides_def by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1247
  ultimately have "?lhs = ?rhs" by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1248
thus "?lhs \<equiv> ?rhs"  by - (atomize(full), blast) 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1249
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1250
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1251
lemma basic_cqe_conv1:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1252
  "(\<exists>x. poly p x = 0 \<and> poly [] x \<noteq> 0) \<equiv> False"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1253
  "(\<exists>x. poly [] x \<noteq> 0) \<equiv> False"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1254
  "(\<exists>x. poly [c] x \<noteq> 0) \<equiv> c\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1255
  "(\<exists>x. poly [] x = 0) \<equiv> True"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1256
  "(\<exists>x. poly [c] x = 0) \<equiv> c = 0" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1257
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1258
lemma basic_cqe_conv2: 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1259
  assumes l:"last (a#b#p) \<noteq> 0" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1260
  shows "(\<exists>x. poly (a#b#p) x = (0::complex)) \<equiv> True"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1261
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1262
  {fix h t
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1263
    assume h: "h\<noteq>0" "list_all (\<lambda>c. c=(0::complex)) t"  "a#b#p = h#t"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1264
    hence "list_all (\<lambda>c. c= 0) (b#p)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1265
    moreover have "last (b#p) \<in> set (b#p)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1266
    ultimately have "last (b#p) = 0" by (simp add: list_all_iff)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1267
    with l have False by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1268
  hence th: "\<not> (\<exists> h t. h\<noteq>0 \<and> list_all (\<lambda>c. c=0) t \<and> a#b#p = h#t)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1269
    by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1270
  from fundamental_theorem_of_algebra_alt[OF th] 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1271
  show "(\<exists>x. poly (a#b#p) x = (0::complex)) \<equiv> True" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1272
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1273
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1274
lemma  basic_cqe_conv_2b: "(\<exists>x. poly p x \<noteq> (0::complex)) \<equiv> (list_ex (\<lambda>c. c \<noteq> 0) p)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1275
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1276
  have "\<not> (list_ex (\<lambda>c. c \<noteq> 0) p) \<longleftrightarrow> poly p = poly []" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1277
    by (simp add: poly_zero list_all_iff list_ex_iff)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1278
  also have "\<dots> \<longleftrightarrow> (\<not> (\<exists>x. poly p x \<noteq> 0))" by (auto intro: ext)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1279
  finally show "(\<exists>x. poly p x \<noteq> (0::complex)) \<equiv> (list_ex (\<lambda>c. c \<noteq> 0) p)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1280
    by - (atomize (full), blast)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1281
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1282
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1283
lemma basic_cqe_conv3:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1284
  fixes p q :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1285
  assumes l: "last (a#p) \<noteq> 0" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1286
  shows "(\<exists>x. poly (a#p) x =0 \<and> poly q x \<noteq> 0) \<equiv> \<not> ((a#p) divides (q %^ (length p)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1287
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1288
  note np = pnormalize_eq[OF l]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1289
  {assume "poly (a#p) = poly []" hence False using l
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1290
      unfolding poly_zero apply (auto simp add: list_all_iff del: last.simps)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1291
      apply (cases p, simp_all) done}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1292
  then have p0: "poly (a#p) \<noteq> poly []"  by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1293
  from np have dp:"degree (a#p) = length p" by (simp add: degree_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1294
  from nullstellensatz_univariate[of "a#p" q] p0 dp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1295
  show "(\<exists>x. poly (a#p) x =0 \<and> poly q x \<noteq> 0) \<equiv> \<not> ((a#p) divides (q %^ (length p)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1296
    by - (atomize (full), auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1297
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1298
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1299
lemma basic_cqe_conv4:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1300
  fixes p q :: "complex list"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1301
  assumes h: "\<And>x. poly (q %^ n) x \<equiv> poly r x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1302
  shows "p divides (q %^ n) \<equiv> p divides r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1303
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1304
  from h have "poly (q %^ n) = poly r" by (auto intro: ext)  
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1305
  thus "p divides (q %^ n) \<equiv> p divides r" unfolding divides_def by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1306
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1307
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1308
lemma pmult_Cons_Cons: "((a::complex)#b#p) *** q = (a %*q) +++ (0#((b#p) *** q))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1309
  by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1310
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1311
lemma elim_neg_conv: "- z \<equiv> (-1) * (z::complex)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1312
lemma eqT_intr: "PROP P \<Longrightarrow> (True \<Longrightarrow> PROP P )" "PROP P \<Longrightarrow> True" by blast+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1313
lemma negate_negate_rule: "Trueprop P \<equiv> \<not> P \<equiv> False" by (atomize (full), auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1314
lemma last_simps: "last [x] = x" "last (x#y#ys) = last (y#ys)" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1315
lemma length_simps: "length [] = 0" "length (x#y#xs) = length xs + 2" "length [x] = 1" by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1316
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1317
lemma complex_entire: "(z::complex) \<noteq> 0 \<and> w \<noteq> 0 \<equiv> z*w \<noteq> 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1318
lemma resolve_eq_ne: "(P \<equiv> True) \<equiv> (\<not>P \<equiv> False)" "(P \<equiv> False) \<equiv> (\<not>P \<equiv> True)" 
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1319
  by (atomize (full)) simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1320
lemma cqe_conv1: "poly [] x = 0 \<longleftrightarrow> True"  by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1321
lemma cqe_conv2: "(p \<Longrightarrow> (q \<equiv> r)) \<equiv> ((p \<and> q) \<equiv> (p \<and> r))"  (is "?l \<equiv> ?r")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1322
proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1323
  assume "p \<Longrightarrow> q \<equiv> r" thus "p \<and> q \<equiv> p \<and> r" apply - apply (atomize (full)) by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1324
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1325
  assume "p \<and> q \<equiv> p \<and> r" "p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1326
  thus "q \<equiv> r" apply - apply (atomize (full)) apply blast done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1327
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1328
lemma poly_const_conv: "poly [c] (x::complex) = y \<longleftrightarrow> c = y" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1329
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1330
end