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

[Merged by Bors] - feat(data/polynomial/degree/definition): nat_degree_monomial in ite form #11123

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/data/polynomial/degree/definitions.lean
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,13 @@ nat_degree_eq_of_degree_eq_some (degree_C_mul_X_pow n ha)
@[simp] lemma nat_degree_C_mul_X (a : R) (ha : a ≠ 0) : nat_degree (C a * X) = 1 :=
by simpa only [pow_one] using nat_degree_C_mul_X_pow 1 a ha

@[simp] lemma nat_degree_monomial (i : ℕ) (r : R) (hr : r ≠ 0) :
nat_degree (monomial i r) = i :=
by rw [← C_mul_X_pow_eq_monomial, nat_degree_C_mul_X_pow i r hr]
@[simp] lemma nat_degree_monomial [decidable_eq R] (i : ℕ) (r : R) :
nat_degree (monomial i r) = if r = 0 then 0 else i :=
begin
split_ifs with hr,
{ simp [hr] },
{ rw [← C_mul_X_pow_eq_monomial, nat_degree_C_mul_X_pow i r hr] }
end

lemma coeff_eq_zero_of_degree_lt (h : degree p < n) : coeff p n = 0 :=
not_not.1 (mt le_degree_of_ne_zero (not_le_of_gt h))
Expand Down Expand Up @@ -564,7 +568,7 @@ lemma degree_pow_le (p : polynomial R) : ∀ (n : ℕ), degree (p ^ n) ≤ n •
begin
by_cases ha : a = 0,
{ simp only [ha, (monomial n).map_zero, leading_coeff_zero] },
{ rw [leading_coeff, nat_degree_monomial _ _ ha, coeff_monomial], simp }
{ rw [leading_coeff, nat_degree_monomial, if_neg ha, coeff_monomial], simp }
end

lemma leading_coeff_C_mul_X_pow (a : R) (n : ℕ) : leading_coeff (C a * X ^ n) = a :=
Expand Down
2 changes: 1 addition & 1 deletion src/data/polynomial/erase_lead.lean
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ erase_lead_card_support fc
begin
by_cases hr : r = 0,
{ subst r, simp only [monomial_zero_right, erase_lead_zero] },
{ rw [erase_lead, nat_degree_monomial _ _ hr, erase_monomial] }
{ rw [erase_lead, nat_degree_monomial, if_neg hr, erase_monomial] }
end

@[simp] lemma erase_lead_C (r : R) : erase_lead (C r) = 0 :=
Expand Down
3 changes: 2 additions & 1 deletion src/data/polynomial/mirror.lean
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ noncomputable def mirror := p.reverse * X ^ p.nat_trailing_degree

lemma mirror_monomial (n : ℕ) (a : R) : (monomial n a).mirror = (monomial n a) :=
begin
classical,
by_cases ha : a = 0,
{ rw [ha, monomial_zero_right, mirror_zero] },
{ rw [mirror, reverse, nat_degree_monomial n a ha, nat_trailing_degree_monomial ha,
{ rw [mirror, reverse, nat_degree_monomial n a, if_neg ha, nat_trailing_degree_monomial ha,
←C_mul_X_pow_eq_monomial, reflect_C_mul_X_pow, rev_at_le (le_refl n),
tsub_self, pow_zero, mul_one] },
end
Expand Down