Skip to content

Commit 48e7264

Browse files
committed
feat(Polynomial/Chebyshev): calculate values of T and U at zero (leanprover-community#33311)
Added theorems stating the value of T and U at 0. The proofs are quite clunky — would appreciate any simplifications.
1 parent 0763a3b commit 48e7264

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

Mathlib/Algebra/Ring/Parity.lean

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,38 @@ lemma Even.sub_odd (ha : Even a) (hb : Odd b) : Odd (a - b) := by
218218
lemma Odd.sub_odd (ha : Odd a) (hb : Odd b) : Even (a - b) := by
219219
rw [sub_eq_add_neg]; exact ha.add_odd hb.neg
220220

221+
@[simp]
222+
lemma even_add_one : Even (a + 1) ↔ Odd a :=
223+
⟨(by convert ·.sub_odd odd_one; rw [eq_sub_iff_add_eq]), (·.add_one)⟩
224+
225+
@[simp]
226+
lemma even_sub_one : Even (a - 1) ↔ Odd a :=
227+
⟨(by convert ·.add_odd odd_one; rw [sub_add_cancel]), (·.sub_odd odd_one)⟩
228+
229+
@[simp]
230+
lemma even_add_two : Even (a + 2) ↔ Even a :=
231+
⟨(by convert ·.sub even_two; rw [eq_sub_iff_add_eq]), (·.add even_two)⟩
232+
233+
@[simp]
234+
lemma even_sub_two : Even (a - 2) ↔ Even a :=
235+
⟨(by convert ·.add even_two; rw [sub_add_cancel]), (·.sub even_two)⟩
236+
237+
@[simp]
238+
lemma odd_add_one : Odd (a + 1) ↔ Even a :=
239+
⟨(by convert ·.sub_odd odd_one; rw [eq_sub_iff_add_eq]), (·.add_one)⟩
240+
241+
@[simp]
242+
lemma odd_sub_one : Odd (a - 1) ↔ Even a :=
243+
⟨(by convert ·.add_odd odd_one; rw [sub_add_cancel]), (·.sub_odd odd_one)⟩
244+
245+
@[simp]
246+
lemma odd_add_two : Odd (a + 2) ↔ Odd a :=
247+
by rw [← one_add_one_eq_two, ← add_assoc, odd_add_one, even_add_one]
248+
249+
@[simp]
250+
lemma odd_sub_two : Odd (a - 2) ↔ Odd a :=
251+
by rw [← odd_add_two (a := a - 2), add_comm_sub, sub_self, add_zero]
252+
221253
end Ring
222254

223255
namespace Nat

Mathlib/RingTheory/Polynomial/Chebyshev.lean

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,28 @@ theorem T_eval_neg_one (n : ℤ) : (T R n).eval (-1) = n.negOnePow := by
182182
Int.negOnePow_sub]
183183
ring
184184

185+
theorem T_eval_zero (n : ℤ) :
186+
(T R n).eval 0 = (if Even n then (n / 2).negOnePow else 0 : ℤ) := by
187+
induction n using Polynomial.Chebyshev.induct with
188+
| zero => simp
189+
| one => simp
190+
| add_two n ih1 ih2 =>
191+
have : ((n : ℤ) + 2) / 2 = (n : ℤ) / 2 + 1 := by lia
192+
by_cases Even n <;> simp_all [Int.negOnePow_add]
193+
| neg_add_one n ih1 ih2 =>
194+
have : (-(n : ℤ) + 1) / 2 = (-(n : ℤ) - 1) / 2 + 1 := by lia
195+
by_cases Even n <;> simp_all [T_sub_one, ← Int.not_even_iff_odd, Int.negOnePow_add]
196+
197+
@[simp]
198+
theorem T_eval_zero_of_even {n : ℤ} (hn : Even n) : (T R n).eval 0 = (n / 2).negOnePow := by
199+
simp [T_eval_zero, hn]
200+
201+
theorem T_eval_two_mul_zero (n : ℤ) : (T R (2 * n)).eval 0 = n.negOnePow := by simp
202+
203+
@[simp]
204+
theorem T_eval_zero_of_odd {n : ℤ} (hn : Odd n) : (T R n).eval 0 = 0 := by
205+
simp [T_eval_zero, ← Int.not_odd_iff_even, hn]
206+
185207
@[simp]
186208
theorem degree_T [IsDomain R] [NeZero (2 : R)] (n : ℤ) : (T R n).degree = n.natAbs := by
187209
induction n using Chebyshev.induct' with
@@ -327,6 +349,28 @@ theorem U_eval_neg_one (n : ℤ) : (U R n).eval (-1) = n.negOnePow * (n + 1) :=
327349
norm_num
328350
ring
329351

352+
theorem U_eval_zero (n : ℤ) :
353+
(U R n).eval 0 = (if Even n then (n / 2).negOnePow else 0 : ℤ) := by
354+
induction n using Polynomial.Chebyshev.induct with
355+
| zero => simp
356+
| one => simp
357+
| add_two n ih1 ih2 =>
358+
have : ((n : ℤ) + 2) / 2 = (n : ℤ) / 2 + 1 := by lia
359+
by_cases Even n <;> simp_all [Int.negOnePow_add]
360+
| neg_add_one n ih1 ih2 =>
361+
have : (-(n : ℤ) + 1) / 2 = (-(n : ℤ) - 1) / 2 + 1 := by lia
362+
by_cases Even n <;> simp_all [U_sub_one, ← Int.not_even_iff_odd, Int.negOnePow_add]
363+
364+
@[simp]
365+
theorem U_eval_zero_of_even {n : ℤ} (hn : Even n) : (U R n).eval 0 = (n / 2).negOnePow := by
366+
simp [U_eval_zero, hn]
367+
368+
theorem U_eval_two_mul_zero (n : ℤ) : (U R (2 * n)).eval 0 = n.negOnePow := by simp
369+
370+
@[simp]
371+
theorem U_eval_zero_of_odd {n : ℤ} (hn : Odd n) : (U R n).eval 0 = 0 := by
372+
simp [U_eval_zero, ← Int.not_odd_iff_even, hn]
373+
330374
@[simp]
331375
theorem degree_U_natCast [IsDomain R] [NeZero (2 : R)] (n : ℕ) : (U R n).degree = n := by
332376
induction n using Nat.twoStepInduction with

0 commit comments

Comments
 (0)