@@ -463,6 +463,23 @@ lemma roots_prod_X_sub_C (s : finset R) :
463
463
(roots_prod (λ a, X - C a) s (prod_ne_zero_iff.mpr (λ a _, X_sub_C_ne_zero a))).trans
464
464
(by simp_rw [roots_X_sub_C, multiset.bind_singleton, multiset.map_id'])
465
465
466
+ @[simp] lemma roots_multiset_prod_X_sub_C (s : multiset R) :
467
+ (s.map (λ a, X - C a)).prod.roots = s :=
468
+ begin
469
+ rw [roots_multiset_prod, multiset.bind_map],
470
+ { simp_rw [roots_X_sub_C, multiset.bind_singleton, multiset.map_id'] },
471
+ { rw [multiset.mem_map], rintro ⟨a, -, h⟩, exact X_sub_C_ne_zero a h },
472
+ end
473
+
474
+ @[simp] lemma nat_degree_multiset_prod_X_sub_C_eq_card (s : multiset R):
475
+ (s.map (λ a, X - C a)).prod.nat_degree = s.card :=
476
+ begin
477
+ rw [nat_degree_multiset_prod_of_monic, multiset.map_map],
478
+ { convert multiset.sum_repeat 1 _,
479
+ { convert multiset.map_const _ 1 , ext, apply nat_degree_X_sub_C }, { simp } },
480
+ { intros f hf, obtain ⟨a, ha, rfl⟩ := multiset.mem_map.1 hf, exact monic_X_sub_C a },
481
+ end
482
+
466
483
lemma card_roots_X_pow_sub_C {n : ℕ} (hn : 0 < n) (a : R) :
467
484
(roots ((X : R[X]) ^ n - C a)).card ≤ n :=
468
485
with_bot.coe_le_coe.1 $
@@ -498,8 +515,8 @@ begin
498
515
simp only [polynomial.map_pow, polynomial.map_sub, map_pow, map_sub, map_X, map_C],
499
516
end
500
517
501
- lemma count_map_roots [is_domain A] { p : A[X]} {f : A →+* B} (hf : function.injective f)
502
- (a : B) : count a (multiset. map f p.roots ) ≤ root_multiplicity a (map f p) :=
518
+ lemma count_map_roots [is_domain A] ( p : A[X]) {f : A →+* B} (hf : function.injective f)
519
+ (a : B) : count a (p.roots. map f) ≤ root_multiplicity a (map f p) :=
503
520
begin
504
521
by_cases h : ∃ t, f t = a,
505
522
{ rcases h with ⟨h_w, rfl⟩,
@@ -514,12 +531,12 @@ end
514
531
515
532
lemma roots_map_of_injective_card_eq_total_degree [is_domain A] [is_domain B] {p : A[X]}
516
533
{f : A →+* B} (hf : function.injective f) (hroots : p.roots.card = p.nat_degree) :
517
- multiset. map f p.roots = (map f p).roots :=
534
+ p.roots. map f = (map f p).roots :=
518
535
begin
519
536
by_cases hp0 : p = 0 , { simp only [hp0, roots_zero, multiset.map_zero, polynomial.map_zero], },
520
537
have hmap : map f p ≠ 0 , { simpa only [polynomial.map_zero] using (map_injective f hf).ne hp0, },
521
538
apply multiset.eq_of_le_of_card_le,
522
- { simpa only [multiset.le_iff_count, count_roots] using count_map_roots hf },
539
+ { simpa only [multiset.le_iff_count, count_roots] using count_map_roots p hf },
523
540
{ simpa only [multiset.card_map, hroots] using (card_roots' _).trans (nat_degree_map_le f p) },
524
541
end
525
542
@@ -719,8 +736,7 @@ begin
719
736
rw [hr, nat_degree_mul'] at hdeg, swap,
720
737
{ rw [hp.leading_coeff, one_mul, leading_coeff_ne_zero], exact rzero },
721
738
rw [mul_comm, @eq_C_of_nat_degree_eq_zero _ _ r] at hr,
722
- { convert hr, convert leading_coeff_C _ using 1 ,
723
- rw [hr, leading_coeff_mul_monic hp] },
739
+ { convert hr, convert leading_coeff_C _ using 1 , rw [hr, leading_coeff_mul_monic hp] },
724
740
{ exact (add_right_inj _).1 (le_antisymm hdeg $ nat.le.intro rfl) },
725
741
end
726
742
@@ -741,33 +757,56 @@ theorem pairwise_coprime_X_sub_C {K} [field K] {I : Type v} {s : I → K}
741
757
(H : function.injective s) : pairwise (is_coprime on (λ i : I, X - C (s i))) :=
742
758
λ i j hij, is_coprime_X_sub_C_of_is_unit_sub (sub_ne_zero_of_ne $ H.ne hij).is_unit
743
759
760
+ lemma monic_prod_multiset_X_sub_C : monic (p.roots.map (λ a, X - C a)).prod :=
761
+ monic_multiset_prod_of_monic _ _ (λ a _, monic_X_sub_C a)
762
+
763
+ lemma prod_multiset_root_eq_finset_root :
764
+ (p.roots.map (λ a, X - C a)).prod =
765
+ p.roots.to_finset.prod (λ a, (X - C a) ^ root_multiplicity a p) :=
766
+ by simp only [count_roots, finset.prod_multiset_map_count]
767
+
768
+ /-- The product `∏ (X - a)` for `a` inside the multiset `p.roots` divides `p`. -/
769
+ lemma prod_multiset_X_sub_C_dvd (p : R[X]) : (p.roots.map (λ a, X - C a)).prod ∣ p :=
770
+ begin
771
+ rw ← map_dvd_map _ (is_fraction_ring.injective R $ fraction_ring R) monic_prod_multiset_X_sub_C,
772
+ rw [prod_multiset_root_eq_finset_root, polynomial.map_prod],
773
+ refine finset.prod_dvd_of_coprime (λ a _ b _ h, _) (λ a _, _),
774
+ { simp_rw [polynomial.map_pow, polynomial.map_sub, map_C, map_X],
775
+ exact (pairwise_coprime_X_sub_C (is_fraction_ring.injective R $ fraction_ring R) _ _ h).pow },
776
+ { exact polynomial.map_dvd _ (pow_root_multiplicity_dvd p a) },
777
+ end
778
+
779
+ lemma exists_prod_multiset_X_sub_C_mul (p : R[X]) : ∃ q,
780
+ (p.roots.map (λ a, X - C a)).prod * q = p ∧
781
+ p.roots.card + q.nat_degree = p.nat_degree ∧
782
+ q.roots = 0 :=
783
+ begin
784
+ obtain ⟨q, he⟩ := prod_multiset_X_sub_C_dvd p,
785
+ use [q, he.symm],
786
+ obtain (rfl|hq) := eq_or_ne q 0 ,
787
+ { rw mul_zero at he, subst he, simp },
788
+ split,
789
+ { conv_rhs { rw he },
790
+ rw [monic_prod_multiset_X_sub_C.nat_degree_mul' hq, nat_degree_multiset_prod_X_sub_C_eq_card] },
791
+ { replace he := congr_arg roots he.symm,
792
+ rw [roots_mul, roots_multiset_prod_X_sub_C] at he,
793
+ exacts [add_right_eq_self.1 he, mul_ne_zero monic_prod_multiset_X_sub_C.ne_zero hq] },
794
+ end
795
+
744
796
/-- A polynomial `p` that has as many roots as its degree
745
797
can be written `p = p.leading_coeff * ∏(X - a)`, for `a` in `p.roots`. -/
746
798
lemma C_leading_coeff_mul_prod_multiset_X_sub_C (hroots : p.roots.card = p.nat_degree) :
747
- C p.leading_coeff * (p.roots.map (λ (a : R), X - C a)).prod = p :=
748
- begin
749
- symmetry, classical,
750
- apply eq_leading_coeff_mul_of_monic_of_dvd_of_nat_degree_le,
751
- { exact monic_multiset_prod_of_monic _ _ (λ a _, monic_X_sub_C a) },
752
- { rw ← map_dvd_map _ (is_fraction_ring.injective R $ fraction_ring R),
753
- swap, { exact monic_multiset_prod_of_monic _ _ (λ a _, monic_X_sub_C a) },
754
- rw [finset.prod_multiset_map_count, polynomial.map_prod],
755
- refine finset.prod_dvd_of_coprime (λ a _ b _ h, _) (λ a _, _),
756
- { simp_rw [polynomial.map_pow, polynomial.map_sub, map_C, map_X],
757
- exact (pairwise_coprime_X_sub_C (is_fraction_ring.injective R $ fraction_ring R) _ _ h).pow },
758
- { rw count_roots, exact polynomial.map_dvd _ (pow_root_multiplicity_dvd p a) } },
759
- { rw [nat_degree_multiset_prod_of_monic, multiset.map_map],
760
- { convert hroots.symm.le, convert multiset.sum_repeat 1 _,
761
- { convert multiset.map_const _ 1 , ext, apply nat_degree_X_sub_C }, { simp } },
762
- { intros f hf, obtain ⟨a, ha, rfl⟩ := multiset.mem_map.1 hf, exact monic_X_sub_C a } },
763
- end
799
+ C p.leading_coeff * (p.roots.map (λ a, X - C a)).prod = p :=
800
+ (eq_leading_coeff_mul_of_monic_of_dvd_of_nat_degree_le monic_prod_multiset_X_sub_C
801
+ (prod_multiset_X_sub_C_dvd p) $
802
+ ((nat_degree_multiset_prod_X_sub_C_eq_card _).trans hroots).ge).symm
764
803
765
804
/-- A monic polynomial `p` that has as many roots as its degree
766
805
can be written `p = ∏(X - a)`, for `a` in `p.roots`. -/
767
806
lemma prod_multiset_X_sub_C_of_monic_of_roots_card_eq
768
807
(hp : p.monic) (hroots : p.roots.card = p.nat_degree) :
769
- (p.roots.map (λ (a : R) , X - C a)).prod = p :=
770
- by {convert C_leading_coeff_mul_prod_multiset_X_sub_C hroots, rw [hp.leading_coeff, C_1, one_mul] }
808
+ (p.roots.map (λ a , X - C a)).prod = p :=
809
+ by { convert C_leading_coeff_mul_prod_multiset_X_sub_C hroots, rw [hp.leading_coeff, C_1, one_mul] }
771
810
772
811
end comm_ring
773
812
@@ -776,7 +815,7 @@ section
776
815
variables [semiring R] [comm_ring S] [is_domain S] (φ : R →+* S)
777
816
778
817
lemma is_unit_of_is_unit_leading_coeff_of_is_unit_map
779
- ( f : R[X]) (hf : is_unit (leading_coeff f) ) (H : is_unit (map φ f)) :
818
+ { f : R[X]} (hf : is_unit f.leading_coeff ) (H : is_unit (map φ f)) :
780
819
is_unit f :=
781
820
begin
782
821
have dz := degree_eq_zero_of_is_unit H,
0 commit comments