{
  "id": "2680",
  "ident": "NS.02680",
  "slug": "erdos-639",
  "title": "Erdős Problem 639",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Is it true that if the edges of $K_n$ are 2-coloured then there are at most $n^2/4$ many edges\nwhich do not occur in a monochromatic triangle?\n\nSolved by Erdős, Rousseau, and Schelp for large $n$, but unpublished. Alon has observed that this\nalso follows from a result of Pyber [Py86], which states that (for large enough $n$) at most\n$\\lfloor n^2/4\\rfloor+2$ monochromatic cliques cover all edges of a $2$-coloured $K_n$.\n\nThis problem was solved completely by Keevash and Sudakov [KeSu04], who proved that the correct\nthreshold is $\\lfloor n^2/4\\rfloor$ for all $n\\geq 7$, is $\\binom{n}{2}$ for $n\\leq 5$, and is\n$10$ for $n=6$.\n\nSince the bound fails for small $n$ (at $n=6$ the threshold is $10 > 6^2/4$), the statement is\nformalized in the asymptotic reading in which the problem was posed and solved: for all\nsufficiently large $n$, every $2$-colouring of the edges of $K_n$ leaves at most $n^2/4$ edges\nnot occurring in a monochromatic triangle. Edges of $K_n$ are the non-diagonal unordered pairs\n`Sym2 (Fin n)`; an edge $\\{x, y\\}$ occurs in a monochromatic triangle if and only if there is a\nthird vertex $z$ with $C(\\{x, z\\}) = C(\\{y, z\\}) = C(\\{x, y\\})$.\n\nThe linked file proves the bound for every finite vertex type with at least $10$ vertices, which\ngives the `atTop` reading below, and collects the uncovered edges as the edge set of a graph\nrather than as a set of pairs.",
  "subjects": [
    "math.CO",
    "msc:05"
  ],
  "tags": [
    "question",
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos639.erdos_639",
  "statement_lean": "theorem erdos_639 :\n    ∀ᶠ (n : ℕ) in atTop, ∀ C : Sym2 (Fin n) → Fin 2,\n      {e : Sym2 (Fin n) | ¬e.IsDiag ∧\n        ∀ x y : Fin n, e = s(x, y) →\n          ¬∃ z, z ≠ x ∧ z ≠ y ∧ C s(x, z) = C e ∧ C s(y, z) = C e}.ncard ≤ n ^ 2 / 4",
  "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 639\n\n*References:*\n- [erdosproblems.com/639](https://www.erdosproblems.com/639)\n- [Er97d] Erdős, Paul, *Some recent problems and results in graph theory*. Discrete Math.\n  (1997), 81-85.\n- [KeSu04] Keevash, Peter and Sudakov, Benny, *On the number of edges not covered by monochromatic\n  copies of a fixed graph*. J. Combin. Theory Ser. B (2004), 41-53.\n- [Py86] Pyber, L., *Clique covering of graphs*. Combinatorica (1986), 393-398.\n-/\n\n@[expose] public section\n\nopen Filter\n\nnamespace Erdos639\n\nset_option linter.style.formal_proof_palomar false in\n/--\nIs it true that if the edges of $K_n$ are 2-coloured then there are at most $n^2/4$ many edges\nwhich do not occur in a monochromatic triangle?\n\nSolved by Erdős, Rousseau, and Schelp for large $n$, but unpublished. Alon has observed that this\nalso follows from a result of Pyber [Py86], which states that (for large enough $n$) at most\n$\\lfloor n^2/4\\rfloor+2$ monochromatic cliques cover all edges of a $2$-coloured $K_n$.\n\nThis problem was solved completely by Keevash and Sudakov [KeSu04], who proved that the correct\nthreshold is $\\lfloor n^2/4\\rfloor$ for all $n\\geq 7$, is $\\binom{n}{2}$ for $n\\leq 5$, and is\n$10$ for $n=6$.\n\nSince the bound fails for small $n$ (at $n=6$ the threshold is $10 > 6^2/4$), the statement is\nformalized in the asymptotic reading in which the problem was posed and solved: for all\nsufficiently large $n$, every $2$-colouring of the edges of $K_n$ leaves at most $n^2/4$ edges\nnot occurring in a monochromatic triangle. Edges of $K_n$ are the non-diagonal unordered pairs\n`Sym2 (Fin n)`; an edge $\\{x, y\\}$ occurs in a monochromatic triangle if and only if there is a\nthird vertex $z$ with $C(\\{x, z\\}) = C(\\{y, z\\}) = C(\\{x, y\\})$.\n\nThe linked file proves the bound for every finite vertex type with at least $10$ vertices, which\ngives the `atTop` reading below, and collects the uncovered edges as the edge set of a graph\nrather than as a set of pairs.\n-/\n@[category research solved, question, AMS 5, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/68da20b96673899166e94638f5a7fffeb7231d35/src/latest/ErdosProblems/Erdos639.lean\"]\ntheorem erdos_639 :\n    ∀ᶠ (n : ℕ) in atTop, ∀ C : Sym2 (Fin n) → Fin 2,\n      {e : Sym2 (Fin n) | ¬e.IsDiag ∧\n        ∀ x y : Fin n, e = s(x, y) →\n          ¬∃ z, z ≠ x ∧ z ≠ y ∧ C s(x, z) = C e ∧ C s(y, z) = C e}.ncard ≤ n ^ 2 / 4 := by\n  sorry\n\n/-- The edges of a two-coloured complete graph that lie in no monochromatic triangle. -/\ndef uncoveredEdges {n : ℕ} (C : Sym2 (Fin n) → Fin 2) : Set (Sym2 (Fin n)) :=\n  {e | ¬e.IsDiag ∧ ∀ x y : Fin n, e = s(x, y) →\n    ¬∃ z, z ≠ x ∧ z ≠ y ∧ C s(x, z) = C e ∧ C s(y, z) = C e}\n\n/--\nThe exact maximum number of uncovered edges is $\\binom{n}{2}$ for $n\\leq 5$, $10$ for\n$n=6$, and $\\lfloor n^2/4\\rfloor$ for $n\\geq 7$ [KeSu04, Theorem 1.1].\n`IsGreatest` states both the upper bound and its attainment by a colouring.\n-/\n@[category research solved, AMS 5]\ntheorem erdos_639.variants.exact :\n    ∀ n : ℕ, IsGreatest\n      (Set.range fun C : Sym2 (Fin n) → Fin 2 => (uncoveredEdges C).ncard)\n      (if n ≤ 5 then n.choose 2 else if n = 6 then 10 else n ^ 2 / 4) := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/-- Every two-colouring of $K_n$ with $n\\geq 10$ has at most\n$\\lfloor n^2/4\\rfloor$ uncovered edges [KeSu04, Proposition 2.1]. -/\n@[category research solved, AMS 5, formal_proof using lean4 at\n  \"https://github.com/AItoBit/formal-conjectures/blob/0ad11a9f7f83c7ada19d42f1a95964465fb1195f/proofs/erdos639/Bridge639.lean\"]\ntheorem erdos_639.variants.ten_le :\n    ∀ n : ℕ, 10 ≤ n → ∀ C : Sym2 (Fin n) → Fin 2,\n      (uncoveredEdges C).ncard ≤ n ^ 2 / 4 := by\n  sorry\n\n/-- A colouring of $K_6$ with exactly ten uncovered edges. -/\nprivate def sixColoring (e : Sym2 (Fin 6)) : Fin 2 :=\n  if e ∈ ({s(0, 1), s(1, 2), s(2, 3), s(3, 4), s(4, 0),\n      s(5, 1), s(5, 4), s(0, 5)} : Finset (Sym2 (Fin 6))) then 0 else 1\n\nprivate def sixUncovered : Finset (Sym2 (Fin 6)) :=\n  {s(0, 2), s(0, 3), s(1, 2), s(1, 3), s(1, 4),\n    s(2, 3), s(2, 4), s(2, 5), s(3, 4), s(3, 5)}\n\n/-- There is a two-colouring of $K_6$ with ten uncovered edges, exceeding $6^2/4$. -/\n@[category research solved, AMS 5]\ntheorem erdos_639.variants.six_vertices :\n    ∃ C : Sym2 (Fin 6) → Fin 2, (uncoveredEdges C).ncard = 10 ∧\n      6 ^ 2 / 4 < (uncoveredEdges C).ncard := by\n  have h : (uncoveredEdges sixColoring).ncard = 10 := by\n    have hs : uncoveredEdges sixColoring = (sixUncovered : Set (Sym2 (Fin 6))) := by\n      unfold uncoveredEdges\n      apply Set.ext\n      simp only [Set.mem_ofPred_eq]\n      decide\n    rw [hs, Set.ncard_coe_finset]\n    decide\n  refine ⟨sixColoring, h, ?_⟩\n  rw [h]\n  decide\n\nend Erdos639\n",
  "statement_hash": "d68aef35b3bb5657e03f4f47717997bfc789798112c59caec10ca1d6f3e4f23c",
  "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."
}