AFTD Auto-Formalizing Theoretical Domains

op874_two_color_palettes_repeat

theoremverified

Any assignment of two-element subsets of four colors to at least seven vertices repeats a palette.

Statement

theorem op874_two_color_palettes_repeat
    {V : Type*} [DecidableEq V] (S : Finset V) (P : V → Finset (Fin 4))
    (hP : ∀ v ∈ S, (P v).card = 2) (hS : 7 ≤ S.card) :
    ∃ u ∈ S, ∃ v ∈ S, u ≠ v ∧ P u = P v
Source
Matching-adversarial factor-word construction for OP-874, https://arxiv.org/abs/2610.41950.
Verified
26 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

The proof, explained

The theorem is proved by contradiction using the Pigeonhole Principle. There are only 6 possible two-element palettes chosen from four colors. If at least seven vertices were assigned distinct two-element palettes, the assignment would inject the vertices into this 6-element set of palettes, forcing |S| ≤ 6 and contradicting |S| ≥ 7.

  1. Assume for contradiction that no two distinct vertices in S receive the same palette.

    We assume classical logic and proceed by contradiction, introducing the negation of the conclusion. Pushing the negation through the quantifiers yields the hypothesis that any two distinct vertices u, v ∈ S have different palettes, P(u) ≠ P(v).

    lines 5–7

      classical
      by_contra hn
      push Not at hn
  2. The collection Q of all 2-element subsets of four colors has cardinality 6. automation

    We define Q as the collection of all subsets of the 4 colors of size 2. Lean's `decide` tactic checks this finite enumeration by computation, confirming |Q| = 6.

    lines 8–9

      let Q : Finset (Finset (Fin 4)) := Finset.univ.filter fun p => p.card = 2
      have hQ : Q.card = 6 := by decide
  3. Every palette assigned to a vertex in S belongs to Q (i.e., P(S) ⊆ Q).

    Any element in the image P(S) is the palette P(v) of some vertex v ∈ S by definition of the image (`Finset.mem_image.mp`). By the hypothesis that every palette on S has size 2, P(v) satisfies the filtering condition to be in Q (`Finset.mem_filter.mpr`, `Finset.mem_univ`).

    lines 10–13

    uses Finset.mem_image.mp, Finset.mem_filter.mpr, Finset.mem_univ

      have hsub : S.image P ⊆ Q := by
        intro t ht
        obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp ht
        exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hP v hv⟩
  4. The palette assignment P is injective on S.

    Suppose u, v ∈ S have P(u) = P(v). If u ≠ v, this would contradict the assumption from Step 1 that distinct vertices receive distinct palettes; hence u = v.

    lines 14–17

      have hinj : Set.InjOn P S := by
        intro u hu v hv heq
        by_contra hne
        exact hn u hu v hv hne heq
  5. Contradiction: |S| ≤ 6, which contradicts |S| ≥ 7. automation

    Because P is injective on S, the size of the image P(S) equals |S| (`Finset.card_image_iff.mpr`). Since P(S) ⊆ Q, we have |P(S)| ≤ |Q| = 6 (`Finset.card_le_card`), so |S| ≤ 6. The `omega` tactic detects the linear integer arithmetic contradiction between |S| ≤ 6 and |S| ≥ 7 to close the proof.

    lines 18–20

    uses Finset.card_image_iff.mpr, Finset.card_le_card

      have himage : (S.image P).card = S.card := Finset.card_image_iff.mpr hinj
      have hle := Finset.card_le_card hsub
      omega
Finset.mem_image.mp
An element y is in the image of a finite set under f if and only if y = f(x) for some element x in the set.
Finset.mem_filter.mpr
An element belongs to a filtered set if it belongs to the ambient set and satisfies the filtering predicate.
Finset.mem_univ
Every element of a finite type belongs to the universal finite set Finset.univ.
Finset.card_image_iff.mpr
If a function is injective on a finite set, the cardinality of its image equals the cardinality of the original set.
Finset.card_le_card
If one finite set is a subset of another, its cardinality is at most that of the superset.

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 op874_two_color_palettes_repeat    {V : Type*} [DecidableEq V] (S : Finset V) (P : V → Finset (Fin 4))    (hP : ∀ v ∈ S, (P v).card = 2) (hS : 7 ≤ S.card) :    ∃ u ∈ S, ∃ v ∈ S, u ≠ v ∧ P u = P v := by  classical  by_contra hn  push Not at hn  let Q : Finset (Finset (Fin 4)) := Finset.univ.filter fun p => p.card = 2  have hQ : Q.card = 6 := by decide  have hsub : S.image P ⊆ Q := by    intro t ht    obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp ht    exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hP v hv⟩  have hinj : Set.InjOn P S := by    intro u hu v hv heq    by_contra hne    exact hn u hu v hv hne heq  have himage : (S.image P).card = S.card := Finset.card_image_iff.mpr hinj  have hle := Finset.card_le_card hsub  omega
See it in the graphDiscuss this resultChallenge it