Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 570c293

Browse files
feat(data/polynomial/ring_division): Two easy lemmas about polynomials (#4742)
Two easy lemmas from my previous, now splitted, PR. Co-authored-by: jalex-stark <alexmaplegm@gmail.com>
1 parent b9a94d6 commit 570c293

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/data/polynomial/monic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ by simpa only [C_neg] using monic_X_add_C (-x)
225225
theorem monic_X_pow_sub {n : ℕ} (H : degree p ≤ n) : monic (X ^ (n+1) - p) :=
226226
monic_X_pow_add ((degree_neg p).symm ▸ H)
227227

228+
/-- `X ^ n - a` is monic. -/
229+
lemma monic_X_pow_sub_C {R : Type u} [ring R] (a : R) {n : ℕ} (h : n ≠ 0) : (X ^ n - C a).monic :=
230+
begin
231+
obtain ⟨k, hk⟩ := nat.exists_eq_succ_of_ne_zero h,
232+
convert monic_X_pow_sub _,
233+
exact le_trans degree_C_le nat.with_bot.coe_nonneg,
234+
end
235+
228236
section injective
229237
open function
230238
variables [semiring S] {f : R →+* S} (hf : injective f)

src/data/polynomial/ring_division.lean

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,27 @@ this.elim
512512
by rw h₁ at h₂; exact absurd h₂ dec_trivial)
513513
(λ hgu, by rw [hg, degree_mul, degree_X_sub_C, degree_eq_zero_of_is_unit hgu, add_zero])
514514

515+
/-- Division by a monic polynomial doesn't change the leading coefficient. -/
516+
lemma leading_coeff_div_by_monic_of_monic {R : Type u} [integral_domain R] {p q : polynomial R}
517+
(hmonic : q.monic) (hdegree : q.degree ≤ p.degree) : (p /ₘ q).leading_coeff = p.leading_coeff :=
518+
begin
519+
have hp := mod_by_monic_add_div p hmonic,
520+
have hzero : (p /ₘ q) ≠ 0,
521+
{ intro h,
522+
exact not_lt_of_le hdegree ((div_by_monic_eq_zero_iff hmonic (monic.ne_zero hmonic)).1 h) },
523+
have deglt : (p %ₘ q).degree < (q * (p /ₘ q)).degree,
524+
{ rw degree_mul,
525+
refine lt_of_lt_of_le (degree_mod_by_monic_lt p hmonic (monic.ne_zero hmonic)) _,
526+
rw [degree_eq_nat_degree (monic.ne_zero hmonic), degree_eq_nat_degree hzero],
527+
norm_cast,
528+
simp only [zero_le, le_add_iff_nonneg_right] },
529+
have hrew := (leading_coeff_add_of_degree_lt deglt),
530+
rw leading_coeff_mul q (p /ₘ q) at hrew,
531+
simp only [hmonic, one_mul, monic.leading_coeff] at hrew,
532+
nth_rewrite 1 ← hp,
533+
exact hrew.symm
534+
end
535+
515536
end integral_domain
516537

517538
section

0 commit comments

Comments
 (0)