{
  "id": "8436",
  "ident": "NS.08436",
  "slug": "wikipedia-sidorenkoconjecture",
  "title": "Sidorenko's conjecture (1993)",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "**Sidorenko's conjecture (1993).**\n\nFor every finite bipartite simple graph $H$ and every finite simple graph $G$:\n$t(H, G) \\ge t(K_2, G)^{e(H)}$, where $K_2$ denotes the single-edge graph on 2 vertices\n(i.e. `completeGraph (Fin 2)`).\n\nThis is false. It was disproved by an internal OpenAI model in September 2026 [OAI26a]; see the\nlinked Lean proof, which gives a bipartite $H$ with $35$ vertices and $66$ edges and a finite\nhost $G$ with $t(H, G) < t(K_2, G)^{66}$.",
  "subjects": [
    "math.CO",
    "msc:05"
  ],
  "tags": [
    "question",
    "formal_proof"
  ],
  "collection": "wikipedia",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "SidorenkoConjecture.sidorenko_conjecture",
  "statement_lean": "theorem sidorenko_conjecture :\n    ¬ ∀ {V W : Type} [Fintype V] [Fintype W] [DecidableEq V] [DecidableEq W] [Nonempty W]\n      (H : SimpleGraph V) (G : SimpleGraph W)\n      [DecidableRel H.Adj] [DecidableRel G.Adj],\n      H.IsBipartite →\n      homDensity (completeGraph (Fin 2)) G ^ H.edgeFinset.card ≤ homDensity H G",
  "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# Sidorenko's conjecture (1993)\n\n*References:*\n* [Wikipedia](https://en.wikipedia.org/wiki/Sidorenko%27s_conjecture)\n* [Si93] Sidorenko, A. (1993). \"A correlation inequality for bipartite graphs.\"\n  *Graphs Combin.* 9, pp. 201--204.\n* [CoFo10] Conlon, D. and Fox, J. (2010). \"Bounds for graph regularity and removal lemmas.\"\n  *Geom. Funct. Anal.* 22, pp. 1191--1256.\n* [KLL18] Kim, J.H., Lee, C., Lee, J. (2018). \"Two approaches to Sidorenko's conjecture.\"\n  *Trans. Amer. Math. Soc.* 370, pp. 8515--8552.\n* [ArXiv2605] [arXiv:2605.14138](https://arxiv.org/abs/2605.14138)\n* [BR65] Blakley, G. R. and Roy, P. (1965). \"A Hölder type inequality for symmetric matrices\n  with nonnegative entries.\" *Proc. Amer. Math. Soc.* 16, pp. 1244--1245.\n* [OAI26a] OpenAI, *A counterexample to Sidorenko's conjecture*. OpenAI Math Release preprint\n  (2026).\n  https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/preprints/A-counterexample-to-Sidorenkos-conjecture-September-23-2026/paper.pdf\n-/\n\n@[expose] public section\n\nopen Finset SimpleGraph\n\nnamespace SidorenkoConjecture\n\nopen LimitObjects\n\n/- ## Homomorphism density\n\nWe use `SimpleGraph.homCount` / `SimpleGraph.homDensity` from\n`FormalConjecturesForMathlib.Combinatorics.SimpleGraph.HomDensity` for finite host graphs,\nand `graphonHomDensity` / `graphonEdgeDensity` from\n`FormalConjecturesForMathlib.Combinatorics.LimitObjects.Graphon` for graphons on measure spaces. -/\n\nvariable {V W : Type*}\n\n/- ## The conjecture -/\n\nset_option linter.style.formal_proof_palomar false in\n/--\n**Sidorenko's conjecture (1993).**\n\nFor every finite bipartite simple graph $H$ and every finite simple graph $G$:\n$t(H, G) \\ge t(K_2, G)^{e(H)}$, where $K_2$ denotes the single-edge graph on 2 vertices\n(i.e. `completeGraph (Fin 2)`).\n\nThis is false. It was disproved by an internal OpenAI model in September 2026 [OAI26a]; see the\nlinked Lean proof, which gives a bipartite $H$ with $35$ vertices and $66$ edges and a finite\nhost $G$ with $t(H, G) < t(K_2, G)^{66}$.\n-/\n@[category research solved, question, AMS 5, formal_proof using lean4 at\n  \"https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Combinatorics/Sidorenko/RandomHost.lean#L319\"]\ntheorem sidorenko_conjecture :\n    ¬ ∀ {V W : Type} [Fintype V] [Fintype W] [DecidableEq V] [DecidableEq W] [Nonempty W]\n      (H : SimpleGraph V) (G : SimpleGraph W)\n      [DecidableRel H.Adj] [DecidableRel G.Adj],\n      H.IsBipartite →\n      homDensity (completeGraph (Fin 2)) G ^ H.edgeFinset.card ≤ homDensity H G := by\n  sorry\n\n/--\n**Sidorenko's conjecture for graphons (1993).**\n\nFor every finite bipartite simple graph $H$ and every graphon $W$ on $[0, 1]$ with Lebesgue measure:\n$t(H, W) \\ge t(K_2, W)^{e(H)}$, where $t(K_2, W) = p(W)$ is the edge density of $W$,\nand $t(H, W)$ is the graphon homomorphism density of $H$ in $W$.\n\nThis is false. The finite counterexample of [OAI26a] (see `sidorenko_conjecture`) also refutes\nthe graphon form: the step graphon of the finite host graph has the same homomorphism\ndensities and the same edge density as the host. This reduction is not part of the linked Lean\nproof of the finite form.\n-/\n@[category research solved, question, AMS 5]\ntheorem sidorenko_conjecture_graphon :\n    ¬ ∀ {V : Type*} [Fintype V] [DecidableEq V] (H : SimpleGraph V) [DecidableRel H.Adj],\n      H.IsBipartite →\n      ∀ (W : Graphon),\n        (graphonEdgeDensity W) ^ H.edgeFinset.card ≤ graphonHomDensity H W := by\n  sorry\n\n/- ## Proved graphon special cases -/\n\n/--\n**Case: `H` is a tree (Sidorenko 1993, graphon version).**\n\nIf `H` is a finite tree then Sidorenko's inequality holds for all graphons on $[0, 1]$.\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_tree_graphon {V : Type*} [Fintype V] [DecidableEq V]\n    (H : SimpleGraph V) [DecidableRel H.Adj] (hTree : H.IsTree)\n    (W : LimitObjects.Graphon) :\n    (graphonEdgeDensity W) ^ H.edgeFinset.card ≤ graphonHomDensity H W := by\n  sorry\n\n/--\n**Case: `H = C_{2k}` is an even cycle (Sidorenko 1993, graphon version).**\n\nEvery even cycle $C_{2k}$ satisfies Sidorenko's inequality for all graphons on $[0, 1]$.\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_even_cycle_graphon (k : ℕ) (hk : 1 ≤ k)\n    (W : LimitObjects.Graphon) :\n    (graphonEdgeDensity W) ^ (cycleGraph (2 * k)).edgeFinset.card ≤\n      graphonHomDensity (cycleGraph (2 * k)) W := by\n  sorry\n\nopen scoped Classical in\n/--\n**Case: `H = K_{a,b}` is a complete bipartite graph (Sidorenko 1993, graphon version).**\n\nEvery complete bipartite graph $K_{a,b}$ satisfies Sidorenko's inequality for all graphons on $[0, 1]$.\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_completeBipartiteGraph_graphon {A B : Type*} [Fintype A] [Fintype B]\n    [DecidableEq A] [DecidableEq B] (W : LimitObjects.Graphon) :\n    (graphonEdgeDensity W) ^ (completeBipartiteGraph A B).edgeFinset.card ≤\n      graphonHomDensity (completeBipartiteGraph A B) W := by\n  sorry\n\n/- ## Tournament Anti-Sidorenko (TAS) Trees Conjecture -/\n\nopen scoped Classical in\n/--\n**Tournament Anti-Sidorenko (TAS) Trees Conjecture.**\n\nFor every finite undirected tree $T$, there exists an orientation $\\vec{T}$ of its edges such that\nfor any finite tournament $G$, the homomorphism density satisfies:\n$$ t_{\\vec{T}}(G) \\le 2^{-e(T)} $$\nwhere $e(T)$ is the total number of edges in $T$.\n-/\n@[category research open, question, AMS 5]\ntheorem tournament_anti_sidorenko_trees_conjecture :\n    ∀ {V : Type*} [Fintype V] [DecidableEq V] (T : SimpleGraph V) [DecidableRel T.Adj],\n      T.IsTree →\n      ∃ (D : Digraph V),\n        D.IsOrientation T ∧\n        ∀ {W : Type*} [Fintype W] [DecidableEq W] [Nonempty W]\n          (G : Digraph W) [DecidableRel G.Adj],\n          G.IsTournament →\n          Digraph.homDensity D G ≤ (1 / 2 : ℝ) ^ T.edgeFinset.card := by\n  sorry\n\nopen scoped Classical in\n/--\n**Tournament Anti-Sidorenko (TAS) Trees Conjecture (Tournamenton limit version).**\n\nFor every finite undirected tree $T$, there exists an orientation $\\vec{T}$ of its edges such that\nfor every tournamenton $W : [0, 1]^2 \\to [0, 1]$, the homomorphism density satisfies:\n$$ t_{\\vec{T}}(W) \\le 2^{-e(T)} $$\nwhere $e(T)$ is the total number of edges in $T$.\n-/\n@[category research open, question, AMS 5]\ntheorem tournament_anti_sidorenko_trees_conjecture_tournamenton :\n    ∀ {V : Type*} [Fintype V] [DecidableEq V] (T : SimpleGraph V) [DecidableRel T.Adj],\n      T.IsTree →\n      ∃ (D : Digraph V),\n        D.IsOrientation T ∧\n        ∀ (W : LimitObjects.Tournamenton),\n          tournamentonHomDensity D W ≤ (1 / 2 : ℝ) ^ T.edgeFinset.card := by\n  sorry\n\nopen scoped Classical in\n/--\n**TAS Trees Conjecture: Trees with a single even-degree vertex.**\n\nProven case of TAS Trees Conjecture: any tree containing exactly one vertex of even degree\npossesses an orientation satisfying the Tournament Anti-Sidorenko inequality $t_{\\vec{T}}(G) \\le 2^{-e(T)}$.\n-/\n@[category research solved, AMS 5]\ntheorem tournament_anti_sidorenko_single_even_degree_tree {V : Type*} [Fintype V] [DecidableEq V]\n    (T : SimpleGraph V) [DecidableRel T.Adj] (hTree : T.IsTree)\n    (hEven : (Finset.univ.filter (fun v => Even (T.degree v))).card = 1) :\n    ∃ (D : Digraph V),\n      D.IsOrientation T ∧\n      ∀ {W : Type*} [Fintype W] [DecidableEq W] [Nonempty W]\n        (G : Digraph W) [DecidableRel G.Adj],\n        G.IsTournament →\n        Digraph.homDensity D G ≤ (1 / 2 : ℝ) ^ T.edgeFinset.card := by\n  sorry\n\nopen scoped Classical in\n/--\n**The $(2,3,4)$-spider tree.**\nA tree composed of three paths of lengths 2, 3, and 4 joined at a single central vertex: the\ncentre is the unique vertex of degree 3 (every other vertex has degree at most 2), so the tree\nhas exactly three leaves, at distances 2, 3 and 4 from the centre.\n-/\ndef IsSpider234 {V : Type*} [Fintype V] [DecidableEq V] (T : SimpleGraph V) [DecidableRel T.Adj] : Prop :=\n  T.IsTree ∧ Fintype.card V = 10 ∧\n  ∃ (center l₁ l₂ l₃ : V),\n    T.degree center = 3 ∧\n    (∀ v, v ≠ center → T.degree v ≤ 2) ∧\n    l₁ ≠ l₂ ∧ l₁ ≠ l₃ ∧ l₂ ≠ l₃ ∧\n    T.degree l₁ = 1 ∧ T.degree l₂ = 1 ∧ T.degree l₃ = 1 ∧\n    ({T.dist center l₁, T.dist center l₂, T.dist center l₃} : Multiset ℕ) = {2, 3, 4}\n\nopen scoped Classical in\n/--\n**TAS Trees Conjecture: The $(2,3,4)$-spider tree (Solved case).**\n\nThe $(2,3,4)$-spider tree satisfies the Tournament Anti-Sidorenko Trees Conjecture.\n\n*Reference:*\n* [ArXiv 2605.14138](https://arxiv.org/abs/2605.14138)\n-/\n@[category research solved, AMS 5]\ntheorem tournament_anti_sidorenko_spider234 {V : Type*} [Fintype V] [DecidableEq V]\n    (T : SimpleGraph V) [DecidableRel T.Adj] (hSpider : IsSpider234 T) :\n    ∃ (D : Digraph V),\n      D.IsOrientation T ∧\n      ∀ {W : Type*} [Fintype W] [DecidableEq W] [Nonempty W]\n        (G : Digraph W) [DecidableRel G.Adj],\n        G.IsTournament →\n        Digraph.homDensity D G ≤ (1 / 2 : ℝ) ^ T.edgeFinset.card := by\n  sorry\n\n/- ## Proved special cases -/\n\n/--\n**Case `H = K_2` (single edge): Sidorenko's inequality holds trivially with equality.**\n\nWhen `H` is `K_2` (the single-edge graph on 2 vertices), `e(H) = 1`, so the RHS of Sidorenko's\ninequality is just `t(K_2, G)^1 = t(K_2, G) = t(H, G)`, which equals the LHS. Hence the\ninequality holds as equality.\n\nThe proof records that `(completeGraph (Fin 2)).edgeFinset.card = 1` and then reduces the claim\nto `t(K_2, G) ≤ t(K_2, G)`, which is `le_refl`.\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_K2 {W : Type} [Fintype W] [DecidableEq W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ^\n      ((completeGraph (Fin 2)).edgeFinset.card) ≤\n      homDensity (completeGraph (Fin 2)) G := by\n  -- `(completeGraph (Fin 2)).edgeFinset.card = 1`, so the inequality is `x^1 ≤ x`, i.e. `x ≤ x`.\n  have hK2 : (completeGraph (Fin 2)).edgeFinset.card = 1 := by\n    rw [SimpleGraph.card_edgeFinset_completeGraph_fin, Nat.choose_self]\n  rw [hK2, pow_one]\n\n/- ## Sidorenko for `K_{2,2}`: auxiliary lemmas -/\n\nopen scoped Classical in\n/-- `edgeCount` of `K_{2,2}` (complete bipartite graph on `Fin 2 + Fin 2`) is `4`.\n\nThe four edges are `{inl 0, inr 0}`, `{inl 0, inr 1}`, `{inl 1, inr 0}`, `{inl 1, inr 1}`. -/\n@[category API, AMS 5]\nlemma edgeCount_completeBipartiteGraph_fin_two :\n    (completeBipartiteGraph (Fin 2) (Fin 2)).edgeFinset.card = 4 := by\n  -- Every vertex of `K_{2,2}` has degree 2, and there are 4 vertices; so by the\n  -- handshake formula `2 * #E = ∑ deg = 4 * 2 = 8`, hence `#E = 4`.\n  have hdeg : ∀ v : Fin 2 ⊕ Fin 2, (completeBipartiteGraph (Fin 2) (Fin 2)).degree v = 2 := by\n    intro v\n    rw [show (completeBipartiteGraph (Fin 2) (Fin 2)).degree v =\n        ((completeBipartiteGraph (Fin 2) (Fin 2)).neighborFinset v).card from rfl]\n    cases v with\n    | inl i =>\n      -- Neighbours of `inl i`: exactly `{inr 0, inr 1}`.\n      rw [neighborFinset_eq_filter]\n      rw [show (Finset.univ : Finset (Fin 2 ⊕ Fin 2)).filter\n          (fun w => (completeBipartiteGraph (Fin 2) (Fin 2)).Adj (Sum.inl i) w)\n          = {Sum.inr (0 : Fin 2), Sum.inr (1 : Fin 2)} from ?_]\n      · decide\n      · ext w\n        cases w with\n        | inl k =>\n          simp [completeBipartiteGraph_adj]\n        | inr k =>\n          simp [completeBipartiteGraph_adj]\n          fin_cases k <;> decide\n    | inr j =>\n      rw [neighborFinset_eq_filter]\n      rw [show (Finset.univ : Finset (Fin 2 ⊕ Fin 2)).filter\n          (fun w => (completeBipartiteGraph (Fin 2) (Fin 2)).Adj (Sum.inr j) w)\n          = {Sum.inl (0 : Fin 2), Sum.inl (1 : Fin 2)} from ?_]\n      · decide\n      · ext w\n        cases w with\n        | inl k =>\n          simp [completeBipartiteGraph_adj]\n          fin_cases k <;> decide\n        | inr k =>\n          simp [completeBipartiteGraph_adj]\n  have h : 2 * ((completeBipartiteGraph (Fin 2) (Fin 2)).edgeFinset).card =\n      ∑ v : Fin 2 ⊕ Fin 2, (completeBipartiteGraph (Fin 2) (Fin 2)).degree v := by\n    rw [← (completeBipartiteGraph (Fin 2) (Fin 2)).sum_degrees_eq_twice_card_edges]\n  rw [Finset.sum_congr rfl (fun v _ => hdeg v)] at h\n  simp at h\n  omega\n\n/-- **Homomorphism count of `K_2` into `G` equals `2 · #edgeFinset`.**\n\nA homomorphism `K_2 →g G` is the same data as an ordered pair `(f 0, f 1)` of distinct\nvertices with `G.Adj (f 0) (f 1)`. These are in bijection with the `Dart`s of `G`, and\n`#Darts(G) = 2 · #E(G)` by `dart_card_eq_twice_card_edges`. -/\n@[category API, AMS 5]\nlemma homCount_completeGraph_fin_two_eq_two_mul_card_edgeFinset\n    {W : Type*} [Fintype W] [DecidableEq W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homCount (completeGraph (Fin 2)) G = 2 * #G.edgeFinset := by\n  -- Build a bijection `(completeGraph (Fin 2) →g G) ≃ G.Dart`.\n  unfold homCount\n  rw [← G.dart_card_eq_twice_card_edges]\n  -- Now: `Fintype.card (completeGraph (Fin 2) →g G) = Fintype.card G.Dart`.\n  refine Fintype.card_congr ?_\n  refine\n    { toFun := fun f =>\n        ⟨(f 0, f 1), f.map_adj (by decide : (completeGraph (Fin 2)).Adj 0 1)⟩\n      invFun := fun d =>\n        { toFun := fun i => if i = 0 then d.fst else d.snd\n          map_rel' := fun {a b} hab => by\n            -- `completeGraph (Fin 2)` adjacency means `a ≠ b`.\n            simp only [completeGraph, top_adj] at hab\n            -- `a, b ∈ Fin 2` with `a ≠ b` means `{a, b} = {0, 1}`.\n            fin_cases a <;> fin_cases b\n            · simp at hab\n            · exact d.adj\n            · exact d.adj.symm\n            · simp at hab }\n      left_inv := fun f => by\n        ext i\n        fin_cases i <;> simp\n      right_inv := fun d => by\n        cases d\n        rfl }\n\nopen scoped Classical in\n/-- **The `Hom(K_{2,2}, G)` decomposition.** The number of homomorphisms from\n`K_{2,2}` to `G` equals `∑_{(a, b) ∈ W × W} |N(a) ∩ N(b)|^2`, where `N(v)` is the\nneighbourhood of `v` in `G`. Equivalently, summing over *ordered* pairs\n`(b₀, b₁) ∈ W × W` and counting common neighbours squared.\n\n**Math.** A homomorphism `K_{2,2} →g G` is an assignment `f : Fin 2 ⊕ Fin 2 → W`\nwith `G.Adj (f (inl i)) (f (inr j))` for all `i, j ∈ Fin 2`. Equivalently, choose\n`(a₀, a₁) := (f (inl 0), f (inl 1))` arbitrarily in `W × W` and require\n`(f (inr 0), f (inr 1))` to both lie in `N(a₀) ∩ N(a₁)`. The count is thus\n`∑_{(a₀, a₁)} |N(a₀) ∩ N(a₁)|²`.\n\n**Proof.** Construct an explicit bijection\n`(K_{2,2} →g G) ≃ Σ (p : W × W), (N(p.1) ∩ N(p.2)) × (N(p.1) ∩ N(p.2))`\nby sending a homomorphism `f` to `⟨(f (inl 0), f (inl 1)), ⟨f (inr 0), f (inr 1)⟩⟩`.\nThe total cardinality of the sigma-product is then\n`∑_p (Fintype.card (N(p.1) ∩ N(p.2)))² = ∑_p |N(p.1) ∩ N(p.2)|²`. -/\n@[category API, AMS 5]\nlemma homCount_completeBipartiteGraph_fin_two_eq_sum_inter_sq\n    {W : Type*} [Fintype W] [DecidableEq W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    (homCount (completeBipartiteGraph (Fin 2) (Fin 2)) G : ℝ) =\n      ∑ p : W × W,\n        (((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card : ℝ) ^ 2 := by\n  -- Reduce to a ℕ identity then cast.\n  have hNat : homCount (completeBipartiteGraph (Fin 2) (Fin 2)) G =\n      ∑ p : W × W,\n        ((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card ^ 2 := by\n    unfold homCount\n    -- Build a `Fintype`-card equivalence between `K_{2,2} →g G` and\n    -- the sigma type `Σ (p : W × W), (N(p.1) ∩ N(p.2)) × (N(p.1) ∩ N(p.2))`.\n    -- A homomorphism `f : K_{2,2} →g G` is determined by the four values\n    -- `(f (inl 0), f (inl 1), f (inr 0), f (inr 1))` with `(inr j)`\n    -- adjacent to `(inl i)` for all `i, j`.  So parameterise by\n    -- `a₀ := f (inl 0)`, `a₁ := f (inl 1)`, then `(b₀, b₁) := (f (inr 0), f (inr 1))`\n    -- must both lie in `N(a₀) ∩ N(a₁)`.\n    let KBip := completeBipartiteGraph (Fin 2) (Fin 2)\n    -- Define the target type parameterised in `p = (a₀, a₁)`.\n    -- Step 1: `card (K_{2,2} →g G) = card (Σ p, (N(p.1) ∩ N(p.2)) × (N(p.1) ∩ N(p.2)))`.\n    have hEquiv : (KBip →g G) ≃\n        Σ p : W × W,\n          ({a : W // a ∈ G.neighborFinset p.1 ∩ G.neighborFinset p.2} ×\n            {a : W // a ∈ G.neighborFinset p.1 ∩ G.neighborFinset p.2}) := by\n      refine\n        { toFun := fun f =>\n            ⟨(f (Sum.inl 0), f (Sum.inl 1)),\n              ⟨⟨f (Sum.inr 0), ?_⟩, ⟨f (Sum.inr 1), ?_⟩⟩⟩\n          invFun := fun x =>\n            { toFun := fun v => match v with\n                | Sum.inl 0 => x.1.1\n                | Sum.inl 1 => x.1.2\n                | Sum.inr 0 => x.2.1.val\n                | Sum.inr 1 => x.2.2.val\n              map_rel' := ?_ }\n          left_inv := ?_\n          right_inv := ?_ }\n      all_goals (try (\n        -- `f (Sum.inr j) ∈ N(f (Sum.inl 0)) ∩ N(f (Sum.inl 1))` for j = 0, 1.\n        simp only [Finset.mem_inter, mem_neighborFinset]\n        refine ⟨f.map_adj ?_, f.map_adj ?_⟩ <;>\n          simp [KBip, completeBipartiteGraph_adj]))\n      · -- Adjacency preservation for the inverse function.\n        rintro a b hab\n        rcases x with ⟨⟨a₀, a₁⟩, ⟨⟨b₀, hb₀⟩, ⟨b₁, hb₁⟩⟩⟩\n        simp only [KBip, completeBipartiteGraph_adj] at hab\n        simp only [Finset.mem_inter, mem_neighborFinset] at hb₀ hb₁\n        match a, b, hab with\n        | Sum.inl i, Sum.inr j, hab =>\n          fin_cases i <;> fin_cases j <;>\n            first | exact hb₀.1 | exact hb₀.2 | exact hb₁.1 | exact hb₁.2\n        | Sum.inr j, Sum.inl i, hab =>\n          fin_cases i <;> fin_cases j <;>\n            first | exact (hb₀.1).symm | exact (hb₀.2).symm |\n                    exact (hb₁.1).symm | exact (hb₁.2).symm\n      · -- left_inv\n        intro f\n        ext v\n        -- v : Fin 2 ⊕ Fin 2, enumerate cases.\n        match v with\n        | Sum.inl i => fin_cases i <;> rfl\n        | Sum.inr j => fin_cases j <;> rfl\n      · -- right_inv\n        rintro ⟨⟨a₀, a₁⟩, ⟨⟨b₀, hb₀⟩, ⟨b₁, hb₁⟩⟩⟩\n        rfl\n    -- Step 2: use `Fintype.card_congr` and simplify the cardinality of the sigma-product.\n    rw [Fintype.card_congr hEquiv]\n    rw [Fintype.card_sigma]\n    apply Finset.sum_congr rfl\n    intro p _\n    rw [Fintype.card_prod, sq]\n    -- Rewrite each subtype cardinality to a finset cardinality.\n    have hcard : Fintype.card\n        {a : W // a ∈ G.neighborFinset p.1 ∩ G.neighborFinset p.2}\n          = (G.neighborFinset p.1 ∩ G.neighborFinset p.2).card := Fintype.card_coe _\n    rw [hcard]\n  -- Cast ℕ identity to ℝ.\n  have := congrArg (Nat.cast (R := ℝ)) hNat\n  push_cast at this\n  exact this\n\n/-- **`K_{2,2}` count via a re-indexed sum.** Swapping the order of summation, the\n`Hom(K_{2,2}, G)` count equals `∑_{a ∈ W} (G.degree a)²` summed over... wait, more\nprecisely: the sum `∑_{(b₀, b₁)} |N(b₀) ∩ N(b₁)|` (without the square) equals\n`∑_a (G.degree a)²`, by swapping `(∑_{b₀, b₁} ∑_a [a ~ b₀][a ~ b₁]) = ∑_a (∑_b [a ~ b])²`.\n\nThis version of the identity is what appears in the Cauchy-Schwarz step. -/\n@[category API, AMS 5]\nlemma sum_inter_card_eq_sum_degree_sq\n    {W : Type*} [Fintype W] [DecidableEq W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    ∑ p : W × W,\n        (((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card : ℝ) =\n      ∑ a : W, ((G.degree a : ℝ)) ^ 2 := by\n  -- Work in ℕ for the combinatorial part, then cast.\n  have hNat : ∑ p : W × W, ((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card =\n      ∑ a : W, (G.degree a) ^ 2 := by\n    -- `|N(b₀) ∩ N(b₁)| = ∑_a [a ∈ N(b₀)][a ∈ N(b₁)]`, so summing gives\n    -- `∑_{b₀, b₁} |N(b₀) ∩ N(b₁)| = ∑_a (∑_{b₀} [b₀ ∈ N(a)])² = ∑_a deg(a)²`,\n    -- using `b ∈ N(a) ↔ a ∈ N(b)` (`adj_comm`).\n    calc ∑ p : W × W, ((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card\n        = ∑ p : W × W,\n            ((Finset.univ : Finset W).filter\n              (fun a => a ∈ G.neighborFinset p.1 ∧ a ∈ G.neighborFinset p.2)).card := by\n          apply Finset.sum_congr rfl\n          intro p _\n          congr 1\n          ext a\n          simp [Finset.mem_inter]\n      _ = ∑ p : W × W, ∑ a : W,\n            (if a ∈ G.neighborFinset p.1 ∧ a ∈ G.neighborFinset p.2 then 1 else 0) := by\n          apply Finset.sum_congr rfl\n          intro p _\n          rw [Finset.card_filter]\n      _ = ∑ a : W, ∑ p : W × W,\n            (if a ∈ G.neighborFinset p.1 ∧ a ∈ G.neighborFinset p.2 then 1 else 0) :=\n          Finset.sum_comm\n      _ = ∑ a : W, (∑ b : W, (if a ∈ G.neighborFinset b then 1 else 0)) ^ 2 := by\n          apply Finset.sum_congr rfl\n          intro a _\n          rw [sq, Finset.sum_mul_sum]\n          -- Goal: `∑ p : W × W, ite (a ∈ N p.1 ∧ a ∈ N p.2) 1 0 = ∑ p ∈ univ ×ˢ univ, ...`\n          rw [show (Finset.univ : Finset (W × W)) = Finset.univ ×ˢ Finset.univ from\n            (Finset.univ_product_univ).symm]\n          rw [Finset.sum_product]\n          apply Finset.sum_congr rfl\n          intro b₀ _\n          apply Finset.sum_congr rfl\n          intro b₁ _\n          by_cases h0 : a ∈ G.neighborFinset b₀ <;> by_cases h1 : a ∈ G.neighborFinset b₁ <;>\n            simp [h0, h1]\n      _ = ∑ a : W, (G.degree a) ^ 2 := by\n          apply Finset.sum_congr rfl\n          intro a _\n          congr 1\n          -- Want: `∑ b, ite (a ∈ N(b)) 1 0 = G.degree a`.\n          rw [Finset.sum_ite, Finset.sum_const, Finset.sum_const_zero, add_zero,\n            smul_eq_mul, mul_one]\n          rw [← card_neighborFinset_eq_degree]\n          congr 1\n          ext b\n          simp [mem_neighborFinset, adj_comm]\n  -- Cast to ℝ.\n  have := congrArg (Nat.cast (R := ℝ)) hNat\n  simp only [Nat.cast_sum, Nat.cast_pow] at this\n  exact this\n\nopen scoped Classical in\n/--\n**Case `H = K_{2,2}` (four-cycle, also called `C_4`): Sidorenko's conjecture holds, by\nCauchy–Schwarz.**\n\nThe textbook statement at `H = K_{2,2}` is\n`t(K_2, G)^{e(K_{2,2})} = t(K_2, G)^4 ≤ t(K_{2,2}, G)`.\n\n**Proof sketch.** Write `d(a) := G.degree a`. Then\n- `homCount(K_2, G) = ∑_a d(a) = 2·|E(G)|` (handshaking).\n- `homCount(K_{2,2}, G) = ∑_{b₀, b₁} |N(b₀) ∩ N(b₁)|²` (product structure of bipartite\n  homomorphism).\n- `∑_{b₀, b₁} |N(b₀) ∩ N(b₁)| = ∑_a d(a)²` (swap sums).\n- Cauchy–Schwarz #1: `(∑_{b₀, b₁} |N(b₀) ∩ N(b₁)|)² ≤ |W|² · ∑_{b₀, b₁} |N(b₀) ∩ N(b₁)|²`.\n- Cauchy–Schwarz #2: `(∑_a d(a))² ≤ |W| · ∑_a d(a)²`.\n- Chain: `(∑_a d(a))⁴ ≤ |W|⁴ · homCount(K_{2,2}, G)`.\n- Divide by `|W|^8` to get `t(K_2, G)^4 ≤ t(K_{2,2}, G)`.\n\nThe proof uses `Finset.sum_mul_sq_le_sq_mul_sq` (discrete Cauchy–Schwarz) from\n`Mathlib.Algebra.Order.BigOperators.Ring.Finset`.\n\n**Status (2026-04-22):** main theorem closed sorry-free. See [Si93].\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_K22 {W : Type} [Fintype W] [DecidableEq W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ^\n      ((completeBipartiteGraph (Fin 2) (Fin 2)).edgeFinset.card) ≤\n      homDensity (completeBipartiteGraph (Fin 2) (Fin 2)) G := by\n  -- Unfold `edgeCount` to `4`.\n  rw [edgeCount_completeBipartiteGraph_fin_two]\n  -- Dispatch the empty-vertex-type case.\n  by_cases hW : IsEmpty W\n  · -- With `W` empty: `homCount K_2 G = 0` (no functions `Fin 2 → W`), hence `homDensity = 0`.\n    -- `homCount K_{2,2} G = 0` as well, but division by `0^4 = 0` still gives `0`.\n    simp only [homDensity]\n    have hcardW : Fintype.card W = 0 := Fintype.card_eq_zero\n    rw [hcardW]\n    -- The goal now involves `0 ^ _` in denominators. Both sides reduce to `0`.\n    simp only [Fintype.card_fin, pow_succ, pow_zero, one_mul]\n    -- Fin 2 has 2 elements, (Fin 2 ⊕ Fin 2) has 4.\n    rw [show Fintype.card (Fin 2 ⊕ Fin 2) = 4 by decide]\n    norm_num\n  -- Now `W` is nonempty.\n  have : Nonempty W := not_isEmpty_iff.mp hW\n  have hWpos : 0 < (Fintype.card W : ℝ) := by exact_mod_cast Fintype.card_pos\n  -- Unfold densities.\n  unfold homDensity\n  set n : ℕ := Fintype.card W with hn\n  have hn_pos : 0 < (n : ℝ) := hWpos\n  -- Cardinalities of the two `V` sides of `homDensity`.\n  have hFin2 : Fintype.card (Fin 2) = 2 := by decide\n  have hFin2sum : Fintype.card (Fin 2 ⊕ Fin 2) = 4 := by decide\n  rw [hFin2, hFin2sum]\n  -- Notation.\n  set N : ℕ := homCount (completeGraph (Fin 2)) G with hN\n  set M : ℕ := homCount (completeBipartiteGraph (Fin 2) (Fin 2)) G with hM\n  -- Goal: `((N : ℝ) / n^2)^4 ≤ (M : ℝ) / n^4`.\n  -- Multiply through by `n^8`: `N^4 * n^0 ≤ M * n^4`... but power combining is tricky.\n  -- Instead: express as `N^4 ≤ M * n^4` then divide by `n^8 = (n^2)^4`.\n  have h_main : (N : ℝ) ^ 4 ≤ (M : ℝ) * (n : ℝ) ^ 4 := by\n    -- Plan:\n    -- (1) `N = ∑ a, deg(a)` (from K_2 bijection + handshaking).\n    have hN_expand : (N : ℝ) = ∑ a : W, (G.degree a : ℝ) := by\n      rw [hN, homCount_completeGraph_fin_two_eq_two_mul_card_edgeFinset]\n      rw [← G.sum_degrees_eq_twice_card_edges]\n      push_cast; rfl\n    -- (2) `M = ∑ (b₀, b₁) : W × W, |N(b₀) ∩ N(b₁)|²` (Hom K_{2,2} decomposition).\n    have hM_expand : (M : ℝ) =\n        ∑ p : W × W, (((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card : ℝ) ^ 2 :=\n      homCount_completeBipartiteGraph_fin_two_eq_sum_inter_sq G\n    -- Define `S := ∑ (b₀, b₁), |N(b₀) ∩ N(b₁)|`. Then:\n    -- - C-S #1: `S² ≤ n² · M`.\n    -- - `S = ∑ a, deg(a)²` (swap sums).\n    -- - C-S #2: `N² = (∑_a deg a)² ≤ n · ∑_a deg(a)² = n · S`.\n    -- Combining: `N⁴ = (N²)² ≤ (n · S)² = n² · S² ≤ n² · (n² · M) = n⁴ · M`.\n    set S : ℝ := ∑ p : W × W, (((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card : ℝ)\n      with hS\n    -- S_nonneg\n    have hS_nonneg : 0 ≤ S := Finset.sum_nonneg fun _ _ => by positivity\n    -- Step A: S = ∑ a, deg(a)².\n    have hS_eq_sumdeg_sq : S = ∑ a : W, ((G.degree a : ℝ)) ^ 2 :=\n      sum_inter_card_eq_sum_degree_sq G\n    -- Step B: C-S #2: `(∑_a deg a)² ≤ n · ∑_a deg(a)²`.\n    have hCS2 : (∑ a : W, (G.degree a : ℝ)) ^ 2 ≤ (n : ℝ) * ∑ a : W, ((G.degree a : ℝ)) ^ 2 := by\n      have hraw := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset W)\n        (fun a => (G.degree a : ℝ)) (fun _ => (1 : ℝ))\n      -- hraw : (∑ a ∈ univ, deg(a) * 1)^2 ≤ (∑ a ∈ univ, deg(a)^2) * ∑ a ∈ univ, 1^2\n      simp only [mul_one, one_pow] at hraw\n      -- After simp: `(∑_a deg a)² ≤ (∑_a deg a ²) * ∑_a 1`.\n      have hcard : (∑ _a : W, (1 : ℝ)) = (n : ℝ) := by\n        simp [Finset.sum_const, Finset.card_univ, ← hn]\n      rw [hcard] at hraw\n      linarith [hraw]\n    -- Step C: C-S #1: `(∑ p, x(p))² ≤ n² · ∑ p, x(p)²` where `p : W × W` and `|W × W| = n²`.\n    have hCS1 : S ^ 2 ≤ (n : ℝ) ^ 2 * (M : ℝ) := by\n      have hraw := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset (W × W))\n        (fun p => (((G.neighborFinset p.1) ∩ (G.neighborFinset p.2)).card : ℝ))\n        (fun _ => (1 : ℝ))\n      simp only [mul_one, one_pow] at hraw\n      have hcard : (∑ _p : W × W, (1 : ℝ)) = (n : ℝ) ^ 2 := by\n        simp only [Finset.sum_const, Finset.card_univ, Fintype.card_prod, ← hn]\n        ring\n      rw [hcard] at hraw\n      rw [hS, hM_expand]\n      linarith [hraw]\n    -- Now chain.\n    have hN_eq : (N : ℝ) = ∑ a : W, (G.degree a : ℝ) := hN_expand\n    have hN2_le : (N : ℝ) ^ 2 ≤ (n : ℝ) * S := by\n      rw [hN_eq, hS_eq_sumdeg_sq]; exact hCS2\n    have hN_nonneg : 0 ≤ (N : ℝ) := Nat.cast_nonneg _\n    have hn_nonneg : 0 ≤ (n : ℝ) := hn_pos.le\n    have hn2_nonneg : 0 ≤ (n : ℝ) ^ 2 := by positivity\n    -- N^4 = (N^2)^2 ≤ (n·S)^2 = n²·S² ≤ n²·(n²·M) = n⁴·M.\n    have hN4_le : (N : ℝ) ^ 4 ≤ (n : ℝ) ^ 2 * S ^ 2 := by\n      have : ((N : ℝ) ^ 2) ^ 2 ≤ ((n : ℝ) * S) ^ 2 := by\n        apply sq_le_sq' (by nlinarith [sq_nonneg ((N : ℝ)^2 + (n : ℝ)*S)]) hN2_le\n      calc (N : ℝ) ^ 4 = ((N : ℝ) ^ 2) ^ 2 := by ring\n        _ ≤ ((n : ℝ) * S) ^ 2 := this\n        _ = (n : ℝ) ^ 2 * S ^ 2 := by ring\n    calc (N : ℝ) ^ 4 ≤ (n : ℝ) ^ 2 * S ^ 2 := hN4_le\n      _ ≤ (n : ℝ) ^ 2 * ((n : ℝ) ^ 2 * (M : ℝ)) := by\n          apply mul_le_mul_of_nonneg_left hCS1 hn2_nonneg\n      _ = (M : ℝ) * (n : ℝ) ^ 4 := by ring\n  -- Turn `h_main : N^4 ≤ M * n^4` into the density inequality `(N/n²)^4 ≤ M/n⁴`.\n  have hn4_pos : 0 < (n : ℝ) ^ 4 := by positivity\n  have hn2_pos : 0 < (n : ℝ) ^ 2 := by positivity\n  rw [div_pow, div_le_div_iff₀ (by positivity) hn4_pos]\n  -- Goal: N^4 * n^4 ≤ M * (n^2)^4 = M * n^8.\n  -- From h_main: N^4 ≤ M * n^4. Multiply both sides by n^4 > 0.\n  have hmul := mul_le_mul_of_nonneg_right h_main hn4_pos.le\n  -- hmul : N^4 * n^4 ≤ (M * n^4) * n^4\n  nlinarith [hmul, sq_nonneg ((n : ℝ))]\n\nopen scoped Classical in\n/-- Consequence of `homDensity_le_one`: both sides of the Sidorenko K_{2,2}\ninequality are bounded above by 1. This is a trivial consequence, recorded\nas a sanity check on the helper infrastructure in\n`FormalConjecturesForMathlib.Combinatorics.SimpleGraph.HomDensity`. -/\n@[category API, AMS 5]\ntheorem sidorenko_K22_both_sides_bounded {W : Type*} [Fintype W] [Nonempty W]\n    [DecidableEq W] (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ≤ 1\n    ∧ homDensity (completeBipartiteGraph (Fin 2) (Fin 2)) G ≤ 1 :=\n  ⟨SimpleGraph.homDensity_le_one _ _, SimpleGraph.homDensity_le_one _ _⟩\n\n/- ## Sidorenko for trees: auxiliary lemmas -/\n\n/-- If the domain of `H` has at most one vertex, `H` has no edges.\n\n**Proof.** `SimpleGraph.Adj` is irreflexive, so any adjacency `H.Adj u v` forces\n`u ≠ v`; on a subsingleton that's impossible, so no edges exist. -/\n@[category API, AMS 5]\nlemma edgeCount_eq_zero_of_subsingleton {V : Type*} [Fintype V] [Subsingleton V]\n    (H : SimpleGraph V) [DecidableRel H.Adj] : H.edgeFinset.card = 0 := by\n  rw [Finset.card_eq_zero]\n  rw [Finset.eq_empty_iff_forall_notMem]\n  intro e he\n  rw [mem_edgeFinset] at he\n  induction e with\n  | h u v =>\n    rw [mem_edgeSet] at he\n    exact H.ne_of_adj he (Subsingleton.elim u v)\n\n/-- If the domain of `H` has at most one vertex, every function `V → W` is a homomorphism\n`H →g G`. Equivalently, `homCount H G = |W|^|V|`.\n\n**Proof.** The adjacency `H.Adj u v` is irreflexive; on a subsingleton it is uninhabited,\nso the homomorphism condition `H.Adj u v → G.Adj (f u) (f v)` is vacuous. Hence the\n`coe : (H →g G) → (V → W)` map is a bijection. -/\n@[category API, AMS 5]\nlemma homCount_eq_of_subsingleton {V W : Type*} [Fintype V] [Fintype W]\n    [Subsingleton V] [DecidableEq V] [DecidableEq W]\n    (H : SimpleGraph V) (G : SimpleGraph W)\n    [DecidableRel H.Adj] [DecidableRel G.Adj] :\n    homCount H G = (Fintype.card W) ^ (Fintype.card V) := by\n  unfold homCount\n  rw [← Fintype.card_fun]\n  refine Fintype.card_congr ?_\n  refine\n    { toFun := fun f => (f : V → W)\n      invFun := fun f =>\n        { toFun := f\n          map_rel' := fun {u v} huv => (H.ne_of_adj huv (Subsingleton.elim u v)).elim }\n      left_inv := fun _ => rfl\n      right_inv := fun _ => rfl }\n\n/-- **Base case of Sidorenko for trees.** When the tree `H` has at most one vertex,\nboth sides of Sidorenko's inequality evaluate to `1` (there are no edges, and every\nfunction is a homomorphism). Thus the inequality `1 ≤ 1` holds trivially.\n\nThis covers the `|V(T)| = 1` base case of the induction on tree size. -/\n@[category research solved, AMS 5]\ntheorem sidorenko_tree_subsingleton {V W : Type} [Fintype V] [Fintype W]\n    [Subsingleton V] [DecidableEq V] [DecidableEq W] [Nonempty W]\n    (H : SimpleGraph V) (G : SimpleGraph W)\n    [DecidableRel H.Adj] [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ^ (H.edgeFinset.card) ≤ homDensity H G := by\n  -- `H.edgeFinset.card = 0`, so LHS = `_ ^ 0 = 1`.\n  rw [edgeCount_eq_zero_of_subsingleton H, pow_zero]\n  -- `homDensity H G = |W|^|V| / |W|^|V| = 1`.\n  have hWpos : 0 < Fintype.card W := Fintype.card_pos\n  have hWpow : (0 : ℝ) < (Fintype.card W : ℝ) ^ Fintype.card V :=\n    pow_pos (by exact_mod_cast hWpos) _\n  rw [homDensity, homCount_eq_of_subsingleton H G]\n  push_cast\n  rw [div_self (ne_of_gt hWpow)]\n\n/--\n**Case: `H` is a tree (Sidorenko 1993).**\n\nIf `H` is a finite tree then Sidorenko's inequality holds.\n\n**Proof idea (Sidorenko 1993):** by induction on the tree, applying Jensen / convexity. The\nnumber of homomorphisms from a tree `T` with `v` vertices and `v - 1` edges into `G` factors\nnicely in the degree sequence of `G`, and AM–GM / convexity gives the required lower bound.\n\n**Current status (2026-04-22, partial):**\n- The subsingleton base case (`|V(T)| ≤ 1`) is dispatched via `sidorenko_tree_subsingleton`.\n- The main inductive step (leaf extraction + AM–GM on the degree sequence) is deferred;\n  it requires a walk-parametrised homomorphism count for trees and a discrete Jensen\n  inequality. See [Si93].\n\nThe full proof is left as `sorry`; the subsingleton case is closed.\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_tree {V W : Type} [Fintype V] [Fintype W]\n    [DecidableEq V] [DecidableEq W] [Nonempty W]\n    (H : SimpleGraph V) (G : SimpleGraph W)\n    [DecidableRel H.Adj] [DecidableRel G.Adj]\n    (hTree : H.IsTree) :\n    homDensity (completeGraph (Fin 2)) G ^ (H.edgeFinset.card) ≤ homDensity H G := by\n  -- A tree's vertex set is nonempty.\n  have : Nonempty V := hTree.nonempty\n  -- Split on whether `V` is a subsingleton.\n  by_cases hSub : Subsingleton V\n  · -- Base case: `|V| ≤ 1`, so `H` has no edges and both sides equal `1`.\n    exact sidorenko_tree_subsingleton H G\n  · -- Inductive step: `|V| ≥ 2`. This is the AM–GM / Jensen part of Sidorenko's proof.\n    -- The argument: pick a leaf `v` of `H`, set `H' := H \\ {v}` (a tree on `|V|-1`\n    -- vertices), apply IH, then use the leaf decomposition\n    -- `homCount H G = ∑ {φ : H' →g G}, G.degree (φ u)` (where `u` is the unique neighbour\n    -- of `v` in `H`) and discrete Jensen on the degree sequence.\n    --\n    -- This requires:\n    -- 1. A `homCount_of_leaf_decomposition` lemma (sum over `φ : H' →g G` of `G.degree (φ u)`).\n    -- 2. A discrete Jensen inequality (`∑ x_i · w_i ≥ (∑ w_i) · ((∑ x_i w_i) / ∑ w_i)` with\n    --    appropriate convexity).\n    -- 3. Induction on `H.edgeFinset.card` (equivalently `|V| - 1`).\n    --\n    -- Deferred to a future commit; see `docs/PHASE2_PROOF_ROADMAP.md` §6.\n    sorry\n\n/- ## Further variants of Sidorenko's conjecture -/\n\n/--\n**Case: complete bipartite graphs `K_{s,t}` (Sidorenko 1993).**\n\nSidorenko's inequality holds when `H = K_{s,t}` is a complete bipartite graph. This is one\nof the earliest known cases; it follows from repeated applications of the Cauchy–Schwarz /\nHölder inequality. The `s = t = 2` instance is `sidorenko_K22`.\n\n*Reference:* [Si93].\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_conjecture.variants.complete_bipartite (s t : ℕ)\n    [DecidableRel (completeBipartiteGraph (Fin s) (Fin t)).Adj]\n    {W : Type} [Fintype W] [DecidableEq W] [Nonempty W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ^\n        ((completeBipartiteGraph (Fin s) (Fin t)).edgeFinset.card) ≤\n      homDensity (completeBipartiteGraph (Fin s) (Fin t)) G := by\n  sorry\n\n/--\n**Case: even cycles `C_{2k}` (Sidorenko 1993).**\n\nSidorenko's inequality holds for every even cycle `C_{2k}` with `k ≥ 2`\n(`cycleGraph (2 * k)`). Even cycles are bipartite; the `k = 2` case `C_4` coincides\nwith `K_{2,2}` (`sidorenko_K22`).\n\n*Reference:* [Si93].\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_conjecture.variants.even_cycle (k : ℕ) (hk : 2 ≤ k)\n    {W : Type} [Fintype W] [DecidableEq W] [Nonempty W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ^\n        ((cycleGraph (2 * k)).edgeFinset.card) ≤\n      homDensity (cycleGraph (2 * k)) G := by\n  sorry\n\n/--\n**Case: paths, the Blakley–Roy inequality (1965).**\n\nFor the path `P_n` on `n` vertices (`pathGraph n`), Sidorenko's inequality\n`t(K_2, G)^{e(P_n)} ≤ t(P_n, G)` is the Blakley–Roy inequality, established well before\nSidorenko's general conjecture. Paths are trees, so this is also a special case of\n`sidorenko_tree`.\n\n*Reference:* [BR65].\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_conjecture.variants.path_blakley_roy (n : ℕ)\n    [DecidableRel (pathGraph n).Adj]\n    {W : Type} [Fintype W] [DecidableEq W] [Nonempty W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ^ ((pathGraph n).edgeFinset.card) ≤\n      homDensity (pathGraph n) G := by\n  sorry\n\n/-- **Homomorphism count of the star `K_{1,m}`.** The number of homomorphisms from the star\n`K_{1,m} = completeBipartiteGraph (Fin 1) (Fin m)` into `G` equals `∑_{c} (G.degree c)^m`.\n\n**Math.** A homomorphism `f : K_{1,m} →g G` is determined by the image `c := f` of the centre\n`Sum.inl 0` together with the images of the `m` leaves `Sum.inr j`, each of which must lie in\nthe neighbourhood `N(c)` (and there is no constraint between distinct leaves). So the data is a\nchoice of `c` and a function `Fin m → N(c)`, giving `∑_c |N(c)|^m = ∑_c (G.degree c)^m`. -/\n@[category API, AMS 5]\nlemma homCount_star_eq_sum_degree_pow (m : ℕ)\n    [DecidableRel (completeBipartiteGraph (Fin 1) (Fin m)).Adj]\n    {W : Type*} [Fintype W] [DecidableEq W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homCount (completeBipartiteGraph (Fin 1) (Fin m)) G = ∑ c : W, (G.degree c) ^ m := by\n  unfold homCount\n  have hEquiv : (completeBipartiteGraph (Fin 1) (Fin m) →g G) ≃\n      Σ c : W, (Fin m → {w : W // w ∈ G.neighborFinset c}) := by\n    refine\n      { toFun := fun f => ⟨f (Sum.inl 0), fun j => ⟨f (Sum.inr j), ?_⟩⟩\n        invFun := fun x =>\n          { toFun := fun v =>\n              match v with\n              | Sum.inl _ => x.1\n              | Sum.inr j => (x.2 j).val\n            map_rel' := ?_ }\n        left_inv := ?_\n        right_inv := ?_ }\n    · -- `f (Sum.inr j) ∈ N(f (Sum.inl 0))`.\n      rw [mem_neighborFinset]\n      exact f.map_adj (by simp [completeBipartiteGraph])\n    · -- Adjacency preservation for the inverse.\n      rintro a b hab\n      obtain ⟨c, g⟩ := x\n      cases a with\n      | inl i =>\n        cases b with\n        | inl k => simp [completeBipartiteGraph] at hab\n        | inr j =>\n          have hj := (g j).property\n          rw [mem_neighborFinset] at hj\n          exact hj\n      | inr j =>\n        cases b with\n        | inl k =>\n          have hj := (g j).property\n          rw [mem_neighborFinset] at hj\n          exact hj.symm\n        | inr k => simp [completeBipartiteGraph] at hab\n    · -- left_inv\n      intro f\n      ext v\n      cases v with\n      | inl i => obtain rfl := Fin.fin_one_eq_zero i; rfl\n      | inr j => rfl\n    · -- right_inv\n      rintro ⟨c, g⟩\n      rfl\n  rw [Fintype.card_congr hEquiv, Fintype.card_sigma]\n  apply Finset.sum_congr rfl\n  intro c _\n  rw [Fintype.card_fun, Fintype.card_coe, card_neighborFinset_eq_degree, Fintype.card_fin]\n\n/-- **Edge count of the star `K_{1,m}`.** The star `completeBipartiteGraph (Fin 1) (Fin m)`\nhas exactly `m` edges (the centre `Sum.inl 0` joined to each of the `m` leaves). -/\n@[category API, AMS 5]\nlemma card_edgeFinset_star (m : ℕ)\n    [DecidableRel (completeBipartiteGraph (Fin 1) (Fin m)).Adj] :\n    (completeBipartiteGraph (Fin 1) (Fin m)).edgeFinset.card = m := by\n  -- Handshake: `2 · #E = ∑ deg = deg(centre) + ∑ deg(leaf) = m + m·1 = 2m`.\n  have hdeg_centre : (completeBipartiteGraph (Fin 1) (Fin m)).degree (Sum.inl 0) = m := by\n    rw [← card_neighborFinset_eq_degree, neighborFinset_eq_filter]\n    rw [show (Finset.univ.filter\n        fun w => (completeBipartiteGraph (Fin 1) (Fin m)).Adj (Sum.inl 0) w)\n        = Finset.univ.map ⟨Sum.inr, Sum.inr_injective⟩ from ?_]\n    · simp\n    · ext w\n      cases w with\n      | inl k => simp [completeBipartiteGraph]\n      | inr k => simp [completeBipartiteGraph]\n  have hdeg_leaf : ∀ j : Fin m, (completeBipartiteGraph (Fin 1) (Fin m)).degree (Sum.inr j) = 1 := by\n    intro j\n    rw [← card_neighborFinset_eq_degree, neighborFinset_eq_filter]\n    rw [show (Finset.univ.filter\n        fun w => (completeBipartiteGraph (Fin 1) (Fin m)).Adj (Sum.inr j) w)\n        = {Sum.inl (0 : Fin 1)} from ?_]\n    · simp\n    · ext w\n      cases w with\n      | inl k => simp [completeBipartiteGraph, Fin.fin_one_eq_zero k]\n      | inr k => simp [completeBipartiteGraph]\n  have hsum : ∑ v : Fin 1 ⊕ Fin m, (completeBipartiteGraph (Fin 1) (Fin m)).degree v = 2 * m := by\n    rw [Fintype.sum_sum_type, Fin.sum_univ_one, hdeg_centre]\n    simp only [hdeg_leaf, Finset.sum_const, Finset.card_univ, Fintype.card_fin, smul_eq_mul,\n      mul_one]\n    ring\n  have h := (completeBipartiteGraph (Fin 1) (Fin m)).sum_degrees_eq_twice_card_edges\n  rw [hsum] at h\n  omega\n\n/--\n**Case: stars `K_{1,m}` (Sidorenko).**\n\nSidorenko's inequality holds for every star `K_{1,m} = completeBipartiteGraph (Fin 1) (Fin m)`.\nThis is a fully proved instance of both `sidorenko_conjecture.variants.complete_bipartite` and\n`sidorenko_tree` (a star is a complete bipartite graph and a tree).\n\n**Proof.** With `d(c) := G.degree c` and `N := |W|`, the star has `m` edges, so the desired\ninequality is `(∑_c d(c) / N^2)^m ≤ (∑_c d(c)^m) / N^{m+1}` (using `t(K_2, G) = ∑_c d(c) / N^2`\nand `t(K_{1,m}, G) = ∑_c d(c)^m / N^{m+1}` via `homCount_star_eq_sum_degree_pow`). After clearing\ndenominators this is `(∑_c d(c))^m ≤ N^{m-1} · ∑_c d(c)^m`, the power-mean (Jensen) inequality\n`Finset.pow_sum_div_card_le_sum_pow`. -/\n@[category research solved, AMS 5]\ntheorem sidorenko_conjecture.variants.star (m : ℕ)\n    [DecidableRel (completeBipartiteGraph (Fin 1) (Fin m)).Adj]\n    {W : Type} [Fintype W] [DecidableEq W] [Nonempty W]\n    (G : SimpleGraph W) [DecidableRel G.Adj] :\n    homDensity (completeGraph (Fin 2)) G ^\n        ((completeBipartiteGraph (Fin 1) (Fin m)).edgeFinset.card) ≤\n      homDensity (completeBipartiteGraph (Fin 1) (Fin m)) G := by\n  rw [card_edgeFinset_star]\n  set N : ℕ := Fintype.card W with hN\n  have hNpos : 0 < (N : ℝ) := by exact_mod_cast Fintype.card_pos\n  -- Left-hand base `t(K_2, G) = (∑_c d(c)) / N^2`.\n  have hLbase : homDensity (completeGraph (Fin 2)) G = (∑ c : W, (G.degree c : ℝ)) / (N : ℝ) ^ 2 := by\n    unfold homDensity\n    rw [homCount_completeGraph_fin_two_eq_two_mul_card_edgeFinset,\n      ← G.sum_degrees_eq_twice_card_edges]\n    simp only [Fintype.card_fin, ← hN]\n    push_cast\n    ring\n  -- Right-hand side `t(K_{1,m}, G) = (∑_c d(c)^m) / N^{m+1}`.\n  have hR : homDensity (completeBipartiteGraph (Fin 1) (Fin m)) G\n      = (∑ c : W, (G.degree c : ℝ) ^ m) / (N : ℝ) ^ (m + 1) := by\n    unfold homDensity\n    rw [homCount_star_eq_sum_degree_pow]\n    have hcardV : Fintype.card (Fin 1 ⊕ Fin m) = m + 1 := by simp [add_comm]\n    rw [hcardV, ← hN]\n    push_cast\n    rfl\n  rw [hLbase, hR, div_pow]\n  rcases Nat.eq_zero_or_pos m with hm | hm\n  · -- `m = 0`: both sides equal `1`.\n    subst hm\n    simp [Finset.sum_const, Finset.card_univ, ← hN]\n  · -- `m ≥ 1`: the power-mean (Jensen) inequality `(∑ d)^m / N^{m-1} ≤ ∑ d^m`.\n    obtain ⟨k, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hm.ne'\n    have hjensen := pow_sum_div_card_le_sum_pow (s := (Finset.univ : Finset W))\n      (f := fun c => (G.degree c : ℝ)) (fun _ _ => by positivity) k\n    rw [Finset.card_univ, ← hN, div_le_iff₀ (by positivity : (0 : ℝ) < (N : ℝ) ^ k)] at hjensen\n    -- hjensen : (∑ c, ↑(d c))^(k+1) ≤ (∑ c, (↑(d c))^(k+1)) * N^k\n    rw [div_le_div_iff₀ (by positivity) (by positivity)]\n    calc (∑ c : W, (G.degree c : ℝ)) ^ (k + 1) * (N : ℝ) ^ (k + 1 + 1)\n        ≤ ((∑ c : W, (G.degree c : ℝ) ^ (k + 1)) * (N : ℝ) ^ k) * (N : ℝ) ^ (k + 1 + 1) :=\n          mul_le_mul_of_nonneg_right hjensen (by positivity)\n      _ = (∑ c : W, (G.degree c : ℝ) ^ (k + 1)) * ((N : ℝ) ^ 2) ^ (k + 1) := by ring\n\n/--\n**Bipartiteness is necessary: the triangle is not a Sidorenko graph.**\n\nThe hypothesis `H.IsBipartite` in `sidorenko_conjecture` cannot be dropped. For the\ntriangle `H = K_3` (chromatic number `3`, hence not bipartite) and the single edge\n`G = K_2`, Sidorenko's inequality fails: the putative lower bound is\n`t(K_2, K_2)^{e(K_3)} = (1/2)^3 = 1/8`, while the actual density is `t(K_3, K_2) = 0`,\nbecause there is no graph homomorphism from `K_3` into the triangle-free graph `K_2`\n(such a homomorphism would be an injection `Fin 3 ↪ Fin 2`). So the lower bound `1/8`\nstrictly exceeds the true value `0`.\n\nMore generally, any `H` containing an odd cycle fails Sidorenko's inequality against a\nsuitable bipartite `G`, since then `t(H, G) = 0 < t(K_2, G)^{e(H)}`.\n-/\n@[category research solved, AMS 5]\ntheorem sidorenko_conjecture.variants.non_bipartite_necessary :\n    homDensity (completeGraph (Fin 3)) (completeGraph (Fin 2)) <\n      homDensity (completeGraph (Fin 2)) (completeGraph (Fin 2)) ^\n        ((completeGraph (Fin 3)).edgeFinset.card) := by\n  -- `e(K_3) = 3`.\n  have hK3edges : (completeGraph (Fin 3)).edgeFinset.card = 3 := by\n    rw [SimpleGraph.card_edgeFinset_completeGraph_fin]; decide\n  -- `t(K_2, K_2) = homCount(K_2, K_2) / 2^2 = 2 / 4 = 1/2`.\n  have hRHSbase : homDensity (completeGraph (Fin 2)) (completeGraph (Fin 2)) = 1 / 2 := by\n    unfold homDensity\n    rw [homCount_completeGraph_fin_two_eq_two_mul_card_edgeFinset,\n      SimpleGraph.card_edgeFinset_completeGraph_fin]\n    simp only [Fintype.card_fin, Nat.choose_self]\n    norm_num\n  -- `t(K_3, K_2) = 0`: there is no homomorphism `K_3 →g K_2`.\n  have hLHS : homDensity (completeGraph (Fin 3)) (completeGraph (Fin 2)) = 0 := by\n    have hempty : IsEmpty (completeGraph (Fin 3) →g completeGraph (Fin 2)) := by\n      refine ⟨fun f => ?_⟩\n      -- Any homomorphism into a complete graph is injective on adjacent (i.e. distinct) vertices.\n      have hinj : Function.Injective (f : Fin 3 → Fin 2) := by\n        intro a b hab\n        by_contra hne\n        have hadj : (completeGraph (Fin 3)).Adj a b := by\n          rw [completeGraph_eq_top, top_adj]; exact hne\n        have hadj' : (completeGraph (Fin 2)).Adj (f a) (f b) := f.map_adj hadj\n        exact hadj'.ne hab\n      have hle := Fintype.card_le_of_injective _ hinj\n      simp only [Fintype.card_fin] at hle\n      omega\n    have hcount : homCount (completeGraph (Fin 3)) (completeGraph (Fin 2)) = 0 := by\n      have := hempty\n      simp [homCount]\n    unfold homDensity\n    rw [hcount]\n    simp\n  rw [hLHS, hK3edges, hRHSbase]\n  norm_num\n\nend SidorenkoConjecture\n",
  "statement_hash": "53f97833a68b309627755d494f95dec3369204ac51b79f4dd363ad47d1ff93e9",
  "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."
}