Finite hypergraphs: uniformity, partiteness, cover number, matching number, and Ryser's inequality
DefinitionTenChallenges_HypergraphThe definitions behind Challenge 8 of the Ten Challenges benchmark.
- Finite hypergraph. A structure with a finite set of vertices and a set of edges, each edge a finite subset of the vertices.
- Uniform, partite. is -uniform if every edge has exactly elements; it is -partite if there are parts , pairwise disjoint, whose union is the vertex set, such that every edge meets every part in exactly one vertex.
- Covers and matchings. A vertex cover is a subset of the vertices meeting every edge; a matching is a finite set of edges that are pairwise disjoint.
- Cover and matching numbers. is the least cardinality of a vertex cover and the largest cardinality of a matching, as natural numbers.
- Ryser's inequality at . says: if is -uniform and -partite then
Formalization Note. is sInf of the set of sizes of covers and is sSup of the set of sizes of matchings in , with and of an unbounded set by convention; edges form a Set (Finset α), necessarily finite. The vertex type carries decidable equality.
import Mathlib.Order.Lattice.Nat
/-- A finite hypergraph with edges contained in its vertex set. -/
structure FinHypergraph (α : Type*) where
vertices : Finset α
edges : Set (Finset α)
edges_subset_vertices : ∀ e ∈ edges, e ⊆ vertices
variable {V : Type*} [DecidableEq V] (H : FinHypergraph V)
namespace FinHypergraph
/-- An `r`-uniform hypergraph has every edge of cardinality `r`. -/
def IsUniform (r : ℕ) : Prop :=
∀ e ∈ H.edges, e.card = r
/-- An `r`-partite hypergraph has its vertices partitioned into `r` parts, and
every edge meets every part in exactly one vertex. -/
def IsPartite (r : ℕ) : Prop :=
∃ parts : Fin r → Finset V,
(∀ v : V, v ∈ H.vertices ↔ ∃ i : Fin r, v ∈ parts i) ∧
(∀ i j : Fin r, i ≠ j → Disjoint (parts i) (parts j)) ∧
(∀ e ∈ H.edges, ∀ i : Fin r, (parts i ∩ e).card = 1)
/-- A vertex cover is a set of vertices meeting every edge. -/
def IsVertexCover (C : Finset V) : Prop :=
C ⊆ H.vertices ∧ ∀ e ∈ H.edges, ∃ v ∈ C, v ∈ e
/-- A matching is a finite set of pairwise disjoint edges. -/
def IsMatching (M : Finset (Finset V)) : Prop :=
(∀ e ∈ M, e ∈ H.edges) ∧
∀ e₁ ∈ M, ∀ e₂ ∈ M, e₁ ≠ e₂ → Disjoint e₁ e₂
/-- The cover number `τ(H)`: the least cardinality of a vertex cover, as an
`sInf` over the achievable cover cardinalities (`0` if no cover exists). -/
noncomputable def coverNumber : ℕ :=
sInf {n | ∃ C : Finset V, H.IsVertexCover C ∧ C.card = n}
/-- The matching number `ν(H)`: the largest size of a matching, as an `sSup`
over the achievable matching sizes. -/
noncomputable def matchingNumber : ℕ :=
sSup {n | ∃ M : Finset (Finset V), H.IsMatching M ∧ M.card = n}
/-- Ryser's hypergraph conjecture for a fixed value of `r`. -/
def RyserConjectureFor (r : ℕ) : Prop :=
H.IsUniform r → H.IsPartite r → H.coverNumber ≤ (r - 1) * H.matchingNumber
end FinHypergraph
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Preamble. The file imports only Mathlib's lattice structure on (needed for the infimum/supremum of sets of natural numbers below). It declares one structure, FinHypergraph, and seven definitions in its namespace. After the structure, every definition is made in the context of a fixed type (in an arbitrary universe) that is assumed to carry a decidable equality (a typeclass assumption carried silently as an argument by each definition; it has no mathematical content, it is only what makes finite-set intersections well-defined) and a fixed finite hypergraph on .
The structure FinHypergraph. For any type (in any universe; no decidable-equality or other assumption on ), a finite hypergraph on consists of exactly three pieces of data: (i) a finite set , called the vertices; (ii) a set whose members are finite subsets of , called the edges — note that is an arbitrary set of finite subsets, not itself packaged as a finite set, although it is necessarily finite because of (iii); (iii) a proof that every edge is contained in the vertex set: for all , . Nothing else is required: may be empty; may be empty; the empty set may be an edge; singletons may be edges; edges may have different sizes and may be nested in one another. Since is a set, there are no repeated edges.
-uniform (IsUniform). For a natural number (including ), is -uniform iff every edge has exactly elements:
Edge cases: if , then is -uniform for every simultaneously. is -uniform iff every edge is the empty set, i.e. .
-partite (IsPartite). For a natural number , is -partite iff there exists a family of finite subsets , indexed by , such that all three of the following hold:
- for every : if and only if for some index — equivalently ;
- for all indices , ;
- for every edge and every index , (the edge meets each part in exactly one vertex).
Notes on what is not required: the parts are not required to be nonempty — if some , condition 3 forces , and the hypergraph is still -partite. The family is not required to be unique. For the index set is empty, so there is exactly one candidate family (the empty family); condition 1 then says that no lies in , i.e. , and conditions 2 and 3 hold vacuously; hence is -partite iff it has no vertices. If , condition 3 holds vacuously. If and , condition 3 fails, so such an is not -partite.
Vertex cover (IsVertexCover). A finite set is a vertex cover of iff and every edge contains some element of :
Edge cases: if , then every subset of , in particular , is a vertex cover. If , no vertex cover exists at all. If no edge is empty, itself is a vertex cover.
Matching (IsMatching). A finite set of finite subsets of is a matching of iff every member of is an edge of and any two distinct members are disjoint:
Edge cases: is always a matching; any single edge with is a matching; if , the empty edge may be a member of any matching, since it is disjoint from everything. Because is a set, an edge occurs in at most once.
Cover number (coverNumber). is the natural number
where is Mathlib's infimum of a set of natural numbers: the least element of the set if the set is nonempty, and by convention if the set is empty. Hence: if at least one vertex cover exists, is the minimum cardinality of a vertex cover; if no vertex cover exists (exactly when ), as a junk value. Also when (the empty set is then a cover). So does not by itself distinguish "no edges" from "the empty edge is present".
Matching number (matchingNumber). is the natural number
where is Mathlib's supremum of a set of natural numbers: the least upper bound of the set if it is bounded above, and by convention if it is unbounded. The set here always contains (the empty matching) and is always bounded above, because every matching is a set of subsets of the finite set , so ; consequently is the maximum number of (distinct, pairwise disjoint) edges in a matching of . In particular iff , and if the empty edge contributes at most to .
Ryser's inequality for a fixed (RyserConjectureFor). For a natural number , the proposition
where is truncated natural-number subtraction: it equals when and when . The two hypotheses are premises of an implication (so the proposition is true whenever fails to be -uniform or fails to be -partite), the inequality is non-strict (), and the multiplication is in . For and for the right-hand side is , so in those cases the conclusion is . No lower bound on and no nonemptiness of or is imposed in this definition.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.