Zulip Chat Archive
Stream: new members
Topic: Floor division hell in asymptotics
Gareth Ma (Apr 23 2024 at 23:15):
(Not surprisingly) I am struggling to prove the following result:
example {b : ℤ} (hb : 2 <= b) :
∃ c > 0, |((b / 2 * (b / 2 - 1) / 2) : ℝ) - (b : ℝ) ^ 2 / 8| ≤ c * |(b : ℝ)| / 2 := by
sorry
Is there any general tips on how to tackle these? In particular, I just want to prove some messy division stuff is , but it's all in floor division :(
Gareth Ma (Apr 23 2024 at 23:17):
(This basically comes from or something, so some floor(s / divisions) are unavoidable?)
Richard Copley (Apr 23 2024 at 23:18):
All of those divisions are ℝ → ℝ → ℝ
, fyi
Mario Carneiro (Apr 23 2024 at 23:19):
you can lower and upper bound floor division wrt regular division, and apply asymptotics on the result
Gareth Ma (Apr 23 2024 at 23:27):
That's the idea but implementing it still seems hard, can you provide some help? For example I guess a generous estimate would be to lower bound , so I want to prove
example {b : ℤ} (hb : 2 ≤ b) :
((b : ℚ) - 2) * (b - 2) / 8 - (b - 2) / 4 ≤ ((b / 2) * (b / 2 - 1) / 2 : ℤ) := by
sorry
I think.
Mario Carneiro (Apr 23 2024 at 23:28):
does gcongr
help?
Gareth Ma (Apr 23 2024 at 23:28):
Nope 0 progress
Mario Carneiro (Apr 23 2024 at 23:29):
looks like you did some simplifications on that expression too
Gareth Ma (Apr 23 2024 at 23:30):
example {b : ℤ} (hb : 2 ≤ b) :
(((b - 2 : ℚ) / 2) * ((b - 2 : ℚ) / 2 - 1) - 2) / 2 ≤ ((b / 2) * (b / 2 - 1) / 2 : ℤ) := by
gcongr
I reverted the manual simplifiactions I did, but still 0 progress
Gareth Ma (Apr 23 2024 at 23:32):
It fails for this too:
example {a b : ℤ} (hb : a ≤ b) :
((a : ℚ) - 2) / 2 ≤ (b / 2 : ℤ) := by
gcongr
So I don't think it can help with floor divisions.
Mario Carneiro (Apr 23 2024 at 23:32):
it helps with all the stuff which isn't the floor divisions here
Mario Carneiro (Apr 23 2024 at 23:33):
for the floor division itself you need a lemma
Gareth Ma (Apr 23 2024 at 23:42):
I will start with
lemma aux_floor_div {a b k : ℤ} (hb : a ≤ b) (hk : 0 < k) :
((a : ℚ) - k + 1) / k ≤ (b / k : ℤ) := by
rw [div_le_iff (by norm_cast), ← add_sub_right_comm, sub_le_iff_le_add]
norm_cast
rw [add_one_le_iff]
apply lt_of_le_of_lt hb
rw [← add_one_mul, ← Int.ediv_lt_iff_lt_mul hk]
exact lt_succ _
lemma aux_floor_div' {a b k : ℤ} (hb : a ≤ b) (hk : 0 < k) :
((a : ℚ) - k) / k ≤ (b / k : ℤ) := by
apply le_trans ?_ (aux_floor_div hb hk)
gcongr
exact le_add_of_nonneg_right zero_le_one
and "build" the blocks one by one I guess. Thanks!
Mario Carneiro (Apr 23 2024 at 23:42):
I think your original expression is off, it seems to work except for that
Gareth Ma (Apr 23 2024 at 23:43):
The very first message? Yes I put the type casting wrong, let me fix it
Mario Carneiro (Apr 23 2024 at 23:43):
no, the numbers are wrong
Gareth Ma (Apr 23 2024 at 23:43):
which one?
Mario Carneiro (Apr 23 2024 at 23:44):
import Mathlib.Tactic.Linarith
import Mathlib.Data.Real.Basic
theorem todo (a b : ℤ) : (a / b - 1 : ℚ) ≤ (a / b : ℤ) := sorry
example {b : ℤ} (hb : 4 ≤ b) :
((b : ℚ) - 2) * (b - 4) / 8 - 1 ≤ ((b / 2) * (b / 2 - 1) / 2 : ℤ) := by
calc ((b : ℚ) - 2) * (b - 4) / 8 - 1
_ = ((b / 2 - 1) * ((b / 2 - 1) - 1)) / 2 - 1 := by ring
_ ≤ ((b / 2 : ℤ) * ((b / 2 : ℤ) - 1)) / 2 - 1 := by
gcongr
· linarith [show 4 ≤ (b:ℚ) by exact_mod_cast hb]
· apply todo
· apply todo
_ ≤ ((b / 2) * (b / 2 - 1) : ℤ) / 2 - 1 := by simp
_ ≤ ((b / 2) * (b / 2 - 1) / 2 : ℤ) := todo ..
Gareth Ma (Apr 23 2024 at 23:44):
Oh my god lol thanks so much...
Gareth Ma (Apr 25 2024 at 10:21):
Ohhhhhh wait I had a realisation. I shouldn't be bounding the final term (b/2)*(b/2-1)/2 directly (every / is floor division here)
Gareth Ma (Apr 25 2024 at 10:24):
The term is obtained from a sum , so I should bound , which is easier because for integers .
Gareth Ma (Apr 25 2024 at 10:24):
Where
Last updated: May 02 2025 at 03:31 UTC