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

Commit 39962b7

Browse files
chore(data/polynomial/derivative): golf proof of mem_support_derivative (#4134)
Golfed proof to be similar to what it was like prior to the refactor.
1 parent 6756d47 commit 39962b7

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/data/polynomial/coeff.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ lemma coeff_sum [semiring S] (n : ℕ) (f : ℕ → R → polynomial S) :
3939
@[simp] lemma coeff_smul (p : polynomial R) (r : R) (n : ℕ) :
4040
coeff (r • p) n = r * coeff p n := finsupp.smul_apply
4141

42+
lemma mem_support_iff_coeff_ne_zero : n ∈ p.support ↔ p.coeff n ≠ 0 :=
43+
by { rw mem_support_to_fun, refl }
44+
4245
variable (R)
4346
/-- The nth coefficient, as a linear map. -/
4447
def lcoeff (n : ℕ) : polynomial R →ₗ[R] R :=

src/data/polynomial/derivative.lean

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,12 @@ end comm_semiring
185185

186186
section domain
187187
variables [integral_domain R]
188-
-- TODO: golf this, dunno how i broke it so bad
188+
189189
lemma mem_support_derivative [char_zero R] (p : polynomial R) (n : ℕ) :
190190
n ∈ (derivative p).support ↔ n + 1 ∈ p.support :=
191-
begin
192-
rw finsupp.mem_support_iff, split; intro h,
193-
suffices h1 : p.coeff (n+1) ≠ 0, simp; tauto, contrapose! h,
194-
convert coeff_derivative _ _, simp [h],
195-
contrapose! h, simp,
196-
suffices : p.to_fun (n + 1) * (n + 1) = 0, simp only [mul_eq_zero] at this, cases this,
197-
{ exact this }, { norm_cast at this },
198-
erw ← h, symmetry, convert coeff_derivative _ _,
199-
end
191+
suffices (¬(coeff p (n + 1) = 0 ∨ ((n + 1:ℕ) : R) = 0)) ↔ coeff p (n + 1) ≠ 0,
192+
by simpa only [mem_support_iff_coeff_ne_zero, coeff_derivative, ne.def, mul_eq_zero],
193+
by { rw [nat.cast_eq_zero], simp only [nat.succ_ne_zero, or_false] }
200194

201195
@[simp] lemma degree_derivative_eq [char_zero R] (p : polynomial R) (hp : 0 < nat_degree p) :
202196
degree (derivative p) = (nat_degree p - 1 : ℕ) :=

0 commit comments

Comments
 (0)