src/HOL/Fundamental_Theorem_Algebra.thy
 author huffman Mon Jan 12 12:09:54 2009 -0800 (2009-01-12) changeset 29460 ad87e5d1488b parent 29292 11045b88af1a child 29464 c0d225a7f6ff permissions -rw-r--r--
new lemmas about synthetic_div; declare degree_pCons_eq_if [simp]
 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 ``` haftmann@29197 ` 6` ```imports Univ_Poly Dense_Linear_Order 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 ``` chaieb@26123 ` 48` ``` by (simp add: ring_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@26123 ` 62` ``` apply ferrack apply arith done ``` chaieb@26123 ` 63` chaieb@26123 ` 64` ```text{* The triangle inequality for cmod *} ``` chaieb@26123 ` 65` ```lemma complex_mod_triangle_sub: "cmod w \ cmod (w + z) + norm z" ``` chaieb@26123 ` 66` ``` using complex_mod_triangle_ineq2[of "w + z" "-z"] by auto ``` chaieb@26123 ` 67` huffman@27445 ` 68` ```subsection{* Basic lemmas about complex polynomials *} ``` chaieb@26123 ` 69` chaieb@26123 ` 70` ```lemma poly_bound_exists: ``` chaieb@26123 ` 71` ``` shows "\m. m > 0 \ (\z. cmod z <= r \ cmod (poly p z) \ m)" ``` chaieb@26123 ` 72` ```proof(induct p) ``` chaieb@26123 ` 73` ``` case Nil thus ?case by (rule exI[where x=1], simp) ``` chaieb@26123 ` 74` ```next ``` chaieb@26123 ` 75` ``` case (Cons c cs) ``` chaieb@26123 ` 76` ``` from Cons.hyps obtain m where m: "\z. cmod z \ r \ cmod (poly cs z) \ m" ``` chaieb@26123 ` 77` ``` by blast ``` chaieb@26123 ` 78` ``` let ?k = " 1 + cmod c + \r * m\" ``` huffman@27514 ` 79` ``` have kp: "?k > 0" using abs_ge_zero[of "r*m"] norm_ge_zero[of c] by arith ``` chaieb@26123 ` 80` ``` {fix z ``` chaieb@26123 ` 81` ``` assume H: "cmod z \ r" ``` chaieb@26123 ` 82` ``` from m H have th: "cmod (poly cs z) \ m" by blast ``` huffman@27514 ` 83` ``` from H have rp: "r \ 0" using norm_ge_zero[of z] by arith ``` chaieb@26123 ` 84` ``` have "cmod (poly (c # cs) z) \ cmod c + cmod (z* poly cs z)" ``` huffman@27514 ` 85` ``` using norm_triangle_ineq[of c "z* poly cs z"] by simp ``` huffman@27514 ` 86` ``` 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 ` 87` ``` also have "\ \ ?k" by simp ``` chaieb@26123 ` 88` ``` finally have "cmod (poly (c # cs) z) \ ?k" .} ``` chaieb@26123 ` 89` ``` with kp show ?case by blast ``` chaieb@26123 ` 90` ```qed ``` chaieb@26123 ` 91` chaieb@26123 ` 92` chaieb@26123 ` 93` ```text{* Offsetting the variable in a polynomial gives another of same degree *} ``` wenzelm@26135 ` 94` ``` (* FIXME : Lemma holds also in locale --- fix it later *) ``` chaieb@26123 ` 95` ```lemma poly_offset_lemma: ``` chaieb@26123 ` 96` ``` shows "\b q. (length q = length p) \ (\x. poly (b#q) (x::complex) = (a + x) * poly p x)" ``` chaieb@26123 ` 97` ```proof(induct p) ``` chaieb@26123 ` 98` ``` case Nil thus ?case by simp ``` chaieb@26123 ` 99` ```next ``` chaieb@26123 ` 100` ``` case (Cons c cs) ``` chaieb@26123 ` 101` ``` from Cons.hyps obtain b q where ``` chaieb@26123 ` 102` ``` bq: "length q = length cs" "\x. poly (b # q) x = (a + x) * poly cs x" ``` chaieb@26123 ` 103` ``` by blast ``` chaieb@26123 ` 104` ``` let ?b = "a*c" ``` chaieb@26123 ` 105` ``` let ?q = "(b+c)#q" ``` chaieb@26123 ` 106` ``` have lg: "length ?q = length (c#cs)" using bq(1) by simp ``` chaieb@26123 ` 107` ``` {fix x ``` chaieb@26123 ` 108` ``` from bq(2)[rule_format, of x] ``` chaieb@26123 ` 109` ``` have "x*poly (b # q) x = x*((a + x) * poly cs x)" by simp ``` chaieb@26123 ` 110` ``` hence "poly (?b# ?q) x = (a + x) * poly (c # cs) x" ``` chaieb@26123 ` 111` ``` by (simp add: ring_simps)} ``` chaieb@26123 ` 112` ``` with lg show ?case by blast ``` chaieb@26123 ` 113` ```qed ``` chaieb@26123 ` 114` chaieb@26123 ` 115` ``` (* FIXME : This one too*) ``` chaieb@26123 ` 116` ```lemma poly_offset: "\ q. length q = length p \ (\x. poly q (x::complex) = poly p (a + x))" ``` chaieb@26123 ` 117` ```proof (induct p) ``` chaieb@26123 ` 118` ``` case Nil thus ?case by simp ``` chaieb@26123 ` 119` ```next ``` chaieb@26123 ` 120` ``` case (Cons c cs) ``` chaieb@26123 ` 121` ``` from Cons.hyps obtain q where q: "length q = length cs" "\x. poly q x = poly cs (a + x)" by blast ``` chaieb@26123 ` 122` ``` from poly_offset_lemma[of q a] obtain b p where ``` chaieb@26123 ` 123` ``` bp: "length p = length q" "\x. poly (b # p) x = (a + x) * poly q x" ``` chaieb@26123 ` 124` ``` by blast ``` chaieb@26123 ` 125` ``` thus ?case using q bp by - (rule exI[where x="(c + b)#p"], simp) ``` chaieb@26123 ` 126` ```qed ``` chaieb@26123 ` 127` chaieb@26123 ` 128` ```text{* An alternative useful formulation of completeness of the reals *} ``` chaieb@26123 ` 129` ```lemma real_sup_exists: assumes ex: "\x. P x" and bz: "\z. \x. P x \ x < z" ``` chaieb@26123 ` 130` ``` shows "\(s::real). \y. (\x. P x \ y < x) \ y < s" ``` chaieb@26123 ` 131` ```proof- ``` chaieb@26123 ` 132` ``` from ex bz obtain x Y where x: "P x" and Y: "\x. P x \ x < Y" by blast ``` chaieb@26123 ` 133` ``` from ex have thx:"\x. x \ Collect P" by blast ``` chaieb@26123 ` 134` ``` from bz have thY: "\Y. isUb UNIV (Collect P) Y" ``` chaieb@26123 ` 135` ``` by(auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def order_le_less) ``` chaieb@26123 ` 136` ``` from reals_complete[OF thx thY] obtain L where L: "isLub UNIV (Collect P) L" ``` chaieb@26123 ` 137` ``` by blast ``` chaieb@26123 ` 138` ``` from Y[OF x] have xY: "x < Y" . ``` chaieb@26123 ` 139` ``` 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 ` 140` ``` from Y have Y': "\x. P x \ x \ Y" ``` chaieb@26123 ` 141` ``` apply (clarsimp, atomize (full)) by auto ``` chaieb@26123 ` 142` ``` from L Y' have "L \ Y" by (auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def) ``` chaieb@26123 ` 143` ``` {fix y ``` chaieb@26123 ` 144` ``` {fix z assume z: "P z" "y < z" ``` chaieb@26123 ` 145` ``` from L' z have "y < L" by auto } ``` chaieb@26123 ` 146` ``` moreover ``` chaieb@26123 ` 147` ``` {assume yL: "y < L" "\z. P z \ \ y < z" ``` chaieb@26123 ` 148` ``` hence nox: "\z. P z \ y \ z" by auto ``` chaieb@26123 ` 149` ``` from nox L have "y \ L" by (auto simp add: isUb_def isLub_def setge_def setle_def leastP_def Ball_def) ``` chaieb@26123 ` 150` ``` with yL(1) have False by arith} ``` chaieb@26123 ` 151` ``` ultimately have "(\x. P x \ y < x) \ y < L" by blast} ``` chaieb@26123 ` 152` ``` thus ?thesis by blast ``` chaieb@26123 ` 153` ```qed ``` chaieb@26123 ` 154` chaieb@26123 ` 155` huffman@27445 ` 156` ```subsection{* Some theorems about Sequences*} ``` chaieb@26123 ` 157` ```text{* Given a binary function @{text "f:: nat \ 'a \ 'a"}, its values are uniquely determined by a function g *} ``` chaieb@26123 ` 158` chaieb@26123 ` 159` ```lemma num_Axiom: "EX! g. g 0 = e \ (\n. g (Suc n) = f n (g n))" ``` chaieb@26123 ` 160` ``` unfolding Ex1_def ``` chaieb@26123 ` 161` ``` apply (rule_tac x="nat_rec e f" in exI) ``` chaieb@26123 ` 162` ``` apply (rule conjI)+ ``` chaieb@26123 ` 163` ```apply (rule def_nat_rec_0, simp) ``` chaieb@26123 ` 164` ```apply (rule allI, rule def_nat_rec_Suc, simp) ``` chaieb@26123 ` 165` ```apply (rule allI, rule impI, rule ext) ``` chaieb@26123 ` 166` ```apply (erule conjE) ``` chaieb@26123 ` 167` ```apply (induct_tac x) ``` chaieb@26123 ` 168` ```apply (simp add: nat_rec_0) ``` chaieb@26123 ` 169` ```apply (erule_tac x="n" in allE) ``` chaieb@26123 ` 170` ```apply (simp) ``` chaieb@26123 ` 171` ```done ``` chaieb@26123 ` 172` chaieb@26123 ` 173` ``` text{* An equivalent formulation of monotony -- Not used here, but might be useful *} ``` chaieb@26123 ` 174` ```lemma mono_Suc: "mono f = (\n. (f n :: 'a :: order) \ f (Suc n))" ``` chaieb@26123 ` 175` ```unfolding mono_def ``` chaieb@26123 ` 176` ```proof auto ``` chaieb@26123 ` 177` ``` fix A B :: nat ``` chaieb@26123 ` 178` ``` assume H: "\n. f n \ f (Suc n)" "A \ B" ``` chaieb@26123 ` 179` ``` hence "\k. B = A + k" apply - apply (thin_tac "\n. f n \ f (Suc n)") ``` chaieb@26123 ` 180` ``` by presburger ``` chaieb@26123 ` 181` ``` then obtain k where k: "B = A + k" by blast ``` chaieb@26123 ` 182` ``` {fix a k ``` chaieb@26123 ` 183` ``` have "f a \ f (a + k)" ``` chaieb@26123 ` 184` ``` proof (induct k) ``` chaieb@26123 ` 185` ``` case 0 thus ?case by simp ``` chaieb@26123 ` 186` ``` next ``` chaieb@26123 ` 187` ``` case (Suc k) ``` chaieb@26123 ` 188` ``` from Suc.hyps H(1)[rule_format, of "a + k"] show ?case by simp ``` chaieb@26123 ` 189` ``` qed} ``` chaieb@26123 ` 190` ``` with k show "f A \ f B" by blast ``` chaieb@26123 ` 191` ```qed ``` chaieb@26123 ` 192` chaieb@26123 ` 193` ```text{* for any sequence, there is a mootonic subsequence *} ``` chaieb@26123 ` 194` ```lemma seq_monosub: "\f. subseq f \ monoseq (\ n. (s (f n)))" ``` chaieb@26123 ` 195` ```proof- ``` chaieb@26123 ` 196` ``` {assume H: "\n. \p >n. \ m\p. s m \ s p" ``` chaieb@26123 ` 197` ``` let ?P = "\ p n. p > n \ (\m \ p. s m \ s p)" ``` chaieb@26123 ` 198` ``` from num_Axiom[of "SOME p. ?P p 0" "\p n. SOME p. ?P p n"] ``` chaieb@26123 ` 199` ``` obtain f where f: "f 0 = (SOME p. ?P p 0)" "\n. f (Suc n) = (SOME p. ?P p (f n))" by blast ``` chaieb@26123 ` 200` ``` have "?P (f 0) 0" unfolding f(1) some_eq_ex[of "\p. ?P p 0"] ``` chaieb@26123 ` 201` ``` using H apply - ``` chaieb@26123 ` 202` ``` apply (erule allE[where x=0], erule exE, rule_tac x="p" in exI) ``` chaieb@26123 ` 203` ``` unfolding order_le_less by blast ``` chaieb@26123 ` 204` ``` hence f0: "f 0 > 0" "\m \ f 0. s m \ s (f 0)" by blast+ ``` chaieb@26123 ` 205` ``` {fix n ``` chaieb@26123 ` 206` ``` have "?P (f (Suc n)) (f n)" ``` chaieb@26123 ` 207` ``` unfolding f(2)[rule_format, of n] some_eq_ex[of "\p. ?P p (f n)"] ``` chaieb@26123 ` 208` ``` using H apply - ``` chaieb@26123 ` 209` ``` apply (erule allE[where x="f n"], erule exE, rule_tac x="p" in exI) ``` chaieb@26123 ` 210` ``` unfolding order_le_less by blast ``` chaieb@26123 ` 211` ``` hence "f (Suc n) > f n" "\m \ f (Suc n). s m \ s (f (Suc n))" by blast+} ``` chaieb@26123 ` 212` ``` note fSuc = this ``` chaieb@26123 ` 213` ``` {fix p q assume pq: "p \ f q" ``` chaieb@26123 ` 214` ``` have "s p \ s(f(q))" using f0(2)[rule_format, of p] pq fSuc ``` chaieb@26123 ` 215` ``` by (cases q, simp_all) } ``` chaieb@26123 ` 216` ``` note pqth = this ``` chaieb@26123 ` 217` ``` {fix q ``` chaieb@26123 ` 218` ``` have "f (Suc q) > f q" apply (induct q) ``` chaieb@26123 ` 219` ``` using f0(1) fSuc(1)[of 0] apply simp by (rule fSuc(1))} ``` chaieb@26123 ` 220` ``` note fss = this ``` chaieb@26123 ` 221` ``` from fss have th1: "subseq f" unfolding subseq_Suc_iff .. ``` chaieb@26123 ` 222` ``` {fix a b ``` chaieb@26123 ` 223` ``` have "f a \ f (a + b)" ``` chaieb@26123 ` 224` ``` proof(induct b) ``` chaieb@26123 ` 225` ``` case 0 thus ?case by simp ``` chaieb@26123 ` 226` ``` next ``` chaieb@26123 ` 227` ``` case (Suc b) ``` chaieb@26123 ` 228` ``` from fSuc(1)[of "a + b"] Suc.hyps show ?case by simp ``` chaieb@26123 ` 229` ``` qed} ``` chaieb@26123 ` 230` ``` note fmon0 = this ``` chaieb@26123 ` 231` ``` have "monoseq (\n. s (f n))" ``` chaieb@26123 ` 232` ``` proof- ``` chaieb@26123 ` 233` ``` {fix n ``` chaieb@26123 ` 234` ``` have "s (f n) \ s (f (Suc n))" ``` chaieb@26123 ` 235` ``` proof(cases n) ``` chaieb@26123 ` 236` ``` case 0 ``` chaieb@26123 ` 237` ``` assume n0: "n = 0" ``` chaieb@26123 ` 238` ``` from fSuc(1)[of 0] have th0: "f 0 \ f (Suc 0)" by simp ``` chaieb@26123 ` 239` ``` from f0(2)[rule_format, OF th0] show ?thesis using n0 by simp ``` chaieb@26123 ` 240` ``` next ``` chaieb@26123 ` 241` ``` case (Suc m) ``` chaieb@26123 ` 242` ``` assume m: "n = Suc m" ``` chaieb@26123 ` 243` ``` from fSuc(1)[of n] m have th0: "f (Suc m) \ f (Suc (Suc m))" by simp ``` chaieb@26123 ` 244` ``` from m fSuc(2)[rule_format, OF th0] show ?thesis by simp ``` chaieb@26123 ` 245` ``` qed} ``` chaieb@26123 ` 246` ``` thus "monoseq (\n. s (f n))" unfolding monoseq_Suc by blast ``` chaieb@26123 ` 247` ``` qed ``` chaieb@26123 ` 248` ``` with th1 have ?thesis by blast} ``` chaieb@26123 ` 249` ``` moreover ``` chaieb@26123 ` 250` ``` {fix N assume N: "\p >N. \ m\p. s m > s p" ``` chaieb@26123 ` 251` ``` {fix p assume p: "p \ Suc N" ``` chaieb@26123 ` 252` ``` hence pN: "p > N" by arith with N obtain m where m: "m \ p" "s m > s p" by blast ``` chaieb@26123 ` 253` ``` have "m \ p" using m(2) by auto ``` chaieb@26123 ` 254` ``` with m have "\m>p. s p < s m" by - (rule exI[where x=m], auto)} ``` chaieb@26123 ` 255` ``` note th0 = this ``` chaieb@26123 ` 256` ``` let ?P = "\m x. m > x \ s x < s m" ``` chaieb@26123 ` 257` ``` from num_Axiom[of "SOME x. ?P x (Suc N)" "\m x. SOME y. ?P y x"] ``` chaieb@26123 ` 258` ``` obtain f where f: "f 0 = (SOME x. ?P x (Suc N))" ``` chaieb@26123 ` 259` ``` "\n. f (Suc n) = (SOME m. ?P m (f n))" by blast ``` chaieb@26123 ` 260` ``` have "?P (f 0) (Suc N)" unfolding f(1) some_eq_ex[of "\p. ?P p (Suc N)"] ``` chaieb@26123 ` 261` ``` using N apply - ``` chaieb@26123 ` 262` ``` apply (erule allE[where x="Suc N"], clarsimp) ``` chaieb@26123 ` 263` ``` apply (rule_tac x="m" in exI) ``` chaieb@26123 ` 264` ``` apply auto ``` chaieb@26123 ` 265` ``` apply (subgoal_tac "Suc N \ m") ``` chaieb@26123 ` 266` ``` apply simp ``` chaieb@26123 ` 267` ``` apply (rule ccontr, simp) ``` chaieb@26123 ` 268` ``` done ``` chaieb@26123 ` 269` ``` hence f0: "f 0 > Suc N" "s (Suc N) < s (f 0)" by blast+ ``` chaieb@26123 ` 270` ``` {fix n ``` chaieb@26123 ` 271` ``` have "f n > N \ ?P (f (Suc n)) (f n)" ``` chaieb@26123 ` 272` ``` unfolding f(2)[rule_format, of n] some_eq_ex[of "\p. ?P p (f n)"] ``` chaieb@26123 ` 273` ``` proof (induct n) ``` chaieb@26123 ` 274` ``` case 0 thus ?case ``` chaieb@26123 ` 275` ``` using f0 N apply auto ``` chaieb@26123 ` 276` ``` apply (erule allE[where x="f 0"], clarsimp) ``` chaieb@26123 ` 277` ``` apply (rule_tac x="m" in exI, simp) ``` chaieb@26123 ` 278` ``` by (subgoal_tac "f 0 \ m", auto) ``` chaieb@26123 ` 279` ``` next ``` chaieb@26123 ` 280` ``` case (Suc n) ``` chaieb@26123 ` 281` ``` from Suc.hyps have Nfn: "N < f n" by blast ``` chaieb@26123 ` 282` ``` from Suc.hyps obtain m where m: "m > f n" "s (f n) < s m" by blast ``` chaieb@26123 ` 283` ``` with Nfn have mN: "m > N" by arith ``` chaieb@26123 ` 284` ``` note key = Suc.hyps[unfolded some_eq_ex[of "\p. ?P p (f n)", symmetric] f(2)[rule_format, of n, symmetric]] ``` chaieb@26123 ` 285` ``` ``` chaieb@26123 ` 286` ``` from key have th0: "f (Suc n) > N" by simp ``` chaieb@26123 ` 287` ``` from N[rule_format, OF th0] ``` chaieb@26123 ` 288` ``` obtain m' where m': "m' \ f (Suc n)" "s (f (Suc n)) < s m'" by blast ``` chaieb@26123 ` 289` ``` have "m' \ f (Suc (n))" apply (rule ccontr) using m'(2) by auto ``` chaieb@26123 ` 290` ``` hence "m' > f (Suc n)" using m'(1) by simp ``` chaieb@26123 ` 291` ``` with key m'(2) show ?case by auto ``` chaieb@26123 ` 292` ``` qed} ``` chaieb@26123 ` 293` ``` note fSuc = this ``` chaieb@26123 ` 294` ``` {fix n ``` chaieb@26123 ` 295` ``` have "f n \ Suc N \ f(Suc n) > f n \ s(f n) < s(f(Suc n))" using fSuc[of n] by auto ``` chaieb@26123 ` 296` ``` hence "f n \ Suc N" "f(Suc n) > f n" "s(f n) < s(f(Suc n))" by blast+} ``` chaieb@26123 ` 297` ``` note thf = this ``` chaieb@26123 ` 298` ``` have sqf: "subseq f" unfolding subseq_Suc_iff using thf by simp ``` chaieb@26123 ` 299` ``` have "monoseq (\n. s (f n))" unfolding monoseq_Suc using thf ``` chaieb@26123 ` 300` ``` apply - ``` chaieb@26123 ` 301` ``` apply (rule disjI1) ``` chaieb@26123 ` 302` ``` apply auto ``` chaieb@26123 ` 303` ``` apply (rule order_less_imp_le) ``` chaieb@26123 ` 304` ``` apply blast ``` chaieb@26123 ` 305` ``` done ``` chaieb@26123 ` 306` ``` then have ?thesis using sqf by blast} ``` chaieb@26123 ` 307` ``` ultimately show ?thesis unfolding linorder_not_less[symmetric] by blast ``` chaieb@26123 ` 308` ```qed ``` chaieb@26123 ` 309` chaieb@26123 ` 310` ```lemma seq_suble: assumes sf: "subseq f" shows "n \ f n" ``` chaieb@26123 ` 311` ```proof(induct n) ``` chaieb@26123 ` 312` ``` case 0 thus ?case by simp ``` chaieb@26123 ` 313` ```next ``` chaieb@26123 ` 314` ``` case (Suc n) ``` chaieb@26123 ` 315` ``` from sf[unfolded subseq_Suc_iff, rule_format, of n] Suc.hyps ``` chaieb@26123 ` 316` ``` have "n < f (Suc n)" by arith ``` chaieb@26123 ` 317` ``` thus ?case by arith ``` chaieb@26123 ` 318` ```qed ``` chaieb@26123 ` 319` huffman@27445 ` 320` ```subsection {* Fundamental theorem of algebra *} ``` chaieb@26123 ` 321` ```lemma unimodular_reduce_norm: ``` chaieb@26123 ` 322` ``` assumes md: "cmod z = 1" ``` chaieb@26123 ` 323` ``` shows "cmod (z + 1) < 1 \ cmod (z - 1) < 1 \ cmod (z + ii) < 1 \ cmod (z - ii) < 1" ``` chaieb@26123 ` 324` ```proof- ``` chaieb@26123 ` 325` ``` obtain x y where z: "z = Complex x y " by (cases z, auto) ``` chaieb@26123 ` 326` ``` from md z have xy: "x^2 + y^2 = 1" by (simp add: cmod_def) ``` chaieb@26123 ` 327` ``` {assume C: "cmod (z + 1) \ 1" "cmod (z - 1) \ 1" "cmod (z + ii) \ 1" "cmod (z - ii) \ 1" ``` chaieb@26123 ` 328` ``` from C z xy have "2*x \ 1" "2*x \ -1" "2*y \ 1" "2*y \ -1" ``` chaieb@26123 ` 329` ``` by (simp_all add: cmod_def power2_eq_square ring_simps) ``` chaieb@26123 ` 330` ``` hence "abs (2*x) \ 1" "abs (2*y) \ 1" by simp_all ``` chaieb@26123 ` 331` ``` hence "(abs (2 * x))^2 <= 1^2" "(abs (2 * y)) ^2 <= 1^2" ``` chaieb@26123 ` 332` ``` by - (rule power_mono, simp, simp)+ ``` chaieb@26123 ` 333` ``` hence th0: "4*x^2 \ 1" "4*y^2 \ 1" ``` chaieb@26123 ` 334` ``` by (simp_all add: power2_abs power_mult_distrib) ``` chaieb@26123 ` 335` ``` from add_mono[OF th0] xy have False by simp } ``` chaieb@26123 ` 336` ``` thus ?thesis unfolding linorder_not_le[symmetric] by blast ``` chaieb@26123 ` 337` ```qed ``` chaieb@26123 ` 338` wenzelm@26135 ` 339` ```text{* Hence we can always reduce modulus of @{text "1 + b z^n"} if nonzero *} ``` chaieb@26123 ` 340` ```lemma reduce_poly_simple: ``` chaieb@26123 ` 341` ``` assumes b: "b \ 0" and n: "n\0" ``` chaieb@26123 ` 342` ``` shows "\z. cmod (1 + b * z^n) < 1" ``` chaieb@26123 ` 343` ```using n ``` chaieb@26123 ` 344` ```proof(induct n rule: nat_less_induct) ``` chaieb@26123 ` 345` ``` fix n ``` chaieb@26123 ` 346` ``` assume IH: "\m 0 \ (\z. cmod (1 + b * z ^ m) < 1)" and n: "n \ 0" ``` chaieb@26123 ` 347` ``` let ?P = "\z n. cmod (1 + b * z ^ n) < 1" ``` chaieb@26123 ` 348` ``` {assume e: "even n" ``` chaieb@26123 ` 349` ``` hence "\m. n = 2*m" by presburger ``` chaieb@26123 ` 350` ``` then obtain m where m: "n = 2*m" by blast ``` chaieb@26123 ` 351` ``` from n m have "m\0" "m < n" by presburger+ ``` chaieb@26123 ` 352` ``` with IH[rule_format, of m] obtain z where z: "?P z m" by blast ``` chaieb@26123 ` 353` ``` from z have "?P (csqrt z) n" by (simp add: m power_mult csqrt) ``` chaieb@26123 ` 354` ``` hence "\z. ?P z n" ..} ``` chaieb@26123 ` 355` ``` moreover ``` chaieb@26123 ` 356` ``` {assume o: "odd n" ``` chaieb@26123 ` 357` ``` from b have b': "b^2 \ 0" unfolding power2_eq_square by simp ``` chaieb@26123 ` 358` ``` have "Im (inverse b) * (Im (inverse b) * \Im b * Im b + Re b * Re b\) + ``` chaieb@26123 ` 359` ``` Re (inverse b) * (Re (inverse b) * \Im b * Im b + Re b * Re b\) = ``` chaieb@26123 ` 360` ``` ((Re (inverse b))^2 + (Im (inverse b))^2) * \Im b * Im b + Re b * Re b\" by algebra ``` chaieb@26123 ` 361` ``` also have "\ = cmod (inverse b) ^2 * cmod b ^ 2" ``` chaieb@26123 ` 362` ``` apply (simp add: cmod_def) using realpow_two_le_add_order[of "Re b" "Im b"] ``` chaieb@26123 ` 363` ``` by (simp add: power2_eq_square) ``` chaieb@26123 ` 364` ``` finally ``` chaieb@26123 ` 365` ``` have th0: "Im (inverse b) * (Im (inverse b) * \Im b * Im b + Re b * Re b\) + ``` chaieb@26123 ` 366` ``` Re (inverse b) * (Re (inverse b) * \Im b * Im b + Re b * Re b\) = ``` chaieb@26123 ` 367` ``` 1" ``` huffman@27514 ` 368` ``` apply (simp add: power2_eq_square norm_mult[symmetric] norm_inverse[symmetric]) ``` chaieb@26123 ` 369` ``` using right_inverse[OF b'] ``` chaieb@26123 ` 370` ``` by (simp add: power2_eq_square[symmetric] power_inverse[symmetric] ring_simps) ``` chaieb@26123 ` 371` ``` have th0: "cmod (complex_of_real (cmod b) / b) = 1" ``` chaieb@26123 ` 372` ``` apply (simp add: complex_Re_mult cmod_def power2_eq_square Re_complex_of_real Im_complex_of_real divide_inverse ring_simps ) ``` chaieb@26123 ` 373` ``` by (simp add: real_sqrt_mult[symmetric] th0) ``` chaieb@26123 ` 374` ``` from o have "\m. n = Suc (2*m)" by presburger+ ``` chaieb@26123 ` 375` ``` then obtain m where m: "n = Suc (2*m)" by blast ``` chaieb@26123 ` 376` ``` from unimodular_reduce_norm[OF th0] o ``` chaieb@26123 ` 377` ``` have "\v. cmod (complex_of_real (cmod b) / b + v^n) < 1" ``` chaieb@26123 ` 378` ``` apply (cases "cmod (complex_of_real (cmod b) / b + 1) < 1", rule_tac x="1" in exI, simp) ``` chaieb@26123 ` 379` ``` apply (cases "cmod (complex_of_real (cmod b) / b - 1) < 1", rule_tac x="-1" in exI, simp add: diff_def) ``` chaieb@26123 ` 380` ``` apply (cases "cmod (complex_of_real (cmod b) / b + ii) < 1") ``` chaieb@26123 ` 381` ``` apply (cases "even m", rule_tac x="ii" in exI, simp add: m power_mult) ``` chaieb@26123 ` 382` ``` apply (rule_tac x="- ii" in exI, simp add: m power_mult) ``` chaieb@26123 ` 383` ``` apply (cases "even m", rule_tac x="- ii" in exI, simp add: m power_mult diff_def) ``` chaieb@26123 ` 384` ``` apply (rule_tac x="ii" in exI, simp add: m power_mult diff_def) ``` chaieb@26123 ` 385` ``` done ``` chaieb@26123 ` 386` ``` then obtain v where v: "cmod (complex_of_real (cmod b) / b + v^n) < 1" by blast ``` chaieb@26123 ` 387` ``` let ?w = "v / complex_of_real (root n (cmod b))" ``` chaieb@26123 ` 388` ``` from odd_real_root_pow[OF o, of "cmod b"] ``` chaieb@26123 ` 389` ``` have th1: "?w ^ n = v^n / complex_of_real (cmod b)" ``` chaieb@26123 ` 390` ``` by (simp add: power_divide complex_of_real_power) ``` huffman@27514 ` 391` ``` have th2:"cmod (complex_of_real (cmod b) / b) = 1" using b by (simp add: norm_divide) ``` chaieb@26123 ` 392` ``` hence th3: "cmod (complex_of_real (cmod b) / b) \ 0" by simp ``` chaieb@26123 ` 393` ``` have th4: "cmod (complex_of_real (cmod b) / b) * ``` chaieb@26123 ` 394` ``` cmod (1 + b * (v ^ n / complex_of_real (cmod b))) ``` chaieb@26123 ` 395` ``` < cmod (complex_of_real (cmod b) / b) * 1" ``` huffman@27514 ` 396` ``` apply (simp only: norm_mult[symmetric] right_distrib) ``` chaieb@26123 ` 397` ``` using b v by (simp add: th2) ``` chaieb@26123 ` 398` chaieb@26123 ` 399` ``` from mult_less_imp_less_left[OF th4 th3] ``` chaieb@26123 ` 400` ``` have "?P ?w n" unfolding th1 . ``` chaieb@26123 ` 401` ``` hence "\z. ?P z n" .. } ``` chaieb@26123 ` 402` ``` ultimately show "\z. ?P z n" by blast ``` chaieb@26123 ` 403` ```qed ``` chaieb@26123 ` 404` chaieb@26123 ` 405` chaieb@26123 ` 406` ```text{* Bolzano-Weierstrass type property for closed disc in complex plane. *} ``` chaieb@26123 ` 407` chaieb@26123 ` 408` ```lemma metric_bound_lemma: "cmod (x - y) <= \Re x - Re y\ + \Im x - Im y\" ``` chaieb@26123 ` 409` ``` using real_sqrt_sum_squares_triangle_ineq[of "Re x - Re y" 0 0 "Im x - Im y" ] ``` chaieb@26123 ` 410` ``` unfolding cmod_def by simp ``` chaieb@26123 ` 411` chaieb@26123 ` 412` ```lemma bolzano_weierstrass_complex_disc: ``` chaieb@26123 ` 413` ``` assumes r: "\n. cmod (s n) \ r" ``` chaieb@26123 ` 414` ``` shows "\f z. subseq f \ (\e >0. \N. \n \ N. cmod (s (f n) - z) < e)" ``` chaieb@26123 ` 415` ```proof- ``` chaieb@26123 ` 416` ``` from seq_monosub[of "Re o s"] ``` chaieb@26123 ` 417` ``` obtain f g where f: "subseq f" "monoseq (\n. Re (s (f n)))" ``` chaieb@26123 ` 418` ``` unfolding o_def by blast ``` chaieb@26123 ` 419` ``` from seq_monosub[of "Im o s o f"] ``` chaieb@26123 ` 420` ``` obtain g where g: "subseq g" "monoseq (\n. Im (s(f(g n))))" unfolding o_def by blast ``` chaieb@26123 ` 421` ``` let ?h = "f o g" ``` huffman@27514 ` 422` ``` from r[rule_format, of 0] have rp: "r \ 0" using norm_ge_zero[of "s 0"] by arith ``` chaieb@26123 ` 423` ``` have th:"\n. r + 1 \ \ Re (s n)\" ``` chaieb@26123 ` 424` ``` proof ``` chaieb@26123 ` 425` ``` fix n ``` chaieb@26123 ` 426` ``` from abs_Re_le_cmod[of "s n"] r[rule_format, of n] show "\Re (s n)\ \ r + 1" by arith ``` chaieb@26123 ` 427` ``` qed ``` chaieb@26123 ` 428` ``` have conv1: "convergent (\n. Re (s ( f n)))" ``` chaieb@26123 ` 429` ``` apply (rule Bseq_monoseq_convergent) ``` chaieb@26123 ` 430` ``` apply (simp add: Bseq_def) ``` chaieb@26123 ` 431` ``` apply (rule exI[where x= "r + 1"]) ``` chaieb@26123 ` 432` ``` using th rp apply simp ``` chaieb@26123 ` 433` ``` using f(2) . ``` chaieb@26123 ` 434` ``` have th:"\n. r + 1 \ \ Im (s n)\" ``` chaieb@26123 ` 435` ``` proof ``` chaieb@26123 ` 436` ``` fix n ``` chaieb@26123 ` 437` ``` from abs_Im_le_cmod[of "s n"] r[rule_format, of n] show "\Im (s n)\ \ r + 1" by arith ``` chaieb@26123 ` 438` ``` qed ``` chaieb@26123 ` 439` chaieb@26123 ` 440` ``` have conv2: "convergent (\n. Im (s (f (g n))))" ``` chaieb@26123 ` 441` ``` apply (rule Bseq_monoseq_convergent) ``` chaieb@26123 ` 442` ``` apply (simp add: Bseq_def) ``` chaieb@26123 ` 443` ``` apply (rule exI[where x= "r + 1"]) ``` chaieb@26123 ` 444` ``` using th rp apply simp ``` chaieb@26123 ` 445` ``` using g(2) . ``` chaieb@26123 ` 446` chaieb@26123 ` 447` ``` from conv1[unfolded convergent_def] obtain x where "LIMSEQ (\n. Re (s (f n))) x" ``` chaieb@26123 ` 448` ``` by blast ``` chaieb@26123 ` 449` ``` hence x: "\r>0. \n0. \n\n0. \ Re (s (f n)) - x \ < r" ``` chaieb@26123 ` 450` ``` unfolding LIMSEQ_def real_norm_def . ``` chaieb@26123 ` 451` chaieb@26123 ` 452` ``` from conv2[unfolded convergent_def] obtain y where "LIMSEQ (\n. Im (s (f (g n)))) y" ``` chaieb@26123 ` 453` ``` by blast ``` chaieb@26123 ` 454` ``` hence y: "\r>0. \n0. \n\n0. \ Im (s (f (g n))) - y \ < r" ``` chaieb@26123 ` 455` ``` unfolding LIMSEQ_def real_norm_def . ``` chaieb@26123 ` 456` ``` let ?w = "Complex x y" ``` chaieb@26123 ` 457` ``` from f(1) g(1) have hs: "subseq ?h" unfolding subseq_def by auto ``` chaieb@26123 ` 458` ``` {fix e assume ep: "e > (0::real)" ``` chaieb@26123 ` 459` ``` hence e2: "e/2 > 0" by simp ``` chaieb@26123 ` 460` ``` from x[rule_format, OF e2] y[rule_format, OF e2] ``` chaieb@26123 ` 461` ``` 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 ` 462` ``` {fix n assume nN12: "n \ N1 + N2" ``` chaieb@26123 ` 463` ``` hence nN1: "g n \ N1" and nN2: "n \ N2" using seq_suble[OF g(1), of n] by arith+ ``` chaieb@26123 ` 464` ``` from add_strict_mono[OF N1[rule_format, OF nN1] N2[rule_format, OF nN2]] ``` chaieb@26123 ` 465` ``` have "cmod (s (?h n) - ?w) < e" ``` chaieb@26123 ` 466` ``` using metric_bound_lemma[of "s (f (g n))" ?w] by simp } ``` chaieb@26123 ` 467` ``` hence "\N. \n\N. cmod (s (?h n) - ?w) < e" by blast } ``` chaieb@26123 ` 468` ``` with hs show ?thesis by blast ``` chaieb@26123 ` 469` ```qed ``` chaieb@26123 ` 470` chaieb@26123 ` 471` ```text{* Polynomial is continuous. *} ``` chaieb@26123 ` 472` chaieb@26123 ` 473` ```lemma poly_cont: ``` chaieb@26123 ` 474` ``` assumes ep: "e > 0" ``` chaieb@26123 ` 475` ``` shows "\d >0. \w. 0 < cmod (w - z) \ cmod (w - z) < d \ cmod (poly p w - poly p z) < e" ``` chaieb@26123 ` 476` ```proof- ``` chaieb@26123 ` 477` ``` from poly_offset[of p z] obtain q where q: "length q = length p" "\x. poly q x = poly p (z + x)" by blast ``` chaieb@26123 ` 478` ``` {fix w ``` chaieb@26123 ` 479` ``` note q(2)[of "w - z", simplified]} ``` chaieb@26123 ` 480` ``` note th = this ``` chaieb@26123 ` 481` ``` show ?thesis unfolding th[symmetric] ``` chaieb@26123 ` 482` ``` proof(induct q) ``` chaieb@26123 ` 483` ``` case Nil thus ?case using ep by auto ``` chaieb@26123 ` 484` ``` next ``` chaieb@26123 ` 485` ``` case (Cons c cs) ``` chaieb@26123 ` 486` ``` from poly_bound_exists[of 1 "cs"] ``` chaieb@26123 ` 487` ``` obtain m where m: "m > 0" "\z. cmod z \ 1 \ cmod (poly cs z) \ m" by blast ``` chaieb@26123 ` 488` ``` from ep m(1) have em0: "e/m > 0" by (simp add: field_simps) ``` chaieb@26123 ` 489` ``` have one0: "1 > (0::real)" by arith ``` chaieb@26123 ` 490` ``` from real_lbound_gt_zero[OF one0 em0] ``` chaieb@26123 ` 491` ``` obtain d where d: "d >0" "d < 1" "d < e / m" by blast ``` chaieb@26123 ` 492` ``` from d(1,3) m(1) have dm: "d*m > 0" "d*m < e" ``` chaieb@26123 ` 493` ``` by (simp_all add: field_simps real_mult_order) ``` chaieb@26123 ` 494` ``` show ?case ``` huffman@27514 ` 495` ``` proof(rule ex_forward[OF real_lbound_gt_zero[OF one0 em0]], clarsimp simp add: norm_mult) ``` chaieb@26123 ` 496` ``` fix d w ``` chaieb@26123 ` 497` ``` assume H: "d > 0" "d < 1" "d < e/m" "w\z" "cmod (w-z) < d" ``` chaieb@26123 ` 498` ``` hence d1: "cmod (w-z) \ 1" "d \ 0" by simp_all ``` chaieb@26123 ` 499` ``` from H(3) m(1) have dme: "d*m < e" by (simp add: field_simps) ``` chaieb@26123 ` 500` ``` from H have th: "cmod (w-z) \ d" by simp ``` huffman@27514 ` 501` ``` from mult_mono[OF th m(2)[OF d1(1)] d1(2) norm_ge_zero] dme ``` chaieb@26123 ` 502` ``` show "cmod (w - z) * cmod (poly cs (w - z)) < e" by simp ``` chaieb@26123 ` 503` ``` qed ``` chaieb@26123 ` 504` ``` qed ``` chaieb@26123 ` 505` ```qed ``` chaieb@26123 ` 506` chaieb@26123 ` 507` ```text{* Hence a polynomial attains minimum on a closed disc ``` chaieb@26123 ` 508` ``` in the complex plane. *} ``` chaieb@26123 ` 509` ```lemma poly_minimum_modulus_disc: ``` chaieb@26123 ` 510` ``` "\z. \w. cmod w \ r \ cmod (poly p z) \ cmod (poly p w)" ``` chaieb@26123 ` 511` ```proof- ``` chaieb@26123 ` 512` ``` {assume "\ r \ 0" hence ?thesis unfolding linorder_not_le ``` chaieb@26123 ` 513` ``` apply - ``` chaieb@26123 ` 514` ``` apply (rule exI[where x=0]) ``` chaieb@26123 ` 515` ``` apply auto ``` chaieb@26123 ` 516` ``` apply (subgoal_tac "cmod w < 0") ``` chaieb@26123 ` 517` ``` apply simp ``` chaieb@26123 ` 518` ``` apply arith ``` chaieb@26123 ` 519` ``` done } ``` chaieb@26123 ` 520` ``` moreover ``` chaieb@26123 ` 521` ``` {assume rp: "r \ 0" ``` chaieb@26123 ` 522` ``` from rp have "cmod 0 \ r \ cmod (poly p 0) = - (- cmod (poly p 0))" by simp ``` chaieb@26123 ` 523` ``` hence mth1: "\x z. cmod z \ r \ cmod (poly p z) = - x" by blast ``` chaieb@26123 ` 524` ``` {fix x z ``` chaieb@26123 ` 525` ``` assume H: "cmod z \ r" "cmod (poly p z) = - x" "\x < 1" ``` chaieb@26123 ` 526` ``` hence "- x < 0 " by arith ``` huffman@27514 ` 527` ``` with H(2) norm_ge_zero[of "poly p z"] have False by simp } ``` chaieb@26123 ` 528` ``` then have mth2: "\z. \x. (\z. cmod z \ r \ cmod (poly p z) = - x) \ x < z" by blast ``` chaieb@26123 ` 529` ``` from real_sup_exists[OF mth1 mth2] obtain s where ``` chaieb@26123 ` 530` ``` s: "\y. (\x. (\z. cmod z \ r \ cmod (poly p z) = - x) \ y < x) \(y < s)" by blast ``` chaieb@26123 ` 531` ``` let ?m = "-s" ``` chaieb@26123 ` 532` ``` {fix y ``` chaieb@26123 ` 533` ``` from s[rule_format, of "-y"] have ``` chaieb@26123 ` 534` ``` "(\z x. cmod z \ r \ -(- cmod (poly p z)) < y) \ ?m < y" ``` chaieb@26123 ` 535` ``` unfolding minus_less_iff[of y ] equation_minus_iff by blast } ``` chaieb@26123 ` 536` ``` note s1 = this[unfolded minus_minus] ``` chaieb@26123 ` 537` ``` from s1[of ?m] have s1m: "\z x. cmod z \ r \ cmod (poly p z) \ ?m" ``` chaieb@26123 ` 538` ``` by auto ``` chaieb@26123 ` 539` ``` {fix n::nat ``` chaieb@26123 ` 540` ``` from s1[rule_format, of "?m + 1/real (Suc n)"] ``` chaieb@26123 ` 541` ``` have "\z. cmod z \ r \ cmod (poly p z) < - s + 1 / real (Suc n)" ``` chaieb@26123 ` 542` ``` by simp} ``` chaieb@26123 ` 543` ``` hence th: "\n. \z. cmod z \ r \ cmod (poly p z) < - s + 1 / real (Suc n)" .. ``` chaieb@26123 ` 544` ``` from choice[OF th] obtain g where ``` chaieb@26123 ` 545` ``` 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 ` 549` ``` by blast ``` chaieb@26123 ` 550` ``` {fix w ``` chaieb@26123 ` 551` ``` assume wr: "cmod w \ r" ``` chaieb@26123 ` 552` ``` let ?e = "\cmod (poly p z) - ?m\" ``` chaieb@26123 ` 553` ``` {assume e: "?e > 0" ``` chaieb@26123 ` 554` ``` hence e2: "?e/2 > 0" by simp ``` chaieb@26123 ` 555` ``` from poly_cont[OF e2, of z p] obtain d where ``` chaieb@26123 ` 556` ``` d: "d>0" "\w. 0 cmod(w - z) < d \ cmod(poly p w - poly p z) < ?e/2" by blast ``` chaieb@26123 ` 557` ``` {fix w assume w: "cmod (w - z) < d" ``` chaieb@26123 ` 558` ``` have "cmod(poly p w - poly p z) < ?e / 2" ``` chaieb@26123 ` 559` ``` using d(2)[rule_format, of w] w e by (cases "w=z", simp_all)} ``` chaieb@26123 ` 560` ``` note th1 = this ``` chaieb@26123 ` 561` ``` ``` chaieb@26123 ` 562` ``` from fz(2)[rule_format, OF d(1)] obtain N1 where ``` chaieb@26123 ` 563` ``` N1: "\n\N1. cmod (g (f n) - z) < d" by blast ``` chaieb@26123 ` 564` ``` from reals_Archimedean2[of "2/?e"] obtain N2::nat where ``` chaieb@26123 ` 565` ``` N2: "2/?e < real N2" by blast ``` chaieb@26123 ` 566` ``` have th2: "cmod(poly p (g(f(N1 + N2))) - poly p z) < ?e/2" ``` chaieb@26123 ` 567` ``` using N1[rule_format, of "N1 + N2"] th1 by simp ``` chaieb@26123 ` 568` ``` {fix a b e2 m :: real ``` chaieb@26123 ` 569` ``` have "a < e2 \ abs(b - m) < e2 \ 2 * e2 <= abs(b - m) + a ``` chaieb@26123 ` 570` ``` ==> False" by arith} ``` chaieb@26123 ` 571` ``` note th0 = this ``` chaieb@26123 ` 572` ``` have ath: ``` chaieb@26123 ` 573` ``` "\m x e. m <= x \ x < m + e ==> abs(x - m::real) < e" by arith ``` chaieb@26123 ` 574` ``` from s1m[OF g(1)[rule_format]] ``` chaieb@26123 ` 575` ``` have th31: "?m \ cmod(poly p (g (f (N1 + N2))))" . ``` chaieb@26123 ` 576` ``` from seq_suble[OF fz(1), of "N1+N2"] ``` chaieb@26123 ` 577` ``` have th00: "real (Suc (N1+N2)) \ real (Suc (f (N1+N2)))" by simp ``` chaieb@26123 ` 578` ``` have th000: "0 \ (1::real)" "(1::real) \ 1" "real (Suc (N1+N2)) > 0" ``` chaieb@26123 ` 579` ``` using N2 by auto ``` chaieb@26123 ` 580` ``` 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 ` 581` ``` from g(2)[rule_format, of "f (N1 + N2)"] ``` chaieb@26123 ` 582` ``` have th01:"cmod (poly p (g (f (N1 + N2)))) < - s + 1 / real (Suc (f (N1 + N2)))" . ``` chaieb@26123 ` 583` ``` from order_less_le_trans[OF th01 th00] ``` chaieb@26123 ` 584` ``` have th32: "cmod(poly p (g (f (N1 + N2)))) < ?m + (1/ real(Suc (N1 + N2)))" . ``` chaieb@26123 ` 585` ``` from N2 have "2/?e < real (Suc (N1 + N2))" by arith ``` chaieb@26123 ` 586` ``` with e2 less_imp_inverse_less[of "2/?e" "real (Suc (N1 + N2))"] ``` chaieb@26123 ` 587` ``` have "?e/2 > 1/ real (Suc (N1 + N2))" by (simp add: inverse_eq_divide) ``` chaieb@26123 ` 588` ``` with ath[OF th31 th32] ``` chaieb@26123 ` 589` ``` have thc1:"\cmod(poly p (g (f (N1 + N2)))) - ?m\< ?e/2" by arith ``` chaieb@26123 ` 590` ``` have ath2: "\(a::real) b c m. \a - b\ <= c ==> \b - m\ <= \a - m\ + c" ``` chaieb@26123 ` 591` ``` by arith ``` chaieb@26123 ` 592` ``` have th22: "\cmod (poly p (g (f (N1 + N2)))) - cmod (poly p z)\ ``` chaieb@26123 ` 593` ```\ cmod (poly p (g (f (N1 + N2))) - poly p z)" ``` huffman@27514 ` 594` ``` by (simp add: norm_triangle_ineq3) ``` chaieb@26123 ` 595` ``` from ath2[OF th22, of ?m] ``` chaieb@26123 ` 596` ``` 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 ` 597` ``` from th0[OF th2 thc1 thc2] have False .} ``` chaieb@26123 ` 598` ``` hence "?e = 0" by auto ``` chaieb@26123 ` 599` ``` then have "cmod (poly p z) = ?m" by simp ``` chaieb@26123 ` 600` ``` with s1m[OF wr] ``` chaieb@26123 ` 601` ``` have "cmod (poly p z) \ cmod (poly p w)" by simp } ``` chaieb@26123 ` 602` ``` hence ?thesis by blast} ``` chaieb@26123 ` 603` ``` ultimately show ?thesis by blast ``` chaieb@26123 ` 604` ```qed ``` chaieb@26123 ` 605` chaieb@26123 ` 606` ```lemma "(rcis (sqrt (abs r)) (a/2)) ^ 2 = rcis (abs r) a" ``` chaieb@26123 ` 607` ``` unfolding power2_eq_square ``` chaieb@26123 ` 608` ``` apply (simp add: rcis_mult) ``` chaieb@26123 ` 609` ``` apply (simp add: power2_eq_square[symmetric]) ``` chaieb@26123 ` 610` ``` done ``` chaieb@26123 ` 611` chaieb@26123 ` 612` ```lemma cispi: "cis pi = -1" ``` chaieb@26123 ` 613` ``` unfolding cis_def ``` chaieb@26123 ` 614` ``` by simp ``` chaieb@26123 ` 615` chaieb@26123 ` 616` ```lemma "(rcis (sqrt (abs r)) ((pi + a)/2)) ^ 2 = rcis (- abs r) a" ``` chaieb@26123 ` 617` ``` unfolding power2_eq_square ``` chaieb@26123 ` 618` ``` apply (simp add: rcis_mult add_divide_distrib) ``` chaieb@26123 ` 619` ``` apply (simp add: power2_eq_square[symmetric] rcis_def cispi cis_mult[symmetric]) ``` chaieb@26123 ` 620` ``` done ``` chaieb@26123 ` 621` chaieb@26123 ` 622` ```text {* Nonzero polynomial in z goes to infinity as z does. *} ``` chaieb@26123 ` 623` chaieb@26123 ` 624` ```instance complex::idom_char_0 by (intro_classes) ``` chaieb@26123 ` 625` ```instance complex :: recpower_idom_char_0 by intro_classes ``` chaieb@26123 ` 626` chaieb@26123 ` 627` ```lemma poly_infinity: ``` chaieb@26123 ` 628` ``` assumes ex: "list_ex (\c. c \ 0) p" ``` chaieb@26123 ` 629` ``` shows "\r. \z. r \ cmod z \ d \ cmod (poly (a#p) z)" ``` chaieb@26123 ` 630` ```using ex ``` chaieb@26123 ` 631` ```proof(induct p arbitrary: a d) ``` chaieb@26123 ` 632` ``` case (Cons c cs a d) ``` chaieb@26123 ` 633` ``` {assume H: "list_ex (\c. c\0) cs" ``` chaieb@26123 ` 634` ``` with Cons.hyps obtain r where r: "\z. r \ cmod z \ d + cmod a \ cmod (poly (c # cs) z)" by blast ``` chaieb@26123 ` 635` ``` let ?r = "1 + \r\" ``` chaieb@26123 ` 636` ``` {fix z assume h: "1 + \r\ \ cmod z" ``` chaieb@26123 ` 637` ``` have r0: "r \ cmod z" using h by arith ``` chaieb@26123 ` 638` ``` from r[rule_format, OF r0] ``` chaieb@26123 ` 639` ``` have th0: "d + cmod a \ 1 * cmod(poly (c#cs) z)" by arith ``` chaieb@26123 ` 640` ``` from h have z1: "cmod z \ 1" by arith ``` huffman@27514 ` 641` ``` from order_trans[OF th0 mult_right_mono[OF z1 norm_ge_zero[of "poly (c#cs) z"]]] ``` chaieb@26123 ` 642` ``` have th1: "d \ cmod(z * poly (c#cs) z) - cmod a" ``` huffman@27514 ` 643` ``` unfolding norm_mult by (simp add: ring_simps) ``` chaieb@26123 ` 644` ``` from complex_mod_triangle_sub[of "z * poly (c#cs) z" a] ``` chaieb@26123 ` 645` ``` have th2: "cmod(z * poly (c#cs) z) - cmod a \ cmod (poly (a#c#cs) z)" ``` chaieb@26123 ` 646` ``` by (simp add: diff_le_eq ring_simps) ``` chaieb@26123 ` 647` ``` from th1 th2 have "d \ cmod (poly (a#c#cs) z)" by arith} ``` chaieb@26123 ` 648` ``` hence ?case by blast} ``` chaieb@26123 ` 649` ``` moreover ``` chaieb@26123 ` 650` ``` {assume cs0: "\ (list_ex (\c. c \ 0) cs)" ``` chaieb@26123 ` 651` ``` with Cons.prems have c0: "c \ 0" by simp ``` chaieb@26123 ` 652` ``` from cs0 have cs0': "list_all (\c. c = 0) cs" ``` chaieb@26123 ` 653` ``` by (auto simp add: list_all_iff list_ex_iff) ``` chaieb@26123 ` 654` ``` {fix z ``` chaieb@26123 ` 655` ``` assume h: "(\d\ + cmod a) / cmod c \ cmod z" ``` chaieb@26123 ` 656` ``` from c0 have "cmod c > 0" by simp ``` chaieb@26123 ` 657` ``` from h c0 have th0: "\d\ + cmod a \ cmod (z*c)" ``` huffman@27514 ` 658` ``` by (simp add: field_simps norm_mult) ``` chaieb@26123 ` 659` ``` have ath: "\mzh mazh ma. mzh <= mazh + ma ==> abs(d) + ma <= mzh ==> d <= mazh" by arith ``` chaieb@26123 ` 660` ``` from complex_mod_triangle_sub[of "z*c" a ] ``` chaieb@26123 ` 661` ``` have th1: "cmod (z * c) \ cmod (a + z * c) + cmod a" ``` chaieb@26123 ` 662` ``` by (simp add: ring_simps) ``` chaieb@26123 ` 663` ``` from ath[OF th1 th0] have "d \ cmod (poly (a # c # cs) z)" ``` chaieb@26123 ` 664` ``` using poly_0[OF cs0'] by simp} ``` chaieb@26123 ` 665` ``` then have ?case by blast} ``` chaieb@26123 ` 666` ``` ultimately show ?case by blast ``` chaieb@26123 ` 667` ```qed simp ``` chaieb@26123 ` 668` chaieb@26123 ` 669` ```text {* Hence polynomial's modulus attains its minimum somewhere. *} ``` chaieb@26123 ` 670` ```lemma poly_minimum_modulus: ``` chaieb@26123 ` 671` ``` "\z.\w. cmod (poly p z) \ cmod (poly p w)" ``` chaieb@26123 ` 672` ```proof(induct p) ``` chaieb@26123 ` 673` ``` case (Cons c cs) ``` chaieb@26123 ` 674` ``` {assume cs0: "list_ex (\c. c \ 0) cs" ``` chaieb@26123 ` 675` ``` from poly_infinity[OF cs0, of "cmod (poly (c#cs) 0)" c] ``` chaieb@26123 ` 676` ``` obtain r where r: "\z. r \ cmod z \ cmod (poly (c # cs) 0) \ cmod (poly (c # cs) z)" by blast ``` chaieb@26123 ` 677` ``` have ath: "\z r. r \ cmod z \ cmod z \ \r\" by arith ``` chaieb@26123 ` 678` ``` from poly_minimum_modulus_disc[of "\r\" "c#cs"] ``` chaieb@26123 ` 679` ``` obtain v where v: "\w. cmod w \ \r\ \ cmod (poly (c # cs) v) \ cmod (poly (c # cs) w)" by blast ``` chaieb@26123 ` 680` ``` {fix z assume z: "r \ cmod z" ``` chaieb@26123 ` 681` ``` from v[of 0] r[OF z] ``` chaieb@26123 ` 682` ``` have "cmod (poly (c # cs) v) \ cmod (poly (c # cs) z)" ``` chaieb@26123 ` 683` ``` by simp } ``` chaieb@26123 ` 684` ``` note v0 = this ``` chaieb@26123 ` 685` ``` from v0 v ath[of r] have ?case by blast} ``` chaieb@26123 ` 686` ``` moreover ``` chaieb@26123 ` 687` ``` {assume cs0: "\ (list_ex (\c. c\0) cs)" ``` chaieb@26123 ` 688` ``` hence th:"list_all (\c. c = 0) cs" by (simp add: list_all_iff list_ex_iff) ``` chaieb@26123 ` 689` ``` from poly_0[OF th] Cons.hyps have ?case by simp} ``` chaieb@26123 ` 690` ``` ultimately show ?case by blast ``` chaieb@26123 ` 691` ```qed simp ``` chaieb@26123 ` 692` chaieb@26123 ` 693` ```text{* Constant function (non-syntactic characterization). *} ``` chaieb@26123 ` 694` ```definition "constant f = (\x y. f x = f y)" ``` chaieb@26123 ` 695` chaieb@26123 ` 696` ```lemma nonconstant_length: "\ (constant (poly p)) \ length p \ 2" ``` chaieb@26123 ` 697` ``` unfolding constant_def ``` chaieb@26123 ` 698` ``` apply (induct p, auto) ``` chaieb@26123 ` 699` ``` apply (unfold not_less[symmetric]) ``` chaieb@26123 ` 700` ``` apply simp ``` chaieb@26123 ` 701` ``` apply (rule ccontr) ``` chaieb@26123 ` 702` ``` apply auto ``` chaieb@26123 ` 703` ``` done ``` chaieb@26123 ` 704` ``` ``` chaieb@26123 ` 705` ```lemma poly_replicate_append: ``` chaieb@26123 ` 706` ``` "poly ((replicate n 0)@p) (x::'a::{recpower, comm_ring}) = x^n * poly p x" ``` chaieb@26123 ` 707` ``` by(induct n, auto simp add: power_Suc ring_simps) ``` chaieb@26123 ` 708` chaieb@26123 ` 709` ```text {* Decomposition of polynomial, skipping zero coefficients ``` chaieb@26123 ` 710` ``` after the first. *} ``` chaieb@26123 ` 711` chaieb@26123 ` 712` ```lemma poly_decompose_lemma: ``` chaieb@26123 ` 713` ``` assumes nz: "\(\z. z\0 \ poly p z = (0::'a::{recpower,idom}))" ``` chaieb@26123 ` 714` ``` shows "\k a q. a\0 \ Suc (length q + k) = length p \ ``` chaieb@26123 ` 715` ``` (\z. poly p z = z^k * poly (a#q) z)" ``` chaieb@26123 ` 716` ```using nz ``` chaieb@26123 ` 717` ```proof(induct p) ``` chaieb@26123 ` 718` ``` case Nil thus ?case by simp ``` chaieb@26123 ` 719` ```next ``` chaieb@26123 ` 720` ``` case (Cons c cs) ``` chaieb@26123 ` 721` ``` {assume c0: "c = 0" ``` chaieb@26123 ` 722` ``` ``` chaieb@26123 ` 723` ``` from Cons.hyps Cons.prems c0 have ?case apply auto ``` chaieb@26123 ` 724` ``` apply (rule_tac x="k+1" in exI) ``` chaieb@26123 ` 725` ``` apply (rule_tac x="a" in exI, clarsimp) ``` chaieb@26123 ` 726` ``` apply (rule_tac x="q" in exI) ``` chaieb@26123 ` 727` ``` by (auto simp add: power_Suc)} ``` chaieb@26123 ` 728` ``` moreover ``` chaieb@26123 ` 729` ``` {assume c0: "c\0" ``` chaieb@26123 ` 730` ``` hence ?case apply- ``` chaieb@26123 ` 731` ``` apply (rule exI[where x=0]) ``` chaieb@26123 ` 732` ``` apply (rule exI[where x=c], clarsimp) ``` chaieb@26123 ` 733` ``` apply (rule exI[where x=cs]) ``` chaieb@26123 ` 734` ``` apply auto ``` chaieb@26123 ` 735` ``` done} ``` chaieb@26123 ` 736` ``` ultimately show ?case by blast ``` chaieb@26123 ` 737` ```qed ``` chaieb@26123 ` 738` chaieb@26123 ` 739` ```lemma poly_decompose: ``` chaieb@26123 ` 740` ``` assumes nc: "~constant(poly p)" ``` chaieb@26123 ` 741` ``` shows "\k a q. a\(0::'a::{recpower,idom}) \ k\0 \ ``` chaieb@26123 ` 742` ``` length q + k + 1 = length p \ ``` chaieb@26123 ` 743` ``` (\z. poly p z = poly p 0 + z^k * poly (a#q) z)" ``` chaieb@26123 ` 744` ```using nc ``` chaieb@26123 ` 745` ```proof(induct p) ``` chaieb@26123 ` 746` ``` case Nil thus ?case by (simp add: constant_def) ``` chaieb@26123 ` 747` ```next ``` chaieb@26123 ` 748` ``` case (Cons c cs) ``` chaieb@26123 ` 749` ``` {assume C:"\z. z \ 0 \ poly cs z = 0" ``` chaieb@26123 ` 750` ``` {fix x y ``` chaieb@26123 ` 751` ``` from C have "poly (c#cs) x = poly (c#cs) y" by (cases "x=0", auto)} ``` chaieb@26123 ` 752` ``` with Cons.prems have False by (auto simp add: constant_def)} ``` chaieb@26123 ` 753` ``` hence th: "\ (\z. z \ 0 \ poly cs z = 0)" .. ``` chaieb@26123 ` 754` ``` from poly_decompose_lemma[OF th] ``` chaieb@26123 ` 755` ``` show ?case ``` chaieb@26123 ` 756` ``` apply clarsimp ``` chaieb@26123 ` 757` ``` apply (rule_tac x="k+1" in exI) ``` chaieb@26123 ` 758` ``` apply (rule_tac x="a" in exI) ``` chaieb@26123 ` 759` ``` apply simp ``` chaieb@26123 ` 760` ``` apply (rule_tac x="q" in exI) ``` chaieb@26123 ` 761` ``` apply (auto simp add: power_Suc) ``` chaieb@26123 ` 762` ``` done ``` chaieb@26123 ` 763` ```qed ``` chaieb@26123 ` 764` chaieb@26123 ` 765` ```text{* Fundamental theorem of algebral *} ``` chaieb@26123 ` 766` chaieb@26123 ` 767` ```lemma fundamental_theorem_of_algebra: ``` chaieb@26123 ` 768` ``` assumes nc: "~constant(poly p)" ``` chaieb@26123 ` 769` ``` shows "\z::complex. poly p z = 0" ``` chaieb@26123 ` 770` ```using nc ``` chaieb@26123 ` 771` ```proof(induct n\ "length p" arbitrary: p rule: nat_less_induct) ``` chaieb@26123 ` 772` ``` fix n fix p :: "complex list" ``` chaieb@26123 ` 773` ``` let ?p = "poly p" ``` chaieb@26123 ` 774` ``` assume H: "\mp. \ constant (poly p) \ m = length p \ (\(z::complex). poly p z = 0)" and nc: "\ constant ?p" and n: "n = length p" ``` chaieb@26123 ` 775` ``` let ?ths = "\z. ?p z = 0" ``` chaieb@26123 ` 776` chaieb@26123 ` 777` ``` from nonconstant_length[OF nc] have n2: "n\ 2" by (simp add: n) ``` chaieb@26123 ` 778` ``` from poly_minimum_modulus obtain c where ``` chaieb@26123 ` 779` ``` c: "\w. cmod (?p c) \ cmod (?p w)" by blast ``` chaieb@26123 ` 780` ``` {assume pc: "?p c = 0" hence ?ths by blast} ``` chaieb@26123 ` 781` ``` moreover ``` chaieb@26123 ` 782` ``` {assume pc0: "?p c \ 0" ``` chaieb@26123 ` 783` ``` from poly_offset[of p c] obtain q where ``` chaieb@26123 ` 784` ``` q: "length q = length p" "\x. poly q x = ?p (c+x)" by blast ``` chaieb@26123 ` 785` ``` {assume h: "constant (poly q)" ``` chaieb@26123 ` 786` ``` from q(2) have th: "\x. poly q (x - c) = ?p x" by auto ``` chaieb@26123 ` 787` ``` {fix x y ``` chaieb@26123 ` 788` ``` from th have "?p x = poly q (x - c)" by auto ``` chaieb@26123 ` 789` ``` also have "\ = poly q (y - c)" ``` chaieb@26123 ` 790` ``` using h unfolding constant_def by blast ``` chaieb@26123 ` 791` ``` also have "\ = ?p y" using th by auto ``` chaieb@26123 ` 792` ``` finally have "?p x = ?p y" .} ``` chaieb@26123 ` 793` ``` with nc have False unfolding constant_def by blast } ``` chaieb@26123 ` 794` ``` hence qnc: "\ constant (poly q)" by blast ``` chaieb@26123 ` 795` ``` from q(2) have pqc0: "?p c = poly q 0" by simp ``` chaieb@26123 ` 796` ``` from c pqc0 have cq0: "\w. cmod (poly q 0) \ cmod (?p w)" by simp ``` chaieb@26123 ` 797` ``` let ?a0 = "poly q 0" ``` chaieb@26123 ` 798` ``` from pc0 pqc0 have a00: "?a0 \ 0" by simp ``` chaieb@26123 ` 799` ``` from a00 ``` chaieb@26123 ` 800` ``` have qr: "\z. poly q z = poly (map (op * (inverse ?a0)) q) z * ?a0" ``` chaieb@26123 ` 801` ``` by (simp add: poly_cmult_map) ``` chaieb@26123 ` 802` ``` let ?r = "map (op * (inverse ?a0)) q" ``` chaieb@26123 ` 803` ``` have lgqr: "length q = length ?r" by simp ``` chaieb@26123 ` 804` ``` {assume h: "\x y. poly ?r x = poly ?r y" ``` chaieb@26123 ` 805` ``` {fix x y ``` chaieb@26123 ` 806` ``` from qr[rule_format, of x] ``` chaieb@26123 ` 807` ``` have "poly q x = poly ?r x * ?a0" by auto ``` chaieb@26123 ` 808` ``` also have "\ = poly ?r y * ?a0" using h by simp ``` chaieb@26123 ` 809` ``` also have "\ = poly q y" using qr[rule_format, of y] by simp ``` chaieb@26123 ` 810` ``` finally have "poly q x = poly q y" .} ``` chaieb@26123 ` 811` ``` with qnc have False unfolding constant_def by blast} ``` chaieb@26123 ` 812` ``` hence rnc: "\ constant (poly ?r)" unfolding constant_def by blast ``` chaieb@26123 ` 813` ``` from qr[rule_format, of 0] a00 have r01: "poly ?r 0 = 1" by auto ``` chaieb@26123 ` 814` ``` {fix w ``` chaieb@26123 ` 815` ``` have "cmod (poly ?r w) < 1 \ cmod (poly q w / ?a0) < 1" ``` chaieb@26123 ` 816` ``` using qr[rule_format, of w] a00 by simp ``` chaieb@26123 ` 817` ``` also have "\ \ cmod (poly q w) < cmod ?a0" ``` huffman@27514 ` 818` ``` using a00 unfolding norm_divide by (simp add: field_simps) ``` chaieb@26123 ` 819` ``` finally have "cmod (poly ?r w) < 1 \ cmod (poly q w) < cmod ?a0" .} ``` chaieb@26123 ` 820` ``` note mrmq_eq = this ``` chaieb@26123 ` 821` ``` from poly_decompose[OF rnc] obtain k a s where ``` chaieb@26123 ` 822` ``` kas: "a\0" "k\0" "length s + k + 1 = length ?r" ``` chaieb@26123 ` 823` ``` "\z. poly ?r z = poly ?r 0 + z^k* poly (a#s) z" by blast ``` chaieb@26123 ` 824` ``` {assume "k + 1 = n" ``` chaieb@26123 ` 825` ``` with kas(3) lgqr[symmetric] q(1) n[symmetric] have s0:"s=[]" by auto ``` chaieb@26123 ` 826` ``` {fix w ``` chaieb@26123 ` 827` ``` have "cmod (poly ?r w) = cmod (1 + a * w ^ k)" ``` chaieb@26123 ` 828` ``` using kas(4)[rule_format, of w] s0 r01 by (simp add: ring_simps)} ``` chaieb@26123 ` 829` ``` note hth = this [symmetric] ``` chaieb@26123 ` 830` ``` from reduce_poly_simple[OF kas(1,2)] ``` chaieb@26123 ` 831` ``` have "\w. cmod (poly ?r w) < 1" unfolding hth by blast} ``` chaieb@26123 ` 832` ``` moreover ``` chaieb@26123 ` 833` ``` {assume kn: "k+1 \ n" ``` chaieb@26123 ` 834` ``` from kn kas(3) q(1) n[symmetric] have k1n: "k + 1 < n" by simp ``` chaieb@26123 ` 835` ``` have th01: "\ constant (poly (1#((replicate (k - 1) 0)@[a])))" ``` chaieb@26123 ` 836` ``` unfolding constant_def poly_Nil poly_Cons poly_replicate_append ``` chaieb@26123 ` 837` ``` using kas(1) apply simp ``` chaieb@26123 ` 838` ``` by (rule exI[where x=0], rule exI[where x=1], simp) ``` chaieb@26123 ` 839` ``` from kas(2) have th02: "k+1 = length (1#((replicate (k - 1) 0)@[a]))" ``` chaieb@26123 ` 840` ``` by simp ``` chaieb@26123 ` 841` ``` from H[rule_format, OF k1n th01 th02] ``` chaieb@26123 ` 842` ``` obtain w where w: "1 + w^k * a = 0" ``` chaieb@26123 ` 843` ``` unfolding poly_Nil poly_Cons poly_replicate_append ``` chaieb@26123 ` 844` ``` using kas(2) by (auto simp add: power_Suc[symmetric, of _ "k - Suc 0"] ``` chaieb@26123 ` 845` ``` mult_assoc[of _ _ a, symmetric]) ``` chaieb@26123 ` 846` ``` from poly_bound_exists[of "cmod w" s] obtain m where ``` chaieb@26123 ` 847` ``` m: "m > 0" "\z. cmod z \ cmod w \ cmod (poly s z) \ m" by blast ``` chaieb@26123 ` 848` ``` have w0: "w\0" using kas(2) w by (auto simp add: power_0_left) ``` chaieb@26123 ` 849` ``` from w have "(1 + w ^ k * a) - 1 = 0 - 1" by simp ``` chaieb@26123 ` 850` ``` then have wm1: "w^k * a = - 1" by simp ``` chaieb@26123 ` 851` ``` have inv0: "0 < inverse (cmod w ^ (k + 1) * m)" ``` huffman@27514 ` 852` ``` using norm_ge_zero[of w] w0 m(1) ``` chaieb@26123 ` 853` ``` by (simp add: inverse_eq_divide zero_less_mult_iff) ``` chaieb@26123 ` 854` ``` with real_down2[OF zero_less_one] obtain t where ``` chaieb@26123 ` 855` ``` t: "t > 0" "t < 1" "t < inverse (cmod w ^ (k + 1) * m)" by blast ``` chaieb@26123 ` 856` ``` let ?ct = "complex_of_real t" ``` chaieb@26123 ` 857` ``` let ?w = "?ct * w" ``` chaieb@26123 ` 858` ``` 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: ring_simps power_mult_distrib) ``` chaieb@26123 ` 859` ``` also have "\ = complex_of_real (1 - t^k) + ?w^k * ?w * poly s ?w" ``` chaieb@26123 ` 860` ``` unfolding wm1 by (simp) ``` chaieb@26123 ` 861` ``` 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 ` 862` ``` apply - ``` chaieb@26123 ` 863` ``` apply (rule cong[OF refl[of cmod]]) ``` chaieb@26123 ` 864` ``` apply assumption ``` chaieb@26123 ` 865` ``` done ``` huffman@27514 ` 866` ``` with norm_triangle_ineq[of "complex_of_real (1 - t^k)" "?w^k * ?w * poly s ?w"] ``` huffman@27514 ` 867` ``` 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 ` 868` ``` have ath: "\x (t::real). 0\ x \ x < t \ t\1 \ \1 - t\ + x < 1" by arith ``` chaieb@26123 ` 869` ``` have "t *cmod w \ 1 * cmod w" apply (rule mult_mono) using t(1,2) by auto ``` huffman@27514 ` 870` ``` then have tw: "cmod ?w \ cmod w" using t(1) by (simp add: norm_mult) ``` chaieb@26123 ` 871` ``` from t inv0 have "t* (cmod w ^ (k + 1) * m) < 1" ``` chaieb@26123 ` 872` ``` by (simp add: inverse_eq_divide field_simps) ``` chaieb@26123 ` 873` ``` with zero_less_power[OF t(1), of k] ``` chaieb@26123 ` 874` ``` have th30: "t^k * (t* (cmod w ^ (k + 1) * m)) < t^k * 1" ``` chaieb@26123 ` 875` ``` apply - apply (rule mult_strict_left_mono) by simp_all ``` chaieb@26123 ` 876` ``` have "cmod (?w^k * ?w * poly s ?w) = t^k * (t* (cmod w ^ (k+1) * cmod (poly s ?w)))" using w0 t(1) ``` huffman@27514 ` 877` ``` by (simp add: ring_simps power_mult_distrib norm_of_real norm_power norm_mult) ``` chaieb@26123 ` 878` ``` then have "cmod (?w^k * ?w * poly s ?w) \ t^k * (t* (cmod w ^ (k + 1) * m))" ``` chaieb@26123 ` 879` ``` using t(1,2) m(2)[rule_format, OF tw] w0 ``` chaieb@26123 ` 880` ``` apply (simp only: ) ``` chaieb@26123 ` 881` ``` apply auto ``` huffman@27514 ` 882` ``` apply (rule mult_mono, simp_all add: norm_ge_zero)+ ``` chaieb@26123 ` 883` ``` apply (simp add: zero_le_mult_iff zero_le_power) ``` chaieb@26123 ` 884` ``` done ``` chaieb@26123 ` 885` ``` with th30 have th120: "cmod (?w^k * ?w * poly s ?w) < t^k" by simp ``` chaieb@26123 ` 886` ``` from power_strict_mono[OF t(2), of k] t(1) kas(2) have th121: "t^k \ 1" ``` chaieb@26123 ` 887` ``` by auto ``` huffman@27514 ` 888` ``` from ath[OF norm_ge_zero[of "?w^k * ?w * poly s ?w"] th120 th121] ``` chaieb@26123 ` 889` ``` have th12: "\1 - t^k\ + cmod (?w^k * ?w * poly s ?w) < 1" . ``` chaieb@26123 ` 890` ``` from th11 th12 ``` chaieb@26123 ` 891` ``` have "cmod (1 + ?w^k * (a + ?w * poly s ?w)) < 1" by arith ``` chaieb@26123 ` 892` ``` then have "cmod (poly ?r ?w) < 1" ``` chaieb@26123 ` 893` ``` unfolding kas(4)[rule_format, of ?w] r01 by simp ``` chaieb@26123 ` 894` ``` then have "\w. cmod (poly ?r w) < 1" by blast} ``` chaieb@26123 ` 895` ``` ultimately have cr0_contr: "\w. cmod (poly ?r w) < 1" by blast ``` chaieb@26123 ` 896` ``` from cr0_contr cq0 q(2) ``` chaieb@26123 ` 897` ``` have ?ths unfolding mrmq_eq not_less[symmetric] by auto} ``` chaieb@26123 ` 898` ``` ultimately show ?ths by blast ``` chaieb@26123 ` 899` ```qed ``` chaieb@26123 ` 900` chaieb@26123 ` 901` ```text {* Alternative version with a syntactic notion of constant polynomial. *} ``` chaieb@26123 ` 902` chaieb@26123 ` 903` ```lemma fundamental_theorem_of_algebra_alt: ``` chaieb@26123 ` 904` ``` assumes nc: "~(\a l. a\ 0 \ list_all(\b. b = 0) l \ p = a#l)" ``` chaieb@26123 ` 905` ``` shows "\z. poly p z = (0::complex)" ``` chaieb@26123 ` 906` ```using nc ``` chaieb@26123 ` 907` ```proof(induct p) ``` chaieb@26123 ` 908` ``` case (Cons c cs) ``` chaieb@26123 ` 909` ``` {assume "c=0" hence ?case by auto} ``` chaieb@26123 ` 910` ``` moreover ``` chaieb@26123 ` 911` ``` {assume c0: "c\0" ``` chaieb@26123 ` 912` ``` {assume nc: "constant (poly (c#cs))" ``` chaieb@26123 ` 913` ``` from nc[unfolded constant_def, rule_format, of 0] ``` chaieb@26123 ` 914` ``` have "\w. w \ 0 \ poly cs w = 0" by auto ``` chaieb@26123 ` 915` ``` hence "list_all (\c. c=0) cs" ``` chaieb@26123 ` 916` ``` proof(induct cs) ``` chaieb@26123 ` 917` ``` case (Cons d ds) ``` chaieb@26123 ` 918` ``` {assume "d=0" hence ?case using Cons.prems Cons.hyps by simp} ``` chaieb@26123 ` 919` ``` moreover ``` chaieb@26123 ` 920` ``` {assume d0: "d\0" ``` chaieb@26123 ` 921` ``` from poly_bound_exists[of 1 ds] obtain m where ``` chaieb@26123 ` 922` ``` m: "m > 0" "\z. \z. cmod z \ 1 \ cmod (poly ds z) \ m" by blast ``` chaieb@26123 ` 923` ``` have dm: "cmod d / m > 0" using d0 m(1) by (simp add: field_simps) ``` chaieb@26123 ` 924` ``` from real_down2[OF dm zero_less_one] obtain x where ``` chaieb@26123 ` 925` ``` x: "x > 0" "x < cmod d / m" "x < 1" by blast ``` chaieb@26123 ` 926` ``` let ?x = "complex_of_real x" ``` chaieb@26123 ` 927` ``` from x have cx: "?x \ 0" "cmod ?x \ 1" by simp_all ``` chaieb@26123 ` 928` ``` from Cons.prems[rule_format, OF cx(1)] ``` chaieb@26123 ` 929` ``` have cth: "cmod (?x*poly ds ?x) = cmod d" by (simp add: eq_diff_eq[symmetric]) ``` chaieb@26123 ` 930` ``` from m(2)[rule_format, OF cx(2)] x(1) ``` chaieb@26123 ` 931` ``` have th0: "cmod (?x*poly ds ?x) \ x*m" ``` huffman@27514 ` 932` ``` by (simp add: norm_mult) ``` chaieb@26123 ` 933` ``` from x(2) m(1) have "x*m < cmod d" by (simp add: field_simps) ``` chaieb@26123 ` 934` ``` with th0 have "cmod (?x*poly ds ?x) \ cmod d" by auto ``` chaieb@26123 ` 935` ``` with cth have ?case by blast} ``` chaieb@26123 ` 936` ``` ultimately show ?case by blast ``` chaieb@26123 ` 937` ``` qed simp} ``` chaieb@26123 ` 938` ``` then have nc: "\ constant (poly (c#cs))" using Cons.prems c0 ``` chaieb@26123 ` 939` ``` by blast ``` chaieb@26123 ` 940` ``` from fundamental_theorem_of_algebra[OF nc] have ?case .} ``` chaieb@26123 ` 941` ``` ultimately show ?case by blast ``` chaieb@26123 ` 942` ```qed simp ``` chaieb@26123 ` 943` huffman@27445 ` 944` ```subsection{* Nullstellenstatz, degrees and divisibility of polynomials *} ``` chaieb@26123 ` 945` chaieb@26123 ` 946` ```lemma nullstellensatz_lemma: ``` chaieb@26123 ` 947` ``` fixes p :: "complex list" ``` chaieb@26123 ` 948` ``` assumes "\x. poly p x = 0 \ poly q x = 0" ``` chaieb@26123 ` 949` ``` and "degree p = n" and "n \ 0" ``` chaieb@26123 ` 950` ``` shows "p divides (pexp q n)" ``` chaieb@26123 ` 951` ```using prems ``` chaieb@26123 ` 952` ```proof(induct n arbitrary: p q rule: nat_less_induct) ``` chaieb@26123 ` 953` ``` fix n::nat fix p q :: "complex list" ``` chaieb@26123 ` 954` ``` assume IH: "\mp q. ``` chaieb@26123 ` 955` ``` (\x. poly p x = (0::complex) \ poly q x = 0) \ ``` chaieb@26123 ` 956` ``` degree p = m \ m \ 0 \ p divides (q %^ m)" ``` chaieb@26123 ` 957` ``` and pq0: "\x. poly p x = 0 \ poly q x = 0" ``` chaieb@26123 ` 958` ``` and dpn: "degree p = n" and n0: "n \ 0" ``` chaieb@26123 ` 959` ``` let ?ths = "p divides (q %^ n)" ``` chaieb@26123 ` 960` ``` {fix a assume a: "poly p a = 0" ``` chaieb@26123 ` 961` ``` {assume p0: "poly p = poly []" ``` chaieb@26123 ` 962` ``` hence ?ths unfolding divides_def using pq0 n0 ``` chaieb@26123 ` 963` ``` apply - apply (rule exI[where x="[]"], rule ext) ``` chaieb@26123 ` 964` ``` by (auto simp add: poly_mult poly_exp)} ``` chaieb@26123 ` 965` ``` moreover ``` chaieb@26123 ` 966` ``` {assume p0: "poly p \ poly []" ``` chaieb@26123 ` 967` ``` and oa: "order a p \ 0" ``` chaieb@26123 ` 968` ``` from p0 have pne: "p \ []" by auto ``` chaieb@26123 ` 969` ``` let ?op = "order a p" ``` chaieb@26123 ` 970` ``` from p0 have ap: "([- a, 1] %^ ?op) divides p" ``` chaieb@26123 ` 971` ``` "\ pexp [- a, 1] (Suc ?op) divides p" using order by blast+ ``` chaieb@26123 ` 972` ``` note oop = order_degree[OF p0, unfolded dpn] ``` chaieb@26123 ` 973` ``` {assume q0: "q = []" ``` chaieb@26123 ` 974` ``` hence ?ths using n0 unfolding divides_def ``` chaieb@26123 ` 975` ``` apply simp ``` chaieb@26123 ` 976` ``` apply (rule exI[where x="[]"], rule ext) ``` chaieb@26123 ` 977` ``` by (simp add: divides_def poly_exp poly_mult)} ``` chaieb@26123 ` 978` ``` moreover ``` chaieb@26123 ` 979` ``` {assume q0: "q\[]" ``` chaieb@26123 ` 980` ``` from pq0[rule_format, OF a, unfolded poly_linear_divides] q0 ``` chaieb@26123 ` 981` ``` obtain r where r: "q = pmult [- a, 1] r" by blast ``` chaieb@26123 ` 982` ``` from ap[unfolded divides_def] obtain s where ``` chaieb@26123 ` 983` ``` s: "poly p = poly (pmult (pexp [- a, 1] ?op) s)" by blast ``` chaieb@26123 ` 984` ``` have s0: "poly s \ poly []" ``` chaieb@26123 ` 985` ``` using s p0 by (simp add: poly_entire) ``` chaieb@26123 ` 986` ``` hence pns0: "poly (pnormalize s) \ poly []" and sne: "s\[]" by auto ``` chaieb@26123 ` 987` ``` {assume ds0: "degree s = 0" ``` chaieb@26123 ` 988` ``` from ds0 pns0 have "\k. pnormalize s = [k]" unfolding degree_def ``` chaieb@26123 ` 989` ``` by (cases "pnormalize s", auto) ``` chaieb@26123 ` 990` ``` then obtain k where kpn: "pnormalize s = [k]" by blast ``` chaieb@26123 ` 991` ``` from pns0[unfolded poly_zero] kpn have k: "k \0" "poly s = poly [k]" ``` chaieb@26123 ` 992` ``` using poly_normalize[of s] by simp_all ``` chaieb@26123 ` 993` ``` let ?w = "pmult (pmult [1/k] (pexp [-a,1] (n - ?op))) (pexp r n)" ``` chaieb@26123 ` 994` ``` from k r s oop have "poly (pexp q n) = poly (pmult p ?w)" ``` chaieb@26123 ` 995` ``` by - (rule ext, simp add: poly_mult poly_exp poly_cmult poly_add power_add[symmetric] ring_simps power_mult_distrib[symmetric]) ``` chaieb@26123 ` 996` ``` hence ?ths unfolding divides_def by blast} ``` chaieb@26123 ` 997` ``` moreover ``` chaieb@26123 ` 998` ``` {assume ds0: "degree s \ 0" ``` chaieb@26123 ` 999` ``` from ds0 s0 dpn degree_unique[OF s, unfolded linear_pow_mul_degree] oa ``` chaieb@26123 ` 1000` ``` have dsn: "degree s < n" by auto ``` chaieb@26123 ` 1001` ``` {fix x assume h: "poly s x = 0" ``` chaieb@26123 ` 1002` ``` {assume xa: "x = a" ``` chaieb@26123 ` 1003` ``` from h[unfolded xa poly_linear_divides] sne obtain u where ``` chaieb@26123 ` 1004` ``` u: "s = pmult [- a, 1] u" by blast ``` chaieb@26123 ` 1005` ``` have "poly p = poly (pmult (pexp [- a, 1] (Suc ?op)) u)" ``` chaieb@26123 ` 1006` ``` unfolding s u ``` chaieb@26123 ` 1007` ``` apply (rule ext) ``` chaieb@26123 ` 1008` ``` by (simp add: ring_simps power_mult_distrib[symmetric] poly_mult poly_cmult poly_add poly_exp) ``` chaieb@26123 ` 1009` ``` with ap(2)[unfolded divides_def] have False by blast} ``` chaieb@26123 ` 1010` ``` note xa = this ``` chaieb@26123 ` 1011` ``` from h s have "poly p x = 0" by (simp add: poly_mult) ``` chaieb@26123 ` 1012` ``` with pq0 have "poly q x = 0" by blast ``` chaieb@26123 ` 1013` ``` with r xa have "poly r x = 0" ``` chaieb@26123 ` 1014` ``` by (auto simp add: poly_mult poly_add poly_cmult eq_diff_eq[symmetric])} ``` chaieb@26123 ` 1015` ``` note impth = this ``` chaieb@26123 ` 1016` ``` from IH[rule_format, OF dsn, of s r] impth ds0 ``` chaieb@26123 ` 1017` ``` have "s divides (pexp r (degree s))" by blast ``` chaieb@26123 ` 1018` ``` then obtain u where u: "poly (pexp r (degree s)) = poly (pmult s u)" ``` chaieb@26123 ` 1019` ``` unfolding divides_def by blast ``` chaieb@26123 ` 1020` ``` hence u': "\x. poly s x * poly u x = poly r x ^ degree s" ``` chaieb@26123 ` 1021` ``` by (simp add: poly_mult[symmetric] poly_exp[symmetric]) ``` chaieb@26123 ` 1022` ``` let ?w = "pmult (pmult u (pexp [-a,1] (n - ?op))) (pexp r (n - degree s))" ``` chaieb@26123 ` 1023` ``` from u' s r oop[of a] dsn have "poly (pexp q n) = poly (pmult p ?w)" ``` chaieb@26123 ` 1024` ``` apply - apply (rule ext) ``` chaieb@26123 ` 1025` ``` apply (simp only: power_mult_distrib power_add[symmetric] poly_add poly_mult poly_exp poly_cmult ring_simps) ``` chaieb@26123 ` 1026` ``` ``` chaieb@26123 ` 1027` ``` apply (simp add: power_mult_distrib power_add[symmetric] poly_add poly_mult poly_exp poly_cmult mult_assoc[symmetric]) ``` chaieb@26123 ` 1028` ``` done ``` chaieb@26123 ` 1029` ``` hence ?ths unfolding divides_def by blast} ``` chaieb@26123 ` 1030` ``` ultimately have ?ths by blast } ``` chaieb@26123 ` 1031` ``` ultimately have ?ths by blast} ``` chaieb@26123 ` 1032` ``` ultimately have ?ths using a order_root by blast} ``` chaieb@26123 ` 1033` ``` moreover ``` chaieb@26123 ` 1034` ``` {assume exa: "\ (\a. poly p a = 0)" ``` chaieb@26123 ` 1035` ``` from fundamental_theorem_of_algebra_alt[of p] exa obtain c cs where ``` chaieb@26123 ` 1036` ``` ccs: "c\0" "list_all (\c. c = 0) cs" "p = c#cs" by blast ``` chaieb@26123 ` 1037` ``` ``` chaieb@26123 ` 1038` ``` from poly_0[OF ccs(2)] ccs(3) ``` chaieb@26123 ` 1039` ``` have pp: "\x. poly p x = c" by simp ``` chaieb@26123 ` 1040` ``` let ?w = "pmult [1/c] (pexp q n)" ``` chaieb@26123 ` 1041` ``` from pp ccs(1) ``` chaieb@26123 ` 1042` ``` have "poly (pexp q n) = poly (pmult p ?w) " ``` chaieb@26123 ` 1043` ``` apply - apply (rule ext) ``` chaieb@26123 ` 1044` ``` unfolding poly_mult_assoc[symmetric] by (simp add: poly_mult) ``` chaieb@26123 ` 1045` ``` hence ?ths unfolding divides_def by blast} ``` chaieb@26123 ` 1046` ``` ultimately show ?ths by blast ``` chaieb@26123 ` 1047` ```qed ``` chaieb@26123 ` 1048` chaieb@26123 ` 1049` ```lemma nullstellensatz_univariate: ``` chaieb@26123 ` 1050` ``` "(\x. poly p x = (0::complex) \ poly q x = 0) \ ``` chaieb@26123 ` 1051` ``` p divides (q %^ (degree p)) \ (poly p = poly [] \ poly q = poly [])" ``` chaieb@26123 ` 1052` ```proof- ``` chaieb@26123 ` 1053` ``` {assume pe: "poly p = poly []" ``` chaieb@26123 ` 1054` ``` hence eq: "(\x. poly p x = (0::complex) \ poly q x = 0) \ poly q = poly []" ``` chaieb@26123 ` 1055` ``` apply auto ``` chaieb@26123 ` 1056` ``` by (rule ext, simp) ``` chaieb@26123 ` 1057` ``` {assume "p divides (pexp q (degree p))" ``` chaieb@26123 ` 1058` ``` then obtain r where r: "poly (pexp q (degree p)) = poly (pmult p r)" ``` chaieb@26123 ` 1059` ``` unfolding divides_def by blast ``` chaieb@26123 ` 1060` ``` from cong[OF r refl] pe degree_unique[OF pe] ``` chaieb@26123 ` 1061` ``` have False by (simp add: poly_mult degree_def)} ``` chaieb@26123 ` 1062` ``` with eq pe have ?thesis by blast} ``` chaieb@26123 ` 1063` ``` moreover ``` chaieb@26123 ` 1064` ``` {assume pe: "poly p \ poly []" ``` chaieb@26123 ` 1065` ``` have p0: "poly [0] = poly []" by (rule ext, simp) ``` chaieb@26123 ` 1066` ``` {assume dp: "degree p = 0" ``` chaieb@26123 ` 1067` ``` then obtain k where "pnormalize p = [k]" using pe poly_normalize[of p] ``` chaieb@26123 ` 1068` ``` unfolding degree_def by (cases "pnormalize p", auto) ``` chaieb@26123 ` 1069` ``` hence k: "pnormalize p = [k]" "poly p = poly [k]" "k\0" ``` chaieb@26123 ` 1070` ``` using pe poly_normalize[of p] by (auto simp add: p0) ``` chaieb@26123 ` 1071` ``` hence th1: "\x. poly p x \ 0" by simp ``` chaieb@26123 ` 1072` ``` from k(2,3) dp have "poly (pexp q (degree p)) = poly (pmult p [1/k]) " ``` chaieb@26123 ` 1073` ``` by - (rule ext, simp add: poly_mult poly_exp) ``` chaieb@26123 ` 1074` ``` hence th2: "p divides (pexp q (degree p))" unfolding divides_def by blast ``` chaieb@26123 ` 1075` ``` from th1 th2 pe have ?thesis by blast} ``` chaieb@26123 ` 1076` ``` moreover ``` chaieb@26123 ` 1077` ``` {assume dp: "degree p \ 0" ``` chaieb@26123 ` 1078` ``` then obtain n where n: "degree p = Suc n " by (cases "degree p", auto) ``` chaieb@26123 ` 1079` ``` {assume "p divides (pexp q (Suc n))" ``` chaieb@26123 ` 1080` ``` then obtain u where u: "poly (pexp q (Suc n)) = poly (pmult p u)" ``` chaieb@26123 ` 1081` ``` unfolding divides_def by blast ``` chaieb@26123 ` 1082` ``` hence u' :"\x. poly (pexp q (Suc n)) x = poly (pmult p u) x" by simp_all ``` chaieb@26123 ` 1083` ``` {fix x assume h: "poly p x = 0" "poly q x \ 0" ``` chaieb@26123 ` 1084` ``` hence "poly (pexp q (Suc n)) x \ 0" by (simp only: poly_exp) simp ``` chaieb@26123 ` 1085` ``` hence False using u' h(1) by (simp only: poly_mult poly_exp) simp}} ``` chaieb@26123 ` 1086` ``` with n nullstellensatz_lemma[of p q "degree p"] dp ``` chaieb@26123 ` 1087` ``` have ?thesis by auto} ``` chaieb@26123 ` 1088` ``` ultimately have ?thesis by blast} ``` chaieb@26123 ` 1089` ``` ultimately show ?thesis by blast ``` chaieb@26123 ` 1090` ```qed ``` chaieb@26123 ` 1091` chaieb@26123 ` 1092` ```text{* Useful lemma *} ``` chaieb@26123 ` 1093` chaieb@26123 ` 1094` ```lemma (in idom_char_0) constant_degree: "constant (poly p) \ degree p = 0" (is "?lhs = ?rhs") ``` chaieb@26123 ` 1095` ```proof ``` chaieb@26123 ` 1096` ``` assume l: ?lhs ``` chaieb@26123 ` 1097` ``` from l[unfolded constant_def, rule_format, of _ "zero"] ``` chaieb@26123 ` 1098` ``` have th: "poly p = poly [poly p 0]" apply - by (rule ext, simp) ``` chaieb@26123 ` 1099` ``` from degree_unique[OF th] show ?rhs by (simp add: degree_def) ``` chaieb@26123 ` 1100` ```next ``` chaieb@26123 ` 1101` ``` assume r: ?rhs ``` chaieb@26123 ` 1102` ``` from r have "pnormalize p = [] \ (\k. pnormalize p = [k])" ``` chaieb@26123 ` 1103` ``` unfolding degree_def by (cases "pnormalize p", auto) ``` chaieb@26123 ` 1104` ``` then show ?lhs unfolding constant_def poly_normalize[of p, symmetric] ``` chaieb@26123 ` 1105` ``` by (auto simp del: poly_normalize) ``` chaieb@26123 ` 1106` ```qed ``` chaieb@26123 ` 1107` chaieb@26123 ` 1108` ```(* It would be nicer to prove this without using algebraic closure... *) ``` chaieb@26123 ` 1109` chaieb@26123 ` 1110` ```lemma divides_degree_lemma: assumes dpn: "degree (p::complex list) = n" ``` chaieb@26123 ` 1111` ``` shows "n \ degree (p *** q) \ poly (p *** q) = poly []" ``` chaieb@26123 ` 1112` ``` using dpn ``` chaieb@26123 ` 1113` ```proof(induct n arbitrary: p q) ``` chaieb@26123 ` 1114` ``` case 0 thus ?case by simp ``` chaieb@26123 ` 1115` ```next ``` chaieb@26123 ` 1116` ``` case (Suc n p q) ``` chaieb@26123 ` 1117` ``` from Suc.prems fundamental_theorem_of_algebra[of p] constant_degree[of p] ``` chaieb@26123 ` 1118` ``` obtain a where a: "poly p a = 0" by auto ``` chaieb@26123 ` 1119` ``` then obtain r where r: "p = pmult [-a, 1] r" unfolding poly_linear_divides ``` chaieb@26123 ` 1120` ``` using Suc.prems by (auto simp add: degree_def) ``` chaieb@26123 ` 1121` ``` {assume h: "poly (pmult r q) = poly []" ``` chaieb@26123 ` 1122` ``` hence "poly (pmult p q) = poly []" using r ``` chaieb@26123 ` 1123` ``` apply - apply (rule ext) by (auto simp add: poly_entire poly_mult poly_add poly_cmult) hence ?case by blast} ``` chaieb@26123 ` 1124` ``` moreover ``` chaieb@26123 ` 1125` ``` {assume h: "poly (pmult r q) \ poly []" ``` chaieb@26123 ` 1126` ``` hence r0: "poly r \ poly []" and q0: "poly q \ poly []" ``` chaieb@26123 ` 1127` ``` by (auto simp add: poly_entire) ``` chaieb@26123 ` 1128` ``` have eq: "poly (pmult p q) = poly (pmult [-a, 1] (pmult r q))" ``` chaieb@26123 ` 1129` ``` apply - apply (rule ext) ``` chaieb@26123 ` 1130` ``` by (simp add: r poly_mult poly_add poly_cmult ring_simps) ``` chaieb@26123 ` 1131` ``` from linear_mul_degree[OF h, of "- a"] ``` chaieb@26123 ` 1132` ``` have dqe: "degree (pmult p q) = degree (pmult r q) + 1" ``` chaieb@26123 ` 1133` ``` unfolding degree_unique[OF eq] . ``` chaieb@26123 ` 1134` ``` from linear_mul_degree[OF r0, of "- a", unfolded r[symmetric]] r Suc.prems ``` chaieb@26123 ` 1135` ``` have dr: "degree r = n" by auto ``` chaieb@26123 ` 1136` ``` from Suc.hyps[OF dr, of q] have "Suc n \ degree (pmult p q)" ``` chaieb@26123 ` 1137` ``` unfolding dqe using h by (auto simp del: poly.simps) ``` chaieb@26123 ` 1138` ``` hence ?case by blast} ``` chaieb@26123 ` 1139` ``` ultimately show ?case by blast ``` chaieb@26123 ` 1140` ```qed ``` chaieb@26123 ` 1141` chaieb@26123 ` 1142` ```lemma divides_degree: assumes pq: "p divides (q:: complex list)" ``` chaieb@26123 ` 1143` ``` shows "degree p \ degree q \ poly q = poly []" ``` chaieb@26123 ` 1144` ```using pq divides_degree_lemma[OF refl, of p] ``` chaieb@26123 ` 1145` ```apply (auto simp add: divides_def poly_entire) ``` chaieb@26123 ` 1146` ```apply atomize ``` chaieb@26123 ` 1147` ```apply (erule_tac x="qa" in allE, auto) ``` chaieb@26123 ` 1148` ```apply (subgoal_tac "degree q = degree (p *** qa)", simp) ``` chaieb@26123 ` 1149` ```apply (rule degree_unique, simp) ``` chaieb@26123 ` 1150` ```done ``` chaieb@26123 ` 1151` chaieb@26123 ` 1152` ```(* Arithmetic operations on multivariate polynomials. *) ``` chaieb@26123 ` 1153` chaieb@26123 ` 1154` ```lemma mpoly_base_conv: ``` chaieb@26123 ` 1155` ``` "(0::complex) \ poly [] x" "c \ poly [c] x" "x \ poly [0,1] x" by simp_all ``` chaieb@26123 ` 1156` chaieb@26123 ` 1157` ```lemma mpoly_norm_conv: ``` chaieb@26123 ` 1158` ``` "poly [0] (x::complex) \ poly [] x" "poly [poly [] y] x \ poly [] x" by simp_all ``` chaieb@26123 ` 1159` chaieb@26123 ` 1160` ```lemma mpoly_sub_conv: ``` chaieb@26123 ` 1161` ``` "poly p (x::complex) - poly q x \ poly p x + -1 * poly q x" ``` chaieb@26123 ` 1162` ``` by (simp add: diff_def) ``` chaieb@26123 ` 1163` chaieb@26123 ` 1164` ```lemma poly_pad_rule: "poly p x = 0 ==> poly (0#p) x = (0::complex)" by simp ``` chaieb@26123 ` 1165` chaieb@26123 ` 1166` ```lemma poly_cancel_eq_conv: "p = (0::complex) \ a \ 0 \ (q = 0) \ (a * q - b * p = 0)" apply (atomize (full)) by auto ``` chaieb@26123 ` 1167` chaieb@26123 ` 1168` ```lemma resolve_eq_raw: "poly [] x \ 0" "poly [c] x \ (c::complex)" by auto ``` chaieb@26123 ` 1169` ```lemma resolve_eq_then: "(P \ (Q \ Q1)) \ (\P \ (Q \ Q2)) ``` chaieb@26123 ` 1170` ``` \ Q \ P \ Q1 \ \P\ Q2" apply (atomize (full)) by blast ``` chaieb@26123 ` 1171` ```lemma expand_ex_beta_conv: "list_ex P [c] \ P c" by simp ``` chaieb@26123 ` 1172` chaieb@26123 ` 1173` ```lemma poly_divides_pad_rule: ``` chaieb@26123 ` 1174` ``` fixes p q :: "complex list" ``` chaieb@26123 ` 1175` ``` assumes pq: "p divides q" ``` chaieb@26123 ` 1176` ``` shows "p divides ((0::complex)#q)" ``` chaieb@26123 ` 1177` ```proof- ``` chaieb@26123 ` 1178` ``` from pq obtain r where r: "poly q = poly (p *** r)" unfolding divides_def by blast ``` chaieb@26123 ` 1179` ``` hence "poly (0#q) = poly (p *** ([0,1] *** r))" ``` chaieb@26123 ` 1180` ``` by - (rule ext, simp add: poly_mult poly_cmult poly_add) ``` chaieb@26123 ` 1181` ``` thus ?thesis unfolding divides_def by blast ``` chaieb@26123 ` 1182` ```qed ``` chaieb@26123 ` 1183` chaieb@26123 ` 1184` ```lemma poly_divides_pad_const_rule: ``` chaieb@26123 ` 1185` ``` fixes p q :: "complex list" ``` chaieb@26123 ` 1186` ``` assumes pq: "p divides q" ``` chaieb@26123 ` 1187` ``` shows "p divides (a %* q)" ``` chaieb@26123 ` 1188` ```proof- ``` chaieb@26123 ` 1189` ``` from pq obtain r where r: "poly q = poly (p *** r)" unfolding divides_def by blast ``` chaieb@26123 ` 1190` ``` hence "poly (a %* q) = poly (p *** (a %* r))" ``` chaieb@26123 ` 1191` ``` by - (rule ext, simp add: poly_mult poly_cmult poly_add) ``` chaieb@26123 ` 1192` ``` thus ?thesis unfolding divides_def by blast ``` chaieb@26123 ` 1193` ```qed ``` chaieb@26123 ` 1194` chaieb@26123 ` 1195` chaieb@26123 ` 1196` ```lemma poly_divides_conv0: ``` chaieb@26123 ` 1197` ``` fixes p :: "complex list" ``` chaieb@26123 ` 1198` ``` assumes lgpq: "length q < length p" and lq:"last p \ 0" ``` chaieb@26123 ` 1199` ``` shows "p divides q \ (\ (list_ex (\c. c \ 0) q))" (is "?lhs \ ?rhs") ``` chaieb@26123 ` 1200` ```proof- ``` chaieb@26123 ` 1201` ``` {assume r: ?rhs ``` chaieb@26123 ` 1202` ``` hence eq: "poly q = poly []" unfolding poly_zero ``` chaieb@26123 ` 1203` ``` by (simp add: list_all_iff list_ex_iff) ``` chaieb@26123 ` 1204` ``` hence "poly q = poly (p *** [])" by - (rule ext, simp add: poly_mult) ``` chaieb@26123 ` 1205` ``` hence ?lhs unfolding divides_def by blast} ``` chaieb@26123 ` 1206` ``` moreover ``` chaieb@26123 ` 1207` ``` {assume l: ?lhs ``` chaieb@26123 ` 1208` ``` have ath: "\lq lp dq::nat. lq < lp ==> lq \ 0 \ dq <= lq - 1 ==> dq < lp - 1" ``` chaieb@26123 ` 1209` ``` by arith ``` chaieb@26123 ` 1210` ``` {assume q0: "length q = 0" ``` chaieb@26123 ` 1211` ``` hence "q = []" by simp ``` chaieb@26123 ` 1212` ``` hence ?rhs by simp} ``` chaieb@26123 ` 1213` ``` moreover ``` chaieb@26123 ` 1214` ``` {assume lgq0: "length q \ 0" ``` chaieb@26123 ` 1215` ``` from pnormalize_length[of q] have dql: "degree q \ length q - 1" ``` chaieb@26123 ` 1216` ``` unfolding degree_def by simp ``` chaieb@26123 ` 1217` ``` from ath[OF lgpq lgq0 dql, unfolded pnormal_degree[OF lq, symmetric]] divides_degree[OF l] have "poly q = poly []" by auto ``` chaieb@26123 ` 1218` ``` hence ?rhs unfolding poly_zero by (simp add: list_all_iff list_ex_iff)} ``` chaieb@26123 ` 1219` ``` ultimately have ?rhs by blast } ``` chaieb@26123 ` 1220` ``` ultimately show "?lhs \ ?rhs" by - (atomize (full), blast) ``` chaieb@26123 ` 1221` ```qed ``` chaieb@26123 ` 1222` chaieb@26123 ` 1223` ```lemma poly_divides_conv1: ``` chaieb@26123 ` 1224` ``` assumes a0: "a\ (0::complex)" and pp': "(p::complex list) divides p'" ``` chaieb@26123 ` 1225` ``` and qrp': "\x. a * poly q x - poly p' x \ poly r x" ``` chaieb@26123 ` 1226` ``` shows "p divides q \ p divides (r::complex list)" (is "?lhs \ ?rhs") ``` chaieb@26123 ` 1227` ```proof- ``` chaieb@26123 ` 1228` ``` { ``` chaieb@26123 ` 1229` ``` from pp' obtain t where t: "poly p' = poly (p *** t)" ``` chaieb@26123 ` 1230` ``` unfolding divides_def by blast ``` chaieb@26123 ` 1231` ``` {assume l: ?lhs ``` chaieb@26123 ` 1232` ``` then obtain u where u: "poly q = poly (p *** u)" unfolding divides_def by blast ``` chaieb@26123 ` 1233` ``` have "poly r = poly (p *** ((a %* u) +++ (-- t)))" ``` chaieb@26123 ` 1234` ``` using u qrp' t ``` chaieb@26123 ` 1235` ``` by - (rule ext, ``` chaieb@26123 ` 1236` ``` simp add: poly_add poly_mult poly_cmult poly_minus ring_simps) ``` chaieb@26123 ` 1237` ``` then have ?rhs unfolding divides_def by blast} ``` chaieb@26123 ` 1238` ``` moreover ``` chaieb@26123 ` 1239` ``` {assume r: ?rhs ``` chaieb@26123 ` 1240` ``` then obtain u where u: "poly r = poly (p *** u)" unfolding divides_def by blast ``` chaieb@26123 ` 1241` ``` from u t qrp' a0 have "poly q = poly (p *** ((1/a) %* (u +++ t)))" ``` chaieb@26123 ` 1242` ``` by - (rule ext, atomize (full), simp add: poly_mult poly_add poly_cmult field_simps) ``` chaieb@26123 ` 1243` ``` hence ?lhs unfolding divides_def by blast} ``` chaieb@26123 ` 1244` ``` ultimately have "?lhs = ?rhs" by blast } ``` chaieb@26123 ` 1245` ```thus "?lhs \ ?rhs" by - (atomize(full), blast) ``` chaieb@26123 ` 1246` ```qed ``` chaieb@26123 ` 1247` chaieb@26123 ` 1248` ```lemma basic_cqe_conv1: ``` chaieb@26123 ` 1249` ``` "(\x. poly p x = 0 \ poly [] x \ 0) \ False" ``` chaieb@26123 ` 1250` ``` "(\x. poly [] x \ 0) \ False" ``` chaieb@26123 ` 1251` ``` "(\x. poly [c] x \ 0) \ c\0" ``` chaieb@26123 ` 1252` ``` "(\x. poly [] x = 0) \ True" ``` chaieb@26123 ` 1253` ``` "(\x. poly [c] x = 0) \ c = 0" by simp_all ``` chaieb@26123 ` 1254` chaieb@26123 ` 1255` ```lemma basic_cqe_conv2: ``` chaieb@26123 ` 1256` ``` assumes l:"last (a#b#p) \ 0" ``` chaieb@26123 ` 1257` ``` shows "(\x. poly (a#b#p) x = (0::complex)) \ True" ``` chaieb@26123 ` 1258` ```proof- ``` chaieb@26123 ` 1259` ``` {fix h t ``` chaieb@26123 ` 1260` ``` assume h: "h\0" "list_all (\c. c=(0::complex)) t" "a#b#p = h#t" ``` chaieb@26123 ` 1261` ``` hence "list_all (\c. c= 0) (b#p)" by simp ``` chaieb@26123 ` 1262` ``` moreover have "last (b#p) \ set (b#p)" by simp ``` chaieb@26123 ` 1263` ``` ultimately have "last (b#p) = 0" by (simp add: list_all_iff) ``` chaieb@26123 ` 1264` ``` with l have False by simp} ``` chaieb@26123 ` 1265` ``` hence th: "\ (\ h t. h\0 \ list_all (\c. c=0) t \ a#b#p = h#t)" ``` chaieb@26123 ` 1266` ``` by blast ``` chaieb@26123 ` 1267` ``` from fundamental_theorem_of_algebra_alt[OF th] ``` chaieb@26123 ` 1268` ``` show "(\x. poly (a#b#p) x = (0::complex)) \ True" by auto ``` chaieb@26123 ` 1269` ```qed ``` chaieb@26123 ` 1270` chaieb@26123 ` 1271` ```lemma basic_cqe_conv_2b: "(\x. poly p x \ (0::complex)) \ (list_ex (\c. c \ 0) p)" ``` chaieb@26123 ` 1272` ```proof- ``` chaieb@26123 ` 1273` ``` have "\ (list_ex (\c. c \ 0) p) \ poly p = poly []" ``` chaieb@26123 ` 1274` ``` by (simp add: poly_zero list_all_iff list_ex_iff) ``` chaieb@26123 ` 1275` ``` also have "\ \ (\ (\x. poly p x \ 0))" by (auto intro: ext) ``` chaieb@26123 ` 1276` ``` finally show "(\x. poly p x \ (0::complex)) \ (list_ex (\c. c \ 0) p)" ``` chaieb@26123 ` 1277` ``` by - (atomize (full), blast) ``` chaieb@26123 ` 1278` ```qed ``` chaieb@26123 ` 1279` chaieb@26123 ` 1280` ```lemma basic_cqe_conv3: ``` chaieb@26123 ` 1281` ``` fixes p q :: "complex list" ``` chaieb@26123 ` 1282` ``` assumes l: "last (a#p) \ 0" ``` chaieb@26123 ` 1283` ``` shows "(\x. poly (a#p) x =0 \ poly q x \ 0) \ \ ((a#p) divides (q %^ (length p)))" ``` chaieb@26123 ` 1284` ```proof- ``` chaieb@26123 ` 1285` ``` note np = pnormalize_eq[OF l] ``` chaieb@26123 ` 1286` ``` {assume "poly (a#p) = poly []" hence False using l ``` chaieb@26123 ` 1287` ``` unfolding poly_zero apply (auto simp add: list_all_iff del: last.simps) ``` chaieb@26123 ` 1288` ``` apply (cases p, simp_all) done} ``` chaieb@26123 ` 1289` ``` then have p0: "poly (a#p) \ poly []" by blast ``` chaieb@26123 ` 1290` ``` from np have dp:"degree (a#p) = length p" by (simp add: degree_def) ``` chaieb@26123 ` 1291` ``` from nullstellensatz_univariate[of "a#p" q] p0 dp ``` chaieb@26123 ` 1292` ``` show "(\x. poly (a#p) x =0 \ poly q x \ 0) \ \ ((a#p) divides (q %^ (length p)))" ``` chaieb@26123 ` 1293` ``` by - (atomize (full), auto) ``` chaieb@26123 ` 1294` ```qed ``` chaieb@26123 ` 1295` chaieb@26123 ` 1296` ```lemma basic_cqe_conv4: ``` chaieb@26123 ` 1297` ``` fixes p q :: "complex list" ``` chaieb@26123 ` 1298` ``` assumes h: "\x. poly (q %^ n) x \ poly r x" ``` chaieb@26123 ` 1299` ``` shows "p divides (q %^ n) \ p divides r" ``` chaieb@26123 ` 1300` ```proof- ``` chaieb@26123 ` 1301` ``` from h have "poly (q %^ n) = poly r" by (auto intro: ext) ``` chaieb@26123 ` 1302` ``` thus "p divides (q %^ n) \ p divides r" unfolding divides_def by simp ``` chaieb@26123 ` 1303` ```qed ``` chaieb@26123 ` 1304` chaieb@26123 ` 1305` ```lemma pmult_Cons_Cons: "((a::complex)#b#p) *** q = (a %*q) +++ (0#((b#p) *** q))" ``` chaieb@26123 ` 1306` ``` by simp ``` chaieb@26123 ` 1307` chaieb@26123 ` 1308` ```lemma elim_neg_conv: "- z \ (-1) * (z::complex)" by simp ``` chaieb@26123 ` 1309` ```lemma eqT_intr: "PROP P \ (True \ PROP P )" "PROP P \ True" by blast+ ``` chaieb@26123 ` 1310` ```lemma negate_negate_rule: "Trueprop P \ \ P \ False" by (atomize (full), auto) ``` chaieb@26123 ` 1311` ```lemma last_simps: "last [x] = x" "last (x#y#ys) = last (y#ys)" by simp_all ``` chaieb@26123 ` 1312` ```lemma length_simps: "length [] = 0" "length (x#y#xs) = length xs + 2" "length [x] = 1" by simp_all ``` chaieb@26123 ` 1313` chaieb@26123 ` 1314` ```lemma complex_entire: "(z::complex) \ 0 \ w \ 0 \ z*w \ 0" by simp ``` chaieb@26123 ` 1315` ```lemma resolve_eq_ne: "(P \ True) \ (\P \ False)" "(P \ False) \ (\P \ True)" ``` chaieb@26123 ` 1316` ``` by (atomize (full)) simp_all ``` chaieb@26123 ` 1317` ```lemma cqe_conv1: "poly [] x = 0 \ True" by simp ``` chaieb@26123 ` 1318` ```lemma cqe_conv2: "(p \ (q \ r)) \ ((p \ q) \ (p \ r))" (is "?l \ ?r") ``` chaieb@26123 ` 1319` ```proof ``` chaieb@26123 ` 1320` ``` assume "p \ q \ r" thus "p \ q \ p \ r" apply - apply (atomize (full)) by blast ``` chaieb@26123 ` 1321` ```next ``` chaieb@26123 ` 1322` ``` assume "p \ q \ p \ r" "p" ``` chaieb@26123 ` 1323` ``` thus "q \ r" apply - apply (atomize (full)) apply blast done ``` chaieb@26123 ` 1324` ```qed ``` chaieb@26123 ` 1325` ```lemma poly_const_conv: "poly [c] (x::complex) = y \ c = y" by simp ``` chaieb@26123 ` 1326` chaieb@26123 ` 1327` `end`