src/HOL/Library/Fundamental_Theorem_Algebra.thy
author nipkow
Mon, 31 Aug 2009 14:09:42 +0200
changeset 32456 341c83339aeb
parent 31337 a9ed5fcc5e39
child 32960 69916a850301
permissions -rw-r--r--
tuned the simp rules for Int involving insert and intervals.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29197
6d4cb27ed19c adapted HOL source structure to distribution layout
haftmann
parents: 28952
diff changeset
     1
(* Author: Amine Chaieb, TU Muenchen *)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     2
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     3
header{*Fundamental Theorem of Algebra*}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     4
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     5
theory Fundamental_Theorem_Algebra
29811
026b0f9f579f fixed Proofs and dependencies ; Theory Dense_Linear_Order moved to Library
chaieb@chaieb-laptop
parents: 29667
diff changeset
     6
imports Polynomial Complex
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     7
begin
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
     8
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
     9
subsection {* Square root of complex numbers *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    10
definition csqrt :: "complex \<Rightarrow> complex" where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    11
"csqrt z = (if Im z = 0 then
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    12
            if 0 \<le> Re z then Complex (sqrt(Re z)) 0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    13
            else Complex 0 (sqrt(- Re z))
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    14
           else Complex (sqrt((cmod z + Re z) /2))
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    15
                        ((Im z / abs(Im z)) * sqrt((cmod z - Re z) /2)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    16
27668
6eb20b2cecf8 Tuned and simplified proofs
chaieb
parents: 27514
diff changeset
    17
lemma csqrt[algebra]: "csqrt z ^ 2 = z"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    18
proof-
29292
11045b88af1a avoid implicit prems -- tuned proofs;
wenzelm
parents: 29197
diff changeset
    19
  obtain x y where xy: "z = Complex x y" by (cases z)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    20
  {assume y0: "y = 0"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    21
    {assume x0: "x \<ge> 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    22
      then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    23
	by (simp add: csqrt_def power2_eq_square)}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    24
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    25
    {assume "\<not> x \<ge> 0" hence x0: "- x \<ge> 0" by arith
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    26
      then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    27
	by (simp add: csqrt_def power2_eq_square) }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    28
    ultimately have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    29
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    30
  {assume y0: "y\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    31
    {fix x y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    32
      let ?z = "Complex x y"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    33
      from abs_Re_le_cmod[of ?z] have tha: "abs x \<le> cmod ?z" by auto
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    34
      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
    35
      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
    36
    note th = this
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    37
    have sq4: "\<And>x::real. x^2 / 4 = (x / 2) ^ 2"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    38
      by (simp add: power2_eq_square)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    39
    from th[of x y]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    40
    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
    41
    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"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    42
      unfolding power2_eq_square by simp
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    43
    have "sqrt 4 = sqrt (2^2)" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    44
    hence sqrt4: "sqrt 4 = 2" by (simp only: real_sqrt_abs)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    45
    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
    46
      using iffD2[OF real_sqrt_pow2_iff sum_power2_ge_zero[of x y]] y0
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    47
      unfolding power2_eq_square
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
    48
      by (simp add: algebra_simps real_sqrt_divide sqrt4)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    49
     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
    50
       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
    51
      using th1 th2  ..}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    52
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    53
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    54
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    55
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
    56
subsection{* More lemmas about module of complex numbers *}
26123
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
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
    59
  by (rule of_real_power [symmetric])
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 real_down2: "(0::real) < d1 \<Longrightarrow> 0 < d2 ==> EX e. 0 < e & e < d1 & e < d2"
29811
026b0f9f579f fixed Proofs and dependencies ; Theory Dense_Linear_Order moved to Library
chaieb@chaieb-laptop
parents: 29667
diff changeset
    62
  apply (rule exI[where x = "min d1 d2 / 2"])
026b0f9f579f fixed Proofs and dependencies ; Theory Dense_Linear_Order moved to Library
chaieb@chaieb-laptop
parents: 29667
diff changeset
    63
  by (simp add: field_simps min_def)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    64
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    65
text{* The triangle inequality for cmod *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    66
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
    67
  using complex_mod_triangle_ineq2[of "w + z" "-z"] by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    68
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
    69
subsection{* Basic lemmas about complex polynomials *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    70
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    71
lemma poly_bound_exists:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    72
  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
    73
proof(induct p)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
    74
  case 0 thus ?case by (rule exI[where x=1], simp)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    75
next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    76
  case (pCons c cs)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    77
  from pCons.hyps obtain m where m: "\<forall>z. cmod z \<le> r \<longrightarrow> cmod (poly cs z) \<le> m"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    78
    by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    79
  let ?k = " 1 + cmod c + \<bar>r * m\<bar>"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    80
  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
    81
  {fix z
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    82
    assume H: "cmod z \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    83
    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
    84
    from H have rp: "r \<ge> 0" using norm_ge_zero[of z] by arith
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    85
    have "cmod (poly (pCons c cs) z) \<le> cmod c + cmod (z* poly cs z)"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    86
      using norm_triangle_ineq[of c "z* poly cs z"] by simp
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
    87
    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
    88
    also have "\<dots> \<le> ?k" by simp
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    89
    finally have "cmod (poly (pCons c cs) z) \<le> ?k" .}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    90
  with kp show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    91
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    92
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    93
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
    94
text{* Offsetting the variable in a polynomial gives another of same degree *}
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    95
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    96
definition
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    97
  "offset_poly p h = poly_rec 0 (\<lambda>a p q. smult h q + pCons a q) p"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    98
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
    99
lemma offset_poly_0: "offset_poly 0 h = 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   100
  unfolding offset_poly_def by (simp add: poly_rec_0)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   101
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   102
lemma offset_poly_pCons:
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   103
  "offset_poly (pCons a p) h =
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   104
    smult h (offset_poly p h) + pCons a (offset_poly p h)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   105
  unfolding offset_poly_def by (simp add: poly_rec_pCons)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   106
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   107
lemma offset_poly_single: "offset_poly [:a:] h = [:a:]"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   108
by (simp add: offset_poly_pCons offset_poly_0)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   109
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   110
lemma poly_offset_poly: "poly (offset_poly p h) x = poly p (h + x)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   111
apply (induct p)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   112
apply (simp add: offset_poly_0)
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   113
apply (simp add: offset_poly_pCons algebra_simps)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   114
done
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   115
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   116
lemma offset_poly_eq_0_lemma: "smult c p + pCons a p = 0 \<Longrightarrow> p = 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   117
by (induct p arbitrary: a, simp, force)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   118
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   119
lemma offset_poly_eq_0_iff: "offset_poly p h = 0 \<longleftrightarrow> p = 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   120
apply (safe intro!: offset_poly_0)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   121
apply (induct p, simp)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   122
apply (simp add: offset_poly_pCons)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   123
apply (frule offset_poly_eq_0_lemma, simp)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   124
done
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   125
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   126
lemma degree_offset_poly: "degree (offset_poly p h) = degree p"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   127
apply (induct p)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   128
apply (simp add: offset_poly_0)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   129
apply (case_tac "p = 0")
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   130
apply (simp add: offset_poly_0 offset_poly_pCons)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   131
apply (simp add: offset_poly_pCons)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   132
apply (subst degree_add_eq_right)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   133
apply (rule le_less_trans [OF degree_smult_le])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   134
apply (simp add: offset_poly_eq_0_iff)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   135
apply (simp add: offset_poly_eq_0_iff)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   136
done
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   137
29478
4a2482e16934 code generation for polynomials
huffman
parents: 29476
diff changeset
   138
definition
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   139
  "psize p = (if p = 0 then 0 else Suc (degree p))"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   140
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   141
lemma psize_eq_0_iff [simp]: "psize p = 0 \<longleftrightarrow> p = 0"
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   142
  unfolding psize_def by simp
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   143
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   144
lemma poly_offset: "\<exists> q. psize q = psize p \<and> (\<forall>x. poly q (x::complex) = poly p (a + x))"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   145
proof (intro exI conjI)
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   146
  show "psize (offset_poly p a) = psize p"
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   147
    unfolding psize_def
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   148
    by (simp add: offset_poly_eq_0_iff degree_offset_poly)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   149
  show "\<forall>x. poly (offset_poly p a) x = poly p (a + x)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   150
    by (simp add: poly_offset_poly)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   151
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   152
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   153
text{* An alternative useful formulation of completeness of the reals *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   154
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
   155
  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
   156
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   157
  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
   158
  from ex have thx:"\<exists>x. x \<in> Collect P" by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   159
  from bz have thY: "\<exists>Y. isUb UNIV (Collect P) Y"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   160
    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
   161
  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
   162
    by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   163
  from Y[OF x] have xY: "x < Y" .
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   164
  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)
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   165
  from Y have Y': "\<forall>x. P x \<longrightarrow> x \<le> Y"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   166
    apply (clarsimp, atomize (full)) by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   167
  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
   168
  {fix y
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   169
    {fix z assume z: "P z" "y < z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   170
      from L' z have "y < L" by auto }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   171
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   172
    {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
   173
      hence nox: "\<forall>z. P z \<longrightarrow> y \<ge> z" by auto
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   174
      from nox L have "y \<ge> L" by (auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   175
      with yL(1) have False  by arith}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   176
    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
   177
  thus ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   178
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   179
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
   180
subsection {* Fundamental theorem of algebra *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   181
lemma  unimodular_reduce_norm:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   182
  assumes md: "cmod z = 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   183
  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
   184
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   185
  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
   186
  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
   187
  {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
   188
    from C z xy have "2*x \<le> 1" "2*x \<ge> -1" "2*y \<le> 1" "2*y \<ge> -1"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   189
      by (simp_all add: cmod_def power2_eq_square algebra_simps)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   190
    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
   191
    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
   192
      by - (rule power_mono, simp, simp)+
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   193
    hence th0: "4*x^2 \<le> 1" "4*y^2 \<le> 1"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   194
      by (simp_all  add: power2_abs power_mult_distrib)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   195
    from add_mono[OF th0] xy have False by simp }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   196
  thus ?thesis unfolding linorder_not_le[symmetric] by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   197
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   198
26135
01f4e5d21eaf fixed document;
wenzelm
parents: 26123
diff changeset
   199
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
   200
lemma reduce_poly_simple:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   201
 assumes b: "b \<noteq> 0" and n: "n\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   202
  shows "\<exists>z. cmod (1 + b * z^n) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   203
using n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   204
proof(induct n rule: nat_less_induct)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   205
  fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   206
  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
   207
  let ?P = "\<lambda>z n. cmod (1 + b * z ^ n) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   208
  {assume e: "even n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   209
    hence "\<exists>m. n = 2*m" by presburger
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   210
    then obtain m where m: "n = 2*m" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   211
    from n m have "m\<noteq>0" "m < n" by presburger+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   212
    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
   213
    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
   214
    hence "\<exists>z. ?P z n" ..}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   215
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   216
  {assume o: "odd n"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   217
    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
   218
    have "Im (inverse b) * (Im (inverse b) * \<bar>Im b * Im b + Re b * Re b\<bar>) +
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   219
    Re (inverse b) * (Re (inverse b) * \<bar>Im b * Im b + Re b * Re b\<bar>) =
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   220
    ((Re (inverse b))^2 + (Im (inverse b))^2) * \<bar>Im b * Im b + Re b * Re b\<bar>" by algebra
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   221
    also have "\<dots> = cmod (inverse b) ^2 * cmod b ^ 2"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   222
      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
   223
      by (simp add: power2_eq_square)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   224
    finally
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   225
    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
   226
    Re (inverse b) * (Re (inverse b) * \<bar>Im b * Im b + Re b * Re b\<bar>) =
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   227
    1"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   228
      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
   229
      using right_inverse[OF b']
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   230
      by (simp add: power2_eq_square[symmetric] power_inverse[symmetric] algebra_simps)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   231
    have th0: "cmod (complex_of_real (cmod b) / b) = 1"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   232
      apply (simp add: complex_Re_mult cmod_def power2_eq_square Re_complex_of_real Im_complex_of_real divide_inverse algebra_simps )
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   233
      by (simp add: real_sqrt_mult[symmetric] th0)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   234
    from o have "\<exists>m. n = Suc (2*m)" by presburger+
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   235
    then obtain m where m: "n = Suc (2*m)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   236
    from unimodular_reduce_norm[OF th0] o
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   237
    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
   238
      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
   239
      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
   240
      apply (cases "cmod (complex_of_real (cmod b) / b + ii) < 1")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   241
      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
   242
      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
   243
      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
   244
      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
   245
      done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   246
    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
   247
    let ?w = "v / complex_of_real (root n (cmod b))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   248
    from odd_real_root_pow[OF o, of "cmod b"]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   249
    have th1: "?w ^ n = v^n / complex_of_real (cmod b)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   250
      by (simp add: power_divide complex_of_real_power)
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   251
    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
   252
    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
   253
    have th4: "cmod (complex_of_real (cmod b) / b) *
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   254
   cmod (1 + b * (v ^ n / complex_of_real (cmod b)))
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   255
   < cmod (complex_of_real (cmod b) / b) * 1"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   256
      apply (simp only: norm_mult[symmetric] right_distrib)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   257
      using b v by (simp add: th2)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   258
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   259
    from mult_less_imp_less_left[OF th4 th3]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   260
    have "?P ?w n" unfolding th1 .
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   261
    hence "\<exists>z. ?P z n" .. }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   262
  ultimately show "\<exists>z. ?P z n" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   263
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   264
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   265
text{* Bolzano-Weierstrass type property for closed disc in complex plane. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   266
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   267
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
   268
  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
   269
  unfolding cmod_def by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   270
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   271
lemma bolzano_weierstrass_complex_disc:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   272
  assumes r: "\<forall>n. cmod (s n) \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   273
  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
   274
proof-
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   275
  from seq_monosub[of "Re o s"]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   276
  obtain f g where f: "subseq f" "monoseq (\<lambda>n. Re (s (f n)))"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   277
    unfolding o_def by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   278
  from seq_monosub[of "Im o s o f"]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   279
  obtain g where g: "subseq g" "monoseq (\<lambda>n. Im (s(f(g n))))" unfolding o_def by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   280
  let ?h = "f o g"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   281
  from r[rule_format, of 0] have rp: "r \<ge> 0" using norm_ge_zero[of "s 0"] by arith
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   282
  have th:"\<forall>n. r + 1 \<ge> \<bar> Re (s n)\<bar>"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   283
  proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   284
    fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   285
    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
   286
  qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   287
  have conv1: "convergent (\<lambda>n. Re (s ( f n)))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   288
    apply (rule Bseq_monoseq_convergent)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   289
    apply (simp add: Bseq_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   290
    apply (rule exI[where x= "r + 1"])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   291
    using th rp apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   292
    using f(2) .
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   293
  have th:"\<forall>n. r + 1 \<ge> \<bar> Im (s n)\<bar>"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   294
  proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   295
    fix n
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   296
    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
   297
  qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   298
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   299
  have conv2: "convergent (\<lambda>n. Im (s (f (g n))))"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   300
    apply (rule Bseq_monoseq_convergent)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   301
    apply (simp add: Bseq_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   302
    apply (rule exI[where x= "r + 1"])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   303
    using th rp apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   304
    using g(2) .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   305
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   306
  from conv1[unfolded convergent_def] obtain x where "LIMSEQ (\<lambda>n. Re (s (f n))) x"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   307
    by blast
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   308
  hence  x: "\<forall>r>0. \<exists>n0. \<forall>n\<ge>n0. \<bar> Re (s (f n)) - x \<bar> < r"
31337
a9ed5fcc5e39 LIMSEQ_def -> LIMSEQ_iff
huffman
parents: 31021
diff changeset
   309
    unfolding LIMSEQ_iff real_norm_def .
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   310
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   311
  from conv2[unfolded convergent_def] obtain y where "LIMSEQ (\<lambda>n. Im (s (f (g n)))) y"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   312
    by blast
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   313
  hence  y: "\<forall>r>0. \<exists>n0. \<forall>n\<ge>n0. \<bar> Im (s (f (g n))) - y \<bar> < r"
31337
a9ed5fcc5e39 LIMSEQ_def -> LIMSEQ_iff
huffman
parents: 31021
diff changeset
   314
    unfolding LIMSEQ_iff real_norm_def .
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   315
  let ?w = "Complex x y"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   316
  from f(1) g(1) have hs: "subseq ?h" unfolding subseq_def by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   317
  {fix e assume ep: "e > (0::real)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   318
    hence e2: "e/2 > 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   319
    from x[rule_format, OF e2] y[rule_format, OF e2]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   320
    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
   321
    {fix n assume nN12: "n \<ge> N1 + N2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   322
      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
   323
      from add_strict_mono[OF N1[rule_format, OF nN1] N2[rule_format, OF nN2]]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   324
      have "cmod (s (?h n) - ?w) < e"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   325
	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
   326
    hence "\<exists>N. \<forall>n\<ge>N. cmod (s (?h n) - ?w) < e" by blast }
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   327
  with hs show ?thesis  by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   328
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   329
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   330
text{* Polynomial is continuous. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   331
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   332
lemma poly_cont:
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   333
  assumes ep: "e > 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   334
  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
   335
proof-
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   336
  obtain q where q: "degree q = degree p" "\<And>x. poly q x = poly p (z + x)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   337
  proof
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   338
    show "degree (offset_poly p z) = degree p"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   339
      by (rule degree_offset_poly)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   340
    show "\<And>x. poly (offset_poly p z) x = poly p (z + x)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   341
      by (rule poly_offset_poly)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   342
  qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   343
  {fix w
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   344
    note q(2)[of "w - z", simplified]}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   345
  note th = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   346
  show ?thesis unfolding th[symmetric]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   347
  proof(induct q)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   348
    case 0 thus ?case  using ep by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   349
  next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   350
    case (pCons c cs)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   351
    from poly_bound_exists[of 1 "cs"]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   352
    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
   353
    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
   354
    have one0: "1 > (0::real)"  by arith
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   355
    from real_lbound_gt_zero[OF one0 em0]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   356
    obtain d where d: "d >0" "d < 1" "d < e / m" by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   357
    from d(1,3) m(1) have dm: "d*m > 0" "d*m < e"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   358
      by (simp_all add: field_simps real_mult_order)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   359
    show ?case
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   360
      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
   361
	fix d w
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   362
	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
   363
	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
   364
	from H(3) m(1) have dme: "d*m < e" by (simp add: field_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   365
	from H have th: "cmod (w-z) \<le> d" by simp
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   366
	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
   367
	show "cmod (w - z) * cmod (poly cs (w - z)) < e" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   368
      qed
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   369
    qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   370
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   371
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   372
text{* Hence a polynomial attains minimum on a closed disc
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   373
  in the complex plane. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   374
lemma  poly_minimum_modulus_disc:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   375
  "\<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
   376
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   377
  {assume "\<not> r \<ge> 0" hence ?thesis unfolding linorder_not_le
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   378
      apply -
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   379
      apply (rule exI[where x=0])
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   380
      apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   381
      apply (subgoal_tac "cmod w < 0")
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   382
      apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   383
      apply arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   384
      done }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   385
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   386
  {assume rp: "r \<ge> 0"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   387
    from rp have "cmod 0 \<le> r \<and> cmod (poly p 0) = - (- cmod (poly p 0))" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   388
    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
   389
    {fix x z
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   390
      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
   391
      hence "- x < 0 " by arith
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   392
      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
   393
    then have mth2: "\<exists>z. \<forall>x. (\<exists>z. cmod z \<le> r \<and> cmod (poly p z) = - x) \<longrightarrow> x < z" by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   394
    from real_sup_exists[OF mth1 mth2] obtain s where
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   395
      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
   396
    let ?m = "-s"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   397
    {fix y
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   398
      from s[rule_format, of "-y"] have
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   399
    "(\<exists>z x. cmod z \<le> r \<and> -(- cmod (poly p z)) < y) \<longleftrightarrow> ?m < y"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   400
	unfolding minus_less_iff[of y ] equation_minus_iff by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   401
    note s1 = this[unfolded minus_minus]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   402
    from s1[of ?m] have s1m: "\<And>z x. cmod z \<le> r \<Longrightarrow> cmod (poly p z) \<ge> ?m"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   403
      by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   404
    {fix n::nat
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   405
      from s1[rule_format, of "?m + 1/real (Suc n)"]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   406
      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
   407
	by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   408
    hence th: "\<forall>n. \<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)" ..
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   409
    from choice[OF th] obtain g where
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   410
      g: "\<forall>n. cmod (g n) \<le> r" "\<forall>n. cmod (poly p (g n)) <?m+1 /real(Suc n)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   411
      by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   412
    from bolzano_weierstrass_complex_disc[OF g(1)]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   413
    obtain f z where fz: "subseq f" "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. cmod (g (f n) - z) < e"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   414
      by blast
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   415
    {fix w
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   416
      assume wr: "cmod w \<le> r"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   417
      let ?e = "\<bar>cmod (poly p z) - ?m\<bar>"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   418
      {assume e: "?e > 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   419
	hence e2: "?e/2 > 0" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   420
	from poly_cont[OF e2, of z p] obtain d where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   421
	  d: "d>0" "\<forall>w. 0<cmod (w - z)\<and> cmod(w - z) < d \<longrightarrow> cmod(poly p w - poly p z) < ?e/2" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   422
	{fix w assume w: "cmod (w - z) < d"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   423
	  have "cmod(poly p w - poly p z) < ?e / 2"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   424
	    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
   425
	note th1 = this
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   426
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   427
	from fz(2)[rule_format, OF d(1)] obtain N1 where
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   428
	  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
   429
	from reals_Archimedean2[of "2/?e"] obtain N2::nat where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   430
	  N2: "2/?e < real N2" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   431
	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
   432
	  using N1[rule_format, of "N1 + N2"] th1 by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   433
	{fix a b e2 m :: real
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   434
	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
   435
          ==> False" by arith}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   436
      note th0 = this
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   437
      have ath:
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   438
	"\<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
   439
      from s1m[OF g(1)[rule_format]]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   440
      have th31: "?m \<le> cmod(poly p (g (f (N1 + N2))))" .
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   441
      from seq_suble[OF fz(1), of "N1+N2"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   442
      have th00: "real (Suc (N1+N2)) \<le> real (Suc (f (N1+N2)))" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   443
      have th000: "0 \<le> (1::real)" "(1::real) \<le> 1" "real (Suc (N1+N2)) > 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   444
	using N2 by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   445
      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
   446
      from g(2)[rule_format, of "f (N1 + N2)"]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   447
      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
   448
      from order_less_le_trans[OF th01 th00]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   449
      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
   450
      from N2 have "2/?e < real (Suc (N1 + N2))" by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   451
      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
   452
      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
   453
      with ath[OF th31 th32]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   454
      have thc1:"\<bar>cmod(poly p (g (f (N1 + N2)))) - ?m\<bar>< ?e/2" by arith
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   455
      have ath2: "\<And>(a::real) b c m. \<bar>a - b\<bar> <= c ==> \<bar>b - m\<bar> <= \<bar>a - m\<bar> + c"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   456
	by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   457
      have th22: "\<bar>cmod (poly p (g (f (N1 + N2)))) - cmod (poly p z)\<bar>
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   458
\<le> cmod (poly p (g (f (N1 + N2))) - poly p z)"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   459
	by (simp add: norm_triangle_ineq3)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   460
      from ath2[OF th22, of ?m]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   461
      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
   462
      from th0[OF th2 thc1 thc2] have False .}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   463
      hence "?e = 0" by auto
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   464
      then have "cmod (poly p z) = ?m" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   465
      with s1m[OF wr]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   466
      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
   467
    hence ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   468
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   469
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   470
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   471
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
   472
  unfolding power2_eq_square
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   473
  apply (simp add: rcis_mult)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   474
  apply (simp add: power2_eq_square[symmetric])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   475
  done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   476
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   477
lemma cispi: "cis pi = -1"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   478
  unfolding cis_def
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   479
  by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   480
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   481
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
   482
  unfolding power2_eq_square
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   483
  apply (simp add: rcis_mult add_divide_distrib)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   484
  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
   485
  done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   486
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   487
text {* Nonzero polynomial in z goes to infinity as z does. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   488
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   489
lemma poly_infinity:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   490
  assumes ex: "p \<noteq> 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   491
  shows "\<exists>r. \<forall>z. r \<le> cmod z \<longrightarrow> d \<le> cmod (poly (pCons a p) z)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   492
using ex
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   493
proof(induct p arbitrary: a d)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   494
  case (pCons c cs a d)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   495
  {assume H: "cs \<noteq> 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   496
    with pCons.hyps obtain r where r: "\<forall>z. r \<le> cmod z \<longrightarrow> d + cmod a \<le> cmod (poly (pCons c cs) z)" by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   497
    let ?r = "1 + \<bar>r\<bar>"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   498
    {fix z assume h: "1 + \<bar>r\<bar> \<le> cmod z"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   499
      have r0: "r \<le> cmod z" using h by arith
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   500
      from r[rule_format, OF r0]
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   501
      have th0: "d + cmod a \<le> 1 * cmod(poly (pCons c cs) z)" by arith
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   502
      from h have z1: "cmod z \<ge> 1" by arith
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   503
      from order_trans[OF th0 mult_right_mono[OF z1 norm_ge_zero[of "poly (pCons c cs) z"]]]
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   504
      have th1: "d \<le> cmod(z * poly (pCons c cs) z) - cmod a"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   505
	unfolding norm_mult by (simp add: algebra_simps)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   506
      from complex_mod_triangle_sub[of "z * poly (pCons c cs) z" a]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   507
      have th2: "cmod(z * poly (pCons c cs) z) - cmod a \<le> cmod (poly (pCons a (pCons c cs)) z)"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   508
	by (simp add: diff_le_eq algebra_simps)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   509
      from th1 th2 have "d \<le> cmod (poly (pCons a (pCons c cs)) z)"  by arith}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   510
    hence ?case by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   511
  moreover
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   512
  {assume cs0: "\<not> (cs \<noteq> 0)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   513
    with pCons.prems have c0: "c \<noteq> 0" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   514
    from cs0 have cs0': "cs = 0" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   515
    {fix z
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   516
      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
   517
      from c0 have "cmod c > 0" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   518
      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
   519
	by (simp add: field_simps norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   520
      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
   521
      from complex_mod_triangle_sub[of "z*c" a ]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   522
      have th1: "cmod (z * c) \<le> cmod (a + z * c) + cmod a"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   523
	by (simp add: algebra_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   524
      from ath[OF th1 th0] have "d \<le> cmod (poly (pCons a (pCons c cs)) z)"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   525
        using cs0' by simp}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   526
    then have ?case  by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   527
  ultimately show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   528
qed simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   529
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   530
text {* Hence polynomial's modulus attains its minimum somewhere. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   531
lemma poly_minimum_modulus:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   532
  "\<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
   533
proof(induct p)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   534
  case (pCons c cs)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   535
  {assume cs0: "cs \<noteq> 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   536
    from poly_infinity[OF cs0, of "cmod (poly (pCons c cs) 0)" c]
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   537
    obtain r where r: "\<And>z. r \<le> cmod z \<Longrightarrow> cmod (poly (pCons c cs) 0) \<le> cmod (poly (pCons c cs) z)" by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   538
    have ath: "\<And>z r. r \<le> cmod z \<or> cmod z \<le> \<bar>r\<bar>" by arith
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   539
    from poly_minimum_modulus_disc[of "\<bar>r\<bar>" "pCons c cs"]
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   540
    obtain v where v: "\<And>w. cmod w \<le> \<bar>r\<bar> \<Longrightarrow> cmod (poly (pCons c cs) v) \<le> cmod (poly (pCons c cs) w)" by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   541
    {fix z assume z: "r \<le> cmod z"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   542
      from v[of 0] r[OF z]
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   543
      have "cmod (poly (pCons c cs) v) \<le> cmod (poly (pCons c cs) z)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   544
	by simp }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   545
    note v0 = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   546
    from v0 v ath[of r] have ?case by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   547
  moreover
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   548
  {assume cs0: "\<not> (cs \<noteq> 0)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   549
    hence th:"cs = 0" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   550
    from th pCons.hyps have ?case by simp}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   551
  ultimately show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   552
qed simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   553
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   554
text{* Constant function (non-syntactic characterization). *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   555
definition "constant f = (\<forall>x y. f x = f y)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   556
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   557
lemma nonconstant_length: "\<not> (constant (poly p)) \<Longrightarrow> psize p \<ge> 2"
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   558
  unfolding constant_def psize_def
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   559
  apply (induct p, auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   560
  done
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   561
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   562
lemma poly_replicate_append:
31021
53642251a04f farewell to class recpower
haftmann
parents: 30488
diff changeset
   563
  "poly (monom 1 n * p) (x::'a::{comm_ring_1}) = x^n * poly p x"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   564
  by (simp add: poly_monom)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   565
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   566
text {* Decomposition of polynomial, skipping zero coefficients
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   567
  after the first.  *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   568
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   569
lemma poly_decompose_lemma:
31021
53642251a04f farewell to class recpower
haftmann
parents: 30488
diff changeset
   570
 assumes nz: "\<not>(\<forall>z. z\<noteq>0 \<longrightarrow> poly p z = (0::'a::{idom}))"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   571
  shows "\<exists>k a q. a\<noteq>0 \<and> Suc (psize q + k) = psize p \<and>
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   572
                 (\<forall>z. poly p z = z^k * poly (pCons a q) z)"
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   573
unfolding psize_def
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   574
using nz
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   575
proof(induct p)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   576
  case 0 thus ?case by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   577
next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   578
  case (pCons c cs)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   579
  {assume c0: "c = 0"
32456
341c83339aeb tuned the simp rules for Int involving insert and intervals.
nipkow
parents: 31337
diff changeset
   580
    from pCons.hyps pCons.prems c0 have ?case
341c83339aeb tuned the simp rules for Int involving insert and intervals.
nipkow
parents: 31337
diff changeset
   581
      apply (auto)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   582
      apply (rule_tac x="k+1" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   583
      apply (rule_tac x="a" in exI, clarsimp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   584
      apply (rule_tac x="q" in exI)
32456
341c83339aeb tuned the simp rules for Int involving insert and intervals.
nipkow
parents: 31337
diff changeset
   585
      by (auto)}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   586
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   587
  {assume c0: "c\<noteq>0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   588
    hence ?case apply-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   589
      apply (rule exI[where x=0])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   590
      apply (rule exI[where x=c], clarsimp)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   591
      apply (rule exI[where x=cs])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   592
      apply auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   593
      done}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   594
  ultimately show ?case by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   595
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   596
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   597
lemma poly_decompose:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   598
  assumes nc: "~constant(poly p)"
31021
53642251a04f farewell to class recpower
haftmann
parents: 30488
diff changeset
   599
  shows "\<exists>k a q. a\<noteq>(0::'a::{idom}) \<and> k\<noteq>0 \<and>
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   600
               psize q + k + 1 = psize p \<and>
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   601
              (\<forall>z. poly p z = poly p 0 + z^k * poly (pCons a q) z)"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   602
using nc
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   603
proof(induct p)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   604
  case 0 thus ?case by (simp add: constant_def)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   605
next
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   606
  case (pCons c cs)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   607
  {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
   608
    {fix x y
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   609
      from C have "poly (pCons c cs) x = poly (pCons c cs) y" by (cases "x=0", auto)}
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   610
    with pCons.prems have False by (auto simp add: constant_def)}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   611
  hence th: "\<not> (\<forall>z. z \<noteq> 0 \<longrightarrow> poly cs z = 0)" ..
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   612
  from poly_decompose_lemma[OF th]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   613
  show ?case
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   614
    apply clarsimp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   615
    apply (rule_tac x="k+1" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   616
    apply (rule_tac x="a" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   617
    apply simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   618
    apply (rule_tac x="q" in exI)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   619
    apply (auto simp add: power_Suc)
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   620
    apply (auto simp add: psize_def split: if_splits)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   621
    done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   622
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   623
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   624
text{* Fundamental theorem of algebral *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   625
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   626
lemma fundamental_theorem_of_algebra:
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   627
  assumes nc: "~constant(poly p)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   628
  shows "\<exists>z::complex. poly p z = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   629
using nc
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   630
proof(induct n\<equiv> "psize p" arbitrary: p rule: nat_less_induct)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   631
  fix n fix p :: "complex poly"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   632
  let ?p = "poly p"
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   633
  assume H: "\<forall>m<n. \<forall>p. \<not> constant (poly p) \<longrightarrow> m = psize p \<longrightarrow> (\<exists>(z::complex). poly p z = 0)" and nc: "\<not> constant ?p" and n: "n = psize p"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   634
  let ?ths = "\<exists>z. ?p z = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   635
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   636
  from nonconstant_length[OF nc] have n2: "n\<ge> 2" by (simp add: n)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   637
  from poly_minimum_modulus obtain c where
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   638
    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
   639
  {assume pc: "?p c = 0" hence ?ths by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   640
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   641
  {assume pc0: "?p c \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   642
    from poly_offset[of p c] obtain q where
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   643
      q: "psize q = psize p" "\<forall>x. poly q x = ?p (c+x)" by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   644
    {assume h: "constant (poly q)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   645
      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
   646
      {fix x y
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   647
	from th have "?p x = poly q (x - c)" by auto
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   648
	also have "\<dots> = poly q (y - c)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   649
	  using h unfolding constant_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   650
	also have "\<dots> = ?p y" using th by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   651
	finally have "?p x = ?p y" .}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   652
      with nc have False unfolding constant_def by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   653
    hence qnc: "\<not> constant (poly q)" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   654
    from q(2) have pqc0: "?p c = poly q 0" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   655
    from c pqc0 have cq0: "\<forall>w. cmod (poly q 0) \<le> cmod (?p w)" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   656
    let ?a0 = "poly q 0"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   657
    from pc0 pqc0 have a00: "?a0 \<noteq> 0" by simp
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   658
    from a00
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   659
    have qr: "\<forall>z. poly q z = poly (smult (inverse ?a0) q) z * ?a0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   660
      by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   661
    let ?r = "smult (inverse ?a0) q"
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   662
    have lgqr: "psize q = psize ?r"
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   663
      using a00 unfolding psize_def degree_def
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   664
      by (simp add: expand_poly_eq)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   665
    {assume h: "\<And>x y. poly ?r x = poly ?r y"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   666
      {fix x y
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   667
	from qr[rule_format, of x]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   668
	have "poly q x = poly ?r x * ?a0" by auto
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   669
	also have "\<dots> = poly ?r y * ?a0" using h by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   670
	also have "\<dots> = poly q y" using qr[rule_format, of y] by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   671
	finally have "poly q x = poly q y" .}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   672
      with qnc have False unfolding constant_def by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   673
    hence rnc: "\<not> constant (poly ?r)" unfolding constant_def by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   674
    from qr[rule_format, of 0] a00  have r01: "poly ?r 0 = 1" by auto
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   675
    {fix w
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   676
      have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w / ?a0) < 1"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   677
	using qr[rule_format, of w] a00 by (simp add: divide_inverse mult_ac)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   678
      also have "\<dots> \<longleftrightarrow> cmod (poly q w) < cmod ?a0"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   679
	using a00 unfolding norm_divide by (simp add: field_simps)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   680
      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
   681
    note mrmq_eq = this
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   682
    from poly_decompose[OF rnc] obtain k a s where
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   683
      kas: "a\<noteq>0" "k\<noteq>0" "psize s + k + 1 = psize ?r"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   684
      "\<forall>z. poly ?r z = poly ?r 0 + z^k* poly (pCons a s) z" by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   685
    {assume "k + 1 = n"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   686
      with kas(3) lgqr[symmetric] q(1) n[symmetric] have s0:"s=0" by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   687
      {fix w
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   688
	have "cmod (poly ?r w) = cmod (1 + a * w ^ k)"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   689
	  using kas(4)[rule_format, of w] s0 r01 by (simp add: algebra_simps)}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   690
      note hth = this [symmetric]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   691
	from reduce_poly_simple[OF kas(1,2)]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   692
      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
   693
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   694
    {assume kn: "k+1 \<noteq> n"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   695
      from kn kas(3) q(1) n[symmetric] lgqr have k1n: "k + 1 < n" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   696
      have th01: "\<not> constant (poly (pCons 1 (monom a (k - 1))))"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   697
	unfolding constant_def poly_pCons poly_monom
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   698
	using kas(1) apply simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   699
	by (rule exI[where x=0], rule exI[where x=1], simp)
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   700
      from kas(1) kas(2) have th02: "k+1 = psize (pCons 1 (monom a (k - 1)))"
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
   701
	by (simp add: psize_def degree_monom_eq)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   702
      from H[rule_format, OF k1n th01 th02]
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   703
      obtain w where w: "1 + w^k * a = 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   704
	unfolding poly_pCons poly_monom
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   705
	using kas(2) by (cases k, auto simp add: algebra_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   706
      from poly_bound_exists[of "cmod w" s] obtain m where
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   707
	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
   708
      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
   709
      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
   710
      then have wm1: "w^k * a = - 1" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   711
      have inv0: "0 < inverse (cmod w ^ (k + 1) * m)"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   712
	using norm_ge_zero[of w] w0 m(1)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   713
	  by (simp add: inverse_eq_divide zero_less_mult_iff)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   714
      with real_down2[OF zero_less_one] obtain t where
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   715
	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
   716
      let ?ct = "complex_of_real t"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   717
      let ?w = "?ct * w"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   718
      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: algebra_simps power_mult_distrib)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   719
      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
   720
	unfolding wm1 by (simp)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   721
      finally have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) = cmod (complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   722
	apply -
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   723
	apply (rule cong[OF refl[of cmod]])
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   724
	apply assumption
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   725
	done
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   726
      with norm_triangle_ineq[of "complex_of_real (1 - t^k)" "?w^k * ?w * poly s ?w"]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   727
      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
   728
      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
   729
      have "t *cmod w \<le> 1 * cmod w" apply (rule mult_mono) using t(1,2) by auto
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   730
      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
   731
      from t inv0 have "t* (cmod w ^ (k + 1) * m) < 1"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   732
	by (simp add: inverse_eq_divide field_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   733
      with zero_less_power[OF t(1), of k]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   734
      have th30: "t^k * (t* (cmod w ^ (k + 1) * m)) < t^k * 1"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   735
	apply - apply (rule mult_strict_left_mono) by simp_all
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   736
      have "cmod (?w^k * ?w * poly s ?w) = t^k * (t* (cmod w ^ (k+1) * cmod (poly s ?w)))"  using w0 t(1)
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
   737
	by (simp add: algebra_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
   738
      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
   739
	using t(1,2) m(2)[rule_format, OF tw] w0
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   740
	apply (simp only: )
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   741
	apply auto
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   742
	apply (rule mult_mono, simp_all add: norm_ge_zero)+
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   743
	apply (simp add: zero_le_mult_iff zero_le_power)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   744
	done
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   745
      with th30 have th120: "cmod (?w^k * ?w * poly s ?w) < t^k" by simp
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   746
      from power_strict_mono[OF t(2), of k] t(1) kas(2) have th121: "t^k \<le> 1"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   747
	by auto
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   748
      from ath[OF norm_ge_zero[of "?w^k * ?w * poly s ?w"] th120 th121]
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   749
      have th12: "\<bar>1 - t^k\<bar> + cmod (?w^k * ?w * poly s ?w) < 1" .
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   750
      from th11 th12
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   751
      have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) < 1"  by arith
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   752
      then have "cmod (poly ?r ?w) < 1"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   753
	unfolding kas(4)[rule_format, of ?w] r01 by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   754
      then have "\<exists>w. cmod (poly ?r w) < 1" by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   755
    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
   756
    from cr0_contr cq0 q(2)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   757
    have ?ths unfolding mrmq_eq not_less[symmetric] by auto}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   758
  ultimately show ?ths by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   759
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   760
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   761
text {* Alternative version with a syntactic notion of constant polynomial. *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   762
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   763
lemma fundamental_theorem_of_algebra_alt:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   764
  assumes nc: "~(\<exists>a l. a\<noteq> 0 \<and> l = 0 \<and> p = pCons a l)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   765
  shows "\<exists>z. poly p z = (0::complex)"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   766
using nc
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   767
proof(induct p)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   768
  case (pCons c cs)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   769
  {assume "c=0" hence ?case by auto}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   770
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   771
  {assume c0: "c\<noteq>0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   772
    {assume nc: "constant (poly (pCons c cs))"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   773
      from nc[unfolded constant_def, rule_format, of 0]
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   774
      have "\<forall>w. w \<noteq> 0 \<longrightarrow> poly cs w = 0" by auto
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   775
      hence "cs = 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   776
	proof(induct cs)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   777
	  case (pCons d ds)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   778
	  {assume "d=0" hence ?case using pCons.prems pCons.hyps by simp}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   779
	  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   780
	  {assume d0: "d\<noteq>0"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   781
	    from poly_bound_exists[of 1 ds] obtain m where
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   782
	      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
   783
	    have dm: "cmod d / m > 0" using d0 m(1) by (simp add: field_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   784
	    from real_down2[OF dm zero_less_one] obtain x where
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   785
	      x: "x > 0" "x < cmod d / m" "x < 1" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   786
	    let ?x = "complex_of_real x"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   787
	    from x have cx: "?x \<noteq> 0"  "cmod ?x \<le> 1" by simp_all
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   788
	    from pCons.prems[rule_format, OF cx(1)]
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   789
	    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
   790
	    from m(2)[rule_format, OF cx(2)] x(1)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   791
	    have th0: "cmod (?x*poly ds ?x) \<le> x*m"
27514
6fcf6864d703 remove redundant lemmas about cmod
huffman
parents: 27445
diff changeset
   792
	      by (simp add: norm_mult)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   793
	    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
   794
	    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
   795
	    with cth  have ?case by blast}
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   796
	  ultimately show ?case by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   797
	qed simp}
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   798
      then have nc: "\<not> constant (poly (pCons c cs))" using pCons.prems c0
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   799
	by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   800
      from fundamental_theorem_of_algebra[OF nc] have ?case .}
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   801
  ultimately show ?case by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   802
qed simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   803
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   804
27445
0829a2c4b287 section -> subsection
huffman
parents: 27108
diff changeset
   805
subsection{* Nullstellenstatz, degrees and divisibility of polynomials *}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   806
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   807
lemma nullstellensatz_lemma:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   808
  fixes p :: "complex poly"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   809
  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
   810
  and "degree p = n" and "n \<noteq> 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   811
  shows "p dvd (q ^ n)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   812
using prems
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   813
proof(induct n arbitrary: p q rule: nat_less_induct)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   814
  fix n::nat fix p q :: "complex poly"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   815
  assume IH: "\<forall>m<n. \<forall>p q.
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   816
                 (\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longrightarrow>
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   817
                 degree p = m \<longrightarrow> m \<noteq> 0 \<longrightarrow> p dvd (q ^ m)"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   818
    and pq0: "\<forall>x. poly p x = 0 \<longrightarrow> poly q x = 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   819
    and dpn: "degree p = n" and n0: "n \<noteq> 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   820
  from dpn n0 have pne: "p \<noteq> 0" by auto
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   821
  let ?ths = "p dvd (q ^ n)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   822
  {fix a assume a: "poly p a = 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   823
    {assume oa: "order a p \<noteq> 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   824
      let ?op = "order a p"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   825
      from pne have ap: "([:- a, 1:] ^ ?op) dvd p"
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   826
	"\<not> [:- a, 1:] ^ (Suc ?op) dvd p" using order by blast+
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   827
      note oop = order_degree[OF pne, unfolded dpn]
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   828
      {assume q0: "q = 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   829
	hence ?ths using n0
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   830
          by (simp add: power_0_left)}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   831
      moreover
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   832
      {assume q0: "q \<noteq> 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   833
	from pq0[rule_format, OF a, unfolded poly_eq_0_iff_dvd]
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   834
	obtain r where r: "q = [:- a, 1:] * r" by (rule dvdE)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   835
	from ap(1) obtain s where
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   836
	  s: "p = [:- a, 1:] ^ ?op * s" by (rule dvdE)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   837
	have sne: "s \<noteq> 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   838
	  using s pne by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   839
	{assume ds0: "degree s = 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   840
	  from ds0 have "\<exists>k. s = [:k:]"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   841
            by (cases s, simp split: if_splits)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   842
	  then obtain k where kpn: "s = [:k:]" by blast
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   843
          from sne kpn have k: "k \<noteq> 0" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   844
	  let ?w = "([:1/k:] * ([:-a,1:] ^ (n - ?op))) * (r ^ n)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   845
          from k oop [of a] have "q ^ n = p * ?w"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   846
            apply -
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   847
            apply (subst r, subst s, subst kpn)
29472
a63a2e46cec9 declare smult rules [simp]
huffman
parents: 29470
diff changeset
   848
            apply (subst power_mult_distrib, simp)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   849
            apply (subst power_add [symmetric], simp)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   850
            done
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   851
	  hence ?ths unfolding dvd_def by blast}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   852
	moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   853
	{assume ds0: "degree s \<noteq> 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   854
	  from ds0 sne dpn s oa
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   855
	    have dsn: "degree s < n" apply auto
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   856
              apply (erule ssubst)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   857
              apply (simp add: degree_mult_eq degree_linear_power)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   858
              done
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   859
	    {fix x assume h: "poly s x = 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   860
	      {assume xa: "x = a"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   861
		from h[unfolded xa poly_eq_0_iff_dvd] obtain u where
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   862
		  u: "s = [:- a, 1:] * u" by (rule dvdE)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   863
		have "p = [:- a, 1:] ^ (Suc ?op) * u"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   864
                  by (subst s, subst u, simp only: power_Suc mult_ac)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   865
		with ap(2)[unfolded dvd_def] have False by blast}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   866
	      note xa = this
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   867
	      from h have "poly p x = 0" by (subst s, simp)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   868
	      with pq0 have "poly q x = 0" by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   869
	      with r xa have "poly r x = 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   870
                by (auto simp add: uminus_add_conv_diff)}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   871
	    note impth = this
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   872
	    from IH[rule_format, OF dsn, of s r] impth ds0
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   873
	    have "s dvd (r ^ (degree s))" by blast
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   874
	    then obtain u where u: "r ^ (degree s) = s * u" ..
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   875
	    hence u': "\<And>x. poly s x * poly u x = poly r x ^ degree s"
29470
1851088a1f87 convert Deriv.thy to use new Polynomial library (incomplete)
huffman
parents: 29464
diff changeset
   876
              by (simp only: poly_mult[symmetric] poly_power[symmetric])
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   877
	    let ?w = "(u * ([:-a,1:] ^ (n - ?op))) * (r ^ (n - degree s))"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   878
	    from oop[of a] dsn have "q ^ n = p * ?w"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   879
              apply -
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   880
              apply (subst s, subst r)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   881
              apply (simp only: power_mult_distrib)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   882
              apply (subst mult_assoc [where b=s])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   883
              apply (subst mult_assoc [where a=u])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   884
              apply (subst mult_assoc [where b=u, symmetric])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   885
              apply (subst u [symmetric])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   886
              apply (simp add: mult_ac power_add [symmetric])
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   887
              done
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   888
	    hence ?ths unfolding dvd_def by blast}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   889
      ultimately have ?ths by blast }
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   890
      ultimately have ?ths by blast}
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   891
    then have ?ths using a order_root pne by blast}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   892
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   893
  {assume exa: "\<not> (\<exists>a. poly p a = 0)"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   894
    from fundamental_theorem_of_algebra_alt[of p] exa obtain c where
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   895
      ccs: "c\<noteq>0" "p = pCons c 0" by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   896
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   897
    then have pp: "\<And>x. poly p x =  c" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   898
    let ?w = "[:1/c:] * (q ^ n)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   899
    from ccs
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   900
    have "(q ^ n) = (p * ?w) "
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   901
      by (simp add: smult_smult)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   902
    hence ?ths unfolding dvd_def by blast}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   903
  ultimately show ?ths by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   904
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   905
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   906
lemma nullstellensatz_univariate:
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   907
  "(\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longleftrightarrow>
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   908
    p dvd (q ^ (degree p)) \<or> (p = 0 \<and> q = 0)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   909
proof-
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   910
  {assume pe: "p = 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   911
    hence eq: "(\<forall>x. poly p x = (0::complex) \<longrightarrow> poly q x = 0) \<longleftrightarrow> q = 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   912
      apply auto
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   913
      apply (rule poly_zero [THEN iffD1])
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   914
      by (rule ext, simp)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   915
    {assume "p dvd (q ^ (degree p))"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   916
      then obtain r where r: "q ^ (degree p) = p * r" ..
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   917
      from r pe have False by simp}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   918
    with eq pe have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   919
  moreover
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   920
  {assume pe: "p \<noteq> 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   921
    {assume dp: "degree p = 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   922
      then obtain k where k: "p = [:k:]" "k\<noteq>0" using pe
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   923
        by (cases p, simp split: if_splits)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   924
      hence th1: "\<forall>x. poly p x \<noteq> 0" by simp
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   925
      from k dp have "q ^ (degree p) = p * [:1/k:]"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   926
        by (simp add: one_poly_def)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   927
      hence th2: "p dvd (q ^ (degree p))" ..
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   928
      from th1 th2 pe have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   929
    moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   930
    {assume dp: "degree p \<noteq> 0"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   931
      then obtain n where n: "degree p = Suc n " by (cases "degree p", auto)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   932
      {assume "p dvd (q ^ (Suc n))"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   933
	then obtain u where u: "q ^ (Suc n) = p * u" ..
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   934
	{fix x assume h: "poly p x = 0" "poly q x \<noteq> 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   935
	  hence "poly (q ^ (Suc n)) x \<noteq> 0" by simp
29470
1851088a1f87 convert Deriv.thy to use new Polynomial library (incomplete)
huffman
parents: 29464
diff changeset
   936
	  hence False using u h(1) by (simp only: poly_mult) simp}}
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   937
	with n nullstellensatz_lemma[of p q "degree p"] dp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   938
	have ?thesis by auto}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   939
    ultimately have ?thesis by blast}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   940
  ultimately show ?thesis by blast
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   941
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   942
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   943
text{* Useful lemma *}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   944
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   945
lemma constant_degree:
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   946
  fixes p :: "'a::{idom,ring_char_0} poly"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   947
  shows "constant (poly p) \<longleftrightarrow> degree p = 0" (is "?lhs = ?rhs")
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   948
proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   949
  assume l: ?lhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   950
  from l[unfolded constant_def, rule_format, of _ "0"]
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   951
  have th: "poly p = poly [:poly p 0:]" apply - by (rule ext, simp)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   952
  then have "p = [:poly p 0:]" by (simp add: poly_eq_iff)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   953
  then have "degree p = degree [:poly p 0:]" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   954
  then show ?rhs by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   955
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   956
  assume r: ?rhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   957
  then obtain k where "p = [:k:]"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   958
    by (cases p, simp split: if_splits)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   959
  then show ?lhs unfolding constant_def by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   960
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   961
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   962
lemma divides_degree: assumes pq: "p dvd (q:: complex poly)"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   963
  shows "degree p \<le> degree q \<or> q = 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   964
apply (cases "q = 0", simp_all)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   965
apply (erule dvd_imp_degree_le [OF pq])
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   966
done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   967
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   968
(* Arithmetic operations on multivariate polynomials.                        *)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   969
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   970
lemma mpoly_base_conv:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   971
  "(0::complex) \<equiv> poly 0 x" "c \<equiv> poly [:c:] x" "x \<equiv> poly [:0,1:] x" by simp_all
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   972
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   973
lemma mpoly_norm_conv:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   974
  "poly [:0:] (x::complex) \<equiv> poly 0 x" "poly [:poly 0 y:] x \<equiv> poly 0 x" by simp_all
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   975
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   976
lemma mpoly_sub_conv:
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   977
  "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
   978
  by (simp add: diff_def)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   979
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   980
lemma poly_pad_rule: "poly p x = 0 ==> poly (pCons 0 p) x = (0::complex)" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   981
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   982
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
   983
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   984
lemma resolve_eq_raw:  "poly 0 x \<equiv> 0" "poly [:c:] x \<equiv> (c::complex)" by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   985
lemma  resolve_eq_then: "(P \<Longrightarrow> (Q \<equiv> Q1)) \<Longrightarrow> (\<not>P \<Longrightarrow> (Q \<equiv> Q2))
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   986
  \<Longrightarrow> Q \<equiv> P \<and> Q1 \<or> \<not>P\<and> Q2" apply (atomize (full)) by blast
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   987
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   988
lemma poly_divides_pad_rule:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   989
  fixes p q :: "complex poly"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   990
  assumes pq: "p dvd q"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   991
  shows "p dvd (pCons (0::complex) q)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   992
proof-
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   993
  have "pCons 0 q = q * [:0,1:]" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   994
  then have "q dvd (pCons 0 q)" ..
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   995
  with pq show ?thesis by (rule dvd_trans)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   996
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
   997
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
   998
lemma poly_divides_pad_const_rule:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
   999
  fixes p q :: "complex poly"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1000
  assumes pq: "p dvd q"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1001
  shows "p dvd (smult a q)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1002
proof-
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1003
  have "smult a q = q * [:a:]" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1004
  then have "q dvd smult a q" ..
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1005
  with pq show ?thesis by (rule dvd_trans)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1006
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1007
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1008
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1009
lemma poly_divides_conv0:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1010
  fixes p :: "complex poly"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1011
  assumes lgpq: "degree q < degree p" and lq:"p \<noteq> 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1012
  shows "p dvd q \<equiv> q = 0" (is "?lhs \<equiv> ?rhs")
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1013
proof-
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1014
  {assume r: ?rhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1015
    hence "q = p * 0" by simp
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1016
    hence ?lhs ..}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1017
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1018
  {assume l: ?lhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1019
    {assume q0: "q = 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1020
      hence ?rhs by simp}
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1021
    moreover
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1022
    {assume q0: "q \<noteq> 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1023
      from l q0 have "degree p \<le> degree q"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1024
        by (rule dvd_imp_degree_le)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1025
      with lgpq have ?rhs by simp }
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1026
    ultimately have ?rhs by blast }
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1027
  ultimately show "?lhs \<equiv> ?rhs" by - (atomize (full), blast)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1028
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1029
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1030
lemma poly_divides_conv1:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1031
  assumes a0: "a\<noteq> (0::complex)" and pp': "(p::complex poly) dvd p'"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1032
  and qrp': "smult a q - p' \<equiv> r"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1033
  shows "p dvd q \<equiv> p dvd (r::complex poly)" (is "?lhs \<equiv> ?rhs")
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1034
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1035
  {
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1036
  from pp' obtain t where t: "p' = p * t" ..
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1037
  {assume l: ?lhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1038
    then obtain u where u: "q = p * u" ..
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1039
     have "r = p * (smult a u - t)"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
  1040
       using u qrp' [symmetric] t by (simp add: algebra_simps mult_smult_right)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1041
     then have ?rhs ..}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1042
  moreover
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1043
  {assume r: ?rhs
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1044
    then obtain u where u: "r = p * u" ..
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1045
    from u [symmetric] t qrp' [symmetric] a0
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1046
    have "q = p * smult (1/a) (u + t)"
29667
53103fc8ffa3 Replaced group_ and ring_simps by algebra_simps;
nipkow
parents: 29538
diff changeset
  1047
      by (simp add: algebra_simps mult_smult_right smult_smult)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1048
    hence ?lhs ..}
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1049
  ultimately have "?lhs = ?rhs" by blast }
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1050
thus "?lhs \<equiv> ?rhs"  by - (atomize(full), blast)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1051
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1052
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1053
lemma basic_cqe_conv1:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1054
  "(\<exists>x. poly p x = 0 \<and> poly 0 x \<noteq> 0) \<equiv> False"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1055
  "(\<exists>x. poly 0 x \<noteq> 0) \<equiv> False"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1056
  "(\<exists>x. poly [:c:] x \<noteq> 0) \<equiv> c\<noteq>0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1057
  "(\<exists>x. poly 0 x = 0) \<equiv> True"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1058
  "(\<exists>x. poly [:c:] x = 0) \<equiv> c = 0" by simp_all
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1059
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1060
lemma basic_cqe_conv2:
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1061
  assumes l:"p \<noteq> 0"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1062
  shows "(\<exists>x. poly (pCons a (pCons b p)) x = (0::complex)) \<equiv> True"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1063
proof-
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1064
  {fix h t
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1065
    assume h: "h\<noteq>0" "t=0"  "pCons a (pCons b p) = pCons h t"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1066
    with l have False by simp}
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1067
  hence th: "\<not> (\<exists> h t. h\<noteq>0 \<and> t=0 \<and> pCons a (pCons b p) = pCons h t)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1068
    by blast
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1069
  from fundamental_theorem_of_algebra_alt[OF th]
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1070
  show "(\<exists>x. poly (pCons a (pCons b p)) x = (0::complex)) \<equiv> True" by auto
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1071
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1072
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1073
lemma  basic_cqe_conv_2b: "(\<exists>x. poly p x \<noteq> (0::complex)) \<equiv> (p \<noteq> 0)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1074
proof-
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1075
  have "p = 0 \<longleftrightarrow> poly p = poly 0"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1076
    by (simp add: poly_zero)
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1077
  also have "\<dots> \<longleftrightarrow> (\<not> (\<exists>x. poly p x \<noteq> 0))" by (auto intro: ext)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1078
  finally show "(\<exists>x. poly p x \<noteq> (0::complex)) \<equiv> p \<noteq> 0"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1079
    by - (atomize (full), blast)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1080
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1081
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1082
lemma basic_cqe_conv3:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1083
  fixes p q :: "complex poly"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1084
  assumes l: "p \<noteq> 0"
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
  1085
  shows "(\<exists>x. poly (pCons a p) x = 0 \<and> poly q x \<noteq> 0) \<equiv> \<not> ((pCons a p) dvd (q ^ (psize p)))"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1086
proof-
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
  1087
  from l have dp:"degree (pCons a p) = psize p" by (simp add: psize_def)
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1088
  from nullstellensatz_univariate[of "pCons a p" q] l
29538
5cc98af1398d rename plength to psize
huffman
parents: 29485
diff changeset
  1089
  show "(\<exists>x. poly (pCons a p) x = 0 \<and> poly q x \<noteq> 0) \<equiv> \<not> ((pCons a p) dvd (q ^ (psize p)))"
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1090
    unfolding dp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1091
    by - (atomize (full), auto)
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1092
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1093
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1094
lemma basic_cqe_conv4:
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1095
  fixes p q :: "complex poly"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1096
  assumes h: "\<And>x. poly (q ^ n) x \<equiv> poly r x"
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1097
  shows "p dvd (q ^ n) \<equiv> p dvd r"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1098
proof-
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1099
  from h have "poly (q ^ n) = poly r" by (auto intro: ext)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1100
  then have "(q ^ n) = r" by (simp add: poly_eq_iff)
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1101
  thus "p dvd (q ^ n) \<equiv> p dvd r" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1102
qed
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1103
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1104
lemma pmult_Cons_Cons: "(pCons (a::complex) (pCons b p) * q = (smult a q) + (pCons 0 (pCons b p * q)))"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1105
  by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1106
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1107
lemma elim_neg_conv: "- z \<equiv> (-1) * (z::complex)" by simp
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1108
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
  1109
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
  1110
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1111
lemma complex_entire: "(z::complex) \<noteq> 0 \<and> w \<noteq> 0 \<equiv> z*w \<noteq> 0" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30242
diff changeset
  1112
lemma resolve_eq_ne: "(P \<equiv> True) \<equiv> (\<not>P \<equiv> False)" "(P \<equiv> False) \<equiv> (\<not>P \<equiv> True)"
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1113
  by (atomize (full)) simp_all
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1114
lemma cqe_conv1: "poly 0 x = 0 \<longleftrightarrow> True"  by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1115
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
  1116
proof
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1117
  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
  1118
next
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1119
  assume "p \<and> q \<equiv> p \<and> r" "p"
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1120
  thus "q \<equiv> r" apply - apply (atomize (full)) apply blast done
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1121
qed
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1122
lemma poly_const_conv: "poly [:c:] (x::complex) = y \<longleftrightarrow> c = y" by simp
26123
44384b5c4fc0 A proof a the fundamental theorem of algebra
chaieb
parents:
diff changeset
  1123
29464
c0d225a7f6ff convert Fundamental_Theorem_Algebra.thy to use new Polynomial library
huffman
parents: 29292
diff changeset
  1124
end