215 case (Cons x xs) |
215 case (Cons x xs) |
216 {fix h |
216 {fix h |
217 from Cons.hyps[rule_format, of x] |
217 from Cons.hyps[rule_format, of x] |
218 obtain q r where qr: "x#xs = [r] +++ [- a, 1] *** q" by blast |
218 obtain q r where qr: "x#xs = [r] +++ [- a, 1] *** q" by blast |
219 have "h#x#xs = [a*r + h] +++ [-a, 1] *** (r#q)" |
219 have "h#x#xs = [a*r + h] +++ [-a, 1] *** (r#q)" |
220 using qr by(cases q, simp_all add: ring_simps diff_def[symmetric] |
220 using qr by(cases q, simp_all add: algebra_simps diff_def[symmetric] |
221 minus_mult_left[symmetric] right_minus) |
221 minus_mult_left[symmetric] right_minus) |
222 hence "\<exists>q r. h#x#xs = [r] +++ [-a, 1] *** q" by blast} |
222 hence "\<exists>q r. h#x#xs = [r] +++ [-a, 1] *** q" by blast} |
223 thus ?case by blast |
223 thus ?case by blast |
224 qed |
224 qed |
225 |
225 |
301 i: "\<forall>x. poly q x = 0 \<longrightarrow> (\<exists>m\<le>n. x = i m)" by blast |
301 i: "\<forall>x. poly q x = 0 \<longrightarrow> (\<exists>m\<le>n. x = i m)" by blast |
302 let ?i = "\<lambda>m. if m = Suc n then a else i m" |
302 let ?i = "\<lambda>m. if m = Suc n then a else i m" |
303 from C[of ?i] obtain y where y: "poly p y = 0" "\<forall>m\<le> Suc n. y \<noteq> ?i m" |
303 from C[of ?i] obtain y where y: "poly p y = 0" "\<forall>m\<le> Suc n. y \<noteq> ?i m" |
304 by blast |
304 by blast |
305 from y have "y = a \<or> poly q y = 0" |
305 from y have "y = a \<or> poly q y = 0" |
306 by (simp only: q poly_mult_eq_zero_disj poly_add) (simp add: ring_simps) |
306 by (simp only: q poly_mult_eq_zero_disj poly_add) (simp add: algebra_simps) |
307 with i[rule_format, of y] y(1) y(2) have False apply auto |
307 with i[rule_format, of y] y(1) y(2) have False apply auto |
308 apply (erule_tac x="m" in allE) |
308 apply (erule_tac x="m" in allE) |
309 apply auto |
309 apply auto |
310 done} |
310 done} |
311 thus ?case by blast |
311 thus ?case by blast |
412 with p0 q0 show ?thesis unfolding poly_roots_finite by auto |
412 with p0 q0 show ?thesis unfolding poly_roots_finite by auto |
413 qed |
413 qed |
414 |
414 |
415 lemma (in idom_char_0) poly_entire: |
415 lemma (in idom_char_0) poly_entire: |
416 "poly (p *** q) = poly [] \<longleftrightarrow> poly p = poly [] \<or> poly q = poly []" |
416 "poly (p *** q) = poly [] \<longleftrightarrow> poly p = poly [] \<or> poly q = poly []" |
417 using poly_entire_lemma2[of p q] |
417 using poly_entire_lemma2[of p q] |
418 by auto (rule ext, simp add: poly_mult)+ |
418 by (auto simp add: expand_fun_eq poly_mult) |
419 |
419 |
420 lemma (in idom_char_0) poly_entire_neg: "(poly (p *** q) \<noteq> poly []) = ((poly p \<noteq> poly []) & (poly q \<noteq> poly []))" |
420 lemma (in idom_char_0) poly_entire_neg: "(poly (p *** q) \<noteq> poly []) = ((poly p \<noteq> poly []) & (poly q \<noteq> poly []))" |
421 by (simp add: poly_entire) |
421 by (simp add: poly_entire) |
422 |
422 |
423 lemma fun_eq: " (f = g) = (\<forall>x. f x = g x)" |
423 lemma fun_eq: " (f = g) = (\<forall>x. f x = g x)" |
424 by (auto intro!: ext) |
424 by (auto intro!: ext) |
425 |
425 |
426 lemma (in comm_ring_1) poly_add_minus_zero_iff: "(poly (p +++ -- q) = poly []) = (poly p = poly q)" |
426 lemma (in comm_ring_1) poly_add_minus_zero_iff: "(poly (p +++ -- q) = poly []) = (poly p = poly q)" |
427 by (auto simp add: ring_simps poly_add poly_minus_def fun_eq poly_cmult minus_mult_left[symmetric]) |
427 by (auto simp add: algebra_simps poly_add poly_minus_def fun_eq poly_cmult minus_mult_left[symmetric]) |
428 |
428 |
429 lemma (in comm_ring_1) poly_add_minus_mult_eq: "poly (p *** q +++ --(p *** r)) = poly (p *** (q +++ -- r))" |
429 lemma (in comm_ring_1) poly_add_minus_mult_eq: "poly (p *** q +++ --(p *** r)) = poly (p *** (q +++ -- r))" |
430 by (auto simp add: poly_add poly_minus_def fun_eq poly_mult poly_cmult right_distrib minus_mult_left[symmetric] minus_mult_right[symmetric]) |
430 by (auto simp add: poly_add poly_minus_def fun_eq poly_mult poly_cmult right_distrib minus_mult_left[symmetric] minus_mult_right[symmetric]) |
431 |
431 |
432 subclass (in idom_char_0) comm_ring_1 .. |
432 subclass (in idom_char_0) comm_ring_1 .. |
548 |
548 |
549 lemma (in comm_ring_1) poly_divides_diff: |
549 lemma (in comm_ring_1) poly_divides_diff: |
550 "[| p divides q; p divides (q +++ r) |] ==> p divides r" |
550 "[| p divides q; p divides (q +++ r) |] ==> p divides r" |
551 apply (simp add: divides_def, auto) |
551 apply (simp add: divides_def, auto) |
552 apply (rule_tac x = "padd qaa (poly_minus qa)" in exI) |
552 apply (rule_tac x = "padd qaa (poly_minus qa)" in exI) |
553 apply (auto simp add: poly_add fun_eq poly_mult poly_minus right_diff_distrib compare_rls add_ac) |
553 apply (auto simp add: poly_add fun_eq poly_mult poly_minus algebra_simps) |
554 done |
554 done |
555 |
555 |
556 lemma (in comm_ring_1) poly_divides_diff2: "[| p divides r; p divides (q +++ r) |] ==> p divides q" |
556 lemma (in comm_ring_1) poly_divides_diff2: "[| p divides r; p divides (q +++ r) |] ==> p divides q" |
557 apply (erule poly_divides_diff) |
557 apply (erule poly_divides_diff) |
558 apply (auto simp add: poly_add fun_eq poly_mult divides_def add_ac) |
558 apply (auto simp add: poly_add fun_eq poly_mult divides_def add_ac) |
890 |
890 |
891 lemma (in idom_char_0) poly_Cons_eq: "poly (c#cs) = poly (d#ds) \<longleftrightarrow> c=d \<and> poly cs = poly ds" (is "?lhs \<longleftrightarrow> ?rhs") |
891 lemma (in idom_char_0) poly_Cons_eq: "poly (c#cs) = poly (d#ds) \<longleftrightarrow> c=d \<and> poly cs = poly ds" (is "?lhs \<longleftrightarrow> ?rhs") |
892 proof |
892 proof |
893 assume eq: ?lhs |
893 assume eq: ?lhs |
894 hence "\<And>x. poly ((c#cs) +++ -- (d#ds)) x = 0" |
894 hence "\<And>x. poly ((c#cs) +++ -- (d#ds)) x = 0" |
895 by (simp only: poly_minus poly_add ring_simps) simp |
895 by (simp only: poly_minus poly_add algebra_simps) simp |
896 hence "poly ((c#cs) +++ -- (d#ds)) = poly []" by - (rule ext, simp) |
896 hence "poly ((c#cs) +++ -- (d#ds)) = poly []" by(simp add:expand_fun_eq) |
897 hence "c = d \<and> list_all (\<lambda>x. x=0) ((cs +++ -- ds))" |
897 hence "c = d \<and> list_all (\<lambda>x. x=0) ((cs +++ -- ds))" |
898 unfolding poly_zero by (simp add: poly_minus_def ring_simps minus_mult_left[symmetric]) |
898 unfolding poly_zero by (simp add: poly_minus_def algebra_simps) |
899 hence "c = d \<and> (\<forall>x. poly (cs +++ -- ds) x = 0)" |
899 hence "c = d \<and> (\<forall>x. poly (cs +++ -- ds) x = 0)" |
900 unfolding poly_zero[symmetric] by simp |
900 unfolding poly_zero[symmetric] by simp |
901 thus ?rhs apply (simp add: poly_minus poly_add ring_simps) apply (rule ext, simp) done |
901 thus ?rhs by (simp add: poly_minus poly_add algebra_simps expand_fun_eq) |
902 next |
902 next |
903 assume ?rhs then show ?lhs by - (rule ext,simp) |
903 assume ?rhs then show ?lhs by(simp add:expand_fun_eq) |
904 qed |
904 qed |
905 |
905 |
906 lemma (in idom_char_0) pnormalize_unique: "poly p = poly q \<Longrightarrow> pnormalize p = pnormalize q" |
906 lemma (in idom_char_0) pnormalize_unique: "poly p = poly q \<Longrightarrow> pnormalize p = pnormalize q" |
907 proof(induct q arbitrary: p) |
907 proof(induct q arbitrary: p) |
908 case Nil thus ?case by (simp only: poly_zero lemma_degree_zero) simp |
908 case Nil thus ?case by (simp only: poly_zero lemma_degree_zero) simp |
1006 moreover |
1006 moreover |
1007 {assume p: "poly p \<noteq> poly []" |
1007 {assume p: "poly p \<noteq> poly []" |
1008 from p have ap: "poly ([a,1] *** p) \<noteq> poly []" |
1008 from p have ap: "poly ([a,1] *** p) \<noteq> poly []" |
1009 using poly_mult_not_eq_poly_Nil unfolding poly_entire by auto |
1009 using poly_mult_not_eq_poly_Nil unfolding poly_entire by auto |
1010 have eq: "poly ([a,1] %^(Suc n) *** p) = poly ([a,1]%^n *** ([a,1] *** p))" |
1010 have eq: "poly ([a,1] %^(Suc n) *** p) = poly ([a,1]%^n *** ([a,1] *** p))" |
1011 by (rule ext, simp add: poly_mult poly_add poly_exp poly_cmult mult_ac add_ac right_distrib) |
1011 by (rule ext, simp add: poly_mult poly_add poly_exp poly_cmult algebra_simps) |
1012 from ap have ap': "(poly ([a,1] *** p) = poly []) = False" by blast |
1012 from ap have ap': "(poly ([a,1] *** p) = poly []) = False" by blast |
1013 have th0: "degree ([a,1]%^n *** ([a,1] *** p)) = degree ([a,1] *** p) + n" |
1013 have th0: "degree ([a,1]%^n *** ([a,1] *** p)) = degree ([a,1] *** p) + n" |
1014 apply (simp only: Suc.hyps[of a "pmult [a,one] p"] ap') |
1014 apply (simp only: Suc.hyps[of a "pmult [a,one] p"] ap') |
1015 by simp |
1015 by simp |
1016 |
1016 |