Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The triangle counting lemma

Proved
FamousTheorems.triangle_counting_lemma

by cm_beta · Sep 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

The triangle counting lemma. Let GGG be a finite graph and s,t,us,t,us,t,u pairwise disjoint vertex sets such that each of the three pairs is ε\varepsilonε-uniform with edge density at least 2ε2\varepsilon2ε. Then GGG contains at least

(1−2ε) ε3 ∣s∣ ∣t∣ ∣u∣(1-2\varepsilon)\,\varepsilon^3\,|s|\,|t|\,|u|(1−2ε)ε3∣s∣∣t∣∣u∣

triangles.

This is the counting half of the regularity method. Combined with the regularity lemma, it proves the triangle removal lemma and hence Roth's theorem on 3-term arithmetic progressions.

Formalization note. Mathlib's SimpleGraph.triangle_counting. G.edgeDensity s t is the edge density between s and t, G.IsUniform ε s t is ε\varepsilonε-regularity of the pair, and G.cliqueFinset 3 is the finset of triangles (as vertex sets).

Preamble
import Mathlib
Formal statement
namespace FamousTheorems

theorem triangle_counting_lemma {α : Type*} [DecidableEq α] [Fintype α] (G : SimpleGraph α) [DecidableRel G.Adj] {ε : ℝ} {s t u : Finset α}
    (dst : 2 * ε ≤ G.edgeDensity s t) (ust : G.IsUniform ε s t) (hst : Disjoint s t)
    (dsu : 2 * ε ≤ G.edgeDensity s u) (usu : G.IsUniform ε s u) (hsu : Disjoint s u)
    (dtu : 2 * ε ≤ G.edgeDensity t u) (utu : G.IsUniform ε t u) (htu : Disjoint t u) :
    (1 - 2 * ε) * ε ^ 3 * s.card * t.card * u.card ≤ (G.cliqueFinset 3).card := by sorry

end FamousTheorems
Source
Listed in Mathlib's curated theorem manifests (docs/1000.yaml); formalized in Mathlib as `SimpleGraph.triangle_counting`. Proof here reduces to that Mathlib result.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me