Zulip Chat Archive
Stream: new members
Topic: Sorting divisors
Nathan (Sep 26 2025 at 04:43):
How can I formalize (in Lean) this statement from an IMO problem?
Let be a positive integer, with divisors . Prove that is always less than , and determine when it is a divisor of .
I initially tried using Finset.sort Nat.lt n.divisors but I get the error "failed to synthesize DecidableRel Nat.lt". I also considered defining recursively, as the minimum of the set of divisors that are bigger than .
Ruben Van de Velde (Sep 26 2025 at 06:01):
I don't think you should use Nat.lt directly. Does (. < .) work?
Nathan (Sep 26 2025 at 06:10):
Screenshot 2025-09-26 at 2.10.20 AM.png
no, it doesn't seem to
Nathan (Sep 26 2025 at 06:13):
oh wait
Nathan (Sep 26 2025 at 06:14):
(. ≤ .) seems to work
Nathan (Sep 26 2025 at 06:21):
thanks :pray:
Nathan (Sep 26 2025 at 06:27):
sort produces a List. I wonder, are lists the right approach here?
Nathan (Sep 26 2025 at 06:31):
my goal is to prove the solution to the problem
Ruben Van de Velde (Sep 26 2025 at 07:33):
Yes, I think you want a list, and then probably sum over Finset.range n? You'll want to start your indices from 0 as well
Nathan (Sep 26 2025 at 18:11):
Shouldn't I sum over something like Finset.range (n.divisors.card-1)?
Ruben Van de Velde (Sep 26 2025 at 18:15):
Uh, yes, confused my variables there
Nathan (Sep 26 2025 at 19:02):
Is this right? I'm not sure how to prove h1, h2
import MIL.Common
section p_1_12_13
def divi (n i : ℕ) (h : i < n.divisors.card) :=
let d := n.divisors.sort (. ≤ .)
have h : d.length = n.divisors.card := Multiset.length_sort (. ≤ .)
d[i]
def sumdiv (n : ℕ) :=
∑ i : Finset.Icc 0 (n.divisors.card-2),
have h₁ : i < n.divisors.card := sorry
have h₂ : i+1 < n.divisors.card := sorry
(divi n i h₁) * (divi n (i+1) h₂)
example : sumdiv 4 = 10 := sorry
theorem t1 (n : ℕ) (h : n ≥ 2) : sumdiv n < n^2 := sorry
end p_1_12_13
Jireh Loreaux (Sep 26 2025 at 19:23):
import Mathlib
example (n : ℕ) :
letI sorted_divisors := n.divisors.sort (· ≤ ·)
(List.zipWith (· * ·) (0 :: sorted_divisors) sorted_divisors).sum < n ^ 2 := by
sorry
Nathan (Sep 26 2025 at 20:01):
I see! thanks :pray: This avoids indices. I'll try to make some progress with the proof later.
Nathan (Sep 27 2025 at 16:39):
I think I still might need something like divi (which I defined above), because I want to use . The proof goes like this:
So won't I need something that maps ?
Nathan (Sep 27 2025 at 16:55):
I found a lot of helpful things in Mathlib like List.sum_le_sum and Nat.image_div_divisors_eq_divisors but I wasn't able to put them together into anything coherent.
Last updated: Dec 20 2025 at 21:32 UTC