AFTD Auto-Formalizing Theoretical Domains

op861_palette_surplus_hypergraph_iff

theoremverified

A standard-list coloring whose first selector stays in a prescribed k+r+s-color palette exists exactly when the specified uniform hypergraph coverage and avoidance conditions hold on that palette.

Statement

theorem op861_palette_surplus_hypergraph_iff (k r s : ℕ) (hsmall : r + s < k)
    (U : Finset (Fin (2*k - 1))) (hU : U.card = k + r + s) :
    (∃ f g : {S : Finset (Fin (2*k - 1)) // S.card = k} → Fin (2*k - 1),
      (∀ S, f S ∈ S.1 ∧ f S ∈ U) ∧ (∀ T, g T ∈ T.1) ∧
      ∀ S T, (S.1 ∩ T.1).card ≤ r → f S ≠ g T) ↔
    ∃ H : Fin (2*k - 1) → Finset (Fin (2*k - 1)) → Prop,
      (∀ v Y, H v Y → v ∈ U ∧ Y ⊆ U ∧ Y.card = s + 1 ∧ v ∉ Y) ∧
      (∀ X : Finset (Fin (2*k - 1)), X ⊆ U → X.card = r + s + 1 →
        ∃ v ∈ X, ∀ Y : Finset (Fin (2*k - 1)),
          Y ⊆ X.erase v → Y.card = s + 1 → H v Y) ∧
      (∀ R : Finset (Fin (2*k - 1)), R ⊆ U → R.card = r + s →
        ∃ v ∈ U, v ∉ R ∧ ∀ Y : Finset (Fin (2*k - 1)), H v Y → ¬ Y ⊆ R)
Source
Palette-surplus reduction for the open problem OP-861; finite models checked in experiment 30660.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1

The proof, explained

The theorem establishes an equivalence between the existence of standard-list coloring selectors (f, g) on k-subsets of [2k-1] (where f chooses from a palette U of size k+r+s and f(S) ≠ g(T) whenever |S ∩ T| ≤ r) and a uniform hypergraph relation H(v, Y) on U satisfying coverage on (r+s+1)-subsets and avoidance on (r+s)-subsets. In the forward direction, H(v, Y) is defined by taking v = f(C ∪ X) where C is the complement of U (of size k - r - s - 1) and X is an (r+s+1)-subset containing Y ∪ {v}; avoidance holds because a violating hyperedge would produce an intersection |(C ∪ X) ∩ (U \ R)| ≤ r, contradicting f(S) ≠ g(T). In the reverse direction, f(S) is chosen from S ∩ U via coverage on an (r+s+1)-subset X (available since |S ∩ U| ≥ r+s+1), while g(T) is chosen either outside U or via avoidance on U \ T; separation holds because any collision f(S) = g(T) would leave at least s + 1 elements in X \ T, generating a hyperedge that violates avoidance.

  1. Reduce the equivalence to two implications, and assume in the forward direction the existence of selectors f and g.

    To establish the "if and only if" statement, we split into the forward and reverse directions. In the forward direction (⇒), we assume selectors f, g : {S ⊆ [2k-1] : |S| = k} → [2k-1] such that f(S) ∈ S ∩ U, g(T) ∈ T, and |S ∩ T| ≤ r implies f(S) ≠ g(T). We also activate classical logic for the construction.

    lines 13–15

      constructor
      · rintro ⟨f, g, hf, hg, hproper⟩
        classical
  2. The complement C = [2k-1] \ U has cardinality k - r - s - 1, and for any (r+s+1)-subset X ⊆ U, the disjoint union C ∪ X has cardinality k.

    Because the total universe has size 2k - 1 and U has size k + r + s, the complement C = Finset.univ \ U has size (2k - 1) - (k + r + s) = k - r - s - 1. For any X ⊆ U of size r + s + 1, C and X are disjoint, so |C ∪ X| = |C| + |X| = (k - r - s - 1) + (r + s + 1) = k, making C ∪ X a valid k-element input for f.

    lines 16–29

    uses Finset.card_sdiff_of_subset, Finset.subset_univ, Finset.disjoint_left, Finset.mem_sdiff.mp, Finset.card_union_of_disjoint

        let C : Finset (Fin (2*k - 1)) := Finset.univ \ U
        have h_univ : (Finset.univ : Finset (Fin (2*k - 1))).card = 2 * k - 1 := by simp
        have hC_card : C.card = k - r - s - 1 := by
          dsimp [C]
          rw [Finset.card_sdiff_of_subset (Finset.subset_univ U), h_univ, hU]
          omega
        have hCX_card : ∀ X ⊆ U, X.card = r + s + 1 → (C ∪ X).card = k := by
          intro X hXU hX
          have hdisj : Disjoint C X := by
            rw [Finset.disjoint_left]
            intro x hxC hxX
            exact (Finset.mem_sdiff.mp hxC).2 (hXU hxX)
          rw [Finset.card_union_of_disjoint hdisj, hC_card, hX]
          omega
  3. Define the hypergraph relation H(v, Y) and verify its well-formedness property.

    We define H(v, Y) to hold when v ∈ U, Y ⊆ U, |Y| = s + 1, v ∉ Y, and there exists X ⊆ U of size r + s + 1 such that f(C ∪ X) = v and Y ⊆ X \ {v}. The first condition of the goal (well-formedness: v ∈ U, Y ⊆ U, |Y| = s + 1, and v ∉ Y whenever H(v, Y) holds) is immediate by extracting these conjuncts from the definition of H.

    lines 30–36

        let H : Fin (2*k - 1) → Finset (Fin (2*k - 1)) → Prop := fun v Y =>
          v ∈ U ∧ Y ⊆ U ∧ Y.card = s + 1 ∧ v ∉ Y ∧
            ∃ (X : Finset (Fin (2*k - 1))) (hXU : X ⊆ U) (hXcard : X.card = r + s + 1),
              f ⟨C ∪ X, hCX_card X hXU hXcard⟩ = v ∧ Y ⊆ X.erase v
        refine ⟨H, ?_, ?_, ?_⟩
        · intro v Y h
          exact ⟨h.1, h.2.1, h.2.2.1, h.2.2.2.1⟩
  4. The relation H satisfies the coverage property for all (r+s+1)-subsets of U.

    Given X ⊆ U with |X| = r + s + 1, the set C ∪ X has size k, so let v = f(C ∪ X). By hypothesis, v ∈ (C ∪ X) ∩ U; since C and U are disjoint, v must belong to X. For any Y ⊆ X \ {v} of size s + 1, X itself serves as the required witness in the definition of H(v, Y), confirming coverage.

    lines 37–51

    uses Finset.mem_union.mp, False.elim, Finset.mem_sdiff.mp, Finset.erase_subset, Finset.mem_erase.mp

        · intro X hXU hXcard
          have hcard := hCX_card X hXU hXcard
          let v := f ⟨C ∪ X, hcard⟩
          have hv_in := (hf ⟨C ∪ X, hcard⟩).1
          have hv_U := (hf ⟨C ∪ X, hcard⟩).2
          have hv_X : v ∈ X := by
            rcases Finset.mem_union.mp hv_in with hvC | hvX
            · exact False.elim ((Finset.mem_sdiff.mp hvC).2 hv_U)
            · exact hvX
          refine ⟨v, hv_X, ?_⟩
          intro Y hYX hYcard
          refine ⟨hv_U, ?_, hYcard, ?_, X, hXU, hXcard, rfl, hYX⟩
          · exact hYX.trans ((Finset.erase_subset v X).trans hXU)
          · intro hvY
            exact (Finset.mem_erase.mp (hYX hvY)).1 rfl
  5. The relation H satisfies the avoidance property for all (r+s)-subsets of U.

    Given R ⊆ U of size r + s, the set T = U \ R has size |U| - |R| = (k + r + s) - (r + s) = k. Setting v = g(T) ∈ T, we have v ∈ U \ R. Suppose for contradiction that some Y satisfies H(v, Y) and Y ⊆ R. Then H(v, Y) is witnessed by some X ⊆ U of size r + s + 1 with f(C ∪ X) = v and Y ⊆ X \ {v}. Setting S = C ∪ X, since C is disjoint from T ⊆ U, we have S ∩ T = X ∩ T = X \ R. Furthermore, Y and X \ R are disjoint subsets of X, so |Y| + |S ∩ T| ≤ |X|, which means (s + 1) + |S ∩ T| ≤ r + s + 1, giving |S ∩ T| ≤ r. By the separation property of f and g, this requires f(S) ≠ g(T), contradicting f(S) = v = g(T).

    lines 52–99

    uses Finset.card_sdiff_of_subset, Finset.mem_sdiff.mp, Finset.disjoint_left, Finset.union_inter_distrib_right, Finset.disjoint_iff_inter_eq_empty.mp, Finset.empty_union, Finset.mem_inter, Finset.mem_sdiff, Finset.union_subset, Finset.erase_subset, Finset.sdiff_subset, Finset.card_le_card, Finset.card_union_of_disjoint

        · intro R hRU hRcard
          let T : Finset (Fin (2*k - 1)) := U \ R
          have hTcard : T.card = k := by
            have hTsub : R ⊆ U := hRU
            have hsdiff := Finset.card_sdiff_of_subset hTsub
            dsimp [T]
            rw [hsdiff, hU, hRcard]
            omega
          let t : {T : Finset (Fin (2*k - 1)) // T.card = k} := ⟨T, hTcard⟩
          let v := g t
          have hvT : v ∈ T := hg t
          have hvU : v ∈ U := (Finset.mem_sdiff.mp hvT).1
          have hvR : v ∉ R := (Finset.mem_sdiff.mp hvT).2
          refine ⟨v, hvU, hvR, ?_⟩
          intro Y hH hYR
          obtain ⟨-, -, hYcard, -, X, hXU, hXcard, hfX, hYX⟩ := hH
          let S := C ∪ X
          have hcardS := hCX_card X hXU hXcard
          have hproper_app := hproper ⟨S, hcardS⟩ t
          have hST : (S ∩ T).card ≤ r := by
            have hCT_disj : Disjoint C T := by
              rw [Finset.disjoint_left]
              intro x hxC hxT
              exact (Finset.mem_sdiff.mp hxC).2 (Finset.mem_sdiff.mp hxT).1
            have hST_eq : S ∩ T = X ∩ T := by
              dsimp [S]
              rw [Finset.union_inter_distrib_right, (Finset.disjoint_iff_inter_eq_empty.mp hCT_disj), Finset.empty_union]
            rw [hST_eq]
            have hXT_eq : X ∩ T = X \ R := by
              ext x
              simp only [T, Finset.mem_inter, Finset.mem_sdiff]
              constructor
              · rintro ⟨hxX, hxU, hxR⟩; exact ⟨hxX, hxR⟩
              · rintro ⟨hxX, hxR⟩; exact ⟨hxX, hXU hxX, hxR⟩
            rw [hXT_eq]
            have hdisj : Disjoint Y (X \ R) := by
              rw [Finset.disjoint_left]
              intro x hxY hxXR
              exact (Finset.mem_sdiff.mp hxXR).2 (hYR hxY)
            have hsub : Y ∪ (X \ R) ⊆ X := by
              apply Finset.union_subset
              · exact hYX.trans (Finset.erase_subset v X)
              · exact Finset.sdiff_subset
            have hcard_le := Finset.card_le_card hsub
            rw [Finset.card_union_of_disjoint hdisj, hYcard, hXcard] at hcard_le
            omega
          apply hproper_app hST
          exact hfX.trans (rfl : v = g t)
  6. In the reverse direction, assume a hypergraph relation H and re-evaluate the cardinality of C = [2k-1] \ U.

    In the reverse direction (⇐), we assume a relation H satisfying well-formedness, coverage for (r+s+1)-subsets of U, and avoidance for (r+s)-subsets of U. As in the forward direction, the complement C = Finset.univ \ U has size (2k - 1) - (k + r + s) = k - r - s - 1.

    lines 100–107

    uses Finset.card_sdiff_of_subset, Finset.subset_univ

      · rintro ⟨H, _hHprop, hcover, havoid⟩
        classical
        let C : Finset (Fin (2*k - 1)) := Finset.univ \ U
        have h_univ : (Finset.univ : Finset (Fin (2*k - 1))).card = 2 * k - 1 := by simp
        have hC_card : C.card = k - r - s - 1 := by
          dsimp [C]
          rw [Finset.card_sdiff_of_subset (Finset.subset_univ U), h_univ, hU]
          omega
  7. Construct the selector f on all k-subsets S using coverage.

    For each k-subset S, the elements outside U are contained in C, so |S \ U| ≤ |C| = k - r - s - 1, which implies |S ∩ U| = |S| - |S \ U| ≥ k - (k - r - s - 1) = r + s + 1. We choose a subset X ⊆ S ∩ U of size r + s + 1. By the coverage property of H on X, there is some v ∈ X such that every (s+1)-subset of X \ {v} belongs to H with v. Using classical choice, we define f(S) to be this vertex v ∈ S ∩ U, along with its witness X.

    lines 108–136

    uses Finset.mem_sdiff.mpr, Finset.mem_univ, Finset.mem_sdiff.mp, Finset.card_le_card, Finset.card_union_of_disjoint, Finset.mem_union, Finset.mem_inter, Finset.mem_sdiff, Finset.disjoint_left, Finset.mem_inter.mp, Finset.exists_subset_card_eq, Finset.inter_subset_right, Classical.choose, Classical.choose_spec

        have h_choice_S : ∀ S : {S : Finset (Fin (2*k - 1)) // S.card = k},
            ∃ v ∈ S.1 ∩ U, ∃ X ⊆ S.1 ∩ U, X.card = r + s + 1 ∧ v ∈ X ∧
              ∀ Y ⊆ X.erase v, Y.card = s + 1 → H v Y := by
          intro S
          have hS_sub : S.1 \ U ⊆ C := by
            intro x hx
            exact Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, (Finset.mem_sdiff.mp hx).2⟩
          have hS_diff_le : (S.1 \ U).card ≤ C.card := Finset.card_le_card hS_sub
          have h_split : S.1.card = (S.1 ∩ U).card + (S.1 \ U).card := by
            rw [← Finset.card_union_of_disjoint]
            · congr 1
              ext x
              simp only [Finset.mem_union, Finset.mem_inter, Finset.mem_sdiff]
              tauto
            · rw [Finset.disjoint_left]
              intro x hx1 hx2
              exact (Finset.mem_sdiff.mp hx2).2 (Finset.mem_inter.mp hx1).2
          have hScard := S.2
          have hcard_ge : r + s + 1 ≤ (S.1 ∩ U).card := by omega
          obtain ⟨X, hX_sub, hX_card⟩ := Finset.exists_subset_card_eq hcard_ge
          have hX_U : X ⊆ U := hX_sub.trans Finset.inter_subset_right
          obtain ⟨v, hvX, hH_cov⟩ := hcover X hX_U hX_card
          refine ⟨v, hX_sub hvX, X, hX_sub, hX_card, hvX, hH_cov⟩
        let f : {S : Finset (Fin (2*k - 1)) // S.card = k} → Fin (2*k - 1) :=
          fun S => Classical.choose (h_choice_S S)
        have hf_spec (S : {S : Finset (Fin (2*k - 1)) // S.card = k}) :
            f S ∈ S.1 ∩ U ∧ ∃ X ⊆ S.1 ∩ U, X.card = r + s + 1 ∧ f S ∈ X ∧
              ∀ Y ⊆ X.erase (f S), Y.card = s + 1 → H (f S) Y :=
          Classical.choose_spec (h_choice_S S)
  8. Construct the selector g on all k-subsets T using avoidance.

    For each k-subset T, we case-split on whether T \ U is nonempty. If T contains an element outside U, we pick v ∈ T \ U so that v ∉ U. If T ⊆ U, then R = U \ T has size |U| - |T| = (k + r + s) - k = r + s. Applying the avoidance condition to R yields an element v ∈ U \ R = T such that no Y with H(v, Y) is contained in R = U \ T. Using classical choice, we define g(T) to be this vertex v ∈ T.

    lines 137–159

    uses Finset.mem_sdiff.mp, Or.inl, Finset.nonempty_iff_ne_empty, Finset.sdiff_eq_empty_iff_subset, Finset.card_sdiff_of_subset, Finset.sdiff_subset, Finset.mem_sdiff.mpr, Or.inr, Classical.choose, Classical.choose_spec

        have h_choice_T : ∀ T : {T : Finset (Fin (2*k - 1)) // T.card = k},
            ∃ v ∈ T.1, (v ∉ U) ∨ (∀ Y, H v Y → ¬ Y ⊆ U \ T.1) := by
          intro T
          by_cases hne : (T.1 \ U).Nonempty
          · obtain ⟨v, hv⟩ := hne
            exact ⟨v, (Finset.mem_sdiff.mp hv).1, Or.inl (Finset.mem_sdiff.mp hv).2⟩
          · rw [Finset.nonempty_iff_ne_empty, not_not, Finset.sdiff_eq_empty_iff_subset] at hne
            let R := U \ T.1
            have hRcard : R.card = r + s := by
              dsimp [R]
              rw [Finset.card_sdiff_of_subset hne, hU, T.2]
              omega
            have hRU : R ⊆ U := Finset.sdiff_subset
            obtain ⟨v, hvU, hvR, hHav⟩ := havoid R hRU hRcard
            have hvT : v ∈ T.1 := by
              by_contra hnot
              exact hvR (Finset.mem_sdiff.mpr ⟨hvU, hnot⟩)
            exact ⟨v, hvT, Or.inr hHav⟩
        let g : {T : Finset (Fin (2*k - 1)) // T.card = k} → Fin (2*k - 1) :=
          fun T => Classical.choose (h_choice_T T)
        have hg_spec (T : {T : Finset (Fin (2*k - 1)) // T.card = k}) :
            g T ∈ T.1 ∧ ((g T ∉ U) ∨ (∀ Y, H (g T) Y → ¬ Y ⊆ U \ T.1)) :=
          Classical.choose_spec (h_choice_T T)
  9. The selectors f and g satisfy the membership requirements: f(S) ∈ S ∩ U and g(T) ∈ T.

    Both containment properties follow immediately from the specifications of f and g extracted from the choice principles in their definitions.

    lines 160–164

    uses Finset.mem_inter.mp

        refine ⟨f, g, ?_, ?_, ?_⟩
        · intro S
          exact ⟨(Finset.mem_inter.mp (hf_spec S).1).1, (Finset.mem_inter.mp (hf_spec S).1).2⟩
        · intro T
          exact (hg_spec T).1
  10. The selectors f and g satisfy the separation property: |S ∩ T| ≤ r implies f(S) ≠ g(T).

    Assume for contradiction that |S ∩ T| ≤ r but f(S) = g(T) = v. Since f(S) ∈ U, we have v ∈ U, so the second branch of g's specification must hold: no Y with H(v, Y) is contained in U \ T. On the other hand, f(S) came with a witness X ⊆ S ∩ U of size r + s + 1. The set W = X \ T satisfies |W| = |X| - |X ∩ T| ≥ (r + s + 1) - |S ∩ T| ≥ (r + s + 1) - r = s + 1. Choosing an (s+1)-element subset Y ⊆ W, we find Y ⊆ X \ T. Since v = g(T) ∈ T, v ∉ Y, so Y ⊆ X \ {v}. By the coverage property of f(S), we have H(v, Y). But Y ⊆ X ⊆ U and Y is disjoint from T, meaning Y ⊆ U \ T, which contradicts the avoidance condition for g(T). Thus f(S) ≠ g(T).

    lines 165–208

    uses Finset.mem_inter.mp, Finset.inter_subset_left, Finset.inter_subset_right, Finset.card_union_of_disjoint, Finset.mem_union, Finset.mem_sdiff, Finset.mem_inter, Finset.disjoint_left, Finset.mem_sdiff.mp, Finset.inter_subset_inter_right, Finset.card_le_card, Finset.exists_subset_card_eq, Finset.mem_erase.mpr, Finset.mem_sdiff.mpr

        · intro S T hint heq
          have hvU : f S ∈ U := (Finset.mem_inter.mp (hf_spec S).1).2
          have hg_disj := (hg_spec T).2
          rw [← heq] at hg_disj
          rcases hg_disj with hnotU | hHav
          · exact hnotU hvU
          · obtain ⟨-, X, hX_sub, hX_card, hvX, hH_cov⟩ := hf_spec S
            have hX_S : X ⊆ S.1 := hX_sub.trans Finset.inter_subset_left
            have hX_U : X ⊆ U := hX_sub.trans Finset.inter_subset_right
            let W := X \ T.1
            have h_split : X.card = (X \ T.1).card + (X ∩ T.1).card := by
              rw [← Finset.card_union_of_disjoint]
              · congr 1
                ext x
                simp only [Finset.mem_union, Finset.mem_sdiff, Finset.mem_inter]
                tauto
              · rw [Finset.disjoint_left]
                intro x hx1 hx2
                exact (Finset.mem_sdiff.mp hx1).2 (Finset.mem_inter.mp hx2).2
            have hXT_sub : X ∩ T.1 ⊆ S.1 ∩ T.1 := Finset.inter_subset_inter_right hX_S
            have hXT_le : (X ∩ T.1).card ≤ r := (Finset.card_le_card hXT_sub).trans hint
            have hW_card : s + 1 ≤ W.card := by
              dsimp [W]
              omega
            obtain ⟨Y, hYW, hYcard⟩ := Finset.exists_subset_card_eq hW_card
            have hY_erase : Y ⊆ X.erase (f S) := by
              intro y hy
              have hyW := hYW hy
              have hyX := (Finset.mem_sdiff.mp hyW).1
              have hnotT := (Finset.mem_sdiff.mp hyW).2
              apply Finset.mem_erase.mpr
              refine ⟨?_, hyX⟩
              intro hy_eq
              apply hnotT
              rw [hy_eq, heq]
              exact (hg_spec T).1
            have hHY : H (f S) Y := hH_cov Y hY_erase hYcard
            have hYR : Y ⊆ U \ T.1 := by
              intro y hy
              have hyW := hYW hy
              have hyX := (Finset.mem_sdiff.mp hyW).1
              have hnotT := (Finset.mem_sdiff.mp hyW).2
              exact Finset.mem_sdiff.mpr ⟨hX_U hyX, hnotT⟩
            exact hHav Y hHY hYR
Finset.card_sdiff_of_subset
For finite sets s ⊆ t, the cardinality of their difference is |t \ s| = |t| - |s|.
Finset.subset_univ
Every finite set of a finite type is a subset of the universal set Finset.univ.
Finset.disjoint_left
Two sets s and t are disjoint if and only if no element of s belongs to t.
Finset.card_union_of_disjoint
If two finite sets s and t are disjoint, the cardinality of their union is |s ∪ t| = |s| + |t|.
Finset.mem_sdiff.mp
If x ∈ s \ t, then x ∈ s and x ∉ t.
Finset.mem_union.mp
If x ∈ s ∪ t, then x ∈ s or x ∈ t.
False.elim
From False, any proposition follows (principle of explosion).
Finset.erase_subset
Removing an element from a set yields a subset: s \ {a} ⊆ s.
Finset.mem_erase.mp
If x ∈ s \ {a}, then x ≠ a and x ∈ s.
Finset.union_inter_distrib_right
Intersection distributes over union on the right: (s ∪ t) ∩ u = (s ∩ u) ∪ (t ∩ u).
Finset.disjoint_iff_inter_eq_empty.mp
If two sets s and t are disjoint, their intersection is empty: s ∩ t = ∅.
Finset.empty_union
The union of the empty set with any set s is s: ∅ ∪ s = s.
Finset.mem_inter
An element x belongs to s ∩ t if and only if x ∈ s and x ∈ t.
Finset.mem_sdiff
An element x belongs to s \ t if and only if x ∈ s and x ∉ t.
Finset.union_subset
If s ⊆ u and t ⊆ u, then s ∪ t ⊆ u.
Finset.sdiff_subset
The set difference s \ t is always a subset of s.
Finset.card_le_card
If s ⊆ t, then |s| ≤ |t|.
Finset.mem_sdiff.mpr
If x ∈ s and x ∉ t, then x ∈ s \ t.
Finset.mem_univ
In a finite type, every element belongs to Finset.univ.
Finset.mem_union
An element x belongs to s ∪ t if and only if x ∈ s or x ∈ t.
Finset.mem_inter.mp
If x ∈ s ∩ t, then x ∈ s and x ∈ t.
Finset.exists_subset_card_eq
If n ≤ |s|, there exists a subset of s with cardinality n.
Finset.inter_subset_right
The intersection s ∩ t is a subset of t.
Classical.choose
Given an existential proof, returns a witness satisfying the predicate.
Classical.choose_spec
The witness produced by Classical.choose satisfies the given predicate.
Or.inl
Constructs a proof of A ∨ B from a proof of A.
Finset.nonempty_iff_ne_empty
A finite set is nonempty if and only if it is not equal to ∅.
Finset.sdiff_eq_empty_iff_subset
The set difference s \ t is empty if and only if s ⊆ t.
Or.inr
Constructs a proof of A ∨ B from a proof of B.
Finset.inter_subset_left
The intersection s ∩ t is a subset of s.
Finset.inter_subset_inter_right
If s ⊆ t, then s ∩ u ⊆ t ∩ u.
Finset.mem_erase.mpr
If x ≠ a and x ∈ s, then x ∈ s \ {a}.

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 op861_palette_surplus_hypergraph_iff (k r s : ℕ) (hsmall : r + s < k)    (U : Finset (Fin (2*k - 1))) (hU : U.card = k + r + s) :    (∃ f g : {S : Finset (Fin (2*k - 1)) // S.card = k} → Fin (2*k - 1),      (∀ S, f S ∈ S.1 ∧ f S ∈ U) ∧ (∀ T, g T ∈ T.1) ∧      ∀ S T, (S.1 ∩ T.1).card ≤ r → f S ≠ g T) ↔    ∃ H : Fin (2*k - 1) → Finset (Fin (2*k - 1)) → Prop,      (∀ v Y, H v Y → v ∈ U ∧ Y ⊆ U ∧ Y.card = s + 1 ∧ v ∉ Y) ∧      (∀ X : Finset (Fin (2*k - 1)), X ⊆ U → X.card = r + s + 1 →        ∃ v ∈ X, ∀ Y : Finset (Fin (2*k - 1)),          Y ⊆ X.erase v → Y.card = s + 1 → H v Y) ∧      (∀ R : Finset (Fin (2*k - 1)), R ⊆ U → R.card = r + s →        ∃ v ∈ U, v ∉ R ∧ ∀ Y : Finset (Fin (2*k - 1)), H v Y → ¬ Y ⊆ R) := by  constructor  · rintro ⟨f, g, hf, hg, hproper⟩    classical    let C : Finset (Fin (2*k - 1)) := Finset.univ \ U    have h_univ : (Finset.univ : Finset (Fin (2*k - 1))).card = 2 * k - 1 := by simp    have hC_card : C.card = k - r - s - 1 := by      dsimp [C]      rw [Finset.card_sdiff_of_subset (Finset.subset_univ U), h_univ, hU]      omega    have hCX_card : ∀ X ⊆ U, X.card = r + s + 1 → (C ∪ X).card = k := by      intro X hXU hX      have hdisj : Disjoint C X := by        rw [Finset.disjoint_left]        intro x hxC hxX        exact (Finset.mem_sdiff.mp hxC).2 (hXU hxX)      rw [Finset.card_union_of_disjoint hdisj, hC_card, hX]      omega    let H : Fin (2*k - 1) → Finset (Fin (2*k - 1)) → Prop := fun v Y =>      v ∈ U ∧ Y ⊆ U ∧ Y.card = s + 1 ∧ v ∉ Y ∧        ∃ (X : Finset (Fin (2*k - 1))) (hXU : X ⊆ U) (hXcard : X.card = r + s + 1),          f ⟨C ∪ X, hCX_card X hXU hXcard⟩ = v ∧ Y ⊆ X.erase v    refine ⟨H, ?_, ?_, ?_⟩    · intro v Y h      exact ⟨h.1, h.2.1, h.2.2.1, h.2.2.2.1⟩    · intro X hXU hXcard      have hcard := hCX_card X hXU hXcard      let v := f ⟨C ∪ X, hcard⟩      have hv_in := (hf ⟨C ∪ X, hcard⟩).1      have hv_U := (hf ⟨C ∪ X, hcard⟩).2      have hv_X : v ∈ X := by        rcases Finset.mem_union.mp hv_in with hvC | hvX        · exact False.elim ((Finset.mem_sdiff.mp hvC).2 hv_U)        · exact hvX      refine ⟨v, hv_X, ?_⟩      intro Y hYX hYcard      refine ⟨hv_U, ?_, hYcard, ?_, X, hXU, hXcard, rfl, hYX⟩      · exact hYX.trans ((Finset.erase_subset v X).trans hXU)      · intro hvY        exact (Finset.mem_erase.mp (hYX hvY)).1 rfl    · intro R hRU hRcard      let T : Finset (Fin (2*k - 1)) := U \ R      have hTcard : T.card = k := by        have hTsub : R ⊆ U := hRU        have hsdiff := Finset.card_sdiff_of_subset hTsub        dsimp [T]        rw [hsdiff, hU, hRcard]        omega      let t : {T : Finset (Fin (2*k - 1)) // T.card = k} := ⟨T, hTcard⟩      let v := g t      have hvT : v ∈ T := hg t      have hvU : v ∈ U := (Finset.mem_sdiff.mp hvT).1      have hvR : v ∉ R := (Finset.mem_sdiff.mp hvT).2      refine ⟨v, hvU, hvR, ?_⟩      intro Y hH hYR      obtain ⟨-, -, hYcard, -, X, hXU, hXcard, hfX, hYX⟩ := hH      let S := C ∪ X      have hcardS := hCX_card X hXU hXcard      have hproper_app := hproper ⟨S, hcardS⟩ t      have hST : (S ∩ T).card ≤ r := by        have hCT_disj : Disjoint C T := by          rw [Finset.disjoint_left]          intro x hxC hxT          exact (Finset.mem_sdiff.mp hxC).2 (Finset.mem_sdiff.mp hxT).1        have hST_eq : S ∩ T = X ∩ T := by          dsimp [S]          rw [Finset.union_inter_distrib_right, (Finset.disjoint_iff_inter_eq_empty.mp hCT_disj), Finset.empty_union]        rw [hST_eq]        have hXT_eq : X ∩ T = X \ R := by          ext x          simp only [T, Finset.mem_inter, Finset.mem_sdiff]          constructor          · rintro ⟨hxX, hxU, hxR⟩; exact ⟨hxX, hxR⟩          · rintro ⟨hxX, hxR⟩; exact ⟨hxX, hXU hxX, hxR⟩        rw [hXT_eq]        have hdisj : Disjoint Y (X \ R) := by          rw [Finset.disjoint_left]          intro x hxY hxXR          exact (Finset.mem_sdiff.mp hxXR).2 (hYR hxY)        have hsub : Y ∪ (X \ R) ⊆ X := by          apply Finset.union_subset          · exact hYX.trans (Finset.erase_subset v X)          · exact Finset.sdiff_subset        have hcard_le := Finset.card_le_card hsub        rw [Finset.card_union_of_disjoint hdisj, hYcard, hXcard] at hcard_le        omega      apply hproper_app hST      exact hfX.trans (rfl : v = g t)  · rintro ⟨H, _hHprop, hcover, havoid⟩    classical    let C : Finset (Fin (2*k - 1)) := Finset.univ \ U    have h_univ : (Finset.univ : Finset (Fin (2*k - 1))).card = 2 * k - 1 := by simp    have hC_card : C.card = k - r - s - 1 := by      dsimp [C]      rw [Finset.card_sdiff_of_subset (Finset.subset_univ U), h_univ, hU]      omega    have h_choice_S : ∀ S : {S : Finset (Fin (2*k - 1)) // S.card = k},        ∃ v ∈ S.1 ∩ U, ∃ X ⊆ S.1 ∩ U, X.card = r + s + 1 ∧ v ∈ X ∧          ∀ Y ⊆ X.erase v, Y.card = s + 1 → H v Y := by      intro S      have hS_sub : S.1 \ U ⊆ C := by        intro x hx        exact Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, (Finset.mem_sdiff.mp hx).2⟩      have hS_diff_le : (S.1 \ U).card ≤ C.card := Finset.card_le_card hS_sub      have h_split : S.1.card = (S.1 ∩ U).card + (S.1 \ U).card := by        rw [← Finset.card_union_of_disjoint]        · congr 1          ext x          simp only [Finset.mem_union, Finset.mem_inter, Finset.mem_sdiff]          tauto        · rw [Finset.disjoint_left]          intro x hx1 hx2          exact (Finset.mem_sdiff.mp hx2).2 (Finset.mem_inter.mp hx1).2      have hScard := S.2      have hcard_ge : r + s + 1 ≤ (S.1 ∩ U).card := by omega      obtain ⟨X, hX_sub, hX_card⟩ := Finset.exists_subset_card_eq hcard_ge      have hX_U : X ⊆ U := hX_sub.trans Finset.inter_subset_right      obtain ⟨v, hvX, hH_cov⟩ := hcover X hX_U hX_card      refine ⟨v, hX_sub hvX, X, hX_sub, hX_card, hvX, hH_cov⟩    let f : {S : Finset (Fin (2*k - 1)) // S.card = k} → Fin (2*k - 1) :=      fun S => Classical.choose (h_choice_S S)    have hf_spec (S : {S : Finset (Fin (2*k - 1)) // S.card = k}) :        f S ∈ S.1 ∩ U ∧ ∃ X ⊆ S.1 ∩ U, X.card = r + s + 1 ∧ f S ∈ X ∧          ∀ Y ⊆ X.erase (f S), Y.card = s + 1 → H (f S) Y :=      Classical.choose_spec (h_choice_S S)    have h_choice_T : ∀ T : {T : Finset (Fin (2*k - 1)) // T.card = k},        ∃ v ∈ T.1, (v ∉ U) ∨ (∀ Y, H v Y → ¬ Y ⊆ U \ T.1) := by      intro T      by_cases hne : (T.1 \ U).Nonempty      · obtain ⟨v, hv⟩ := hne        exact ⟨v, (Finset.mem_sdiff.mp hv).1, Or.inl (Finset.mem_sdiff.mp hv).2⟩      · rw [Finset.nonempty_iff_ne_empty, not_not, Finset.sdiff_eq_empty_iff_subset] at hne        let R := U \ T.1        have hRcard : R.card = r + s := by          dsimp [R]          rw [Finset.card_sdiff_of_subset hne, hU, T.2]          omega        have hRU : R ⊆ U := Finset.sdiff_subset        obtain ⟨v, hvU, hvR, hHav⟩ := havoid R hRU hRcard        have hvT : v ∈ T.1 := by          by_contra hnot          exact hvR (Finset.mem_sdiff.mpr ⟨hvU, hnot⟩)        exact ⟨v, hvT, Or.inr hHav⟩    let g : {T : Finset (Fin (2*k - 1)) // T.card = k} → Fin (2*k - 1) :=      fun T => Classical.choose (h_choice_T T)    have hg_spec (T : {T : Finset (Fin (2*k - 1)) // T.card = k}) :        g T ∈ T.1 ∧ ((g T ∉ U) ∨ (∀ Y, H (g T) Y → ¬ Y ⊆ U \ T.1)) :=      Classical.choose_spec (h_choice_T T)    refine ⟨f, g, ?_, ?_, ?_⟩    · intro S      exact ⟨(Finset.mem_inter.mp (hf_spec S).1).1, (Finset.mem_inter.mp (hf_spec S).1).2⟩    · intro T      exact (hg_spec T).1    · intro S T hint heq      have hvU : f S ∈ U := (Finset.mem_inter.mp (hf_spec S).1).2      have hg_disj := (hg_spec T).2      rw [← heq] at hg_disj      rcases hg_disj with hnotU | hHav      · exact hnotU hvU      · obtain ⟨-, X, hX_sub, hX_card, hvX, hH_cov⟩ := hf_spec S        have hX_S : X ⊆ S.1 := hX_sub.trans Finset.inter_subset_left        have hX_U : X ⊆ U := hX_sub.trans Finset.inter_subset_right        let W := X \ T.1        have h_split : X.card = (X \ T.1).card + (X ∩ T.1).card := by          rw [← Finset.card_union_of_disjoint]          · congr 1            ext x            simp only [Finset.mem_union, Finset.mem_sdiff, Finset.mem_inter]            tauto          · rw [Finset.disjoint_left]            intro x hx1 hx2            exact (Finset.mem_sdiff.mp hx1).2 (Finset.mem_inter.mp hx2).2        have hXT_sub : X ∩ T.1 ⊆ S.1 ∩ T.1 := Finset.inter_subset_inter_right hX_S        have hXT_le : (X ∩ T.1).card ≤ r := (Finset.card_le_card hXT_sub).trans hint        have hW_card : s + 1 ≤ W.card := by          dsimp [W]          omega        obtain ⟨Y, hYW, hYcard⟩ := Finset.exists_subset_card_eq hW_card        have hY_erase : Y ⊆ X.erase (f S) := by          intro y hy          have hyW := hYW hy          have hyX := (Finset.mem_sdiff.mp hyW).1          have hnotT := (Finset.mem_sdiff.mp hyW).2          apply Finset.mem_erase.mpr          refine ⟨?_, hyX⟩          intro hy_eq          apply hnotT          rw [hy_eq, heq]          exact (hg_spec T).1        have hHY : H (f S) Y := hH_cov Y hY_erase hYcard        have hYR : Y ⊆ U \ T.1 := by          intro y hy          have hyW := hYW hy          have hyX := (Finset.mem_sdiff.mp hyW).1          have hnotT := (Finset.mem_sdiff.mp hyW).2          exact Finset.mem_sdiff.mpr ⟨hX_U hyX, hnotT⟩        exact hHav Y hHY hYR
See it in the graphDiscuss this resultChallenge it