From 6c7d871c3833389330aff2e3d8556acbe25813ec Mon Sep 17 00:00:00 2001 From: e-271828 Date: Sat, 11 Apr 2026 14:06:13 +0900 Subject: [PATCH 1/5] feat(Analysis/Calculus/DSlope): add `eq_smul_dslope_of_zero` and iterated version --- Mathlib/Analysis/Calculus/DSlope.lean | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Mathlib/Analysis/Calculus/DSlope.lean b/Mathlib/Analysis/Calculus/DSlope.lean index 7d1cf1104ae1fc..1060d293c75acd 100644 --- a/Mathlib/Analysis/Calculus/DSlope.lean +++ b/Mathlib/Analysis/Calculus/DSlope.lean @@ -141,3 +141,38 @@ theorem differentiableOn_dslope_of_notMem (h : a โˆ‰ s) : theorem differentiableAt_dslope_of_ne (h : b โ‰  a) : DifferentiableAt ๐•œ (dslope f a) b โ†” DifferentiableAt ๐•œ f b := by simp only [โ† differentiableWithinAt_univ, differentiableWithinAt_dslope_of_ne h] + +variable {๐•œ : Type*} [NontriviallyNormedField ๐•œ] +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ๐•œ E] + +/-- If `f a = 0`, then `f b = (b - a) โ€ข dslope f a b`. -/ +lemma eq_smul_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (hf : f a = 0) (b : ๐•œ) : + f b = (b - a) โ€ข dslope f a b := by + by_cases h : b = a + ยท simp [h, hf] + ยท -- ๆญฃใ—ใ้–ขๆ•ฐ f ใ‚’ๆธกใ—ใฆ dslope ใ‚’ slope ใซๅฑ•้–‹ใ™ใ‚‹ + rw [dslope_of_ne f h] + -- slope ใฎๅฎš็พฉ๏ผˆๅ‚พใใฎๅผ๏ผ‰ใซๅผทๅˆถ็š„ใซๆ›ธใๆ›ใˆใ‚‹ + change f b = (b - a) โ€ข ((b - a)โปยน โ€ข (f b - f a)) + -- (b - a) * (b - a)โปยน = 1 ใจใชใ‚‹ใ“ใจใ‚’็”จใ„ใฆไปฃๆ•ฐ็š„ใซ็ด„ๅˆ†ใ™ใ‚‹ + rw [โ† mul_smul, mul_inv_cancelโ‚€ (sub_ne_zero.mpr h)] + rw [one_smul, hf, sub_zero] + +/-- If `f` and its first `n-1` iterated dslopes at `a` vanish, +then `f b = (b - a) ^ n โ€ข (Function.swap dslope a)^[n] f b`. -/ +lemma eq_pow_smul_iterate_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (n : โ„•) + (hf : โˆ€ k < n, (Function.swap dslope a)^[k] f a = 0) (b : ๐•œ) : + f b = (b - a) ^ n โ€ข (Function.swap dslope a)^[n] f b := by + induction n with + | zero => simp + | succ n ih => + have h_lt : โˆ€ k < n, (Function.swap dslope a)^[k] f a = 0 := + fun k hk => hf k (Nat.lt_trans hk (Nat.lt_succ_self n)) + rw [ih h_lt] + have h_zero : (Function.swap dslope a)^[n] f a = 0 := + hf n (Nat.lt_succ_self n) + have h_dslope := eq_smul_dslope_of_zero h_zero b + rw [h_dslope] + -- ใ‚นใ‚ซใƒฉใƒผๅ€ใฎ็ตๅˆๆณ•ๅ‰‡ใจใ€็ดฏไน—ใฎๅฎš็พฉใ‚’ไฝฟใฃใฆ็พŽใ—ใๆ•ด็†ใ™ใ‚‹ + rw [โ† mul_smul, โ† pow_succ] + rw [Function.iterate_succ_apply'] From 252139db5ea237ca6c3f127d19aea72b069bb2f0 Mon Sep 17 00:00:00 2001 From: e-271828 <39018690+e-271828@users.noreply.github.com> Date: Sat, 11 Apr 2026 23:47:58 +0900 Subject: [PATCH 2/5] Update Mathlib/Analysis/Calculus/DSlope.lean Apply suggestion from wwylele to simplify proof using sub_smul_dslope Co-authored-by: Weiyi Wang --- Mathlib/Analysis/Calculus/DSlope.lean | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Mathlib/Analysis/Calculus/DSlope.lean b/Mathlib/Analysis/Calculus/DSlope.lean index 1060d293c75acd..4c427991a15380 100644 --- a/Mathlib/Analysis/Calculus/DSlope.lean +++ b/Mathlib/Analysis/Calculus/DSlope.lean @@ -148,15 +148,7 @@ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ๐•œ E] /-- If `f a = 0`, then `f b = (b - a) โ€ข dslope f a b`. -/ lemma eq_smul_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (hf : f a = 0) (b : ๐•œ) : f b = (b - a) โ€ข dslope f a b := by - by_cases h : b = a - ยท simp [h, hf] - ยท -- ๆญฃใ—ใ้–ขๆ•ฐ f ใ‚’ๆธกใ—ใฆ dslope ใ‚’ slope ใซๅฑ•้–‹ใ™ใ‚‹ - rw [dslope_of_ne f h] - -- slope ใฎๅฎš็พฉ๏ผˆๅ‚พใใฎๅผ๏ผ‰ใซๅผทๅˆถ็š„ใซๆ›ธใๆ›ใˆใ‚‹ - change f b = (b - a) โ€ข ((b - a)โปยน โ€ข (f b - f a)) - -- (b - a) * (b - a)โปยน = 1 ใจใชใ‚‹ใ“ใจใ‚’็”จใ„ใฆไปฃๆ•ฐ็š„ใซ็ด„ๅˆ†ใ™ใ‚‹ - rw [โ† mul_smul, mul_inv_cancelโ‚€ (sub_ne_zero.mpr h)] - rw [one_smul, hf, sub_zero] + simp [hf] /-- If `f` and its first `n-1` iterated dslopes at `a` vanish, then `f b = (b - a) ^ n โ€ข (Function.swap dslope a)^[n] f b`. -/ From 2f1e133d740aeae53b4a030fa821dfe57737f155 Mon Sep 17 00:00:00 2001 From: e-271828 Date: Thu, 16 Apr 2026 02:54:33 +0900 Subject: [PATCH 3/5] refactor: flip equalities and update proofs per reviewer suggestions --- Mathlib/Analysis/Calculus/DSlope.lean | 38 +++++++++++---------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Mathlib/Analysis/Calculus/DSlope.lean b/Mathlib/Analysis/Calculus/DSlope.lean index 4c427991a15380..d7ebfb7255838a 100644 --- a/Mathlib/Analysis/Calculus/DSlope.lean +++ b/Mathlib/Analysis/Calculus/DSlope.lean @@ -142,29 +142,23 @@ theorem differentiableAt_dslope_of_ne (h : b โ‰  a) : DifferentiableAt ๐•œ (dslope f a) b โ†” DifferentiableAt ๐•œ f b := by simp only [โ† differentiableWithinAt_univ, differentiableWithinAt_dslope_of_ne h] -variable {๐•œ : Type*} [NontriviallyNormedField ๐•œ] -variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ๐•œ E] - -/-- If `f a = 0`, then `f b = (b - a) โ€ข dslope f a b`. -/ -lemma eq_smul_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (hf : f a = 0) (b : ๐•œ) : - f b = (b - a) โ€ข dslope f a b := by - simp [hf] - -/-- If `f` and its first `n-1` iterated dslopes at `a` vanish, -then `f b = (b - a) ^ n โ€ข (Function.swap dslope a)^[n] f b`. -/ -lemma eq_pow_smul_iterate_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (n : โ„•) +lemma sub_smul_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (hf : f a = 0) (b : ๐•œ) : + (b - a) โ€ข dslope f a b = f b := by + by_cases h : b = a + ยท simp [h, hf] + ยท have h_dslope : dslope f a b = (b - a)โปยน โ€ข f b := by simp [dslope, slope, h, hf] + have h_sub_ne_zero : b - a โ‰  0 := sub_ne_zero.mpr h + rw [h_dslope, smul_smul] + simp [h_sub_ne_zero] + +lemma pow_sub_smul_iterate_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (n : โ„•) (hf : โˆ€ k < n, (Function.swap dslope a)^[k] f a = 0) (b : ๐•œ) : - f b = (b - a) ^ n โ€ข (Function.swap dslope a)^[n] f b := by - induction n with + (b - a) ^ n โ€ข (Function.swap dslope a)^[n] f b = f b := by + induction n generalizing f with | zero => simp | succ n ih => - have h_lt : โˆ€ k < n, (Function.swap dslope a)^[k] f a = 0 := + rw [Function.iterate_succ_apply', pow_succ, mul_smul] + have hf_n : (Function.swap dslope a)^[n] f a = 0 := hf n (Nat.lt_succ_self n) + have hf_lt : โˆ€ k < n, (Function.swap dslope a)^[k] f a = 0 := fun k hk => hf k (Nat.lt_trans hk (Nat.lt_succ_self n)) - rw [ih h_lt] - have h_zero : (Function.swap dslope a)^[n] f a = 0 := - hf n (Nat.lt_succ_self n) - have h_dslope := eq_smul_dslope_of_zero h_zero b - rw [h_dslope] - -- ใ‚นใ‚ซใƒฉใƒผๅ€ใฎ็ตๅˆๆณ•ๅ‰‡ใจใ€็ดฏไน—ใฎๅฎš็พฉใ‚’ไฝฟใฃใฆ็พŽใ—ใๆ•ด็†ใ™ใ‚‹ - rw [โ† mul_smul, โ† pow_succ] - rw [Function.iterate_succ_apply'] + rw [sub_smul_dslope_of_zero hf_n b, ih hf_lt] From 6e7bcbbca587f4b6aa0f7ea4b86e42ed6b4a38c1 Mon Sep 17 00:00:00 2001 From: e-271828 Date: Thu, 16 Apr 2026 22:37:33 +0900 Subject: [PATCH 4/5] fix: replace verbose LLM workaround with simp [hf] per reviewer suggestion --- Mathlib/Analysis/Calculus/DSlope.lean | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Mathlib/Analysis/Calculus/DSlope.lean b/Mathlib/Analysis/Calculus/DSlope.lean index d7ebfb7255838a..5a2606e474ecc8 100644 --- a/Mathlib/Analysis/Calculus/DSlope.lean +++ b/Mathlib/Analysis/Calculus/DSlope.lean @@ -144,12 +144,7 @@ theorem differentiableAt_dslope_of_ne (h : b โ‰  a) : lemma sub_smul_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (hf : f a = 0) (b : ๐•œ) : (b - a) โ€ข dslope f a b = f b := by - by_cases h : b = a - ยท simp [h, hf] - ยท have h_dslope : dslope f a b = (b - a)โปยน โ€ข f b := by simp [dslope, slope, h, hf] - have h_sub_ne_zero : b - a โ‰  0 := sub_ne_zero.mpr h - rw [h_dslope, smul_smul] - simp [h_sub_ne_zero] + simp [hf] lemma pow_sub_smul_iterate_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (n : โ„•) (hf : โˆ€ k < n, (Function.swap dslope a)^[k] f a = 0) (b : ๐•œ) : From 57b32773838504734dfd60386fc804e25ce09d69 Mon Sep 17 00:00:00 2001 From: e-271828 Date: Fri, 17 Apr 2026 03:15:38 +0900 Subject: [PATCH 5/5] fix: golf the second lemma using grind per reviewer suggestion --- Mathlib/Analysis/Calculus/DSlope.lean | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Mathlib/Analysis/Calculus/DSlope.lean b/Mathlib/Analysis/Calculus/DSlope.lean index 5a2606e474ecc8..b63f46c76b1f1d 100644 --- a/Mathlib/Analysis/Calculus/DSlope.lean +++ b/Mathlib/Analysis/Calculus/DSlope.lean @@ -152,8 +152,5 @@ lemma pow_sub_smul_iterate_dslope_of_zero {f : ๐•œ โ†’ E} {a : ๐•œ} (n : โ„•) induction n generalizing f with | zero => simp | succ n ih => - rw [Function.iterate_succ_apply', pow_succ, mul_smul] - have hf_n : (Function.swap dslope a)^[n] f a = 0 := hf n (Nat.lt_succ_self n) - have hf_lt : โˆ€ k < n, (Function.swap dslope a)^[k] f a = 0 := - fun k hk => hf k (Nat.lt_trans hk (Nat.lt_succ_self n)) - rw [sub_smul_dslope_of_zero hf_n b, ih hf_lt] + rw [Function.iterate_succ_apply', pow_succ, mul_smul, + sub_smul_dslope_of_zero (hf n n.lt_succ_self), ih (by grind)]