AFTD Auto-Formalizing Theoretical Domains

op869_orient_three_color_blocks

theoremverified

For each bipartite block with a three-colored owner and at most one three-colored target of a different color, its two sides can be assigned the two colors different from the owner so that the designated side has the target color when a target exists.

Statement

theorem op869_orient_three_color_blocks {V B : Type} (φ : V → Fin 3) (owner : B → V)
    (target : B → Option V) (selected : B → Bool) :
    (∀ b v, target b = some v → φ v ≠ φ (owner b)) →
    ∃ left right : B → Fin 3, ∀ b,
      left b ≠ φ (owner b) ∧ right b ≠ φ (owner b) ∧ left b ≠ right b ∧
      ∀ v, target b = some v → (if selected b then left b else right b) = φ v
Source
arXiv:2610.41516, Lemma 2.5: reserve disjoint bipartite copies and orient them for an offline three-coloring.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 1

The proof, explained

We first prove an auxiliary lemma: in any three-element set, any two distinct elements leave a third element distinct from both. For each bipartite block, we then choose two distinct colors avoiding the owner: if a target exists, we place its color on the designated side and the third color on the opposite side; if no target exists, any two colors avoiding the owner suffice. Finally, the axiom of choice promotes these pointwise choices to global coloring functions for both sides of all blocks.

  1. In Fin 3, given two distinct elements, there exists a third element distinct from both. automation

    By exhaustive case analysis on all pairs (a, b) in Fin 3 with b ≠ a, arithmetic normalization and the decision procedure find the remaining third color.

    lines 1–3

    lemma op869_third_color_tmp (a b : Fin 3) (h : b ≠ a) :
        ∃ c : Fin 3, c ≠ a ∧ c ≠ b := by
      fin_cases a <;> fin_cases b <;> norm_num at * <;> decide
  2. We assume the hypothesis that any target vertex has a color distinct from its block's owner.

    We enable classical reasoning and introduce the assumption (named h) that for every block b and vertex v, if target(b) = some v, then φ(v) ≠ φ(owner(b)).

    lines 11–12

      classical
      intro h
  3. For any individual block, there exist valid left and right colors satisfying all block-level requirements.

    We reduce the problem of finding global functions to a pointwise statement `local_choice`: for any block b, there exist colors l and r in Fin 3 that are distinct, both differ from φ(owner(b)), and when target(b) is some v, the selected side equals φ(v). We fix an arbitrary block b.

    lines 13–16

      have local_choice : ∀ b : B, ∃ l r : Fin 3,
          l ≠ φ (owner b) ∧ r ≠ φ (owner b) ∧ l ≠ r ∧
          ∀ v, target b = some v → (if selected b then l else r) = φ v := by
        intro b
  4. When the block has no target, two distinct colors different from the owner's color can be chosen. automation

    We consider the case where target(b) is none. By testing all three possible values of the owner's color in Fin 3, we find two distinct colors l and r different from the owner's color. Since there is no target vertex, the target condition holds vacuously.

    lines 17–23

        cases ht : target b with
        | none =>
          have hn : ∃ l r : Fin 3, l ≠ φ (owner b) ∧ r ≠ φ (owner b) ∧ l ≠ r := by
            generalize hcol : φ (owner b) = col
            fin_cases col <;> simp_all <;> decide
          obtain ⟨l, r, hl, hr, hlr⟩ := hn
          exact ⟨l, r, hl, hr, hlr, by simp [ht]⟩
  5. When the block has a target vertex, we obtain a third color distinct from both the owner and the target.

    In the case where target(b) = some v, the hypothesis implies that φ(v) ≠ φ(owner(b)). Applying the helper lemma `op869_third_color_tmp` to the owner's color and the target's color yields a third color c distinct from both.

    lines 24–26

    uses op869_third_color_tmp

        | some v =>
          have hv : φ v ≠ φ (owner b) := h b v ht
          obtain ⟨c, hco, hcv⟩ := op869_third_color_tmp (φ (owner b)) (φ v) hv
  6. If the block selects its right side, we assign the target color to the right and the third color to the left.

    When `selected b` is false, the selected side is the right side. We assign left = c and right = φ(v). Both colors differ from the owner's color and from each other. If target(b) = some w, injectivity of Option.some gives w = v, so the right side correctly matches φ(w).

    lines 27–33

    uses Option.some.inj

          cases hs : selected b with
          | false =>
            refine ⟨c, φ v, hco, hv, hcv, ?_⟩
            intro w hw
            have : w = v := (Option.some.inj hw).symm
            subst w
            simp [hs]
  7. If the block selects its left side, we assign the target color to the left and the third color to the right.

    When `selected b` is true, the selected side is the left side. We assign left = φ(v) and right = c. Both colors differ from the owner's color and from each other (using symmetry of inequality `Ne.symm`). Any target w must equal v by injectivity of Option.some, so the left side matches φ(w).

    lines 34–39

    uses Option.some.inj, Ne.symm

          | true =>
            refine ⟨φ v, c, hv, hco, Ne.symm hcv, ?_⟩
            intro w hw
            have : w = v := (Option.some.inj hw).symm
            subst w
            simp [hs]
  8. By the axiom of choice, the pointwise color choices yield the required global colorings left and right.

    Using the `choose` tactic, we extract global functions left, right : B → Fin 3 from the pointwise existence statement `local_choice`, completing the proof.

    lines 40–41

      choose left right hleft using local_choice
      exact ⟨left, right, hleft⟩
op869_third_color_tmp
In Fin 3, given two distinct elements a and b, there exists a third element c distinct from both a and b.
Option.some.inj
The constructor `some` of Option is injective: if `some x = some y`, then `x = y`.
Ne.symm
Inequality is symmetric: if `a ≠ b`, then `b ≠ a`.

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

lemma op869_third_color_tmp (a b : Fin 3) (h : b ≠ a) :    ∃ c : Fin 3, c ≠ a ∧ c ≠ b := by  fin_cases a <;> fin_cases b <;> norm_num at * <;> decidetheorem op869_orient_three_color_blocks {V B : Type} (φ : V → Fin 3) (owner : B → V)    (target : B → Option V) (selected : B → Bool) :    (∀ b v, target b = some v → φ v ≠ φ (owner b)) →    ∃ left right : B → Fin 3, ∀ b,      left b ≠ φ (owner b) ∧ right b ≠ φ (owner b) ∧ left b ≠ right b ∧      ∀ v, target b = some v → (if selected b then left b else right b) = φ v := by  classical  intro h  have local_choice : ∀ b : B, ∃ l r : Fin 3,      l ≠ φ (owner b) ∧ r ≠ φ (owner b) ∧ l ≠ r ∧      ∀ v, target b = some v → (if selected b then l else r) = φ v := by    intro b    cases ht : target b with    | none =>      have hn : ∃ l r : Fin 3, l ≠ φ (owner b) ∧ r ≠ φ (owner b) ∧ l ≠ r := by        generalize hcol : φ (owner b) = col        fin_cases col <;> simp_all <;> decide      obtain ⟨l, r, hl, hr, hlr⟩ := hn      exact ⟨l, r, hl, hr, hlr, by simp [ht]⟩    | some v =>      have hv : φ v ≠ φ (owner b) := h b v ht      obtain ⟨c, hco, hcv⟩ := op869_third_color_tmp (φ (owner b)) (φ v) hv      cases hs : selected b with      | false =>        refine ⟨c, φ v, hco, hv, hcv, ?_⟩        intro w hw        have : w = v := (Option.some.inj hw).symm        subst w        simp [hs]      | true =>        refine ⟨φ v, c, hv, hco, Ne.symm hcv, ?_⟩        intro w hw        have : w = v := (Option.some.inj hw).symm        subst w        simp [hs]  choose left right hleft using local_choice  exact ⟨left, right, hleft⟩
See it in the graphDiscuss this resultChallenge it