Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Out-degree, directed cycles and the Caccetta–Häggkvist statement at out-degree rrr

Definition
TenChallenges_CaccettaHaggkvist

by utkuokur · Nov 4, 2026 · Mathlib 0df444a (Lean v4.33.1)

caccetta-haggkvistcombinatoricscyclesdigraphs

The definitions behind Challenge 3 of the Ten Challenges benchmark, on top of Mathlib's Digraph V (an arbitrary binary relation on the vertex type VVV).

  1. Out-degree. For a digraph GGG on VVV and a vertex vvv, d+(v)d^+(v)d+(v) is the number of vertices www with an arc v→wv\to wv→w (the cardinality of the set of out-neighbours, 000 if that set is infinite).
  2. Directed cycles. GGG has a cycle of length ℓ\ellℓ if there is an injective map f ⁣:{0,…,ℓ−1}→Vf\colon\{0,\dots,\ell-1\}\to Vf:{0,…,ℓ−1}→V such that f(i)→f(i+1)f(i)\to f(i+1)f(i)→f(i+1) is an arc for every iii, with f(ℓ−1)→f(0)f(\ell-1)\to f(0)f(ℓ−1)→f(0) closing the cycle.
  3. The statement at out-degree rrr. CaccettaHaggkvistFor(r)\mathrm{CaccettaHaggkvistFor}(r)CaccettaHaggkvistFor(r) says: if r>0r>0r>0, then for every finite nonempty vertex type VVV (in the lowest universe) and every digraph GGG on VVV without loops in which every vertex has out-degree at least rrr, there is some ℓ≥2\ell\ge 2ℓ≥2 with
ℓ⋅r<∣V∣+r\ell\cdot r < |V| + rℓ⋅r<∣V∣+r

such that GGG has a cycle of length ℓ\ellℓ. The inequality says exactly ℓ≤⌈∣V∣/r⌉\ell\le\lceil |V|/r\rceilℓ≤⌈∣V∣/r⌉.

Formalization Note. Loops are excluded by hypothesis; arcs in both directions between two vertices are allowed, and a 222-cycle counts as a cycle. The cyclic successor on Fin ℓ\mathrm{Fin}\,\ellFinℓ is finRotate ℓ.

Definition code
import Mathlib.Combinatorics.Digraph.Basic
import Mathlib.Data.Set.Card
import Mathlib.Logic.Equiv.Fin.Rotate

namespace Digraph

variable {V : Type*} (G : Digraph V)

/-- The out-degree of `v`: the number of out-neighbours of `v`. -/
noncomputable def outDegree (v : V) : ℕ := {w | G.Adj v w}.ncard

/-- A directed cycle of length `ℓ`: `ℓ` distinct vertices, each joined by an arc
to the next one, cyclically. -/
def HasCycleOfLength (ℓ : ℕ) : Prop :=
  ∃ f : Fin ℓ → V, Function.Injective f ∧ ∀ i, G.Adj (f i) (f (finRotate ℓ i))

end Digraph

/-- The Caccetta–Häggkvist conjecture at minimum out-degree `r`: every loopless
digraph on `n ≥ 1` vertices in which every vertex has out-degree at least `r` has
a directed cycle of length at most `⌈n / r⌉`, i.e. of some length `ℓ` with
`ℓ * r < n + r`. -/
def CaccettaHaggkvistFor (r : ℕ) : Prop :=
  0 < r → ∀ {V : Type} [Fintype V] [Nonempty V] (G : Digraph V),
    (∀ v, ¬ G.Adj v v) → (∀ v, r ≤ G.outDegree v) →
      ∃ ℓ, 2 ≤ ℓ ∧ ℓ * r < Fintype.card V + r ∧ G.HasCycleOfLength ℓ
Source
Ten Challenges repository, file Defs_and_Lems/CaccettaHaggkvist.lean (commit ff14a56), https://github.com/TenChallenges/ten-challenges/blob/main/Defs_and_Lems/CaccettaHaggkvist.lean; conjecture as in L. Caccetta, R. Häggkvist, On minimal digraphs with given girth, 1978.
Read-back

What the Lean code literally says, in plain math · claude-fable-5-1

This file introduces three definitions. Throughout, a digraph GGG on a vertex type VVV is Mathlib's notion: nothing more than a binary relation AdjG\mathrm{Adj}_GAdjG​ on VVV, where AdjG(v,w)\mathrm{Adj}_G(v,w)AdjG​(v,w) reads "there is an arc from vvv to www". No axiom is imposed on this relation: loops AdjG(v,v)\mathrm{Adj}_G(v,v)AdjG​(v,v) are permitted, arcs in both directions between two vertices are permitted, and VVV is not required to be finite.

Definition 1 (out-degree). For every type VVV (in any universe), every digraph GGG on VVV and every vertex v∈Vv \in Vv∈V, the out-degree of vvv is the natural number

outDeg⁡G(v)  =  ncard⁡{ w∈V∣AdjG(v,w) },\operatorname{outDeg}_G(v) \;=\; \operatorname{ncard}\{\, w \in V \mid \mathrm{Adj}_G(v,w) \,\},outDegG​(v)=ncard{w∈V∣AdjG​(v,w)},

where ncard⁡\operatorname{ncard}ncard is Mathlib's natural-number cardinality of a set: it is the number of elements when the set is finite, and it takes the junk value 000 when the set is infinite. Hence a vertex with infinitely many out-neighbours has out-degree 000. If AdjG(v,v)\mathrm{Adj}_G(v,v)AdjG​(v,v) holds, then vvv is counted among its own out-neighbours. No hypothesis on GGG or VVV is needed for this definition.

Definition 2 (having a cycle of a given length). For every type VVV (in any universe), every digraph GGG on VVV and every natural number ℓ\ellℓ (including ℓ=0\ell = 0ℓ=0), the proposition HasCycle⁡G(ℓ)\operatorname{HasCycle}_G(\ell)HasCycleG​(ℓ) asserts:

there exists a function f:{0,1,…,ℓ−1}→Vf : \{0, 1, \dots, \ell-1\} \to Vf:{0,1,…,ℓ−1}→V which is injective (the ℓ\ellℓ values f0,…,fℓ−1f_0, \dots, f_{\ell-1}f0​,…,fℓ−1​ are pairwise distinct) and such that for every index i∈{0,…,ℓ−1}i \in \{0, \dots, \ell-1\}i∈{0,…,ℓ−1} the arc AdjG(fi, fρ(i))\mathrm{Adj}_G\big(f_i,\, f_{\rho(i)}\big)AdjG​(fi​,fρ(i)​) is present, where ρ\rhoρ is the cyclic shift of the index set: ρ(i)=i+1\rho(i) = i+1ρ(i)=i+1 for i<ℓ−1i < \ell - 1i<ℓ−1 and ρ(ℓ−1)=0\rho(\ell - 1) = 0ρ(ℓ−1)=0 (i.e. ρ(i)=i+1 mod ℓ\rho(i) = i + 1 \bmod \ellρ(i)=i+1modℓ; for ℓ≤1\ell \le 1ℓ≤1 the shift is the identity).

For ℓ≥2\ell \ge 2ℓ≥2 this says: GGG contains ℓ\ellℓ pairwise distinct vertices v0,v1,…,vℓ−1v_0, v_1, \dots, v_{\ell-1}v0​,v1​,…,vℓ−1​ with the arcs v0→v1→⋯→vℓ−1→v0v_0 \to v_1 \to \cdots \to v_{\ell-1} \to v_0v0​→v1​→⋯→vℓ−1​→v0​, each in the stated direction. Nothing is required about the absence of further arcs among these vertices (chords, reverse arcs); only the ℓ\ellℓ listed arcs must exist. Edge cases, exactly as the definition stands:

  • ℓ=0\ell = 0ℓ=0: the index set is empty, the empty function is injective and the arc condition is vacuous, so HasCycle⁡G(0)\operatorname{HasCycle}_G(0)HasCycleG​(0) is true for every digraph, even one with no vertices.
  • ℓ=1\ell = 1ℓ=1: the shift is the identity, so the condition is "there is a vertex v0v_0v0​ with a loop AdjG(v0,v0)\mathrm{Adj}_G(v_0, v_0)AdjG​(v0​,v0​)".
  • ℓ=2\ell = 2ℓ=2: two distinct vertices v0≠v1v_0 \neq v_1v0​=v1​ with both AdjG(v0,v1)\mathrm{Adj}_G(v_0, v_1)AdjG​(v0​,v1​) and AdjG(v1,v0)\mathrm{Adj}_G(v_1, v_0)AdjG​(v1​,v0​).
  • If VVV has fewer than ℓ\ellℓ elements, no injective fff exists and the proposition is false.

Definition 3 (the conjecture at a given minimum out-degree). For every natural number rrr, CH⁡(r)\operatorname{CH}(r)CH(r) (the file's CaccettaHaggkvistFor r) is the following proposition:

If 0<r0 < r0<r, then: for every type VVV in the lowest type universe, every finiteness structure on VVV (so VVV is a finite type), every witness that VVV is nonempty, and every digraph GGG on VVV, if

  1. GGG is loopless, i.e. for every vertex vvv, ¬ AdjG(v,v)\neg\, \mathrm{Adj}_G(v,v)¬AdjG​(v,v), and
  2. for every vertex vvv,   r≤outDeg⁡G(v)\; r \le \operatorname{outDeg}_G(v)r≤outDegG​(v) (out-degree as in Definition 1),

then there exists a natural number ℓ\ellℓ with

2≤ℓ,ℓ⋅r  <  ∣V∣+r,andHasCycle⁡G(ℓ),2 \le \ell, \qquad \ell \cdot r \;<\; |V| + r, \qquad \text{and} \qquad \operatorname{HasCycle}_G(\ell),2≤ℓ,ℓ⋅r<∣V∣+r,andHasCycleG​(ℓ),

where ∣V∣|V|∣V∣ is the number of elements of the finite type VVV, and the inequality is between natural numbers built only from multiplication and addition (no truncated subtraction or division occurs).

What the quantifiers silently include:

  • For r=0r = 0r=0 the antecedent 0<r0 < r0<r is false, so CH⁡(0)\operatorname{CH}(0)CH(0) is true unconditionally.
  • For r≥1r \ge 1r≥1 and natural ℓ\ellℓ, the condition ℓr<∣V∣+r\ell r < |V| + rℓr<∣V∣+r is equivalent to (ℓ−1) r<∣V∣(\ell - 1)\, r < |V|(ℓ−1)r<∣V∣, i.e. to ℓ≤⌈∣V∣/r⌉\ell \le \lceil |V| / r \rceilℓ≤⌈∣V∣/r⌉.
  • Since VVV is finite, every out-neighbourhood is finite, so in hypothesis 2 the out-degree is the honest count of out-neighbours and the junk value 000 of ncard⁡\operatorname{ncard}ncard does not arise. Since GGG is loopless, every out-degree is at most ∣V∣−1|V| - 1∣V∣−1; thus if r≥∣V∣r \ge |V|r≥∣V∣ no digraph on VVV satisfies hypothesis 2 and the implication holds vacuously for that VVV. (Correspondingly, 2≤ℓ2 \le \ell2≤ℓ together with ℓr<∣V∣+r\ell r < |V| + rℓr<∣V∣+r forces r<∣V∣r < |V|r<∣V∣.)
  • The requirement 2≤ℓ2 \le \ell2≤ℓ excludes from the conclusion the always-true case ℓ=0\ell = 0ℓ=0 and the loop case ℓ=1\ell = 1ℓ=1 of Definition 2; the asserted cycle must consist of at least two distinct vertices. (Loops are in any case ruled out by hypothesis 1.)
  • VVV ranges only over types in the lowest universe, and ∣V∣≥1|V| \ge 1∣V∣≥1 because of the nonemptiness assumption. The finiteness structure and the nonemptiness witness are universally quantified typeclass arguments.
  • No hypothesis concerns in-degrees, and apart from looplessness nothing makes GGG "simple": for distinct u,wu, wu,w both arcs u→wu \to wu→w and w→uw \to uw→u may be present, and such a pair is by Definition 2 a cycle of length 222.
Human review
  • Endorsed by Shuze Chen · Nov 4, 2026

    Confirmed by the moderator at approval.

  • Endorsed by utkuokur · Nov 4, 2026

    Confirmed by the mission captain (proposal self-audit).

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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me