Zulip Chat Archive
Stream: new members
Topic: Can this proof be shortened?
Ching-Tsun Chou (May 25 2025 at 17:53):
Just for fun, I proved a simple proposition from a blog post by Terence Tao:
https://terrytao.wordpress.com/2023/12/05/a-slightly-longer-lean-4-proof-tour/
My proof differs from Tao's in that it uses an invariant (h4 in the proof) to obviate the need to talk about summations. But I am not very satisfied by how much code I had to prove basically trivial properties. For example, the calc seems to contain way too many steps. Is there a shorter proof?
import mathlib
example (a D : ℕ → ℝ) (h1 : Antitone a) (h2 : ∀ k, D k ≥ 0)
(h3 : ∀ k, a k ≤ D k - D (k + 1)) : a k ≤ D 0 / (k + 1) := by
suffices h4 : (k + 1) * a k ≤ D 0 - D (k + 1) by
have h5 : (↑k + 1) * a k ≤ D 0 := by have := h2 (k + 1) ; bound
have h6 : 0 < k + (1 : ℝ) := by bound
exact (le_div_iff₀' h6).mpr h5
induction' k with k h_ind <;> simp
· exact h3 0
calc
(↑k + 1 + 1) * a (k + 1) = (↑k + 1) * a (k + 1) + 1 * a (k + 1) := by ring
_ = (↑k + 1) * a (k + 1) + a (k + 1) := by field_simp
_ ≤ (↑k + 1) * a k + a (k + 1) := by bound
_ ≤ D 0 - D (k + 1) + a (k + 1) := by bound
_ ≤ D 0 - D (k + 1) + D (k + 1) - D (k + 1 + 1) := by have := h3 (k + 1) ; bound
_ ≤ D 0 - D (k + 1 + 1) := by field_simp
By the way, the above was inspired by a PVS proof I saw. It uses the same invariant, but then PVS basically grinds out all the details with only some high-level human directions. Very impressive.
Bjørn Kjos-Hanssen (May 25 2025 at 18:02):
Yes, the number of calc steps can be reduced:
import Mathlib
example (a D : ℕ → ℝ) (h₁ : Antitone a) (h₂ : ∀ k, D k ≥ 0)
(h₃ : ∀ k, a k ≤ D k - D (k + 1)) : a k ≤ D 0 / (k + 1) := by
have : (k + 1) * a k ≤ D 0 - D (k + 1) := by
induction' k with k h_ind <;> simp
· exact h₃ 0
calc _ = (↑k + 1) * a (k + 1) + a (k + 1) := by ring
_ ≤ (↑k + 1) * a k + a (k + 1) := by bound
_ ≤ _ := by specialize h₃ (k+1); bound
apply (le_div_iff₀' (by bound)).mpr
specialize h₂ (k + 1)
bound
Ching-Tsun Chou (May 26 2025 at 15:51):
Thanks! I have to say that field_simp had behaved as I thought. Since ℝ is a field, I had thought that the first calc step could be solved by field_simp and was surprised that it couldn't.
Damiano Testa (May 26 2025 at 16:03):
Ching-Tsun Chou said:
Is there a shorter proof?
A "shortest proof" of any provable result exists, but it is almost never observed.
Damiano Testa (May 26 2025 at 16:05):
So, the answer to "Is there a shorter proof" is invariably "Yes".
Ching-Tsun Chou (May 26 2025 at 16:51):
That's why I asked the question. (;-)
Last updated: Dec 20 2025 at 21:32 UTC