Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Partial partitions, unfriendliness at a vertex, and the partitioning game with an ordinal clock

Definition
TenChallenges_UnfriendlyPartition

by utkuokur · Nov 4, 2026 · Mathlib 0df444a (Lean v4.33.1)

gamesinfinite-graphsordinalsunfriendly-partition

The definitions behind Challenge 10 of the Ten Challenges benchmark, for a simple graph GGG on a vertex type VVV.

  1. Partial partitions. A partial partition is a function fff from VVV to {undefined,0,1}\{\text{undefined}, 0, 1\}{undefined,0,1}. The empty partition is undefined everywhere; fff has finite domain if only finitely many vertices are assigned a class; ggg extends fff if every assignment made by fff is kept by ggg.
  2. Unfriendly at vvv. fff is unfriendly at vvv if f(v)=bf(v)=bf(v)=b is defined and the cardinality of the set of neighbours of vvv assigned bbb is at most the cardinality of the set of neighbours assigned the opposite class 1−b1-b1−b. Unassigned neighbours are not counted.
  3. Legal response. Given fff and a challenged vertex vvv, a partial partition ggg is a legal response if it extends fff, has finite domain, and is unfriendly at vvv.
  4. Partitioner wins. For an ordinal clock α\alphaα, PartitionerWins(G,f,α)\mathrm{PartitionerWins}(G,f,\alpha)PartitionerWins(G,f,α) holds if for every vertex vvv and every ordinal β<α\beta<\alphaβ<α there is a legal response ggg to (f,v)(f,v)(f,v) with PartitionerWins(G,g,β)\mathrm{PartitionerWins}(G,g,\beta)PartitionerWins(G,g,β). For α=0\alpha=0α=0 this holds vacuously.

These definitions encode the rrr-partitioning game: Challenger names vvv and β<α\beta<\alphaβ<α, Partitioner answers with a legal response, and play continues with clock β\betaβ.

Formalization Note. Classes are Option Bool; cardinalities are Mathlib's Cardinal.mk of subtypes of V; the recursion on the ordinal is well-founded recursion (termination_by α). The vertex type and the ordinal have independent universe parameters u and v.

Definition code
import Mathlib.SetTheory.Ordinal.Basic
import Mathlib.Combinatorics.SimpleGraph.Basic

universe u v

open scoped Cardinal

variable {V : Type u} (G : SimpleGraph V)

/-- Neighbours of `v` mapped to value `b` by `f`. -/
def NeighColored {β : Type*} (f : V → β)
    (v : V) (b : β) : Type u := ↥(G.neighborSet v ∩ f ⁻¹' {b})

/-- `v` is coloured, with at least as many neighbours of the opposite colour as of its own. -/
def UnfriendlyAt (f : V → Option Bool)
    (v : V) : Prop :=
  ∃ b : Bool, f v = some b ∧
    #(NeighColored G f v (some b)) ≤ #(NeighColored G f v (some (!b)))

/-- The empty partial partition. -/
def emptyPartition (V : Type u) : V → Option Bool :=
  fun _ => none

/-- Only finitely many vertices are assigned a colour. -/
def HasFiniteDomain {V : Type u} (f : V → Option Bool) : Prop :=
  {v : V | f v ≠ none}.Finite

/-- `g` extends `f` when all assignments already made by `f` are preserved. -/
def Extends {V : Type u} (f g : V → Option Bool) : Prop :=
  ∀ v b, f v = some b → g v = some b

/-- A finite extension of `f` that is unfriendly at the challenged vertex `v`. -/
def IsLegalResponse {V : Type u} (G : SimpleGraph V)
    (f g : V → Option Bool) (v : V) : Prop :=
  Extends f g ∧ HasFiniteDomain g ∧ UnfriendlyAt G g v

/-- Partitioner wins from `(f, α)`, by recursion on the ordinal clock `α`. -/
def PartitionerWins {V : Type u} (G : SimpleGraph V)
    (f : V → Option Bool) (α : Ordinal.{v}) : Prop :=
  ∀ v : V, ∀ β : Ordinal.{v}, β < α →
    ∃ g : V → Option Bool,
      IsLegalResponse G f g v ∧ PartitionerWins G g β
termination_by α
Source
Ten Challenges repository, file Defs_and_Lems/UnfriendlyPartition.lean (commit ff14a56), https://github.com/TenChallenges/ten-challenges/blob/main/Defs_and_Lems/UnfriendlyPartition.lean; the game is defined on the Ten Challenges website, challenge 10 (Definition "The r-partitioning game"); unfriendly partitions as in R. Aharoni, E. C. Milner, K. Prikry, Unfriendly partitions of a graph, JCTB 50 (1990).
Read-back

What the Lean code literally says, in plain math · claude-fable-5-1

Setting and notation. Throughout, VVV is an arbitrary type (the vertex set) living in a universe uuu; VVV may be empty, finite or infinite. GGG is a simple graph on VVV, i.e. a binary adjacency relation v∼Gwv \sim_G wv∼G​w on VVV that is symmetric and irreflexive (no loops, no multiple edges, and no further restriction: a vertex may have infinitely many neighbours). NG(v)={ w∈V:v∼Gw }N_G(v) = \{\, w \in V : v \sim_G w \,\}NG​(v)={w∈V:v∼G​w} is the set of neighbours of vvv. A partial 2-colouring is any function f:V→{⊥,T,F}f : V \to \{\bot, \mathsf T, \mathsf F\}f:V→{⊥,T,F}, where ⊥\bot⊥ means "no colour assigned" and T,F\mathsf T, \mathsf FT,F are the two Boolean colours; for a Boolean bbb, bˉ\bar bbˉ denotes its negation (Tˉ=F\bar{\mathsf T} = \mathsf FTˉ=F, Fˉ=T\bar{\mathsf F} = \mathsf TFˉ=T). ∣X∣|X|∣X∣ denotes the cardinality of XXX as a cardinal number (in universe uuu), so it may be infinite, and ≤\le≤ between cardinalities means existence of an injection. Ordinals α,β,r\alpha, \beta, rα,β,r range over the ordinals of a second universe vvv, independent of uuu; β<α\beta < \alphaβ<α is the usual strict well-ordering of ordinals.

Definition NeighColored (written Nbf(v)N^{f}_{b}(v)Nbf​(v)). For any type BBB, any function f:V→Bf : V \to Bf:V→B, any vertex v∈Vv \in Vv∈V and any value b∈Bb \in Bb∈B, Nbf(v)N^f_b(v)Nbf​(v) is the type (in universe uuu) whose elements are the members of the set

Nbf(v)  =  NG(v)∩f−1({b})  =  { w∈V:v∼Gw  and  f(w)=b },N^f_b(v) \;=\; N_G(v) \cap f^{-1}(\{b\}) \;=\; \{\, w \in V : v \sim_G w \ \text{ and } \ f(w) = b \,\},Nbf​(v)=NG​(v)∩f−1({b})={w∈V:v∼G​w  and  f(w)=b},

i.e. the neighbours of vvv whose fff-value is exactly bbb. (Below it is only ever used with B={⊥,T,F}B = \{\bot,\mathsf T,\mathsf F\}B={⊥,T,F} and b∈{T,F}b \in \{\mathsf T,\mathsf F\}b∈{T,F}.)

Definition UnfriendlyAt (written Unf(G,f,v)\mathrm{Unf}(G, f, v)Unf(G,f,v)). For a partial 2-colouring f:V→{⊥,T,F}f : V \to \{\bot,\mathsf T,\mathsf F\}f:V→{⊥,T,F} and a vertex v∈Vv \in Vv∈V:

Unf(G,f,v)  ⟺  ∃ b∈{T,F}  such that  f(v)=b  and  ∣Nbf(v)∣  ≤  ∣Nbˉf(v)∣.\mathrm{Unf}(G,f,v) \iff \exists\, b \in \{\mathsf T,\mathsf F\}\ \text{ such that }\ f(v) = b \ \text{ and }\ \bigl|N^f_{b}(v)\bigr| \;\le\; \bigl|N^f_{\bar b}(v)\bigr| .Unf(G,f,v)⟺∃b∈{T,F}  such that  f(v)=b  and  ​Nbf​(v)​≤​Nbˉf​(v)​.

In words: vvv is actually coloured (so f(v)≠⊥f(v) \ne \botf(v)=⊥; the witness bbb is forced to be the colour of vvv), and the number of neighbours of vvv carrying the same colour as vvv is at most, as cardinals, the number of neighbours carrying the opposite colour. Neighbours with f(w)=⊥f(w) = \botf(w)=⊥ are counted on neither side. Edge cases that the definition literally includes: a coloured vertex with no neighbours satisfies it (0≤00 \le 00≤0); if both sides are infinite of the same cardinality the inequality holds; if the same-colour side is infinite and the opposite side finite it fails; an uncoloured vertex (f(v)=⊥f(v) = \botf(v)=⊥) is never unfriendly.

Definition emptyPartition (written f∅f_\emptysetf∅​). For a type VVV (universe uuu), f∅:V→{⊥,T,F}f_\emptyset : V \to \{\bot,\mathsf T,\mathsf F\}f∅​:V→{⊥,T,F} is the constant function f∅(v)=⊥f_\emptyset(v) = \botf∅​(v)=⊥ for all vvv (no vertex coloured).

Definition HasFiniteDomain (written FinDom(f)\mathrm{FinDom}(f)FinDom(f)). For f:V→{⊥,T,F}f : V \to \{\bot,\mathsf T,\mathsf F\}f:V→{⊥,T,F},

FinDom(f)  ⟺  { v∈V:f(v)≠⊥ }  is a finite set,\mathrm{FinDom}(f) \iff \{\, v \in V : f(v) \ne \bot \,\} \ \text{ is a finite set},FinDom(f)⟺{v∈V:f(v)=⊥}  is a finite set,

i.e. there are n∈Nn \in \mathbb Nn∈N and a bijection between this set and {0,…,n−1}\{0,\dots,n-1\}{0,…,n−1}; n=0n = 0n=0 is allowed, so f∅f_\emptysetf∅​ has finite domain.

Definition Extends (written f⪯gf \preceq gf⪯g). For f,g:V→{⊥,T,F}f, g : V \to \{\bot,\mathsf T,\mathsf F\}f,g:V→{⊥,T,F},

f⪯g  ⟺  ∀v∈V, ∀b∈{T,F}:f(v)=b  ⇒  g(v)=b.f \preceq g \iff \forall v \in V,\ \forall b \in \{\mathsf T,\mathsf F\}:\quad f(v) = b \;\Rightarrow\; g(v) = b .f⪯g⟺∀v∈V, ∀b∈{T,F}:f(v)=b⇒g(v)=b.

Every colour already assigned by fff is kept unchanged by ggg. Nothing is required at vertices with f(v)=⊥f(v) = \botf(v)=⊥: ggg may colour them or leave them uncoloured. In particular f⪯ff \preceq ff⪯f, and f∅⪯gf_\emptyset \preceq gf∅​⪯g for every ggg.

Definition IsLegalResponse (written L(G,f,g,v)L(G, f, g, v)L(G,f,g,v)). For f,g:V→{⊥,T,F}f, g : V \to \{\bot,\mathsf T,\mathsf F\}f,g:V→{⊥,T,F} and v∈Vv \in Vv∈V,

L(G,f,g,v)  ⟺  (f⪯g) ∧ FinDom(g) ∧ Unf(G,g,v).L(G,f,g,v) \iff (f \preceq g)\ \wedge\ \mathrm{FinDom}(g)\ \wedge\ \mathrm{Unf}(G, g, v).L(G,f,g,v)⟺(f⪯g) ∧ FinDom(g) ∧ Unf(G,g,v).

No hypothesis is placed on fff itself (although f⪯gf \preceq gf⪯g together with FinDom(g)\mathrm{FinDom}(g)FinDom(g) forces the coloured set of fff to be finite as well). ggg is not required to differ from fff; ggg is required to be unfriendly only at the single vertex vvv and nothing is asserted about other vertices; ggg may colour any finite number of further vertices anywhere in VVV.

Definition PartitionerWins (written W(G,f,α)W(G, f, \alpha)W(G,f,α)). For a partial 2-colouring f:V→{⊥,T,F}f : V \to \{\bot,\mathsf T,\mathsf F\}f:V→{⊥,T,F} and an ordinal α\alphaα (universe vvv), W(G,f,α)W(G,f,\alpha)W(G,f,α) is defined by well-founded recursion on α\alphaα (the recursive call is at an ordinal β<α\beta < \alphaβ<α):

W(G,f,α)  ⟺  ∀v∈V,  ∀β<α,  ∃ g:V→{⊥,T,F}:L(G,f,g,v) ∧ W(G,g,β).W(G,f,\alpha) \iff \forall v \in V,\ \ \forall \beta < \alpha,\ \ \exists\, g : V \to \{\bot,\mathsf T,\mathsf F\}:\quad L(G,f,g,v)\ \wedge\ W(G,g,\beta).W(G,f,α)⟺∀v∈V,  ∀β<α,  ∃g:V→{⊥,T,F}:L(G,f,g,v) ∧ W(G,g,β).

In words: for every vertex vvv (any vertex at all, coloured or not under fff; the same vertex may be chosen again at later stages) and for every ordinal β\betaβ strictly smaller than α\alphaα (all such β\betaβ, not only an immediate predecessor; at a limit α\alphaα this is every β<α\beta < \alphaβ<α), there exists a ggg that extends fff, colours only finitely many vertices, and is unfriendly at vvv (the choice of ggg may depend on both vvv and β\betaβ), and the same property holds again from the pair (g,β)(g, \beta)(g,β). Unfolding the recursion, this is a sequence of alternations: an opponent picks (v0,β0)(v_0, \beta_0)(v0​,β0​) with β0<α\beta_0 < \alphaβ0​<α, the Partitioner answers g0g_0g0​ with L(G,f,g0,v0)L(G,f,g_0,v_0)L(G,f,g0​,v0​); the opponent picks (v1,β1)(v_1,\beta_1)(v1​,β1​) with β1<β0\beta_1 < \beta_0β1​<β0​, the Partitioner answers g1g_1g1​ with L(G,g0,g1,v1)L(G,g_0,g_1,v_1)L(G,g0​,g1​,v1​); and so on; since the ordinals β0>β1>⋯\beta_0 > \beta_1 > \cdotsβ0​>β1​>⋯ strictly decrease, every such run is finite. Consequences of the literal definition: W(G,f,0)W(G,f,0)W(G,f,0) holds for every GGG and every fff (there is no β<0\beta < 0β<0), including fff with infinitely many coloured vertices; if VVV is empty then W(G,f,α)W(G,f,\alpha)W(G,f,α) holds for every α\alphaα; if α>0\alpha > 0α>0, VVV is nonempty and fff has infinitely many coloured vertices, then W(G,f,α)W(G,f,\alpha)W(G,f,α) fails (no finite-domain ggg extends fff).

Human review
  • Endorsed by Shuze Chen · Nov 4, 2026

    Confirmed by the moderator at approval.

  • Endorsed by utkuokur · Nov 4, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me