AFTD Auto-Formalizing Theoretical Domains

op309_five_palette_two_pairs

theoremverified

Two injective five-color lists with three shared entries have the same remaining pair up to swapping.

Statement

theorem op309_five_palette_two_pairs
    (p q r a b x y : Fin 5)
    (hfirst : ([p,q,r,a,b] : List (Fin 5)).Nodup)
    (hsecond : ([p,q,r,x,y] : List (Fin 5)).Nodup) :
    (a=x ∧ b=y) ∨ (a=y ∧ b=x)
Source
OP-309 local P3 port pairing obstruction; experiments 41711-41716.
Verified
27 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 2

The proof, explained

Because the list $[p, q, r, a, b]$ has no duplicates, its five entries exhaust the five-element domain $\mathrm{Fin}\ 5$, as an injective map from a finite set to itself is surjective. Consequently, the elements $x$ and $y$ from the second list must belong to $\{p, q, r, a, b\}$. Since $x$ and $y$ are distinct from $p, q, r$ and from each other, the pair $\{x, y\}$ must equal $\{a, b\}$, matching either in the same order or swapped.

  1. The duplicate-free conditions on `[p, q, r, a, b]` and `[p, q, r, x, y]` are unpacked into explicit pairwise inequalities between their elements.

    Simplifying with basic list membership and `Nodup` reduction lemmas expands the distinctness hypotheses `hfirst` and `hsecond` into conjunctions of pairwise inequalities ($p \ne q$, $p \ne r$, and so on) for all distinct pairs in both lists.

    lines 6–9

    uses List.nodup_cons, List.mem_cons, List.mem_singleton, List.nodup_singleton, not_or

      set_option maxHeartbeats 4000000 in
        classical
        simp only [List.nodup_cons, List.mem_cons, List.mem_singleton,
          List.nodup_singleton, not_or] at hfirst hsecond
  2. The function `f : Fin 5 → Fin 5` mapping the indices `0, 1, 2, 3, 4` to `p, q, r, a, b` respectively is injective.

    We define $f$ as the 5-vector $![p, q, r, a, b]$. To prove injectivity, we assume $f(i) = f(j)$ and exhaust all 25 possible index pairs $(i, j)$ using `fin_cases`. When $i = j$ the equality is trivial, and when $i \ne j$ the equality $f(i) = f(j)$ contradicts one of the pairwise inequalities from `hfirst`, allowing `simp_all` to close every branch.

    lines 10–13

        let f : Fin 5 → Fin 5 := ![p,q,r,a,b]
        have hf : Function.Injective f := by
          intro i j h
          fin_cases i <;> fin_cases j <;> simp_all [f]
  3. Every element `z : Fin 5` is equal to `p`, `q`, `r`, `a`, or `b`.

    Because the domain $\mathrm{Fin}\ 5$ is finite, the injective map $f$ is also surjective (`Finite.surjective_of_injective`). Thus any $z \in \mathrm{Fin}\ 5$ is $f(i)$ for some index $i$. Checking the five possible values of $i \in \{0, 1, 2, 3, 4\}$ via `fin_cases` shows that $z$ must equal $p$, $q$, $r$, $a$, or $b$.

    lines 14–16

    uses Finite.surjective_of_injective

        have cover (z : Fin 5) : z=p ∨ z=q ∨ z=r ∨ z=a ∨ z=b := by
          obtain ⟨i,hi⟩ := (Finite.surjective_of_injective hf) z
          fin_cases i <;> simp_all [f]
  4. Either `x = a` (leaving `b = y` to be shown) or `x = b` (leaving `a = y` to be shown).

    By the covering property, $x \in \{p, q, r, a, b\}$. Since $[p, q, r, x, y]$ has distinct entries (`hsecond`), $x$ cannot be $p$, $q$, or $r$. Discarding those three contradictions leaves the two cases $x = a$ and $x = b$.

    line 17

        rcases cover x with h | h | h | h | h <;> simp_all
  5. `(a = x ∧ b = y) ∨ (a = y ∧ b = x)` holds.

    In both branches, we apply the covering property to $y$, giving $y \in \{p, q, r, a, b\}$. By `hsecond`, $y$ cannot be $p, q, r$, nor can it equal $x$. If $x = a$, this forces $y = b$, yielding $a = x \land b = y$; if $x = b$, it forces $y = a$, yielding $a = y \land b = x$.

    line 18

        all_goals rcases cover y with h | h | h | h | h <;> simp_all
List.nodup_cons
A cons list `a :: l` has no duplicates if and only if `a` is not an element of `l` and `l` has no duplicates.
List.mem_cons
An element belongs to `b :: l` if and only if it equals `b` or belongs to `l`.
List.mem_singleton
An element belongs to the singleton list `[b]` if and only if it equals `b`.
List.nodup_singleton
Any singleton list `[a]` has no duplicate elements.
not_or
The negation of a disjunction `¬(p ∨ q)` is equivalent to `¬p ∧ ¬q`.
Finite.surjective_of_injective
An injective map from any finite type to itself is surjective.

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 op309_five_palette_two_pairs    (p q r a b x y : Fin 5)    (hfirst : ([p,q,r,a,b] : List (Fin 5)).Nodup)    (hsecond : ([p,q,r,x,y] : List (Fin 5)).Nodup) :    (a=x ∧ b=y) ∨ (a=y ∧ b=x) := by  set_option maxHeartbeats 4000000 in    classical    simp only [List.nodup_cons, List.mem_cons, List.mem_singleton,      List.nodup_singleton, not_or] at hfirst hsecond    let f : Fin 5 → Fin 5 := ![p,q,r,a,b]    have hf : Function.Injective f := by      intro i j h      fin_cases i <;> fin_cases j <;> simp_all [f]    have cover (z : Fin 5) : z=p ∨ z=q ∨ z=r ∨ z=a ∨ z=b := by      obtain ⟨i,hi⟩ := (Finite.surjective_of_injective hf) z      fin_cases i <;> simp_all [f]    rcases cover x with h | h | h | h | h <;> simp_all    all_goals rcases cover y with h | h | h | h | h <;> simp_all
See it in the graphDiscuss this resultChallenge it