odd_components_group_into_exactly
If a finite graph has at least s odd connected components, s is positive, and the vertex count has the same parity as s, then its vertices partition into exactly s odd anticomplete groups.
Statement
theorem odd_components_group_into_exactly {V : Type*} [Fintype V] [DecidableEq V] (H : SimpleGraph V) (s : ℕ) (hs : 1 ≤ s) (hodd : s ≤ H.oddComponents.ncard) (hpar : Fintype.card V % 2 = s % 2) : ∃ f : V → Fin s, (∀ i : Fin s, Odd ((Finset.univ.filter (fun v => f v = i)).card)) ∧ (∀ u v, f u ≠ f v → ¬ H.Adj u v)
- Source
- OP-1957: grouping odd barrier components.
- Verified
- 24 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 3
- op1957_odd_components_ambient_partitionOdd components ambient partition.
- boundary_five_odd_positive_barrier_forces_patterns_with_extendibilityThe displayed positive-barrier defect patterns hold under the original saturated five-by-odd assumptions together with explicit…
- boundary_five_odd_blocks_one_defect_essential_edge_forces_twoFor an odd c with 5≤c≤k, consider the explicitly displayed order-4k four-block partition with |A|=5, |C|=c, factor-critical B, minimum…
The proof, explained
The theorem is established by first proving a general combinatorial lemma for maps between finite sets: given any map g : V → I with at least s odd fibers (where s ≥ 1) and |V| ≡ s (mod 2), the vertices V can be partitioned into s = m + 1 odd sets that each consist of whole fibers of g. This is done by picking m odd fibers of g to form m of the parts, while grouping all remaining fibers together into the (m + 1)-th part, which is guaranteed to be odd because the parities of |V| and the m chosen odd fibers differ by 1. Applying this lemma to the graph's canonical projection map from vertices to connected components yields a partition of V into s odd sets with no edges between distinct parts.
It suffices to consider s = m + 1 for some natural number m.
We split into cases on s. The case s = 0 contradicts the hypothesis 1 ≤ s, which is ruled out by linear arithmetic. Thus s must be a successor m + 1.
classical cases s with | zero => omega | succ m =>
There exists a subset J ⊆ I of size m whose fibers under g all have odd cardinality.
Let O be the set of indices in I with odd fibers under g. By hypothesis, |O| ≥ s = m + 1 > m. By Finset.exists_subset_card_eq, we choose a subset J ⊆ O of cardinality exactly m. Every element of J indexes an odd fiber of g.
uses
Finset.exists_subset_card_eqlet O : Finset I := Finset.univ.filter (fun i => Odd ((Finset.univ.filter (fun v : V => g v = i)).card)) change m+1 ≤ O.card at hodd obtain ⟨J,hJO,hJcard⟩ := Finset.exists_subset_card_eq (s := O) (n := m) (by omega) have hJodd : ∀ i ∈ J, Odd ((Finset.univ.filter (fun v : V => g v = i)).card) := by intro i hi exact (Finset.mem_filter.mp (hJO hi)).2
We construct the assignment map f : V → Fin (m + 1) and the preimage set S = g⁻¹(J).
Since |J| = m, we fix an equivalence e : J ≃ Fin m via Finset.equivFinOfCardEq. We define f(v) to be (e(g(v))).succ ∈ Fin (m + 1) when g(v) ∈ J, and 0 otherwise. We let S ⊆ V be the set of vertices whose image under g lies in J.
uses
Finset.equivFinOfCardEqlet e : J ≃ Fin m := Finset.equivFinOfCardEq hJcard let f : V → Fin (m+1) := fun v => if hv : g v ∈ J then (e ⟨g v,hv⟩).succ else 0 let S : Finset V := Finset.univ.filter (fun v => g v ∈ J)
The cardinality of S has the same parity as m (|S| ≡ m mod 2).
The set S is the disjoint union of the fibers g⁻¹(i) for i ∈ J, so |S| = ∑_{i ∈ J} |g⁻¹(i)| by Finset.sum_card_fiberwise_eq_card_filter. Since every fiber in J is odd, Finset.odd_sum_iff_odd_card_odd implies that |S| is odd if and only if |J| = m is odd. Evaluating remainders modulo 2 yields |S| ≡ m mod 2.
uses
Finset.sum_card_fiberwise_eq_card_filter,Finset.filter_eq_self.mpr,Finset.odd_sum_iff_odd_card_odd,Nat.odd_iff,Nat.mod_lthave hsum : (∑ i ∈ J, (Finset.univ.filter (fun v : V => g v = i)).card) = S.card := by simpa [S] using Finset.sum_card_fiberwise_eq_card_filter (Finset.univ : Finset V) J g have hSmod : S.card % 2 = m % 2 := by have hfilter : J.filter (fun i => Odd ((Finset.univ.filter (fun v : V => g v = i)).card)) = J := Finset.filter_eq_self.mpr hJodd have ho : Odd S.card ↔ Odd J.card := by rw [← hsum, Finset.odd_sum_iff_odd_card_odd, hfilter] rw [hJcard] at ho simp only [Nat.odd_iff] at ho have h1 := Nat.mod_lt S.card (by omega : 0 < 2) have h2 := Nat.mod_lt m (by omega : 0 < 2) omega
The fiber f⁻¹(0) has odd cardinality.
By definition of f, f(v) = 0 if and only if g(v) ∉ J, so f⁻¹(0) = V \ S. Its size is |V| - |S| by Finset.card_sdiff_of_subset. Since |V| ≡ m + 1 mod 2 and |S| ≡ m mod 2, the difference has |V \ S| ≡ (m + 1) - m = 1 mod 2, so |f⁻¹(0)| is odd.
uses
Nat.odd_iff.mpr,Finset.card_sdiff_of_subset,Finset.subset_univ,Finset.card_univ,Finset.card_le_univhave hzero : (Finset.univ.filter (fun v : V => f v = 0)) = Finset.univ \ S := by ext v by_cases hv : g v ∈ J <;> simp [f,S,hv] have hzeroOdd : Odd ((Finset.univ.filter (fun v : V => f v = 0)).card) := by apply Nat.odd_iff.mpr rw [hzero,Finset.card_sdiff_of_subset (Finset.subset_univ S),Finset.card_univ] have hle : S.card ≤ Fintype.card V := by simpa using Finset.card_le_univ S omega
Every fiber of f has odd cardinality.
Using Fin.cases, we check each index i ∈ Fin (m + 1). The fiber over 0 was shown to be odd in the previous step. For an index j.succ with j ∈ Fin m, let x = e⁻¹(j) ∈ J. A vertex satisfies f(v) = j.succ precisely when g(v) = x. Thus the fiber f⁻¹(j.succ) is identical to g⁻¹(x), which has odd cardinality since x ∈ J.
uses
Fin.cases,Fin.succ_ne_zero,Subtype.extrefine ⟨f, ?_, ?_⟩ · intro i refine Fin.cases hzeroOdd ?_ i intro j let x : J := e.symm j have hex : e x = j := e.apply_symm_apply j have hfiber : (Finset.univ.filter (fun v : V => f v = j.succ)) = Finset.univ.filter (fun v : V => g v = x.val) := by ext v simp only [Finset.mem_filter,Finset.mem_univ,true_and] by_cases hv : g v ∈ J · simp only [f,hv,dif_pos,Fin.succ_inj] constructor · intro h have hh : (⟨g v,hv⟩ : J) = x := e.injective (by simpa [hex] using h) exact congrArg Subtype.val hh · intro hg have hh : (⟨g v,hv⟩ : J) = x := Subtype.ext hg simpa [hh] using hex · have hneq : g v ≠ x.val := by intro hh apply hv simpa [hh] using x.property have hj0 : (0 : Fin (m+1)) ≠ j.succ := (Fin.succ_ne_zero j).symm simp [f,hv,hneq,hj0] rw [hfiber] exact hJodd x.val x.property
The function f is constant on every fiber of g.
Assume g(u) = g(v). If this value is in J, both f(u) and f(v) evaluate to (e(g(u))).succ, so f(u) = f(v). If the value is not in J, both evaluate to 0, so f(u) = f(v). In either case, f is constant on fibers of g.
uses
Subtype.ext· intro u v huv by_cases hu : g u ∈ J · have hv : g v ∈ J := by simpa [← huv] using hu simp only [f,hu,hv,dif_pos] congr 2 exact Subtype.ext huv · have hv : g v ∉ J := by simpa [← huv] using hu simp [f,hu,hv]
The connected component map g : V → H.ConnectedComponent has at least s odd fibers.
Let g map each vertex to its connected component in H. By SimpleGraph.ConnectedComponent.mem_supp_iff, the fiber g⁻¹(C) over component C is the support of C. Hence the odd fibers of g correspond to the odd connected components of H. Since H has at least s odd components, g has at least s odd fibers.
uses
SimpleGraph.ConnectedComponent.mem_supp_iff,Set.ncard_eq_toFinset_card'classical let g : V → H.ConnectedComponent := H.connectedComponentMk have hfiber (c : H.ConnectedComponent) : (Finset.univ.filter (fun v : V => g v = c)) = c.supp.toFinset := by ext v simp [g,SimpleGraph.ConnectedComponent.mem_supp_iff] have hset : (Finset.univ.filter (fun c : H.ConnectedComponent => Odd ((Finset.univ.filter (fun v : V => g v = c)).card))) = H.oddComponents.toFinset := by ext c simp only [Finset.mem_filter,Finset.mem_univ,true_and,Set.mem_toFinset] rw [hfiber,← Set.ncard_eq_toFinset_card'] rfl have hodd' : s ≤ (Finset.univ.filter (fun c : H.ConnectedComponent => Odd ((Finset.univ.filter (fun v : V => g v = c)).card))).card := by rw [hset,← Set.ncard_eq_toFinset_card'] exact hodd
The vertices of H partition into exactly s odd anticomplete groups.
Applying in1158_finite_odd_fibers_local to the component map g produces a function f : V → Fin s with all fibers odd and constant on each connected component. If u and v are adjacent, they are reachable from each other, so by SimpleGraph.ConnectedComponent.eq.mpr they share the same component, meaning f(u) = f(v). Contrapositively, vertices with different colors under f cannot be adjacent.
uses
in1158_finite_odd_fibers_local,SimpleGraph.ConnectedComponent.eq.mprobtain ⟨f,hf,hconst⟩ := in1158_finite_odd_fibers_local V H.ConnectedComponent g s hs hodd' hpar refine ⟨f,hf,?_⟩ intro u v hne hadj apply hne apply hconst exact SimpleGraph.ConnectedComponent.eq.mpr hadj.reachable
Finset.exists_subset_card_eq- A finite set of cardinality at least n contains a subset of cardinality exactly n.
Finset.equivFinOfCardEq- A finite set of cardinality n is in bijection with Fin n, the canonical n-element set.
Finset.sum_card_fiberwise_eq_card_filter- The sum of the sizes of the fibers of a map g over a set of targets J equals the size of the preimage g⁻¹(J).
Finset.filter_eq_self.mpr- Filtering a finite set by a predicate satisfied by all its members returns the set itself.
Finset.odd_sum_iff_odd_card_odd- A sum of natural numbers is odd if and only if the number of odd summands is odd.
Nat.odd_iff- A natural number is odd if and only if its remainder modulo 2 is 1.
Nat.mod_lt- For any positive divisor y, the remainder x mod y is strictly less than y.
Nat.odd_iff.mpr- If a natural number has remainder 1 modulo 2, then it is odd.
Finset.card_sdiff_of_subset- For finite sets s ⊆ t, the cardinality of the difference t \ s is |t| - |s|.
Finset.subset_univ- Every finite set of elements of a finite type is a subset of the universal set of all elements.
Finset.card_univ- The cardinality of the universal set of a finite type equals the total number of elements in the type.
Finset.card_le_univ- The cardinality of any subset of a finite type is at most the total cardinality of the type.
Fin.cases- To prove a property for all elements of Fin (n + 1), it suffices to prove it for 0 and for the successor of each element in Fin n.
Fin.succ_ne_zero- The successor of an element in Fin n is never 0 in Fin (n + 1).
Subtype.ext- Two elements of a subtype are equal if and only if their underlying values are equal.
SimpleGraph.ConnectedComponent.mem_supp_iff- A vertex belongs to the support of a connected component if and only if its connected component is that component.
Set.ncard_eq_toFinset_card'- The counting measure ncard of a set equals the cardinality of its finset representation.
in1158_finite_odd_fibers_local- Given a map g : V → I with at least s odd fibers (s ≥ 1) and |V| ≡ s (mod 2), there is a map f : V → Fin s with every fiber odd and constant on each fiber of g.
SimpleGraph.ConnectedComponent.eq.mpr- If two vertices in a graph are reachable from one another, they have the same connected component.
- The modular arithmetic showing that the difference |V \ S| is odd (deducing (|V| - |S|) % 2 = 1 from |V| % 2 = (m + 1) % 2, |S| % 2 = m % 2, and |S| ≤ |V|) is discharged automatically by the linear integer arithmetic tactic omega.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
set_option maxHeartbeats 3000000theorem in1158_finite_odd_fibers_local (V I : Type*) [Fintype V] [Fintype I] [DecidableEq V] [DecidableEq I] (g : V → I) (s : ℕ) (hs : 1 ≤ s) (hodd : s ≤ (Finset.univ.filter (fun i : I => Odd ((Finset.univ.filter (fun v : V => g v = i)).card))).card) (hpar : Fintype.card V % 2 = s % 2) : ∃ f : V → Fin s, (∀ i : Fin s, Odd ((Finset.univ.filter (fun v => f v = i)).card)) ∧ (∀ u v, g u = g v → f u = f v) := by classical cases s with | zero => omega | succ m => let O : Finset I := Finset.univ.filter (fun i => Odd ((Finset.univ.filter (fun v : V => g v = i)).card)) change m+1 ≤ O.card at hodd obtain ⟨J,hJO,hJcard⟩ := Finset.exists_subset_card_eq (s := O) (n := m) (by omega) have hJodd : ∀ i ∈ J, Odd ((Finset.univ.filter (fun v : V => g v = i)).card) := by intro i hi exact (Finset.mem_filter.mp (hJO hi)).2 let e : J ≃ Fin m := Finset.equivFinOfCardEq hJcard let f : V → Fin (m+1) := fun v => if hv : g v ∈ J then (e ⟨g v,hv⟩).succ else 0 let S : Finset V := Finset.univ.filter (fun v => g v ∈ J) have hsum : (∑ i ∈ J, (Finset.univ.filter (fun v : V => g v = i)).card) = S.card := by simpa [S] using Finset.sum_card_fiberwise_eq_card_filter (Finset.univ : Finset V) J g have hSmod : S.card % 2 = m % 2 := by have hfilter : J.filter (fun i => Odd ((Finset.univ.filter (fun v : V => g v = i)).card)) = J := Finset.filter_eq_self.mpr hJodd have ho : Odd S.card ↔ Odd J.card := by rw [← hsum, Finset.odd_sum_iff_odd_card_odd, hfilter] rw [hJcard] at ho simp only [Nat.odd_iff] at ho have h1 := Nat.mod_lt S.card (by omega : 0 < 2) have h2 := Nat.mod_lt m (by omega : 0 < 2) omega have hzero : (Finset.univ.filter (fun v : V => f v = 0)) = Finset.univ \ S := by ext v by_cases hv : g v ∈ J <;> simp [f,S,hv] have hzeroOdd : Odd ((Finset.univ.filter (fun v : V => f v = 0)).card) := by apply Nat.odd_iff.mpr rw [hzero,Finset.card_sdiff_of_subset (Finset.subset_univ S),Finset.card_univ] have hle : S.card ≤ Fintype.card V := by simpa using Finset.card_le_univ S omega refine ⟨f, ?_, ?_⟩ · intro i refine Fin.cases hzeroOdd ?_ i intro j let x : J := e.symm j have hex : e x = j := e.apply_symm_apply j have hfiber : (Finset.univ.filter (fun v : V => f v = j.succ)) = Finset.univ.filter (fun v : V => g v = x.val) := by ext v simp only [Finset.mem_filter,Finset.mem_univ,true_and] by_cases hv : g v ∈ J · simp only [f,hv,dif_pos,Fin.succ_inj] constructor · intro h have hh : (⟨g v,hv⟩ : J) = x := e.injective (by simpa [hex] using h) exact congrArg Subtype.val hh · intro hg have hh : (⟨g v,hv⟩ : J) = x := Subtype.ext hg simpa [hh] using hex · have hneq : g v ≠ x.val := by intro hh apply hv simpa [hh] using x.property have hj0 : (0 : Fin (m+1)) ≠ j.succ := (Fin.succ_ne_zero j).symm simp [f,hv,hneq,hj0] rw [hfiber] exact hJodd x.val x.property · intro u v huv by_cases hu : g u ∈ J · have hv : g v ∈ J := by simpa [← huv] using hu simp only [f,hu,hv,dif_pos] congr 2 exact Subtype.ext huv · have hv : g v ∉ J := by simpa [← huv] using hu simp [f,hu,hv]theorem odd_components_group_into_exactly {V : Type*} [Fintype V] [DecidableEq V] (H : SimpleGraph V) (s : ℕ) (hs : 1 ≤ s) (hodd : s ≤ H.oddComponents.ncard) (hpar : Fintype.card V % 2 = s % 2) : ∃ f : V → Fin s, (∀ i : Fin s, Odd ((Finset.univ.filter (fun v => f v = i)).card)) ∧ (∀ u v, f u ≠ f v → ¬ H.Adj u v) := by classical let g : V → H.ConnectedComponent := H.connectedComponentMk have hfiber (c : H.ConnectedComponent) : (Finset.univ.filter (fun v : V => g v = c)) = c.supp.toFinset := by ext v simp [g,SimpleGraph.ConnectedComponent.mem_supp_iff] have hset : (Finset.univ.filter (fun c : H.ConnectedComponent => Odd ((Finset.univ.filter (fun v : V => g v = c)).card))) = H.oddComponents.toFinset := by ext c simp only [Finset.mem_filter,Finset.mem_univ,true_and,Set.mem_toFinset] rw [hfiber,← Set.ncard_eq_toFinset_card'] rfl have hodd' : s ≤ (Finset.univ.filter (fun c : H.ConnectedComponent => Odd ((Finset.univ.filter (fun v : V => g v = c)).card))).card := by rw [hset,← Set.ncard_eq_toFinset_card'] exact hodd obtain ⟨f,hf,hconst⟩ := in1158_finite_odd_fibers_local V H.ConnectedComponent g s hs hodd' hpar refine ⟨f,hf,?_⟩ intro u v hne hadj apply hne apply hconst exact SimpleGraph.ConnectedComponent.eq.mpr hadj.reachable