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