AFTD Auto-Formalizing Theoretical Domains

fin_five_three_subset_avoids_two

theoremverified

A five-element set has a three-element subset different from either of two prescribed subsets.

Statement

theorem fin_five_three_subset_avoids_two (A B : Finset (Fin 5)) :
    ∃ S : Finset (Fin 5), S.card = 3 ∧ S ≠ A ∧ S ≠ B
Source
Exceptional five-vertex contraction case in the OP-874 matching-cut reduction.
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

The theorem is proved by constructing three explicit 3-element subsets of Fin 5—namely X = {0, 1, 2}, Y = {0, 1, 3}, and Z = {0, 1, 4}—and verifying by computation that they are pairwise distinct. Since there are three distinct candidates and only two sets A and B to avoid, at least one candidate must differ from both. The formal proof establishes this through an exhaustive case analysis on whether X and Y equal A or B, showing in each case that transitivity of equality rules out collisions with the chosen candidate.

  1. Define three candidate 3-element subsets X = {0, 1, 2}, Y = {0, 1, 3}, and Z = {0, 1, 4} of Fin 5.

    We define three concrete subsets X, Y, and Z of {0, 1, 2, 3, 4} as candidates for the required witness S.

    lines 3–5

      let X : Finset (Fin 5) := {0,1,2}
      let Y : Finset (Fin 5) := {0,1,3}
      let Z : Finset (Fin 5) := {0,1,4}
  2. The subsets X, Y, and Z each have cardinality 3 and are pairwise distinct.

    Each candidate set contains three distinct elements, and any two sets differ on their last element (2, 3, or 4). All six facts (X ≠ Y, X ≠ Z, Y ≠ Z, |X| = 3, |Y| = 3, and |Z| = 3) are proven by computation using `decide`.

    lines 6–11

      have hXY : X ≠ Y := by decide
      have hXZ : X ≠ Z := by decide
      have hYZ : Y ≠ Z := by decide
      have hX : X.card = 3 := by decide
      have hY : Y.card = 3 := by decide
      have hZ : Z.card = 3 := by decide
  3. If X = A and Y = B, then Z is a 3-element subset distinct from both A and B.

    We branch on whether X = A, and within that branch on whether Y = B. In the subcase where X = A and Y = B, we propose Z. If Z = A, then X = A = Z, contradicting X ≠ Z. Similarly, if Z = B, then Y = B = Z, contradicting Y ≠ Z. Thus Z avoids both A and B.

    lines 12–18

      by_cases hXA : X = A
      · by_cases hYB : Y = B
        · refine ⟨Z, hZ, ?_, ?_⟩
          · intro hZA
            exact hXZ (hXA.trans hZA.symm)
          · intro hZB
            exact hYZ (hYB.trans hZB.symm)
  4. If X = A and Y ≠ B, then Y is a 3-element subset distinct from both A and B.

    Here Y ≠ B holds by assumption. If Y = A, then X = A = Y, which contradicts X ≠ Y. Hence Y ≠ A as well, so Y avoids both A and B.

    lines 19–21

        · refine ⟨Y, hY, ?_, hYB⟩
          intro hYA
          exact hXY (hXA.trans hYA.symm)
  5. If X ≠ A, X = B, and Y = A, then Z is a 3-element subset distinct from both A and B.

    In the branch where X ≠ A, we branch on whether X = B and then on whether Y = A. When both X = B and Y = A hold, we choose Z. If Z = A, then Y = A = Z, contradicting Y ≠ Z. If Z = B, then X = B = Z, contradicting X ≠ Z. Thus Z avoids both A and B.

    lines 22–28

      · by_cases hXB : X = B
        · by_cases hYA : Y = A
          · refine ⟨Z, hZ, ?_, ?_⟩
            · intro hZA
              exact hYZ (hYA.trans hZA.symm)
            · intro hZB
              exact hXZ (hXB.trans hZB.symm)
  6. If X ≠ A, X = B, and Y ≠ A, then Y is a 3-element subset distinct from both A and B.

    Here Y ≠ A is given. If Y = B, then X = B = Y, which contradicts X ≠ Y. Thus Y ≠ B as well, so Y avoids both A and B.

    lines 29–31

          · refine ⟨Y, hY, hYA, ?_⟩
            intro hYB
            exact hXY (hXB.trans hYB.symm)
  7. If X ≠ A and X ≠ B, then X is a 3-element subset distinct from both A and B.

    In the remaining subcase, X is already known to differ from both A and B, so X itself satisfies all the conditions.

    line 32

        · exact ⟨X, hX, hXA, hXB⟩

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 fin_five_three_subset_avoids_two (A B : Finset (Fin 5)) :    ∃ S : Finset (Fin 5), S.card = 3 ∧ S ≠ A ∧ S ≠ B := by  let X : Finset (Fin 5) := {0,1,2}  let Y : Finset (Fin 5) := {0,1,3}  let Z : Finset (Fin 5) := {0,1,4}  have hXY : X ≠ Y := by decide  have hXZ : X ≠ Z := by decide  have hYZ : Y ≠ Z := by decide  have hX : X.card = 3 := by decide  have hY : Y.card = 3 := by decide  have hZ : Z.card = 3 := by decide  by_cases hXA : X = A  · by_cases hYB : Y = B    · refine ⟨Z, hZ, ?_, ?_⟩      · intro hZA        exact hXZ (hXA.trans hZA.symm)      · intro hZB        exact hYZ (hYB.trans hZB.symm)    · refine ⟨Y, hY, ?_, hYB⟩      intro hYA      exact hXY (hXA.trans hYA.symm)  · by_cases hXB : X = B    · by_cases hYA : Y = A      · refine ⟨Z, hZ, ?_, ?_⟩        · intro hZA          exact hYZ (hYA.trans hZA.symm)        · intro hZB          exact hXZ (hXB.trans hZB.symm)      · refine ⟨Y, hY, hYA, ?_⟩        intro hYB        exact hXY (hXB.trans hYB.symm)    · exact ⟨X, hX, hXA, hXB⟩
See it in the graphDiscuss this resultChallenge it