AFTD Auto-Formalizing Theoretical Domains

op874_bad_matching_ports_force_factor_matching

theoremverified

In a finite set with two distinct symmetric factor neighbors per vertex, a class-switching matching involution, and an ownership map, suppose every false vertex owns a factor neighbor and every true vertex is owned by a false vertex. Then the undirected factor edges owned at one endpoint form a perfect matching.

Statement

theorem op874_bad_matching_ports_force_factor_matching {V : Type*} [Fintype V] [DecidableEq V]
    (flag : V → Bool) (mate own : V → V) (step : V → Fin 2 → V)
    (hmate : ∀ v, mate (mate v) = v)
    (hflip : ∀ v, flag (mate v) = !flag v)
    (hcover : ∀ p, flag p = true → ∃ q, flag q = false ∧ own q = p)
    (howneradj : ∀ q, flag q = false → ∃ i, step q i = own q)
    (hsym : ∀ v i, ∃ j, step (step v i) j = v)
    (hdist : ∀ v, step v 0 ≠ step v 1) :
    ∀ v, ∃! i, (flag v = false ∧ own v = step v i) ∨
      (flag (step v i) = false ∧ own (step v i) = v)
Source
Structural reduction for the exact-owner global-pair route to OP-874; experiment 43048 tests the hypotheses.
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 1

The proof, explained

The theorem shows that the undirected factor edges owned by their false endpoints form a 1-factor (a perfect matching). First, an established lemma shows that ownership restricts to a bijection from false vertices to true vertices, and factor stepping is verified to be injective on ports {0, 1}. The proof then splits on the flag of an arbitrary vertex v: if v is false, it owns a unique factor neighbor and cannot be owned by another false neighbor; if v is true, it is owned by a unique false vertex q, which is adjacent to v, and symmetry provides a unique return port from v to q.

  1. Ownership maps false vertices injectively to true vertices, and we fix an arbitrary vertex v.

    By op874_opposite_paired_cover_is_bijective, using the flag-reversing matching involution (hmate, hflip) and the assumption that every true vertex is owned (hcover), the ownership map own sends false vertices to true vertices and is injective on false vertices. We then fix an arbitrary vertex v.

    lines 11–13

    uses op874_opposite_paired_cover_is_bijective

      classical
      have hb := op874_opposite_paired_cover_is_bijective flag mate own hmate hflip hcover
      intro v
  2. For each vertex v, the port-stepping map i ↦ step v i from Fin 2 to V is injective.

    Let i, j ∈ {0, 1} with step v i = step v j. Exhaustive case analysis on {0, 1} shows that if i = j the equality is reflexivity, while if i ≠ j, we obtain step v 0 = step v 1, directly contradicting the hypothesis hdist that the two factor neighbors are distinct. False.elim derives the conclusion from this contradiction.

    lines 14–20

    uses False.elim

      have hinjstep : Function.Injective (step v) := by
        intro i j h
        fin_cases i <;> fin_cases j
        · rfl
        · exact False.elim (hdist v h)
        · exact False.elim (hdist v h.symm)
        · rfl
  3. When flag v = false, there exists a port i along which v owns its neighbor.

    We split into cases on whether flag v is false or true. When flag v = false, hypothesis howneradj guarantees that v owns one of its factor neighbors, so step v i = own v for some port i ∈ {0, 1}. This satisfies the first disjunct using Or.inl, leaving uniqueness to be proved.

    lines 21–24

    uses Or.inl

      cases hv : flag v with
      | false =>
        obtain ⟨i, hi⟩ := howneradj v hv
        refine ⟨i, Or.inl ⟨rfl, hi.symm⟩, ?_⟩
  4. When flag v = false, the port i at v is unique.

    Suppose another port j satisfies the disjunction. If the first branch holds, step v j = own v. If the second branch were to hold, step v j would be a false vertex that owns v; but by the bijectivity result (hb), the owner of any false vertex has a true flag, contradicting flag v = false. Thus step v j = own v = step v i, and injectivity of step v ensures j = i.

    lines 25–33

        intro j hj
        have hstep : step v j = own v := by
          rcases hj with ⟨_, h⟩ | ⟨hf, ho⟩
          · exact h.symm
          · have ht := (hb (step v j) hf).1
            rw [ho, hv] at ht
            contradiction
        have heq : step v j = step v i := hstep.trans hi.symm
        exact hinjstep heq
  5. When flag v = true, there exists a port j along which the neighbor is false and owns v.

    When flag v = true, hypothesis hcover provides a false vertex q that owns v. By howneradj, q owns one of its factor neighbors, so step q i = own q = v for some port i. Factor edge symmetry (hsym) provides a return port j such that step v j = q. Since q is false and owns v, this port j satisfies the second disjunct using Or.inr, leaving uniqueness to be proved.

    lines 34–40

    uses Or.inr

      | true =>
        obtain ⟨q, hq, hqown⟩ := hcover v hv
        obtain ⟨i, hi⟩ := howneradj q hq
        have hi' : step q i = v := hi.trans hqown
        obtain ⟨j, hj⟩ := hsym q i
        rw [hi'] at hj
        refine ⟨j, Or.inr ⟨hj ▸ hq, by rw [hj]; exact hqown⟩, ?_⟩
  6. When flag v = true, the port j at v is unique.

    Suppose another port k satisfies the disjunction. The first branch requires flag v = false, contradicting flag v = true. Thus the second branch must hold, so step v k is a false vertex owning v. Since q is also a false vertex owning v, the injectivity of own on false vertices (from hb) implies step v k = q. Since step v j = q as well, step v k = step v j, and injectivity of step v yields k = j.

    lines 41–49

        intro k hk
        have hkq : step v k = q := by
          rcases hk with ⟨hf, _⟩ | ⟨hf, ho⟩
          · contradiction
          · symm
            apply (hb (step v k) hf).2 q hq
            exact hqown.trans ho.symm
        have heq : step v k = step v j := hkq.trans hj.symm
        exact hinjstep heq
op874_opposite_paired_cover_is_bijective
Under a flag-reversing involution, if every true vertex is owned by some false vertex, then the ownership map sends every false vertex to a true vertex and is injective on false vertices.
False.elim
From a contradiction (a proof of False), any proposition can be deduced (the principle of explosion).
Or.inl
Constructs a proof of A ∨ B from a proof of the left disjunct A.
Or.inr
Constructs a proof of A ∨ B from a proof of the right disjunct B.

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_bad_matching_ports_force_factor_matching {V : Type*} [Fintype V] [DecidableEq V]    (flag : V → Bool) (mate own : V → V) (step : V → Fin 2 → V)    (hmate : ∀ v, mate (mate v) = v)    (hflip : ∀ v, flag (mate v) = !flag v)    (hcover : ∀ p, flag p = true → ∃ q, flag q = false ∧ own q = p)    (howneradj : ∀ q, flag q = false → ∃ i, step q i = own q)    (hsym : ∀ v i, ∃ j, step (step v i) j = v)    (hdist : ∀ v, step v 0 ≠ step v 1) :    ∀ v, ∃! i, (flag v = false ∧ own v = step v i) ∨      (flag (step v i) = false ∧ own (step v i) = v) := by  classical  have hb := op874_opposite_paired_cover_is_bijective flag mate own hmate hflip hcover  intro v  have hinjstep : Function.Injective (step v) := by    intro i j h    fin_cases i <;> fin_cases j    · rfl    · exact False.elim (hdist v h)    · exact False.elim (hdist v h.symm)    · rfl  cases hv : flag v with  | false =>    obtain ⟨i, hi⟩ := howneradj v hv    refine ⟨i, Or.inl ⟨rfl, hi.symm⟩, ?_⟩    intro j hj    have hstep : step v j = own v := by      rcases hj with ⟨_, h⟩ | ⟨hf, ho⟩      · exact h.symm      · have ht := (hb (step v j) hf).1        rw [ho, hv] at ht        contradiction    have heq : step v j = step v i := hstep.trans hi.symm    exact hinjstep heq  | true =>    obtain ⟨q, hq, hqown⟩ := hcover v hv    obtain ⟨i, hi⟩ := howneradj q hq    have hi' : step q i = v := hi.trans hqown    obtain ⟨j, hj⟩ := hsym q i    rw [hi'] at hj    refine ⟨j, Or.inr ⟨hj ▸ hq, by rw [hj]; exact hqown⟩, ?_⟩    intro k hk    have hkq : step v k = q := by      rcases hk with ⟨hf, _⟩ | ⟨hf, ho⟩      · contradiction      · symm        apply (hb (step v k) hf).2 q hq        exact hqown.trans ho.symm    have heq : step v k = step v j := hkq.trans hj.symm    exact hinjstep heq
See it in the graphDiscuss this resultChallenge it