AFTD Auto-Formalizing Theoretical Domains

op869_disjoint_reserved_copies

theoremverified

If each of q colors occurs in at least qD copies, one can reserve D copies for each color so that reservations for different colors are disjoint.

Statement

theorem op869_disjoint_reserved_copies {α : Type} [DecidableEq α] (q D : ℕ) (S : Fin q → Finset α) :
    (∀ i, q * D ≤ (S i).card) →
    ∃ T : Fin q → Finset α, (∀ i, T i ⊆ S i ∧ (T i).card = D) ∧
      (∀ i j, i ≠ j → Disjoint (T i) (T j))
Source
arXiv:2610.41516, Lemma 2.5: reserve disjoint bipartite copies and orient them for an offline three-coloring.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

The proof, explained

The theorem is proven by reducing the selection of D distinct elements from each of q color sets to Hall's Marriage Theorem. Indexing the selections by the product Fin q × Fin D, Hall's condition holds because any nonempty index subset has size at most q * D, which is bounded by the size of any of the color sets involved, and thus by the size of their union. The resulting injective choice function partitions into q disjoint subsets of size D, each contained in its corresponding color set.

  1. Assume that each of the q color sets has cardinality at least q * D.

    We enable classical logic and introduce the hypothesis `hS`, which states that |S(i)| ≥ q * D for every color index i.

    lines 5–6

      classical
      intro hS
  2. Hall's marriage condition holds: for any subset A ⊆ Fin q × Fin D, |A| ≤ |⋃_{p ∈ A} S(p.1)|.

    We consider an arbitrary subset of indices A. If A is empty, both sides of the inequality are 0. If A is nonempty, it contains some pair (i, d). The size |A| is bounded above by the total number of index pairs |Fin q × Fin D| = q * D, which is at most |S(i)| by the size assumption on S(i). Since (i, d) ∈ A, the set S(i) is included in the union ⋃_{p ∈ A} S(p.1), so |S(i)| ≤ |⋃_{p ∈ A} S(p.1)|. Chaining these inequalities verifies Hall's condition.

    lines 7–18

    uses Finset.card_le_univ, Finset.card_le_card, Finset.subset_biUnion_of_mem, Finset.not_nonempty_iff_eq_empty.mp

      have hHall : ∀ A : Finset (Fin q × Fin D), A.card ≤ (A.biUnion (fun p => S p.1)).card := by
        intro A
        by_cases hA : A.Nonempty
        · obtain ⟨⟨i, d⟩, hid⟩ := hA
          calc
            A.card ≤ Fintype.card (Fin q × Fin D) := Finset.card_le_univ A
            _ = q * D := by simp
            _ ≤ (S i).card := hS i
            _ ≤ (A.biUnion (fun p => S p.1)).card :=
              Finset.card_le_card (Finset.subset_biUnion_of_mem (fun p => S p.1) hid)
        · have hA' : A = ∅ := Finset.not_nonempty_iff_eq_empty.mp hA
          simp [hA']
  3. Hall's Marriage Theorem yields an injective choice function, from which we define the candidate sets T(i).

    Applying Hall's Marriage Theorem (the forward direction of `Finset.all_card_le_biUnion_card_iff_exists_injective`) to our verified condition produces an injective function f : Fin q × Fin D → α such that f(i, d) ∈ S(i) for all (i, d). For each color i, we define T(i) as the image of Fin D under d ↦ f(i, d).

    lines 19–21

    uses Finset.all_card_le_biUnion_card_iff_exists_injective

      obtain ⟨f, hf, hmem⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective (fun p : Fin q × Fin D => S p.1)).mp hHall
      let T : Fin q → Finset α := fun i => Finset.univ.image (fun d : Fin D => f (i, d))
      refine ⟨T, ?_, ?_⟩
  4. Each reserved set T(i) is a subset of S(i).

    Any element a ∈ T(i) is of the form f(i, d) for some d ∈ Fin D. By the choice condition on f, f(i, d) belongs to S(i), proving T(i) ⊆ S(i).

    lines 22–26

    uses Finset.mem_image.mp

      · intro i
        constructor
        · intro a ha
          obtain ⟨d, hd, rfl⟩ := Finset.mem_image.mp ha
          exact hmem (i,d)
  5. Each reserved set T(i) has cardinality D.

    The map d ↦ f(i, d) from Fin D to α is injective because f is injective: if f(i, a) = f(i, b), then (i, a) = (i, b), which implies a = b by projecting onto the second coordinate. Since Fin D has size D and taking the image under an injection preserves cardinality, |T(i)| = D.

    lines 27–30

    uses congrArg, Prod.snd, Finset.card_image_of_injective

        · have hinj : Function.Injective (fun d : Fin D => f (i,d)) := by
            intro a b hab
            exact congrArg Prod.snd (hf hab)
          simp [T, Finset.card_image_of_injective _ hinj]
  6. The sets T(i) and T(j) are disjoint whenever i ≠ j.

    Suppose for contradiction that some element a belongs to both T(i) and T(j). Then a = f(i, d) and a = f(j, e) for some d, e ∈ Fin D. By the injectivity of f, (i, d) = (j, e). Projecting onto the first component gives i = j, contradicting the assumption that i ≠ j.

    lines 31–37

    uses Finset.disjoint_left.mpr, Finset.mem_image.mp, congrArg, Prod.fst

      · intro i j hij
        apply Finset.disjoint_left.mpr
        intro a hai haj
        obtain ⟨d, hd, hda⟩ := Finset.mem_image.mp hai
        obtain ⟨e, he, hea⟩ := Finset.mem_image.mp haj
        have heq : (i, d) = (j, e) := hf (hda.trans hea.symm)
        exact hij (congrArg Prod.fst heq)
Finset.card_le_univ
The cardinality of any finite subset of a finite type is at most the cardinality of the type.
Finset.card_le_card
If s ⊆ t for finite sets s and t, then |s| ≤ |t|.
Finset.subset_biUnion_of_mem
If an element x belongs to an index set s, then u(x) is a subset of the union ⋃_{a ∈ s} u(a).
Finset.not_nonempty_iff_eq_empty.mp
A finite set that is not nonempty is the empty set.
Finset.all_card_le_biUnion_card_iff_exists_injective
Hall's Marriage Theorem for finite sets: an indexed family of sets admits an injective system of distinct representatives if and only if every finite index subset s satisfies |s| ≤ |⋃_{x ∈ s} t(x)|.
Finset.mem_image.mp
An element belongs to the image f(s) if and only if it equals f(x) for some x ∈ s.
congrArg
Applying a function to equal arguments produces equal values.
Prod.snd
The projection from an ordered pair to its second component.
Finset.card_image_of_injective
An injective function preserves the cardinality of any finite set under taking images.
Finset.disjoint_left.mpr
Two finite sets are disjoint if no element of the first belongs to the second.
Prod.fst
The projection from an ordered pair to its first component.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

theorem op869_disjoint_reserved_copies {α : Type} [DecidableEq α] (q D : ℕ) (S : Fin q → Finset α) :    (∀ i, q * D ≤ (S i).card) →    ∃ T : Fin q → Finset α, (∀ i, T i ⊆ S i ∧ (T i).card = D) ∧      (∀ i j, i ≠ j → Disjoint (T i) (T j)) := by  classical  intro hS  have hHall : ∀ A : Finset (Fin q × Fin D), A.card ≤ (A.biUnion (fun p => S p.1)).card := by    intro A    by_cases hA : A.Nonempty    · obtain ⟨⟨i, d⟩, hid⟩ := hA      calc        A.card ≤ Fintype.card (Fin q × Fin D) := Finset.card_le_univ A        _ = q * D := by simp        _ ≤ (S i).card := hS i        _ ≤ (A.biUnion (fun p => S p.1)).card :=          Finset.card_le_card (Finset.subset_biUnion_of_mem (fun p => S p.1) hid)    · have hA' : A = ∅ := Finset.not_nonempty_iff_eq_empty.mp hA      simp [hA']  obtain ⟨f, hf, hmem⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective (fun p : Fin q × Fin D => S p.1)).mp hHall  let T : Fin q → Finset α := fun i => Finset.univ.image (fun d : Fin D => f (i, d))  refine ⟨T, ?_, ?_⟩  · intro i    constructor    · intro a ha      obtain ⟨d, hd, rfl⟩ := Finset.mem_image.mp ha      exact hmem (i,d)    · have hinj : Function.Injective (fun d : Fin D => f (i,d)) := by        intro a b hab        exact congrArg Prod.snd (hf hab)      simp [T, Finset.card_image_of_injective _ hinj]  · intro i j hij    apply Finset.disjoint_left.mpr    intro a hai haj    obtain ⟨d, hd, hda⟩ := Finset.mem_image.mp hai    obtain ⟨e, he, hea⟩ := Finset.mem_image.mp haj    have heq : (i, d) = (j, e) := hf (hda.trans hea.symm)    exact hij (congrArg Prod.fst heq)
See it in the graphDiscuss this resultChallenge it