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