Homomorphism density, Sidorenko's inequality, bipartite graphs with bounded sides
DefinitionTenChallenges_SidorenkoThe definitions behind Challenge 4 of the Ten Challenges benchmark, for simple graphs on a finite vertex type and on a finite vertex type .
- Homomorphism density. is the number of maps such that is an edge of whenever is an edge of , divided by , as a real number.
- Sidorenko's inequality for in :
where is the complete graph on two vertices, so that is the edge density , and is the number of edges of . 3. Bipartite with sides bounded by . admits sets of vertices with , and disjoint, every edge of joining to , and .
These definitions express Sidorenko's conjecture and its restriction to bipartite graphs of bounded size; the density is reusable for any subgraph-counting statement.
Formalization Note. The count of homomorphisms is Nat.card of a subtype of functions; the bipartition uses Mathlib's IsBipartiteWith and the sizes are Set.ncard. When the density is by the convention for division by zero.
import Mathlib.Combinatorics.SimpleGraph.Bipartite
import Mathlib.Data.Real.Basic
open SimpleGraph
variable {W V : Type*} [Fintype W] [Fintype V]
/-- The homomorphism density `t(H, G)`: the number of
graph homomorphisms `H → G`, divided by `|V(G)| ^ |V(H)|`. -/
noncomputable def homDensity (H : SimpleGraph W) (G : SimpleGraph V) : ℝ :=
(Nat.card {f : W → V // ∀ ⦃a b : W⦄, H.Adj a b → G.Adj (f a) (f b)} : ℝ) /
(Fintype.card V : ℝ) ^ Fintype.card W
/-- Sidorenko's inequality for a graph `H` over `G`,
in normalized homomorphism-density form: `t(H, G) ≥ t(K₂, G) ^ e(H)`. -/
def SidorenkoFor (H : SimpleGraph W) (G : SimpleGraph V) : Prop :=
homDensity H G ≥ homDensity (completeGraph (Fin 2)) G ^ Nat.card H.edgeSet
/-- `H` is *bipartite with sides bounded by `k`*: it admits
a bipartition `V(H) = X ∪ Y`, with `|X| ≤ k` and `|Y| ≤ k`. -/
def BipartiteBoundedBy (H : SimpleGraph W) (k : ℕ) : Prop :=
∃ X Y : Set W,
H.IsBipartiteWith X Y ∧ X ∪ Y = Set.univ ∧ X.ncard ≤ k ∧ Y.ncard ≤ k
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Conventions used throughout this file. A simple graph on a type of vertices is a symmetric and irreflexive adjacency relation (undirected, no loops, no multiple edges). denotes the cardinality of a set as a natural number. The file contains three definitions; their vertex types live in arbitrary universes, and their finiteness assumptions differ, so each is listed separately below.
Definition 1: homDensity, written . Parameters: a vertex type and a vertex type , each equipped with a finiteness structure (so both are finite sets of vertices); a simple graph on ; a simple graph on . The value is the real number
The numerator counts all functions from to (not required to be injective or surjective) such that every pair of -adjacent vertices is sent to a pair of -adjacent vertices (graph homomorphisms ); because has no loops, a function that sends two -adjacent vertices to the same vertex is not counted. The count is formed as a natural number (with the convention that an infinite set counts as ; this does not arise, since and are finite) and then cast to a real. The denominator is the real number raised to the natural-number power . Edge cases the definition silently includes, using the conventions that real division by yields and that : (i) if , there is exactly one function (the empty map), the condition holds vacuously, the denominator is , and — this holds even when (as ); (ii) if and , there are no functions, the denominator is , and ; (iii) if has no edges and , every function is counted and .
Definition 2: SidorenkoFor . Parameters: as in Definition 1 ( and finite, a simple graph on , a simple graph on ). It is the proposition, about these two specific graphs (nothing is quantified),
where: is the complete graph on the two-element vertex set (its two distinct vertices are adjacent, and nothing else); is the density of Definition 1 with , i.e. the number of maps with divided by — equivalently, the number of ordered pairs with (which is twice the number of edges of ) divided by , and equal to when ; and is the number of edges of , i.e. the number of unordered pairs with , as a natural number (an infinite edge set would count as , which does not arise because is finite). The exponent is a natural-number power of a real, so when the right-hand side equals regardless of (even when ). The inequality is non-strict ().
Definition 3: BipartiteBoundedBy . Parameters: a vertex type with no finiteness assumption (this is the one definition in the file whose signature carries none); a simple graph on ; a natural number . It is the proposition: there exist subsets such that
- and are disjoint, ;
- for all : if then ( and ) or ( and );
- (every vertex lies in or in );
- and .
The first two bullets are exactly Mathlib's " is bipartite with parts and "; the third adds that the two parts cover all of . Here and are set cardinalities as natural numbers with the convention that an infinite set has cardinality . Consequently, when is infinite an infinite part satisfies its bound automatically, for every including ; when is finite the cardinalities are the true ones. Nothing requires or to be nonempty, nothing requires to have any edges (an edgeless graph satisfies the adjacency condition for any disjoint cover ), and a vertex with no neighbours may be placed on either side. For finite and the conditions force .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.