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