Mathlib theorem · Existing formal mathematics

Existing in Mathlib · Combinatorics

Hall's Marriage Theorem

Suppose each index i is assigned a finite set t i. One can choose an element f i from every t i with no two indices choosing the same element exactly when, for every finite collection of indices, the union of their assigned sets has at least as many elements as that collection.

Exact theorem

Exact Mathlib statement

theorem Finset.all_card_le_biUnion_card_iff_exists_injective {ι : Type u} {α : Type v} [DecidableEq α] (t : ι → Finset α) : (∀ s : Finset ι, s.card ≤ (s.biUnion t).card) ↔ ∃ f : ι → α, Function.Injective f ∧ ∀ x : ι, f x ∈ t x

The theorem at a glance

Hall's Marriage Theorem at a glance

A visual guide to the theorem's hypotheses, structure, and conclusion; the exact statement gives the formal detail.

Every finite-subfamily union condition is shown equivalent to a total injective representative function, without implying surjectivity onto the target type. Explanatory diagram.
Detailed visual description

The left side selects a finite subfamily of indexed Finsets, forms its union, and compares the two cardinalities. The right side highlights one distinct allowed representative per index while many elements of alpha remain unused. A lower strip names all five scope ingredients before an injective-not-onto footer.

Statement structure

From hypotheses to conclusion

Statement map for Hall's Marriage TheoremA family of finite sets has distinct representatives exactly when every finite subfamily has a union at least as large as the subfamily. The pinned upstream declaration is Finset.all_card_le_biUnion_card_iff_exists_injective. The exact checked statement is theorem Finset.all_card_le_biUnion_card_iff_exists_injective {ι : Type u} {α : Type v} [DecidableEq α] (t : ι → Finset α) : (∀ s : Finset ι, s.card ≤ (s.biUnion t).card) ↔ ∃ f : ι → α, Function.Injective f ∧ ∀ x : ι, f x ∈ t x.Mathematical readingA family of finite setshas distinctrepresentatives exactlywhen every finitesubfamily has a union atleast as large as thesubfamily.Pinned declarationmathlib ·Finset.all_card_le_biUnion_card_iff_exists_injectiveExact checked formtheoremFinset.all_card_le_biUnion_card_iff_exists_injective{ι : Type u} {α : Typev} [DecidableEq α] (t :ι → Finset α) : (∀ s :Finset ι, s.card ≤(s.biUnion t).card) ↔ ∃f : ι → α,Function.Injective f ∧ ∀x : ι, f x ∈ t xStatement map for Hall's Marriage TheoremA family of finite sets has distinct representatives exactly when every finite subfamily has a union at least as large as the subfamily. The pinned upstream declaration is Finset.all_card_le_biUnion_card_iff_exists_injective. The exact checked statement is theorem Finset.all_card_le_biUnion_card_iff_exists_injective {ι : Type u} {α : Type v} [DecidableEq α] (t : ι → Finset α) : (∀ s : Finset ι, s.card ≤ (s.biUnion t).card) ↔ ∃ f : ι → α, Function.Injective f ∧ ∀ x : ι, f x ∈ t x.Mathematical readingA family of finite setshas distinctrepresentatives exactlywhen every finitesubfamily has a union atleast as large as thesubfamily.Pinned declarationmathlib ·Finset.all_card_le_biUnion_card_iff_exists_injectiveExact checked formtheoremFinset.all_card_le_biUnion_card_iff_exists_injective{ι : Type u} {α : Typev} [DecidableEq α] (t :ι → Finset α) : (∀ s :Finset ι, s.card ≤(s.biUnion t).card) ↔ ∃f : ι → α,Function.Injective f ∧ ∀x : ι, f x ∈ t x

This map summarizes the statement's structure; the exact Mathlib declaration remains authoritative.

Five indexed sets receive distinct representatives; two available right-side values remain unused. Explanatory scientific diagram.
Detailed visual description

Five emerald vertices on the left each send one luminous gold edge to a different ivory vertex on the right. Seven ivory vertices are available in total, and two remain unmatched; thin candidate edges and cobalt neighborhood contours show the wider choice system without implying surjectivity.

Why it matters

A mathematical landmark

Hall's theorem characterizes when a perfect system of distinct representatives exists. It is a cornerstone of matching theory and finite combinatorics; Mathlib's selected statement allows an arbitrary index type while testing every finite subfamily.

Proof architecture

From finite matchings to one global choice

5 curated stages

Mathlib's arbitrary-index Hall theorem builds finite local matching spaces, organizes their restrictions into an inverse system, uses compactness to select a coherent section, extracts a global injective representative function, and proves the converse by cardinality comparison.

These source-anchored stages explain the retained Mathlib proof route. They are generated explanations, not proof evidence or an extracted Lean proof-term dependency graph.

  1. Build finite local matchings

    Every finite subfamily has a finite, nonempty space of injective representative choices.

    Nonempty (hallMatchingsOn t ι') ∧ Finite (hallMatchingsOn t ι')

    For a finite index set ι', hallMatchingsOn stores functions into α that are injective and choose inside each assigned finite set. The Hall inequality feeds the finite theorem to prove nonemptiness, while encoding a matching into the finite union proves that this local matching space is finite.

  2. Restrict larger matchings

    A matching on a larger finite subfamily restricts to the same choices on every smaller one.

    hallMatchingsOn t ι'' → hallMatchingsOn t ι'

    hallMatchingsOn.restrict precomposes a larger local matching with the subset inclusion and retains injectivity and membership. hallMatchingsFunctor uses exactly these restriction maps, reversing inclusions through the opposite category.

  3. Choose a coherent section

    Compatible matchings on arbitrary finite subfamilies assemble into one global choice.

    obtain ⟨u, hu⟩ := nonempty_sections_of_finite_inverse_system ...

    The figure shows the compactness stage of Mathlib’s arbitrary-index Finset form of Hall’s marriage theorem. Several nested finite-subfamily matching cards appear in two compatible towers. Every restriction arrow points upward from a larger finite subfamily to a smaller one, aligned choices agree across the two towers, and dashed paths feed the coherent local family into one representative function. The lowest cards continue the inverse system without identifying any finite subfamily with the arbitrary index type.

  4. Read off the global injective choice

    Singleton values form the global choice, while pairwise coherence forces those choices to be injective.

    ∃ f, Function.Injective f ∧ ∀ i, f i ∈ t i

    The function takes i from the coherent matching on the singleton containing i. For i and i', hu compares both singleton choices with the matching on their pair, whose injectivity proves equality of values can only come from equality of indices. The singleton matching also proves f i belongs to t i.

  5. Recover the Hall inequalities

    Any injective representative choice sends each finite subfamily into its allowed union, so cardinalities satisfy Hall's condition.

    (∀ s, #s ≤ #(s.biUnion t)) ↔ ∃ f, Function.Injective f ∧ ∀ i, f i ∈ t i

    Injectivity rewrites the size of s as the size of s.image f. Membership of every representative places that image inside s.biUnion t, and card_le_card gives the desired inequality. This closes the reverse implication and therefore the exact equivalence.

ProofAtlas record

What has been checked

Upstream indexedPinned source bytes verified locally
Locally reproducedExact upstream declaration replayed
Reviewed pageCurrent public presentation reviewed
Accepted Atlas resultNot recorded for the preferred artifact

Mathlib is the source of the theorem; the local Lean replay and page review are separate.

Claim boundary

No new theorem is claimed

This is Mathlib's indexed-Finset equivalence. It concerns finite member sets t i, checks every finite subfamily s, and concludes the existence of an injective representative function; the page does not substitute a different graph-theoretic formulation.

Source and local evidence

Where the theorem comes from

Existing declaration
Finset.all_card_le_biUnion_card_iff_exists_injective in mathlib
Relationship
The checked artifact is the upstream declaration itself
Local Lean evidence
artifact.library.mathlib.hall-marriage-theorem.v001
Source
Open the pinned upstream reference