{
  "id": "1727",
  "ident": "NS.01727",
  "slug": "erdos-331",
  "title": "Erdős Problem 331",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Let $A,B\\subseteq \\mathbb{N}$ such that for all large $N$$$\\lvert A\\cap \\{1,\\ldots,N\\}\\rvert \\gg\nN^{1/2}$$and$$\\lvert B\\cap \\{1,\\ldots,N\\}\\rvert \\gg N^{1/2}.$$\nIs it true that there are infinitely many solutions to $a_1-a_2=b_1-b_2\\neq 0$ with $a_1,a_2\\in A$\nand $b_1,b_2\\in B$?\n\nRuzsa has observed that there is a simple counterexample: take $A$ to be the set of numbers whose\nbinary representation has only non-zero digits in even places, and $B$ similarly but with non-zero\ndigits only in odd places. It is easy to see $A$ and $B$ both grow like $\\gg N^{1/2}$ and yet for\nany $n\\geq 1$ there is exactly one solution to $n=a+b$ with $a\\in A$ and $b\\in B$.\n\nThis was formalized in Lean by van Doorn using Aristotle.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question",
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos331.erdos_331",
  "statement_lean": "theorem erdos_331 :\n    ¬ ∀ A B : Set ℕ,\n    (fun (n : ℕ) ↦ (n : ℝ) ^ (1 / 2 : ℝ)) =O[atTop] (fun (n : ℕ) ↦ (count (· ∈ A) n : ℝ)) →\n    (fun (n : ℕ) ↦ (n : ℝ) ^ (1 / 2 : ℝ)) =O[atTop] (fun (n : ℕ) ↦ (count (· ∈ B) n : ℝ)) →\n    { s : ℕ × ℕ × ℕ × ℕ | let ⟨a₁, a₂, b₁, b₂⟩ := s\n      a₁ ∈ A ∧ a₂ ∈ A ∧ b₁ ∈ B ∧ b₂ ∈ B ∧\n      a₁ ≠ a₂ ∧ a₁ + b₂ = a₂ + b₁ }.Infinite",
  "challenge_source": "/-\nCopyright 2026 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 331\n\n*References:*\n- [erdosproblems.com/331](https://www.erdosproblems.com/331)\n- [ErFr84] Erdős, P. and Freud, R., On disjoint sets of differences. J. Number Theory (1984),\n  99--109.\n-/\n\n@[expose] public section\n\nopen Nat Filter\nopen scoped Asymptotics\n\nnamespace Erdos331\n\nopen scoped Classical in\nset_option linter.style.formal_proof_palomar false in\n/--\nLet $A,B\\subseteq \\mathbb{N}$ such that for all large $N$$$\\lvert A\\cap \\{1,\\ldots,N\\}\\rvert \\gg\nN^{1/2}$$and$$\\lvert B\\cap \\{1,\\ldots,N\\}\\rvert \\gg N^{1/2}.$$\nIs it true that there are infinitely many solutions to $a_1-a_2=b_1-b_2\\neq 0$ with $a_1,a_2\\in A$\nand $b_1,b_2\\in B$?\n\nRuzsa has observed that there is a simple counterexample: take $A$ to be the set of numbers whose\nbinary representation has only non-zero digits in even places, and $B$ similarly but with non-zero\ndigits only in odd places. It is easy to see $A$ and $B$ both grow like $\\gg N^{1/2}$ and yet for\nany $n\\geq 1$ there is exactly one solution to $n=a+b$ with $a\\in A$ and $b\\in B$.\n\nThis was formalized in Lean by van Doorn using Aristotle.\n-/\n@[category research solved, question, AMS 11, formal_proof using lean4 at \"https://github.com/Woett/Lean-files/blob/d30552f64c55686d40b928a0a3b8e2396357a4ee/ErdosProblem331.lean\"]\ntheorem erdos_331 :\n    ¬ ∀ A B : Set ℕ,\n    (fun (n : ℕ) ↦ (n : ℝ) ^ (1 / 2 : ℝ)) =O[atTop] (fun (n : ℕ) ↦ (count (· ∈ A) n : ℝ)) →\n    (fun (n : ℕ) ↦ (n : ℝ) ^ (1 / 2 : ℝ)) =O[atTop] (fun (n : ℕ) ↦ (count (· ∈ B) n : ℝ)) →\n    { s : ℕ × ℕ × ℕ × ℕ | let ⟨a₁, a₂, b₁, b₂⟩ := s\n      a₁ ∈ A ∧ a₂ ∈ A ∧ b₁ ∈ B ∧ b₂ ∈ B ∧\n      a₁ ≠ a₂ ∧ a₁ + b₂ = a₂ + b₁ }.Infinite := by\n  sorry\n\nopen scoped Classical in\n/--\nRuzsa suggests that a non-trivial variant of this problem arises if one imposes the stronger\ncondition that $|A \\cap \\{1,\\dots,N\\}| \\sim c_A N^{1/2}$ for some constant $c_A>0$, and similarly\nfor $B$.\n\nThe answer is yes. Write $A(N) = |A \\cap \\{1,\\dots,N\\}|$ and $B(N) = |B \\cap \\{1,\\dots,N\\}|$.\nErdős and Freud [ErFr84, Theorem 4] proved that if $a_1 - a_2 = b_1 - b_2$ has only trivial\nsolutions and $\\liminf_N \\min(A(N), B(N)) / N^{1/2} > 0$, then neither $A(N) / N^{1/2}$ nor\n$B(N) / N^{1/2}$ tends to a limit. If there were only finitely many non-trivial solutions, removing\nthe finitely many elements of $A$ that occur in them would give sets with the same asymptotics and\nno non-trivial solution.\n-/\n@[category research solved, question, AMS 11]\ntheorem erdos_331.variants.ruzsa :\n    ∀ A B : Set ℕ,\n    (∃ c_A > 0, (fun (n : ℕ) ↦ (count (· ∈ A) n : ℝ)) ~[atTop] (fun (n : ℕ) ↦ c_A * (n : ℝ) ^ (1 / 2 : ℝ))) →\n    (∃ c_B > 0, (fun (n : ℕ) ↦ (count (· ∈ B) n : ℝ)) ~[atTop] (fun (n : ℕ) ↦ c_B * (n : ℝ) ^ (1 / 2 : ℝ))) →\n    { s : ℕ × ℕ × ℕ × ℕ | let ⟨a₁, a₂, b₁, b₂⟩ := s\n      a₁ ∈ A ∧ a₂ ∈ A ∧ b₁ ∈ B ∧ b₂ ∈ B ∧\n      a₁ ≠ a₂ ∧ a₁ + b₂ = a₂ + b₁ }.Infinite := by\n  sorry\nend Erdos331\n",
  "statement_hash": "f21ec02db250f5736fc7e8749d92902e28399661197759ca75fc1277f6abda85",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}