src/HOL/Library/Fundamental_Theorem_Algebra.thy
changeset 32960 69916a850301
parent 32456 341c83339aeb
child 34915 7894c7dab132
equal deleted inserted replaced
32959:23a8c5ac35f8 32960:69916a850301
    18 proof-
    18 proof-
    19   obtain x y where xy: "z = Complex x y" by (cases z)
    19   obtain x y where xy: "z = Complex x y" by (cases z)
    20   {assume y0: "y = 0"
    20   {assume y0: "y = 0"
    21     {assume x0: "x \<ge> 0"
    21     {assume x0: "x \<ge> 0"
    22       then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
    22       then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
    23 	by (simp add: csqrt_def power2_eq_square)}
    23         by (simp add: csqrt_def power2_eq_square)}
    24     moreover
    24     moreover
    25     {assume "\<not> x \<ge> 0" hence x0: "- x \<ge> 0" by arith
    25     {assume "\<not> x \<ge> 0" hence x0: "- x \<ge> 0" by arith
    26       then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
    26       then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
    27 	by (simp add: csqrt_def power2_eq_square) }
    27         by (simp add: csqrt_def power2_eq_square) }
    28     ultimately have ?thesis by blast}
    28     ultimately have ?thesis by blast}
    29   moreover
    29   moreover
    30   {assume y0: "y\<noteq>0"
    30   {assume y0: "y\<noteq>0"
    31     {fix x y
    31     {fix x y
    32       let ?z = "Complex x y"
    32       let ?z = "Complex x y"
   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
   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
   321     {fix n assume nN12: "n \<ge> N1 + N2"
   321     {fix n assume nN12: "n \<ge> N1 + N2"
   322       hence nN1: "g n \<ge> N1" and nN2: "n \<ge> N2" using seq_suble[OF g(1), of n] by arith+
   322       hence nN1: "g n \<ge> N1" and nN2: "n \<ge> N2" using seq_suble[OF g(1), of n] by arith+
   323       from add_strict_mono[OF N1[rule_format, OF nN1] N2[rule_format, OF nN2]]
   323       from add_strict_mono[OF N1[rule_format, OF nN1] N2[rule_format, OF nN2]]
   324       have "cmod (s (?h n) - ?w) < e"
   324       have "cmod (s (?h n) - ?w) < e"
   325 	using metric_bound_lemma[of "s (f (g n))" ?w] by simp }
   325         using metric_bound_lemma[of "s (f (g n))" ?w] by simp }
   326     hence "\<exists>N. \<forall>n\<ge>N. cmod (s (?h n) - ?w) < e" by blast }
   326     hence "\<exists>N. \<forall>n\<ge>N. cmod (s (?h n) - ?w) < e" by blast }
   327   with hs show ?thesis  by blast
   327   with hs show ?thesis  by blast
   328 qed
   328 qed
   329 
   329 
   330 text{* Polynomial is continuous. *}
   330 text{* Polynomial is continuous. *}
   356     obtain d where d: "d >0" "d < 1" "d < e / m" by blast
   356     obtain d where d: "d >0" "d < 1" "d < e / m" by blast
   357     from d(1,3) m(1) have dm: "d*m > 0" "d*m < e"
   357     from d(1,3) m(1) have dm: "d*m > 0" "d*m < e"
   358       by (simp_all add: field_simps real_mult_order)
   358       by (simp_all add: field_simps real_mult_order)
   359     show ?case
   359     show ?case
   360       proof(rule ex_forward[OF real_lbound_gt_zero[OF one0 em0]], clarsimp simp add: norm_mult)
   360       proof(rule ex_forward[OF real_lbound_gt_zero[OF one0 em0]], clarsimp simp add: norm_mult)
   361 	fix d w
   361         fix d w
   362 	assume H: "d > 0" "d < 1" "d < e/m" "w\<noteq>z" "cmod (w-z) < d"
   362         assume H: "d > 0" "d < 1" "d < e/m" "w\<noteq>z" "cmod (w-z) < d"
   363 	hence d1: "cmod (w-z) \<le> 1" "d \<ge> 0" by simp_all
   363         hence d1: "cmod (w-z) \<le> 1" "d \<ge> 0" by simp_all
   364 	from H(3) m(1) have dme: "d*m < e" by (simp add: field_simps)
   364         from H(3) m(1) have dme: "d*m < e" by (simp add: field_simps)
   365 	from H have th: "cmod (w-z) \<le> d" by simp
   365         from H have th: "cmod (w-z) \<le> d" by simp
   366 	from mult_mono[OF th m(2)[OF d1(1)] d1(2) norm_ge_zero] dme
   366         from mult_mono[OF th m(2)[OF d1(1)] d1(2) norm_ge_zero] dme
   367 	show "cmod (w - z) * cmod (poly cs (w - z)) < e" by simp
   367         show "cmod (w - z) * cmod (poly cs (w - z)) < e" by simp
   368       qed
   368       qed
   369     qed
   369     qed
   370 qed
   370 qed
   371 
   371 
   372 text{* Hence a polynomial attains minimum on a closed disc
   372 text{* Hence a polynomial attains minimum on a closed disc
   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
   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
   396     let ?m = "-s"
   396     let ?m = "-s"
   397     {fix y
   397     {fix y
   398       from s[rule_format, of "-y"] have
   398       from s[rule_format, of "-y"] have
   399     "(\<exists>z x. cmod z \<le> r \<and> -(- cmod (poly p z)) < y) \<longleftrightarrow> ?m < y"
   399     "(\<exists>z x. cmod z \<le> r \<and> -(- cmod (poly p z)) < y) \<longleftrightarrow> ?m < y"
   400 	unfolding minus_less_iff[of y ] equation_minus_iff by blast }
   400         unfolding minus_less_iff[of y ] equation_minus_iff by blast }
   401     note s1 = this[unfolded minus_minus]
   401     note s1 = this[unfolded minus_minus]
   402     from s1[of ?m] have s1m: "\<And>z x. cmod z \<le> r \<Longrightarrow> cmod (poly p z) \<ge> ?m"
   402     from s1[of ?m] have s1m: "\<And>z x. cmod z \<le> r \<Longrightarrow> cmod (poly p z) \<ge> ?m"
   403       by auto
   403       by auto
   404     {fix n::nat
   404     {fix n::nat
   405       from s1[rule_format, of "?m + 1/real (Suc n)"]
   405       from s1[rule_format, of "?m + 1/real (Suc n)"]
   406       have "\<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)"
   406       have "\<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)"
   407 	by simp}
   407         by simp}
   408     hence th: "\<forall>n. \<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)" ..
   408     hence th: "\<forall>n. \<exists>z. cmod z \<le> r \<and> cmod (poly p z) < - s + 1 / real (Suc n)" ..
   409     from choice[OF th] obtain g where
   409     from choice[OF th] obtain g where
   410       g: "\<forall>n. cmod (g n) \<le> r" "\<forall>n. cmod (poly p (g n)) <?m+1 /real(Suc n)"
   410       g: "\<forall>n. cmod (g n) \<le> r" "\<forall>n. cmod (poly p (g n)) <?m+1 /real(Suc n)"
   411       by blast
   411       by blast
   412     from bolzano_weierstrass_complex_disc[OF g(1)]
   412     from bolzano_weierstrass_complex_disc[OF g(1)]
   414       by blast
   414       by blast
   415     {fix w
   415     {fix w
   416       assume wr: "cmod w \<le> r"
   416       assume wr: "cmod w \<le> r"
   417       let ?e = "\<bar>cmod (poly p z) - ?m\<bar>"
   417       let ?e = "\<bar>cmod (poly p z) - ?m\<bar>"
   418       {assume e: "?e > 0"
   418       {assume e: "?e > 0"
   419 	hence e2: "?e/2 > 0" by simp
   419         hence e2: "?e/2 > 0" by simp
   420 	from poly_cont[OF e2, of z p] obtain d where
   420         from poly_cont[OF e2, of z p] obtain d where
   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
   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
   422 	{fix w assume w: "cmod (w - z) < d"
   422         {fix w assume w: "cmod (w - z) < d"
   423 	  have "cmod(poly p w - poly p z) < ?e / 2"
   423           have "cmod(poly p w - poly p z) < ?e / 2"
   424 	    using d(2)[rule_format, of w] w e by (cases "w=z", simp_all)}
   424             using d(2)[rule_format, of w] w e by (cases "w=z", simp_all)}
   425 	note th1 = this
   425         note th1 = this
   426 
   426 
   427 	from fz(2)[rule_format, OF d(1)] obtain N1 where
   427         from fz(2)[rule_format, OF d(1)] obtain N1 where
   428 	  N1: "\<forall>n\<ge>N1. cmod (g (f n) - z) < d" by blast
   428           N1: "\<forall>n\<ge>N1. cmod (g (f n) - z) < d" by blast
   429 	from reals_Archimedean2[of "2/?e"] obtain N2::nat where
   429         from reals_Archimedean2[of "2/?e"] obtain N2::nat where
   430 	  N2: "2/?e < real N2" by blast
   430           N2: "2/?e < real N2" by blast
   431 	have th2: "cmod(poly p (g(f(N1 + N2))) - poly p z) < ?e/2"
   431         have th2: "cmod(poly p (g(f(N1 + N2))) - poly p z) < ?e/2"
   432 	  using N1[rule_format, of "N1 + N2"] th1 by simp
   432           using N1[rule_format, of "N1 + N2"] th1 by simp
   433 	{fix a b e2 m :: real
   433         {fix a b e2 m :: real
   434 	have "a < e2 \<Longrightarrow> abs(b - m) < e2 \<Longrightarrow> 2 * e2 <= abs(b - m) + a
   434         have "a < e2 \<Longrightarrow> abs(b - m) < e2 \<Longrightarrow> 2 * e2 <= abs(b - m) + a
   435           ==> False" by arith}
   435           ==> False" by arith}
   436       note th0 = this
   436       note th0 = this
   437       have ath:
   437       have ath:
   438 	"\<And>m x e. m <= x \<Longrightarrow>  x < m + e ==> abs(x - m::real) < e" by arith
   438         "\<And>m x e. m <= x \<Longrightarrow>  x < m + e ==> abs(x - m::real) < e" by arith
   439       from s1m[OF g(1)[rule_format]]
   439       from s1m[OF g(1)[rule_format]]
   440       have th31: "?m \<le> cmod(poly p (g (f (N1 + N2))))" .
   440       have th31: "?m \<le> cmod(poly p (g (f (N1 + N2))))" .
   441       from seq_suble[OF fz(1), of "N1+N2"]
   441       from seq_suble[OF fz(1), of "N1+N2"]
   442       have th00: "real (Suc (N1+N2)) \<le> real (Suc (f (N1+N2)))" by simp
   442       have th00: "real (Suc (N1+N2)) \<le> real (Suc (f (N1+N2)))" by simp
   443       have th000: "0 \<le> (1::real)" "(1::real) \<le> 1" "real (Suc (N1+N2)) > 0"
   443       have th000: "0 \<le> (1::real)" "(1::real) \<le> 1" "real (Suc (N1+N2)) > 0"
   444 	using N2 by auto
   444         using N2 by auto
   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
   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
   446       from g(2)[rule_format, of "f (N1 + N2)"]
   446       from g(2)[rule_format, of "f (N1 + N2)"]
   447       have th01:"cmod (poly p (g (f (N1 + N2)))) < - s + 1 / real (Suc (f (N1 + N2)))" .
   447       have th01:"cmod (poly p (g (f (N1 + N2)))) < - s + 1 / real (Suc (f (N1 + N2)))" .
   448       from order_less_le_trans[OF th01 th00]
   448       from order_less_le_trans[OF th01 th00]
   449       have th32: "cmod(poly p (g (f (N1 + N2)))) < ?m + (1/ real(Suc (N1 + N2)))" .
   449       have th32: "cmod(poly p (g (f (N1 + N2)))) < ?m + (1/ real(Suc (N1 + N2)))" .
   451       with e2 less_imp_inverse_less[of "2/?e" "real (Suc (N1 + N2))"]
   451       with e2 less_imp_inverse_less[of "2/?e" "real (Suc (N1 + N2))"]
   452       have "?e/2 > 1/ real (Suc (N1 + N2))" by (simp add: inverse_eq_divide)
   452       have "?e/2 > 1/ real (Suc (N1 + N2))" by (simp add: inverse_eq_divide)
   453       with ath[OF th31 th32]
   453       with ath[OF th31 th32]
   454       have thc1:"\<bar>cmod(poly p (g (f (N1 + N2)))) - ?m\<bar>< ?e/2" by arith
   454       have thc1:"\<bar>cmod(poly p (g (f (N1 + N2)))) - ?m\<bar>< ?e/2" by arith
   455       have ath2: "\<And>(a::real) b c m. \<bar>a - b\<bar> <= c ==> \<bar>b - m\<bar> <= \<bar>a - m\<bar> + c"
   455       have ath2: "\<And>(a::real) b c m. \<bar>a - b\<bar> <= c ==> \<bar>b - m\<bar> <= \<bar>a - m\<bar> + c"
   456 	by arith
   456         by arith
   457       have th22: "\<bar>cmod (poly p (g (f (N1 + N2)))) - cmod (poly p z)\<bar>
   457       have th22: "\<bar>cmod (poly p (g (f (N1 + N2)))) - cmod (poly p z)\<bar>
   458 \<le> cmod (poly p (g (f (N1 + N2))) - poly p z)"
   458 \<le> cmod (poly p (g (f (N1 + N2))) - poly p z)"
   459 	by (simp add: norm_triangle_ineq3)
   459         by (simp add: norm_triangle_ineq3)
   460       from ath2[OF th22, of ?m]
   460       from ath2[OF th22, of ?m]
   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
   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
   462       from th0[OF th2 thc1 thc2] have False .}
   462       from th0[OF th2 thc1 thc2] have False .}
   463       hence "?e = 0" by auto
   463       hence "?e = 0" by auto
   464       then have "cmod (poly p z) = ?m" by simp
   464       then have "cmod (poly p z) = ?m" by simp
   500       from r[rule_format, OF r0]
   500       from r[rule_format, OF r0]
   501       have th0: "d + cmod a \<le> 1 * cmod(poly (pCons c cs) z)" by arith
   501       have th0: "d + cmod a \<le> 1 * cmod(poly (pCons c cs) z)" by arith
   502       from h have z1: "cmod z \<ge> 1" by arith
   502       from h have z1: "cmod z \<ge> 1" by arith
   503       from order_trans[OF th0 mult_right_mono[OF z1 norm_ge_zero[of "poly (pCons c cs) z"]]]
   503       from order_trans[OF th0 mult_right_mono[OF z1 norm_ge_zero[of "poly (pCons c cs) z"]]]
   504       have th1: "d \<le> cmod(z * poly (pCons c cs) z) - cmod a"
   504       have th1: "d \<le> cmod(z * poly (pCons c cs) z) - cmod a"
   505 	unfolding norm_mult by (simp add: algebra_simps)
   505         unfolding norm_mult by (simp add: algebra_simps)
   506       from complex_mod_triangle_sub[of "z * poly (pCons c cs) z" a]
   506       from complex_mod_triangle_sub[of "z * poly (pCons c cs) z" a]
   507       have th2: "cmod(z * poly (pCons c cs) z) - cmod a \<le> cmod (poly (pCons a (pCons c cs)) z)"
   507       have th2: "cmod(z * poly (pCons c cs) z) - cmod a \<le> cmod (poly (pCons a (pCons c cs)) z)"
   508 	by (simp add: diff_le_eq algebra_simps)
   508         by (simp add: diff_le_eq algebra_simps)
   509       from th1 th2 have "d \<le> cmod (poly (pCons a (pCons c cs)) z)"  by arith}
   509       from th1 th2 have "d \<le> cmod (poly (pCons a (pCons c cs)) z)"  by arith}
   510     hence ?case by blast}
   510     hence ?case by blast}
   511   moreover
   511   moreover
   512   {assume cs0: "\<not> (cs \<noteq> 0)"
   512   {assume cs0: "\<not> (cs \<noteq> 0)"
   513     with pCons.prems have c0: "c \<noteq> 0" by simp
   513     with pCons.prems have c0: "c \<noteq> 0" by simp
   514     from cs0 have cs0': "cs = 0" by simp
   514     from cs0 have cs0': "cs = 0" by simp
   515     {fix z
   515     {fix z
   516       assume h: "(\<bar>d\<bar> + cmod a) / cmod c \<le> cmod z"
   516       assume h: "(\<bar>d\<bar> + cmod a) / cmod c \<le> cmod z"
   517       from c0 have "cmod c > 0" by simp
   517       from c0 have "cmod c > 0" by simp
   518       from h c0 have th0: "\<bar>d\<bar> + cmod a \<le> cmod (z*c)"
   518       from h c0 have th0: "\<bar>d\<bar> + cmod a \<le> cmod (z*c)"
   519 	by (simp add: field_simps norm_mult)
   519         by (simp add: field_simps norm_mult)
   520       have ath: "\<And>mzh mazh ma. mzh <= mazh + ma ==> abs(d) + ma <= mzh ==> d <= mazh" by arith
   520       have ath: "\<And>mzh mazh ma. mzh <= mazh + ma ==> abs(d) + ma <= mzh ==> d <= mazh" by arith
   521       from complex_mod_triangle_sub[of "z*c" a ]
   521       from complex_mod_triangle_sub[of "z*c" a ]
   522       have th1: "cmod (z * c) \<le> cmod (a + z * c) + cmod a"
   522       have th1: "cmod (z * c) \<le> cmod (a + z * c) + cmod a"
   523 	by (simp add: algebra_simps)
   523         by (simp add: algebra_simps)
   524       from ath[OF th1 th0] have "d \<le> cmod (poly (pCons a (pCons c cs)) z)"
   524       from ath[OF th1 th0] have "d \<le> cmod (poly (pCons a (pCons c cs)) z)"
   525         using cs0' by simp}
   525         using cs0' by simp}
   526     then have ?case  by blast}
   526     then have ?case  by blast}
   527   ultimately show ?case by blast
   527   ultimately show ?case by blast
   528 qed simp
   528 qed simp
   539     from poly_minimum_modulus_disc[of "\<bar>r\<bar>" "pCons c cs"]
   539     from poly_minimum_modulus_disc[of "\<bar>r\<bar>" "pCons c cs"]
   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
   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
   541     {fix z assume z: "r \<le> cmod z"
   541     {fix z assume z: "r \<le> cmod z"
   542       from v[of 0] r[OF z]
   542       from v[of 0] r[OF z]
   543       have "cmod (poly (pCons c cs) v) \<le> cmod (poly (pCons c cs) z)"
   543       have "cmod (poly (pCons c cs) v) \<le> cmod (poly (pCons c cs) z)"
   544 	by simp }
   544         by simp }
   545     note v0 = this
   545     note v0 = this
   546     from v0 v ath[of r] have ?case by blast}
   546     from v0 v ath[of r] have ?case by blast}
   547   moreover
   547   moreover
   548   {assume cs0: "\<not> (cs \<noteq> 0)"
   548   {assume cs0: "\<not> (cs \<noteq> 0)"
   549     hence th:"cs = 0" by simp
   549     hence th:"cs = 0" by simp
   642     from poly_offset[of p c] obtain q where
   642     from poly_offset[of p c] obtain q where
   643       q: "psize q = psize p" "\<forall>x. poly q x = ?p (c+x)" by blast
   643       q: "psize q = psize p" "\<forall>x. poly q x = ?p (c+x)" by blast
   644     {assume h: "constant (poly q)"
   644     {assume h: "constant (poly q)"
   645       from q(2) have th: "\<forall>x. poly q (x - c) = ?p x" by auto
   645       from q(2) have th: "\<forall>x. poly q (x - c) = ?p x" by auto
   646       {fix x y
   646       {fix x y
   647 	from th have "?p x = poly q (x - c)" by auto
   647         from th have "?p x = poly q (x - c)" by auto
   648 	also have "\<dots> = poly q (y - c)"
   648         also have "\<dots> = poly q (y - c)"
   649 	  using h unfolding constant_def by blast
   649           using h unfolding constant_def by blast
   650 	also have "\<dots> = ?p y" using th by auto
   650         also have "\<dots> = ?p y" using th by auto
   651 	finally have "?p x = ?p y" .}
   651         finally have "?p x = ?p y" .}
   652       with nc have False unfolding constant_def by blast }
   652       with nc have False unfolding constant_def by blast }
   653     hence qnc: "\<not> constant (poly q)" by blast
   653     hence qnc: "\<not> constant (poly q)" by blast
   654     from q(2) have pqc0: "?p c = poly q 0" by simp
   654     from q(2) have pqc0: "?p c = poly q 0" by simp
   655     from c pqc0 have cq0: "\<forall>w. cmod (poly q 0) \<le> cmod (?p w)" by simp
   655     from c pqc0 have cq0: "\<forall>w. cmod (poly q 0) \<le> cmod (?p w)" by simp
   656     let ?a0 = "poly q 0"
   656     let ?a0 = "poly q 0"
   662     have lgqr: "psize q = psize ?r"
   662     have lgqr: "psize q = psize ?r"
   663       using a00 unfolding psize_def degree_def
   663       using a00 unfolding psize_def degree_def
   664       by (simp add: expand_poly_eq)
   664       by (simp add: expand_poly_eq)
   665     {assume h: "\<And>x y. poly ?r x = poly ?r y"
   665     {assume h: "\<And>x y. poly ?r x = poly ?r y"
   666       {fix x y
   666       {fix x y
   667 	from qr[rule_format, of x]
   667         from qr[rule_format, of x]
   668 	have "poly q x = poly ?r x * ?a0" by auto
   668         have "poly q x = poly ?r x * ?a0" by auto
   669 	also have "\<dots> = poly ?r y * ?a0" using h by simp
   669         also have "\<dots> = poly ?r y * ?a0" using h by simp
   670 	also have "\<dots> = poly q y" using qr[rule_format, of y] by simp
   670         also have "\<dots> = poly q y" using qr[rule_format, of y] by simp
   671 	finally have "poly q x = poly q y" .}
   671         finally have "poly q x = poly q y" .}
   672       with qnc have False unfolding constant_def by blast}
   672       with qnc have False unfolding constant_def by blast}
   673     hence rnc: "\<not> constant (poly ?r)" unfolding constant_def by blast
   673     hence rnc: "\<not> constant (poly ?r)" unfolding constant_def by blast
   674     from qr[rule_format, of 0] a00  have r01: "poly ?r 0 = 1" by auto
   674     from qr[rule_format, of 0] a00  have r01: "poly ?r 0 = 1" by auto
   675     {fix w
   675     {fix w
   676       have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w / ?a0) < 1"
   676       have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w / ?a0) < 1"
   677 	using qr[rule_format, of w] a00 by (simp add: divide_inverse mult_ac)
   677         using qr[rule_format, of w] a00 by (simp add: divide_inverse mult_ac)
   678       also have "\<dots> \<longleftrightarrow> cmod (poly q w) < cmod ?a0"
   678       also have "\<dots> \<longleftrightarrow> cmod (poly q w) < cmod ?a0"
   679 	using a00 unfolding norm_divide by (simp add: field_simps)
   679         using a00 unfolding norm_divide by (simp add: field_simps)
   680       finally have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w) < cmod ?a0" .}
   680       finally have "cmod (poly ?r w) < 1 \<longleftrightarrow> cmod (poly q w) < cmod ?a0" .}
   681     note mrmq_eq = this
   681     note mrmq_eq = this
   682     from poly_decompose[OF rnc] obtain k a s where
   682     from poly_decompose[OF rnc] obtain k a s where
   683       kas: "a\<noteq>0" "k\<noteq>0" "psize s + k + 1 = psize ?r"
   683       kas: "a\<noteq>0" "k\<noteq>0" "psize s + k + 1 = psize ?r"
   684       "\<forall>z. poly ?r z = poly ?r 0 + z^k* poly (pCons a s) z" by blast
   684       "\<forall>z. poly ?r z = poly ?r 0 + z^k* poly (pCons a s) z" by blast
   685     {assume "k + 1 = n"
   685     {assume "k + 1 = n"
   686       with kas(3) lgqr[symmetric] q(1) n[symmetric] have s0:"s=0" by auto
   686       with kas(3) lgqr[symmetric] q(1) n[symmetric] have s0:"s=0" by auto
   687       {fix w
   687       {fix w
   688 	have "cmod (poly ?r w) = cmod (1 + a * w ^ k)"
   688         have "cmod (poly ?r w) = cmod (1 + a * w ^ k)"
   689 	  using kas(4)[rule_format, of w] s0 r01 by (simp add: algebra_simps)}
   689           using kas(4)[rule_format, of w] s0 r01 by (simp add: algebra_simps)}
   690       note hth = this [symmetric]
   690       note hth = this [symmetric]
   691 	from reduce_poly_simple[OF kas(1,2)]
   691         from reduce_poly_simple[OF kas(1,2)]
   692       have "\<exists>w. cmod (poly ?r w) < 1" unfolding hth by blast}
   692       have "\<exists>w. cmod (poly ?r w) < 1" unfolding hth by blast}
   693     moreover
   693     moreover
   694     {assume kn: "k+1 \<noteq> n"
   694     {assume kn: "k+1 \<noteq> n"
   695       from kn kas(3) q(1) n[symmetric] lgqr have k1n: "k + 1 < n" by simp
   695       from kn kas(3) q(1) n[symmetric] lgqr have k1n: "k + 1 < n" by simp
   696       have th01: "\<not> constant (poly (pCons 1 (monom a (k - 1))))"
   696       have th01: "\<not> constant (poly (pCons 1 (monom a (k - 1))))"
   697 	unfolding constant_def poly_pCons poly_monom
   697         unfolding constant_def poly_pCons poly_monom
   698 	using kas(1) apply simp
   698         using kas(1) apply simp
   699 	by (rule exI[where x=0], rule exI[where x=1], simp)
   699         by (rule exI[where x=0], rule exI[where x=1], simp)
   700       from kas(1) kas(2) have th02: "k+1 = psize (pCons 1 (monom a (k - 1)))"
   700       from kas(1) kas(2) have th02: "k+1 = psize (pCons 1 (monom a (k - 1)))"
   701 	by (simp add: psize_def degree_monom_eq)
   701         by (simp add: psize_def degree_monom_eq)
   702       from H[rule_format, OF k1n th01 th02]
   702       from H[rule_format, OF k1n th01 th02]
   703       obtain w where w: "1 + w^k * a = 0"
   703       obtain w where w: "1 + w^k * a = 0"
   704 	unfolding poly_pCons poly_monom
   704         unfolding poly_pCons poly_monom
   705 	using kas(2) by (cases k, auto simp add: algebra_simps)
   705         using kas(2) by (cases k, auto simp add: algebra_simps)
   706       from poly_bound_exists[of "cmod w" s] obtain m where
   706       from poly_bound_exists[of "cmod w" s] obtain m where
   707 	m: "m > 0" "\<forall>z. cmod z \<le> cmod w \<longrightarrow> cmod (poly s z) \<le> m" by blast
   707         m: "m > 0" "\<forall>z. cmod z \<le> cmod w \<longrightarrow> cmod (poly s z) \<le> m" by blast
   708       have w0: "w\<noteq>0" using kas(2) w by (auto simp add: power_0_left)
   708       have w0: "w\<noteq>0" using kas(2) w by (auto simp add: power_0_left)
   709       from w have "(1 + w ^ k * a) - 1 = 0 - 1" by simp
   709       from w have "(1 + w ^ k * a) - 1 = 0 - 1" by simp
   710       then have wm1: "w^k * a = - 1" by simp
   710       then have wm1: "w^k * a = - 1" by simp
   711       have inv0: "0 < inverse (cmod w ^ (k + 1) * m)"
   711       have inv0: "0 < inverse (cmod w ^ (k + 1) * m)"
   712 	using norm_ge_zero[of w] w0 m(1)
   712         using norm_ge_zero[of w] w0 m(1)
   713 	  by (simp add: inverse_eq_divide zero_less_mult_iff)
   713           by (simp add: inverse_eq_divide zero_less_mult_iff)
   714       with real_down2[OF zero_less_one] obtain t where
   714       with real_down2[OF zero_less_one] obtain t where
   715 	t: "t > 0" "t < 1" "t < inverse (cmod w ^ (k + 1) * m)" by blast
   715         t: "t > 0" "t < 1" "t < inverse (cmod w ^ (k + 1) * m)" by blast
   716       let ?ct = "complex_of_real t"
   716       let ?ct = "complex_of_real t"
   717       let ?w = "?ct * w"
   717       let ?w = "?ct * w"
   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)
   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)
   719       also have "\<dots> = complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w"
   719       also have "\<dots> = complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w"
   720 	unfolding wm1 by (simp)
   720         unfolding wm1 by (simp)
   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)"
   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)"
   722 	apply -
   722         apply -
   723 	apply (rule cong[OF refl[of cmod]])
   723         apply (rule cong[OF refl[of cmod]])
   724 	apply assumption
   724         apply assumption
   725 	done
   725         done
   726       with norm_triangle_ineq[of "complex_of_real (1 - t^k)" "?w^k * ?w * poly s ?w"]
   726       with norm_triangle_ineq[of "complex_of_real (1 - t^k)" "?w^k * ?w * poly s ?w"]
   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
   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
   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
   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
   729       have "t *cmod w \<le> 1 * cmod w" apply (rule mult_mono) using t(1,2) by auto
   729       have "t *cmod w \<le> 1 * cmod w" apply (rule mult_mono) using t(1,2) by auto
   730       then have tw: "cmod ?w \<le> cmod w" using t(1) by (simp add: norm_mult)
   730       then have tw: "cmod ?w \<le> cmod w" using t(1) by (simp add: norm_mult)
   731       from t inv0 have "t* (cmod w ^ (k + 1) * m) < 1"
   731       from t inv0 have "t* (cmod w ^ (k + 1) * m) < 1"
   732 	by (simp add: inverse_eq_divide field_simps)
   732         by (simp add: inverse_eq_divide field_simps)
   733       with zero_less_power[OF t(1), of k]
   733       with zero_less_power[OF t(1), of k]
   734       have th30: "t^k * (t* (cmod w ^ (k + 1) * m)) < t^k * 1"
   734       have th30: "t^k * (t* (cmod w ^ (k + 1) * m)) < t^k * 1"
   735 	apply - apply (rule mult_strict_left_mono) by simp_all
   735         apply - apply (rule mult_strict_left_mono) by simp_all
   736       have "cmod (?w^k * ?w * poly s ?w) = t^k * (t* (cmod w ^ (k+1) * cmod (poly s ?w)))"  using w0 t(1)
   736       have "cmod (?w^k * ?w * poly s ?w) = t^k * (t* (cmod w ^ (k+1) * cmod (poly s ?w)))"  using w0 t(1)
   737 	by (simp add: algebra_simps power_mult_distrib norm_of_real norm_power norm_mult)
   737         by (simp add: algebra_simps power_mult_distrib norm_of_real norm_power norm_mult)
   738       then have "cmod (?w^k * ?w * poly s ?w) \<le> t^k * (t* (cmod w ^ (k + 1) * m))"
   738       then have "cmod (?w^k * ?w * poly s ?w) \<le> t^k * (t* (cmod w ^ (k + 1) * m))"
   739 	using t(1,2) m(2)[rule_format, OF tw] w0
   739         using t(1,2) m(2)[rule_format, OF tw] w0
   740 	apply (simp only: )
   740         apply (simp only: )
   741 	apply auto
   741         apply auto
   742 	apply (rule mult_mono, simp_all add: norm_ge_zero)+
   742         apply (rule mult_mono, simp_all add: norm_ge_zero)+
   743 	apply (simp add: zero_le_mult_iff zero_le_power)
   743         apply (simp add: zero_le_mult_iff zero_le_power)
   744 	done
   744         done
   745       with th30 have th120: "cmod (?w^k * ?w * poly s ?w) < t^k" by simp
   745       with th30 have th120: "cmod (?w^k * ?w * poly s ?w) < t^k" by simp
   746       from power_strict_mono[OF t(2), of k] t(1) kas(2) have th121: "t^k \<le> 1"
   746       from power_strict_mono[OF t(2), of k] t(1) kas(2) have th121: "t^k \<le> 1"
   747 	by auto
   747         by auto
   748       from ath[OF norm_ge_zero[of "?w^k * ?w * poly s ?w"] th120 th121]
   748       from ath[OF norm_ge_zero[of "?w^k * ?w * poly s ?w"] th120 th121]
   749       have th12: "\<bar>1 - t^k\<bar> + cmod (?w^k * ?w * poly s ?w) < 1" .
   749       have th12: "\<bar>1 - t^k\<bar> + cmod (?w^k * ?w * poly s ?w) < 1" .
   750       from th11 th12
   750       from th11 th12
   751       have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) < 1"  by arith
   751       have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) < 1"  by arith
   752       then have "cmod (poly ?r ?w) < 1"
   752       then have "cmod (poly ?r ?w) < 1"
   753 	unfolding kas(4)[rule_format, of ?w] r01 by simp
   753         unfolding kas(4)[rule_format, of ?w] r01 by simp
   754       then have "\<exists>w. cmod (poly ?r w) < 1" by blast}
   754       then have "\<exists>w. cmod (poly ?r w) < 1" by blast}
   755     ultimately have cr0_contr: "\<exists>w. cmod (poly ?r w) < 1" by blast
   755     ultimately have cr0_contr: "\<exists>w. cmod (poly ?r w) < 1" by blast
   756     from cr0_contr cq0 q(2)
   756     from cr0_contr cq0 q(2)
   757     have ?ths unfolding mrmq_eq not_less[symmetric] by auto}
   757     have ?ths unfolding mrmq_eq not_less[symmetric] by auto}
   758   ultimately show ?ths by blast
   758   ultimately show ?ths by blast
   771   {assume c0: "c\<noteq>0"
   771   {assume c0: "c\<noteq>0"
   772     {assume nc: "constant (poly (pCons c cs))"
   772     {assume nc: "constant (poly (pCons c cs))"
   773       from nc[unfolded constant_def, rule_format, of 0]
   773       from nc[unfolded constant_def, rule_format, of 0]
   774       have "\<forall>w. w \<noteq> 0 \<longrightarrow> poly cs w = 0" by auto
   774       have "\<forall>w. w \<noteq> 0 \<longrightarrow> poly cs w = 0" by auto
   775       hence "cs = 0"
   775       hence "cs = 0"
   776 	proof(induct cs)
   776         proof(induct cs)
   777 	  case (pCons d ds)
   777           case (pCons d ds)
   778 	  {assume "d=0" hence ?case using pCons.prems pCons.hyps by simp}
   778           {assume "d=0" hence ?case using pCons.prems pCons.hyps by simp}
   779 	  moreover
   779           moreover
   780 	  {assume d0: "d\<noteq>0"
   780           {assume d0: "d\<noteq>0"
   781 	    from poly_bound_exists[of 1 ds] obtain m where
   781             from poly_bound_exists[of 1 ds] obtain m where
   782 	      m: "m > 0" "\<forall>z. \<forall>z. cmod z \<le> 1 \<longrightarrow> cmod (poly ds z) \<le> m" by blast
   782               m: "m > 0" "\<forall>z. \<forall>z. cmod z \<le> 1 \<longrightarrow> cmod (poly ds z) \<le> m" by blast
   783 	    have dm: "cmod d / m > 0" using d0 m(1) by (simp add: field_simps)
   783             have dm: "cmod d / m > 0" using d0 m(1) by (simp add: field_simps)
   784 	    from real_down2[OF dm zero_less_one] obtain x where
   784             from real_down2[OF dm zero_less_one] obtain x where
   785 	      x: "x > 0" "x < cmod d / m" "x < 1" by blast
   785               x: "x > 0" "x < cmod d / m" "x < 1" by blast
   786 	    let ?x = "complex_of_real x"
   786             let ?x = "complex_of_real x"
   787 	    from x have cx: "?x \<noteq> 0"  "cmod ?x \<le> 1" by simp_all
   787             from x have cx: "?x \<noteq> 0"  "cmod ?x \<le> 1" by simp_all
   788 	    from pCons.prems[rule_format, OF cx(1)]
   788             from pCons.prems[rule_format, OF cx(1)]
   789 	    have cth: "cmod (?x*poly ds ?x) = cmod d" by (simp add: eq_diff_eq[symmetric])
   789             have cth: "cmod (?x*poly ds ?x) = cmod d" by (simp add: eq_diff_eq[symmetric])
   790 	    from m(2)[rule_format, OF cx(2)] x(1)
   790             from m(2)[rule_format, OF cx(2)] x(1)
   791 	    have th0: "cmod (?x*poly ds ?x) \<le> x*m"
   791             have th0: "cmod (?x*poly ds ?x) \<le> x*m"
   792 	      by (simp add: norm_mult)
   792               by (simp add: norm_mult)
   793 	    from x(2) m(1) have "x*m < cmod d" by (simp add: field_simps)
   793             from x(2) m(1) have "x*m < cmod d" by (simp add: field_simps)
   794 	    with th0 have "cmod (?x*poly ds ?x) \<noteq> cmod d" by auto
   794             with th0 have "cmod (?x*poly ds ?x) \<noteq> cmod d" by auto
   795 	    with cth  have ?case by blast}
   795             with cth  have ?case by blast}
   796 	  ultimately show ?case by blast
   796           ultimately show ?case by blast
   797 	qed simp}
   797         qed simp}
   798       then have nc: "\<not> constant (poly (pCons c cs))" using pCons.prems c0
   798       then have nc: "\<not> constant (poly (pCons c cs))" using pCons.prems c0
   799 	by blast
   799         by blast
   800       from fundamental_theorem_of_algebra[OF nc] have ?case .}
   800       from fundamental_theorem_of_algebra[OF nc] have ?case .}
   801   ultimately show ?case by blast
   801   ultimately show ?case by blast
   802 qed simp
   802 qed simp
   803 
   803 
   804 
   804 
   821   let ?ths = "p dvd (q ^ n)"
   821   let ?ths = "p dvd (q ^ n)"
   822   {fix a assume a: "poly p a = 0"
   822   {fix a assume a: "poly p a = 0"
   823     {assume oa: "order a p \<noteq> 0"
   823     {assume oa: "order a p \<noteq> 0"
   824       let ?op = "order a p"
   824       let ?op = "order a p"
   825       from pne have ap: "([:- a, 1:] ^ ?op) dvd p"
   825       from pne have ap: "([:- a, 1:] ^ ?op) dvd p"
   826 	"\<not> [:- a, 1:] ^ (Suc ?op) dvd p" using order by blast+
   826         "\<not> [:- a, 1:] ^ (Suc ?op) dvd p" using order by blast+
   827       note oop = order_degree[OF pne, unfolded dpn]
   827       note oop = order_degree[OF pne, unfolded dpn]
   828       {assume q0: "q = 0"
   828       {assume q0: "q = 0"
   829 	hence ?ths using n0
   829         hence ?ths using n0
   830           by (simp add: power_0_left)}
   830           by (simp add: power_0_left)}
   831       moreover
   831       moreover
   832       {assume q0: "q \<noteq> 0"
   832       {assume q0: "q \<noteq> 0"
   833 	from pq0[rule_format, OF a, unfolded poly_eq_0_iff_dvd]
   833         from pq0[rule_format, OF a, unfolded poly_eq_0_iff_dvd]
   834 	obtain r where r: "q = [:- a, 1:] * r" by (rule dvdE)
   834         obtain r where r: "q = [:- a, 1:] * r" by (rule dvdE)
   835 	from ap(1) obtain s where
   835         from ap(1) obtain s where
   836 	  s: "p = [:- a, 1:] ^ ?op * s" by (rule dvdE)
   836           s: "p = [:- a, 1:] ^ ?op * s" by (rule dvdE)
   837 	have sne: "s \<noteq> 0"
   837         have sne: "s \<noteq> 0"
   838 	  using s pne by auto
   838           using s pne by auto
   839 	{assume ds0: "degree s = 0"
   839         {assume ds0: "degree s = 0"
   840 	  from ds0 have "\<exists>k. s = [:k:]"
   840           from ds0 have "\<exists>k. s = [:k:]"
   841             by (cases s, simp split: if_splits)
   841             by (cases s, simp split: if_splits)
   842 	  then obtain k where kpn: "s = [:k:]" by blast
   842           then obtain k where kpn: "s = [:k:]" by blast
   843           from sne kpn have k: "k \<noteq> 0" by simp
   843           from sne kpn have k: "k \<noteq> 0" by simp
   844 	  let ?w = "([:1/k:] * ([:-a,1:] ^ (n - ?op))) * (r ^ n)"
   844           let ?w = "([:1/k:] * ([:-a,1:] ^ (n - ?op))) * (r ^ n)"
   845           from k oop [of a] have "q ^ n = p * ?w"
   845           from k oop [of a] have "q ^ n = p * ?w"
   846             apply -
   846             apply -
   847             apply (subst r, subst s, subst kpn)
   847             apply (subst r, subst s, subst kpn)
   848             apply (subst power_mult_distrib, simp)
   848             apply (subst power_mult_distrib, simp)
   849             apply (subst power_add [symmetric], simp)
   849             apply (subst power_add [symmetric], simp)
   850             done
   850             done
   851 	  hence ?ths unfolding dvd_def by blast}
   851           hence ?ths unfolding dvd_def by blast}
   852 	moreover
   852         moreover
   853 	{assume ds0: "degree s \<noteq> 0"
   853         {assume ds0: "degree s \<noteq> 0"
   854 	  from ds0 sne dpn s oa
   854           from ds0 sne dpn s oa
   855 	    have dsn: "degree s < n" apply auto
   855             have dsn: "degree s < n" apply auto
   856               apply (erule ssubst)
   856               apply (erule ssubst)
   857               apply (simp add: degree_mult_eq degree_linear_power)
   857               apply (simp add: degree_mult_eq degree_linear_power)
   858               done
   858               done
   859 	    {fix x assume h: "poly s x = 0"
   859             {fix x assume h: "poly s x = 0"
   860 	      {assume xa: "x = a"
   860               {assume xa: "x = a"
   861 		from h[unfolded xa poly_eq_0_iff_dvd] obtain u where
   861                 from h[unfolded xa poly_eq_0_iff_dvd] obtain u where
   862 		  u: "s = [:- a, 1:] * u" by (rule dvdE)
   862                   u: "s = [:- a, 1:] * u" by (rule dvdE)
   863 		have "p = [:- a, 1:] ^ (Suc ?op) * u"
   863                 have "p = [:- a, 1:] ^ (Suc ?op) * u"
   864                   by (subst s, subst u, simp only: power_Suc mult_ac)
   864                   by (subst s, subst u, simp only: power_Suc mult_ac)
   865 		with ap(2)[unfolded dvd_def] have False by blast}
   865                 with ap(2)[unfolded dvd_def] have False by blast}
   866 	      note xa = this
   866               note xa = this
   867 	      from h have "poly p x = 0" by (subst s, simp)
   867               from h have "poly p x = 0" by (subst s, simp)
   868 	      with pq0 have "poly q x = 0" by blast
   868               with pq0 have "poly q x = 0" by blast
   869 	      with r xa have "poly r x = 0"
   869               with r xa have "poly r x = 0"
   870                 by (auto simp add: uminus_add_conv_diff)}
   870                 by (auto simp add: uminus_add_conv_diff)}
   871 	    note impth = this
   871             note impth = this
   872 	    from IH[rule_format, OF dsn, of s r] impth ds0
   872             from IH[rule_format, OF dsn, of s r] impth ds0
   873 	    have "s dvd (r ^ (degree s))" by blast
   873             have "s dvd (r ^ (degree s))" by blast
   874 	    then obtain u where u: "r ^ (degree s) = s * u" ..
   874             then obtain u where u: "r ^ (degree s) = s * u" ..
   875 	    hence u': "\<And>x. poly s x * poly u x = poly r x ^ degree s"
   875             hence u': "\<And>x. poly s x * poly u x = poly r x ^ degree s"
   876               by (simp only: poly_mult[symmetric] poly_power[symmetric])
   876               by (simp only: poly_mult[symmetric] poly_power[symmetric])
   877 	    let ?w = "(u * ([:-a,1:] ^ (n - ?op))) * (r ^ (n - degree s))"
   877             let ?w = "(u * ([:-a,1:] ^ (n - ?op))) * (r ^ (n - degree s))"
   878 	    from oop[of a] dsn have "q ^ n = p * ?w"
   878             from oop[of a] dsn have "q ^ n = p * ?w"
   879               apply -
   879               apply -
   880               apply (subst s, subst r)
   880               apply (subst s, subst r)
   881               apply (simp only: power_mult_distrib)
   881               apply (simp only: power_mult_distrib)
   882               apply (subst mult_assoc [where b=s])
   882               apply (subst mult_assoc [where b=s])
   883               apply (subst mult_assoc [where a=u])
   883               apply (subst mult_assoc [where a=u])
   884               apply (subst mult_assoc [where b=u, symmetric])
   884               apply (subst mult_assoc [where b=u, symmetric])
   885               apply (subst u [symmetric])
   885               apply (subst u [symmetric])
   886               apply (simp add: mult_ac power_add [symmetric])
   886               apply (simp add: mult_ac power_add [symmetric])
   887               done
   887               done
   888 	    hence ?ths unfolding dvd_def by blast}
   888             hence ?ths unfolding dvd_def by blast}
   889       ultimately have ?ths by blast }
   889       ultimately have ?ths by blast }
   890       ultimately have ?ths by blast}
   890       ultimately have ?ths by blast}
   891     then have ?ths using a order_root pne by blast}
   891     then have ?ths using a order_root pne by blast}
   892   moreover
   892   moreover
   893   {assume exa: "\<not> (\<exists>a. poly p a = 0)"
   893   {assume exa: "\<not> (\<exists>a. poly p a = 0)"
   928       from th1 th2 pe have ?thesis by blast}
   928       from th1 th2 pe have ?thesis by blast}
   929     moreover
   929     moreover
   930     {assume dp: "degree p \<noteq> 0"
   930     {assume dp: "degree p \<noteq> 0"
   931       then obtain n where n: "degree p = Suc n " by (cases "degree p", auto)
   931       then obtain n where n: "degree p = Suc n " by (cases "degree p", auto)
   932       {assume "p dvd (q ^ (Suc n))"
   932       {assume "p dvd (q ^ (Suc n))"
   933 	then obtain u where u: "q ^ (Suc n) = p * u" ..
   933         then obtain u where u: "q ^ (Suc n) = p * u" ..
   934 	{fix x assume h: "poly p x = 0" "poly q x \<noteq> 0"
   934         {fix x assume h: "poly p x = 0" "poly q x \<noteq> 0"
   935 	  hence "poly (q ^ (Suc n)) x \<noteq> 0" by simp
   935           hence "poly (q ^ (Suc n)) x \<noteq> 0" by simp
   936 	  hence False using u h(1) by (simp only: poly_mult) simp}}
   936           hence False using u h(1) by (simp only: poly_mult) simp}}
   937 	with n nullstellensatz_lemma[of p q "degree p"] dp
   937         with n nullstellensatz_lemma[of p q "degree p"] dp
   938 	have ?thesis by auto}
   938         have ?thesis by auto}
   939     ultimately have ?thesis by blast}
   939     ultimately have ?thesis by blast}
   940   ultimately show ?thesis by blast
   940   ultimately show ?thesis by blast
   941 qed
   941 qed
   942 
   942 
   943 text{* Useful lemma *}
   943 text{* Useful lemma *}