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

Commit c65d807

Browse files
committed
feat(data/polynomial/erase_lead + data/polynomial/reverse): rename an old lemma, add a stronger one (#12909)
Taking advantage of nat-subtraction in edge cases, a lemma that previously proved `x ≤ y` actually holds with `x ≤ y - 1`. Thus, I renamed the old lemma to `original_name_aux` and `original_name` is now the name of the new lemma. Since this lemma was used in a different file, I used the `_aux` name in the other file. Note that the `_aux` lemma is currently an ingredient in the proof of the stronger lemma. It may be possible to have a simple direct proof of the stronger one that avoids using the `_aux` lemma, but I have not given this any thought.
1 parent 7a1e0f2 commit c65d807

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/data/polynomial/erase_lead.lean

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ begin
134134
apply coeff_eq_zero_of_degree_lt hi
135135
end
136136

137-
lemma erase_lead_nat_degree_le : (erase_lead f).nat_degree ≤ f.nat_degree :=
137+
lemma erase_lead_nat_degree_le_aux : (erase_lead f).nat_degree ≤ f.nat_degree :=
138138
nat_degree_le_nat_degree erase_lead_degree_le
139139

140140
lemma erase_lead_nat_degree_lt (f0 : 2 ≤ f.support.card) :
141141
(erase_lead f).nat_degree < f.nat_degree :=
142-
lt_of_le_of_ne erase_lead_nat_degree_le $ ne_nat_degree_of_mem_erase_lead_support $
142+
lt_of_le_of_ne erase_lead_nat_degree_le_aux $ ne_nat_degree_of_mem_erase_lead_support $
143143
nat_degree_mem_support_of_nonzero $ erase_lead_ne_zero f0
144144

145145
lemma erase_lead_nat_degree_lt_or_erase_lead_eq_zero (f : R[X]) :
@@ -153,6 +153,13 @@ begin
153153
apply erase_lead_nat_degree_lt (lt_of_not_ge h) }
154154
end
155155

156+
lemma erase_lead_nat_degree_le (f : R[X]) : (erase_lead f).nat_degree ≤ f.nat_degree - 1 :=
157+
begin
158+
rcases f.erase_lead_nat_degree_lt_or_erase_lead_eq_zero with h | h,
159+
{ exact nat.le_pred_of_lt h },
160+
{ simp only [h, nat_degree_zero, zero_le] }
161+
end
162+
156163
end erase_lead
157164

158165
/-- An induction lemma for polynomials. It takes a natural number `N` as a parameter, that is
@@ -188,7 +195,7 @@ begin
188195
rintro rfl,
189196
simpa using f0 } },
190197
{ exact (nat_degree_C_mul_X_pow_le f.leading_coeff f.nat_degree).trans df },
191-
{ exact hc _ (erase_lead_nat_degree_le.trans df) (erase_lead_card_support f0) },
198+
{ exact hc _ (erase_lead_nat_degree_le_aux.trans df) (erase_lead_card_support f0) },
192199
{ refine P_C_mul_pow _ _ _ df,
193200
rw [ne.def, leading_coeff_eq_zero, ← card_support_eq_zero, f0],
194201
exact nat.succ_ne_zero _ } }

src/data/polynomial/reverse.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ begin
162162
{ exact le_add_left card_support_C_mul_X_pow_le_one },
163163
{ exact (le_trans (nat_degree_C_mul_X_pow_le g.leading_coeff g.nat_degree) Og) },
164164
{ exact nat.lt_succ_iff.mp (gt_of_ge_of_gt Cg (erase_lead_support_card_lt g0)) },
165-
{ exact le_trans erase_lead_nat_degree_le Og } } },
165+
{ exact le_trans erase_lead_nat_degree_le_aux Og } } },
166166
--first induction (left): induction step
167167
{ intros N O f g Cf Cg Nf Og,
168168
by_cases f0 : f = 0,
@@ -173,7 +173,7 @@ begin
173173
{ exact le_add_left card_support_C_mul_X_pow_le_one },
174174
{ exact (le_trans (nat_degree_C_mul_X_pow_le f.leading_coeff f.nat_degree) Nf) },
175175
{ exact nat.lt_succ_iff.mp (gt_of_ge_of_gt Cf (erase_lead_support_card_lt f0)) },
176-
{ exact (le_trans erase_lead_nat_degree_le Nf) } },
176+
{ exact (le_trans erase_lead_nat_degree_le_aux Nf) } }
177177
end
178178

179179
@[simp] theorem reflect_mul

0 commit comments

Comments
 (0)