op869_game_maintains_prefix
A bounded online-coloring strategy preserves graph colorability, the board-size bound, and empty predecessor and color sets at all future positions.
Statement
theorem op869_game_maintains_prefix {n : ℕ} (k D t : ℕ) (goal : Op869SequentialState n → Prop) (fuel : ℕ) (s : Op869SequentialState n) (hinv : op869_prefix_invariant k s) (hgame : op869_sequential_goal_game goal (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next fuel s) : op869_sequential_goal_game (fun s => op869_prefix_invariant k s ∧ goal s) (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next fuel s
- Source
- AFTD formalization of arXiv:2610.41516, Lemma 2.3
- Verified
- 18 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 3
- op869_bounded_game_sequential_composeIf an adversary can force a chosen intermediate state property within fuel₁ moves, and can then force K colors within fuel₂ further moves…
- op869_graph_from_predecessorsThe simple graph on the ordered vertices Fin n whose edge from an earlier vertex a to a later vertex b exists exactly when a is in the…
- op869_predecessor_postdegreeThe post-degree of a vertex in an ordered predecessor presentation is the number of later vertices that list it as a predecessor.
- Used by 1
- op869_one_sided_bipartite_gadgetA t-fold adversary can build a bipartite graph in at most 2^(j+1)-1 vertices with one side containing at least t+j ceil(t/2) colors.
The proof, explained
The theorem proves that a winning strategy in the sequential online coloring game preserves the prefix invariant (the board size bound, k-colorability, and empty predecessor/color sets for future vertices) alongside the goal. First, `op869_game_preserves_invariant` proves by induction on fuel that sequential games preserve any invariant that is maintained across each legal step. Second, `op869_legal_step_preserves_prefix` verifies that a legal step indeed preserves the prefix invariant: the vertex index stays bounded, colorability holds by move legality, and future vertices remain unassigned. Finally, `op869_game_maintains_prefix` applies this general invariant preservation result to the prefix invariant.
In the general game, the invariant preservation holds vacuously when the fuel bound is zero. automation
We proceed by induction on `fuel`. In the base case `fuel = 0`, the sequential game predicate `op869_sequential_goal_game` reduces to False, so the hypothesis `hgame` is contradictory and the goal follows immediately by simplification.
uses
op869_sequential_goal_gameinduction fuel generalizing s with | zero => simp [op869_sequential_goal_game] at hgame
In the inductive step, the winning move maintains the invariant across every valid adversary response.
Unfolding `op869_sequential_goal_game` for `fuel + 1`, we obtain a legal move `a` and a guarantee `hnext` for all adversary responses. We propose this same move `a`. Given any valid response `r`, the step condition `hstep` ensures that the invariant holds in the next state `next s a r`.
uses
op869_sequential_goal_game| succ fuel ih => simp only [op869_sequential_goal_game] at hgame ⊢ obtain ⟨a, ha, hnext⟩ := hgame refine ⟨a, ha, ?_⟩ intro r hr have hi := hstep s a r hinv ha hrThe next state either achieves both the invariant and the goal, or continues to a winning position by induction.
By `hnext`, the adversary response either satisfies `goal` directly (in which case both the invariant and goal hold), or leads to a subgame with `fuel` remaining, where the induction hypothesis guarantees that the invariant is preserved.
uses
Or.inl,Or.inrrcases hnext r hr with hgoal | hrest · exact Or.inl ⟨hi,hgoal⟩ · exact Or.inr (ih _ hi hrest)
A legal step advances the vertex index while keeping it at most n.
In `op869_legal_step_preserves_prefix`, we unpack the legality condition of the move `S`, obtaining `hi : s.i < n` and colorability. Simplifying the transition function and the invariant definition, the new index is `s.i + 1`, which is at most `n` by linear arithmetic from `s.i < n`.
uses
op869_sequential_next,dif_pos,op869_prefix_invariant,Op869SequentialState.i,Op869SequentialState.P,Op869SequentialState.Ctheorem op869_legal_step_preserves_prefix {n : ℕ} (k D t : ℕ) (s : Op869SequentialState n) (S : Finset (Fin n)) (colors : Finset ℕ) (hinv : op869_prefix_invariant k s) (hlegal : op869_sequential_legal k D s S) (hvalid : op869_sequential_valid t s S colors) : op869_prefix_invariant k (op869_sequential_next s S colors) := by classical obtain ⟨hi,hS,hcolor,hdegree⟩ := hlegal simp only [op869_sequential_next, dif_pos hi, op869_prefix_invariant, Op869SequentialState.i, Op869SequentialState.P, Op869SequentialState.C] constructor · omega
The graph remains k-colorable after the step.
The k-colorability of the updated predecessor graph is precisely part of the definition of legality of the move (`hcolor`).
· constructor · exact hcolor
Future vertices beyond the new index still have empty predecessor and color sets.
For any vertex `a` with `s.i + 1 ≤ a.val`, `a` cannot equal the newly added vertex `s.i`. By the invariant before the step, `a` already had empty predecessor and color sets. Since the transition only updates the predecessor and color assignments at index `s.i`, the assignments at `a` remain empty by `Function.update_of_ne`.
uses
congrArg,Fin.val,Function.update_of_ne· intro a ha have hai : a ≠ (⟨s.i,hi⟩ : Fin n) := by intro heq have hv := congrArg Fin.val heq change a.val = s.i at hv omega have hbefore := hinv.2.2 a (by omega) constructor · simpa [Function.update_of_ne hai] using hbefore.1 · simpa [Function.update_of_ne hai] using hbefore.2
The initial empty state satisfies the prefix invariant.
For the empty state with index 0 and empty predecessor/color maps, the index satisfies `0 ≤ n`, the empty graph is trivially k-colorable by assigning all vertices color 0 (since no two vertices are adjacent in the empty predecessor graph), and all vertices vacuously have empty predecessor and color sets.
uses
SimpleGraph.Coloring.mktheorem op869_empty_prefix_invariant (n k : ℕ) (hk : 1 ≤ k) : op869_prefix_invariant k (⟨0, (fun _ : Fin n => ∅), (fun _ : Fin n => ∅)⟩ : Op869SequentialState n) := by refine ⟨by change 0 ≤ n; omega, ?_, ?_⟩ · refine ⟨SimpleGraph.Coloring.mk (fun _ : Fin n => (⟨0, by omega⟩ : Fin k)) ?_⟩ intro a b hadj change (a < b ∧ a ∈ (∅ : Finset (Fin n))) ∨ (b < a ∧ b ∈ (∅ : Finset (Fin n))) at hadj simp at hadj · simp
The sequential game maintains the prefix invariant alongside the goal throughout play.
We apply `op869_game_preserves_invariant` with `op869_prefix_invariant k` as the invariant. The requirement that each step preserves the invariant is discharged by `op869_legal_step_preserves_prefix`. With the invariant holding initially and a winning strategy available, the game maintains the prefix invariant along with the goal.
uses
op869_game_preserves_invariant,op869_prefix_invariant,op869_sequential_legal,op869_sequential_valid,op869_sequential_next,op869_legal_step_preserves_prefixtheorem op869_game_maintains_prefix {n : ℕ} (k D t : ℕ) (goal : Op869SequentialState n → Prop) (fuel : ℕ) (s : Op869SequentialState n) (hinv : op869_prefix_invariant k s) (hgame : op869_sequential_goal_game goal (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next fuel s) : op869_sequential_goal_game (fun s => op869_prefix_invariant k s ∧ goal s) (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next fuel s := by apply op869_game_preserves_invariant goal (op869_prefix_invariant k) (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next (op869_legal_step_preserves_prefix k D t) fuel s hinv hgame
congrArg- Equality is preserved under function application: if x = y then f x = f y.
Fin.val- The underlying natural number value of a Fin n element.
dif_pos- Dependent if-then-else evaluates to the then-branch when the condition is true.
Function.update_of_ne- Updating a function at a' does not change its value at any distinct point a ≠ a'.
Or.inl- Left injection into a disjunction: proves A ∨ B from a proof of A.
Or.inr- Right injection into a disjunction: proves A ∨ B from a proof of B.
Op869SequentialState.C- The color set field of a sequential game state.
Op869SequentialState.i- The index field of a sequential game state, representing the current vertex index.
Op869SequentialState.P- The predecessor set field of a sequential game state.
op869_game_preserves_invariant- If an invariant holds initially and each legal move and valid adversary response preserves it, then any winning strategy for a goal in the sequential game also preserves the invariant.
op869_legal_step_preserves_prefix- A single legal move and valid response preserve the prefix invariant in the sequential game.
op869_prefix_invariant- The state invariant requiring the current index to be at most n, the graph formed by predecessors to be k-colorable, and all vertices at or beyond the current index to have empty predecessor and color sets.
op869_sequential_goal_game- The predicate defining the existence of a winning strategy for a goal in a sequential game with a given fuel bound.
op869_sequential_legal- The predicate defining a legal move: current index strictly less than n, predecessors strictly earlier, k-colorability preserved, and postdegree bounded by D.
op869_sequential_next- The state transition function advancing the index by one and recording the predecessors and colors for that vertex.
op869_sequential_valid- The predicate defining whether an adversary's response is valid for the chosen move.
SimpleGraph.Coloring.mk- Constructs a valid graph coloring from a color assignment function and a proof that adjacent vertices receive different colors.
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.
theorem op869_game_preserves_invariant {S M R : Type} (goal invariant : S → Prop) (legal : S → M → Prop) (valid : S → M → R → Prop) (next : S → M → R → S) (hstep : ∀ s a r, invariant s → legal s a → valid s a r → invariant (next s a r)) (fuel : ℕ) (s : S) (hinv : invariant s) (hgame : op869_sequential_goal_game goal legal valid next fuel s) : op869_sequential_goal_game (fun s => invariant s ∧ goal s) legal valid next fuel s := by induction fuel generalizing s with | zero => simp [op869_sequential_goal_game] at hgame | succ fuel ih => simp only [op869_sequential_goal_game] at hgame ⊢ obtain ⟨a, ha, hnext⟩ := hgame refine ⟨a, ha, ?_⟩ intro r hr have hi := hstep s a r hinv ha hr rcases hnext r hr with hgoal | hrest · exact Or.inl ⟨hi,hgoal⟩ · exact Or.inr (ih _ hi hrest)def op869_prefix_invariant {n : ℕ} (k : ℕ) (s : Op869SequentialState n) : Prop := s.i ≤ n ∧ (op869_graph_from_predecessors s.P).Colorable k ∧ ∀ a, s.i ≤ a.val → s.P a = ∅ ∧ s.C a = ∅theorem op869_legal_step_preserves_prefix {n : ℕ} (k D t : ℕ) (s : Op869SequentialState n) (S : Finset (Fin n)) (colors : Finset ℕ) (hinv : op869_prefix_invariant k s) (hlegal : op869_sequential_legal k D s S) (hvalid : op869_sequential_valid t s S colors) : op869_prefix_invariant k (op869_sequential_next s S colors) := by classical obtain ⟨hi,hS,hcolor,hdegree⟩ := hlegal simp only [op869_sequential_next, dif_pos hi, op869_prefix_invariant, Op869SequentialState.i, Op869SequentialState.P, Op869SequentialState.C] constructor · omega · constructor · exact hcolor · intro a ha have hai : a ≠ (⟨s.i,hi⟩ : Fin n) := by intro heq have hv := congrArg Fin.val heq change a.val = s.i at hv omega have hbefore := hinv.2.2 a (by omega) constructor · simpa [Function.update_of_ne hai] using hbefore.1 · simpa [Function.update_of_ne hai] using hbefore.2theorem op869_empty_prefix_invariant (n k : ℕ) (hk : 1 ≤ k) : op869_prefix_invariant k (⟨0, (fun _ : Fin n => ∅), (fun _ : Fin n => ∅)⟩ : Op869SequentialState n) := by refine ⟨by change 0 ≤ n; omega, ?_, ?_⟩ · refine ⟨SimpleGraph.Coloring.mk (fun _ : Fin n => (⟨0, by omega⟩ : Fin k)) ?_⟩ intro a b hadj change (a < b ∧ a ∈ (∅ : Finset (Fin n))) ∨ (b < a ∧ b ∈ (∅ : Finset (Fin n))) at hadj simp at hadj · simp/-- Fresh-prefix invariant for sequential online games. -/theorem op869_game_maintains_prefix {n : ℕ} (k D t : ℕ) (goal : Op869SequentialState n → Prop) (fuel : ℕ) (s : Op869SequentialState n) (hinv : op869_prefix_invariant k s) (hgame : op869_sequential_goal_game goal (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next fuel s) : op869_sequential_goal_game (fun s => op869_prefix_invariant k s ∧ goal s) (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next fuel s := by apply op869_game_preserves_invariant goal (op869_prefix_invariant k) (op869_sequential_legal k D) (op869_sequential_valid t) op869_sequential_next (op869_legal_step_preserves_prefix k D t) fuel s hinv hgame