{
 "slug": "erdos617-erdos-617",
 "mode": "counterexample (negation) and formalized both examined; partial lemmas are direction-neutral",
 "challenge_sha256": "91e1e04ccad50b7b6c9ab25407a538ee2a313809271ebc9e2fad538774981a04",
 "formalized_challenge_sha256": "9f7e4f5b72a5519be95eadb2df85c4739014abc03265222a40234e1ed7a90483",
 "source_module_sha256": "c558143f3c990258249af9b85b5dd8ec9b7f1ca81fec51b8c03a709076c525f9",
 "class": "d (for the universal positive direction); counterexample direction a-type search only, no candidate",
 "plan": "Complementary to e03-first/e617: translate a missing colour into an independent (r+1)-set of the colour graph, count edges across all r colour classes (Turan lower bound per class versus the C(n,2) partition identity), and push the r^2-vertex Turan equality case (pure colour = r disjoint K_r) through the extra vertex using the star/transversal argument. Then look for a stability inequality that closes the slack.",
 "chance_pct": 0.1,
 "chance_note": "Subjective estimate, not a measured frequency.",
 "status": "partial",
 "full_target_solved": false,
 "candidate": null,
 "input_used": {
  "item": "e03-first/e617",
  "sha256": "d9ac556959e70c89619c1f9fcb626f6ff10f6095cde5e8aab060cc87157a7547",
  "reused": "Exact definitions (Balanced), the six compiled lemmas (copied verbatim into Lemmas.lean namespace E617Attempt), pins and the frozen-affine obstruction"
 },
 "pins": {
  "lean": "leanprover/lean4:v4.35.0-rc2 (commit 11acb17ec6b07a8f9e9173e6845197929540936b)",
  "mathlib": "065356127b1dc0016f66b7283ce0ce2c4055aa55",
  "fc_base": "7d1a8c9912747679d0093f6d1216420c33ee5ffa",
  "fc_target": "6adcbe13652f (reconstructed as base + audit patch; resulting tree hash not separately compared)",
  "tasks": "f5dab9b843c460bf946e0ec7b0e6ad2f2f739eb8",
  "patch_sha256": "352280407fbbe83e636aa07a5c090aab15c6353c7cd77c0491284cd40df51275",
  "patch_sha256_verified_before_apply": true,
  "task_support_sha256": "58a80a223dbd7383d92eb2a57b1ec207c0991131a1a1bf24585a4452777c257e",
  "task_support_matches_metadata": true,
  "lake_manifest_revs_match_fc": true
 },
 "attempted_steps": [
  {
   "step": "Reconstruction",
   "result": "Re-downloaded challenges (both digests match), patch (digest matches, applied at FC base), TaskSupport (digest matches). lake exe cache get exit 0; lake build FormalConjectures.ErdosProblems.«617» exit 0; erdos_617 source sha256 c558143f... matches."
  },
  {
   "step": "Colour-graph translation",
   "result": "missing_iff_indep, balanced_iff_compl_cliqueFree checked."
  },
  {
   "step": "Counting across all colour classes",
   "result": "sum_color_class_card, exists_minority_color, sum_color_degree checked. Paper computation: total Turan excess is identically r^2(r-1)/2 = r*C(r,2), so counting alone leaves exactly an average excess C(r,2) per colour; no contradiction (r=13: per-class minimum 1027, minority at most 1105, consistent with e03-first)."
  },
  {
   "step": "r^2 equality case through one extra vertex",
   "result": "star_hits_independent, pure_rows_cover, pure_rows_meet, at_most_one_pure_color checked: in any balanced colouring of K_{r^2+1}, for every vertex x at most one colour is a disjoint union of r copies of K_r on V\\{x}. This generalises e03-first's affine-only no-extension lemma (the 'meet' hypothesis is now derived by counting)."
  },
  {
   "step": "Stability attempt",
   "result": "Did not find a quantitative stability bound converting non-pure colours into excess beyond r*C(r,2). The affine plane on r^2 vertices has exactly one non-pure colour, so any bound must use the extra vertex essentially."
  }
 ],
 "obstruction": "The exact counting identity sum_k exc_k = r^2(r-1)/2 (exc_k = |E(G_k)| - [(r-1)C(r,2)+C(r+1,2)]) is tight-compatible: counting plus Turan gives no contradiction. The checked structural lemma only excludes two simultaneously pure colours at a vertex. Near-pure colours (small positive excess) are not controlled. The missing piece is a stability inequality: show sum_k exc_k > r*C(r,2) for r graphs partitioning E(K_{r^2+1}) with all alpha(G_k) <= r. Turan's theorem and its equality case were used only on paper and not formalized.",
 "remaining_inequality": "For r>=3 and any r graphs G_1..G_r partitioning E(K_{r^2+1}) with alpha(G_k) <= r for every k: sum_k (|E(G_k)| - (r-1)C(r,2) - C(r+1,2)) > r^2(r-1)/2. This is UNPROVED and equivalent to the conjecture: the left side always equals r^2(r-1)/2, so the claim is that no such family exists. A useful intermediate target is a per-vertex stability bound: if colour k has excess e on V\\{x}, then x's k-star must still hit every independent r-transversal of G_k - x.",
 "compiled_lemmas": [
  {
   "name": "E617Attempt.balanced_iff_no_missing",
   "file": "Lemmas.lean",
   "origin": "e03-first/e617 (copied verbatim, re-checked)",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Attempt.counterexample_refutes",
   "file": "Lemmas.lean",
   "origin": "e03-first/e617 (copied verbatim, re-checked)",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Attempt.transversal_hit_iff_full_row",
   "file": "Lemmas.lean",
   "origin": "e03-first/e617 (copied verbatim, re-checked)",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Attempt.intersecting_partitions_obstruction",
   "file": "Lemmas.lean",
   "origin": "e03-first/e617 (copied verbatim, re-checked)",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Attempt.balanced_star_hits_transversals",
   "file": "Lemmas.lean",
   "origin": "e03-first/e617 (copied verbatim, re-checked)",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Attempt.no_balanced_extension_of_two_partitions",
   "file": "Lemmas.lean",
   "origin": "e03-first/e617 (copied verbatim, re-checked)",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.colorGraph_adj",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.missing_iff_indep",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.balanced_iff_compl_cliqueFree",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.sum_color_class_card",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.exists_minority_color",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.sum_color_degree",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.star_hits_independent",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.pure_rows_cover",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.pure_rows_meet",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  },
  {
   "name": "E617Stability.at_most_one_pure_color",
   "file": "Lemmas.lean",
   "origin": "this item",
   "checked": true,
   "axioms": [
    "propext",
    "Classical.choice",
    "Quot.sound"
   ]
  }
 ],
 "verification": {
  "commands": [
   "lake exe cache get (fc) -> exit 0",
   "lake build FormalConjectures.ErdosProblems.«617» (fc) -> exit 0",
   "lake build TaskSupport Main (scratch project, Main rooted at Lemmas) -> exit 0, Build completed successfully (9203 jobs)",
   "lake env lean Lemmas.lean -> no errors or warnings after fix"
  ],
  "forbidden_token_scan": "no sorry/admit/native_decide/set_option/axiom in Lemmas.lean",
  "imports": [
   "Mathlib",
   "FormalConjectures.ErdosProblems.«617»",
   "TaskSupport"
  ],
  "axioms_permitted_only": true,
  "Bounty_target_checked": false,
  "full_candidate_lake_build_Main": null,
  "different_agent_rebuild": false,
  "note": "Lemmas only; no Bounty.target. The first build attempt failed on colorGraph (SimpleGraph structure fields in pinned Mathlib), which was fixed by using SimpleGraph.fromRel."
 },
 "literature": [
  {
   "date": "2026-10-17",
   "url": "https://arxiv.org/abs/2610.24484",
   "scope": "Xia-Szeider: no balanced 5-colouring of K_26 (r=5 only); not a universal solution.",
   "accessed_on": "2026-11-26"
  },
  {
   "date": "2025 (pinned commit)",
   "url": "https://raw.githubusercontent.com/google-deepmind/formal-conjectures/7d1a8c9912747679d0093f6d1216420c33ee5ffa/FormalConjectures/ErdosProblems/617.lean",
   "scope": "Exact source statement erdos_617; variants r=3,4 attributed to Erdos-Gyarfas [ErGy99].",
   "accessed_on": "2026-11-26"
  },
  {
   "date": "1999",
   "url": "https://doi.org/10.1016/S0012-365X(98)00323-9",
   "scope": "Original Erdos-Gyarfas paper (cited via the first attempt, not re-read here).",
   "accessed_on": "not re-read"
  },
  {
   "date": "2026-11-25",
   "url": "https://raw.githubusercontent.com/Robby955/erdos-617-fixed-cases/cd585782807f3adbbb2eb79d21da16258a49afb7/cutoff/README.md",
   "scope": "Per the first attempt: claimed fixed cases and a large-r cutoff, not all r. Not re-read here; UNVERIFIED.",
   "accessed_on": "not re-read"
  }
 ],
 "literature_gate": {
  "checked_on": "2026-11-26",
  "query": "Erdős Gyárfás balanced coloring conjecture r^2+1 vertices proof 2026",
  "complete_prior_solution_found": false,
  "ineligible": false,
  "note": "One web search was run; no all-r proof or counterexample was found. erdosproblems.com/617 comments were not readable (403 in the first attempt) and were not retried."
 },
 "chat_logs": {
  "original_task_provided_export": null,
  "missing_original_chat_export": true,
  "successful_full_proof_attempts": 0,
  "note": "No original chat export was provided. None was reconstructed."
 },
 "files": {
  "Lemmas.lean": "import Mathlib\nimport FormalConjectures.ErdosProblems.«617»\nimport TaskSupport\n\n/-! Exact counterexample semantics and an obstruction to extending affine seeds. -/\n\nnamespace E617Attempt\n\n/-- The exact positive finite certificate required for a counterexample. -/\ndef Balanced {V : Type} (r : ℕ) (coloring : Sym2 V → Fin r) : Prop :=\n  ∀ S : Finset V, S.card = r + 1 →\n    ∀ k : Fin r, ∃ u ∈ S, ∃ v ∈ S, u ≠ v ∧ coloring s(u, v) = k\n\ntheorem balanced_iff_no_missing {V : Type} (r : ℕ) (coloring : Sym2 V → Fin r) :\n    Balanced r coloring ↔ ¬ ∃ (S : Finset V) (k : Fin r),\n      S.card = r + 1 ∧\n      ∀ u ∈ S, ∀ v ∈ S, u ≠ v → coloring s(u, v) ≠ k := by\n  classical\n  constructor\n  · intro balanced missing\n    obtain ⟨S, k, size, absent⟩ := missing\n    obtain ⟨u, hu, v, hv, ne, eq⟩ := balanced S size k\n    exact absent u hu v hv ne eq\n  · intro no S size k\n    by_contra missing\n    apply no\n    refine ⟨S, k, size, ?_⟩\n    intro u hu v hv ne eq\n    exact missing ⟨u, hu, v, hv, ne, eq⟩\n\n/-- Uses the source declaration's TYPE, never its admitted proof. -/\ntheorem counterexample_refutes {r : ℕ} (hr : 3 ≤ r) {V : Type}\n    [Fintype V] [DecidableEq V] (hV : Fintype.card V = r ^ 2 + 1)\n    (coloring : Sym2 V → Fin r) (balanced : Balanced r coloring) :\n    ¬ (fcTypeOfName% \"Erdos617.erdos_617\") := by\n  intro conjecture\n  exact (balanced_iff_no_missing r coloring).mp balanced (conjecture r hr hV coloring)\n\n/-- If a star hits every transversal of a partition, it contains a whole row. -/\ntheorem transversal_hit_iff_full_row {I J V C : Type*}\n    (rows : I → J → V) (star : V → C) (c : C) :\n    (∀ f : I → J, ∃ i, star (rows i (f i)) = c) ↔\n      ∃ i, ∀ j, star (rows i j) = c := by\n  classical\n  constructor\n  · intro hit\n    by_contra no\n    push Not at no\n    choose f hf using no\n    obtain ⟨i, hi⟩ := hit f\n    exact hf i hi\n  · rintro ⟨i, hi⟩ f\n    exact ⟨i, hi (f i)⟩\n\n/-- Two intersecting row partitions cannot both be hit by disjoint star colors. -/\ntheorem intersecting_partitions_obstruction {I J V C : Type*}\n    (rows₁ rows₂ : I → J → V) (star : V → C) (c₁ c₂ : C)\n    (different : c₁ ≠ c₂)\n    (meet : ∀ i k, ∃ j l, rows₁ i j = rows₂ k l)\n    (hit₁ : ∀ f : I → J, ∃ i, star (rows₁ i (f i)) = c₁)\n    (hit₂ : ∀ f : I → J, ∃ i, star (rows₂ i (f i)) = c₂) : False := by\n  obtain ⟨i, hi⟩ := (transversal_hit_iff_full_row rows₁ star c₁).mp hit₁\n  obtain ⟨k, hk⟩ := (transversal_hit_iff_full_row rows₂ star c₂).mp hit₂\n  obtain ⟨j, l, eq⟩ := meet i k\n  exact different ((hi j).symm.trans ((congrArg star eq).trans (hk l)))\n\n/-- Balance at the added vertex forces its star to hit every independent\ntransversal of an unchanged color partition. -/\ntheorem balanced_star_hits_transversals {r : ℕ} {V : Type} [DecidableEq V]\n    (coloring : Sym2 V → Fin r) (balanced : Balanced r coloring)\n    (apex : V) (rows : Fin r → Fin r → V) (c : Fin r)\n    (new : ∀ i j, rows i j ≠ apex)\n    (disjoint : ∀ i j k l, rows i j = rows k l → i = k)\n    (cross : ∀ i j k l, i ≠ k → coloring s(rows i j, rows k l) ≠ c) :\n    ∀ f : Fin r → Fin r, ∃ i, coloring s(apex, rows i (f i)) = c := by\n  classical\n  intro f\n  let pick : Fin r → V := fun i => rows i (f i)\n  have inj : Function.Injective pick := by\n    intro i k eq\n    exact disjoint i (f i) k (f k) eq\n  let S : Finset V := Finset.univ.image pick\n  have outside : apex ∉ S := by\n    simp only [S, Finset.mem_image, Finset.mem_univ, true_and, not_exists]\n    exact fun i => new i (f i)\n  have size : (insert apex S).card = r + 1 := by\n    rw [Finset.card_insert_of_notMem outside]\n    have sc : S.card = r := by\n      dsimp [S]\n      rw [Finset.card_image_of_injective _ inj, Finset.card_univ, Fintype.card_fin]\n    omega\n  obtain ⟨u, hu, v, hv, ne, edge⟩ := balanced (insert apex S) size c\n  simp only [Finset.mem_insert] at hu hv\n  rcases hu with rfl | hu\n  · rcases hv with rfl | hv\n    · exact (ne rfl).elim\n    · obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hv\n      exact ⟨i, edge⟩\n  · rcases hv with rfl | hv\n    · obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hu\n      exact ⟨i, by simpa only [Sym2.eq_swap] using edge⟩\n    · obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hu\n      obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp hv\n      have ik : i ≠ k := by\n        intro eq\n        subst k\n        exact ne rfl\n      exact (cross i (f i) k (f k) ik edge).elim\n\n/-- In particular, any affine core with two unchanged pure directions has\nno balanced one-vertex extension. This is a restricted obstruction only. -/\ntheorem no_balanced_extension_of_two_partitions {r : ℕ} {V : Type} [DecidableEq V]\n    (coloring : Sym2 V → Fin r) (apex : V)\n    (rows₁ rows₂ : Fin r → Fin r → V) (c₁ c₂ : Fin r)\n    (different : c₁ ≠ c₂)\n    (new₁ : ∀ i j, rows₁ i j ≠ apex) (new₂ : ∀ i j, rows₂ i j ≠ apex)\n    (disjoint₁ : ∀ i j k l, rows₁ i j = rows₁ k l → i = k)\n    (disjoint₂ : ∀ i j k l, rows₂ i j = rows₂ k l → i = k)\n    (cross₁ : ∀ i j k l, i ≠ k → coloring s(rows₁ i j, rows₁ k l) ≠ c₁)\n    (cross₂ : ∀ i j k l, i ≠ k → coloring s(rows₂ i j, rows₂ k l) ≠ c₂)\n    (meet : ∀ i k, ∃ j l, rows₁ i j = rows₂ k l) :\n    ¬ Balanced r coloring := by\n  intro balanced\n  exact intersecting_partitions_obstruction rows₁ rows₂\n    (fun v => coloring s(apex, v)) c₁ c₂ different meet\n    (balanced_star_hits_transversals coloring balanced apex rows₁ c₁ new₁ disjoint₁ cross₁)\n    (balanced_star_hits_transversals coloring balanced apex rows₂ c₂ new₂ disjoint₂ cross₂)\n\nend E617Attempt\n\n#print axioms E617Attempt.balanced_iff_no_missing\n#print axioms E617Attempt.counterexample_refutes\n#print axioms E617Attempt.transversal_hit_iff_full_row\n#print axioms E617Attempt.intersecting_partitions_obstruction\n#print axioms E617Attempt.balanced_star_hits_transversals\n#print axioms E617Attempt.no_balanced_extension_of_two_partitions\n\n/- ## Complementary (counting / stability) partials, item e03-second/e617 -/\n\nnamespace E617Stability\n\nopen Finset\n\n/-- The graph of colour `k`. -/\ndef colorGraph {V : Type} {r : ℕ} (coloring : Sym2 V → Fin r) (k : Fin r) :\n    SimpleGraph V :=\n  SimpleGraph.fromRel (fun u v => coloring s(u, v) = k)\n\ntheorem colorGraph_adj {V : Type} {r : ℕ} (coloring : Sym2 V → Fin r) (k : Fin r) (u v : V) :\n    (colorGraph coloring k).Adj u v ↔ u ≠ v ∧ coloring s(u, v) = k := by\n  simp only [colorGraph, SimpleGraph.fromRel_adj, Sym2.eq_swap (a := v) (b := u), or_self]\n\n/-- A missing colour `k` on `S` is exactly an independent set of the colour-`k` graph. -/\ntheorem missing_iff_indep {V : Type} {r : ℕ} (coloring : Sym2 V → Fin r) (k : Fin r)\n    (S : Finset V) :\n    (∀ u ∈ S, ∀ v ∈ S, u ≠ v → coloring s(u, v) ≠ k) ↔\n      (colorGraph coloring k).IsIndepSet (S : Set V) := by\n  constructor\n  · intro h u hu v hv ne adj\n    exact h u hu v hv ne ((colorGraph_adj coloring k u v).mp adj).2\n  · intro h u hu v hv ne eq\n    exact h hu hv ne ((colorGraph_adj coloring k u v).mpr ⟨ne, eq⟩)\n\n/-- Balance is equivalent to: every colour graph has a `K_{r+1}`-free complement,\ni.e. independence number at most `r`. -/\ntheorem balanced_iff_compl_cliqueFree {V : Type} {r : ℕ} (coloring : Sym2 V → Fin r) :\n    E617Attempt.Balanced r coloring ↔ ∀ k, (colorGraph coloring k)ᶜ.CliqueFree (r + 1) := by\n  constructor\n  · intro bal k t ht\n    obtain ⟨u, hu, v, hv, ne, e⟩ := bal t ht.card_eq k\n    have hadj := ht.isClique (Finset.mem_coe.mpr hu) (Finset.mem_coe.mpr hv) ne\n    rw [SimpleGraph.compl_adj] at hadj\n    exact hadj.2 ((colorGraph_adj coloring k u v).mpr ⟨ne, e⟩)\n  · intro h S hS k\n    by_contra hno\n    apply h k S\n    refine ⟨?_, hS⟩\n    intro u hu v hv ne\n    rw [SimpleGraph.compl_adj]\n    exact ⟨ne, fun hk => hno ⟨u, hu, v, hv, ne, ((colorGraph_adj coloring k u v).mp hk).2⟩⟩\n\n/-- The colour classes partition the edges of the complete graph. -/\ntheorem sum_color_class_card {V : Type} [Fintype V] [DecidableEq V] {r : ℕ}\n    (coloring : Sym2 V → Fin r) :\n    ∑ k : Fin r, ((⊤ : SimpleGraph V).edgeFinset.filter (fun e => coloring e = k)).card =\n      (Fintype.card V).choose 2 := by\n  rw [← SimpleGraph.card_edgeFinset_top_eq_card_choose_two]\n  exact (Finset.card_eq_sum_card_fiberwise (fun e _ => Finset.mem_univ (coloring e))).symm\n\n/-- Minority colour: some colour class has at most `C(n,2)/r` edges. -/\ntheorem exists_minority_color {V : Type} [Fintype V] [DecidableEq V] {r : ℕ} (hr : 0 < r)\n    (coloring : Sym2 V → Fin r) :\n    ∃ k : Fin r,\n      r * ((⊤ : SimpleGraph V).edgeFinset.filter (fun e => coloring e = k)).card ≤\n        (Fintype.card V).choose 2 := by\n  have hne : (Finset.univ : Finset (Fin r)).Nonempty := ⟨⟨0, hr⟩, Finset.mem_univ _⟩\n  have hsum : ∑ k : Fin r,\n      r * ((⊤ : SimpleGraph V).edgeFinset.filter (fun e => coloring e = k)).card ≤\n      ∑ _k : Fin r, (Fintype.card V).choose 2 := by\n    rw [← Finset.mul_sum, sum_color_class_card, Finset.sum_const, Finset.card_univ,\n      Fintype.card_fin, smul_eq_mul]\n  obtain ⟨k, _, hk⟩ := Finset.exists_le_of_sum_le hne hsum\n  exact ⟨k, hk⟩\n\n/-- Degrees of one vertex over all colours sum to `n - 1`. -/\ntheorem sum_color_degree {V : Type} [Fintype V] [DecidableEq V] {r : ℕ}\n    (coloring : Sym2 V → Fin r) (x : V) :\n    ∑ k : Fin r, ((Finset.univ.erase x).filter (fun v => coloring s(x, v) = k)).card =\n      Fintype.card V - 1 := by\n  rw [← Finset.card_eq_sum_card_fiberwise (fun v _ => Finset.mem_univ (coloring s(x, v))),\n    Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ]\n\n/-- One extra vertex: in a balanced colouring, every `r`-set avoiding `x` that misses\ncolour `k` contains a `k`-neighbour of `x`. -/\ntheorem star_hits_independent {V : Type} [DecidableEq V] {r : ℕ}\n    (coloring : Sym2 V → Fin r) (bal : E617Attempt.Balanced r coloring)\n    (x : V) (k : Fin r) (T : Finset V) (hx : x ∉ T) (hT : T.card = r)\n    (indep : ∀ u ∈ T, ∀ v ∈ T, u ≠ v → coloring s(u, v) ≠ k) :\n    ∃ v ∈ T, coloring s(x, v) = k := by\n  have size : (insert x T).card = r + 1 := by\n    rw [Finset.card_insert_of_notMem hx, hT]\n  obtain ⟨u, hu, v, hv, ne, e⟩ := bal (insert x T) size k\n  rw [Finset.mem_insert] at hu hv\n  rcases hu with rfl | hu\n  · rcases hv with rfl | hv\n    · exact (ne rfl).elim\n    · exact ⟨v, hv, e⟩\n  · rcases hv with rfl | hv\n    · exact ⟨u, hu, by rw [Sym2.eq_swap]; exact e⟩\n    · exact (indep u hu v hv ne e).elim\n\n/-- Colour `k` restricted to `V \\ {x}` is a disjoint union of `r` copies of `K_r`\n(the Turán-extremal / equality case on `r^2` vertices). -/\ndef PureRows {V : Type} {r : ℕ} (coloring : Sym2 V → Fin r) (x : V)\n    (rows : Fin r → Fin r → V) (k : Fin r) : Prop :=\n  (∀ i j, rows i j ≠ x) ∧\n  Function.Injective (fun p : Fin r × Fin r => rows p.1 p.2) ∧\n  (∀ i j j', j ≠ j' → coloring s(rows i j, rows i j') = k) ∧\n  (∀ i j i' j', i ≠ i' → coloring s(rows i j, rows i' j') ≠ k)\n\n/-- An injective `r × r` array avoiding `x` covers `V \\ {x}` when `|V| = r^2+1`. -/\ntheorem pure_rows_cover {V : Type} [Fintype V] [DecidableEq V] {r : ℕ}\n    (hV : Fintype.card V = r ^ 2 + 1) (x : V) (rows : Fin r → Fin r → V)\n    (new : ∀ i j, rows i j ≠ x)\n    (inj : Function.Injective (fun p : Fin r × Fin r => rows p.1 p.2)) :\n    ∀ v, v ≠ x → ∃ i j, rows i j = v := by\n  intro v hv\n  let img : Finset V := Finset.univ.image (fun p : Fin r × Fin r => rows p.1 p.2)\n  have sub : img ⊆ Finset.univ.erase x := by\n    intro w hw\n    obtain ⟨p, _, rfl⟩ := Finset.mem_image.mp hw\n    exact Finset.mem_erase.mpr ⟨new p.1 p.2, Finset.mem_univ _⟩\n  have cimg : img.card = r * r := by\n    simp only [img]\n    rw [Finset.card_image_of_injective _ inj, Finset.card_univ, Fintype.card_prod,\n      Fintype.card_fin]\n  have cer : (Finset.univ.erase x).card = r * r := by\n    rw [Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, hV]\n    rw [Nat.pow_two]; omega\n  have heq : img = Finset.univ.erase x :=\n    Finset.eq_of_subset_of_card_le sub (by rw [cimg, cer])\n  have hmem : v ∈ img := by rw [heq]; exact Finset.mem_erase.mpr ⟨hv, Finset.mem_univ _⟩\n  obtain ⟨p, _, hp⟩ := Finset.mem_image.mp hmem\n  exact ⟨p.1, p.2, hp⟩\n\n/-- Counting lemma: rows of two different pure colours on `V \\ {x}` always meet\n(each row of the first meets every row of the second in exactly one point). This\nremoves the affine hypothesis `meet` of the first attempt. -/\ntheorem pure_rows_meet {V : Type} [Fintype V] [DecidableEq V] {r : ℕ}\n    (hV : Fintype.card V = r ^ 2 + 1) (coloring : Sym2 V → Fin r) (x : V)\n    (rows₁ rows₂ : Fin r → Fin r → V) (k₁ k₂ : Fin r) (different : k₁ ≠ k₂)\n    (p₁ : PureRows coloring x rows₁ k₁) (p₂ : PureRows coloring x rows₂ k₂) :\n    ∀ i l, ∃ j m, rows₁ i j = rows₂ l m := by\n  intro i l\n  have cover := pure_rows_cover hV x rows₂ p₂.1 p₂.2.1\n  have pos : ∀ j, ∃ q : Fin r × Fin r, rows₂ q.1 q.2 = rows₁ i j := by\n    intro j\n    obtain ⟨a, b, h⟩ := cover (rows₁ i j) (p₁.1 i j)\n    exact ⟨(a, b), h⟩\n  choose q hq using pos\n  have sinj : Function.Injective (fun j => (q j).1) := by\n    intro j j' hjj\n    by_contra hne\n    have c1 := p₁.2.2.1 i j j' hne\n    have rowne : rows₁ i j ≠ rows₁ i j' := by\n      intro h\n      exact hne (congrArg Prod.snd (p₁.2.1 (a₁ := (i, j)) (a₂ := (i, j')) h))\n    have tne : (q j).2 ≠ (q j').2 := by\n      intro ht\n      apply rowne\n      rw [← hq j, ← hq j']\n      simp only at hjj\n      rw [hjj, ht]\n    have c2 := p₂.2.2.1 (q j).1 (q j).2 (q j').2 tne\n    rw [hq j] at c2\n    have : rows₂ (q j).1 (q j').2 = rows₁ i j' := by\n      simp only at hjj\n      rw [hjj]; exact hq j'\n    rw [this] at c2\n    exact different (c1.symm.trans c2)\n  have ssurj : Function.Surjective (fun j => (q j).1) :=\n    Finite.injective_iff_surjective.mp sinj\n  obtain ⟨j, hj⟩ := ssurj l\n  refine ⟨j, (q j).2, ?_⟩\n  rw [← hq j]\n  simp only at hj\n  rw [hj]\n\n/-- Structural theorem: in a balanced `r`-colouring of `K_{r^2+1}`, for every vertex `x`\nat most one colour is Turán-extremal (a disjoint union of `r` copies of `K_r`) on\n`V \\ {x}`. No affine or symmetry assumption. -/\ntheorem at_most_one_pure_color {V : Type} [Fintype V] [DecidableEq V] {r : ℕ}\n    (hV : Fintype.card V = r ^ 2 + 1) (coloring : Sym2 V → Fin r)\n    (bal : E617Attempt.Balanced r coloring) (x : V)\n    (rows₁ rows₂ : Fin r → Fin r → V) (k₁ k₂ : Fin r)\n    (p₁ : PureRows coloring x rows₁ k₁) (p₂ : PureRows coloring x rows₂ k₂) :\n    k₁ = k₂ := by\n  by_contra different\n  have disj : ∀ {rows : Fin r → Fin r → V} {k : Fin r}, PureRows coloring x rows k →\n      ∀ i j i' j', rows i j = rows i' j' → i = i' := by\n    intro rows k p i j i' j' h\n    exact congrArg Prod.fst (p.2.1 (a₁ := (i, j)) (a₂ := (i', j')) h)\n  exact E617Attempt.no_balanced_extension_of_two_partitions coloring x rows₁ rows₂ k₁ k₂\n    different p₁.1 p₂.1 (disj p₁) (disj p₂) p₁.2.2.2 p₂.2.2.2\n    (pure_rows_meet hV coloring x rows₁ rows₂ k₁ k₂ different p₁ p₂) bal\n\nend E617Stability\n\n#print axioms E617Stability.colorGraph_adj\n#print axioms E617Stability.missing_iff_indep\n#print axioms E617Stability.balanced_iff_compl_cliqueFree\n#print axioms E617Stability.sum_color_class_card\n#print axioms E617Stability.exists_minority_color\n#print axioms E617Stability.sum_color_degree\n#print axioms E617Stability.star_hits_independent\n#print axioms E617Stability.pure_rows_cover\n#print axioms E617Stability.pure_rows_meet\n#print axioms E617Stability.at_most_one_pure_color\n",
  "build.log": "## pins: lean v4.35.0-rc2 (11acb17e), mathlib 065356127b1dc0016f66b7283ce0ce2c4055aa55, FC base 7d1a8c9912747679d0093f6d1216420c33ee5ffa + audit patch sha256 352280407fbbe83e636aa07a5c090aab15c6353c7cd77c0491284cd40df51275 (verified before git apply), TaskSupport sha256 58a80a223dbd7383d92eb2a57b1ec207c0991131a1a1bf24585a4452777c257e\n## fc: lake exe cache get -> exit 0 (8915 files); lake build FormalConjectures.ErdosProblems.«617» -> exit 0\nuser\t0m38.056s\nsys\t1m16.205s\n## proj: lake build TaskSupport Main\nℹ [9202/9203] Built Lemmas (250s)\ninfo: Lemmas.lean:131:0: 'E617Attempt.balanced_iff_no_missing' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:132:0: 'E617Attempt.counterexample_refutes' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:133:0: 'E617Attempt.transversal_hit_iff_full_row' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:134:0: 'E617Attempt.intersecting_partitions_obstruction' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:135:0: 'E617Attempt.balanced_star_hits_transversals' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:136:0: 'E617Attempt.no_balanced_extension_of_two_partitions' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:329:0: 'E617Stability.colorGraph_adj' depends on axioms: [propext, Quot.sound]\ninfo: Lemmas.lean:330:0: 'E617Stability.missing_iff_indep' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:331:0: 'E617Stability.balanced_iff_compl_cliqueFree' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:332:0: 'E617Stability.sum_color_class_card' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:333:0: 'E617Stability.exists_minority_color' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:334:0: 'E617Stability.sum_color_degree' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:335:0: 'E617Stability.star_hits_independent' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:336:0: 'E617Stability.pure_rows_cover' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:337:0: 'E617Stability.pure_rows_meet' depends on axioms: [propext, Classical.choice, Quot.sound]\ninfo: Lemmas.lean:338:0: 'E617Stability.at_most_one_pure_color' depends on axioms: [propext, Classical.choice, Quot.sound]\nBuild completed successfully (9203 jobs).\nexit 0\n",
  "axioms.txt": "'E617Attempt.balanced_iff_no_missing' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Attempt.counterexample_refutes' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Attempt.transversal_hit_iff_full_row' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Attempt.intersecting_partitions_obstruction' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Attempt.balanced_star_hits_transversals' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Attempt.no_balanced_extension_of_two_partitions' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.colorGraph_adj' depends on axioms: [propext, Quot.sound]\n'E617Stability.missing_iff_indep' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.balanced_iff_compl_cliqueFree' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.sum_color_class_card' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.exists_minority_color' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.sum_color_degree' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.star_hits_independent' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.pure_rows_cover' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.pure_rows_meet' depends on axioms: [propext, Classical.choice, Quot.sound]\n'E617Stability.at_most_one_pure_color' depends on axioms: [propext, Classical.choice, Quot.sound]\n",
  "explanation.md": "No target was solved. There is no Main.lean candidate and no Bounty.target proof. Neither the universal statement nor its negation is proved. Status: partial.\n\nApproach (complementary to e03-first/e617): count across all colour classes and look for stability.\n1. Translation (checked): colour k is missing on S exactly when S is an independent set of the colour-k graph G_k (missing_iff_indep). A colouring is balanced exactly when every complement of G_k is K_{r+1}-free, i.e. alpha(G_k) <= r for all k (balanced_iff_compl_cliqueFree).\n2. Counting (checked): the colour classes partition E(K_n), so the sum of |E(G_k)| is C(n,2) (sum_color_class_card). Hence a minority colour has r|E(G_k)| <= C(n,2) (exists_minority_color). At each vertex x, the colour degrees sum to n-1 (sum_color_degree).\n3. One extra vertex (checked): if the colouring is balanced, every r-set T that avoids x and is independent in G_k contains a k-neighbour of x (star_hits_independent).\n4. Equality case on r^2 vertices pushed through x (checked, new): call colour k pure at x when G_k restricted to V\\{x} is exactly r disjoint copies of K_r. By Turan, this is the unique equality case of alpha <= r on r^2 vertices. Two partitions of r^2 points into r blocks of size r, each from a different colour, meet block-to-block in exactly one point, because blocks of the same colour cannot share two points (pure_rows_cover, pure_rows_meet). Combined with the first attempt's transversal lemma: if the colouring is balanced, then for every vertex x at most one colour is pure at x (at_most_one_pure_color). This removes the affine/'meet' hypothesis of the earlier no_balanced_extension_of_two_partitions. It applies to every hypothetical counterexample, but only to its pure colours.\n\nConcrete remaining inequality (NOT proved). Let n = r^2+1. By Turan (complement K_{r+1}-free) every colour has |E(G_k)| >= t := (r-1)C(r,2) + C(r+1,2) = rC(r,2) + r, with equality iff G_k = (r-1)K_r + K_{r+1}. Write the excess as exc_k = |E(G_k)| - t >= 0. Step 2 gives the identity: the sum over k of exc_k equals C(r^2+1,2) - r t = r^2(r-1)/2 = r C(r,2). So counting alone can never contradict: an average excess of C(r,2) per colour is exactly affordable. On V\\{x}, the same identity says the total excess over rC(r,2) is r^2(r-1)/2. The affine plane spends all of it on one doubled colour and leaves r-1 colours pure. Lemma 4 forbids more than one pure colour at any x. To finish one would need a quantitative stability version: if a colour has excess e on V\\{x}, then the transversal/star argument forces more than e/(something) additional excess elsewhere, which would give the sum over k of exc_k(V\\{x}) > r^2(r-1)/2 for some x. Equivalently: show that r graphs partitioning E(K_{r^2+1}), each with alpha <= r, must have total Turan excess strictly greater than r C(r,2). No such stability bound was found. Turan's theorem and its equality case are cited (standard, also used by Kang-Pikhurko for the stability step) and were NOT formalized here. Step 4 uses pure colours as a hypothesis, so it is unconditional as stated.\n\nLiterature: no complete solution for all r >= 3 was found as of 2026-11-26. Known fixed cases (r=3,4 by Erdos-Gyarfas; r=5 by Xia-Szeider arXiv 2610.24484; claimed r=6..9 and 12 plus a large-r cutoff in Robby955/erdos-617-fixed-cases, per the first attempt) do not settle the universal Lean statement. erdosproblems.com/617 and its forum were not directly readable (403) in the first attempt and were not re-read here.\n",
  "lakefile.toml": "name = \"e617_attempt\"\nversion = \"0.1.0\"\ndefaultTargets = [\"TaskSupport\", \"Main\"]\n\n[[require]]\nname = \"formal_conjectures\"\npath = \"../fc\"\n\n[[lean_lib]]\nname = \"TaskSupport\"\n\n[[lean_lib]]\nname = \"Main\"\nroots = [\"Lemmas\"]\n",
  "lean-toolchain": "leanprover/lean4:v4.35.0-rc2\n"
 },
 "file_sha256": {
  "Lemmas.lean": "90c31dcad9a1b4ef205219d1873457758c0f16d6d4faf7791eb4ea66d303162c",
  "build.log": "73c10e7e4b6c0f4e6dd5e192a69e0d3123d5a2987ff641d6b1e59cc6245f763b",
  "axioms.txt": "376f95d8819f26b5ed45920c5825679e1329dab725c07e22d4541edb44224f2c",
  "explanation.md": "fd917fa3a6abf6150248d048c05bb92f7fda4e9348701ed2b1d8f2eb9b7384f7",
  "lakefile.toml": "a92723dd33f5ce6da90e8d5af23e697ce15bc18e91878ab892a45eb84daf97cf",
  "lean-toolchain": "8dc8d6f560141069d9073e370611716ef77ada0da8ffa37e2149f44b2e63ac7a"
 },
 "actions": {
  "local_only": true,
  "submitted": false,
  "uploaded": false,
  "accounts_created": false,
  "credits_bought": false,
  "tao_spent": false
 }
}