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