author | blanchet |
Mon, 19 Aug 2013 14:47:47 +0200 | |
changeset 53084 | 877f5c28016f |
parent 52881 | 4eb44754f1bb |
child 54219 | 63fe59f64578 |
permissions | -rw-r--r-- |
33268
02de0317f66f
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
33153
diff
changeset
|
1 |
(* Title: HOL/Decision_Procs/Polynomial_List.thy |
02de0317f66f
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
33153
diff
changeset
|
2 |
Author: Amine Chaieb |
33153 | 3 |
*) |
4 |
||
33268
02de0317f66f
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
33153
diff
changeset
|
5 |
header {* Univariate Polynomials as Lists *} |
33153 | 6 |
|
7 |
theory Polynomial_List |
|
8 |
imports Main |
|
9 |
begin |
|
10 |
||
11 |
text{* Application of polynomial as a real function. *} |
|
12 |
||
52881 | 13 |
primrec poly :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a::comm_ring" |
52778 | 14 |
where |
33153 | 15 |
poly_Nil: "poly [] x = 0" |
52881 | 16 |
| poly_Cons: "poly (h # t) x = h + x * poly t x" |
33153 | 17 |
|
18 |
||
19 |
subsection{*Arithmetic Operations on Polynomials*} |
|
20 |
||
21 |
text{*addition*} |
|
52881 | 22 |
primrec padd :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a::comm_ring_1 list" (infixl "+++" 65) |
52778 | 23 |
where |
33153 | 24 |
padd_Nil: "[] +++ l2 = l2" |
52881 | 25 |
| padd_Cons: "(h # t) +++ l2 = (if l2 = [] then h # t else (h + hd l2) # (t +++ tl l2))" |
33153 | 26 |
|
27 |
text{*Multiplication by a constant*} |
|
52881 | 28 |
primrec cmult :: "'a::comm_ring_1 \<Rightarrow> 'a list \<Rightarrow> 'a list" (infixl "%*" 70) |
52778 | 29 |
where |
39246 | 30 |
cmult_Nil: "c %* [] = []" |
52881 | 31 |
| cmult_Cons: "c %* (h # t) = (c * h) # (c %* t)" |
33153 | 32 |
|
33 |
text{*Multiplication by a polynomial*} |
|
52881 | 34 |
primrec pmult :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a::comm_ring_1 list" (infixl "***" 70) |
52778 | 35 |
where |
39246 | 36 |
pmult_Nil: "[] *** l2 = []" |
52881 | 37 |
| pmult_Cons: "(h # t) *** l2 = |
38 |
(if t = [] then h %* l2 else (h %* l2) +++ (0 # (t *** l2)))" |
|
33153 | 39 |
|
40 |
text{*Repeated multiplication by a polynomial*} |
|
52881 | 41 |
primrec mulexp :: "nat \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> 'a::comm_ring_1 list" |
52778 | 42 |
where |
39246 | 43 |
mulexp_zero: "mulexp 0 p q = q" |
44 |
| mulexp_Suc: "mulexp (Suc n) p q = p *** mulexp n p q" |
|
33153 | 45 |
|
46 |
text{*Exponential*} |
|
52881 | 47 |
primrec pexp :: "'a list \<Rightarrow> nat \<Rightarrow> 'a::comm_ring_1 list" (infixl "%^" 80) |
52778 | 48 |
where |
39246 | 49 |
pexp_0: "p %^ 0 = [1]" |
50 |
| pexp_Suc: "p %^ (Suc n) = p *** (p %^ n)" |
|
33153 | 51 |
|
52 |
text{*Quotient related value of dividing a polynomial by x + a*} |
|
53 |
(* Useful for divisor properties in inductive proofs *) |
|
52881 | 54 |
primrec pquot :: "'a list \<Rightarrow> 'a::field \<Rightarrow> 'a list" |
52778 | 55 |
where |
52881 | 56 |
pquot_Nil: "pquot [] a = []" |
57 |
| pquot_Cons: "pquot (h # t) a = |
|
58 |
(if t = [] then [h] else (inverse a * (h - hd (pquot t a))) # pquot t a)" |
|
33153 | 59 |
|
60 |
||
61 |
text{*normalization of polynomials (remove extra 0 coeff)*} |
|
52881 | 62 |
primrec pnormalize :: "'a::comm_ring_1 list \<Rightarrow> 'a list" |
52778 | 63 |
where |
39246 | 64 |
pnormalize_Nil: "pnormalize [] = []" |
52881 | 65 |
| pnormalize_Cons: "pnormalize (h # p) = |
66 |
(if (pnormalize p = []) then (if h = 0 then [] else [h]) |
|
67 |
else (h # pnormalize p))" |
|
33153 | 68 |
|
69 |
definition "pnormal p = ((pnormalize p = p) \<and> p \<noteq> [])" |
|
70 |
definition "nonconstant p = (pnormal p \<and> (\<forall>x. p \<noteq> [x]))" |
|
71 |
text{*Other definitions*} |
|
72 |
||
52778 | 73 |
definition poly_minus :: "'a list => ('a :: comm_ring_1) list" ("-- _" [80] 80) |
74 |
where "-- p = (- 1) %* p" |
|
33153 | 75 |
|
52881 | 76 |
definition divides :: "'a::comm_ring_1 list \<Rightarrow> 'a list \<Rightarrow> bool" (infixl "divides" 70) |
77 |
where "p1 divides p2 = (\<exists>q. poly p2 = poly (p1 *** q))" |
|
33153 | 78 |
|
52881 | 79 |
definition order :: "'a::comm_ring_1 \<Rightarrow> 'a list \<Rightarrow> nat" --{*order of a polynomial*} |
80 |
where "order a p = (SOME n. ([-a, 1] %^ n) divides p & ~ (([-a, 1] %^ Suc n) divides p))" |
|
33153 | 81 |
|
52881 | 82 |
definition degree :: "'a::comm_ring_1 list \<Rightarrow> nat" --{*degree of a polynomial*} |
52778 | 83 |
where "degree p = length (pnormalize p) - 1" |
33153 | 84 |
|
52881 | 85 |
definition rsquarefree :: "'a::comm_ring_1 list \<Rightarrow> bool" |
86 |
where --{*squarefree polynomials --- NB with respect to real roots only.*} |
|
87 |
"rsquarefree p = (poly p \<noteq> poly [] \<and> (\<forall>a. order a p = 0 \<or> order a p = 1))" |
|
33153 | 88 |
|
52778 | 89 |
lemma padd_Nil2 [simp]: "p +++ [] = p" |
90 |
by (induct p) auto |
|
33153 | 91 |
|
92 |
lemma padd_Cons_Cons: "(h1 # p1) +++ (h2 # p2) = (h1 + h2) # (p1 +++ p2)" |
|
52778 | 93 |
by auto |
33153 | 94 |
|
52778 | 95 |
lemma pminus_Nil [simp]: "-- [] = []" |
96 |
by (simp add: poly_minus_def) |
|
33153 | 97 |
|
98 |
lemma pmult_singleton: "[h1] *** p1 = h1 %* p1" |
|
52778 | 99 |
by simp |
33153 | 100 |
|
52778 | 101 |
lemma poly_ident_mult [simp]: "1 %* t = t" |
102 |
by (induct t) auto |
|
33153 | 103 |
|
52778 | 104 |
lemma poly_simple_add_Cons [simp]: "[a] +++ ((0)#t) = (a#t)" |
105 |
by simp |
|
33153 | 106 |
|
107 |
text{*Handy general properties*} |
|
108 |
||
109 |
lemma padd_commut: "b +++ a = a +++ b" |
|
52881 | 110 |
apply (induct b arbitrary: a) |
111 |
apply auto |
|
52778 | 112 |
apply (rule padd_Cons [THEN ssubst]) |
52881 | 113 |
apply (case_tac aa) |
114 |
apply auto |
|
52778 | 115 |
done |
33153 | 116 |
|
52881 | 117 |
lemma padd_assoc: "(a +++ b) +++ c = a +++ (b +++ c)" |
118 |
apply (induct a arbitrary: b c) |
|
119 |
apply simp |
|
120 |
apply (case_tac b) |
|
121 |
apply simp_all |
|
52778 | 122 |
done |
33153 | 123 |
|
52881 | 124 |
lemma poly_cmult_distr: "a %* ( p +++ q) = (a %* p +++ a %* q)" |
125 |
apply (induct p arbitrary: q) |
|
52778 | 126 |
apply simp |
127 |
apply (case_tac q) |
|
128 |
apply (simp_all add: distrib_left) |
|
129 |
done |
|
33153 | 130 |
|
52881 | 131 |
lemma pmult_by_x [simp]: "[0, 1] *** t = ((0)#t)" |
132 |
by (induct t) (auto simp add: padd_commut) |
|
33153 | 133 |
|
134 |
||
135 |
text{*properties of evaluation of polynomials.*} |
|
136 |
||
137 |
lemma poly_add: "poly (p1 +++ p2) x = poly p1 x + poly p2 x" |
|
52881 | 138 |
apply (induct p1 arbitrary: p2) |
139 |
apply auto |
|
52778 | 140 |
apply (case_tac "p2") |
141 |
apply (auto simp add: distrib_left) |
|
142 |
done |
|
33153 | 143 |
|
144 |
lemma poly_cmult: "poly (c %* p) x = c * poly p x" |
|
52881 | 145 |
apply (induct p) |
146 |
apply simp |
|
147 |
apply (cases "x = 0") |
|
52778 | 148 |
apply (auto simp add: distrib_left mult_ac) |
149 |
done |
|
33153 | 150 |
|
151 |
lemma poly_minus: "poly (-- p) x = - (poly p x)" |
|
52881 | 152 |
by (simp add: poly_minus_def poly_cmult) |
33153 | 153 |
|
154 |
lemma poly_mult: "poly (p1 *** p2) x = poly p1 x * poly p2 x" |
|
52881 | 155 |
apply (induct p1 arbitrary: p2) |
52778 | 156 |
apply (case_tac p1) |
157 |
apply (auto simp add: poly_cmult poly_add distrib_right distrib_left mult_ac) |
|
158 |
done |
|
33153 | 159 |
|
160 |
lemma poly_exp: "poly (p %^ n) (x::'a::comm_ring_1) = (poly p x) ^ n" |
|
52881 | 161 |
by (induct n) (auto simp add: poly_cmult poly_mult) |
33153 | 162 |
|
163 |
text{*More Polynomial Evaluation Lemmas*} |
|
164 |
||
52778 | 165 |
lemma poly_add_rzero [simp]: "poly (a +++ []) x = poly a x" |
166 |
by simp |
|
33153 | 167 |
|
168 |
lemma poly_mult_assoc: "poly ((a *** b) *** c) x = poly (a *** (b *** c)) x" |
|
169 |
by (simp add: poly_mult mult_assoc) |
|
170 |
||
52778 | 171 |
lemma poly_mult_Nil2 [simp]: "poly (p *** []) x = 0" |
52881 | 172 |
by (induct p) auto |
33153 | 173 |
|
174 |
lemma poly_exp_add: "poly (p %^ (n + d)) x = poly( p %^ n *** p %^ d) x" |
|
52881 | 175 |
by (induct n) (auto simp add: poly_mult mult_assoc) |
33153 | 176 |
|
177 |
subsection{*Key Property: if @{term "f(a) = 0"} then @{term "(x - a)"} divides |
|
178 |
@{term "p(x)"} *} |
|
179 |
||
52881 | 180 |
lemma poly_linear_rem: "\<exists>q r. h # t = [r] +++ [-a, 1] *** q" |
181 |
apply (induct t arbitrary: h) |
|
52778 | 182 |
apply (rule_tac x = "[]" in exI) |
52881 | 183 |
apply (rule_tac x = h in exI) |
184 |
apply simp |
|
185 |
apply (drule_tac x = aa in meta_spec) |
|
186 |
apply safe |
|
52778 | 187 |
apply (rule_tac x = "r#q" in exI) |
188 |
apply (rule_tac x = "a*r + h" in exI) |
|
52881 | 189 |
apply (case_tac q) |
190 |
apply auto |
|
52778 | 191 |
done |
33153 | 192 |
|
52881 | 193 |
lemma poly_linear_divides: "poly p a = 0 \<longleftrightarrow> p = [] \<or> (\<exists>q. p = [-a, 1] *** q)" |
52778 | 194 |
apply (auto simp add: poly_add poly_cmult distrib_left) |
52881 | 195 |
apply (case_tac p) |
196 |
apply simp |
|
197 |
apply (cut_tac h = aa and t = list and a = a in poly_linear_rem) |
|
198 |
apply safe |
|
199 |
apply (case_tac q) |
|
200 |
apply auto |
|
201 |
apply (drule_tac x = "[]" in spec) |
|
202 |
apply simp |
|
52778 | 203 |
apply (auto simp add: poly_add poly_cmult add_assoc) |
52881 | 204 |
apply (drule_tac x = "aa#lista" in spec) |
205 |
apply auto |
|
52778 | 206 |
done |
33153 | 207 |
|
52881 | 208 |
lemma lemma_poly_length_mult [simp]: "length (k %* p +++ (h # (a %* p))) = Suc (length p)" |
209 |
by (induct p arbitrary: h k a) auto |
|
33153 | 210 |
|
52881 | 211 |
lemma lemma_poly_length_mult2 [simp]: "length (k %* p +++ (h # p)) = Suc (length p)" |
212 |
by (induct p arbitrary: h k) auto |
|
33153 | 213 |
|
52881 | 214 |
lemma poly_length_mult [simp]: "length([-a, 1] *** q) = Suc (length q)" |
52778 | 215 |
by auto |
33153 | 216 |
|
217 |
||
218 |
subsection{*Polynomial length*} |
|
219 |
||
52778 | 220 |
lemma poly_cmult_length [simp]: "length (a %* p) = length p" |
221 |
by (induct p) auto |
|
33153 | 222 |
|
52881 | 223 |
lemma poly_add_length: |
224 |
"length (p1 +++ p2) = (if (length p1 < length p2) then length p2 else length p1)" |
|
225 |
by (induct p1 arbitrary: p2) auto |
|
33153 | 226 |
|
52881 | 227 |
lemma poly_root_mult_length [simp]: "length ([a, b] *** p) = Suc (length p)" |
52778 | 228 |
by simp |
33153 | 229 |
|
52881 | 230 |
lemma poly_mult_not_eq_poly_Nil [simp]: |
231 |
"poly (p *** q) x \<noteq> poly [] x \<longleftrightarrow> poly p x \<noteq> poly [] x \<and> poly q x \<noteq> poly [] (x::'a::idom)" |
|
52778 | 232 |
by (auto simp add: poly_mult) |
33153 | 233 |
|
52881 | 234 |
lemma poly_mult_eq_zero_disj: "poly (p *** q) (x::'a::idom) = 0 \<longleftrightarrow> poly p x = 0 \<or> poly q x = 0" |
52778 | 235 |
by (auto simp add: poly_mult) |
33153 | 236 |
|
237 |
text{*Normalisation Properties*} |
|
238 |
||
52881 | 239 |
lemma poly_normalized_nil: "pnormalize p = [] \<longrightarrow> poly p x = 0" |
52778 | 240 |
by (induct p) auto |
33153 | 241 |
|
242 |
text{*A nontrivial polynomial of degree n has no more than n roots*} |
|
243 |
||
244 |
lemma poly_roots_index_lemma0 [rule_format]: |
|
245 |
"\<forall>p x. poly p x \<noteq> poly [] x & length p = n |
|
246 |
--> (\<exists>i. \<forall>x. (poly p x = (0::'a::idom)) --> (\<exists>m. (m \<le> n & x = i m)))" |
|
52881 | 247 |
apply (induct n) |
248 |
apply safe |
|
52778 | 249 |
apply (rule ccontr) |
52881 | 250 |
apply (subgoal_tac "\<exists>a. poly p a = 0") |
251 |
apply safe |
|
252 |
apply (drule poly_linear_divides [THEN iffD1]) |
|
253 |
apply safe |
|
52778 | 254 |
apply (drule_tac x = q in spec) |
255 |
apply (drule_tac x = x in spec) |
|
256 |
apply (simp del: poly_Nil pmult_Cons) |
|
257 |
apply (erule exE) |
|
52881 | 258 |
apply (drule_tac x = "%m. if m = Suc n then a else i m" in spec) |
259 |
apply safe |
|
260 |
apply (drule poly_mult_eq_zero_disj [THEN iffD1]) |
|
261 |
apply safe |
|
52778 | 262 |
apply (drule_tac x = "Suc (length q)" in spec) |
263 |
apply (auto simp add: field_simps) |
|
264 |
apply (drule_tac x = xa in spec) |
|
265 |
apply (clarsimp simp add: field_simps) |
|
266 |
apply (drule_tac x = m in spec) |
|
267 |
apply (auto simp add:field_simps) |
|
268 |
done |
|
45605 | 269 |
lemmas poly_roots_index_lemma1 = conjI [THEN poly_roots_index_lemma0] |
33153 | 270 |
|
52778 | 271 |
lemma poly_roots_index_length0: |
272 |
"poly p (x::'a::idom) \<noteq> poly [] x \<Longrightarrow> |
|
273 |
\<exists>i. \<forall>x. (poly p x = 0) \<longrightarrow> (\<exists>n. n \<le> length p & x = i n)" |
|
274 |
by (blast intro: poly_roots_index_lemma1) |
|
33153 | 275 |
|
52778 | 276 |
lemma poly_roots_finite_lemma: |
277 |
"poly p (x::'a::idom) \<noteq> poly [] x \<Longrightarrow> |
|
278 |
\<exists>N i. \<forall>x. (poly p x = 0) \<longrightarrow> (\<exists>n. (n::nat) < N & x = i n)" |
|
52881 | 279 |
apply (drule poly_roots_index_length0) |
280 |
apply safe |
|
52778 | 281 |
apply (rule_tac x = "Suc (length p)" in exI) |
282 |
apply (rule_tac x = i in exI) |
|
283 |
apply (simp add: less_Suc_eq_le) |
|
284 |
done |
|
33153 | 285 |
|
286 |
||
287 |
lemma real_finite_lemma: |
|
52881 | 288 |
assumes "\<forall>x. P x \<longrightarrow> (\<exists>n. n < length j & x = j!n)" |
33153 | 289 |
shows "finite {(x::'a::idom). P x}" |
52778 | 290 |
proof - |
33153 | 291 |
let ?M = "{x. P x}" |
292 |
let ?N = "set j" |
|
52881 | 293 |
have "?M \<subseteq> ?N" using assms by auto |
52778 | 294 |
then show ?thesis using finite_subset by auto |
33153 | 295 |
qed |
296 |
||
297 |
lemma poly_roots_index_lemma [rule_format]: |
|
52778 | 298 |
"\<forall>p x. poly p x \<noteq> poly [] x & length p = n |
299 |
\<longrightarrow> (\<exists>i. \<forall>x. (poly p x = (0::'a::{idom})) \<longrightarrow> x \<in> set i)" |
|
52881 | 300 |
apply (induct n) |
301 |
apply safe |
|
52778 | 302 |
apply (rule ccontr) |
52881 | 303 |
apply (subgoal_tac "\<exists>a. poly p a = 0") |
304 |
apply safe |
|
305 |
apply (drule poly_linear_divides [THEN iffD1]) |
|
306 |
apply safe |
|
52778 | 307 |
apply (drule_tac x = q in spec) |
308 |
apply (drule_tac x = x in spec) |
|
309 |
apply (auto simp del: poly_Nil pmult_Cons) |
|
310 |
apply (drule_tac x = "a#i" in spec) |
|
311 |
apply (auto simp only: poly_mult List.list.size) |
|
312 |
apply (drule_tac x = xa in spec) |
|
313 |
apply (clarsimp simp add: field_simps) |
|
314 |
done |
|
33153 | 315 |
|
45605 | 316 |
lemmas poly_roots_index_lemma2 = conjI [THEN poly_roots_index_lemma] |
33153 | 317 |
|
52778 | 318 |
lemma poly_roots_index_length: |
319 |
"poly p (x::'a::idom) \<noteq> poly [] x \<Longrightarrow> |
|
320 |
\<exists>i. \<forall>x. (poly p x = 0) --> x \<in> set i" |
|
321 |
by (blast intro: poly_roots_index_lemma2) |
|
33153 | 322 |
|
52778 | 323 |
lemma poly_roots_finite_lemma': |
324 |
"poly p (x::'a::idom) \<noteq> poly [] x \<Longrightarrow> |
|
325 |
\<exists>i. \<forall>x. (poly p x = 0) --> x \<in> set i" |
|
326 |
apply (drule poly_roots_index_length) |
|
327 |
apply auto |
|
328 |
done |
|
33153 | 329 |
|
330 |
lemma UNIV_nat_infinite: "\<not> finite (UNIV :: nat set)" |
|
331 |
unfolding finite_conv_nat_seg_image |
|
52778 | 332 |
proof (auto simp add: set_eq_iff image_iff) |
33153 | 333 |
fix n::nat and f:: "nat \<Rightarrow> nat" |
334 |
let ?N = "{i. i < n}" |
|
335 |
let ?fN = "f ` ?N" |
|
336 |
let ?y = "Max ?fN + 1" |
|
52778 | 337 |
from nat_seg_image_imp_finite[of "?fN" "f" n] |
33153 | 338 |
have thfN: "finite ?fN" by simp |
52778 | 339 |
{ assume "n =0" hence "\<exists>x. \<forall>xa<n. x \<noteq> f xa" by auto } |
33153 | 340 |
moreover |
52778 | 341 |
{ assume nz: "n \<noteq> 0" |
342 |
hence thne: "?fN \<noteq> {}" by auto |
|
33153 | 343 |
have "\<forall>x\<in> ?fN. Max ?fN \<ge> x" using nz Max_ge_iff[OF thfN thne] by auto |
344 |
hence "\<forall>x\<in> ?fN. ?y > x" by (auto simp add: less_Suc_eq_le) |
|
345 |
hence "?y \<notin> ?fN" by auto |
|
346 |
hence "\<exists>x. \<forall>xa<n. x \<noteq> f xa" by auto } |
|
347 |
ultimately show "\<exists>x. \<forall>xa<n. x \<noteq> f xa" by blast |
|
348 |
qed |
|
349 |
||
350 |
lemma UNIV_ring_char_0_infinte: "\<not> finite (UNIV:: ('a::ring_char_0) set)" |
|
351 |
proof |
|
352 |
assume F: "finite (UNIV :: 'a set)" |
|
52881 | 353 |
have th0: "of_nat ` UNIV \<subseteq> (UNIV :: 'a set)" by simp |
33153 | 354 |
from finite_subset[OF th0 F] have th: "finite (of_nat ` UNIV :: 'a set)" . |
52881 | 355 |
have th': "inj_on (of_nat::nat \<Rightarrow> 'a) UNIV" |
33153 | 356 |
unfolding inj_on_def by auto |
52778 | 357 |
from finite_imageD[OF th th'] UNIV_nat_infinite |
33153 | 358 |
show False by blast |
359 |
qed |
|
360 |
||
52881 | 361 |
lemma poly_roots_finite: "poly p \<noteq> poly [] \<longleftrightarrow> finite {x. poly p x = (0::'a::{idom,ring_char_0})}" |
33153 | 362 |
proof |
52881 | 363 |
assume "poly p \<noteq> poly []" |
364 |
then show "finite {x. poly p x = (0::'a)}" |
|
33153 | 365 |
apply - |
52881 | 366 |
apply (erule contrapos_np) |
367 |
apply (rule ext) |
|
33153 | 368 |
apply (rule ccontr) |
369 |
apply (clarify dest!: poly_roots_finite_lemma') |
|
370 |
using finite_subset |
|
52778 | 371 |
proof - |
33153 | 372 |
fix x i |
52778 | 373 |
assume F: "\<not> finite {x. poly p x = (0\<Colon>'a)}" |
33153 | 374 |
and P: "\<forall>x. poly p x = (0\<Colon>'a) \<longrightarrow> x \<in> set i" |
375 |
let ?M= "{x. poly p x = (0\<Colon>'a)}" |
|
376 |
from P have "?M \<subseteq> set i" by auto |
|
377 |
with finite_subset F show False by auto |
|
378 |
qed |
|
379 |
next |
|
52778 | 380 |
assume "finite {x. poly p x = (0\<Colon>'a)}" |
52881 | 381 |
then show "poly p \<noteq> poly []" |
382 |
using UNIV_ring_char_0_infinte by auto |
|
33153 | 383 |
qed |
384 |
||
385 |
text{*Entirety and Cancellation for polynomials*} |
|
386 |
||
52778 | 387 |
lemma poly_entire_lemma: |
388 |
"poly (p:: ('a::{idom,ring_char_0}) list) \<noteq> poly [] \<Longrightarrow> poly q \<noteq> poly [] \<Longrightarrow> |
|
389 |
poly (p *** q) \<noteq> poly []" |
|
390 |
by (auto simp add: poly_roots_finite poly_mult Collect_disj_eq) |
|
33153 | 391 |
|
52778 | 392 |
lemma poly_entire: |
52881 | 393 |
"poly (p *** q) = poly ([]::('a::{idom,ring_char_0}) list) \<longleftrightarrow> |
394 |
(poly p = poly [] \<or> poly q = poly [])" |
|
52778 | 395 |
apply (auto dest: fun_cong simp add: poly_entire_lemma poly_mult) |
396 |
apply (blast intro: ccontr dest: poly_entire_lemma poly_mult [THEN subst]) |
|
397 |
done |
|
33153 | 398 |
|
52778 | 399 |
lemma poly_entire_neg: |
52881 | 400 |
"poly (p *** q) \<noteq> poly ([]::('a::{idom,ring_char_0}) list) \<longleftrightarrow> |
401 |
poly p \<noteq> poly [] \<and> poly q \<noteq> poly []" |
|
52778 | 402 |
by (simp add: poly_entire) |
33153 | 403 |
|
52778 | 404 |
lemma fun_eq: "f = g \<longleftrightarrow> (\<forall>x. f x = g x)" |
405 |
by auto |
|
33153 | 406 |
|
52881 | 407 |
lemma poly_add_minus_zero_iff: "poly (p +++ -- q) = poly [] \<longleftrightarrow> poly p = poly q" |
52778 | 408 |
by (auto simp add: field_simps poly_add poly_minus_def fun_eq poly_cmult) |
33153 | 409 |
|
410 |
lemma poly_add_minus_mult_eq: "poly (p *** q +++ --(p *** r)) = poly (p *** (q +++ -- r))" |
|
52778 | 411 |
by (auto simp add: poly_add poly_minus_def fun_eq poly_mult poly_cmult distrib_left) |
33153 | 412 |
|
52778 | 413 |
lemma poly_mult_left_cancel: |
414 |
"(poly (p *** q) = poly (p *** r)) = |
|
52881 | 415 |
(poly p = poly ([]::('a::{idom,ring_char_0}) list) | poly q = poly r)" |
52778 | 416 |
apply (rule_tac p1 = "p *** q" in poly_add_minus_zero_iff [THEN subst]) |
417 |
apply (auto simp add: poly_add_minus_mult_eq poly_entire poly_add_minus_zero_iff) |
|
418 |
done |
|
33153 | 419 |
|
52778 | 420 |
lemma poly_exp_eq_zero [simp]: |
52881 | 421 |
"poly (p %^ n) = poly ([]::('a::idom) list) \<longleftrightarrow> poly p = poly [] \<and> n \<noteq> 0" |
52778 | 422 |
apply (simp only: fun_eq add: HOL.all_simps [symmetric]) |
423 |
apply (rule arg_cong [where f = All]) |
|
424 |
apply (rule ext) |
|
52881 | 425 |
apply (induct_tac n) |
52778 | 426 |
apply (auto simp add: poly_mult) |
427 |
done |
|
33153 | 428 |
|
52881 | 429 |
lemma poly_prime_eq_zero [simp]: "poly [a, 1::'a::comm_ring_1] \<noteq> poly []" |
52778 | 430 |
apply (simp add: fun_eq) |
52881 | 431 |
apply (rule_tac x = "1 - a" in exI) |
432 |
apply simp |
|
52778 | 433 |
done |
33153 | 434 |
|
52881 | 435 |
lemma poly_exp_prime_eq_zero [simp]: "poly ([a, (1::'a::idom)] %^ n) \<noteq> poly []" |
52778 | 436 |
by auto |
33153 | 437 |
|
438 |
text{*A more constructive notion of polynomials being trivial*} |
|
439 |
||
52778 | 440 |
lemma poly_zero_lemma': |
441 |
"poly (h # t) = poly [] \<Longrightarrow> h = (0::'a::{idom,ring_char_0}) & poly t = poly []" |
|
442 |
apply (simp add: fun_eq) |
|
443 |
apply (case_tac "h = 0") |
|
52881 | 444 |
apply (drule_tac [2] x = 0 in spec) |
445 |
apply auto |
|
446 |
apply (case_tac "poly t = poly []") |
|
447 |
apply simp |
|
52778 | 448 |
proof - |
33153 | 449 |
fix x |
450 |
assume H: "\<forall>x. x = (0\<Colon>'a) \<or> poly t x = (0\<Colon>'a)" and pnz: "poly t \<noteq> poly []" |
|
451 |
let ?S = "{x. poly t x = 0}" |
|
452 |
from H have "\<forall>x. x \<noteq>0 \<longrightarrow> poly t x = 0" by blast |
|
453 |
hence th: "?S \<supseteq> UNIV - {0}" by auto |
|
454 |
from poly_roots_finite pnz have th': "finite ?S" by blast |
|
455 |
from finite_subset[OF th th'] UNIV_ring_char_0_infinte[where ?'a = 'a] |
|
456 |
show "poly t x = (0\<Colon>'a)" by simp |
|
52778 | 457 |
qed |
33153 | 458 |
|
52881 | 459 |
lemma poly_zero: "poly p = poly [] \<longleftrightarrow> list_all (\<lambda>c. c = (0::'a::{idom,ring_char_0})) p" |
52778 | 460 |
apply (induct p) |
461 |
apply simp |
|
462 |
apply (rule iffI) |
|
463 |
apply (drule poly_zero_lemma') |
|
464 |
apply auto |
|
465 |
done |
|
33153 | 466 |
|
467 |
||
468 |
text{*Basics of divisibility.*} |
|
469 |
||
52881 | 470 |
lemma poly_primes: "[a, (1::'a::idom)] divides (p *** q) \<longleftrightarrow> [a, 1] divides p \<or> [a, 1] divides q" |
52778 | 471 |
apply (auto simp add: divides_def fun_eq poly_mult poly_add poly_cmult distrib_right [symmetric]) |
472 |
apply (drule_tac x = "-a" in spec) |
|
473 |
apply (auto simp add: poly_linear_divides poly_add poly_cmult distrib_right [symmetric]) |
|
474 |
apply (rule_tac x = "qa *** q" in exI) |
|
475 |
apply (rule_tac [2] x = "p *** qa" in exI) |
|
476 |
apply (auto simp add: poly_add poly_mult poly_cmult mult_ac) |
|
477 |
done |
|
33153 | 478 |
|
52778 | 479 |
lemma poly_divides_refl [simp]: "p divides p" |
480 |
apply (simp add: divides_def) |
|
481 |
apply (rule_tac x = "[1]" in exI) |
|
482 |
apply (auto simp add: poly_mult fun_eq) |
|
483 |
done |
|
33153 | 484 |
|
52778 | 485 |
lemma poly_divides_trans: "p divides q \<Longrightarrow> q divides r \<Longrightarrow> p divides r" |
52881 | 486 |
apply (simp add: divides_def) |
487 |
apply safe |
|
52778 | 488 |
apply (rule_tac x = "qa *** qaa" in exI) |
489 |
apply (auto simp add: poly_mult fun_eq mult_assoc) |
|
490 |
done |
|
33153 | 491 |
|
52778 | 492 |
lemma poly_divides_exp: "m \<le> n \<Longrightarrow> (p %^ m) divides (p %^ n)" |
493 |
apply (auto simp add: le_iff_add) |
|
494 |
apply (induct_tac k) |
|
495 |
apply (rule_tac [2] poly_divides_trans) |
|
496 |
apply (auto simp add: divides_def) |
|
497 |
apply (rule_tac x = p in exI) |
|
498 |
apply (auto simp add: poly_mult fun_eq mult_ac) |
|
499 |
done |
|
33153 | 500 |
|
52778 | 501 |
lemma poly_exp_divides: "(p %^ n) divides q \<Longrightarrow> m \<le> n \<Longrightarrow> (p %^ m) divides q" |
502 |
by (blast intro: poly_divides_exp poly_divides_trans) |
|
33153 | 503 |
|
52778 | 504 |
lemma poly_divides_add: "p divides q \<Longrightarrow> p divides r \<Longrightarrow> p divides (q +++ r)" |
52881 | 505 |
apply (simp add: divides_def) |
506 |
apply auto |
|
52778 | 507 |
apply (rule_tac x = "qa +++ qaa" in exI) |
508 |
apply (auto simp add: poly_add fun_eq poly_mult distrib_left) |
|
509 |
done |
|
33153 | 510 |
|
52778 | 511 |
lemma poly_divides_diff: "p divides q \<Longrightarrow> p divides (q +++ r) \<Longrightarrow> p divides r" |
52881 | 512 |
apply (auto simp add: divides_def) |
52778 | 513 |
apply (rule_tac x = "qaa +++ -- qa" in exI) |
514 |
apply (auto simp add: poly_add fun_eq poly_mult poly_minus algebra_simps) |
|
515 |
done |
|
33153 | 516 |
|
52881 | 517 |
lemma poly_divides_diff2: "p divides r \<Longrightarrow> p divides (q +++ r) \<Longrightarrow> p divides q" |
52778 | 518 |
apply (erule poly_divides_diff) |
519 |
apply (auto simp add: poly_add fun_eq poly_mult divides_def add_ac) |
|
520 |
done |
|
33153 | 521 |
|
52881 | 522 |
lemma poly_divides_zero: "poly p = poly [] \<Longrightarrow> q divides p" |
52778 | 523 |
apply (simp add: divides_def) |
52881 | 524 |
apply (rule exI [where x = "[]"]) |
52778 | 525 |
apply (auto simp add: fun_eq poly_mult) |
526 |
done |
|
33153 | 527 |
|
52778 | 528 |
lemma poly_divides_zero2 [simp]: "q divides []" |
529 |
apply (simp add: divides_def) |
|
530 |
apply (rule_tac x = "[]" in exI) |
|
531 |
apply (auto simp add: fun_eq) |
|
532 |
done |
|
33153 | 533 |
|
534 |
text{*At last, we can consider the order of a root.*} |
|
535 |
||
536 |
lemma poly_order_exists_lemma [rule_format]: |
|
52778 | 537 |
"\<forall>p. length p = d \<longrightarrow> poly p \<noteq> poly [] \<longrightarrow> |
538 |
(\<exists>n q. p = mulexp n [-a, (1::'a::{idom,ring_char_0})] q & poly q a \<noteq> 0)" |
|
539 |
apply (induct "d") |
|
52881 | 540 |
apply (simp add: fun_eq) |
541 |
apply safe |
|
52778 | 542 |
apply (case_tac "poly p a = 0") |
52881 | 543 |
apply (drule_tac poly_linear_divides [THEN iffD1]) |
544 |
apply safe |
|
52778 | 545 |
apply (drule_tac x = q in spec) |
52881 | 546 |
apply (drule_tac poly_entire_neg [THEN iffD1]) |
547 |
apply safe |
|
548 |
apply force |
|
52778 | 549 |
apply (rule_tac x = "Suc n" in exI) |
550 |
apply (rule_tac x = qa in exI) |
|
551 |
apply (simp del: pmult_Cons) |
|
52881 | 552 |
apply (rule_tac x = 0 in exI) |
553 |
apply force |
|
52778 | 554 |
done |
33153 | 555 |
|
556 |
(* FIXME: Tidy up *) |
|
557 |
lemma poly_order_exists: |
|
52881 | 558 |
"length p = d \<Longrightarrow> poly p \<noteq> poly [] \<Longrightarrow> |
559 |
\<exists>n. ([-a, 1] %^ n) divides p \<and> \<not> (([-a, (1::'a::{idom,ring_char_0})] %^ (Suc n)) divides p)" |
|
560 |
apply (drule poly_order_exists_lemma [where a=a]) |
|
561 |
apply assumption |
|
562 |
apply clarify |
|
563 |
apply (rule_tac x = n in exI) |
|
564 |
apply safe |
|
52778 | 565 |
apply (unfold divides_def) |
566 |
apply (rule_tac x = q in exI) |
|
52881 | 567 |
apply (induct_tac n) |
568 |
apply simp |
|
569 |
apply (simp add: poly_add poly_cmult poly_mult distrib_left mult_ac) |
|
52778 | 570 |
apply safe |
571 |
apply (subgoal_tac "poly (mulexp n [- a, 1] q) \<noteq> poly ([- a, 1] %^ Suc n *** qa)") |
|
572 |
apply simp |
|
573 |
apply (induct_tac n) |
|
574 |
apply (simp del: pmult_Cons pexp_Suc) |
|
575 |
apply (erule_tac Q = "poly q a = 0" in contrapos_np) |
|
576 |
apply (simp add: poly_add poly_cmult) |
|
577 |
apply (rule pexp_Suc [THEN ssubst]) |
|
578 |
apply (rule ccontr) |
|
579 |
apply (simp add: poly_mult_left_cancel poly_mult_assoc del: pmult_Cons pexp_Suc) |
|
580 |
done |
|
33153 | 581 |
|
52778 | 582 |
lemma poly_one_divides [simp]: "[1] divides p" |
583 |
by (auto simp: divides_def) |
|
33153 | 584 |
|
52881 | 585 |
lemma poly_order: "poly p \<noteq> poly [] \<Longrightarrow> |
586 |
\<exists>! n. ([-a, (1::'a::{idom,ring_char_0})] %^ n) divides p \<and> \<not> (([-a, 1] %^ Suc n) divides p)" |
|
52778 | 587 |
apply (auto intro: poly_order_exists simp add: less_linear simp del: pmult_Cons pexp_Suc) |
588 |
apply (cut_tac x = y and y = n in less_linear) |
|
589 |
apply (drule_tac m = n in poly_exp_divides) |
|
590 |
apply (auto dest: Suc_le_eq [THEN iffD2, THEN [2] poly_exp_divides] |
|
52881 | 591 |
simp del: pmult_Cons pexp_Suc) |
52778 | 592 |
done |
33153 | 593 |
|
594 |
text{*Order*} |
|
595 |
||
52881 | 596 |
lemma some1_equalityD: "n = (SOME n. P n) \<Longrightarrow> EX! n. P n \<Longrightarrow> P n" |
52778 | 597 |
by (blast intro: someI2) |
33153 | 598 |
|
599 |
lemma order: |
|
52778 | 600 |
"(([-a, (1::'a::{idom,ring_char_0})] %^ n) divides p & |
601 |
~(([-a, 1] %^ (Suc n)) divides p)) = |
|
602 |
((n = order a p) & ~(poly p = poly []))" |
|
603 |
apply (unfold order_def) |
|
604 |
apply (rule iffI) |
|
605 |
apply (blast dest: poly_divides_zero intro!: some1_equality [symmetric] poly_order) |
|
606 |
apply (blast intro!: poly_order [THEN [2] some1_equalityD]) |
|
607 |
done |
|
33153 | 608 |
|
52778 | 609 |
lemma order2: "poly p \<noteq> poly [] \<Longrightarrow> |
610 |
([-a, (1::'a::{idom,ring_char_0})] %^ (order a p)) divides p & |
|
611 |
~(([-a, 1] %^ (Suc(order a p))) divides p)" |
|
612 |
by (simp add: order del: pexp_Suc) |
|
33153 | 613 |
|
52881 | 614 |
lemma order_unique: "poly p \<noteq> poly [] \<Longrightarrow> ([-a, 1] %^ n) divides p \<Longrightarrow> |
615 |
\<not> (([-a, (1::'a::{idom,ring_char_0})] %^ (Suc n)) divides p) \<Longrightarrow> n = order a p" |
|
52778 | 616 |
using order [of a n p] by auto |
33153 | 617 |
|
52881 | 618 |
lemma order_unique_lemma: |
619 |
"(poly p \<noteq> poly [] \<and> ([-a, 1] %^ n) divides p \<and> |
|
620 |
\<not> (([-a, (1::'a::{idom,ring_char_0})] %^ (Suc n)) divides p)) \<Longrightarrow> |
|
621 |
n = order a p" |
|
52778 | 622 |
by (blast intro: order_unique) |
33153 | 623 |
|
624 |
lemma order_poly: "poly p = poly q ==> order a p = order a q" |
|
52778 | 625 |
by (auto simp add: fun_eq divides_def poly_mult order_def) |
33153 | 626 |
|
52778 | 627 |
lemma pexp_one [simp]: "p %^ (Suc 0) = p" |
628 |
by (induct p) simp_all |
|
33153 | 629 |
|
52881 | 630 |
lemma lemma_order_root: |
631 |
"0 < n & [- a, 1] %^ n divides p & ~ [- a, 1] %^ (Suc n) divides p \<Longrightarrow> poly p a = 0" |
|
632 |
apply (induct n arbitrary: p a) |
|
52778 | 633 |
apply blast |
634 |
apply (auto simp add: divides_def poly_mult simp del: pmult_Cons) |
|
635 |
done |
|
33153 | 636 |
|
52881 | 637 |
lemma order_root: "poly p a = (0::'a::{idom,ring_char_0}) \<longleftrightarrow> poly p = poly [] \<or> order a p \<noteq> 0" |
638 |
apply (cases "poly p = poly []") |
|
639 |
apply auto |
|
640 |
apply (simp add: poly_linear_divides del: pmult_Cons) |
|
641 |
apply safe |
|
52778 | 642 |
apply (drule_tac [!] a = a in order2) |
643 |
apply (rule ccontr) |
|
52881 | 644 |
apply (simp add: divides_def poly_mult fun_eq del: pmult_Cons) |
645 |
apply blast |
|
646 |
using neq0_conv apply (blast intro: lemma_order_root) |
|
52778 | 647 |
done |
33153 | 648 |
|
52881 | 649 |
lemma order_divides: "([-a, 1::'a::{idom,ring_char_0}] %^ n) divides p \<longleftrightarrow> |
650 |
poly p = poly [] \<or> n \<le> order a p" |
|
651 |
apply (cases "poly p = poly []") |
|
652 |
apply auto |
|
52778 | 653 |
apply (simp add: divides_def fun_eq poly_mult) |
654 |
apply (rule_tac x = "[]" in exI) |
|
52881 | 655 |
apply (auto dest!: order2 [where a = a] intro: poly_exp_divides simp del: pexp_Suc) |
52778 | 656 |
done |
33153 | 657 |
|
658 |
lemma order_decomp: |
|
52778 | 659 |
"poly p \<noteq> poly [] \<Longrightarrow> |
52881 | 660 |
\<exists>q. poly p = poly (([-a, 1] %^ (order a p)) *** q) \<and> |
661 |
\<not> ([-a, 1::'a::{idom,ring_char_0}] divides q)" |
|
52778 | 662 |
apply (unfold divides_def) |
663 |
apply (drule order2 [where a = a]) |
|
52881 | 664 |
apply (simp add: divides_def del: pexp_Suc pmult_Cons) |
665 |
apply safe |
|
666 |
apply (rule_tac x = q in exI) |
|
667 |
apply safe |
|
52778 | 668 |
apply (drule_tac x = qa in spec) |
669 |
apply (auto simp add: poly_mult fun_eq poly_exp mult_ac simp del: pmult_Cons) |
|
670 |
done |
|
33153 | 671 |
|
672 |
text{*Important composition properties of orders.*} |
|
673 |
||
52778 | 674 |
lemma order_mult: "poly (p *** q) \<noteq> poly [] \<Longrightarrow> |
675 |
order a (p *** q) = order a p + order (a::'a::{idom,ring_char_0}) q" |
|
676 |
apply (cut_tac a = a and p = "p***q" and n = "order a p + order a q" in order) |
|
677 |
apply (auto simp add: poly_entire simp del: pmult_Cons) |
|
678 |
apply (drule_tac a = a in order2)+ |
|
679 |
apply safe |
|
52881 | 680 |
apply (simp add: divides_def fun_eq poly_exp_add poly_mult del: pmult_Cons) |
681 |
apply safe |
|
52778 | 682 |
apply (rule_tac x = "qa *** qaa" in exI) |
683 |
apply (simp add: poly_mult mult_ac del: pmult_Cons) |
|
684 |
apply (drule_tac a = a in order_decomp)+ |
|
685 |
apply safe |
|
52881 | 686 |
apply (subgoal_tac "[-a, 1] divides (qa *** qaa) ") |
52778 | 687 |
apply (simp add: poly_primes del: pmult_Cons) |
688 |
apply (auto simp add: divides_def simp del: pmult_Cons) |
|
689 |
apply (rule_tac x = qb in exI) |
|
52881 | 690 |
apply (subgoal_tac "poly ([-a, 1] %^ (order a p) *** (qa *** qaa)) = |
691 |
poly ([-a, 1] %^ (order a p) *** ([-a, 1] *** qb))") |
|
692 |
apply (drule poly_mult_left_cancel [THEN iffD1]) |
|
693 |
apply force |
|
694 |
apply (subgoal_tac "poly ([-a, 1] %^ (order a q) *** ([-a, 1] %^ (order a p) *** (qa *** qaa))) = |
|
695 |
poly ([-a, 1] %^ (order a q) *** ([-a, 1] %^ (order a p) *** ([-a, 1] *** qb))) ") |
|
696 |
apply (drule poly_mult_left_cancel [THEN iffD1]) |
|
697 |
apply force |
|
52778 | 698 |
apply (simp add: fun_eq poly_exp_add poly_mult mult_ac del: pmult_Cons) |
699 |
done |
|
33153 | 700 |
|
52881 | 701 |
lemma order_root2: "poly p \<noteq> poly [] \<Longrightarrow> poly p a = 0 \<longleftrightarrow> order (a::'a::{idom,ring_char_0}) p \<noteq> 0" |
702 |
by (rule order_root [THEN ssubst]) auto |
|
33153 | 703 |
|
52778 | 704 |
lemma pmult_one [simp]: "[1] *** p = p" |
705 |
by auto |
|
33153 | 706 |
|
707 |
lemma poly_Nil_zero: "poly [] = poly [0]" |
|
52778 | 708 |
by (simp add: fun_eq) |
33153 | 709 |
|
710 |
lemma rsquarefree_decomp: |
|
52881 | 711 |
"rsquarefree p \<Longrightarrow> poly p a = (0::'a::{idom,ring_char_0}) \<Longrightarrow> |
712 |
\<exists>q. poly p = poly ([-a, 1] *** q) \<and> poly q a \<noteq> 0" |
|
713 |
apply (simp add: rsquarefree_def) |
|
714 |
apply safe |
|
52778 | 715 |
apply (frule_tac a = a in order_decomp) |
716 |
apply (drule_tac x = a in spec) |
|
717 |
apply (drule_tac a = a in order_root2 [symmetric]) |
|
718 |
apply (auto simp del: pmult_Cons) |
|
52881 | 719 |
apply (rule_tac x = q in exI) |
720 |
apply safe |
|
52778 | 721 |
apply (simp add: poly_mult fun_eq) |
722 |
apply (drule_tac p1 = q in poly_linear_divides [THEN iffD1]) |
|
52881 | 723 |
apply (simp add: divides_def del: pmult_Cons) |
724 |
apply safe |
|
52778 | 725 |
apply (drule_tac x = "[]" in spec) |
726 |
apply (auto simp add: fun_eq) |
|
727 |
done |
|
33153 | 728 |
|
729 |
||
730 |
text{*Normalization of a polynomial.*} |
|
731 |
||
52778 | 732 |
lemma poly_normalize [simp]: "poly (pnormalize p) = poly p" |
733 |
by (induct p) (auto simp add: fun_eq) |
|
33153 | 734 |
|
735 |
||
736 |
text{*The degree of a polynomial.*} |
|
737 |
||
52881 | 738 |
lemma lemma_degree_zero: "list_all (\<lambda>c. c = 0) p \<longleftrightarrow> pnormalize p = []" |
52778 | 739 |
by (induct p) auto |
33153 | 740 |
|
52881 | 741 |
lemma degree_zero: "poly p = poly ([] :: 'a::{idom,ring_char_0} list) \<Longrightarrow> degree p = 0" |
742 |
apply (cases "pnormalize p = []") |
|
52778 | 743 |
apply (simp add: degree_def) |
52881 | 744 |
apply (auto simp add: poly_zero lemma_degree_zero) |
52778 | 745 |
done |
33153 | 746 |
|
52881 | 747 |
lemma pnormalize_sing: "pnormalize [x] = [x] \<longleftrightarrow> x \<noteq> 0" |
748 |
by simp |
|
52778 | 749 |
|
52881 | 750 |
lemma pnormalize_pair: "y \<noteq> 0 \<longleftrightarrow> (pnormalize [x, y] = [x, y])" |
751 |
by simp |
|
52778 | 752 |
|
52881 | 753 |
lemma pnormal_cons: "pnormal p \<Longrightarrow> pnormal (c # p)" |
33153 | 754 |
unfolding pnormal_def by simp |
52778 | 755 |
|
52881 | 756 |
lemma pnormal_tail: "p \<noteq> [] \<Longrightarrow> pnormal (c # p) \<Longrightarrow> pnormal p" |
52778 | 757 |
unfolding pnormal_def |
52881 | 758 |
apply (cases "pnormalize p = []") |
759 |
apply auto |
|
760 |
apply (cases "c = 0") |
|
761 |
apply auto |
|
52778 | 762 |
done |
763 |
||
52881 | 764 |
lemma pnormal_last_nonzero: "pnormal p \<Longrightarrow> last p \<noteq> 0" |
765 |
apply (induct p) |
|
766 |
apply (auto simp add: pnormal_def) |
|
767 |
apply (case_tac "pnormalize p = []") |
|
768 |
apply auto |
|
769 |
apply (case_tac "a = 0") |
|
770 |
apply auto |
|
52778 | 771 |
done |
772 |
||
33153 | 773 |
lemma pnormal_length: "pnormal p \<Longrightarrow> 0 < length p" |
774 |
unfolding pnormal_def length_greater_0_conv by blast |
|
52778 | 775 |
|
52881 | 776 |
lemma pnormal_last_length: "0 < length p \<Longrightarrow> last p \<noteq> 0 \<Longrightarrow> pnormal p" |
777 |
apply (induct p) |
|
778 |
apply auto |
|
779 |
apply (case_tac "p = []") |
|
780 |
apply auto |
|
33153 | 781 |
apply (simp add: pnormal_def) |
52881 | 782 |
apply (rule pnormal_cons) |
783 |
apply auto |
|
52778 | 784 |
done |
785 |
||
52881 | 786 |
lemma pnormal_id: "pnormal p \<longleftrightarrow> 0 < length p \<and> last p \<noteq> 0" |
33153 | 787 |
using pnormal_last_length pnormal_length pnormal_last_nonzero by blast |
788 |
||
789 |
text{*Tidier versions of finiteness of roots.*} |
|
790 |
||
52778 | 791 |
lemma poly_roots_finite_set: |
792 |
"poly p \<noteq> poly [] \<Longrightarrow> finite {x::'a::{idom,ring_char_0}. poly p x = 0}" |
|
793 |
unfolding poly_roots_finite . |
|
33153 | 794 |
|
795 |
text{*bound for polynomial.*} |
|
796 |
||
52881 | 797 |
lemma poly_mono: "abs x \<le> k \<Longrightarrow> abs (poly p (x::'a::{linordered_idom})) \<le> poly (map abs p) k" |
798 |
apply (induct p) |
|
799 |
apply auto |
|
52778 | 800 |
apply (rule_tac y = "abs a + abs (x * poly p x)" in order_trans) |
801 |
apply (rule abs_triangle_ineq) |
|
802 |
apply (auto intro!: mult_mono simp add: abs_mult) |
|
803 |
done |
|
33153 | 804 |
|
52881 | 805 |
lemma poly_Sing: "poly [c] x = c" |
806 |
by simp |
|
33268
02de0317f66f
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
33153
diff
changeset
|
807 |
|
33153 | 808 |
end |