AFTD Auto-Formalizing Theoretical Domains

op874_local_cut_three_difference_labels

theoremverified

For a simple cubic graph and a locally maximal cut constant on perfect-matching pairs, its vertices admit three labels that differ across every matching edge and every same-bit factor edge.

Statement

theorem op874_local_cut_three_difference_labels {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) [DecidableRel G.Adj] (hcubic : G.IsRegularOfDegree 3) (M : Finset (Sym2 V)) (hsub : M ⊆ G.edgeFinset) (hperfect : ∀ v : V, ∃! e : Sym2 V, e ∈ M ∧ v ∈ e) (b : V → Bool) (hmatching : ∀ u v, G.Adj u v → s(u,v) ∈ M → b u = b v) (hcut : ∀ u v, G.Adj u v → s(u,v) ∈ M → ((G.neighborFinset u).filter fun w => b w = b u ∧ s(u,w) ∉ M).card + ((G.neighborFinset v).filter fun w => b w = b v ∧ s(v,w) ∉ M).card ≤ 2) : ∃ d : V → Fin 3, ∀ u v, G.Adj u v → (s(u,v) ∈ M ∨ b u = b v) → d u ≠ d v
Source
OP-874: three labels on matching edges and same-bit factor edges of a locally maximal cut
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

The proof, explained

To construct a 3-labeling that separates matching edges and same-bit factor edges, we define a conflict relation R containing all such edges and apply greedy coloring (degeneracy). Any graph where every nonempty induced subgraph has a vertex of degree strictly less than 3 is 3-colorable by strong induction on the vertex set. In a cubic graph, if an induced subgraph had minimum R-degree at least 3, a vertex u would have all 3 neighbors in the subgraph, forcing its matching partner v into the subgraph as well; the local cut condition then forces u to saturate the same-bit budget, leaving v with at most 1 conflict neighbor in the subgraph, a contradiction.

  1. Every vertex v belongs to a unique matching edge e = s(x, z) connecting two distinct vertices x ≠ z

    By the perfect matching hypothesis hperfect, there is a unique edge e in M containing v. Since M ⊆ E(G), e is an edge of the simple graph G, so representing e as an unordered pair s(x, z) gives x ≠ z, with v equal to x or z.

    lines 6–12

    uses SimpleGraph.mem_edgeFinset, Quot.exists_rep, Sym2.mem_iff

      obtain ⟨e, ⟨heM, hve⟩, heuniq⟩ := hperfect v
      have he_adj : e ∈ G.edgeFinset := hsub heM
      rw [SimpleGraph.mem_edgeFinset] at he_adj
      obtain ⟨⟨x, z⟩, rfl⟩ := Quot.exists_rep e
      rw [Sym2.mem_iff] at hve
      have hne : x ≠ z := G.ne_of_adj he_adj
      cases hve with
  2. For every vertex v, there is a unique vertex u such that s(v, u) ∈ M

    We split into cases on whether v = x or v = z. If v = x, the candidate mate is z; any mate u with s(v, u) ∈ M forces s(v, u) = s(v, z) by uniqueness of e, so either u = z or u = v, and the latter contradicts x ≠ z. The case v = z is symmetric with mate x, using the symmetry of unordered pairs (Sym2.eq_swap).

    lines 13–33

    uses Sym2.mem_mk_left, Sym2.eq_iff, Sym2.eq_swap

      | inl hvx =>
        subst hvx
        refine ⟨z, heM, ?_⟩
        intro u hu
        have hu_in : v ∈ s(v, u) := Sym2.mem_mk_left v u
        have h_eq := heuniq s(v, u) ⟨hu, hu_in⟩
        rw [Sym2.eq_iff] at h_eq
        rcases h_eq with (⟨_, rfl⟩ | ⟨rfl, _⟩)
        · rfl
        · exact (hne rfl).elim
      | inr hvz =>
        subst hvz
        have heM' : s(v, x) ∈ M := by rwa [Sym2.eq_swap]
        refine ⟨x, heM', ?_⟩
        intro u hu
        have hu_in : v ∈ s(v, u) := Sym2.mem_mk_left v u
        have h_eq := heuniq s(v, u) ⟨hu, hu_in⟩
        rw [Sym2.eq_iff] at h_eq
        rcases h_eq with (⟨rfl, _⟩ | ⟨_, rfl⟩)
        · exact (hne.symm rfl).elim
        · rfl
  3. If every vertex in a nonempty set s had at least 3 conflict neighbors in s, then for any u ∈ s, all graph neighbors of u would lie in s and be conflict neighbors

    Assume for contradiction that every vertex in s has at least 3 neighbors in s under the conflict relation R(u, w) (holding when u ~ w and either s(u, w) ∈ M or b(u) = b(w)). For any u ∈ s, its R-neighbors in s form a subset of its graph neighborhood N_G(u). Because G is cubic, |N_G(u)| = 3, so a subset of size at least 3 must equal N_G(u).

    lines 45–57

    uses Finset.mem_filter, SimpleGraph.mem_neighborFinset, Finset.eq_of_subset_of_card_le

      let R := fun u v => G.Adj u v ∧ (s(u,v) ∈ M ∨ b u = b v)
      change ∃ v ∈ s, (s.filter (R v)).card < 3
      by_contra! hall
      obtain ⟨u, hu⟩ := hs
      have hcard_u := hall u hu
      have hsub_u : s.filter (R u) ⊆ G.neighborFinset u := by
        intro w hw
        rw [Finset.mem_filter] at hw
        exact (SimpleGraph.mem_neighborFinset G u w).mpr hw.2.1
      have hdeg_u : (G.neighborFinset u).card = 3 := hcubic u
      have heq_u : s.filter (R u) = G.neighborFinset u := by
        apply Finset.eq_of_subset_of_card_le hsub_u
        omega
  4. The matching mate v of u belongs to s, so v also has at least 3 conflict neighbors in s

    By uniqueness of matching partners (op874_local_cut_three_difference_labels_mate_unique), u has a unique partner v with s(u, v) ∈ M. Since M ⊆ E(G), v is a graph neighbor of u, hence belongs to N_G(u) = s ∩ R(u), which places v in s. The contradiction hypothesis applied to v then implies that v has at least 3 R-neighbors in s.

    lines 58–66

    uses op874_local_cut_three_difference_labels_mate_unique, SimpleGraph.mem_edgeFinset.mp, SimpleGraph.mem_neighborFinset, Finset.mem_filter.mp

      obtain ⟨v, hvuM, hvuniq⟩ := op874_local_cut_three_difference_labels_mate_unique G M hsub hperfect u
      have hadj_uv : G.Adj u v := SimpleGraph.mem_edgeFinset.mp (hsub hvuM)
      have hvin : v ∈ G.neighborFinset u := (SimpleGraph.mem_neighborFinset G u v).mpr hadj_uv
      have hvs : v ∈ s := by
        have : v ∈ s.filter (R u) := by
          rw [heq_u]
          exact hvin
        exact (Finset.mem_filter.mp this).1
      have hcard_v := hall v hvs
  5. All non-matching neighbors of u share the bit of u, so by the local cut condition v has no same-bit non-matching neighbors (|F_v| = 0)

    Let F_u be the set of graph neighbors w of u with b(w) = b(u) and s(u, w) ∉ M, and define F_v analogously for v. The local cut condition gives |F_u| + |F_v| ≤ 2. Since every neighbor w of u belongs to s ∩ R(u), any w ≠ v cannot be matched to u (v being unique), forcing b(w) = b(u), so N_G(u) \ {v} ⊆ F_u. Since u has 3 neighbors, |N_G(u) \ {v}| = 2, so |F_u| ≥ 2, which forces |F_v| = 0 by linear arithmetic.

    lines 67–90

    uses Finset.mem_erase, Finset.mem_filter, Finset.mem_filter.mp, Finset.card_erase_of_mem, Finset.card_le_card

      let Fu := (G.neighborFinset u).filter fun w => b w = b u ∧ s(u,w) ∉ M
      let Fv := (G.neighborFinset v).filter fun w => b w = b v ∧ s(v,w) ∉ M
      have hcut_uv : Fu.card + Fv.card ≤ 2 := hcut u v hadj_uv hvuM
      have hsub_Fu : (G.neighborFinset u).erase v ⊆ Fu := by
        intro w hw
        rw [Finset.mem_erase] at hw
        rw [Finset.mem_filter]
        refine ⟨hw.2, ⟨?_, ?_⟩⟩
        · have hw_in : w ∈ s.filter (R u) := by
            rw [heq_u]
            exact hw.2
          have hw_R := (Finset.mem_filter.mp hw_in).2.2
          rcases hw_R with (hwM | hwb)
          · exfalso
            exact hw.1 (hvuniq w hwM)
          · exact hwb.symm
        · intro hwM
          exact hw.1 (hvuniq w hwM)
      have hcard_Fu : 2 ≤ Fu.card := by
        have h_erase : ((G.neighborFinset u).erase v).card = 2 := by
          rw [Finset.card_erase_of_mem hvin, hdeg_u]
        rw [← h_erase]
        exact Finset.card_le_card hsub_Fu
      have hFv_zero : Fv.card = 0 := by omega
  6. The vertex v has at most one conflict neighbor in s (namely u), contradicting that it has at least 3

    For any w ∈ s with R(v, w), either s(v, w) ∈ M (which forces w = u by uniqueness of the mate of v) or b(v) = b(w). The latter case would put w in F_v, which is impossible since |F_v| = 0. Therefore s ∩ R(v) ⊆ {u}, so |s ∩ R(v)| ≤ 1, contradicting |s ∩ R(v)| ≥ 3.

    lines 91–115

    uses Finset.mem_filter, Finset.mem_singleton, SimpleGraph.mem_neighborFinset, Sym2.eq_swap, op874_local_cut_three_difference_labels_mate_unique, Finset.card_eq_zero.mp, Finset.notMem_empty, Finset.card_le_card, Finset.card_singleton

      have hsub_v : s.filter (R v) ⊆ {u} := by
        intro w hw
        rw [Finset.mem_filter] at hw
        rw [Finset.mem_singleton]
        have hw_adj : w ∈ G.neighborFinset v := (SimpleGraph.mem_neighborFinset G v w).mpr hw.2.1
        have hvu_swap : s(v, u) ∈ M := by rwa [Sym2.eq_swap]
        obtain ⟨u', hvu'M, hu'uniq⟩ := op874_local_cut_three_difference_labels_mate_unique G M hsub hperfect v
        have hu'_eq : u = u' := hu'uniq u hvu_swap
        by_cases hwM : s(v, w) ∈ M
        · have hw_eq : w = u' := hu'uniq w hwM
          subst hu'_eq hw_eq
          rfl
        · exfalso
          rcases hw.2.2 with (hwM' | hwb)
          · exact hwM hwM'
          · have : w ∈ Fv := by
              rw [Finset.mem_filter]
              exact ⟨hw_adj, ⟨hwb.symm, hwM⟩⟩
            have h_empty : Fv = ∅ := Finset.card_eq_zero.mp hFv_zero
            rw [h_empty] at this
            exact Finset.notMem_empty w this
      have hcard_le_1 : (s.filter (R v)).card ≤ 1 := by
        calc (s.filter (R v)).card ≤ ({u} : Finset V).card := Finset.card_le_card hsub_v
        _ = 1 := Finset.card_singleton u
      omega
  7. By strong induction on |s|, when s is nonempty we pick a vertex v ∈ s with < 3 conflict neighbors and properly 3-color s \ {v}

    We proceed by strong induction on |s|. When s is nonempty, the hypothesis hdeg provides a vertex v ∈ s with strictly fewer than 3 R-neighbors in s. Erasing v strictly decreases cardinality, so the inductive hypothesis yields a proper 3-coloring d' on s \ {v}.

    lines 123–129

    uses Nat.strong_induction_on, Finset.card_erase_lt_of_mem

      induction' hn : s.card using Nat.strong_induction_on with n ih generalizing s
      by_cases hs : s.Nonempty
      · obtain ⟨v, hv, hcard⟩ := hdeg s hs
        have hlt : (s.erase v).card < n := by
          rw [← hn]
          exact Finset.card_erase_lt_of_mem hv
        obtain ⟨d', hd'⟩ := ih (s.erase v).card hlt (s.erase v) rfl
  8. There exists an available color in Fin 3 that does not appear on any conflict neighbor of v in s

    The forbidden colors for v are the d'-images of its R-neighbors in s. The image size is at most the number of R-neighbors, which is strictly less than 3, so at most 2 colors are forbidden. Since Fin 3 has 3 colors, by comparing cardinalities there must exist at least one color c ∉ forbidden.

    lines 130–142

    uses Finset.card_image_le, Finset.card_le_card, Finset.card_univ, Fintype.card_fin

        let forbidden : Finset (Fin 3) := (s.filter (R v)).image d'
        have hforb : forbidden.card < 3 := by
          calc forbidden.card ≤ (s.filter (R v)).card := Finset.card_image_le
          _ < 3 := hcard
        have hex : ∃ c : Fin 3, c ∉ forbidden := by
          by_contra! hall
          have hle : (Finset.univ : Finset (Fin 3)).card ≤ forbidden.card := by
            apply Finset.card_le_card
            intro x _
            exact hall x
          rw [Finset.card_univ, Fintype.card_fin] at hle
          omega
        obtain ⟨c, hc⟩ := hex
  9. Assigning color c to v and d' to all other vertices yields a valid 3-coloring on all of s

    We extend d' by setting d(v) = c and d(x) = d'(x) for x ≠ v. For any conflict edge R(u, w) with u, w ∈ s: irreflexivity rules out u = w = v; if one endpoint is v and the other is not, c was chosen to differ from the color of that neighbor; and if neither endpoint is v, they differ by the induction hypothesis on d'.

    lines 143–172

    uses if_pos, if_neg, Finset.mem_image, Finset.mem_filter, Finset.mem_erase

        use fun x => if x = v then c else d' x
        intro u hu w hw hRuw
        dsimp only
        by_cases hu_eq : u = v
        · by_cases hw_eq : w = v
          · rw [hu_eq, hw_eq] at hRuw
            exact (hirr _ hRuw).elim
          · rw [if_pos hu_eq, if_neg hw_eq]
            subst hu_eq
            intro h_eq
            apply hc
            rw [Finset.mem_image]
            refine ⟨w, ?_, h_eq.symm⟩
            rw [Finset.mem_filter]
            exact ⟨hw, hRuw⟩
        · by_cases hw_eq : w = v
          · rw [if_neg hu_eq, if_pos hw_eq]
            subst hw_eq
            intro h_eq
            apply hc
            rw [Finset.mem_image]
            refine ⟨u, ?_, h_eq⟩
            rw [Finset.mem_filter]
            exact ⟨hu, hR u w hRuw⟩
          · rw [if_neg hu_eq, if_neg hw_eq]
            apply hd' u _ w _ hRuw
            · rw [Finset.mem_erase]
              exact ⟨hu_eq, hu⟩
            · rw [Finset.mem_erase]
              exact ⟨hw_eq, hw⟩
  10. If s is empty, the constant coloring vacuously satisfies the condition

    When s = ∅, there are no vertices in s, so the non-monochromatic condition holds vacuously for the constant zero coloring.

    lines 173–177

    uses Finset.nonempty_iff_ne_empty, not_not

      · rw [Finset.nonempty_iff_ne_empty, not_not] at hs
        subst hs
        use fun _ => 0
        intro u hu
        simp at hu
  11. The conflict relation R is symmetric, irreflexive, and every nonempty subset contains a vertex of degree < 3

    We define R(u, v) as G.Adj u v ∧ (s(u,v) ∈ M ∨ b u = b v). Symmetry follows from the symmetry of graph adjacency, unordered pairs, and equality of bits. Irreflexivity holds because simple graphs have no loops. The sub-degree-3 property for any nonempty subset s is provided by op874_local_cut_three_difference_labels_deg_lt_three.

    lines 180–193

    uses Sym2.eq_swap, Or.inl, Or.inr, op874_local_cut_three_difference_labels_deg_lt_three

      let R := fun u v => G.Adj u v ∧ (s(u,v) ∈ M ∨ b u = b v)
      have hR_symm : ∀ u v, R u v → R v u := by
        intro u v ⟨hadj, hcase⟩
        refine ⟨hadj.symm, ?_⟩
        rcases hcase with (hM | hb)
        · rw [Sym2.eq_swap]
          exact Or.inl hM
        · exact Or.inr hb.symm
      have hR_irr : ∀ v, ¬ R v v := by
        intro v ⟨hadj, _⟩
        exact G.ne_of_adj hadj rfl
      have hdeg : ∀ s : Finset V, s.Nonempty → ∃ v ∈ s, (s.filter (R v)).card < 3 := by
        intro s hs
        exact op874_local_cut_three_difference_labels_deg_lt_three G hcubic M hsub hperfect b hcut s hs
  12. The whole vertex set admits a 3-labeling differing across all matching edges and all same-bit factor edges

    Applying op874_local_cut_three_difference_labels_exists_coloring to the conflict relation R on the universal finset of all vertices produces a coloring d : V → Fin 3. Any edge that belongs to M or connects vertices with the same bit satisfies R, so its endpoints receive distinct colors under d.

    lines 194–197

    uses op874_local_cut_three_difference_labels_exists_coloring, Finset.mem_univ

      obtain ⟨d, hd⟩ := op874_local_cut_three_difference_labels_exists_coloring R hR_symm hR_irr hdeg Finset.univ
      use d
      intro u v hadj hM_or_b
      exact hd u (Finset.mem_univ u) v (Finset.mem_univ v) ⟨hadj, hM_or_b⟩
SimpleGraph.mem_edgeFinset
an edge is in the edge finset of a graph if and only if it belongs to the graph's edge set
Quot.exists_rep
every element of a quotient type is represented by some underlying element
Sym2.mem_iff
an element belongs to an unordered pair s(b, c) if and only if it equals b or c
Sym2.mem_mk_left
x is an element of the unordered pair s(x, y)
Sym2.eq_iff
two unordered pairs are equal if and only if their elements match in the same or reversed order
Sym2.eq_swap
an unordered pair is invariant under swapping its elements: s(a, b) = s(b, a)
Finset.mem_filter
an element is in a filtered finset if and only if it is in the finset and satisfies the predicate
Finset.mem_filter.mp
if an element is in a filtered finset, it is in the finset and satisfies the predicate
SimpleGraph.mem_neighborFinset
a vertex belongs to the neighbor finset of v if and only if it is adjacent to v
Finset.eq_of_subset_of_card_le
a subset of a finset is equal to the finset if its cardinality is at least that of the finset
op874_local_cut_three_difference_labels_mate_unique
in a graph with a perfect matching, every vertex has a unique matching partner
SimpleGraph.mem_edgeFinset.mp
an edge in the edge finset of a graph is an edge of the graph
Finset.mem_erase
an element belongs to s.erase b if and only if it is in s and not equal to b
Finset.card_erase_of_mem
erasing an element from a finset decreases its cardinality by 1
Finset.card_le_card
if s is a subset of t, the cardinality of s is at most that of t
Finset.mem_singleton
an element belongs to the singleton {a} if and only if it equals a
Finset.card_eq_zero.mp
a finset with cardinality 0 is the empty set
Finset.notMem_empty
no element belongs to the empty finset
Finset.card_singleton
the cardinality of any singleton finset is 1
Nat.strong_induction_on
the principle of strong induction on natural numbers
Finset.card_erase_lt_of_mem
erasing an element of a finset strictly decreases its cardinality
Finset.card_image_le
the image of a finset under a function has cardinality at most that of the finset
Finset.card_univ
the cardinality of the universal finset of a finite type equals the cardinality of the type
Fintype.card_fin
the cardinality of Fin n is n
if_pos
if a condition holds, an if-then-else expression evaluates to the then-branch
if_neg
if a condition is false, an if-then-else expression evaluates to the else-branch
Finset.mem_image
an element is in the image of a finset under f if and only if it is the image of some element of the finset
Finset.nonempty_iff_ne_empty
a finset is nonempty if and only if it is not equal to the empty set
not_not
double negation elimination: ¬¬P ↔ P
Or.inl
from A, infer A ∨ B
Or.inr
from B, infer A ∨ B
op874_local_cut_three_difference_labels_deg_lt_three
in a cubic graph satisfying the cut condition for a matching and vertex bits, every nonempty subset contains a vertex with fewer than 3 conflict neighbors
op874_local_cut_three_difference_labels_exists_coloring
any symmetric, irreflexive relation on a finite set where every nonempty subset has a vertex of degree < 3 admits a proper 3-coloring
Finset.mem_univ
every element of a finite type belongs to the universal finset

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 op874_local_cut_three_difference_labels_mate_unique {V : Type*} [Fintype V] [DecidableEq V]    (G : SimpleGraph V) [DecidableRel G.Adj]    (M : Finset (Sym2 V)) (hsub : M ⊆ G.edgeFinset)    (hperfect : ∀ v : V, ∃! e : Sym2 V, e ∈ M ∧ v ∈ e) (v : V) :    ∃! u : V, s(v, u) ∈ M := by  obtain ⟨e, ⟨heM, hve⟩, heuniq⟩ := hperfect v  have he_adj : e ∈ G.edgeFinset := hsub heM  rw [SimpleGraph.mem_edgeFinset] at he_adj  obtain ⟨⟨x, z⟩, rfl⟩ := Quot.exists_rep e  rw [Sym2.mem_iff] at hve  have hne : x ≠ z := G.ne_of_adj he_adj  cases hve with  | inl hvx =>    subst hvx    refine ⟨z, heM, ?_⟩    intro u hu    have hu_in : v ∈ s(v, u) := Sym2.mem_mk_left v u    have h_eq := heuniq s(v, u) ⟨hu, hu_in⟩    rw [Sym2.eq_iff] at h_eq    rcases h_eq with (⟨_, rfl⟩ | ⟨rfl, _⟩)    · rfl    · exact (hne rfl).elim  | inr hvz =>    subst hvz    have heM' : s(v, x) ∈ M := by rwa [Sym2.eq_swap]    refine ⟨x, heM', ?_⟩    intro u hu    have hu_in : v ∈ s(v, u) := Sym2.mem_mk_left v u    have h_eq := heuniq s(v, u) ⟨hu, hu_in⟩    rw [Sym2.eq_iff] at h_eq    rcases h_eq with (⟨rfl, _⟩ | ⟨_, rfl⟩)    · exact (hne.symm rfl).elim    · rfllemma op874_local_cut_three_difference_labels_deg_lt_three {V : Type*} [Fintype V] [DecidableEq V]    (G : SimpleGraph V) [DecidableRel G.Adj] (hcubic : G.IsRegularOfDegree 3)    (M : Finset (Sym2 V)) (hsub : M ⊆ G.edgeFinset)    (hperfect : ∀ v : V, ∃! e : Sym2 V, e ∈ M ∧ v ∈ e)    (b : V → Bool)    (hcut : ∀ u v, G.Adj u v → s(u,v) ∈ M →      ((G.neighborFinset u).filter fun w => b w = b u ∧ s(u,w) ∉ M).card +      ((G.neighborFinset v).filter fun w => b w = b v ∧ s(v,w) ∉ M).card ≤ 2)    (s : Finset V) (hs : s.Nonempty) :    ∃ v ∈ s, (s.filter fun w => G.Adj v w ∧ (s(v,w) ∈ M ∨ b v = b w)).card < 3 := by  let R := fun u v => G.Adj u v ∧ (s(u,v) ∈ M ∨ b u = b v)  change ∃ v ∈ s, (s.filter (R v)).card < 3  by_contra! hall  obtain ⟨u, hu⟩ := hs  have hcard_u := hall u hu  have hsub_u : s.filter (R u) ⊆ G.neighborFinset u := by    intro w hw    rw [Finset.mem_filter] at hw    exact (SimpleGraph.mem_neighborFinset G u w).mpr hw.2.1  have hdeg_u : (G.neighborFinset u).card = 3 := hcubic u  have heq_u : s.filter (R u) = G.neighborFinset u := by    apply Finset.eq_of_subset_of_card_le hsub_u    omega  obtain ⟨v, hvuM, hvuniq⟩ := op874_local_cut_three_difference_labels_mate_unique G M hsub hperfect u  have hadj_uv : G.Adj u v := SimpleGraph.mem_edgeFinset.mp (hsub hvuM)  have hvin : v ∈ G.neighborFinset u := (SimpleGraph.mem_neighborFinset G u v).mpr hadj_uv  have hvs : v ∈ s := by    have : v ∈ s.filter (R u) := by      rw [heq_u]      exact hvin    exact (Finset.mem_filter.mp this).1  have hcard_v := hall v hvs  let Fu := (G.neighborFinset u).filter fun w => b w = b u ∧ s(u,w) ∉ M  let Fv := (G.neighborFinset v).filter fun w => b w = b v ∧ s(v,w) ∉ M  have hcut_uv : Fu.card + Fv.card ≤ 2 := hcut u v hadj_uv hvuM  have hsub_Fu : (G.neighborFinset u).erase v ⊆ Fu := by    intro w hw    rw [Finset.mem_erase] at hw    rw [Finset.mem_filter]    refine ⟨hw.2, ⟨?_, ?_⟩⟩    · have hw_in : w ∈ s.filter (R u) := by        rw [heq_u]        exact hw.2      have hw_R := (Finset.mem_filter.mp hw_in).2.2      rcases hw_R with (hwM | hwb)      · exfalso        exact hw.1 (hvuniq w hwM)      · exact hwb.symm    · intro hwM      exact hw.1 (hvuniq w hwM)  have hcard_Fu : 2 ≤ Fu.card := by    have h_erase : ((G.neighborFinset u).erase v).card = 2 := by      rw [Finset.card_erase_of_mem hvin, hdeg_u]    rw [← h_erase]    exact Finset.card_le_card hsub_Fu  have hFv_zero : Fv.card = 0 := by omega  have hsub_v : s.filter (R v) ⊆ {u} := by    intro w hw    rw [Finset.mem_filter] at hw    rw [Finset.mem_singleton]    have hw_adj : w ∈ G.neighborFinset v := (SimpleGraph.mem_neighborFinset G v w).mpr hw.2.1    have hvu_swap : s(v, u) ∈ M := by rwa [Sym2.eq_swap]    obtain ⟨u', hvu'M, hu'uniq⟩ := op874_local_cut_three_difference_labels_mate_unique G M hsub hperfect v    have hu'_eq : u = u' := hu'uniq u hvu_swap    by_cases hwM : s(v, w) ∈ M    · have hw_eq : w = u' := hu'uniq w hwM      subst hu'_eq hw_eq      rfl    · exfalso      rcases hw.2.2 with (hwM' | hwb)      · exact hwM hwM'      · have : w ∈ Fv := by          rw [Finset.mem_filter]          exact ⟨hw_adj, ⟨hwb.symm, hwM⟩⟩        have h_empty : Fv = ∅ := Finset.card_eq_zero.mp hFv_zero        rw [h_empty] at this        exact Finset.notMem_empty w this  have hcard_le_1 : (s.filter (R v)).card ≤ 1 := by    calc (s.filter (R v)).card ≤ ({u} : Finset V).card := Finset.card_le_card hsub_v    _ = 1 := Finset.card_singleton u  omegalemma op874_local_cut_three_difference_labels_exists_coloring {V : Type*} [DecidableEq V]    (R : V → V → Prop) [DecidableRel R] (hR : ∀ u v, R u v → R v u)    (hirr : ∀ v, ¬ R v v)    (hdeg : ∀ s : Finset V, s.Nonempty → ∃ v ∈ s, (s.filter (R v)).card < 3)    (s : Finset V) :    ∃ d : V → Fin 3, ∀ u ∈ s, ∀ v ∈ s, R u v → d u ≠ d v := by  induction' hn : s.card using Nat.strong_induction_on with n ih generalizing s  by_cases hs : s.Nonempty  · obtain ⟨v, hv, hcard⟩ := hdeg s hs    have hlt : (s.erase v).card < n := by      rw [← hn]      exact Finset.card_erase_lt_of_mem hv    obtain ⟨d', hd'⟩ := ih (s.erase v).card hlt (s.erase v) rfl    let forbidden : Finset (Fin 3) := (s.filter (R v)).image d'    have hforb : forbidden.card < 3 := by      calc forbidden.card ≤ (s.filter (R v)).card := Finset.card_image_le      _ < 3 := hcard    have hex : ∃ c : Fin 3, c ∉ forbidden := by      by_contra! hall      have hle : (Finset.univ : Finset (Fin 3)).card ≤ forbidden.card := by        apply Finset.card_le_card        intro x _        exact hall x      rw [Finset.card_univ, Fintype.card_fin] at hle      omega    obtain ⟨c, hc⟩ := hex    use fun x => if x = v then c else d' x    intro u hu w hw hRuw    dsimp only    by_cases hu_eq : u = v    · by_cases hw_eq : w = v      · rw [hu_eq, hw_eq] at hRuw        exact (hirr _ hRuw).elim      · rw [if_pos hu_eq, if_neg hw_eq]        subst hu_eq        intro h_eq        apply hc        rw [Finset.mem_image]        refine ⟨w, ?_, h_eq.symm⟩        rw [Finset.mem_filter]        exact ⟨hw, hRuw⟩    · by_cases hw_eq : w = v      · rw [if_neg hu_eq, if_pos hw_eq]        subst hw_eq        intro h_eq        apply hc        rw [Finset.mem_image]        refine ⟨u, ?_, h_eq⟩        rw [Finset.mem_filter]        exact ⟨hu, hR u w hRuw⟩      · rw [if_neg hu_eq, if_neg hw_eq]        apply hd' u _ w _ hRuw        · rw [Finset.mem_erase]          exact ⟨hu_eq, hu⟩        · rw [Finset.mem_erase]          exact ⟨hw_eq, hw⟩  · rw [Finset.nonempty_iff_ne_empty, not_not] at hs    subst hs    use fun _ => 0    intro u hu    simp at hutheorem op874_local_cut_three_difference_labels {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) [DecidableRel G.Adj] (hcubic : G.IsRegularOfDegree 3) (M : Finset (Sym2 V)) (hsub : M ⊆ G.edgeFinset) (hperfect : ∀ v : V, ∃! e : Sym2 V, e ∈ M ∧ v ∈ e) (b : V → Bool) (hmatching : ∀ u v, G.Adj u v → s(u,v) ∈ M → b u = b v) (hcut : ∀ u v, G.Adj u v → s(u,v) ∈ M → ((G.neighborFinset u).filter fun w => b w = b u ∧ s(u,w) ∉ M).card + ((G.neighborFinset v).filter fun w => b w = b v ∧ s(v,w) ∉ M).card ≤ 2) : ∃ d : V → Fin 3, ∀ u v, G.Adj u v → (s(u,v) ∈ M ∨ b u = b v) → d u ≠ d v := by  let R := fun u v => G.Adj u v ∧ (s(u,v) ∈ M ∨ b u = b v)  have hR_symm : ∀ u v, R u v → R v u := by    intro u v ⟨hadj, hcase⟩    refine ⟨hadj.symm, ?_⟩    rcases hcase with (hM | hb)    · rw [Sym2.eq_swap]      exact Or.inl hM    · exact Or.inr hb.symm  have hR_irr : ∀ v, ¬ R v v := by    intro v ⟨hadj, _⟩    exact G.ne_of_adj hadj rfl  have hdeg : ∀ s : Finset V, s.Nonempty → ∃ v ∈ s, (s.filter (R v)).card < 3 := by    intro s hs    exact op874_local_cut_three_difference_labels_deg_lt_three G hcubic M hsub hperfect b hcut s hs  obtain ⟨d, hd⟩ := op874_local_cut_three_difference_labels_exists_coloring R hR_symm hR_irr hdeg Finset.univ  use d  intro u v hadj hM_or_b  exact hd u (Finset.mem_univ u) v (Finset.mem_univ v) ⟨hadj, hM_or_b⟩
See it in the graphDiscuss this resultChallenge it