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