op_2051_slow_exact_nim_joint_seven_witness
In slow exact k-Nim on k+2 piles, for every integer k ≥ 3, the geometric padded witness position slow_exact_nim_geometric_padded_witness 2 k has Sprague-Grundy value 7 and misère invariant 7.
Statement
theorem op_2051_slow_exact_nim_joint_seven_witness (k : ℕ) (hk : 3 ≤ k) :
slow_exact_nim_grundy k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 ∧
slow_exact_nim_misere k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7- Formalizes
- arXiv:2611.14546; OP-2051
- Verified
- 20 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 8
- slow_exact_nim_grundyThe Sprague-Grundy value slow_exact_nim_grundy k n x of a position x : Fin n → ℕ in slow exact k-Nim on n piles is defined as…
- slow_exact_nim_misereThe misère invariant slow_exact_nim_misere k n x of a position x : Fin n → ℕ in slow exact k-Nim on n piles is defined as…
- slow_exact_nim_geometric_padded_witnessFor natural numbers r and k, slow_exact_nim_geometric_padded_witness r k is the position on k + r piles (represented as a function from…
- finset_mexThe minimum excluded natural number (mex) of a finite set of natural numbers s, defined as the smallest natural number not belonging to s.
- slow_exact_nim_followersFor natural numbers k and n and a position x : Fin n → ℕ, the finite set of legal followers slow_exact_nim_followers k n x is the set of…
- slow_exact_nim_misere_compFor natural numbers k and n, fuel : ℕ, and position x : Fin n → ℕ, the fuel-bounded misère invariant slow_exact_nim_misere_comp k n fuel x…
- slow_exact_nim_grundy_compFor natural numbers k and n, fuel : ℕ, and position x : Fin n → ℕ, the fuel-bounded Sprague-Grundy value slow_exact_nim_grundy_comp k n…
- slow_exact_nim_stepGiven a natural number n, a position x : Fin n → ℕ on n piles, and a subset of pile indices S : Finset (Fin n), the follower position…
Read back from the Lean
For every natural number $k$ such that $3 \le k$, both the slow exact Nim Grundy value (slow_exact_nim_grundy) and the misère value (slow_exact_nim_misere) of the $(k+2)$-pile position given by slow_exact_nim_geometric_padded_witness 2 k with parameter $k$ are equal to $7$.
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
The proof, explained
The proof evaluates the Sprague-Grundy value and misère invariant of the geometric padded witness position (1, 2, 4, 7, ..., 7) in slow exact k-Nim on k+2 piles by establishing a bisimulation with a finite abstract game on pile-size frequency vectors. Because each move decrements all piles except two, the k - 1 piles of size 7 decrement together, creating a uniform downward wave of padded piles. For k ≥ 6, the abstract state transitions become independent of the padding amount k - 6 because at most two piles can be skipped at the active level; for k in {3, 4, 5}, finite state spaces of size at most 55 are constructed directly. Each finite transition graph is verified by kernel computation (decide +kernel) to satisfy the mex rules for normal and misère play, yielding the value 7 in all cases.
Decidability of abstract legal moves, good states, and table correctness.
The predicate op2051jw_legal determines whether a pair of skipped pile sizes can be chosen from a pile count vector cv with all zero-piles skipped. The predicate op2051jw_good verifies that a base state has enough piles at the active level s.2 to absorb skipping. The predicate op2051jw_ok checks that a finite list of states forms a closed transition system satisfying the mex rules for normal and misère play. Because all definitions involve bounded quantification over finite types (Fin 8 and finite lists), Lean synthesizes decidability instances automatically by typeclass inference.
instance op2051jw_legal_dec (cv : Fin 8 → ℕ) : DecidablePred (op2051jw_legal cv) := by intro pp; unfold op2051jw_legal; infer_instance def op2051jw_fol (s : (Fin 8 → ℕ) × ℕ) : Finset ((Fin 8 → ℕ) × ℕ) := ((Finset.univ : Finset (Fin 8 × Fin 8)).filter (fun pp => op2051jw_legal s.1 pp)).image (fun pp => (op2051jw_shift s.1 (op2051jw_skip pp.1.val pp.2.val), s.2 - 1)) def op2051jw_gv (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (s : (Fin 8 → ℕ) × ℕ) : ℕ := ((L.find? (fun e => decide (e.1 = s))).map (fun e => e.2.1)).getD 0 def op2051jw_mv (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (s : (Fin 8 → ℕ) × ℕ) : ℕ := ((L.find? (fun e => decide (e.1 = s))).map (fun e => e.2.2)).getD 0 def op2051jw_good (s : (Fin 8 → ℕ) × ℕ) : Prop := s.2 ≤ 7 ∧ (∀ u : Fin 8, u.val = s.2 → 1 ≤ s.2 → 2 ≤ s.1 u) ∧ (s.2 = 0 → 3 ≤ s.1 0) def op2051jw_ok (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (good : Bool) : Prop := ∀ e ∈ L, (∀ s' ∈ op2051jw_fol e.1, s' ∈ L.map Prod.fst) ∧ op2051jw_gv L e.1 = finset_mex ((op2051jw_fol e.1).image (op2051jw_gv L)) ∧ op2051jw_mv L e.1 = (if (op2051jw_fol e.1).Nonempty then finset_mex ((op2051jw_fol e.1).image (op2051jw_mv L)) else 1) ∧ (e.1.2 = 0 → op2051jw_fol e.1 = ∅) ∧ e.1.2 ≤ 7 ∧ (good = true → op2051jw_good e.1) instance op2051jw_good_dec (s : (Fin 8 → ℕ) × ℕ) : Decidable (op2051jw_good s) := by unfold op2051jw_good; infer_instance instance op2051jw_ok_dec (L) (gd) : Decidable (op2051jw_ok L gd) := by unfold op2051jw_ok; infer_instance
The number of piles in a pair {ia, ib} with size vv equals the sum of indicator functions for ia and ib having size vv.
Filtering the universe of pile indices restricted to the pair {ia, ib} is rewritten as filtering the set {ia, ib}. Using Finset.filter_insert and Finset.filter_singleton, the set splits into cases based on whether x ia = vv and x ib = vv; since ia ≠ ib, the cardinality is 0, 1, or 2 accordingly.
uses
Finset.filter_insert,Finset.filter_singletontheorem op2051jw_pair_card {nn : ℕ} (x : Fin nn → ℕ) (ia ib : Fin nn) (hab : ia ≠ ib) (vv : ℕ) : (Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv)).card = (if x ia = vv then 1 else 0) + (if x ib = vv then 1 else 0) := by have : Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv) = ({ia, ib} : Finset (Fin nn)).filter (fun i => x i = vv) := by ext i; simp rw [this, Finset.filter_insert, Finset.filter_singleton] by_cases ha : x ia = vv <;> by_cases hb : x ib = vv <;> simp [ha, hb, hab]
The indicator sum of sizes at ia and ib is at most the total number of piles of size vv.
Rewriting the indicator sum as the cardinality of the pair filter via op2051jw_pair_card, the result follows from Finset.card_le_card because filtering over the pair is a subset of filtering over all piles by Finset.monotone_filter_right.
uses
op2051jw_pair_card,Finset.card_le_card,Finset.monotone_filter_righttheorem op2051jw_pair_le {nn : ℕ} (x : Fin nn → ℕ) (ia ib : Fin nn) (hab : ia ≠ ib) (vv : ℕ) : (if x ia = vv then 1 else 0) + (if x ib = vv then 1 else 0) ≤ (Finset.univ.filter (fun i => x i = vv)).card := by rw [← op2051jw_pair_card x ia ib hab vv] exact Finset.card_le_card (Finset.monotone_filter_right _ (fun i _ hq => hq.2))
A Nim step decrementing all piles except ia and ib shifts the pile counts by op2051jw_shift.
Every pile outside {ia, ib} is strictly positive and drops by 1, so x i - 1 = vv if and only if x i = vv + 1, while piles ia and ib retain their sizes. Summing indicator functions establishes that new piles of size vv plus skipped piles of size vv + 1 equals old piles of size vv + 1 plus skipped piles of size vv. Applying op2051jw_pair_card and distinguishing whether u + 1 < 8 yields the shifted count vector.
uses
Finset.card_filter,Finset.sum_congr,add_comm,op2051jw_pair_card,op2051jw_pair_le,Finset.card_eq_zero,Finset.filter_eq_empty_ifftheorem op2051jw_cnt_step {nn : ℕ} (x : Fin nn → ℕ) (hx : ∀ i, x i ≤ 7) (ia ib : Fin nn) (hab : ia ≠ ib) (hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i) (u : Fin 8) : op2051jw_cnt (slow_exact_nim_step x ({ia, ib}ᶜ)) u = op2051jw_shift (op2051jw_cnt x) (op2051jw_skip (x ia) (x ib)) u := by have key : ∀ vv : ℕ, (Finset.univ.filter (fun i => slow_exact_nim_step x ({ia, ib}ᶜ) i = vv)).card + (Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv + 1)).card = (Finset.univ.filter (fun i => x i = vv + 1)).card + (Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv)).card := by intro vv simp only [Finset.card_filter, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl (fun i _ => ?_) by_cases hi : i = ia ∨ i = ib · have : i ∉ ({ia, ib} : Finset (Fin nn))ᶜ := by simp; tauto simp only [slow_exact_nim_step, this, if_false, hi, true_and] exact add_comm _ _ · have : i ∈ ({ia, ib} : Finset (Fin nn))ᶜ := by simpa using hi have hp := hpos i (fun hq => hi (Or.inl hq)) (fun hq => hi (Or.inr hq)) have e : (x i - 1 = vv) ↔ (x i = vv + 1) := by omega simp only [slow_exact_nim_step, this, if_true, hi, false_and, if_false, e] have k1 := key u.val rw [op2051jw_pair_card x ia ib hab, op2051jw_pair_card x ia ib hab] at k1 have hle := op2051jw_pair_le x ia ib hab (u.val + 1) unfold op2051jw_cnt op2051jw_shift op2051jw_skip by_cases hq : u.val + 1 < 8 · rw [dif_pos hq] show _ = ((Finset.univ.filter (fun i => x i = u.val + 1)).card - ((if x ia = u.val + 1 then 1 else 0) + (if x ib = u.val + 1 then 1 else 0))) + _ omega · rw [dif_neg hq] have h0 : (Finset.univ.filter (fun i => x i = u.val + 1)).card = 0 := by rw [Finset.card_eq_zero, Finset.filter_eq_empty_iff] intro i _; have := hx i; omega omega
Shifting a pile configuration containing j padded piles at level m shifts the j padded piles to level m - 1.
The shift operation decrements all unskipped piles. When evaluating the count at level u = m - 1, the shifted count draws from piles of size m. Since the skipped count dv m does not exceed the base count cv m, subtracting dv m preserves all j extra piles, placing them exactly at level m - 1. All other pile counts shift without modification.
theorem op2051jw_shift_embed (cv dv : Fin 8 → ℕ) (m j : ℕ) (hm1 : 1 ≤ m) (hm7 : m ≤ 7) (hdd : ∀ u : Fin 8, u.val = m → dv u ≤ cv u) (u : Fin 8) : op2051jw_shift (fun u => cv u + if u.val = m then j else 0) dv u = op2051jw_shift cv dv u + if u.val = m - 1 then j else 0 := by unfold op2051jw_shift by_cases hq : u.val + 1 < 8 · rw [dif_pos hq, dif_pos hq] show (cv ⟨u.val + 1, hq⟩ + (if u.val + 1 = m then j else 0)) - dv ⟨u.val + 1, hq⟩ + dv u = (cv ⟨u.val + 1, hq⟩ - dv ⟨u.val + 1, hq⟩ + dv u) + (if u.val = m - 1 then j else 0) by_cases hu : u.val + 1 = m · have := hdd ⟨u.val + 1, hq⟩ hu rw [if_pos hu, if_pos (by omega)]; omega · rw [if_neg hu, if_neg (by omega)]; omega · rw [dif_neg hq, dif_neg hq] have : u.val ≠ m - 1 := by omega simp [this]
A Nim step preserves the simulation relation op2051jw_rel with the active level marker stepping from s.2 to s.2 - 1.
Pile sizes remain bounded by 7 because unskipped piles decrease while skipped piles stay the same. The pile counts after the step match op2051jw_shift by op2051jw_cnt_step. Applying op2051jw_shift_embed via funext transfers the j extra piles from level s.2 to level s.2 - 1, maintaining the invariant.
uses
op2051jw_cnt_step,funext,op2051jw_shift_embedtheorem op2051jw_rel_step {nn : ℕ} (j : ℕ) (x : Fin nn → ℕ) (s : (Fin 8 → ℕ) × ℕ) (hr : op2051jw_rel j x s) (ia ib : Fin nn) (hab : ia ≠ ib) (hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i) (hm1 : 1 ≤ s.2) (hm7 : s.2 ≤ 7) (hdd : ∀ u : Fin 8, u.val = s.2 → op2051jw_skip (x ia) (x ib) u ≤ s.1 u) : op2051jw_rel j (slow_exact_nim_step x ({ia, ib}ᶜ)) (op2051jw_shift s.1 (op2051jw_skip (x ia) (x ib)), s.2 - 1) := by refine ⟨fun i => ?_, fun u => ?_⟩ · have := hr.1 i; unfold slow_exact_nim_step; split_ifs <;> omega · rw [op2051jw_cnt_step x hr.1 ia ib hab hpos u] have hc : op2051jw_cnt x = fun u => s.1 u + if u.val = s.2 then j else 0 := funext hr.2 rw [hc, op2051jw_shift_embed _ _ _ _ hm1 hm7 hdd]
Auxiliary properties: at most two piles are skipped at any size, all size-vv piles are skipped when no other piles have size vv, and abstract transitions decrement the level marker.
The skipped count is a sum of two boolean indicators, so it is bounded by 2. When every pile of size vv belongs to {ia, ib}, the total count equals the pair count via op2051jw_pair_card. By definition of op2051jw_fol, the second component of any follower state is s.2 - 1.
uses
op2051jw_pair_cardtheorem op2051jw_skip_le_two (vv wv : ℕ) (u : Fin 8) : op2051jw_skip vv wv u ≤ 2 := by unfold op2051jw_skip; split_ifs <;> omega theorem op2051jw_cnt_eq_skip {nn : ℕ} (x : Fin nn → ℕ) (ia ib : Fin nn) (hab : ia ≠ ib) (vv : ℕ) (hsub : ∀ i, x i = vv → i = ia ∨ i = ib) : (Finset.univ.filter (fun i => x i = vv)).card = (if x ia = vv then 1 else 0) + (if x ib = vv then 1 else 0) := by rw [← op2051jw_pair_card x ia ib hab vv] congr 1; ext i; simp only [Finset.mem_filter, Finset.mem_univ, true_and] constructor · intro hq; exact ⟨hsub i hq, hq⟩ · intro hq; exact hq.2 theorem op2051jw_fol_snd (s s' : (Fin 8 → ℕ) × ℕ) (hq : s' ∈ op2051jw_fol s) : s'.2 = s.2 - 1 := by unfold op2051jw_fol at hq obtain ⟨pp, _, rfl⟩ := Finset.mem_image.1 hq rfl
Forward bisimulation: every legal move in slow exact k-Nim on k+2 piles induces a valid transition in the abstract game.
In slow exact k-Nim on k+2 piles, choosing k positive piles to decrement leaves a complement of size 2 by Finset.card_compl and Fintype.card_fin, which by Finset.card_eq_two defines a unique pair of skipped piles {ia, ib}. All piles of size 0 must be skipped, satisfying op2051jw_legal. The condition that either j = 0 or s is good ensures that the base count at level s.2 suffices to skip up to two piles without consuming padding. Hence the follower state belongs to op2051jw_fol s and preserves op2051jw_rel by op2051jw_rel_step.
uses
Finset.card_compl,Fintype.card_fin,Finset.card_eq_two,compl_compl,op2051jw_cnt_eq_skip,op2051jw_pair_le,op2051jw_skip_le_two,Fin.ext,op2051jw_rel_steptheorem op2051jw_fwd (k j : ℕ) (x : Fin (k + 2) → ℕ) (s : (Fin 8 → ℕ) × ℕ) (hr : op2051jw_rel j x s) (hm0 : s.2 = 0 → op2051jw_fol s = ∅) (hm7 : s.2 ≤ 7) (hG : j = 0 ∨ op2051jw_good s) (y : Fin (k + 2) → ℕ) (hy : y ∈ slow_exact_nim_followers k (k + 2) x) : ∃ s' ∈ op2051jw_fol s, op2051jw_rel j y s' := by unfold slow_exact_nim_followers at hy obtain ⟨SS, hS, rfl⟩ := Finset.mem_image.1 hy rw [Finset.mem_filter, Finset.mem_powersetCard] at hS have hc2 : SSᶜ.card = 2 := by rw [Finset.card_compl, Fintype.card_fin, hS.1.2]; omega obtain ⟨ia, ib, hab, hSab⟩ := Finset.card_eq_two.1 hc2 have hS' : SS = ({ia, ib} : Finset (Fin (k + 2)))ᶜ := by rw [← hSab, compl_compl] subst hS' have hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i := by intro i ha hb; apply hS.2; simp [ha, hb] have hxa := hr.1 ia have hxb := hr.1 ib have hcnt0 : op2051jw_cnt x 0 = op2051jw_skip (x ia) (x ib) 0 := by unfold op2051jw_cnt op2051jw_skip rw [op2051jw_cnt_eq_skip x ia ib hab] intro i hi by_contra hne; replace hne := not_or.1 hne have := hpos i hne.1 hne.2; simp at hi; omega have hle : ∀ u, op2051jw_skip (x ia) (x ib) u ≤ op2051jw_cnt x u := fun u => op2051jw_pair_le x ia ib hab u.val have h0 := hr.2 0 have hs0 := op2051jw_skip_le_two (x ia) (x ib) 0 -- the move is legal in the abstract game have hlegal : op2051jw_legal s.1 (⟨x ia, by omega⟩, ⟨x ib, by omega⟩) := by refine ⟨fun u => ?_, ?_⟩ · have h1 := hr.2 u have h2 := hle u have h3 := op2051jw_skip_le_two (x ia) (x ib) u show op2051jw_skip (x ia) (x ib) u ≤ s.1 u by_cases hu : u.val = s.2 · rw [if_pos hu] at h1 rcases hG with hj | hg · subst hj; omega · by_cases hm : 1 ≤ s.2 · have := hg.2.1 u hu hm; omega · have h4 := hg.2.2 (by omega) have hu0 : u = 0 := Fin.ext (by simp; omega) subst hu0 simp only [Fin.val_zero] at h0 rw [if_pos (by omega)] at h0 omega · rw [if_neg hu] at h1; omega · show s.1 0 = op2051jw_skip (x ia) (x ib) 0 by_cases hu : (0 : Fin 8).val = s.2 · rw [if_pos hu] at h0 rcases hG with hj | hg · subst hj; omega · have h4 := hg.2.2 (by simp at hu; omega); omega · rw [if_neg hu] at h0; omega have hmem : (op2051jw_shift s.1 (op2051jw_skip (x ia) (x ib)), s.2 - 1) ∈ op2051jw_fol s := by unfold op2051jw_fol exact Finset.mem_image.2 ⟨_, Finset.mem_filter.2 ⟨Finset.mem_univ _, hlegal⟩, rfl⟩ have hm1 : 1 ≤ s.2 := by by_contra hm have := hm0 (by omega) rw [this] at hmem; simp at hmem refine ⟨_, hmem, op2051jw_rel_step j x s hr ia ib hab hpos hm1 hm7 (fun u _ => hlegal.1 u)⟩
Backward bisimulation: every abstract follower transition is realizable by a legal move in slow exact k-Nim.
Given an abstract transition skipping pile sizes pp.1 and pp.2, the hypothesis dv ≤ cv allows selecting two distinct pile indices ia and ib with x ia = pp.1 and x ib = pp.2 using Finset.card_pos and Finset.card_erase_of_mem. The legality condition cv 0 = dv 0 ensures that all piles of size 0 are in {ia, ib}, so all remaining k piles are positive. Decrementing the complement {ia, ib}ᶜ gives a valid follower in slow exact k-Nim whose counts satisfy op2051jw_rel by op2051jw_rel_step.
uses
Finset.card_pos,Finset.card_erase_of_mem,Fin.ext,Finset.eq_of_subset_of_card_le,Finset.monotone_filter_right,op2051jw_pair_card,Finset.card_compl,Fintype.card_fin,Finset.card_pair,op2051jw_rel_steptheorem op2051jw_bwd (k j : ℕ) (x : Fin (k + 2) → ℕ) (s : (Fin 8 → ℕ) × ℕ) (hr : op2051jw_rel j x s) (hm0 : s.2 = 0 → op2051jw_fol s = ∅) (hm7 : s.2 ≤ 7) (s' : (Fin 8 → ℕ) × ℕ) (hs' : s' ∈ op2051jw_fol s) : ∃ y ∈ slow_exact_nim_followers k (k + 2) x, op2051jw_rel j y s' := by have hm1 : 1 ≤ s.2 := by by_contra hm have := hm0 (by omega) rw [this] at hs'; simp at hs' unfold op2051jw_fol at hs' obtain ⟨pp, hp, rfl⟩ := Finset.mem_image.1 hs' have hp := (Finset.mem_filter.1 hp).2 have hge : ∀ u, op2051jw_skip pp.1.val pp.2.val u ≤ op2051jw_cnt x u := by intro u; have := hr.2 u; have := hp.1 u; omega -- choose ia with x ia = pp.1 have h1 := hge pp.1 have hpos1 : 0 < (Finset.univ.filter (fun i => x i = pp.1.val)).card := by have : 1 ≤ op2051jw_skip pp.1.val pp.2.val pp.1 := by unfold op2051jw_skip; simp exact lt_of_lt_of_le this h1 obtain ⟨ia, ha⟩ := Finset.card_pos.1 hpos1 have ha : x ia = pp.1.val := (Finset.mem_filter.1 ha).2 have hbex : ∃ ib, ib ≠ ia ∧ x ib = pp.2.val := by by_cases he : pp.1 = pp.2 · have h2 := hge pp.2 have : 2 ≤ (Finset.univ.filter (fun i => x i = pp.2.val)).card := by have : op2051jw_skip pp.1.val pp.2.val pp.2 = 2 := by unfold op2051jw_skip; simp [he] unfold op2051jw_cnt at h2; omega have hpos : 0 < ((Finset.univ.filter (fun i => x i = pp.2.val)).erase ia).card := by rw [Finset.card_erase_of_mem (by simp [ha, he])]; omega obtain ⟨ib, hb⟩ := Finset.card_pos.1 hpos rw [Finset.mem_erase, Finset.mem_filter] at hb exact ⟨ib, hb.1, hb.2.2⟩ · have h2 := hge pp.2 have : 0 < (Finset.univ.filter (fun i => x i = pp.2.val)).card := by have : 1 ≤ op2051jw_skip pp.1.val pp.2.val pp.2 := by unfold op2051jw_skip; simp unfold op2051jw_cnt at h2; omega obtain ⟨ib, hb⟩ := Finset.card_pos.1 this have hb : x ib = pp.2.val := (Finset.mem_filter.1 hb).2 refine ⟨ib, ?_, hb⟩ rintro rfl; exact he (Fin.ext (by omega)) obtain ⟨ib, hba, hb⟩ := hbex have hab : ia ≠ ib := fun hq => hba hq.symm have hskip : op2051jw_skip (x ia) (x ib) = op2051jw_skip pp.1.val pp.2.val := by rw [ha, hb] -- positivity off {ia, ib} have hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i := by intro i hia hib by_contra hz have hz : x i = 0 := by omega have hc0 : op2051jw_cnt x 0 = op2051jw_skip (x ia) (x ib) 0 := by have := hr.2 0 rw [if_neg (by simp; omega)] at this rw [this, hskip]; exact hp.2 have hsub : Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = 0) = Finset.univ.filter (fun i => x i = 0) := by apply Finset.eq_of_subset_of_card_le · exact Finset.monotone_filter_right _ (fun i _ hq => hq.2) · rw [op2051jw_pair_card x ia ib hab] unfold op2051jw_cnt op2051jw_skip at hc0 simp only [Fin.val_zero] at hc0 omega have : i ∈ Finset.univ.filter (fun i => x i = 0) := by simp [hz] rw [← hsub] at this simp at this rcases this.1 with hq | hq · exact hia hq · exact hib hq refine ⟨slow_exact_nim_step x ({ia, ib}ᶜ), ?_, ?_⟩ · unfold slow_exact_nim_followers refine Finset.mem_image.2 ⟨_, Finset.mem_filter.2 ⟨?_, ?_⟩, rfl⟩ · rw [Finset.mem_powersetCard] refine ⟨Finset.subset_univ _, ?_⟩ rw [Finset.card_compl, Fintype.card_fin, Finset.card_pair hab]; omega · intro i hi; simp at hi; exact hpos i hi.1 hi.2 · have := op2051jw_rel_step j x s hr ia ib hab hpos hm1 hm7 (fun u _ => by rw [hskip]; exact hp.1 u) rw [hskip] at this exact this
Inductive equivalence: game values match the table entries for both Sprague-Grundy values and misère invariants.
By induction on fuel f. At f = 0, s.2 = 0 implies there are no followers, matching the terminal values (0 for normal play, 1 for misère play). For the induction step, forward and backward bisimulation (op2051jw_fwd and op2051jw_bwd) show that the set of follower values in the real game equals the set of follower values in the abstract table. Since every follower state has level s.2 - 1 ≤ f by op2051jw_fol_snd, the induction hypothesis applies to each follower, and the mex operations match.
uses
List.mem_map,op2051jw_fwd,op2051jw_fol_snd,op2051jw_bwd,Finset.image_nonemptytheorem op2051jw_main (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (gd : Bool) (hok : op2051jw_ok L gd) (k j : ℕ) (hj : j = 0 ∨ gd = true) : ∀ f (x : Fin (k + 2) → ℕ) (s : (Fin 8 → ℕ) × ℕ), s ∈ L.map Prod.fst → op2051jw_rel j x s → s.2 ≤ f → slow_exact_nim_grundy_comp k (k + 2) f x = op2051jw_gv L s ∧ slow_exact_nim_misere_comp k (k + 2) f x = op2051jw_mv L s := by intro f induction f with | zero => intro x s hs _ hf obtain ⟨e, he, rfl⟩ := List.mem_map.1 hs obtain ⟨_, hgv, hmv, hm0, _, _⟩ := hok e he have hf0 := hm0 (by omega) rw [hf0] at hgv hmv refine ⟨?_, ?_⟩ · rw [hgv]; rfl · rw [hmv]; simp; rfl | succ f ih => intro x s hs hr hf obtain ⟨e, he, rfl⟩ := List.mem_map.1 hs obtain ⟨hcl, hgv, hmv, hm0, hm7, hgd⟩ := hok e he have hG : j = 0 ∨ op2051jw_good e.1 := by rcases hj with hq | hq · exact Or.inl hq · exact Or.inr (hgd hq) have hstep : ∀ y ∈ slow_exact_nim_followers k (k + 2) x, ∃ s' ∈ op2051jw_fol e.1, slow_exact_nim_grundy_comp k (k + 2) f y = op2051jw_gv L s' ∧ slow_exact_nim_misere_comp k (k + 2) f y = op2051jw_mv L s' := by intro y hy obtain ⟨s', hs', hr'⟩ := op2051jw_fwd k j x e.1 hr hm0 hm7 hG y hy have h2 := op2051jw_fol_snd _ _ hs' exact ⟨s', hs', ih y s' (hcl s' hs') hr' (by omega)⟩ have hstep' : ∀ s' ∈ op2051jw_fol e.1, ∃ y ∈ slow_exact_nim_followers k (k + 2) x, slow_exact_nim_grundy_comp k (k + 2) f y = op2051jw_gv L s' ∧ slow_exact_nim_misere_comp k (k + 2) f y = op2051jw_mv L s' := by intro s' hs' obtain ⟨y, hy, hr'⟩ := op2051jw_bwd k j x e.1 hr hm0 hm7 s' hs' have h2 := op2051jw_fol_snd _ _ hs' exact ⟨y, hy, ih y s' (hcl s' hs') hr' (by omega)⟩ have himg : (slow_exact_nim_followers k (k + 2) x).image (slow_exact_nim_grundy_comp k (k + 2) f) = (op2051jw_fol e.1).image (op2051jw_gv L) := by ext vv; simp only [Finset.mem_image] constructor · rintro ⟨y, hy, rfl⟩ obtain ⟨s', hs', h1, _⟩ := hstep y hy exact ⟨s', hs', h1.symm⟩ · rintro ⟨s', hs', rfl⟩ obtain ⟨y, hy, h1, _⟩ := hstep' s' hs' exact ⟨y, hy, h1⟩ have himg' : (slow_exact_nim_followers k (k + 2) x).image (slow_exact_nim_misere_comp k (k + 2) f) = (op2051jw_fol e.1).image (op2051jw_mv L) := by ext vv; simp only [Finset.mem_image] constructor · rintro ⟨y, hy, rfl⟩ obtain ⟨s', hs', _, h1⟩ := hstep y hy exact ⟨s', hs', h1.symm⟩ · rintro ⟨s', hs', rfl⟩ obtain ⟨y, hy, _, h1⟩ := hstep' s' hs' exact ⟨y, hy, h1⟩ have hne : (slow_exact_nim_followers k (k + 2) x).Nonempty ↔ (op2051jw_fol e.1).Nonempty := by rw [← Finset.image_nonempty (f := slow_exact_nim_grundy_comp k (k + 2) f), himg, Finset.image_nonempty] refine ⟨?_, ?_⟩ · show finset_mex _ = _ rw [himg, hgv] · show (if _ then _ else _) = _ rw [hmv] by_cases hq : (op2051jw_fol e.1).Nonempty · rw [if_pos (hne.2 hq), if_pos hq, himg'] · rw [if_neg (fun h' => hq (hne.1 h')), if_neg hq]
The geometric padded witness position has 1 pile each of sizes 1, 2, and 4, and k - 1 piles of size 7.
Unfolding the definition of slow_exact_nim_geometric_padded_witness with r = 2, piles 0, 1, 2 have sizes 2⁰ = 1, 2¹ = 2, and 2² = 4, while the remaining (k + 2) - 3 = k - 1 piles have size 2³ - 1 = 7. Splitting the sum of indicators over Finset.range (k + 2) into ranges [0, 3) and [3, k + 2) via Fin.sum_univ_eq_sum_range and Finset.sum_range_add confirms the pile count formula.
uses
Fin.sum_univ_eq_sum_range,Finset.sum_range_add,Finset.sum_congr,smul_eq_multheorem op2051jw_wcnt (k : ℕ) (hk : 3 ≤ k) (u : Fin 8) : op2051jw_cnt (slow_exact_nim_geometric_padded_witness 2 k) u = (if u.val = 1 ∨ u.val = 2 ∨ u.val = 4 then 1 else 0) + (if u.val = 7 then k - 1 else 0) := by unfold op2051jw_cnt slow_exact_nim_geometric_padded_witness rw [Finset.card_filter] rw [Fin.sum_univ_eq_sum_range (fun i => if (if i ≤ 2 then 2 ^ i else 2 ^ (2 + 1) - 1) = u.val then 1 else 0) (k + 2)] rw [show k + 2 = 3 + (k - 1) by omega, Finset.sum_range_add] have : ∀ x ∈ Finset.range (k - 1), (if (if 3 + x ≤ 2 then 2 ^ (3 + x) else 2 ^ (2 + 1) - 1) = u.val then 1 else 0) = (if 7 = u.val then 1 else 0) := by intro x _; rw [if_neg (show ¬ 3 + x ≤ 2 by omega)]; norm_num rw [Finset.sum_congr rfl this, Finset.sum_const, Finset.card_range, smul_eq_mul] simp only [Finset.sum_range_succ, Finset.sum_range_zero] fin_cases u <;> norm_num
The geometric padded witness position satisfies op2051jw_rel with padding k - K relative to the base state (0, 1, 1, 0, 1, 0, 0, K - 1) at level 7.
All pile sizes are bounded by 7 because 2² ≤ 7 and 7 ≤ 7. By op2051jw_wcnt, the pile counts match the vector (0, 1, 1, 0, 1, 0, 0, K - 1) plus (k - 1) - (K - 1) = k - K extra piles at size 7. Verifying each size u ∈ Fin 8 confirms the relation.
uses
Nat.pow_le_pow_right,op2051jw_wcnttheorem op2051jw_wrel (k K : ℕ) (hK : 3 ≤ K) (hKk : K ≤ k) : op2051jw_rel (k - K) (slow_exact_nim_geometric_padded_witness 2 k) (![0, 1, 1, 0, 1, 0, 0, K - 1], 7) := by refine ⟨fun i => ?_, fun u => ?_⟩ · unfold slow_exact_nim_geometric_padded_witness split_ifs with hq · calc 2 ^ i.val ≤ 2 ^ 2 := Nat.pow_le_pow_right (by norm_num) hq _ ≤ 7 := by norm_num · norm_num · rw [op2051jw_wcnt k (by omega) u] fin_cases u <;> simp <;> omega
The sum of all pile sizes in the witness position is at least 7.
Since k ≥ 3, pile index 3 exists and has size 7. By Finset.single_le_sum, a single non-negative term is bounded by the total sum of all pile sizes.
uses
Finset.single_le_sumtheorem op2051jw_wsum (k : ℕ) (hk : 3 ≤ k) : 7 ≤ ∑ i, slow_exact_nim_geometric_padded_witness 2 k i := by have := Finset.single_le_sum (f := slow_exact_nim_geometric_padded_witness 2 k) (fun i _ => Nat.zero_le _) (Finset.mem_univ (⟨3, by omega⟩ : Fin (k + 2))) unfold slow_exact_nim_geometric_padded_witness at this ⊢ simpa using this
Kernel verification of the finite transition tables for k = 3, 4, 5, and k ≥ 6. automation
Lean's kernel checks by direct computation (decide +kernel) that tables 3, 4, and 5 (with good = false) and table 6 (with good = true) satisfy op2051jw_ok: each table is closed under followers, terminal states have no followers, and the stored Grundy and misère values satisfy the mex equations.
set_option maxRecDepth 100000 in theorem op2051jw_ok3 : op2051jw_ok op2051jw_table3 false := by decide +kernel set_option maxRecDepth 100000 in theorem op2051jw_ok4 : op2051jw_ok op2051jw_table4 false := by decide +kernel set_option maxRecDepth 100000 in theorem op2051jw_ok5 : op2051jw_ok op2051jw_table5 false := by decide +kernel set_option maxRecDepth 100000 in theorem op2051jw_ok6 : op2051jw_ok op2051jw_table6 true := by decide +kernel
Evaluation rule: if a verified table contains the base state with Grundy and misère values 7, the game values on the witness are both 7.
The game values are defined with fuel equal to the sum of piles, which is at least 7 by op2051jw_wsum. Since the witness position satisfies op2051jw_rel with level marker 7 by op2051jw_wrel, op2051jw_main applies and equates the game's Grundy and misère values to the values 7 stored in the table.
uses
op2051jw_main,op2051jw_wrel,op2051jw_wsumtheorem op2051jw_apply (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (gd : Bool) (hok : op2051jw_ok L gd) (k K : ℕ) (hK : 3 ≤ K) (hKk : K ≤ k) (hj : k - K = 0 ∨ gd = true) (hs : ((![0, 1, 1, 0, 1, 0, 0, K - 1], 7) : (Fin 8 → ℕ) × ℕ) ∈ L.map Prod.fst) (hv : op2051jw_gv L (![0, 1, 1, 0, 1, 0, 0, K - 1], 7) = 7 ∧ op2051jw_mv L (![0, 1, 1, 0, 1, 0, 0, K - 1], 7) = 7) : slow_exact_nim_grundy k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 ∧ slow_exact_nim_misere k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 := by have hq := op2051jw_main L gd hok k (k - K) hj _ _ _ hs (op2051jw_wrel k K hK hKk) (op2051jw_wsum k (by omega)) unfold slow_exact_nim_grundy slow_exact_nim_misere rw [hq.1, hq.2]; exact hv
In slow exact k-Nim on k+2 piles for all k ≥ 3, the geometric padded witness position has Sprague-Grundy value 7 and misère invariant 7.
We split into cases on whether 6 ≤ k. If 6 ≤ k, op2051jw_apply is invoked with table 6, K = 6, and gd = true, where membership and values are checked by decide. If k < 6, the assumption 3 ≤ k restricts k to {3, 4, 5}, handled by interval_cases k; in each case, op2051jw_apply is invoked with table 3, 4, or 5 and K = k, j = 0, with membership and values checked by decide.
uses
op2051jw_apply,op2051jw_ok6,op2051jw_ok3,op2051jw_ok4,op2051jw_ok5/-- The geometric padded witness position achieves Sprague-Grundy value 7 and misère invariant 7 in slow exact k-Nim on k+2 piles for all k ≥ 3. -/ theorem op_2051_slow_exact_nim_joint_seven_witness (k : ℕ) (hk : 3 ≤ k) : slow_exact_nim_grundy k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 ∧ slow_exact_nim_misere k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 := by by_cases h6 : 6 ≤ k · exact op2051jw_apply _ true op2051jw_ok6 k 6 (by norm_num) h6 (Or.inr rfl) (by decide) (by decide) · interval_cases k · exact op2051jw_apply _ false op2051jw_ok3 3 3 le_rfl le_rfl (Or.inl rfl) (by decide) (by decide) · exact op2051jw_apply _ false op2051jw_ok4 4 4 (by norm_num) le_rfl (Or.inl rfl) (by decide) (by decide) · exact op2051jw_apply _ false op2051jw_ok5 5 5 (by norm_num) le_rfl (Or.inl rfl) (by decide) (by decide)
add_comm- Addition is commutative in any additive commutative magma: a + b = b + a.
compl_compl- Double complementation in a Boolean algebra is the identity: xᶜᶜ = x.
Fin.ext- Two elements of Fin n are equal if and only if their underlying natural numbers are equal.
Fin.sum_univ_eq_sum_range- A sum over all elements of Fin n equals the sum over the range 0 to n.
Finset.card_compl- The cardinality of the complement of a subset s of a finite type is the cardinality of the type minus the cardinality of s.
Finset.card_eq_two- A finite set has cardinality 2 if and only if it consists of two distinct elements.
Finset.card_eq_zero- A finite set has cardinality 0 if and only if it is empty.
Finset.card_erase_of_mem- Erasing an element from a finite set decreases its cardinality by 1.
Finset.card_filter- The cardinality of a filtered subset equals the sum of indicators of the filtering predicate.
Finset.card_le_card- If s is a subset of t, the cardinality of s is at most that of t.
Finset.card_pair- A set containing two distinct elements has cardinality 2.
Finset.card_pos- A finite set has positive cardinality if and only if it is non-empty.
Finset.eq_of_subset_of_card_le- If s is a subset of t and the cardinality of t is at most that of s, then s = t.
Finset.filter_eq_empty_iff- Filtering an empty set or a condition that is everywhere false yields the empty set.
Finset.filter_insert- Filtering after inserting an element adds the element if it satisfies the predicate, and leaves the filtered set unchanged otherwise.
Finset.filter_singleton- Filtering a singleton set yields the singleton if the element satisfies the predicate, and the empty set otherwise.
Finset.image_nonempty- The image of a finite set under a function is non-empty if and only if the original set is non-empty.
Finset.monotone_filter_right- If predicate p implies predicate q on all elements of s, then filtering by p produces a subset of filtering by q.
Finset.single_le_sum- A single term in a finite sum of non-negative elements is at most the total sum.
Finset.sum_congr- Two sums over the same finite set are equal if their summands agree on every element.
Finset.sum_range_add- A sum over the range n + m can be split into the sum over range n and the sum over range m shifted by n.
Fintype.card_fin- The cardinality of Fin n is n.
funext- Two functions are equal if they agree on all inputs (functional extensionality).
List.mem_map- An element is in the image of a list under f if and only if it is the image of some element in the list.
Nat.pow_le_pow_right- Power with base at least 1 is monotonically non-decreasing in the exponent.
op2051jw_apply- If a verified table contains the base state for K ≤ k with Grundy and misère values 7, the real game values on the geometric padded witness are both 7.
op2051jw_bwd- Backward bisimulation: every abstract follower transition from state s can be realized by a legal move in slow exact k-Nim.
op2051jw_cnt_eq_skip- When all piles of size vv are among {ia, ib}, the total count of piles of size vv equals the pair indicator sum.
op2051jw_cnt_step- After decrementing all piles except ia and ib, the new pile counts match the shifted count vector minus skipped piles at u+1 plus skipped piles at u.
op2051jw_fol_snd- Every abstract follower of state s has active level marker decremented by 1.
op2051jw_fwd- Forward bisimulation: every legal move in slow exact k-Nim corresponds to a transition in the abstract game.
op2051jw_main- By induction on fuel, game states related to entries in a verified table have Grundy and misère values matching the table entries.
op2051jw_ok3- Precomputed table 3 for k = 3 satisfies the transition table validity predicate.
op2051jw_ok4- Precomputed table 4 for k = 4 satisfies the transition table validity predicate.
op2051jw_ok5- Precomputed table 5 for k = 5 satisfies the transition table validity predicate.
op2051jw_ok6- Precomputed table 6 for k ≥ 6 satisfies the transition table validity predicate with the goodness invariant.
op2051jw_pair_card- The number of piles in {ia, ib} of size vv equals the sum of the indicators for whether ia and ib have size vv.
op2051jw_pair_le- The sum of indicators for whether two piles have size vv is bounded above by the total count of piles of size vv.
op2051jw_rel_step- One move in slow exact Nim preserves the simulation relation op2051jw_rel, decrementing the active level marker by 1.
op2051jw_shift_embed- Shifting pile counts with j extra piles at level m shifts the extra j piles down to level m - 1.
op2051jw_skip_le_two- The number of skipped piles of any given size is at most 2.
op2051jw_wcnt- The geometric padded witness position with parameter 2 on k+2 piles has 1 pile each of sizes 1, 2, 4, and k - 1 piles of size 7.
op2051jw_wrel- The geometric padded witness position is related by op2051jw_rel with padding k - K to the base state with counts (0, 1, 1, 0, 1, 0, 0, K - 1) at level 7.
op2051jw_wsum- The sum of pile sizes in the geometric padded witness position is at least 7.
smul_eq_mul- Scalar multiplication by a natural number equals ordinary multiplication.
- The validity of the four finite transition tables (tables 3, 4, 5, and 6) is verified entirely by Lean's kernel computation (`decide +kernel`), which checks state closure, the mex recursion for both normal and misère values, and the goodness condition for table 6.
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.
Lean’s trace was cut to the first 400 of 405 tactics.
/-- number of piles of size vv -/def op2051jw_cnt {nn : ℕ} (x : Fin nn → ℕ) (u : Fin 8) : ℕ := (Finset.univ.filter (fun i => x i = u.val)).carddef op2051jw_skip (vv wv : ℕ) (u : Fin 8) : ℕ := (if vv = u.val then 1 else 0) + (if wv = u.val then 1 else 0)def op2051jw_shift (cv dv : Fin 8 → ℕ) (u : Fin 8) : ℕ := (if hq : u.val + 1 < 8 then cv ⟨u.val + 1, hq⟩ - dv ⟨u.val + 1, hq⟩ else 0) + dv udef op2051jw_legal (cv : Fin 8 → ℕ) (pp : Fin 8 × Fin 8) : Prop := (∀ u : Fin 8, op2051jw_skip pp.1.val pp.2.val u ≤ cv u) ∧ cv 0 = op2051jw_skip pp.1.val pp.2.val 0instance op2051jw_legal_dec (cv : Fin 8 → ℕ) : DecidablePred (op2051jw_legal cv) := by intro pp; unfold op2051jw_legal; infer_instancedef op2051jw_fol (s : (Fin 8 → ℕ) × ℕ) : Finset ((Fin 8 → ℕ) × ℕ) := ((Finset.univ : Finset (Fin 8 × Fin 8)).filter (fun pp => op2051jw_legal s.1 pp)).image (fun pp => (op2051jw_shift s.1 (op2051jw_skip pp.1.val pp.2.val), s.2 - 1))def op2051jw_gv (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (s : (Fin 8 → ℕ) × ℕ) : ℕ := ((L.find? (fun e => decide (e.1 = s))).map (fun e => e.2.1)).getD 0def op2051jw_mv (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (s : (Fin 8 → ℕ) × ℕ) : ℕ := ((L.find? (fun e => decide (e.1 = s))).map (fun e => e.2.2)).getD 0def op2051jw_good (s : (Fin 8 → ℕ) × ℕ) : Prop := s.2 ≤ 7 ∧ (∀ u : Fin 8, u.val = s.2 → 1 ≤ s.2 → 2 ≤ s.1 u) ∧ (s.2 = 0 → 3 ≤ s.1 0)def op2051jw_ok (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (good : Bool) : Prop := ∀ e ∈ L, (∀ s' ∈ op2051jw_fol e.1, s' ∈ L.map Prod.fst) ∧ op2051jw_gv L e.1 = finset_mex ((op2051jw_fol e.1).image (op2051jw_gv L)) ∧ op2051jw_mv L e.1 = (if (op2051jw_fol e.1).Nonempty then finset_mex ((op2051jw_fol e.1).image (op2051jw_mv L)) else 1) ∧ (e.1.2 = 0 → op2051jw_fol e.1 = ∅) ∧ e.1.2 ≤ 7 ∧ (good = true → op2051jw_good e.1)instance op2051jw_good_dec (s : (Fin 8 → ℕ) × ℕ) : Decidable (op2051jw_good s) := by unfold op2051jw_good; infer_instanceinstance op2051jw_ok_dec (L) (gd) : Decidable (op2051jw_ok L gd) := by unfold op2051jw_ok; infer_instancetheorem op2051jw_pair_card {nn : ℕ} (x : Fin nn → ℕ) (ia ib : Fin nn) (hab : ia ≠ ib) (vv : ℕ) : (Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv)).card = (if x ia = vv then 1 else 0) + (if x ib = vv then 1 else 0) := by have : Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv) = ({ia, ib} : Finset (Fin nn)).filter (fun i => x i = vv) := by ext i; simp rw [this, Finset.filter_insert, Finset.filter_singleton] by_cases ha : x ia = vv <;> by_cases hb : x ib = vv <;> simp [ha, hb, hab]theorem op2051jw_pair_le {nn : ℕ} (x : Fin nn → ℕ) (ia ib : Fin nn) (hab : ia ≠ ib) (vv : ℕ) : (if x ia = vv then 1 else 0) + (if x ib = vv then 1 else 0) ≤ (Finset.univ.filter (fun i => x i = vv)).card := by rw [← op2051jw_pair_card x ia ib hab vv] exact Finset.card_le_card (Finset.monotone_filter_right _ (fun i _ hq => hq.2))theorem op2051jw_cnt_step {nn : ℕ} (x : Fin nn → ℕ) (hx : ∀ i, x i ≤ 7) (ia ib : Fin nn) (hab : ia ≠ ib) (hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i) (u : Fin 8) : op2051jw_cnt (slow_exact_nim_step x ({ia, ib}ᶜ)) u = op2051jw_shift (op2051jw_cnt x) (op2051jw_skip (x ia) (x ib)) u := by have key : ∀ vv : ℕ, (Finset.univ.filter (fun i => slow_exact_nim_step x ({ia, ib}ᶜ) i = vv)).card + (Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv + 1)).card = (Finset.univ.filter (fun i => x i = vv + 1)).card + (Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = vv)).card := by intro vv simp only [Finset.card_filter, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl (fun i _ => ?_) by_cases hi : i = ia ∨ i = ib · have : i ∉ ({ia, ib} : Finset (Fin nn))ᶜ := by simp; tauto simp only [slow_exact_nim_step, this, if_false, hi, true_and] exact add_comm _ _ · have : i ∈ ({ia, ib} : Finset (Fin nn))ᶜ := by simpa using hi have hp := hpos i (fun hq => hi (Or.inl hq)) (fun hq => hi (Or.inr hq)) have e : (x i - 1 = vv) ↔ (x i = vv + 1) := by omega simp only [slow_exact_nim_step, this, if_true, hi, false_and, if_false, e] have k1 := key u.val rw [op2051jw_pair_card x ia ib hab, op2051jw_pair_card x ia ib hab] at k1 have hle := op2051jw_pair_le x ia ib hab (u.val + 1) unfold op2051jw_cnt op2051jw_shift op2051jw_skip by_cases hq : u.val + 1 < 8 · rw [dif_pos hq] show _ = ((Finset.univ.filter (fun i => x i = u.val + 1)).card - ((if x ia = u.val + 1 then 1 else 0) + (if x ib = u.val + 1 then 1 else 0))) + _ omega · rw [dif_neg hq] have h0 : (Finset.univ.filter (fun i => x i = u.val + 1)).card = 0 := by rw [Finset.card_eq_zero, Finset.filter_eq_empty_iff] intro i _; have := hx i; omega omegadef op2051jw_rel {nn : ℕ} (j : ℕ) (x : Fin nn → ℕ) (s : (Fin 8 → ℕ) × ℕ) : Prop := (∀ i, x i ≤ 7) ∧ ∀ u : Fin 8, op2051jw_cnt x u = s.1 u + (if u.val = s.2 then j else 0)theorem op2051jw_shift_embed (cv dv : Fin 8 → ℕ) (m j : ℕ) (hm1 : 1 ≤ m) (hm7 : m ≤ 7) (hdd : ∀ u : Fin 8, u.val = m → dv u ≤ cv u) (u : Fin 8) : op2051jw_shift (fun u => cv u + if u.val = m then j else 0) dv u = op2051jw_shift cv dv u + if u.val = m - 1 then j else 0 := by unfold op2051jw_shift by_cases hq : u.val + 1 < 8 · rw [dif_pos hq, dif_pos hq] show (cv ⟨u.val + 1, hq⟩ + (if u.val + 1 = m then j else 0)) - dv ⟨u.val + 1, hq⟩ + dv u = (cv ⟨u.val + 1, hq⟩ - dv ⟨u.val + 1, hq⟩ + dv u) + (if u.val = m - 1 then j else 0) by_cases hu : u.val + 1 = m · have := hdd ⟨u.val + 1, hq⟩ hu rw [if_pos hu, if_pos (by omega)]; omega · rw [if_neg hu, if_neg (by omega)]; omega · rw [dif_neg hq, dif_neg hq] have : u.val ≠ m - 1 := by omega simp [this]theorem op2051jw_rel_step {nn : ℕ} (j : ℕ) (x : Fin nn → ℕ) (s : (Fin 8 → ℕ) × ℕ) (hr : op2051jw_rel j x s) (ia ib : Fin nn) (hab : ia ≠ ib) (hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i) (hm1 : 1 ≤ s.2) (hm7 : s.2 ≤ 7) (hdd : ∀ u : Fin 8, u.val = s.2 → op2051jw_skip (x ia) (x ib) u ≤ s.1 u) : op2051jw_rel j (slow_exact_nim_step x ({ia, ib}ᶜ)) (op2051jw_shift s.1 (op2051jw_skip (x ia) (x ib)), s.2 - 1) := by refine ⟨fun i => ?_, fun u => ?_⟩ · have := hr.1 i; unfold slow_exact_nim_step; split_ifs <;> omega · rw [op2051jw_cnt_step x hr.1 ia ib hab hpos u] have hc : op2051jw_cnt x = fun u => s.1 u + if u.val = s.2 then j else 0 := funext hr.2 rw [hc, op2051jw_shift_embed _ _ _ _ hm1 hm7 hdd]theorem op2051jw_skip_le_two (vv wv : ℕ) (u : Fin 8) : op2051jw_skip vv wv u ≤ 2 := by unfold op2051jw_skip; split_ifs <;> omegatheorem op2051jw_cnt_eq_skip {nn : ℕ} (x : Fin nn → ℕ) (ia ib : Fin nn) (hab : ia ≠ ib) (vv : ℕ) (hsub : ∀ i, x i = vv → i = ia ∨ i = ib) : (Finset.univ.filter (fun i => x i = vv)).card = (if x ia = vv then 1 else 0) + (if x ib = vv then 1 else 0) := by rw [← op2051jw_pair_card x ia ib hab vv] congr 1; ext i; simp only [Finset.mem_filter, Finset.mem_univ, true_and] constructor · intro hq; exact ⟨hsub i hq, hq⟩ · intro hq; exact hq.2theorem op2051jw_fol_snd (s s' : (Fin 8 → ℕ) × ℕ) (hq : s' ∈ op2051jw_fol s) : s'.2 = s.2 - 1 := by unfold op2051jw_fol at hq obtain ⟨pp, _, rfl⟩ := Finset.mem_image.1 hq rfltheorem op2051jw_fwd (k j : ℕ) (x : Fin (k + 2) → ℕ) (s : (Fin 8 → ℕ) × ℕ) (hr : op2051jw_rel j x s) (hm0 : s.2 = 0 → op2051jw_fol s = ∅) (hm7 : s.2 ≤ 7) (hG : j = 0 ∨ op2051jw_good s) (y : Fin (k + 2) → ℕ) (hy : y ∈ slow_exact_nim_followers k (k + 2) x) : ∃ s' ∈ op2051jw_fol s, op2051jw_rel j y s' := by unfold slow_exact_nim_followers at hy obtain ⟨SS, hS, rfl⟩ := Finset.mem_image.1 hy rw [Finset.mem_filter, Finset.mem_powersetCard] at hS have hc2 : SSᶜ.card = 2 := by rw [Finset.card_compl, Fintype.card_fin, hS.1.2]; omega obtain ⟨ia, ib, hab, hSab⟩ := Finset.card_eq_two.1 hc2 have hS' : SS = ({ia, ib} : Finset (Fin (k + 2)))ᶜ := by rw [← hSab, compl_compl] subst hS' have hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i := by intro i ha hb; apply hS.2; simp [ha, hb] have hxa := hr.1 ia have hxb := hr.1 ib have hcnt0 : op2051jw_cnt x 0 = op2051jw_skip (x ia) (x ib) 0 := by unfold op2051jw_cnt op2051jw_skip rw [op2051jw_cnt_eq_skip x ia ib hab] intro i hi by_contra hne; replace hne := not_or.1 hne have := hpos i hne.1 hne.2; simp at hi; omega have hle : ∀ u, op2051jw_skip (x ia) (x ib) u ≤ op2051jw_cnt x u := fun u => op2051jw_pair_le x ia ib hab u.val have h0 := hr.2 0 have hs0 := op2051jw_skip_le_two (x ia) (x ib) 0 -- the move is legal in the abstract game have hlegal : op2051jw_legal s.1 (⟨x ia, by omega⟩, ⟨x ib, by omega⟩) := by refine ⟨fun u => ?_, ?_⟩ · have h1 := hr.2 u have h2 := hle u have h3 := op2051jw_skip_le_two (x ia) (x ib) u show op2051jw_skip (x ia) (x ib) u ≤ s.1 u by_cases hu : u.val = s.2 · rw [if_pos hu] at h1 rcases hG with hj | hg · subst hj; omega · by_cases hm : 1 ≤ s.2 · have := hg.2.1 u hu hm; omega · have h4 := hg.2.2 (by omega) have hu0 : u = 0 := Fin.ext (by simp; omega) subst hu0 simp only [Fin.val_zero] at h0 rw [if_pos (by omega)] at h0 omega · rw [if_neg hu] at h1; omega · show s.1 0 = op2051jw_skip (x ia) (x ib) 0 by_cases hu : (0 : Fin 8).val = s.2 · rw [if_pos hu] at h0 rcases hG with hj | hg · subst hj; omega · have h4 := hg.2.2 (by simp at hu; omega); omega · rw [if_neg hu] at h0; omega have hmem : (op2051jw_shift s.1 (op2051jw_skip (x ia) (x ib)), s.2 - 1) ∈ op2051jw_fol s := by unfold op2051jw_fol exact Finset.mem_image.2 ⟨_, Finset.mem_filter.2 ⟨Finset.mem_univ _, hlegal⟩, rfl⟩ have hm1 : 1 ≤ s.2 := by by_contra hm have := hm0 (by omega) rw [this] at hmem; simp at hmem refine ⟨_, hmem, op2051jw_rel_step j x s hr ia ib hab hpos hm1 hm7 (fun u _ => hlegal.1 u)⟩theorem op2051jw_bwd (k j : ℕ) (x : Fin (k + 2) → ℕ) (s : (Fin 8 → ℕ) × ℕ) (hr : op2051jw_rel j x s) (hm0 : s.2 = 0 → op2051jw_fol s = ∅) (hm7 : s.2 ≤ 7) (s' : (Fin 8 → ℕ) × ℕ) (hs' : s' ∈ op2051jw_fol s) : ∃ y ∈ slow_exact_nim_followers k (k + 2) x, op2051jw_rel j y s' := by have hm1 : 1 ≤ s.2 := by by_contra hm have := hm0 (by omega) rw [this] at hs'; simp at hs' unfold op2051jw_fol at hs' obtain ⟨pp, hp, rfl⟩ := Finset.mem_image.1 hs' have hp := (Finset.mem_filter.1 hp).2 have hge : ∀ u, op2051jw_skip pp.1.val pp.2.val u ≤ op2051jw_cnt x u := by intro u; have := hr.2 u; have := hp.1 u; omega -- choose ia with x ia = pp.1 have h1 := hge pp.1 have hpos1 : 0 < (Finset.univ.filter (fun i => x i = pp.1.val)).card := by have : 1 ≤ op2051jw_skip pp.1.val pp.2.val pp.1 := by unfold op2051jw_skip; simp exact lt_of_lt_of_le this h1 obtain ⟨ia, ha⟩ := Finset.card_pos.1 hpos1 have ha : x ia = pp.1.val := (Finset.mem_filter.1 ha).2 have hbex : ∃ ib, ib ≠ ia ∧ x ib = pp.2.val := by by_cases he : pp.1 = pp.2 · have h2 := hge pp.2 have : 2 ≤ (Finset.univ.filter (fun i => x i = pp.2.val)).card := by have : op2051jw_skip pp.1.val pp.2.val pp.2 = 2 := by unfold op2051jw_skip; simp [he] unfold op2051jw_cnt at h2; omega have hpos : 0 < ((Finset.univ.filter (fun i => x i = pp.2.val)).erase ia).card := by rw [Finset.card_erase_of_mem (by simp [ha, he])]; omega obtain ⟨ib, hb⟩ := Finset.card_pos.1 hpos rw [Finset.mem_erase, Finset.mem_filter] at hb exact ⟨ib, hb.1, hb.2.2⟩ · have h2 := hge pp.2 have : 0 < (Finset.univ.filter (fun i => x i = pp.2.val)).card := by have : 1 ≤ op2051jw_skip pp.1.val pp.2.val pp.2 := by unfold op2051jw_skip; simp unfold op2051jw_cnt at h2; omega obtain ⟨ib, hb⟩ := Finset.card_pos.1 this have hb : x ib = pp.2.val := (Finset.mem_filter.1 hb).2 refine ⟨ib, ?_, hb⟩ rintro rfl; exact he (Fin.ext (by omega)) obtain ⟨ib, hba, hb⟩ := hbex have hab : ia ≠ ib := fun hq => hba hq.symm have hskip : op2051jw_skip (x ia) (x ib) = op2051jw_skip pp.1.val pp.2.val := by rw [ha, hb] -- positivity off {ia, ib} have hpos : ∀ i, i ≠ ia → i ≠ ib → 0 < x i := by intro i hia hib by_contra hz have hz : x i = 0 := by omega have hc0 : op2051jw_cnt x 0 = op2051jw_skip (x ia) (x ib) 0 := by have := hr.2 0 rw [if_neg (by simp; omega)] at this rw [this, hskip]; exact hp.2 have hsub : Finset.univ.filter (fun i => (i = ia ∨ i = ib) ∧ x i = 0) = Finset.univ.filter (fun i => x i = 0) := by apply Finset.eq_of_subset_of_card_le · exact Finset.monotone_filter_right _ (fun i _ hq => hq.2) · rw [op2051jw_pair_card x ia ib hab] unfold op2051jw_cnt op2051jw_skip at hc0 simp only [Fin.val_zero] at hc0 omega have : i ∈ Finset.univ.filter (fun i => x i = 0) := by simp [hz] rw [← hsub] at this simp at this rcases this.1 with hq | hq · exact hia hq · exact hib hq refine ⟨slow_exact_nim_step x ({ia, ib}ᶜ), ?_, ?_⟩ · unfold slow_exact_nim_followers refine Finset.mem_image.2 ⟨_, Finset.mem_filter.2 ⟨?_, ?_⟩, rfl⟩ · rw [Finset.mem_powersetCard] refine ⟨Finset.subset_univ _, ?_⟩ rw [Finset.card_compl, Fintype.card_fin, Finset.card_pair hab]; omega · intro i hi; simp at hi; exact hpos i hi.1 hi.2 · have := op2051jw_rel_step j x s hr ia ib hab hpos hm1 hm7 (fun u _ => by rw [hskip]; exact hp.1 u) rw [hskip] at this exact thistheorem op2051jw_main (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (gd : Bool) (hok : op2051jw_ok L gd) (k j : ℕ) (hj : j = 0 ∨ gd = true) : ∀ f (x : Fin (k + 2) → ℕ) (s : (Fin 8 → ℕ) × ℕ), s ∈ L.map Prod.fst → op2051jw_rel j x s → s.2 ≤ f → slow_exact_nim_grundy_comp k (k + 2) f x = op2051jw_gv L s ∧ slow_exact_nim_misere_comp k (k + 2) f x = op2051jw_mv L s := by intro f induction f with | zero => intro x s hs _ hf obtain ⟨e, he, rfl⟩ := List.mem_map.1 hs obtain ⟨_, hgv, hmv, hm0, _, _⟩ := hok e he have hf0 := hm0 (by omega) rw [hf0] at hgv hmv refine ⟨?_, ?_⟩ · rw [hgv]; rfl · rw [hmv]; simp; rfl | succ f ih => intro x s hs hr hf obtain ⟨e, he, rfl⟩ := List.mem_map.1 hs obtain ⟨hcl, hgv, hmv, hm0, hm7, hgd⟩ := hok e he have hG : j = 0 ∨ op2051jw_good e.1 := by rcases hj with hq | hq · exact Or.inl hq · exact Or.inr (hgd hq) have hstep : ∀ y ∈ slow_exact_nim_followers k (k + 2) x, ∃ s' ∈ op2051jw_fol e.1, slow_exact_nim_grundy_comp k (k + 2) f y = op2051jw_gv L s' ∧ slow_exact_nim_misere_comp k (k + 2) f y = op2051jw_mv L s' := by intro y hy obtain ⟨s', hs', hr'⟩ := op2051jw_fwd k j x e.1 hr hm0 hm7 hG y hy have h2 := op2051jw_fol_snd _ _ hs' exact ⟨s', hs', ih y s' (hcl s' hs') hr' (by omega)⟩ have hstep' : ∀ s' ∈ op2051jw_fol e.1, ∃ y ∈ slow_exact_nim_followers k (k + 2) x, slow_exact_nim_grundy_comp k (k + 2) f y = op2051jw_gv L s' ∧ slow_exact_nim_misere_comp k (k + 2) f y = op2051jw_mv L s' := by intro s' hs' obtain ⟨y, hy, hr'⟩ := op2051jw_bwd k j x e.1 hr hm0 hm7 s' hs' have h2 := op2051jw_fol_snd _ _ hs' exact ⟨y, hy, ih y s' (hcl s' hs') hr' (by omega)⟩ have himg : (slow_exact_nim_followers k (k + 2) x).image (slow_exact_nim_grundy_comp k (k + 2) f) = (op2051jw_fol e.1).image (op2051jw_gv L) := by ext vv; simp only [Finset.mem_image] constructor · rintro ⟨y, hy, rfl⟩ obtain ⟨s', hs', h1, _⟩ := hstep y hy exact ⟨s', hs', h1.symm⟩ · rintro ⟨s', hs', rfl⟩ obtain ⟨y, hy, h1, _⟩ := hstep' s' hs' exact ⟨y, hy, h1⟩ have himg' : (slow_exact_nim_followers k (k + 2) x).image (slow_exact_nim_misere_comp k (k + 2) f) = (op2051jw_fol e.1).image (op2051jw_mv L) := by ext vv; simp only [Finset.mem_image] constructor · rintro ⟨y, hy, rfl⟩ obtain ⟨s', hs', _, h1⟩ := hstep y hy exact ⟨s', hs', h1.symm⟩ · rintro ⟨s', hs', rfl⟩ obtain ⟨y, hy, _, h1⟩ := hstep' s' hs' exact ⟨y, hy, h1⟩ have hne : (slow_exact_nim_followers k (k + 2) x).Nonempty ↔ (op2051jw_fol e.1).Nonempty := by rw [← Finset.image_nonempty (f := slow_exact_nim_grundy_comp k (k + 2) f), himg, Finset.image_nonempty] refine ⟨?_, ?_⟩ · show finset_mex _ = _ rw [himg, hgv] · show (if _ then _ else _) = _ rw [hmv] by_cases hq : (op2051jw_fol e.1).Nonempty · rw [if_pos (hne.2 hq), if_pos hq, himg'] · rw [if_neg (fun h' => hq (hne.1 h')), if_neg hq]theorem op2051jw_wcnt (k : ℕ) (hk : 3 ≤ k) (u : Fin 8) : op2051jw_cnt (slow_exact_nim_geometric_padded_witness 2 k) u = (if u.val = 1 ∨ u.val = 2 ∨ u.val = 4 then 1 else 0) + (if u.val = 7 then k - 1 else 0) := by unfold op2051jw_cnt slow_exact_nim_geometric_padded_witness rw [Finset.card_filter] rw [Fin.sum_univ_eq_sum_range (fun i => if (if i ≤ 2 then 2 ^ i else 2 ^ (2 + 1) - 1) = u.val then 1 else 0) (k + 2)] rw [show k + 2 = 3 + (k - 1) by omega, Finset.sum_range_add] have : ∀ x ∈ Finset.range (k - 1), (if (if 3 + x ≤ 2 then 2 ^ (3 + x) else 2 ^ (2 + 1) - 1) = u.val then 1 else 0) = (if 7 = u.val then 1 else 0) := by intro x _; rw [if_neg (show ¬ 3 + x ≤ 2 by omega)]; norm_num rw [Finset.sum_congr rfl this, Finset.sum_const, Finset.card_range, smul_eq_mul] simp only [Finset.sum_range_succ, Finset.sum_range_zero] fin_cases u <;> norm_numtheorem op2051jw_wrel (k K : ℕ) (hK : 3 ≤ K) (hKk : K ≤ k) : op2051jw_rel (k - K) (slow_exact_nim_geometric_padded_witness 2 k) (![0, 1, 1, 0, 1, 0, 0, K - 1], 7) := by refine ⟨fun i => ?_, fun u => ?_⟩ · unfold slow_exact_nim_geometric_padded_witness split_ifs with hq · calc 2 ^ i.val ≤ 2 ^ 2 := Nat.pow_le_pow_right (by norm_num) hq _ ≤ 7 := by norm_num · norm_num · rw [op2051jw_wcnt k (by omega) u] fin_cases u <;> simp <;> omegatheorem op2051jw_wsum (k : ℕ) (hk : 3 ≤ k) : 7 ≤ ∑ i, slow_exact_nim_geometric_padded_witness 2 k i := by have := Finset.single_le_sum (f := slow_exact_nim_geometric_padded_witness 2 k) (fun i _ => Nat.zero_le _) (Finset.mem_univ (⟨3, by omega⟩ : Fin (k + 2))) unfold slow_exact_nim_geometric_padded_witness at this ⊢ simpa using thisdef op2051jw_table3 : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ) := [((![0, 1, 1, 0, 1, 0, 0, 2], 7), 7, 7), ((![0, 1, 1, 1, 0, 0, 2, 0], 6), 6, 6), ((![0, 1, 2, 0, 0, 2, 0, 0], 5), 1, 1), ((![0, 2, 0, 0, 1, 0, 2, 0], 6), 4, 4), ((![0, 2, 0, 1, 0, 0, 1, 1], 6), 5, 5), ((![0, 2, 0, 1, 0, 2, 0, 0], 5), 5, 5), ((![0, 2, 1, 0, 0, 1, 1, 0], 5), 4, 4), ((![0, 2, 1, 0, 2, 0, 0, 0], 4), 4, 4), ((![0, 3, 0, 0, 1, 1, 0, 0], 4), 3, 3), ((![0, 3, 0, 2, 0, 0, 0, 0], 3), 3, 3), ((![1, 0, 1, 0, 1, 0, 2, 0], 6), 0, 0), ((![1, 0, 1, 1, 0, 0, 1, 1], 6), 1, 1), ((![1, 0, 1, 1, 0, 2, 0, 0], 5), 1, 1), ((![1, 0, 2, 0, 0, 1, 1, 0], 5), 0, 0), ((![1, 0, 2, 0, 2, 0, 0, 0], 4), 0, 0), ((![1, 1, 0, 0, 1, 0, 1, 1], 6), 3, 3), ((![1, 1, 0, 0, 1, 2, 0, 0], 5), 3, 3), ((![1, 1, 0, 1, 0, 0, 0, 2], 6), 2, 2), ((![1, 1, 0, 1, 0, 1, 1, 0], 5), 2, 2), ((![1, 1, 0, 1, 2, 0, 0, 0], 4), 2, 2), ((![1, 1, 1, 0, 0, 0, 2, 0], 5), 3, 3), ((![1, 1, 1, 0, 0, 1, 0, 1], 5), 3, 3), ((![1, 1, 1, 0, 1, 1, 0, 0], 4), 3, 3), ((![1, 1, 1, 2, 0, 0, 0, 0], 3), 3, 3), ((![1, 2, 0, 0, 0, 2, 0, 0], 4), 2, 2), ((![1, 2, 0, 0, 1, 0, 1, 0], 4), 2, 2), ((![1, 2, 0, 1, 1, 0, 0, 0], 3), 2, 2), ((![1, 2, 2, 0, 0, 0, 0, 0], 2), 2, 2), ((![2, 0, 0, 0, 1, 1, 1, 0], 5), 0, 1), ((![2, 0, 0, 0, 3, 0, 0, 0], 4), 0, 1), ((![2, 0, 0, 1, 0, 0, 2, 0], 5), 1, 0), ((![2, 0, 0, 1, 0, 1, 0, 1], 5), 1, 0), ((![2, 0, 0, 1, 1, 1, 0, 0], 4), 1, 0), ((![2, 0, 0, 3, 0, 0, 0, 0], 3), 1, 0), ((![2, 0, 1, 0, 0, 0, 1, 1], 5), 0, 1), ((![2, 0, 1, 0, 0, 2, 0, 0], 4), 0, 1), ((![2, 0, 1, 0, 1, 0, 1, 0], 4), 0, 1), ((![2, 0, 1, 1, 1, 0, 0, 0], 3), 0, 1), ((![2, 0, 3, 0, 0, 0, 0, 0], 2), 0, 1), ((![2, 1, 0, 0, 0, 1, 1, 0], 4), 1, 0), ((![2, 1, 0, 0, 1, 0, 0, 1], 4), 1, 0), ((![2, 1, 0, 0, 2, 0, 0, 0], 3), 1, 0), ((![2, 1, 0, 1, 0, 1, 0, 0], 3), 1, 0), ((![2, 1, 1, 1, 0, 0, 0, 0], 2), 1, 0), ((![2, 3, 0, 0, 0, 0, 0, 0], 1), 1, 0), ((![3, 0, 0, 0, 1, 1, 0, 0], 3), 0, 1), ((![3, 0, 0, 1, 0, 0, 1, 0], 3), 0, 1), ((![3, 0, 0, 2, 0, 0, 0, 0], 2), 0, 1), ((![3, 0, 1, 0, 1, 0, 0, 0], 2), 0, 1), ((![3, 1, 1, 0, 0, 0, 0, 0], 1), 0, 1), ((![5, 0, 0, 0, 0, 0, 0, 0], 0), 0, 1)]def op2051jw_table4 : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ) := [((![0, 1, 1, 0, 1, 0, 0, 3], 7), 7, 7), ((![0, 1, 1, 1, 0, 0, 3, 0], 6), 6, 6), ((![0, 1, 2, 0, 0, 3, 0, 0], 5), 1, 1), ((![0, 2, 0, 0, 1, 0, 3, 0], 6), 4, 4), ((![0, 2, 0, 1, 0, 0, 2, 1], 6), 5, 5), ((![0, 2, 0, 1, 0, 3, 0, 0], 5), 5, 5), ((![0, 2, 1, 0, 0, 2, 1, 0], 5), 4, 4), ((![0, 2, 1, 0, 3, 0, 0, 0], 4), 4, 4), ((![0, 3, 0, 0, 2, 1, 0, 0], 4), 3, 3), ((![0, 3, 0, 3, 0, 0, 0, 0], 3), 3, 3), ((![1, 0, 1, 0, 1, 0, 3, 0], 6), 0, 0), ((![1, 0, 1, 1, 0, 0, 2, 1], 6), 1, 1), ((![1, 0, 1, 1, 0, 3, 0, 0], 5), 1, 1), ((![1, 0, 2, 0, 0, 2, 1, 0], 5), 0, 0), ((![1, 0, 2, 0, 3, 0, 0, 0], 4), 0, 0), ((![1, 1, 0, 0, 1, 0, 2, 1], 6), 3, 3), ((![1, 1, 0, 0, 1, 3, 0, 0], 5), 3, 3), ((![1, 1, 0, 1, 0, 0, 1, 2], 6), 2, 2), ((![1, 1, 0, 1, 0, 2, 1, 0], 5), 2, 2), ((![1, 1, 0, 1, 3, 0, 0, 0], 4), 2, 2), ((![1, 1, 1, 0, 0, 1, 2, 0], 5), 3, 3), ((![1, 1, 1, 0, 0, 2, 0, 1], 5), 3, 3), ((![1, 1, 1, 0, 2, 1, 0, 0], 4), 3, 3), ((![1, 1, 1, 3, 0, 0, 0, 0], 3), 3, 3), ((![1, 2, 0, 0, 1, 2, 0, 0], 4), 2, 2), ((![1, 2, 0, 0, 2, 0, 1, 0], 4), 2, 2), ((![1, 2, 0, 2, 1, 0, 0, 0], 3), 2, 2), ((![1, 2, 3, 0, 0, 0, 0, 0], 2), 2, 2), ((![2, 0, 0, 0, 1, 2, 1, 0], 5), 0, 1), ((![2, 0, 0, 0, 4, 0, 0, 0], 4), 0, 1), ((![2, 0, 0, 1, 0, 1, 2, 0], 5), 1, 0), ((![2, 0, 0, 1, 0, 2, 0, 1], 5), 1, 0), ((![2, 0, 0, 1, 2, 1, 0, 0], 4), 1, 0), ((![2, 0, 0, 4, 0, 0, 0, 0], 3), 1, 0), ((![2, 0, 1, 0, 0, 0, 3, 0], 5), 0, 1), ((![2, 0, 1, 0, 0, 1, 1, 1], 5), 0, 1), ((![2, 0, 1, 0, 1, 2, 0, 0], 4), 0, 1), ((![2, 0, 1, 0, 2, 0, 1, 0], 4), 0, 1), ((![2, 0, 1, 2, 1, 0, 0, 0], 3), 0, 1), ((![2, 0, 4, 0, 0, 0, 0, 0], 2), 0, 1), ((![2, 1, 0, 0, 0, 3, 0, 0], 4), 1, 0), ((![2, 1, 0, 0, 1, 1, 1, 0], 4), 1, 0), ((![2, 1, 0, 0, 2, 0, 0, 1], 4), 1, 0), ((![2, 1, 0, 1, 2, 0, 0, 0], 3), 1, 0), ((![2, 1, 0, 2, 0, 1, 0, 0], 3), 1, 0), ((![2, 1, 2, 1, 0, 0, 0, 0], 2), 1, 0), ((![2, 4, 0, 0, 0, 0, 0, 0], 1), 1, 0), ((![3, 0, 0, 0, 3, 0, 0, 0], 3), 0, 1), ((![3, 0, 0, 1, 1, 1, 0, 0], 3), 0, 1), ((![3, 0, 0, 2, 0, 0, 1, 0], 3), 0, 1), ((![3, 0, 1, 2, 0, 0, 0, 0], 2), 0, 1), ((![3, 0, 2, 0, 1, 0, 0, 0], 2), 0, 1), ((![3, 2, 1, 0, 0, 0, 0, 0], 1), 0, 1), ((![6, 0, 0, 0, 0, 0, 0, 0], 0), 0, 1)]def op2051jw_table5 : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ) := [((![0, 1, 1, 0, 1, 0, 0, 4], 7), 7, 7), ((![0, 1, 1, 1, 0, 0, 4, 0], 6), 6, 6), ((![0, 1, 2, 0, 0, 4, 0, 0], 5), 1, 1), ((![0, 2, 0, 0, 1, 0, 4, 0], 6), 4, 4), ((![0, 2, 0, 1, 0, 0, 3, 1], 6), 5, 5), ((![0, 2, 0, 1, 0, 4, 0, 0], 5), 5, 5), ((![0, 2, 1, 0, 0, 3, 1, 0], 5), 4, 4), ((![0, 2, 1, 0, 4, 0, 0, 0], 4), 4, 4), ((![0, 3, 0, 0, 3, 1, 0, 0], 4), 3, 3), ((![0, 3, 0, 4, 0, 0, 0, 0], 3), 3, 3), ((![1, 0, 1, 0, 1, 0, 4, 0], 6), 0, 0), ((![1, 0, 1, 1, 0, 0, 3, 1], 6), 1, 1), ((![1, 0, 1, 1, 0, 4, 0, 0], 5), 1, 1), ((![1, 0, 2, 0, 0, 3, 1, 0], 5), 0, 0), ((![1, 0, 2, 0, 4, 0, 0, 0], 4), 0, 0), ((![1, 1, 0, 0, 1, 0, 3, 1], 6), 3, 3), ((![1, 1, 0, 0, 1, 4, 0, 0], 5), 3, 3), ((![1, 1, 0, 1, 0, 0, 2, 2], 6), 2, 2), ((![1, 1, 0, 1, 0, 3, 1, 0], 5), 2, 2), ((![1, 1, 0, 1, 4, 0, 0, 0], 4), 2, 2), ((![1, 1, 1, 0, 0, 2, 2, 0], 5), 3, 3), ((![1, 1, 1, 0, 0, 3, 0, 1], 5), 3, 3), ((![1, 1, 1, 0, 3, 1, 0, 0], 4), 3, 3), ((![1, 1, 1, 4, 0, 0, 0, 0], 3), 3, 3), ((![1, 2, 0, 0, 2, 2, 0, 0], 4), 2, 2), ((![1, 2, 0, 0, 3, 0, 1, 0], 4), 2, 2), ((![1, 2, 0, 3, 1, 0, 0, 0], 3), 2, 2), ((![1, 2, 4, 0, 0, 0, 0, 0], 2), 2, 2), ((![2, 0, 0, 0, 1, 3, 1, 0], 5), 0, 1), ((![2, 0, 0, 0, 5, 0, 0, 0], 4), 0, 1), ((![2, 0, 0, 1, 0, 2, 2, 0], 5), 1, 0), ((![2, 0, 0, 1, 0, 3, 0, 1], 5), 1, 0), ((![2, 0, 0, 1, 3, 1, 0, 0], 4), 1, 0), ((![2, 0, 0, 5, 0, 0, 0, 0], 3), 1, 0), ((![2, 0, 1, 0, 0, 1, 3, 0], 5), 0, 1), ((![2, 0, 1, 0, 0, 2, 1, 1], 5), 0, 1), ((![2, 0, 1, 0, 2, 2, 0, 0], 4), 0, 1), ((![2, 0, 1, 0, 3, 0, 1, 0], 4), 0, 1), ((![2, 0, 1, 3, 1, 0, 0, 0], 3), 0, 1), ((![2, 0, 5, 0, 0, 0, 0, 0], 2), 0, 1), ((![2, 1, 0, 0, 1, 3, 0, 0], 4), 1, 0), ((![2, 1, 0, 0, 2, 1, 1, 0], 4), 1, 0), ((![2, 1, 0, 0, 3, 0, 0, 1], 4), 1, 0), ((![2, 1, 0, 2, 2, 0, 0, 0], 3), 1, 0), ((![2, 1, 0, 3, 0, 1, 0, 0], 3), 1, 0), ((![2, 1, 3, 1, 0, 0, 0, 0], 2), 1, 0), ((![2, 5, 0, 0, 0, 0, 0, 0], 1), 1, 0), ((![3, 0, 0, 1, 3, 0, 0, 0], 3), 0, 1), ((![3, 0, 0, 2, 1, 1, 0, 0], 3), 0, 1), ((![3, 0, 0, 3, 0, 0, 1, 0], 3), 0, 1), ((![3, 0, 2, 2, 0, 0, 0, 0], 2), 0, 1), ((![3, 0, 3, 0, 1, 0, 0, 0], 2), 0, 1), ((![3, 3, 1, 0, 0, 0, 0, 0], 1), 0, 1), ((![7, 0, 0, 0, 0, 0, 0, 0], 0), 0, 1)]def op2051jw_table6 : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ) := [((![0, 1, 1, 0, 1, 0, 0, 5], 7), 7, 7), ((![0, 1, 1, 1, 0, 0, 5, 0], 6), 6, 6), ((![0, 1, 2, 0, 0, 5, 0, 0], 5), 1, 1), ((![0, 2, 0, 0, 1, 0, 5, 0], 6), 4, 4), ((![0, 2, 0, 1, 0, 0, 4, 1], 6), 5, 5), ((![0, 2, 0, 1, 0, 5, 0, 0], 5), 5, 5), ((![0, 2, 1, 0, 0, 4, 1, 0], 5), 4, 4), ((![0, 2, 1, 0, 5, 0, 0, 0], 4), 4, 4), ((![0, 3, 0, 0, 4, 1, 0, 0], 4), 3, 3), ((![0, 3, 0, 5, 0, 0, 0, 0], 3), 3, 3), ((![1, 0, 1, 0, 1, 0, 5, 0], 6), 0, 0), ((![1, 0, 1, 1, 0, 0, 4, 1], 6), 1, 1), ((![1, 0, 1, 1, 0, 5, 0, 0], 5), 1, 1), ((![1, 0, 2, 0, 0, 4, 1, 0], 5), 0, 0), ((![1, 0, 2, 0, 5, 0, 0, 0], 4), 0, 0), ((![1, 1, 0, 0, 1, 0, 4, 1], 6), 3, 3), ((![1, 1, 0, 0, 1, 5, 0, 0], 5), 3, 3), ((![1, 1, 0, 1, 0, 0, 3, 2], 6), 2, 2), ((![1, 1, 0, 1, 0, 4, 1, 0], 5), 2, 2), ((![1, 1, 0, 1, 5, 0, 0, 0], 4), 2, 2), ((![1, 1, 1, 0, 0, 3, 2, 0], 5), 3, 3), ((![1, 1, 1, 0, 0, 4, 0, 1], 5), 3, 3), ((![1, 1, 1, 0, 4, 1, 0, 0], 4), 3, 3), ((![1, 1, 1, 5, 0, 0, 0, 0], 3), 3, 3), ((![1, 2, 0, 0, 3, 2, 0, 0], 4), 2, 2), ((![1, 2, 0, 0, 4, 0, 1, 0], 4), 2, 2), ((![1, 2, 0, 4, 1, 0, 0, 0], 3), 2, 2), ((![1, 2, 5, 0, 0, 0, 0, 0], 2), 2, 2), ((![2, 0, 0, 0, 1, 4, 1, 0], 5), 0, 1), ((![2, 0, 0, 0, 6, 0, 0, 0], 4), 0, 1), ((![2, 0, 0, 1, 0, 3, 2, 0], 5), 1, 0), ((![2, 0, 0, 1, 0, 4, 0, 1], 5), 1, 0), ((![2, 0, 0, 1, 4, 1, 0, 0], 4), 1, 0), ((![2, 0, 0, 6, 0, 0, 0, 0], 3), 1, 0), ((![2, 0, 1, 0, 0, 2, 3, 0], 5), 0, 1), ((![2, 0, 1, 0, 0, 3, 1, 1], 5), 0, 1), ((![2, 0, 1, 0, 3, 2, 0, 0], 4), 0, 1), ((![2, 0, 1, 0, 4, 0, 1, 0], 4), 0, 1), ((![2, 0, 1, 4, 1, 0, 0, 0], 3), 0, 1), ((![2, 0, 6, 0, 0, 0, 0, 0], 2), 0, 1), ((![2, 1, 0, 0, 2, 3, 0, 0], 4), 1, 0), ((![2, 1, 0, 0, 3, 1, 1, 0], 4), 1, 0), ((![2, 1, 0, 0, 4, 0, 0, 1], 4), 1, 0), ((![2, 1, 0, 3, 2, 0, 0, 0], 3), 1, 0), ((![2, 1, 0, 4, 0, 1, 0, 0], 3), 1, 0), ((![2, 1, 4, 1, 0, 0, 0, 0], 2), 1, 0), ((![2, 6, 0, 0, 0, 0, 0, 0], 1), 1, 0), ((![3, 0, 0, 2, 3, 0, 0, 0], 3), 0, 1), ((![3, 0, 0, 3, 1, 1, 0, 0], 3), 0, 1), ((![3, 0, 0, 4, 0, 0, 1, 0], 3), 0, 1), ((![3, 0, 3, 2, 0, 0, 0, 0], 2), 0, 1), ((![3, 0, 4, 0, 1, 0, 0, 0], 2), 0, 1), ((![3, 4, 1, 0, 0, 0, 0, 0], 1), 0, 1), ((![8, 0, 0, 0, 0, 0, 0, 0], 0), 0, 1)]set_option maxRecDepth 100000 intheorem op2051jw_ok3 : op2051jw_ok op2051jw_table3 false := by decide +kernelset_option maxRecDepth 100000 intheorem op2051jw_ok4 : op2051jw_ok op2051jw_table4 false := by decide +kernelset_option maxRecDepth 100000 intheorem op2051jw_ok5 : op2051jw_ok op2051jw_table5 false := by decide +kernelset_option maxRecDepth 100000 intheorem op2051jw_ok6 : op2051jw_ok op2051jw_table6 true := by decide +kerneltheorem op2051jw_apply (L : List (((Fin 8 → ℕ) × ℕ) × ℕ × ℕ)) (gd : Bool) (hok : op2051jw_ok L gd) (k K : ℕ) (hK : 3 ≤ K) (hKk : K ≤ k) (hj : k - K = 0 ∨ gd = true) (hs : ((![0, 1, 1, 0, 1, 0, 0, K - 1], 7) : (Fin 8 → ℕ) × ℕ) ∈ L.map Prod.fst) (hv : op2051jw_gv L (![0, 1, 1, 0, 1, 0, 0, K - 1], 7) = 7 ∧ op2051jw_mv L (![0, 1, 1, 0, 1, 0, 0, K - 1], 7) = 7) : slow_exact_nim_grundy k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 ∧ slow_exact_nim_misere k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 := by have hq := op2051jw_main L gd hok k (k - K) hj _ _ _ hs (op2051jw_wrel k K hK hKk) (op2051jw_wsum k (by omega)) unfold slow_exact_nim_grundy slow_exact_nim_misere rw [hq.1, hq.2]; exact hv/-- The geometric padded witness position achieves Sprague-Grundy value 7 and misère invariant 7 in slow exact k-Nim on k+2 piles for all k ≥ 3. -/theorem op_2051_slow_exact_nim_joint_seven_witness (k : ℕ) (hk : 3 ≤ k) : slow_exact_nim_grundy k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 ∧ slow_exact_nim_misere k (k + 2) (slow_exact_nim_geometric_padded_witness 2 k) = 7 := by by_cases h6 : 6 ≤ k · exact op2051jw_apply _ true op2051jw_ok6 k 6 (by norm_num) h6 (Or.inr rfl) (by decide) (by decide) · interval_cases k · exact op2051jw_apply _ false op2051jw_ok3 3 3 le_rfl le_rfl (Or.inl rfl) (by decide) (by decide) · exact op2051jw_apply _ false op2051jw_ok4 4 4 (by norm_num) le_rfl (Or.inl rfl) (by decide) (by decide) · exact op2051jw_apply _ false op2051jw_ok5 5 5 (by norm_num) le_rfl (Or.inl rfl) (by decide) (by decide)