AFTD Auto-Formalizing Theoretical Domains

path_selection_fixed_endpoints

theoremverified

For a finite path of finite sets of equal cardinality and prescribed elements x and y of its first and last sets, a selection exists from x to y such that each next selection lying in the previous set equals the previous selection if and only if any occurrence of y in every set forces x = y.

Statement

theorem path_selection_fixed_endpoints {Ω : Type*} [DecidableEq Ω]
    (P : ℕ → Finset Ω) (hcard : ∀ i, (P i).card = (P (i+1)).card)
    (x : Ω) (hx : x ∈ P 0) (n : ℕ) (y : Ω) (hy : y ∈ P n) :
    (∃ f : ℕ → Ω, f 0 = x ∧ f n = y ∧ (∀ i ≤ n, f i ∈ P i) ∧
      (∀ i < n, f (i+1) ∈ P i → f (i+1) = f i)) ↔
    ((∀ i ≤ n, y ∈ P i) → x = y)
Source
Endpoint compatibility for the high-color path construction for OP-874, arXiv:2610.41950.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 5

The proof, explained

The equivalence is proved by contraposition in the forward direction and by induction on the path length $n$ in the backward direction. In the forward direction, assuming $x \ne y$ when $y$ is in every set, an induction along the path shows that no step can select $y$ (as landing on $y$ would force the previous selection to already be $y$), contradicting the final endpoint $f(n) = y$. In the backward direction, extending a selection to $n+1$ with target $y$ splits on whether $y \in P_n$: if so, the induction hypothesis provides a path ending at $y$ which simply stays at $y$; if not, an unconstrained selection up to $n$ via `path_equal_cardinality_set_selection` is extended to $y$ at step $n+1$, satisfying the step condition vacuously since $y \notin P_n$.

  1. The equivalence reduces to proving the forward and backward implications.

    We enable classical logic and split the biconditional into two directions: showing that the existence of such a selection implies the uniqueness condition, and conversely that the condition suffices to construct the selection.

    lines 7–8

      classical
      constructor
  2. In the forward direction, assuming $x \ne y$ when $y$ is in every set $P_i$ ($i \le n$) sets up a contradiction.

    Assume a selection $f$ exists with $f(0) = x$, $f(n) = y$, $f(i) \in P_i$ for all $i \le n$, and $f(i+1) \in P_i \implies f(i+1) = f(i)$ for all $i < n$. Assume also that $y \in P_i$ for all $i \le n$. To show $x = y$, we suppose for contradiction that $x \ne y$.

    lines 9–10

      · rintro ⟨f, hf0, hfn, _, hfstep⟩ hall
        by_contra hxy
  3. For every index $i \le n$, $f(i) \ne y$.

    We prove $f(i) \ne y$ by induction on $i$. For the base case $i = 0$, $f(0) = x \ne y$ by the contradiction hypothesis. For the inductive step, suppose $f(i+1) = y$. Since $y \in P_i$ by assumption, $f(i+1) \in P_i$. The selection step condition then forces $f(i+1) = f(i)$, which yields $f(i) = y$, contradicting the induction hypothesis $f(i) \ne y$.

    lines 11–21

        have hprop : ∀ i, i ≤ n → f i ≠ y := by
          intro i
          induction i with
          | zero =>
            intro _ h
            apply hxy
            simpa [hf0] using h
          | succ i ih =>
            intro hi h
            have heq := hfstep i (by omega) (by simpa [h] using hall i (by omega))
            exact ih (by omega) (heq.symm.trans h)
  4. The forward implication holds.

    Evaluating the established property $f(i) \ne y$ at $i = n$ yields $f(n) \ne y$, which directly contradicts the endpoint condition $f(n) = y$.

    line 22

        exact hprop n (by omega) hfn
  5. The backward direction proceeds by induction on the path length $n$, generalized over the target element $y$.

    We assume that whenever $y$ occurs in all sets $P_0, \dots, P_n$, it must be that $x = y$. We then induct on $n$, generalizing over all choices of $y \in P_n$.

    lines 23–24

      · intro hcondition
        induction n generalizing y with
  6. The base case $n = 0$ holds.

    When $n = 0$, the condition that $y$ belongs to all sets up to index $0$ holds automatically because $y \in P_0$, so the hypothesis immediately gives $x = y$. The constant function $f(i) = x$ satisfies $f(0) = x$, $f(0) = y$, $f(0) \in P_0$, and the step condition holds vacuously as there are no indices $i < 0$.

    lines 25–35

        | zero =>
          have hxy := hcondition (by
            intro i hi
            have heq : i = 0 := by omega
            simpa [heq] using hy)
          refine ⟨fun _ => x, rfl, ?_, ?_, ?_⟩
          · exact hxy
          · intro i hi
            have heq : i = 0 := by omega
            simpa [heq] using hx
          · intro i hi; omega
  7. In the inductive step $n + 1$, if $y \in P_n$, the induction hypothesis provides a valid selection $f$ of length $n$ ending at $y$.

    We split into cases on whether $y \in P_n$. If $y \in P_n$, we verify that the induction hypothesis applies to $y$ at step $n$: if $y \in P_i$ for all $i \le n$, then together with $y \in P_{n+1}$, $y$ belongs to all sets up to $n+1$, so $x = y$ by our assumption. The induction hypothesis then yields a selection $f$ up to $n$ satisfying $f(0) = x$, $f(n) = y$, and the path conditions.

    lines 36–45

        | succ n ih =>
          by_cases hmem : y ∈ P n
          · have hcond : (∀ i ≤ n, y ∈ P i) → x = y := by
              intro h
              apply hcondition
              intro i hi
              by_cases heq : i = n+1
              · simpa [heq] using hy
              · exact h i (by omega)
            obtain ⟨f, hf0, hfn, hfmem, hfstep⟩ := ih y hmem hcond
  8. When $y \in P_n$, extending $f$ by setting $f(n+1) = y$ yields a valid selection of length $n+1$.

    We update $f$ at index $n+1$ to take value $y$. This preserves $f(0) = x$, gives $f(n+1) = y$, and ensures $f(i) \in P_i$ for all $i \le n+1$. For transitions at $i < n$, the step condition is unaffected because the values at $i$ and $i+1$ are unchanged. At step $i = n$, if $f(n+1) \in P_n$, then $f(n+1) = y = f(n)$ holds because $f(n) = y$.

    lines 46–61

    uses Function.update_of_ne, Function.update_self

            refine ⟨Function.update f (n+1) y, ?_, ?_, ?_, ?_⟩
            · simpa using hf0
            · simp
            · intro i hi
              by_cases heq : i = n+1
              · simpa [heq] using hy
              · simpa [Function.update_of_ne heq] using hfmem i (by omega)
            · intro i hi
              by_cases heq : i = n
              · subst i
                simp only [Function.update_self, Function.update_of_ne (by omega : n ≠ n+1)]
                intro _
                exact hfn.symm
              · have h1 : i+1 ≠ n+1 := by omega
                have h2 : i ≠ n+1 := by omega
                simpa [Function.update_of_ne h1, Function.update_of_ne h2] using hfstep i (by omega)
  9. In the case $y \notin P_n$, there exists a valid selection $f$ of length $n$ starting at $x$.

    When $y \notin P_n$, we do not require the selection at step $n$ to end at $y$. We invoke `path_equal_cardinality_set_selection` to obtain a selection $f$ starting at $x$ that satisfies the containment and step conditions up to length $n$.

    line 62

    uses path_equal_cardinality_set_selection

          · obtain ⟨f, hf0, hfmem, hfstep⟩ := path_equal_cardinality_set_selection P hcard x hx n
  10. When $y \notin P_n$, extending $f$ by setting $f(n+1) = y$ completes the inductive step.

    We extend $f$ to $n+1$ by setting $f(n+1) = y$. The endpoints and set memberships hold as before, and transitions for $i < n$ follow from the properties of $f$. At the final step $i = n$, the premise $f(n+1) \in P_n$ is $y \in P_n$, which contradicts the case assumption $y \notin P_n$, so the implication $f(n+1) \in P_n \implies f(n+1) = f(n)$ holds vacuously.

    lines 63–78

    uses Function.update_of_ne, Function.update_self

            refine ⟨Function.update f (n+1) y, ?_, ?_, ?_, ?_⟩
            · simpa using hf0
            · simp
            · intro i hi
              by_cases heq : i = n+1
              · simpa [heq] using hy
              · simpa [Function.update_of_ne heq] using hfmem i (by omega)
            · intro i hi
              by_cases heq : i = n
              · subst i
                simp only [Function.update_self, Function.update_of_ne (by omega : n ≠ n+1)]
                intro h
                exact (hmem h).elim
              · have h1 : i+1 ≠ n+1 := by omega
                have h2 : i ≠ n+1 := by omega
                simpa [Function.update_of_ne h1, Function.update_of_ne h2] using hfstep i (by omega)
Function.update_of_ne
Evaluating `Function.update f a' v` at an argument $a \ne a'$ returns the original value $f(a)$.
Function.update_self
Evaluating `Function.update f a v` at the updated index $a$ returns the new value $v$.
path_equal_cardinality_set_selection
Given a sequence of finite sets of equal cardinality and an initial element $x \in P_0$, there exists a selection $f$ starting at $x$ ($f(0) = x$) such that $f(i) \in P_i$ for all $i \le n$, and $f(i+1) \in P_i \implies f(i+1) = f(i)$ for all $i < n$.

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 path_selection_fixed_endpoints {Ω : Type*} [DecidableEq Ω]    (P : ℕ → Finset Ω) (hcard : ∀ i, (P i).card = (P (i+1)).card)    (x : Ω) (hx : x ∈ P 0) (n : ℕ) (y : Ω) (hy : y ∈ P n) :    (∃ f : ℕ → Ω, f 0 = x ∧ f n = y ∧ (∀ i ≤ n, f i ∈ P i) ∧      (∀ i < n, f (i+1) ∈ P i → f (i+1) = f i)) ↔    ((∀ i ≤ n, y ∈ P i) → x = y) := by  classical  constructor  · rintro ⟨f, hf0, hfn, _, hfstep⟩ hall    by_contra hxy    have hprop : ∀ i, i ≤ n → f i ≠ y := by      intro i      induction i with      | zero =>        intro _ h        apply hxy        simpa [hf0] using h      | succ i ih =>        intro hi h        have heq := hfstep i (by omega) (by simpa [h] using hall i (by omega))        exact ih (by omega) (heq.symm.trans h)    exact hprop n (by omega) hfn  · intro hcondition    induction n generalizing y with    | zero =>      have hxy := hcondition (by        intro i hi        have heq : i = 0 := by omega        simpa [heq] using hy)      refine ⟨fun _ => x, rfl, ?_, ?_, ?_⟩      · exact hxy      · intro i hi        have heq : i = 0 := by omega        simpa [heq] using hx      · intro i hi; omega    | succ n ih =>      by_cases hmem : y ∈ P n      · have hcond : (∀ i ≤ n, y ∈ P i) → x = y := by          intro h          apply hcondition          intro i hi          by_cases heq : i = n+1          · simpa [heq] using hy          · exact h i (by omega)        obtain ⟨f, hf0, hfn, hfmem, hfstep⟩ := ih y hmem hcond        refine ⟨Function.update f (n+1) y, ?_, ?_, ?_, ?_⟩        · simpa using hf0        · simp        · intro i hi          by_cases heq : i = n+1          · simpa [heq] using hy          · simpa [Function.update_of_ne heq] using hfmem i (by omega)        · intro i hi          by_cases heq : i = n          · subst i            simp only [Function.update_self, Function.update_of_ne (by omega : n ≠ n+1)]            intro _            exact hfn.symm          · have h1 : i+1 ≠ n+1 := by omega            have h2 : i ≠ n+1 := by omega            simpa [Function.update_of_ne h1, Function.update_of_ne h2] using hfstep i (by omega)      · obtain ⟨f, hf0, hfmem, hfstep⟩ := path_equal_cardinality_set_selection P hcard x hx n        refine ⟨Function.update f (n+1) y, ?_, ?_, ?_, ?_⟩        · simpa using hf0        · simp        · intro i hi          by_cases heq : i = n+1          · simpa [heq] using hy          · simpa [Function.update_of_ne heq] using hfmem i (by omega)        · intro i hi          by_cases heq : i = n          · subst i            simp only [Function.update_self, Function.update_of_ne (by omega : n ≠ n+1)]            intro h            exact (hmem h).elim          · have h1 : i+1 ≠ n+1 := by omega            have h2 : i ≠ n+1 := by omega            simpa [Function.update_of_ne h1, Function.update_of_ne h2] using hfstep i (by omega)
See it in the graphDiscuss this resultChallenge it