AFTD Auto-Formalizing Theoretical Domains

path_selection_endpoint_sets

theoremverified

For equal-size finite palettes along a path and nonempty allowed starting set A, an endpoint-constrained selection exists precisely when an allowed final color is either also allowed initially or disappears from some palette along the path.

Statement

theorem path_selection_endpoint_sets {Ω : Type*} [DecidableEq Ω]
    (P : ℕ → Finset Ω) (hcard : ∀ i, (P i).card = (P (i+1)).card)
    (n : ℕ) (A B : Finset Ω) (hA : A.Nonempty)
    (hA0 : A ⊆ P 0) (hBn : B ⊆ P n) :
    (∃ f : ℕ → Ω, f 0 ∈ A ∧ f n ∈ B ∧ (∀ i ≤ n, f i ∈ P i) ∧
      (∀ i < n, f (i+1) ∈ P i → f (i+1) = f i)) ↔
    (∃ y ∈ B, y ∈ A ∨ ∃ i ≤ n, y ∉ P i)
Source
Endpoint-list criterion for the half-edge path reduction in OP-874.
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • path_selection_fixed_endpointsFor 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…

The proof, explained

The equivalence is proved by reducing the existence of an endpoint-constrained selection to the fixed-endpoints theorem path_selection_fixed_endpoints, which states that a valid selection connecting x to y exists if and only if y belonging to every palette along the path forces x = y. In the forward direction, given a selection f, we choose y = f(n) ∈ B; if y ∉ A, then y cannot belong to all palettes, as the fixed-endpoints theorem would force f(0) = f(n) = y, a contradiction. In the reverse direction, we pick an element a ∈ A from the nonempty set A: if y ∈ A we connect y to itself (which trivially satisfies the condition), and if y is missing from some palette, the condition holds vacuously, allowing us to connect a to y.

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

    Enable classical logic and split the "if and only if" goal into two directions: showing that the existence of a valid endpoint-constrained selection implies the existence of a suitable y ∈ B, and conversely that such a y allows one to construct a valid selection.

    lines 8–9

      classical
      constructor
  2. In the forward direction, given a valid selection f, we set y = f(n) ∈ B; if f(n) ∈ A, the conclusion holds immediately.

    Assume a valid selection f exists, with f(0) ∈ A and f(n) ∈ B. We choose y = f(n), which belongs to B by assumption. We split into cases on whether f(n) ∈ A. If it is, the first disjunct of the conclusion holds directly via Or.inl.

    lines 10–13

    uses Or.inl

      · rintro ⟨f, hfA, hfB, hfmem, hfstep⟩
        refine ⟨f n, hfB, ?_⟩
        by_cases h : f n ∈ A
        · exact Or.inl h
  3. If f(n) ∉ A, then f(n) must be absent from at least one palette along the path.

    In the remaining case f(n) ∉ A, we argue by contradiction to establish that f(n) ∉ P i for some i ≤ n. If f(n) were in P i for every i ≤ n, then applying the forward direction of path_selection_fixed_endpoints to f would force f(0) = f(n). Since f(0) ∈ A, this would imply f(n) ∈ A, directly contradicting the case hypothesis f(n) ∉ A.

    lines 14–23

    uses path_selection_fixed_endpoints

        · right
          by_contra hnone
          have hall : ∀ i ≤ n, f n ∈ P i := by
            intro i hi
            by_contra hni
            exact hnone ⟨i, hi, hni⟩
          have hxy : f 0 = f n :=
            (path_selection_fixed_endpoints P hcard (f 0) (hA0 hfA) n (f n)
              (hBn hfB)).1 ⟨f, rfl, rfl, hfmem, hfstep⟩ hall
          exact h (hxy ▸ hfA)
  4. For the reverse direction, fix an arbitrary starting element a ∈ A and case-split on whether the given y ∈ B is in A or missing from some palette.

    Assume there exists y ∈ B such that y ∈ A or y ∉ P i for some i ≤ n. Because A is nonempty, we can choose an element a ∈ A. We then branch on whether y ∈ A or y ∉ P i for some i ≤ n.

    lines 24–26

      · rintro ⟨y, hyB, hy⟩
        obtain ⟨a, ha⟩ := hA
        rcases hy with hyA | ⟨i, hi, hni⟩
  5. If y ∈ A, there exists a valid selection starting and ending at y.

    When y ∈ A, we have y ∈ P 0 (since A ⊆ P 0) and y ∈ P n (since B ⊆ P n). The condition (∀ i ≤ n, y ∈ P i) → y = y holds trivially by reflexivity. By path_selection_fixed_endpoints, there exists a valid selection f with f(0) = y ∈ A and f(n) = y ∈ B.

    lines 27–29

    uses path_selection_fixed_endpoints

        · obtain ⟨f, hf0, hfn, hfmem, hfstep⟩ :=
            (path_selection_fixed_endpoints P hcard y (hA0 hyA) n y (hBn hyB)).2 (by intro; rfl)
          exact ⟨f, by simpa [hf0] using hyA, by simpa [hfn] using hyB, hfmem, hfstep⟩
  6. If y ∉ P i for some i ≤ n, there exists a valid selection starting at a and ending at y.

    When y ∉ P i for some i ≤ n, the hypothesis that y belongs to every palette along the path is false. Thus the implication (∀ i ≤ n, y ∈ P i) → a = y holds vacuously. Applying path_selection_fixed_endpoints with endpoints a ∈ P 0 and y ∈ P n produces a valid selection f with f(0) = a ∈ A and f(n) = y ∈ B.

    lines 30–33

    uses path_selection_fixed_endpoints

        · obtain ⟨f, hf0, hfn, hfmem, hfstep⟩ :=
            (path_selection_fixed_endpoints P hcard a (hA0 ha) n y (hBn hyB)).2
              (by intro hall; exact (hni (hall i hi)).elim)
          exact ⟨f, by simpa [hf0] using ha, by simpa [hfn] using hyB, hfmem, hfstep⟩
Or.inl
Constructs a proof of the disjunction a ∨ b from a proof of the left disjunct a.
path_selection_fixed_endpoints
For equal-size palettes along a path, a valid step-conserving selection from x ∈ P 0 to y ∈ P n exists if and only if the condition that y remains in all palettes along the path implies x = y.

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_endpoint_sets {Ω : Type*} [DecidableEq Ω]    (P : ℕ → Finset Ω) (hcard : ∀ i, (P i).card = (P (i+1)).card)    (n : ℕ) (A B : Finset Ω) (hA : A.Nonempty)    (hA0 : A ⊆ P 0) (hBn : B ⊆ P n) :    (∃ f : ℕ → Ω, f 0 ∈ A ∧ f n ∈ B ∧ (∀ i ≤ n, f i ∈ P i) ∧      (∀ i < n, f (i+1) ∈ P i → f (i+1) = f i)) ↔    (∃ y ∈ B, y ∈ A ∨ ∃ i ≤ n, y ∉ P i) := by  classical  constructor  · rintro ⟨f, hfA, hfB, hfmem, hfstep⟩    refine ⟨f n, hfB, ?_⟩    by_cases h : f n ∈ A    · exact Or.inl h    · right      by_contra hnone      have hall : ∀ i ≤ n, f n ∈ P i := by        intro i hi        by_contra hni        exact hnone ⟨i, hi, hni⟩      have hxy : f 0 = f n :=        (path_selection_fixed_endpoints P hcard (f 0) (hA0 hfA) n (f n)          (hBn hfB)).1 ⟨f, rfl, rfl, hfmem, hfstep⟩ hall      exact h (hxy ▸ hfA)  · rintro ⟨y, hyB, hy⟩    obtain ⟨a, ha⟩ := hA    rcases hy with hyA | ⟨i, hi, hni⟩    · obtain ⟨f, hf0, hfn, hfmem, hfstep⟩ :=        (path_selection_fixed_endpoints P hcard y (hA0 hyA) n y (hBn hyB)).2 (by intro; rfl)      exact ⟨f, by simpa [hf0] using hyA, by simpa [hfn] using hyB, hfmem, hfstep⟩    · obtain ⟨f, hf0, hfn, hfmem, hfstep⟩ :=        (path_selection_fixed_endpoints P hcard a (hA0 ha) n y (hBn hyB)).2          (by intro hall; exact (hni (hall i hi)).elim)      exact ⟨f, by simpa [hf0] using ha, by simpa [hfn] using hyB, hfmem, hfstep⟩
See it in the graphDiscuss this resultChallenge it