Optimality of Wouter van Doorn's Upper Bound for the Mayer-Erdős Farey Problem
Let f(n) be the minimum number of Farey fractions of order n lying strictly between two badly ordered fractions a/b < c/d, where a<c and b>d. Erdős Problem 1005 asks for the asymptotic constant c in f(n) cn. Van Doorn proved the upper bound f(n) ≤ n/4+O(1) and conjectured that it is optimal.
Every badly ordered pair is reduced to an elementary interval (a/b, (a+1)/(b-1)). The paper then shows that each such interval contains at least n/4 − o(n) Farey fractions, uniformly in a and b. The argument uses primitive progression counts, uniform Farey counts, Farey gap properties and an increment estimate for a weighted totient sum. The proof was formalized in Lean 4 by Aristotle and van Doorn.
The paper proves f(n) = (1/4+o(1))n, so the asymptotic constant in Erdős Problem 1005 is c=1/4 and van Doorn's upper bound is optimal. The Lean formalization is publicly available.
