Out-degree, directed cycles and the Caccetta–Häggkvist statement at out-degree
DefinitionTenChallenges_CaccettaHaggkvistThe definitions behind Challenge 3 of the Ten Challenges benchmark, on top of Mathlib's Digraph V (an arbitrary binary relation on the vertex type ).
- Out-degree. For a digraph on and a vertex , is the number of vertices with an arc (the cardinality of the set of out-neighbours, if that set is infinite).
- Directed cycles. has a cycle of length if there is an injective map such that is an arc for every , with closing the cycle.
- The statement at out-degree . says: if , then for every finite nonempty vertex type (in the lowest universe) and every digraph on without loops in which every vertex has out-degree at least , there is some with
such that has a cycle of length . The inequality says exactly .
Formalization Note. Loops are excluded by hypothesis; arcs in both directions between two vertices are allowed, and a -cycle counts as a cycle. The cyclic successor on is finRotate ℓ.
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 ℓ
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
This file introduces three definitions. Throughout, a digraph on a vertex type is Mathlib's notion: nothing more than a binary relation on , where reads "there is an arc from to ". No axiom is imposed on this relation: loops are permitted, arcs in both directions between two vertices are permitted, and is not required to be finite.
Definition 1 (out-degree). For every type (in any universe), every digraph on and every vertex , the out-degree of is the natural number
where 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 when the set is infinite. Hence a vertex with infinitely many out-neighbours has out-degree . If holds, then is counted among its own out-neighbours. No hypothesis on or is needed for this definition.
Definition 2 (having a cycle of a given length). For every type (in any universe), every digraph on and every natural number (including ), the proposition asserts:
there exists a function which is injective (the values are pairwise distinct) and such that for every index the arc is present, where is the cyclic shift of the index set: for and (i.e. ; for the shift is the identity).
For this says: contains pairwise distinct vertices with the arcs , each in the stated direction. Nothing is required about the absence of further arcs among these vertices (chords, reverse arcs); only the listed arcs must exist. Edge cases, exactly as the definition stands:
- : the index set is empty, the empty function is injective and the arc condition is vacuous, so is true for every digraph, even one with no vertices.
- : the shift is the identity, so the condition is "there is a vertex with a loop ".
- : two distinct vertices with both and .
- If has fewer than elements, no injective exists and the proposition is false.
Definition 3 (the conjecture at a given minimum out-degree). For every natural number , (the file's CaccettaHaggkvistFor r) is the following proposition:
If , then: for every type in the lowest type universe, every finiteness structure on (so is a finite type), every witness that is nonempty, and every digraph on , if
- is loopless, i.e. for every vertex , , and
- for every vertex , (out-degree as in Definition 1),
then there exists a natural number with
where is the number of elements of the finite type , 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 the antecedent is false, so is true unconditionally.
- For and natural , the condition is equivalent to , i.e. to .
- Since 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 of does not arise. Since is loopless, every out-degree is at most ; thus if no digraph on satisfies hypothesis 2 and the implication holds vacuously for that . (Correspondingly, together with forces .)
- The requirement excludes from the conclusion the always-true case and the loop case of Definition 2; the asserted cycle must consist of at least two distinct vertices. (Loops are in any case ruled out by hypothesis 1.)
- ranges only over types in the lowest universe, and 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 "simple": for distinct both arcs and may be present, and such a pair is by Definition 2 a cycle of length .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.