AFTD Auto-Formalizing Theoretical Domains

op874_one_sided_perfect_matching_crosses

theoremverified

For two involutions on a finite set, if the first swaps a Boolean partition and the second sends every false vertex to a true vertex, then the second swaps the partition as well.

Statement

theorem op874_one_sided_perfect_matching_crosses
    {V : Type*} [Fintype V] [DecidableEq V]
    (flag : V → Bool) (mate other : V → V)
    (hmate : ∀ v, mate (mate v) = v)
    (hflip : ∀ v, flag (mate v) = !flag v)
    (hother : ∀ v, other (other v) = v)
    (hone : ∀ v, flag v = false → flag (other v) = true) :
    ∀ v, flag (other v) = !flag v
Source
Structural two-port reduction for OP-874; experiments 43048, 43073 and 43075 test the local-state implications.
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

The proof, explained

The argument partitions the finite set V into the fibers P (where flag is true) and Q (where flag is false). Because the involution mate flips the flag, it provides a bijection between Q and P, showing that |Q| = |P|. The second involution other sends Q to P and is injective, so by equinumerosity it is also surjective from Q onto P. Thus other maps true vertices to false vertices as well, meaning other flips the flag everywhere.

  1. The subsets P = {v | flag v = true} and Q = {v | flag v = false} have the same cardinality.

    We partition V into the fibers P and Q where flag is true and false, respectively. Because the involution mate reverses the flag (hflip), it defines mutually inverse maps between Q and P. This bijection implies |Q| = |P| by Fintype.card_congr.

    lines 9–17

    uses Subtype.ext, Fintype.card_congr

      classical
      let P := {v : V // flag v = true}
      let Q := {v : V // flag v = false}
      let eqv : Q ≃ P :=
        { toFun := fun q => ⟨mate q.1, by simp [hflip, q.2]⟩
          invFun := fun p => ⟨mate p.1, by simp [hflip, p.2]⟩
          left_inv := fun q => Subtype.ext (hmate q.1)
          right_inv := fun p => Subtype.ext (hmate p.1) }
      have hcard : Fintype.card Q = Fintype.card P := Fintype.card_congr eqv
  2. The map f : Q → P defined by f(q) = other(q) is injective.

    By the assumption hone, other maps any vertex in Q into P, defining a function f : Q → P. If f(x) = f(y), then other(x) = other(y) on the underlying vertices. Applying other to both sides and using that other is an involution (hother) yields x = y.

    lines 18–24

    uses Subtype.ext, congrArg, Subtype.val

      let f : Q → P := fun q => ⟨other q.1, hone q.1 q.2⟩
      have hinj : Function.Injective f := by
        intro x y h
        apply Subtype.ext
        have hv : other x.1 = other y.1 := congrArg Subtype.val h
        have hh := congrArg other hv
        simpa [hother] using hh
  3. The map f : Q → P is surjective.

    By Fintype.bijective_iff_injective_and_card, an injective map between finite sets of the same cardinality is bijective, and therefore surjective. Since f is injective and |Q| = |P|, f is surjective.

    lines 25–26

    uses Fintype.bijective_iff_injective_and_card

      have hsurj : Function.Surjective f :=
        ((Fintype.bijective_iff_injective_and_card f).2 ⟨hinj,hcard⟩).2
  4. For any vertex v with flag v = false, other flips the flag: flag (other v) = !flag v.

    We consider an arbitrary vertex v and split into cases on whether flag(v) is false or true. When flag(v) = false, the hypothesis hone directly asserts that flag(other v) = true, which equals !false.

    lines 27–29

      intro v
      cases hv : flag v with
      | false => simpa [hv] using hone v hv
  5. For any vertex v with flag v = true, other flips the flag: flag (other v) = !flag v.

    When flag(v) = true, v belongs to P. By the surjectivity of f, there exists q ∈ Q such that other(q) = v. Since other is an involution (hother), other(v) = q. Because q ∈ Q, its flag is false, which equals !true.

    lines 30–34

    uses congrArg, Subtype.val

      | true =>
        obtain ⟨q,hq⟩ := hsurj ⟨v,hv⟩
        have hvq : other q.1 = v := congrArg Subtype.val hq
        have hqv : other v = q.1 := by rw [←hvq, hother]
        simp [hv, hqv, q.2]
Subtype.ext
Two elements of a subtype are equal if their underlying values are equal.
Fintype.card_congr
If two finite types are in bijection, they have the same cardinality.
congrArg
Applying a function to equal arguments yields equal results (if a₁ = a₂, then f(a₁) = f(a₂)).
Subtype.val
The projection that extracts the underlying value from an element of a subtype.
Fintype.bijective_iff_injective_and_card
A map between finite types of the same cardinality is bijective if and only if it is injective.

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_one_sided_perfect_matching_crosses    {V : Type*} [Fintype V] [DecidableEq V]    (flag : V → Bool) (mate other : V → V)    (hmate : ∀ v, mate (mate v) = v)    (hflip : ∀ v, flag (mate v) = !flag v)    (hother : ∀ v, other (other v) = v)    (hone : ∀ v, flag v = false → flag (other v) = true) :    ∀ v, flag (other v) = !flag v := by  classical  let P := {v : V // flag v = true}  let Q := {v : V // flag v = false}  let eqv : Q ≃ P :=    { toFun := fun q => ⟨mate q.1, by simp [hflip, q.2]⟩      invFun := fun p => ⟨mate p.1, by simp [hflip, p.2]⟩      left_inv := fun q => Subtype.ext (hmate q.1)      right_inv := fun p => Subtype.ext (hmate p.1) }  have hcard : Fintype.card Q = Fintype.card P := Fintype.card_congr eqv  let f : Q → P := fun q => ⟨other q.1, hone q.1 q.2⟩  have hinj : Function.Injective f := by    intro x y h    apply Subtype.ext    have hv : other x.1 = other y.1 := congrArg Subtype.val h    have hh := congrArg other hv    simpa [hother] using hh  have hsurj : Function.Surjective f :=    ((Fintype.bijective_iff_injective_and_card f).2 ⟨hinj,hcard⟩).2  intro v  cases hv : flag v with  | false => simpa [hv] using hone v hv  | true =>    obtain ⟨q,hq⟩ := hsurj ⟨v,hv⟩    have hvq : other q.1 = v := congrArg Subtype.val hq    have hqv : other v = q.1 := by rw [←hvq, hother]    simp [hv, hqv, q.2]
See it in the graphDiscuss this resultChallenge it