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