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