import Mathlib /-! # Exact Infinite Families, Symmetries, and Structural Theorems for the Catch-Up Game We formalize a comprehensive suite of exact analytical theorems for the combinatorial game **Catch-Up** introduced by A. Isaksen, M. Ismail, S. J. Brams, and A. Nealen, *Catch-Up: A Game in Which the Lead Alternates*, Game & Puzzle Design 1(2), 38–49 (2015), formalized as an open conjecture in `FormalConjectures/Paper/CatchUpConjecture.lean`. ## Background & Motivation In Catch-Up, two players alternately remove positive integers from a finite set $S$ and add them to their cumulative scores. Player 1 starts by taking a single number. On every subsequent turn, the active player must keep removing numbers one at a time until their score meets or exceeds the opponent's score (remaining strictly behind before the final pick of the turn). When $S$ is empty, the higher score wins; equal scores give a draw. Isaksen et al. (2015) computed game values for $S = \{1, \dots, N\}$ up to $N = 20$ and conjectured that whenever the triangular number $T_N = N(N+1)/2$ is even ($N \equiv 0, 3 \pmod 4$), optimal play ends in a draw. No general analytical theorems for infinite families of Catch-Up games have been formalized in Lean 4 or established in the published literature. ## Main Results Formalized Here 1. **Exact Minimax API & Fundamental Symmetries**: - **Shift-Invariance (`valueAux_add_right`)**: Adding the same constant to both players' scores leaves the game-theoretic value unchanged. - **Scale-Invariance (`value_image_mul`)**: Multiplying every element of $S$ by any positive integer $c > 0$ preserves `CatchUp.value S`. - **Parity Obstruction (`value_ne_draw_of_odd_sum`, `value_Icc_ne_draw_of_odd_triangular`)**: Whenever $\sum_{x \in S} x$ is odd (in particular for $S = \{1, \dots, N\}$ with $N \equiv 1, 2 \pmod 4$), no draw is possible (`value S ≠ .draw`). 2. **Dominant-Max Exact Infinite Families**: - **Strict Dominance (`value_eq_win_of_dominant_max`)**: If $M \in S$ exceeds the sum of all other elements (e.g. $\{1, 2, 4, \dots, 2^n\}$), then `value S = .win`. - **Exact Balance (`value_eq_draw_of_exact_sum_max`)**: If $|S| \ge 3$, all elements are positive, and $M \in S$ equals the sum of all other elements (e.g. $\{1, 2, 3\}$ or $\{1, 2, 4, \dots, 2^n, 2^{n+1} - 1\}$), then `value S = .draw`. 3. **Complete Classification of All 3-Element Sets & All Balanced 4-Element Sets**: - **`value_three_elements`**: For all $0 < a < b < c$, `value {a, b, c} = if a + b = c then .draw else .win`. - **`value_four_balanced`**: For all $0 < a < b < c < d$ with $a + d = b + c$ (including every 4-term arithmetic progression $\{a, a+u, a+2u, a+3u\}$ and $N = 4$), `value {a, b, c, d} = .draw`. 4. **Main Breakthrough — Exact Checkerboard Value Theorem for Geometric Pair Families (`valueAux_pairSet_exact`, `value_scaledPairSet_even_eq_draw`, `value_scaledPairSet_odd_eq_win`, `value_explicitGeom_even_draw`, `value_explicitGeom_odd_win`)**: For EVERY $r \ge 0$, EVERY step $d \ge 1$, and EVERY well-separated list $a_1 < a_2 < \dots < a_r$ ($a_1 > 3r + 4$, $a_{j} > 2 a_i + 3r + 4$ for $i < j$), forming the $2r$-element set $S = \bigsqcup_{i=1}^r \{d a_i, d (a_i + 1)\}$: - The exact game value from any gap $0 \le g < d (a_1 - r)$ (at multiples of $d$) follows a complete parity checkerboard (`loss` for $g > rd$, `draw` for $g/d \equiv r \pmod 2$, `win` for $g/d \not\equiv r \pmod 2$). - Consequently, **`CatchUp.value S = .draw` for every even $r = 2m$** (size $4m$) and **`CatchUp.value S = .win` for every odd $r = 2m + 1$** (size $4m + 2$). The proof introduces a novel **Double-Pick Knockout** invariant on broken-smallest pair configurations combined with an exact partner-reply induction. -/ namespace CatchUp /-! ## Section 1: Verbatim Catch-Up Definitions and Minimax API -/ /-- An arbitrary two elements type indexing the players in the Catch-Up game. -/ inductive Player | p1 | p2 deriving DecidableEq, Repr /-- Returns the other player. -/ def Player.other : Player → Player | p1 => p2 | p2 => p1 /-- The possible outcomes of a Catch-Up game. -/ inductive Outcome | win | loss | draw deriving DecidableEq, Repr /-- Negates an outcome, swapping win and loss. Used when switching player perspectives. -/ def Outcome.neg : Outcome → Outcome | win => loss | loss => win | draw => draw /-- Computes the best outcome for the current player from a list of possible outcomes. Win > Draw > Loss. -/ def Outcome.best (os : List Outcome) : Outcome := os.foldl (fun | .win, _ => .win | _, .win => .win | .draw, _ => .draw | _, .draw => .draw | _, _ => .loss) .loss /-- Recursive game value function (verbatim from `FormalConjectures/Paper/CatchUpConjecture.lean`). -/ noncomputable def valueAux (remaining : Finset ℕ) (s_me s_opp : ℕ) (isFirstMove : Bool) : Outcome := if remaining = ∅ then if s_me > s_opp then .win else if s_opp > s_me then .loss else .draw else if s_me + remaining.sum (fun x => x) < s_opp then .loss else let moves := remaining.attach.toList let outcomes := moves.map (fun ⟨x, _⟩ => let s_me' := s_me + x let remaining' := remaining.erase x if isFirstMove then (valueAux remaining' s_opp s_me' false).neg else if s_me' ≥ s_opp then (valueAux remaining' s_opp s_me' false).neg else valueAux remaining' s_me' s_opp false ) .best outcomes termination_by remaining.card decreasing_by all_goals simpa [remaining'] using Finset.card_erase_lt_of_mem ‹_› /-- Public API: game-theoretic value of Catch-Up on the set `S`. -/ noncomputable def value (S : Finset ℕ) : Outcome := valueAux S 0 0 true /-! ### Outcome and `Outcome.best` Algebraic Lemmas -/ @[simp] theorem Outcome.neg_neg (o : Outcome) : o.neg.neg = o := by cases o <;> rfl @[simp] theorem Outcome.neg_win : Outcome.win.neg = .loss := rfl @[simp] theorem Outcome.neg_loss : Outcome.loss.neg = .win := rfl @[simp] theorem Outcome.neg_draw : Outcome.draw.neg = .draw := rfl theorem Outcome.neg_eq_win_iff (o : Outcome) : o.neg = .win ↔ o = .loss := by cases o <;> simp [Outcome.neg] theorem Outcome.neg_eq_loss_iff (o : Outcome) : o.neg = .loss ↔ o = .win := by cases o <;> simp [Outcome.neg] theorem Outcome.neg_eq_draw_iff (o : Outcome) : o.neg = .draw ↔ o = .draw := by cases o <;> simp [Outcome.neg] /-- Binary maximum on `Outcome` (`win > draw > loss`). -/ def Outcome.max : Outcome → Outcome → Outcome | .win, _ => .win | _, .win => .win | .draw, _ => .draw | _, .draw => .draw | _, _ => .loss private lemma foldl_max_win (os : List Outcome) : os.foldl Outcome.max .win = .win := by induction os with | nil => rfl | cons o rest ih => cases o <;> simpa [List.foldl, Outcome.max] using ih private lemma foldl_max_draw (os : List Outcome) : os.foldl Outcome.max .draw = if .win ∈ os then .win else .draw := by induction os with | nil => rfl | cons o rest ih => cases o · simp [List.foldl, Outcome.max, foldl_max_win] · simp [List.foldl, Outcome.max, ih] · simp [List.foldl, Outcome.max, ih] private lemma foldl_max_loss (os : List Outcome) : os.foldl Outcome.max .loss = if .win ∈ os then .win else if .draw ∈ os then .draw else .loss := by induction os with | nil => rfl | cons o rest ih => cases o · simp [List.foldl, Outcome.max, foldl_max_win] · simp [List.foldl, Outcome.max, ih] · simp [List.foldl, Outcome.max, foldl_max_draw] theorem Outcome.best_eq (os : List Outcome) : Outcome.best os = if .win ∈ os then .win else if .draw ∈ os then .draw else .loss := by exact foldl_max_loss os theorem Outcome.best_eq_win_iff (os : List Outcome) : Outcome.best os = .win ↔ .win ∈ os := by rw [Outcome.best_eq] split_ifs with h1 h2 <;> simp [h1] theorem Outcome.best_eq_loss_iff (os : List Outcome) : Outcome.best os = .loss ↔ ∀ o ∈ os, o = .loss := by rw [Outcome.best_eq] split_ifs with h1 h2 · constructor · intro h; cases h · intro hall; exact absurd (hall .win h1) (by decide) · constructor · intro h; cases h · intro hall; exact absurd (hall .draw h2) (by decide) · constructor · intro _ o ho cases o · exact absurd ho h1 · rfl · exact absurd ho h2 · intro _; rfl theorem Outcome.best_ne_loss_iff (os : List Outcome) : Outcome.best os ≠ .loss ↔ ∃ o ∈ os, o ≠ .loss := by rw [ne_eq, Outcome.best_eq_loss_iff] push Not rfl theorem Outcome.best_eq_draw_iff (os : List Outcome) : Outcome.best os = .draw ↔ .draw ∈ os ∧ .win ∉ os := by rw [Outcome.best_eq] split_ifs with h1 h2 · simp [h1] · simp [h1, h2] · simp [h1, h2] theorem Outcome.best_ne_win_iff (os : List Outcome) : Outcome.best os ≠ .win ↔ ∀ o ∈ os, o ≠ .win := by rw [ne_eq, Outcome.best_eq_win_iff] constructor · intro h o ho heq; subst heq; exact h ho · intro h hmem; exact h .win hmem rfl /-! ### Clean Minimax API for `valueAux` -/ /-- Outcome of picking a specific element `x` from `remaining`. -/ noncomputable def moveOutcome (remaining : Finset ℕ) (s_me s_opp : ℕ) (isFirstMove : Bool) (x : ℕ) : Outcome := if isFirstMove ∨ s_opp ≤ s_me + x then (valueAux (remaining.erase x) s_opp (s_me + x) false).neg else valueAux (remaining.erase x) (s_me + x) s_opp false @[simp] theorem valueAux_empty (s_me s_opp : ℕ) (first : Bool) : valueAux ∅ s_me s_opp first = if s_me > s_opp then .win else if s_opp > s_me then .loss else .draw := by rw [valueAux] simp theorem valueAux_loss_of_sum_lt {R : Finset ℕ} {s_me s_opp : ℕ} {first : Bool} (hne : R ≠ ∅) (hlt : s_me + R.sum id < s_opp) : valueAux R s_me s_opp first = .loss := by rw [valueAux, if_neg hne, if_pos] simpa [id] using hlt theorem valueAux_eq_best_moveOutcome {R : Finset ℕ} {s_me s_opp : ℕ} {first : Bool} (hne : R ≠ ∅) (hle : s_opp ≤ s_me + R.sum id) : valueAux R s_me s_opp first = Outcome.best (R.attach.toList.map (fun ⟨x, _⟩ ↦ moveOutcome R s_me s_opp first x)) := by rw [valueAux] have hnot : ¬ (s_me + R.sum (fun x ↦ x) < s_opp) := by simpa using not_lt.2 hle simp only [hne, ↓reduceIte, hnot] congr 1 apply List.map_congr_left intro ⟨x, _⟩ _ unfold moveOutcome cases first <;> simp theorem valueAux_eq_win_iff {R : Finset ℕ} {s_me s_opp : ℕ} {first : Bool} (hne : R ≠ ∅) (hle : s_opp ≤ s_me + R.sum id) : valueAux R s_me s_opp first = .win ↔ ∃ x ∈ R, moveOutcome R s_me s_opp first x = .win := by rw [valueAux_eq_best_moveOutcome hne hle, Outcome.best_eq_win_iff] simp only [List.mem_map, Finset.mem_toList, Finset.mem_attach, true_and, Subtype.exists] constructor · rintro ⟨x, hx, h⟩; exact ⟨x, hx, h⟩ · rintro ⟨x, hx, h⟩; exact ⟨x, hx, h⟩ theorem valueAux_ne_loss_iff {R : Finset ℕ} {s_me s_opp : ℕ} {first : Bool} (hne : R ≠ ∅) (hle : s_opp ≤ s_me + R.sum id) : valueAux R s_me s_opp first ≠ .loss ↔ ∃ x ∈ R, moveOutcome R s_me s_opp first x ≠ .loss := by rw [valueAux_eq_best_moveOutcome hne hle, Outcome.best_ne_loss_iff] simp only [List.mem_map, Finset.mem_toList, Finset.mem_attach, true_and, Subtype.exists] constructor · rintro ⟨o, ⟨x, hx, rfl⟩, ho⟩; exact ⟨x, hx, ho⟩ · rintro ⟨x, hx, h⟩; exact ⟨_, ⟨x, hx, rfl⟩, h⟩ theorem valueAux_ne_win_iff {R : Finset ℕ} {s_me s_opp : ℕ} {first : Bool} (hne : R ≠ ∅) (hle : s_opp ≤ s_me + R.sum id) : valueAux R s_me s_opp first ≠ .win ↔ ∀ x ∈ R, moveOutcome R s_me s_opp first x ≠ .win := by rw [valueAux_eq_best_moveOutcome hne hle, Outcome.best_ne_win_iff] simp only [List.mem_map, Finset.mem_toList, Finset.mem_attach, true_and, Subtype.exists] constructor · intro h x hx; exact h _ ⟨x, hx, rfl⟩ · rintro h _ ⟨x, hx, rfl⟩; exact h x hx theorem valueAux_eq_loss_iff {R : Finset ℕ} {s_me s_opp : ℕ} {first : Bool} (hne : R ≠ ∅) (hle : s_opp ≤ s_me + R.sum id) : valueAux R s_me s_opp first = .loss ↔ ∀ x ∈ R, moveOutcome R s_me s_opp first x = .loss := by rw [valueAux_eq_best_moveOutcome hne hle, Outcome.best_eq_loss_iff] simp only [List.mem_map, Finset.mem_toList, Finset.mem_attach, true_and, Subtype.exists] constructor · intro h x hx; exact h _ ⟨x, hx, rfl⟩ · rintro h _ ⟨x, hx, rfl⟩; exact h x hx theorem valueAux_eq_draw_of_ne_win_ne_loss {o : Outcome} (h1 : o ≠ .win) (h2 : o ≠ .loss) : o = .draw := by cases o <;> simp_all /-! ## Section 2: Shift-Invariance, Scale-Invariance, and Parity Obstruction -/ /-- **Theorem 1 (Shift-Invariance)**: Adding the same constant `t` to both players' scores does not change `valueAux`. -/ theorem valueAux_add_right (R : Finset ℕ) (s_me s_opp t : ℕ) (first : Bool) : valueAux R (s_me + t) (s_opp + t) first = valueAux R s_me s_opp first := by induction hcard : R.card using Nat.strong_induction_on generalizing R s_me s_opp first with | h k ih => by_cases hempty : R = ∅ · subst hempty simp only [valueAux_empty] split_ifs <;> first | rfl | omega · by_cases hlt : s_me + R.sum id < s_opp · have hlt' : s_me + t + R.sum id < s_opp + t := by omega rw [valueAux_loss_of_sum_lt hempty hlt', valueAux_loss_of_sum_lt hempty hlt] · have hle : s_opp ≤ s_me + R.sum id := by omega have hle' : s_opp + t ≤ s_me + t + R.sum id := by omega rw [valueAux_eq_best_moveOutcome hempty hle', valueAux_eq_best_moveOutcome hempty hle] congr 1 apply List.map_congr_left intro ⟨x, hx⟩ _ dsimp only unfold moveOutcome have hcond : (first = true ∨ s_opp + t ≤ s_me + t + x) ↔ (first = true ∨ s_opp ≤ s_me + x) := by constructor <;> (rintro (h | h) <;> [exact Or.inl h; exact Or.inr (by omega)]) have hlt_card : (R.erase x).card < k := by rw [← hcard]; exact Finset.card_erase_lt_of_mem hx have hadd : s_me + t + x = s_me + x + t := by omega by_cases hc : first = true ∨ s_opp ≤ s_me + x · have hc' : first = true ∨ s_opp + t ≤ s_me + t + x := hcond.2 hc rw [if_pos hc', if_pos hc, hadd] rw [ih _ hlt_card (R.erase x) s_opp (s_me + x) false rfl] · have hc' : ¬ (first = true ∨ s_opp + t ≤ s_me + t + x) := fun h ↦ hc (hcond.1 h) rw [if_neg hc', if_neg hc, hadd] rw [ih _ hlt_card (R.erase x) (s_me + x) s_opp false rfl] /-- Corollary: `valueAux` depends only on the gap `s_opp - s_me` when `s_me ≤ s_opp`. -/ theorem valueAux_eq_zero_gap {R : Finset ℕ} {s_me s_opp : ℕ} {first : Bool} (hle : s_me ≤ s_opp) : valueAux R s_me s_opp first = valueAux R 0 (s_opp - s_me) first := by have h1 : 0 + s_me = s_me := Nat.zero_add s_me have h2 : (s_opp - s_me) + s_me = s_opp := Nat.sub_add_cancel hle conv_lhs => rw [← h1, ← h2] exact valueAux_add_right R 0 (s_opp - s_me) s_me first /-- **Theorem 2 (Scale-Invariance)**: Multiplying all numbers and scores by a positive integer `c > 0` preserves `valueAux`. -/ theorem valueAux_image_mul {c : ℕ} (hc : 0 < c) (R : Finset ℕ) (s_me s_opp : ℕ) (first : Bool) : valueAux (R.image (c * ·)) (c * s_me) (c * s_opp) first = valueAux R s_me s_opp first := by have hmul_inj : Function.Injective (fun x : ℕ ↦ c * x) := fun x y h ↦ Nat.eq_of_mul_eq_mul_left hc h induction hcard : R.card using Nat.strong_induction_on generalizing R s_me s_opp first with | h k ih => have hsum : (R.image (c * ·)).sum id = c * R.sum id := by rw [Finset.sum_image (fun _ _ _ _ h ↦ hmul_inj h)] simp only [id, Finset.mul_sum] by_cases hempty : R = ∅ · subst hempty simp only [Finset.image_empty, valueAux_empty] have hgt1 : c * s_me > c * s_opp ↔ s_me > s_opp := Nat.mul_lt_mul_left hc have hgt2 : c * s_opp > c * s_me ↔ s_opp > s_me := Nat.mul_lt_mul_left hc simp only [hgt1, hgt2] · have hempty' : R.image (c * ·) ≠ ∅ := by intro h; exact hempty (Finset.image_eq_empty.1 h) by_cases hlt : s_me + R.sum id < s_opp · have hlt' : c * s_me + (R.image (c * ·)).sum id < c * s_opp := by rw [hsum, ← Nat.mul_add] exact Nat.mul_lt_mul_of_pos_left hlt hc rw [valueAux_loss_of_sum_lt hempty' hlt', valueAux_loss_of_sum_lt hempty hlt] · have hle : s_opp ≤ s_me + R.sum id := by omega have hle' : c * s_opp ≤ c * s_me + (R.image (c * ·)).sum id := by rw [hsum, ← Nat.mul_add] exact Nat.mul_le_mul_left c hle have hmove_eq : ∀ x ∈ R, moveOutcome (R.image (c * ·)) (c * s_me) (c * s_opp) first (c * x) = moveOutcome R s_me s_opp first x := by intro x hx unfold moveOutcome have herase : (R.image (c * ·)).erase (c * x) = (R.erase x).image (c * ·) := by ext y simp only [Finset.mem_erase, Finset.mem_image] constructor · rintro ⟨hne, z, hz, rfl⟩ exact ⟨z, ⟨fun h ↦ hne (congrArg (c * ·) h), hz⟩, rfl⟩ · rintro ⟨z, ⟨hne, hz⟩, rfl⟩ exact ⟨fun h ↦ hne (hmul_inj h), z, hz, rfl⟩ have hlt_card : (R.erase x).card < k := by rw [← hcard]; exact Finset.card_erase_lt_of_mem hx have hcond : (first = true ∨ c * s_opp ≤ c * s_me + c * x) ↔ (first = true ∨ s_opp ≤ s_me + x) := by rw [← Nat.mul_add, Nat.mul_le_mul_left_iff hc] rw [herase] by_cases h1 : first = true ∨ s_opp ≤ s_me + x · have h1' : first = true ∨ c * s_opp ≤ c * s_me + c * x := hcond.2 h1 rw [if_pos h1', if_pos h1, ← Nat.mul_add] rw [ih _ hlt_card (R.erase x) s_opp (s_me + x) false rfl] · have h1' : ¬ (first = true ∨ c * s_opp ≤ c * s_me + c * x) := fun h ↦ h1 (hcond.1 h) rw [if_neg h1', if_neg h1, ← Nat.mul_add] rw [ih _ hlt_card (R.erase x) (s_me + x) s_opp false rfl] -- Compare via `Outcome.best_eq` (set of outcomes is identical!) have hwin_iff : valueAux (R.image (c * ·)) (c * s_me) (c * s_opp) first = .win ↔ valueAux R s_me s_opp first = .win := by rw [valueAux_eq_win_iff hempty' hle', valueAux_eq_win_iff hempty hle] constructor · rintro ⟨y, hy, h⟩ rcases Finset.mem_image.1 hy with ⟨x, hx, rfl⟩ exact ⟨x, hx, by rwa [← hmove_eq x hx]⟩ · rintro ⟨x, hx, h⟩ exact ⟨c * x, Finset.mem_image_of_mem _ hx, by rwa [hmove_eq x hx]⟩ have hloss_iff : valueAux (R.image (c * ·)) (c * s_me) (c * s_opp) first = .loss ↔ valueAux R s_me s_opp first = .loss := by rw [valueAux_eq_loss_iff hempty' hle', valueAux_eq_loss_iff hempty hle] constructor · intro h x hx rw [← hmove_eq x hx] exact h (c * x) (Finset.mem_image_of_mem _ hx) · intro h y hy rcases Finset.mem_image.1 hy with ⟨x, hx, rfl⟩ rw [hmove_eq x hx] exact h x hx cases hL : valueAux (R.image (c * ·)) (c * s_me) (c * s_opp) first <;> cases hR : valueAux R s_me s_opp first <;> simp_all /-- Scale-invariance for `CatchUp.value`: multiplying every element of `S` by `c > 0` preserves the game-theoretic value. -/ theorem value_image_mul {c : ℕ} (hc : 0 < c) (S : Finset ℕ) : value (S.image (c * ·)) = value S := by simpa [value] using valueAux_image_mul hc S 0 0 true /-- **Theorem 3 (Parity Obstruction)**: Whenever the total sum `s_me + s_opp + R.sum id` is odd, `valueAux` cannot be `.draw`. -/ theorem valueAux_ne_draw_of_odd_total (R : Finset ℕ) (s_me s_opp : ℕ) (first : Bool) (hodd : Odd (s_me + s_opp + R.sum id)) : valueAux R s_me s_opp first ≠ .draw := by induction hcard : R.card using Nat.strong_induction_on generalizing R s_me s_opp first with | h k ih => by_cases hempty : R = ∅ · subst hempty simp only [Finset.sum_empty, add_zero] at hodd simp only [valueAux_empty] split_ifs with h1 h2 · decide · decide · rcases hodd with ⟨m, hm⟩ omega · by_cases hlt : s_me + R.sum id < s_opp · rw [valueAux_loss_of_sum_lt hempty hlt]; decide · have hle : s_opp ≤ s_me + R.sum id := by omega intro hdraw rw [valueAux_eq_best_moveOutcome hempty hle, Outcome.best_eq_draw_iff] at hdraw rcases List.mem_map.1 hdraw.1 with ⟨⟨x, hx⟩, _, hmx⟩ have hlt_card : (R.erase x).card < k := by rw [← hcard]; exact Finset.card_erase_lt_of_mem hx have hsum_er : (R.erase x).sum id + x = R.sum id := Finset.sum_erase_add R id hx unfold moveOutcome at hmx by_cases hc : first = true ∨ s_opp ≤ s_me + x · simp only [hc, ↓reduceIte, Outcome.neg_eq_draw_iff] at hmx have hodd' : Odd (s_opp + (s_me + x) + (R.erase x).sum id) := by convert hodd using 1; omega exact ih _ hlt_card (R.erase x) s_opp (s_me + x) false hodd' rfl hmx · simp only [hc, ↓reduceIte] at hmx have hodd' : Odd ((s_me + x) + s_opp + (R.erase x).sum id) := by convert hodd using 1; omega exact ih _ hlt_card (R.erase x) (s_me + x) s_opp false hodd' rfl hmx /-- Any set with odd sum cannot draw in Catch-Up. -/ theorem value_ne_draw_of_odd_sum {S : Finset ℕ} (hodd : Odd (S.sum id)) : value S ≠ .draw := by exact valueAux_ne_draw_of_odd_total S 0 0 true (by simpa using hodd) /-- Converse obstruction for the Catch-Up Conjecture: whenever `N * (N + 1) / 2` is odd (equivalently `N ≡ 1, 2 (mod 4)`), `CatchUp.value (.Icc 1 N) ≠ .draw`. -/ theorem value_Icc_ne_draw_of_odd_triangular {N : ℕ} (hodd : Odd (N * (N + 1) / 2)) : value (Finset.Icc 1 N) ≠ .draw := by apply value_ne_draw_of_odd_sum have hsum : ∀ M : ℕ, (Finset.Icc 1 M).sum id = M * (M + 1) / 2 := by intro M induction M with | zero => simp | succ n ih => have hsub : Finset.Icc 1 (n + 1) = insert (n + 1) (Finset.Icc 1 n) := by ext x; simp only [Finset.mem_Icc, Finset.mem_insert]; omega have hnotin : n + 1 ∉ Finset.Icc 1 n := by simp rw [hsub, Finset.sum_insert hnotin, ih] simp only [id] have hdiv : (n + 1) * (n + 1 + 1) / 2 = n * (n + 1) / 2 + (n + 1) := by have h1 : (n + 1) * (n + 1 + 1) = n * (n + 1) + 2 * (n + 1) := by ring rw [h1, Nat.add_mul_div_left _ _ (by decide)] omega rw [hsum N] exact hodd /-! ## Section 3: Dominant-Max & Exact-Sum-Max Infinite Families -/ /-- Universal exact-remaining-sum lemma: if every remaining number is positive and the opponent leads by *exactly* the sum of all remaining numbers, then `valueAux = .draw`. -/ theorem valueAux_eq_draw_of_exact_sum (R : Finset ℕ) (s_me : ℕ) (hpos : ∀ x ∈ R, 0 < x) : valueAux R s_me (s_me + R.sum id) false = .draw := by induction hcard : R.card using Nat.strong_induction_on generalizing R s_me with | h k ih => by_cases hempty : R = ∅ · subst hempty; simp · have hle : s_me + R.sum id ≤ s_me + R.sum id := le_rfl have hevery : ∀ x ∈ R, moveOutcome R s_me (s_me + R.sum id) false x = .draw := by intro x hx unfold moveOutcome have hsum_er : (R.erase x).sum id + x = R.sum id := Finset.sum_erase_add R id hx by_cases hrem : R.erase x = ∅ · have hxsum : x = R.sum id := by rw [hrem, Finset.sum_empty, zero_add] at hsum_er; exact hsum_er have hge : s_me + R.sum id ≤ s_me + x := by omega simp only [hge, or_true, ↓reduceIte, hrem, valueAux_empty, Outcome.neg_eq_draw_iff] split_ifs <;> first | rfl | omega · obtain ⟨y, hy⟩ := Finset.nonempty_iff_ne_empty.2 hrem have hy_pos : 0 < y := hpos y (Finset.mem_of_mem_erase hy) have hsum_pos : 0 < (R.erase x).sum id := lt_of_lt_of_le hy_pos (Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hy) have hlt : ¬ (s_me + R.sum id ≤ s_me + x) := by omega simp only [Bool.false_eq_true, false_or, hlt, ↓reduceIte] have hlt_card : (R.erase x).card < k := by rw [← hcard]; exact Finset.card_erase_lt_of_mem hx have heq : s_me + R.sum id = (s_me + x) + (R.erase x).sum id := by omega rw [heq] exact ih _ hlt_card (R.erase x) (s_me + x) (fun z hz ↦ hpos z (Finset.mem_of_mem_erase hz)) rfl apply valueAux_eq_draw_of_ne_win_ne_loss · rw [valueAux_ne_win_iff hempty hle] intro x hx; rw [hevery x hx]; decide · rw [valueAux_ne_loss_iff hempty hle] obtain ⟨x, hx⟩ := Finset.nonempty_iff_ne_empty.2 hempty exact ⟨x, hx, by rw [hevery x hx]; decide⟩ /-- **Theorem 4 (Dominant-Max Win Theorem)**: If `M ∈ S` strictly exceeds the sum of all other elements of `S` (for example `S = {1, 2, 4, ..., 2^n}`), then `CatchUp.value S = .win`. -/ theorem value_eq_win_of_dominant_max {S : Finset ℕ} {M : ℕ} (hM : M ∈ S) (hdom : (S.erase M).sum id < M) : value S = .win := by have hne : S ≠ ∅ := Finset.ne_empty_of_mem hM unfold value rw [valueAux_eq_win_iff hne (Nat.zero_le _)] refine ⟨M, hM, ?_⟩ unfold moveOutcome simp only [true_or, ↓reduceIte, zero_add, Outcome.neg_eq_win_iff] by_cases her : S.erase M = ∅ · rw [her] at hdom ⊢ rw [valueAux_empty] simp only [Finset.sum_empty] at hdom split_ifs <;> first | rfl | omega · exact valueAux_loss_of_sum_lt her (by omega) /-- **Theorem 5 (Exact-Sum-Max Draw Theorem)**: If `|S| ≥ 3`, every element of `S` is positive, and `M ∈ S` equals the sum of all other elements of `S` (for example `{1, 2, 3}`, `{1, 2, 4, 7}`, or `{1, 2, 4, ..., 2^n, 2^{n+1} - 1}`), then `CatchUp.value S = .draw`. -/ theorem value_eq_draw_of_exact_sum_max {S : Finset ℕ} {M : ℕ} (hM : M ∈ S) (_hcard : 3 ≤ S.card) (hpos : ∀ x ∈ S, 0 < x) (heq : (S.erase M).sum id = M) : value S = .draw := by have hne : S ≠ ∅ := Finset.ne_empty_of_mem hM unfold value apply valueAux_eq_draw_of_ne_win_ne_loss · -- Player 1 cannot win: whatever `x ∈ S` Player 1 picks, Player 2 achieves at least `.draw`. rw [valueAux_ne_win_iff hne (Nat.zero_le _)] intro x hx unfold moveOutcome simp only [true_or, ↓reduceIte, zero_add, ne_eq, Outcome.neg_eq_win_iff] by_cases hxM : x = M · subst hxM have hd := valueAux_eq_draw_of_exact_sum (S.erase x) 0 (fun z hz ↦ hpos z (Finset.mem_of_mem_erase hz)) rw [zero_add, heq] at hd rw [hd]; decide · -- x ≠ M: Player 2 takes M! Since M = (S.erase M).sum id > x, Player 2 catches up and leads by M - x! have hM_in : M ∈ S.erase x := Finset.mem_erase.2 ⟨Ne.symm hxM, hM⟩ have hne_er : S.erase x ≠ ∅ := Finset.ne_empty_of_mem hM_in have hsum_er : (S.erase x).sum id + x = S.sum id := Finset.sum_erase_add S id hx have hsum_M : (S.erase M).sum id + M = S.sum id := Finset.sum_erase_add S id hM have hx_in_erM : x ∈ S.erase M := Finset.mem_erase.2 ⟨hxM, hx⟩ have hrem_er : ((S.erase M).erase x).sum id + x = (S.erase M).sum id := Finset.sum_erase_add (S.erase M) id hx_in_erM have hcomm : (S.erase x).erase M = (S.erase M).erase x := Finset.erase_right_comm have hle_er : x ≤ 0 + (S.erase x).sum id := by omega rw [← ne_eq, valueAux_ne_loss_iff hne_er hle_er] refine ⟨M, hM_in, ?_⟩ unfold moveOutcome have hx_le_M : x ≤ 0 + M := by omega rw [if_pos (Or.inr hx_le_M), zero_add, hcomm, ne_eq, Outcome.neg_eq_loss_iff] have hd := valueAux_eq_draw_of_exact_sum ((S.erase M).erase x) x (fun z hz ↦ hpos z (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hz))) have hM_eq : x + ((S.erase M).erase x).sum id = M := by omega rw [hM_eq] at hd rw [hd]; decide · -- Player 1 guarantees at least `.draw` by opening with `M`. rw [valueAux_ne_loss_iff hne (Nat.zero_le _)] refine ⟨M, hM, ?_⟩ unfold moveOutcome simp only [true_or, ↓reduceIte, zero_add, ne_eq, Outcome.neg_eq_loss_iff] have hd := valueAux_eq_draw_of_exact_sum (S.erase M) 0 (fun z hz ↦ hpos z (Finset.mem_of_mem_erase hz)) rw [zero_add, heq] at hd rw [hd]; decide /-! ## Section 4: Complete 3-Element Classification & Balanced 4-Element Draw Theorem -/ /-- Exact value of a 1-element remaining state `valueAux {a} s_me s_opp false`. -/ theorem valueAux_singleton (a s_me s_opp : ℕ) (first : Bool) : valueAux {a} s_me s_opp first = if s_me + a > s_opp then .win else if s_opp > s_me + a then .loss else .draw := by by_cases hlt : s_me + a < s_opp · rw [valueAux_loss_of_sum_lt (Finset.singleton_ne_empty a) (by simpa using hlt)] split_ifs <;> first | rfl | omega · have hle : s_opp ≤ s_me + ({a} : Finset ℕ).sum id := by simpa using not_lt.1 hlt rw [valueAux_eq_best_moveOutcome (Finset.singleton_ne_empty a) hle] have hm : moveOutcome {a} s_me s_opp first a = if s_me + a > s_opp then .win else if s_opp > s_me + a then .loss else .draw := by unfold moveOutcome have hge : s_opp ≤ s_me + a := by omega simp only [hge, or_true, ↓reduceIte, Finset.erase_singleton, valueAux_empty] split_ifs <;> first | omega | rfl have hwin : Outcome.best (({a} : Finset ℕ).attach.toList.map (fun ⟨x, _⟩ ↦ moveOutcome {a} s_me s_opp first x)) = moveOutcome {a} s_me s_opp first a := by have hmem_all : ∀ o ∈ ({a} : Finset ℕ).attach.toList.map (fun ⟨x, _⟩ ↦ moveOutcome {a} s_me s_opp first x), o = moveOutcome {a} s_me s_opp first a := by intro o ho rcases List.mem_map.1 ho with ⟨⟨x, hx⟩, _, rfl⟩ dsimp only rw [Finset.mem_singleton.1 hx] have hmem_a : moveOutcome {a} s_me s_opp first a ∈ ({a} : Finset ℕ).attach.toList.map (fun ⟨x, _⟩ ↦ moveOutcome {a} s_me s_opp first x) := by exact List.mem_map.2 ⟨⟨a, Finset.mem_singleton_self a⟩, by simp, rfl⟩ rw [Outcome.best_eq] cases hval : moveOutcome {a} s_me s_opp first a · rw [if_pos (hval ▸ hmem_a)] · rw [if_neg (fun h ↦ by have := hmem_all _ h; rw [hval] at this; cases this), if_neg (fun h ↦ by have := hmem_all _ h; rw [hval] at this; cases this)] · rw [if_neg (fun h ↦ by have := hmem_all _ h; rw [hval] at this; cases this), if_pos (hval ▸ hmem_a)] rw [hwin, hm] /-- **Theorem 6 (Complete Classification of All 3-Element Catch-Up Games)**: For every triple $0 < a < b < c$, `CatchUp.value {a, b, c} = if a + b = c then .draw else .win`. -/ theorem value_three_elements {a b c : ℕ} (ha : 0 < a) (hab : a < b) (hbc : b < c) : value {a, b, c} = if a + b = c then .draw else .win := by have hne_ab : a ≠ b := by omega have hne_ac : a ≠ c := by omega have hne_bc : b ≠ c := by omega have her_c : ({a, b, c} : Finset ℕ).erase c = {a, b} := by ext x; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have her_a : ({a, b, c} : Finset ℕ).erase a = {b, c} := by ext x; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_ab : ({a, b} : Finset ℕ).sum id = a + b := by rw [Finset.sum_pair hne_ab]; rfl split_ifs with heq · have hcard : 3 ≤ ({a, b, c} : Finset ℕ).card := by rw [Finset.card_insert_of_notMem (by simp [hne_ab, hne_ac]), Finset.card_pair hne_bc] exact value_eq_draw_of_exact_sum_max (M := c) (by simp) hcard (by intro x hx; simp only [Finset.mem_insert, Finset.mem_singleton] at hx; omega) (by rw [her_c, hsum_ab]; exact heq) · by_cases hlt : a + b < c · exact value_eq_win_of_dominant_max (M := c) (by simp) (by rw [her_c, hsum_ab]; exact hlt) · -- a + b > c: Player 1 opens with `a`, forcing Player 2 to take `b` or `c` and lose! have hgt : c < a + b := by omega unfold value rw [valueAux_eq_win_iff (by simp) (Nat.zero_le _)] refine ⟨a, by simp, ?_⟩ unfold moveOutcome simp only [true_or, ↓reduceIte, zero_add, her_a, Outcome.neg_eq_win_iff] have hsum_bc : ({b, c} : Finset ℕ).sum id = b + c := by rw [Finset.sum_pair hne_bc]; rfl rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_bc]; omega)] intro x hx simp only [Finset.mem_insert, Finset.mem_singleton] at hx unfold moveOutcome rcases hx with hxb | hxc · rw [hxb] have hge : a ≤ 0 + b := by omega have her : ({b, c} : Finset ℕ).erase b = {c} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_pos (Or.inr hge), zero_add, her, valueAux_singleton, Outcome.neg_eq_loss_iff] rw [if_pos (by omega)] · rw [hxc] have hge : a ≤ 0 + c := by omega have her : ({b, c} : Finset ℕ).erase c = {b} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_pos (Or.inr hge), zero_add, her, valueAux_singleton, Outcome.neg_eq_loss_iff] rw [if_pos (by omega)] /-- **Theorem 7 (Balanced 4-Element Draw Theorem)**: For EVERY balanced quadruple $0 < a < b < c < d$ with $a + d = b + c$ (in particular, every 4-term arithmetic progression $\{a, a+u, a+2u, a+3u\}$ and `Catch-Up({1, 2, 3, 4})`), `CatchUp.value {a, b, c, d} = .draw`. -/ theorem value_four_balanced {a b c d : ℕ} (ha : 0 < a) (hab : a < b) (hbc : b < c) (hcd : c < d) (hbal : a + d = b + c) : value {a, b, c, d} = .draw := by have hne : ({a, b, c, d} : Finset ℕ) ≠ ∅ := by simp -- Helper: erasing from a 2-element set `{u, v}` have her2 : ∀ u v : ℕ, u ≠ v → ({u, v} : Finset ℕ).erase u = {v} ∧ ({u, v} : Finset ℕ).erase v = {u} := by intro u v huv constructor <;> (ext x; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega) -- Helper: valueAux on `{u, v}` (`u < v`) at gap `v - u` is `.draw` when `u ≥ v - u` or `v` taken! -- Actually let's evaluate `valueAux {c, d} s (s + (d - c)) false`: have hcd_gap : ∀ s : ℕ, valueAux {c, d} s (s + (d - c)) false ≠ .win := by intro s have hsum : ({c, d} : Finset ℕ).sum id = c + d := by rw [Finset.sum_pair (by omega)]; rfl rw [valueAux_ne_win_iff (by simp) (by rw [hsum]; omega)] intro x hx simp only [Finset.mem_insert, Finset.mem_singleton] at hx unfold moveOutcome rcases hx with hxc | hxd · rw [hxc] have hle : s + (d - c) ≤ s + c := by omega rw [if_pos (Or.inr hle), (her2 c d (by omega)).1, valueAux_singleton, ne_eq, Outcome.neg_eq_win_iff] rw [if_pos (by omega)]; decide · rw [hxd] rw [if_pos (Or.inr (show s + (d - c) ≤ s + d by omega)), (her2 c d (by omega)).2, valueAux_singleton, ne_eq, Outcome.neg_eq_win_iff] rw [if_neg (by omega), if_neg (by omega)]; decide -- Also `valueAux {c, d} s (s + (d - c)) false ≠ .loss` (taking `d` draws!) have hcd_gap_ne_loss : ∀ s : ℕ, valueAux {c, d} s (s + (d - c)) false ≠ .loss := by intro s have hsum : ({c, d} : Finset ℕ).sum id = c + d := by rw [Finset.sum_pair (by omega)]; rfl rw [valueAux_ne_loss_iff (by simp) (by rw [hsum]; omega)] refine ⟨d, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show s + (d - c) ≤ s + d by omega)), (her2 c d (by omega)).2, valueAux_singleton, ne_eq, Outcome.neg_eq_loss_iff] rw [if_neg (by omega), if_neg (by omega)]; decide unfold value apply valueAux_eq_draw_of_ne_win_ne_loss · -- Part 1: Player 1 cannot win (`valueAux ≤ draw`), by exhibiting a drawing reply to every first move! rw [valueAux_ne_win_iff hne (Nat.zero_le _)] intro x hx simp only [Finset.mem_insert, Finset.mem_singleton] at hx unfold moveOutcome simp only [true_or, ↓reduceIte, zero_add, ne_eq, Outcome.neg_eq_win_iff] rcases hx with hxa | hxb | hxc | hxd · rw [hxa] have her : ({a, b, c, d} : Finset ℕ).erase a = {b, c, d} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [her] have hsum : ({b, c, d} : Finset ℕ).sum id = b + c + d := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega rw [← ne_eq, valueAux_ne_loss_iff (by simp) (by rw [hsum]; omega)] refine ⟨b, by simp, ?_⟩ unfold moveOutcome have her' : ({b, c, d} : Finset ℕ).erase b = {c, d} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_pos (Or.inr (show a ≤ 0 + b by omega)), zero_add, her', ne_eq, Outcome.neg_eq_loss_iff] have hgap : b = a + (d - c) := by omega rw [hgap] exact hcd_gap a · rw [hxb] have her : ({a, b, c, d} : Finset ℕ).erase b = {a, c, d} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [her] have hsum : ({a, c, d} : Finset ℕ).sum id = a + c + d := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega rw [← ne_eq, valueAux_ne_loss_iff (by simp) (by rw [hsum]; omega)] refine ⟨a, by simp, ?_⟩ unfold moveOutcome have her' : ({a, c, d} : Finset ℕ).erase a = {c, d} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_neg (by simp; omega), zero_add, her'] have hgap : b = a + (d - c) := by omega rw [hgap] exact hcd_gap_ne_loss a · rw [hxc] have her : ({a, b, c, d} : Finset ℕ).erase c = {a, b, d} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [her] have hsum : ({a, b, d} : Finset ℕ).sum id = a + b + d := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega rw [← ne_eq, valueAux_ne_loss_iff (by simp) (by rw [hsum]; omega)] refine ⟨a, by simp, ?_⟩ unfold moveOutcome have her' : ({a, b, d} : Finset ℕ).erase a = {b, d} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_neg (by simp; omega), zero_add, her'] have hsum2 : ({b, d} : Finset ℕ).sum id = b + d := by rw [Finset.sum_pair (by omega)]; rfl rw [valueAux_ne_loss_iff (by simp) (by rw [hsum2]; omega)] refine ⟨d, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show c ≤ a + d by omega)), (her2 b d (by omega)).2, valueAux_singleton, ne_eq, Outcome.neg_eq_loss_iff] rw [if_neg (by omega), if_neg (by omega)]; decide · rw [hxd] have her : ({a, b, c, d} : Finset ℕ).erase d = {a, b, c} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [her] have hsum : ({a, b, c} : Finset ℕ).sum id = a + b + c := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega rw [← ne_eq, valueAux_ne_loss_iff (by simp) (by rw [hsum]; omega)] refine ⟨c, by simp, ?_⟩ unfold moveOutcome have her' : ({a, b, c} : Finset ℕ).erase c = {a, b} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_neg (by simp; omega), zero_add, her'] have hsum2 : ({a, b} : Finset ℕ).sum id = a + b := by rw [Finset.sum_pair (by omega)]; rfl rw [valueAux_ne_loss_iff (by simp) (by rw [hsum2]; omega)] refine ⟨b, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show d ≤ c + b by omega)), (her2 a b (by omega)).2, valueAux_singleton, ne_eq, Outcome.neg_eq_loss_iff] rw [if_neg (by omega), if_neg (by omega)]; decide · -- Part 2: Player 1 guarantees at least `.draw` by opening with `b`! rw [valueAux_ne_loss_iff hne (Nat.zero_le _)] refine ⟨b, by simp, ?_⟩ unfold moveOutcome have her : ({a, b, c, d} : Finset ℕ).erase b = {a, c, d} := by ext y; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega simp only [true_or, ↓reduceIte, zero_add, her, ne_eq, Outcome.neg_eq_loss_iff] have hsum : ({a, c, d} : Finset ℕ).sum id = a + c + d := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega rw [← ne_eq, valueAux_ne_win_iff (by simp) (by rw [hsum]; omega)] intro y hy simp only [Finset.mem_insert, Finset.mem_singleton] at hy unfold moveOutcome rcases hy with hya | hyc | hyd · rw [hya] have her' : ({a, c, d} : Finset ℕ).erase a = {c, d} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_neg (by simp; omega), zero_add, her'] have hgap : b = a + (d - c) := by omega rw [hgap] exact hcd_gap a · rw [hyc] have her' : ({a, c, d} : Finset ℕ).erase c = {a, d} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_pos (Or.inr (show b ≤ 0 + c by omega)), zero_add, her', ne_eq, Outcome.neg_eq_win_iff] have hsum2 : ({a, d} : Finset ℕ).sum id = a + d := by rw [Finset.sum_pair (by omega)]; rfl rw [← ne_eq, valueAux_ne_loss_iff (by simp) (by rw [hsum2]; omega)] refine ⟨d, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show c ≤ b + d by omega)), (her2 a d (by omega)).2, valueAux_singleton, ne_eq, Outcome.neg_eq_loss_iff] rw [if_neg (by omega), if_pos (by omega)]; decide · rw [hyd] have her' : ({a, c, d} : Finset ℕ).erase d = {a, c} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega rw [if_pos (Or.inr (show b ≤ 0 + d by omega)), zero_add, her', ne_eq, Outcome.neg_eq_win_iff] have hsum2 : ({a, c} : Finset ℕ).sum id = a + c := by rw [Finset.sum_pair (by omega)]; rfl rw [← ne_eq, valueAux_ne_loss_iff (by simp) (by rw [hsum2]; omega)] refine ⟨c, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show d ≤ b + c by omega)), (her2 a c (by omega)).2, valueAux_singleton, ne_eq, Outcome.neg_eq_loss_iff] rw [if_neg (by omega), if_neg (by omega)]; decide /-- Every 4-term arithmetic progression `{a, a + u, a + 2*u, a + 3*u}` (`a, u > 0`) draws. -/ theorem value_four_ap {a u : ℕ} (ha : 0 < a) (hu : 0 < u) : value {a, a + u, a + 2 * u, a + 3 * u} = .draw := value_four_balanced ha (by omega) (by omega) (by omega) (by omega) /-- **Theorem 7b (Complete Classification of ALL 4-Element Catch-Up Games)**: For EVERY quadruple $0 < a < b < c < d$, Player 1 NEVER loses, and `CatchUp.value {a, b, c, d} = if a + d = b + c ∨ a + b + c = d then .draw else .win`. -/ theorem value_four_complete {a b c d : ℕ} (ha : 0 < a) (hab : a < b) (hbc : b < c) (hcd : c < d) : value {a, b, c, d} = if a + d = b + c ∨ a + b + c = d then .draw else .win := by have her2 : ∀ u v : ℕ, u ≠ v → ({u, v} : Finset ℕ).erase u = {v} ∧ ({u, v} : Finset ℕ).erase v = {u} := by intro u v huv constructor <;> (ext x; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega) have her_d : ({a, b, c, d} : Finset ℕ).erase d = {a, b, c} := by ext x; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_abc : ({a, b, c} : Finset ℕ).sum id = a + b + c := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega split_ifs with htie · rcases htie with hbal | hsum_eq · exact value_four_balanced ha hab hbc hcd hbal · have hcard : 3 ≤ ({a, b, c, d} : Finset ℕ).card := by rw [Finset.card_insert_of_notMem (by simp; omega), Finset.card_insert_of_notMem (by simp; omega), Finset.card_pair (by omega)] omega exact value_eq_draw_of_exact_sum_max (M := d) (by simp) hcard (by intro x hx; simp only [Finset.mem_insert, Finset.mem_singleton] at hx; omega) (by rw [her_d, hsum_abc]; exact hsum_eq) · push Not at htie rcases htie with ⟨hne_bal, hne_sum⟩ by_cases hdom : a + b + c < d · exact value_eq_win_of_dominant_max (M := d) (by simp) (by rw [her_d, hsum_abc]; exact hdom) · have hgt_sum : d < a + b + c := by omega unfold value rw [valueAux_eq_win_iff (by simp) (Nat.zero_le _)] by_cases hlt_bal : a + d < b + c · -- Case 1: `a + d < b + c` and `d < a + b + c` -> opening with `b` ALWAYS wins! refine ⟨b, by simp, ?_⟩ unfold moveOutcome have her_b : ({a, b, c, d} : Finset ℕ).erase b = {a, c, d} := by ext x; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_acd : ({a, c, d} : Finset ℕ).sum id = a + c + d := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega rw [if_pos (Or.inl rfl), zero_add, her_b, Outcome.neg_eq_win_iff] rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_acd]; omega)] intro y hy simp only [Finset.mem_insert, Finset.mem_singleton] at hy unfold moveOutcome rcases hy with hya | hyc | hyd · -- P2 takes `a` (behind by `b - a`), stays on turn on `{c, d}`: rw [hya] have her' : ({a, c, d} : Finset ℕ).erase a = {c, d} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_cd : ({c, d} : Finset ℕ).sum id = c + d := by rw [Finset.sum_pair (by omega)]; rfl rw [if_neg (by simp; omega), zero_add, her'] rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_cd]; omega)] intro z hz simp only [Finset.mem_insert, Finset.mem_singleton] at hz unfold moveOutcome rcases hz with hzc | hzd · rw [hzc] rw [if_pos (Or.inr (show b ≤ a + c by omega)), (her2 c d (by omega)).1, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] · rw [hzd] rw [if_pos (Or.inr (show b ≤ a + d by omega)), (her2 c d (by omega)).2, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] · -- P2 takes `c` (> b): P1 takes `d`, wins `b + d > a + c`! rw [hyc] have her' : ({a, c, d} : Finset ℕ).erase c = {a, d} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_ad : ({a, d} : Finset ℕ).sum id = a + d := by rw [Finset.sum_pair (by omega)]; rfl rw [if_pos (Or.inr (show b ≤ 0 + c by omega)), zero_add, her', Outcome.neg_eq_loss_iff] rw [valueAux_eq_win_iff (by simp) (by rw [hsum_ad]; omega)] refine ⟨d, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show c ≤ b + d by omega)), (her2 a d (by omega)).2, valueAux_singleton, Outcome.neg_eq_win_iff, if_neg (by omega), if_pos (by omega)] · -- P2 takes `d` (> b): P1 takes `c` (catches up since `b + c > d`), wins `b + c > a + d`! rw [hyd] have her' : ({a, c, d} : Finset ℕ).erase d = {a, c} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_ac : ({a, c} : Finset ℕ).sum id = a + c := by rw [Finset.sum_pair (by omega)]; rfl rw [if_pos (Or.inr (show b ≤ 0 + d by omega)), zero_add, her', Outcome.neg_eq_loss_iff] rw [valueAux_eq_win_iff (by simp) (by rw [hsum_ac]; omega)] refine ⟨c, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show d ≤ b + c by omega)), (her2 a c (by omega)).2, valueAux_singleton, Outcome.neg_eq_win_iff, if_neg (by omega), if_pos (by omega)] · -- Case 2: `b + c < a + d` and `d < a + b + c`! have hgt_bal : b + c < a + d := by omega by_cases hab_lt : a + b < d · -- Subcase 2a: `a + b < d` -> opening with `a` wins! refine ⟨a, by simp, ?_⟩ unfold moveOutcome have her_a : ({a, b, c, d} : Finset ℕ).erase a = {b, c, d} := by ext x; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_bcd : ({b, c, d} : Finset ℕ).sum id = b + c + d := by rw [Finset.sum_insert (by simp; omega), Finset.sum_pair (by omega)]; simp [id]; omega rw [if_pos (Or.inl rfl), zero_add, her_a, Outcome.neg_eq_win_iff] rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_bcd]; omega)] intro y hy simp only [Finset.mem_insert, Finset.mem_singleton] at hy unfold moveOutcome rcases hy with hyb | hyc | hyd · -- P2 takes `b`: P1 takes `d`, wins `a + d > b + c`! rw [hyb] have her' : ({b, c, d} : Finset ℕ).erase b = {c, d} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_cd : ({c, d} : Finset ℕ).sum id = c + d := by rw [Finset.sum_pair (by omega)]; rfl rw [if_pos (Or.inr (show a ≤ 0 + b by omega)), zero_add, her', Outcome.neg_eq_loss_iff] rw [valueAux_eq_win_iff (by simp) (by rw [hsum_cd]; omega)] refine ⟨d, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show b ≤ a + d by omega)), (her2 c d (by omega)).2, valueAux_singleton, Outcome.neg_eq_win_iff, if_neg (by omega), if_pos (by omega)] · -- P2 takes `c`: P1 takes `d`, wins `a + d > b + c`! rw [hyc] have her' : ({b, c, d} : Finset ℕ).erase c = {b, d} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_bd : ({b, d} : Finset ℕ).sum id = b + d := by rw [Finset.sum_pair (by omega)]; rfl rw [if_pos (Or.inr (show a ≤ 0 + c by omega)), zero_add, her', Outcome.neg_eq_loss_iff] rw [valueAux_eq_win_iff (by simp) (by rw [hsum_bd]; omega)] refine ⟨d, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show c ≤ a + d by omega)), (her2 b d (by omega)).2, valueAux_singleton, Outcome.neg_eq_win_iff, if_neg (by omega), if_pos (by omega)] · -- P2 takes `d`: P1 double-picks `b` (since `a + b < d`) then `c`, winning `a + b + c > d`! rw [hyd] have her' : ({b, c, d} : Finset ℕ).erase d = {b, c} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_bc : ({b, c} : Finset ℕ).sum id = b + c := by rw [Finset.sum_pair (by omega)]; rfl rw [if_pos (Or.inr (show a ≤ 0 + d by omega)), zero_add, her', Outcome.neg_eq_loss_iff] rw [valueAux_eq_win_iff (by simp) (by rw [hsum_bc]; omega)] refine ⟨b, by simp, ?_⟩ unfold moveOutcome rw [if_neg (by simp; omega), (her2 b c (by omega)).1, valueAux_singleton, if_pos (by omega)] · -- Subcase 2b: `d ≤ a + b` -> opening with `d` wins! refine ⟨d, by simp, ?_⟩ unfold moveOutcome rw [if_pos (Or.inl rfl), zero_add, her_d, Outcome.neg_eq_win_iff] rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_abc]; omega)] intro y hy simp only [Finset.mem_insert, Finset.mem_singleton] at hy unfold moveOutcome rcases hy with hya | hyb | hyc · -- P2 takes `a` (behind by `d - a ≤ b`), stays on turn on `{b, c}`: rw [hya] have her' : ({a, b, c} : Finset ℕ).erase a = {b, c} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_bc : ({b, c} : Finset ℕ).sum id = b + c := by rw [Finset.sum_pair (by omega)]; rfl rw [if_neg (by simp; omega), zero_add, her'] rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_bc]; omega)] intro z hz simp only [Finset.mem_insert, Finset.mem_singleton] at hz unfold moveOutcome rcases hz with hzb | hzc · rw [hzb, if_pos (Or.inr (show d ≤ a + b by omega)), (her2 b c (by omega)).1, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] · rw [hzc, if_pos (Or.inr (show d ≤ a + c by omega)), (her2 b c (by omega)).2, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] · -- P2 takes `b` (behind by `d - b ≤ a`), stays on turn on `{a, c}`: rw [hyb] have her' : ({a, b, c} : Finset ℕ).erase b = {a, c} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_ac : ({a, c} : Finset ℕ).sum id = a + c := by rw [Finset.sum_pair (by omega)]; rfl rw [if_neg (by simp; omega), zero_add, her'] rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_ac]; omega)] intro z hz simp only [Finset.mem_insert, Finset.mem_singleton] at hz unfold moveOutcome rcases hz with hza | hzc · rw [hza, if_pos (Or.inr (show d ≤ b + a by omega)), (her2 a c (by omega)).1, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] · rw [hzc, if_pos (Or.inr (show d ≤ b + c by omega)), (her2 a c (by omega)).2, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] · -- P2 takes `c` (behind by `d - c < a`), stays on turn on `{a, b}`: rw [hyc] have her' : ({a, b, c} : Finset ℕ).erase c = {a, b} := by ext z; simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton]; omega have hsum_ab : ({a, b} : Finset ℕ).sum id = a + b := by rw [Finset.sum_pair (by omega)]; rfl rw [if_neg (by simp; omega), zero_add, her'] rw [valueAux_eq_loss_iff (by simp) (by rw [hsum_ab]; omega)] intro z hz simp only [Finset.mem_insert, Finset.mem_singleton] at hz unfold moveOutcome rcases hz with hza | hzb · rw [hza, if_pos (Or.inr (show d ≤ c + a by omega)), (her2 a b (by omega)).1, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] · rw [hzb, if_pos (Or.inr (show d ≤ c + b by omega)), (her2 a b (by omega)).2, valueAux_singleton, Outcome.neg_eq_loss_iff, if_pos (by omega)] /-! ## Section 5: MAIN BREAKTHROUGH — Exact Checkerboard Value Theorem for Geometric Pair Families -/ /-- The disjoint union of consecutive pairs `{a, a + 1}` for `a ∈ L`. -/ def pairSet (L : List ℕ) : Finset ℕ := (L.flatMap (fun a ↦ [a, a + 1])).toFinset /-- A list of pair bases is `PairDisjoint` if any two distinct entries differ by at least 2 (and there are no duplicates), so the pairs `{a, a + 1}` are pairwise disjoint. -/ def PairDisjoint : List ℕ → Prop | [] => True | a :: rest => (∀ b ∈ rest, a + 1 < b ∨ b + 1 < a) ∧ PairDisjoint rest /-- A strictly increasing, geometrically well-separated list of pair bases with slack `M`. Every entry satisfies `a > 3 * M + 4`, and consecutive entries satisfy `b > 2 * a + 3 * M + 4`. -/ def WellSeparated (M : ℕ) : List ℕ → Prop | [] => True | a :: rest => (3 * M + 4 < a) ∧ (∀ b ∈ rest, 2 * a + 3 * M + 4 < b) ∧ WellSeparated M rest /-- The exact parity checkerboard outcome for `r` pairs at gap `g = s_opp - s_me`. -/ def checkerOutcome (r g : ℕ) : Outcome := if r < g then .loss else if (r - g) % 2 = 0 then .draw else .win /-! ### Basic List / Finset Helpers for `pairSet` and `WellSeparated` -/ lemma mem_pairSet_iff {L : List ℕ} {x : ℕ} : x ∈ pairSet L ↔ ∃ a ∈ L, x = a ∨ x = a + 1 := by simp [pairSet] lemma pairSet_nil : pairSet [] = ∅ := rfl lemma pairSet_cons (a : ℕ) (rest : List ℕ) : pairSet (a :: rest) = insert a (insert (a + 1) (pairSet rest)) := by ext x simp only [mem_pairSet_iff, List.mem_cons, Finset.mem_insert] constructor · rintro ⟨b, rfl | hb, h⟩ · rcases h with rfl | rfl <;> simp · exact Or.inr (Or.inr ⟨b, hb, h⟩) · rintro (h | h | ⟨b, hb, h⟩) · exact ⟨a, Or.inl rfl, Or.inl h⟩ · exact ⟨a, Or.inl rfl, Or.inr h⟩ · exact ⟨b, Or.inr hb, h⟩ lemma WellSeparated.pairDisjoint {M : ℕ} {L : List ℕ} (h : WellSeparated M L) : PairDisjoint L := by induction L with | nil => trivial | cons a rest ih => rcases h with ⟨_, hsep, hrest⟩ exact ⟨fun b hb ↦ Or.inl (by have := hsep b hb; omega), ih hrest⟩ lemma WellSeparated.nodup {M : ℕ} {L : List ℕ} (h : WellSeparated M L) : L.Nodup := by induction L with | nil => exact List.nodup_nil | cons a rest ih => rcases h with ⟨_, hsep, hrest⟩ rw [List.nodup_cons] exact ⟨fun ha ↦ by have := hsep a ha; omega, ih hrest⟩ lemma PairDisjoint.nodup {L : List ℕ} (h : PairDisjoint L) : L.Nodup := by induction L with | nil => exact List.nodup_nil | cons a rest ih => rcases h with ⟨hsep, hrest⟩ rw [List.nodup_cons] exact ⟨fun ha ↦ by rcases hsep a ha with h1 | h1 <;> omega, ih hrest⟩ lemma WellSeparated.gt_bound {M : ℕ} {L : List ℕ} (h : WellSeparated M L) : ∀ a ∈ L, 3 * M + 4 < a := by induction L with | nil => intro _ ha; cases ha | cons a rest ih => rcases h with ⟨ha, _, hrest⟩ intro b hb rcases List.mem_cons.1 hb with hba | hb' · rwa [hba] · exact ih hrest b hb' lemma WellSeparated.erase {M : ℕ} {L : List ℕ} (h : WellSeparated M L) (a : ℕ) : WellSeparated M (L.erase a) := by induction L with | nil => trivial | cons b rest ih => rcases h with ⟨hb, hsep, hrest⟩ by_cases hba : b = a · subst hba simpa [List.erase_cons_head] using hrest · rw [List.erase_cons_tail (by simp [hba])] exact ⟨hb, fun c hc ↦ hsep c (List.mem_of_mem_erase hc), ih hrest⟩ lemma PairDisjoint.erase {L : List ℕ} (h : PairDisjoint L) (a : ℕ) : PairDisjoint (L.erase a) := by induction L with | nil => trivial | cons b rest ih => rcases h with ⟨hsep, hrest⟩ by_cases hba : b = a · subst hba simpa [List.erase_cons_head] using hrest · rw [List.erase_cons_tail (by simp [hba])] exact ⟨fun c hc ↦ hsep c (List.mem_of_mem_erase hc), ih hrest⟩ lemma PairDisjoint.sep {L : List ℕ} (h : PairDisjoint L) {a b : ℕ} (ha : a ∈ L) (hb : b ∈ L) (hne : a ≠ b) : a + 1 < b ∨ b + 1 < a := by induction L with | nil => cases ha | cons c rest ih => rcases h with ⟨hsep, hrest⟩ rcases List.mem_cons.1 ha with rfl | ha' <;> rcases List.mem_cons.1 hb with rfl | hb' · exact absurd rfl hne · exact hsep b hb' · exact (hsep a ha').symm · exact ih hrest ha' hb' lemma not_mem_erase_of_nodup {L : List ℕ} (hnd : L.Nodup) (a : ℕ) : a ∉ L.erase a := by induction L with | nil => simp | cons b rest ih => rw [List.nodup_cons] at hnd by_cases hba : b = a · subst hba simpa [List.erase_cons_head] using hnd.1 · rw [List.erase_cons_tail (by simp [hba]), List.mem_cons] rintro (rfl | h) · exact hba rfl · exact ih hnd.2 h lemma pairSet_erase_pair {L : List ℕ} (hpd : PairDisjoint L) {a : ℕ} (ha : a ∈ L) : ((pairSet L).erase a).erase (a + 1) = pairSet (L.erase a) ∧ ((pairSet L).erase (a + 1)).erase a = pairSet (L.erase a) := by have h1 : ((pairSet L).erase a).erase (a + 1) = pairSet (L.erase a) := by ext x simp only [Finset.mem_erase, mem_pairSet_iff] constructor · rintro ⟨hx1, hxa, b, hb, hxb⟩ have hba : b ≠ a := by rintro rfl; rcases hxb with rfl | rfl <;> contradiction exact ⟨b, (List.mem_erase_of_ne hba).2 hb, hxb⟩ · rintro ⟨b, hb, hxb⟩ have hbL : b ∈ L := List.mem_of_mem_erase hb have hba : b ≠ a := by intro heq; subst heq exact not_mem_erase_of_nodup hpd.nodup b hb have hsep := hpd.sep hbL ha hba refine ⟨?_, ?_, b, hbL, hxb⟩ <;> rcases hxb with rfl | rfl <;> rcases hsep with h | h <;> omega exact ⟨h1, by rw [Finset.erase_right_comm, h1]⟩ lemma pairSet_sum_ge_elem {L : List ℕ} {x : ℕ} (hx : x ∈ pairSet L) : x ≤ (pairSet L).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hx lemma pairSet_ne_empty_of_mem {L : List ℕ} {a : ℕ} (ha : a ∈ L) : pairSet L ≠ ∅ := Finset.ne_empty_of_mem (mem_pairSet_iff.2 ⟨a, ha, Or.inl rfl⟩) lemma mem_pairSet_erase_partner {L : List ℕ} {a : ℕ} (ha : a ∈ L) : a + 1 ∈ (pairSet L).erase a ∧ a ∈ (pairSet L).erase (a + 1) := by constructor · exact Finset.mem_erase.2 ⟨by omega, mem_pairSet_iff.2 ⟨a, ha, Or.inr rfl⟩⟩ · exact Finset.mem_erase.2 ⟨by omega, mem_pairSet_iff.2 ⟨a, ha, Or.inl rfl⟩⟩ /-! ### Lemma 5.1: Gap-Exceeds-Pairs Loss Lemma -/ /-- **Gap-Exceeds-Pairs Loss Lemma**: For ANY pairwise-disjoint collection of `r` pairs `P_i = {a_i, a_i + 1}`, if the current player trails by `g = s_opp - s_me` with `r < g` and `∀ a ∈ L, g + r < a`, then the current player **loses immediately** (`valueAux = .loss`). (No geometric separation is needed for this lemma — only the partner-reply invariant!) -/ theorem valueAux_pairSet_loss_of_gap_gt_len : ∀ (r : ℕ) (L : List ℕ), L.length = r → PairDisjoint L → ∀ (s_me s_opp : ℕ), s_me ≤ s_opp → r < s_opp - s_me → (∀ a ∈ L, (s_opp - s_me) + r < a) → valueAux (pairSet L) s_me s_opp false = .loss := by intro r induction r with | zero => intro L hlen _ s_me s_opp hle hgt _ have hL : L = [] := List.eq_nil_of_length_eq_zero hlen subst hL rw [pairSet_nil, valueAux_empty] split_ifs <;> first | rfl | omega | succ r ih => intro L hlen hpd s_me s_opp hle hgt hmin have hneL : L ≠ [] := by intro h; subst h; simp at hlen obtain ⟨a0, ha0⟩ : ∃ a, a ∈ L := List.exists_mem_of_ne_nil L hneL have hne : pairSet L ≠ ∅ := pairSet_ne_empty_of_mem ha0 by_cases hsum : s_me + (pairSet L).sum id < s_opp · exact valueAux_loss_of_sum_lt hne hsum · rw [valueAux_eq_loss_iff hne (by omega)] intro x hx rcases mem_pairSet_iff.1 hx with ⟨a, ha, hxa | hxa⟩ · rw [hxa] unfold moveOutcome have ha_gt : s_opp ≤ s_me + a := by have := hmin a ha; omega rw [if_pos (Or.inr ha_gt), Outcome.neg_eq_loss_iff] have hpart : a + 1 ∈ (pairSet L).erase a := (mem_pairSet_erase_partner ha).1 have hne_er : (pairSet L).erase a ≠ ∅ := Finset.ne_empty_of_mem hpart have hsum_er : s_me + a ≤ s_opp + ((pairSet L).erase a).sum id := by have h1 : a + 1 ≤ ((pairSet L).erase a).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hpart omega rw [valueAux_eq_win_iff hne_er hsum_er] refine ⟨a + 1, hpart, ?_⟩ unfold moveOutcome have hcatch : s_me + a ≤ s_opp + (a + 1) := by omega rw [if_pos (Or.inr hcatch), (pairSet_erase_pair hpd ha).1, Outcome.neg_eq_win_iff] have hlen' : (L.erase a).length = r := by rw [List.length_erase_of_mem ha, hlen]; omega apply ih (L.erase a) hlen' (hpd.erase a) (s_me + a) (s_opp + (a + 1)) (by omega) (by omega) intro b hb have := hmin b (List.mem_of_mem_erase hb) omega · rw [hxa] unfold moveOutcome have ha_gt : s_opp ≤ s_me + (a + 1) := by have := hmin a ha; omega rw [if_pos (Or.inr ha_gt), Outcome.neg_eq_loss_iff] have hpart : a ∈ (pairSet L).erase (a + 1) := (mem_pairSet_erase_partner ha).2 have hne_er : (pairSet L).erase (a + 1) ≠ ∅ := Finset.ne_empty_of_mem hpart have hsum_er : s_me + (a + 1) ≤ s_opp + ((pairSet L).erase (a + 1)).sum id := by have h1 : a ≤ ((pairSet L).erase (a + 1)).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hpart omega rw [valueAux_eq_win_iff hne_er hsum_er] refine ⟨a, hpart, ?_⟩ unfold moveOutcome have hcatch : s_me + (a + 1) ≤ s_opp + a := by omega rw [if_pos (Or.inr hcatch), (pairSet_erase_pair hpd ha).2, Outcome.neg_eq_win_iff] have hlen' : (L.erase a).length = r := by rw [List.length_erase_of_mem ha, hlen]; omega apply ih (L.erase a) hlen' (hpd.erase a) (s_me + (a + 1)) (s_opp + a) (by omega) (by omega) intro b hb have := hmin b (List.mem_of_mem_erase hb) omega /-! ### Main Induction: Exact Checkerboard Theorem via Double-Pick Knockout -/ /-- **Theorem 8 (Exact Checkerboard Value Theorem for Geometric Pair Families)**: For every slack $M$, every `WellSeparated M` list $L$ of length $r \le M$, and every score state `s_me ≤ s_opp` with gap `g = s_opp - s_me` satisfying `∀ a ∈ L, g + r < a`, the exact game-theoretic value is given by the parity checkerboard: `valueAux (pairSet L) s_me s_opp false = checkerOutcome r g`. -/ theorem valueAux_pairSet_exact (M : ℕ) : ∀ (r : ℕ), r ≤ M → ∀ (L : List ℕ), L.length = r → WellSeparated M L → ∀ (s_me s_opp : ℕ), s_me ≤ s_opp → (∀ a ∈ L, (s_opp - s_me) + r < a) → valueAux (pairSet L) s_me s_opp false = checkerOutcome r (s_opp - s_me) := by intro r induction r with | zero => intro _ L hlen _ s_me s_opp hle _ have hL : L = [] := List.eq_nil_of_length_eq_zero hlen subst hL rw [pairSet_nil, valueAux_empty] unfold checkerOutcome split_ifs <;> first | rfl | omega | succ r ih => intro hrM L hlen hws s_me s_opp hle hmin have hpd : PairDisjoint L := hws.pairDisjoint -- Case 1: Gap exceeds `r + 1` -> immediate loss by Lemma 5.1! by_cases hgt : r + 1 < s_opp - s_me · unfold checkerOutcome rw [if_pos hgt] exact valueAux_pairSet_loss_of_gap_gt_len (r + 1) L hlen hpd s_me s_opp hle hgt hmin -- Now `g = s_opp - s_me ≤ r + 1`! -- Decompose `L = a₁ :: rest` (since `L.length = r + 1`). cases L with | nil => simp at hlen | cons a₁ rest => have hws_L : WellSeparated M (a₁ :: rest) := hws have hlen_rest : rest.length = r := by simpa using hlen rcases hws with ⟨ha₁_gt, hsep_a₁, hws_rest⟩ have hne : pairSet (a₁ :: rest) ≠ ∅ := pairSet_ne_empty_of_mem (List.mem_cons_self ..) have hsum_ge : s_opp ≤ s_me + (pairSet (a₁ :: rest)).sum id := by have h1 : a₁ ≤ (pairSet (a₁ :: rest)).sum id := pairSet_sum_ge_elem (mem_pairSet_iff.2 ⟨a₁, List.mem_cons_self .., Or.inl rfl⟩) have := hmin a₁ (List.mem_cons_self ..) omega -- Helper: Broken-Smallest Double-Pick Knockout on `insert u (pairSet rest)`! have hknockout : ∀ (u s_a s_b : ℕ), (u = a₁ ∨ u = a₁ + 1) → s_a ≤ s_b → u ≤ (s_b - s_a) + r → s_b - s_a ≤ u + 1 → ∀ y ∈ pairSet rest, moveOutcome (insert u (pairSet rest)) s_a s_b false y = .loss := by intro u s_a s_b hu hsa_le hlow hhigh y hy rcases mem_pairSet_iff.1 hy with ⟨b, hb, hyb | hyb⟩ · rw [hyb] have hb_gt : 2 * a₁ + 3 * M + 4 < b := hsep_a₁ b hb have hu_not_rest : u ∉ pairSet rest := by intro hmem rcases mem_pairSet_iff.1 hmem with ⟨c, hc, huc⟩ have := hsep_a₁ c hc omega have her_b : (insert u (pairSet rest)).erase b = insert u ((pairSet rest).erase b) := by ext z; simp only [Finset.mem_erase, Finset.mem_insert] constructor · rintro ⟨hzb, rfl | hz⟩ · exact Or.inl rfl · exact Or.inr ⟨hzb, hz⟩ · rintro (rfl | ⟨hzb, hz⟩) · exact ⟨by omega, Or.inl rfl⟩ · exact ⟨hzb, Or.inr hz⟩ unfold moveOutcome have hcatch1 : s_b ≤ s_a + b := by omega rw [if_pos (Or.inr hcatch1), her_b, Outcome.neg_eq_loss_iff] have hu_in : u ∈ insert u ((pairSet rest).erase b) := Finset.mem_insert_self .. have hpart_b : b + 1 ∈ (pairSet rest).erase b := (mem_pairSet_erase_partner hb).1 have hsum_bob : s_a + b ≤ s_b + (insert u ((pairSet rest).erase b)).sum id := by have h1 : b + 1 ≤ (insert u ((pairSet rest).erase b)).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) (Finset.mem_insert_of_mem hpart_b) omega rw [valueAux_eq_win_iff (Finset.insert_ne_empty _ _) hsum_bob] refine ⟨u, hu_in, ?_⟩ unfold moveOutcome have hstill : ¬ (s_a + b ≤ s_b + u) := by omega have her_u : (insert u ((pairSet rest).erase b)).erase u = (pairSet rest).erase b := Finset.erase_insert (fun h ↦ hu_not_rest (Finset.mem_of_mem_erase h)) rw [if_neg (by simp [hstill]), her_u] have hsum_bob2 : s_a + b ≤ (s_b + u) + ((pairSet rest).erase b).sum id := by have h1 : b + 1 ≤ ((pairSet rest).erase b).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hpart_b omega rw [valueAux_eq_win_iff (Finset.ne_empty_of_mem hpart_b) hsum_bob2] refine ⟨b + 1, hpart_b, ?_⟩ unfold moveOutcome have hcatch2 : s_a + b ≤ s_b + u + (b + 1) := by omega rw [if_pos (Or.inr hcatch2), (pairSet_erase_pair hws_rest.pairDisjoint hb).1, Outcome.neg_eq_win_iff] have hlen_er : (rest.erase b).length = r - 1 := by rw [List.length_erase_of_mem hb, hlen_rest] apply valueAux_pairSet_loss_of_gap_gt_len (r - 1) (rest.erase b) hlen_er (hws_rest.pairDisjoint.erase b) (s_a + b) (s_b + u + (b + 1)) (by omega) (by omega) intro c hc have := hsep_a₁ c (List.mem_of_mem_erase hc) omega · rw [hyb] have hb_gt : 2 * a₁ + 3 * M + 4 < b := hsep_a₁ b hb have hu_not_rest : u ∉ pairSet rest := by intro hmem rcases mem_pairSet_iff.1 hmem with ⟨c, hc, huc⟩ have := hsep_a₁ c hc omega have her_b1 : (insert u (pairSet rest)).erase (b + 1) = insert u ((pairSet rest).erase (b + 1)) := by ext z; simp only [Finset.mem_erase, Finset.mem_insert] constructor · rintro ⟨hzb, rfl | hz⟩ · exact Or.inl rfl · exact Or.inr ⟨hzb, hz⟩ · rintro (rfl | ⟨hzb, hz⟩) · exact ⟨by omega, Or.inl rfl⟩ · exact ⟨hzb, Or.inr hz⟩ unfold moveOutcome have hcatch1 : s_b ≤ s_a + (b + 1) := by omega rw [if_pos (Or.inr hcatch1), her_b1, Outcome.neg_eq_loss_iff] have hu_in : u ∈ insert u ((pairSet rest).erase (b + 1)) := Finset.mem_insert_self .. have hpart_b : b ∈ (pairSet rest).erase (b + 1) := (mem_pairSet_erase_partner hb).2 have hsum_bob : s_a + (b + 1) ≤ s_b + (insert u ((pairSet rest).erase (b + 1))).sum id := by have h3 : u + b ≤ (insert u ((pairSet rest).erase (b + 1))).sum id := by rw [Finset.sum_insert (fun h ↦ hu_not_rest (Finset.mem_of_mem_erase h))] have h4 : b ≤ ((pairSet rest).erase (b + 1)).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hpart_b change u + b ≤ u + ((pairSet rest).erase (b + 1)).sum id omega omega rw [valueAux_eq_win_iff (Finset.insert_ne_empty _ _) hsum_bob] refine ⟨u, hu_in, ?_⟩ unfold moveOutcome have hstill : ¬ (s_a + (b + 1) ≤ s_b + u) := by omega have her_u : (insert u ((pairSet rest).erase (b + 1))).erase u = (pairSet rest).erase (b + 1) := Finset.erase_insert (fun h ↦ hu_not_rest (Finset.mem_of_mem_erase h)) rw [if_neg (by simp [hstill]), her_u] have hsum_bob2 : s_a + (b + 1) ≤ (s_b + u) + ((pairSet rest).erase (b + 1)).sum id := by have h1 : b ≤ ((pairSet rest).erase (b + 1)).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hpart_b omega rw [valueAux_eq_win_iff (Finset.ne_empty_of_mem hpart_b) hsum_bob2] refine ⟨b, hpart_b, ?_⟩ unfold moveOutcome have hcatch2 : s_a + (b + 1) ≤ s_b + u + b := by omega rw [if_pos (Or.inr hcatch2), (pairSet_erase_pair hws_rest.pairDisjoint hb).2, Outcome.neg_eq_win_iff] have hlen_er : (rest.erase b).length = r - 1 := by rw [List.length_erase_of_mem hb, hlen_rest] apply valueAux_pairSet_loss_of_gap_gt_len (r - 1) (rest.erase b) hlen_er (hws_rest.pairDisjoint.erase b) (s_a + (b + 1)) (s_b + u + b) (by omega) (by omega) intro c hc have := hsep_a₁ c (List.mem_of_mem_erase hc) omega have ha1_not_rest : a₁ ∉ pairSet rest := by intro h; rcases mem_pairSet_iff.1 h with ⟨c, hc, h1⟩; have := hsep_a₁ c hc; omega have ha1p1_not_rest : a₁ + 1 ∉ pairSet rest := by intro h; rcases mem_pairSet_iff.1 h with ⟨c, hc, h1⟩; have := hsep_a₁ c hc; omega have her_a1 : (pairSet (a₁ :: rest)).erase a₁ = insert (a₁ + 1) (pairSet rest) := by rw [pairSet_cons, Finset.erase_insert (by simp [ha1_not_rest])] have her_a1p1 : (pairSet (a₁ :: rest)).erase (a₁ + 1) = insert a₁ (pairSet rest) := by rw [pairSet_cons, Finset.insert_comm, Finset.erase_insert (by simp [ha1p1_not_rest])] unfold checkerOutcome rw [if_neg hgt] split_ifs with hpar · -- Target is `.draw` (`(r + 1 - g) % 2 = 0`): prove `≠ .win` and `≠ .loss`! apply valueAux_eq_draw_of_ne_win_ne_loss · rw [valueAux_ne_win_iff hne hsum_ge] intro x hx rcases mem_pairSet_iff.1 hx with ⟨a, ha, hxa | hxa⟩ · rw [hxa] unfold moveOutcome have hcatch : s_opp ≤ s_me + a := by have := hmin a ha; omega rw [if_pos (Or.inr hcatch), ne_eq, Outcome.neg_eq_win_iff] have hpart : a + 1 ∈ (pairSet (a₁ :: rest)).erase a := (mem_pairSet_erase_partner ha).1 have hsum_b : s_me + a ≤ s_opp + ((pairSet (a₁ :: rest)).erase a).sum id := by have h1 : a + 1 ≤ ((pairSet (a₁ :: rest)).erase a).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hpart omega rw [← ne_eq, valueAux_ne_loss_iff (Finset.ne_empty_of_mem hpart) hsum_b] refine ⟨a + 1, hpart, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show s_me + a ≤ s_opp + (a + 1) by omega)), (pairSet_erase_pair hpd ha).1, ne_eq, Outcome.neg_eq_loss_iff] have hlen' : ((a₁ :: rest).erase a).length = r := by rw [List.length_erase_of_mem ha, hlen]; omega have hval := ih (by omega) ((a₁ :: rest).erase a) hlen' (hws_L.erase a) (s_me + a) (s_opp + (a + 1)) (by omega) (fun b hb ↦ by have := hmin b (List.mem_of_mem_erase hb); omega) rw [hval] unfold checkerOutcome split_ifs <;> first | decide | omega · rw [hxa] unfold moveOutcome have hcatch : s_opp ≤ s_me + (a + 1) := by have := hmin a ha; omega rw [if_pos (Or.inr hcatch), ne_eq, Outcome.neg_eq_win_iff] have hpart : a ∈ (pairSet (a₁ :: rest)).erase (a + 1) := (mem_pairSet_erase_partner ha).2 have hsum_b : s_me + (a + 1) ≤ s_opp + ((pairSet (a₁ :: rest)).erase (a + 1)).sum id := by have h1 : a ≤ ((pairSet (a₁ :: rest)).erase (a + 1)).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hpart by_cases hgap0 : s_me = s_opp · have hlen' : ((a₁ :: rest).erase a).length = r := by rw [List.length_erase_of_mem ha, hlen]; omega have hr_pos : 0 < r := by omega obtain ⟨b, hb⟩ := List.exists_mem_of_length_pos (by omega : 0 < ((a₁ :: rest).erase a).length) have hb_in : b ∈ ((pairSet (a₁ :: rest)).erase (a + 1)).erase a := by rw [(pairSet_erase_pair hpd ha).2] exact mem_pairSet_iff.2 ⟨b, hb, Or.inl rfl⟩ have hb_gt : 1 ≤ b := by have := hws_L.gt_bound b (List.mem_of_mem_erase hb) omega have hsum2 : (((pairSet (a₁ :: rest)).erase (a + 1)).erase a).sum id + a = ((pairSet (a₁ :: rest)).erase (a + 1)).sum id := Finset.sum_erase_add ((pairSet (a₁ :: rest)).erase (a + 1)) id hpart have hb_le : b ≤ (((pairSet (a₁ :: rest)).erase (a + 1)).erase a).sum id := Finset.single_le_sum (f := id) (fun _ _ ↦ Nat.zero_le _) hb_in omega · omega rw [← ne_eq, valueAux_ne_loss_iff (Finset.ne_empty_of_mem hpart) hsum_b] refine ⟨a, hpart, ?_⟩ unfold moveOutcome by_cases hgap0 : s_me = s_opp · rw [if_neg (by simp; omega), (pairSet_erase_pair hpd ha).2] have hlen' : ((a₁ :: rest).erase a).length = r := by rw [List.length_erase_of_mem ha, hlen]; omega have hval := ih (by omega) ((a₁ :: rest).erase a) hlen' (hws_L.erase a) (s_opp + a) (s_me + (a + 1)) (by omega) (fun b hb ↦ by have := hmin b (List.mem_of_mem_erase hb); omega) rw [hval] unfold checkerOutcome split_ifs <;> first | decide | omega · rw [if_pos (Or.inr (show s_me + (a + 1) ≤ s_opp + a by omega)), (pairSet_erase_pair hpd ha).2, ne_eq, Outcome.neg_eq_loss_iff] have hlen' : ((a₁ :: rest).erase a).length = r := by rw [List.length_erase_of_mem ha, hlen]; omega have hval := ih (by omega) ((a₁ :: rest).erase a) hlen' (hws_L.erase a) (s_me + (a + 1)) (s_opp + a) (by omega) (fun b hb ↦ by have := hmin b (List.mem_of_mem_erase hb); omega) rw [hval] unfold checkerOutcome split_ifs <;> first | decide | omega · -- Lower bound (`≠ .loss`): Alice picks `a₁ + 1` -> Bob faces Broken-Smallest `insert a₁ (pairSet rest)`! rw [valueAux_ne_loss_iff hne hsum_ge] refine ⟨a₁ + 1, mem_pairSet_iff.2 ⟨a₁, List.mem_cons_self .., Or.inr rfl⟩, ?_⟩ unfold moveOutcome have hcatch : s_opp ≤ s_me + (a₁ + 1) := by have := hmin a₁ (List.mem_cons_self ..); omega rw [if_pos (Or.inr hcatch), her_a1p1, ne_eq, Outcome.neg_eq_loss_iff] by_cases hsum_b : s_opp + (insert a₁ (pairSet rest)).sum id < s_me + (a₁ + 1) · rw [valueAux_loss_of_sum_lt (Finset.insert_ne_empty _ _) hsum_b]; decide · rw [← ne_eq, valueAux_ne_win_iff (Finset.insert_ne_empty _ _) (by omega)] intro y hy rcases Finset.mem_insert.1 hy with hy1 | hy_rest · rw [hy1] unfold moveOutcome have her_u : (insert a₁ (pairSet rest)).erase a₁ = pairSet rest := Finset.erase_insert ha1_not_rest by_cases hgap0 : s_me = s_opp · rw [if_neg (by simp; omega), her_u] have hval := ih (by omega) rest hlen_rest hws_rest (s_opp + a₁) (s_me + (a₁ + 1)) (by omega) (fun b hb ↦ by have := hsep_a₁ b hb; omega) rw [hval] unfold checkerOutcome split_ifs <;> first | decide | omega · rw [if_pos (Or.inr (show s_me + (a₁ + 1) ≤ s_opp + a₁ by omega)), her_u, ne_eq, Outcome.neg_eq_win_iff] have hval := ih (by omega) rest hlen_rest hws_rest (s_me + (a₁ + 1)) (s_opp + a₁) (by omega) (fun b hb ↦ by have := hsep_a₁ b hb; omega) rw [hval] unfold checkerOutcome split_ifs <;> first | decide | omega · rw [hknockout a₁ s_opp (s_me + (a₁ + 1)) (Or.inl rfl) (by omega) (by omega) (by omega) y hy_rest] decide · -- Target is `.win` (`(r + 1 - g) % 2 = 1`): exhibit a winning move for Alice! rw [valueAux_eq_win_iff hne hsum_ge] by_cases hgap0 : s_me = s_opp · by_cases hr0 : r = 0 · -- `r = 0`, `rest = []`, `s_me = s_opp`: Alice picks `a₁ + 1` -> Bob has `{a₁}` and loses! have hrest_nil : rest = [] := List.eq_nil_of_length_eq_zero (by omega) refine ⟨a₁ + 1, mem_pairSet_iff.2 ⟨a₁, List.mem_cons_self .., Or.inr rfl⟩, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show s_opp ≤ s_me + (a₁ + 1) by omega)), her_a1p1, hrest_nil, pairSet_nil, Outcome.neg_eq_win_iff] have hsing : insert a₁ (∅ : Finset ℕ) = {a₁} := rfl rw [hsing, valueAux_singleton] rw [if_neg (by omega), if_pos (by omega)] · -- `r ≥ 2` (even and nonzero), `s_me = s_opp`: Alice picks `a₁`! refine ⟨a₁, mem_pairSet_iff.2 ⟨a₁, List.mem_cons_self .., Or.inl rfl⟩, ?_⟩ unfold moveOutcome rw [if_pos (Or.inr (show s_opp ≤ s_me + a₁ by omega)), her_a1, Outcome.neg_eq_win_iff] by_cases hsum_b : s_opp + (insert (a₁ + 1) (pairSet rest)).sum id < s_me + a₁ · exact valueAux_loss_of_sum_lt (Finset.insert_ne_empty _ _) hsum_b · rw [valueAux_eq_loss_iff (Finset.insert_ne_empty _ _) (by omega)] intro y hy rcases Finset.mem_insert.1 hy with hy1 | hy_rest · rw [hy1] unfold moveOutcome have her_u : (insert (a₁ + 1) (pairSet rest)).erase (a₁ + 1) = pairSet rest := Finset.erase_insert ha1p1_not_rest rw [if_pos (Or.inr (show s_me + a₁ ≤ s_opp + (a₁ + 1) by omega)), her_u, Outcome.neg_eq_loss_iff] have hval := ih (by omega) rest hlen_rest hws_rest (s_me + a₁) (s_opp + (a₁ + 1)) (by omega) (fun b hb ↦ by have := hsep_a₁ b hb; omega) rw [hval] unfold checkerOutcome split_ifs <;> first | rfl | omega · exact hknockout (a₁ + 1) s_opp (s_me + a₁) (Or.inr rfl) (by omega) (by omega) (by omega) y hy_rest · refine ⟨a₁ + 1, mem_pairSet_iff.2 ⟨a₁, List.mem_cons_self .., Or.inr rfl⟩, ?_⟩ unfold moveOutcome have hcatch : s_opp ≤ s_me + (a₁ + 1) := by have := hmin a₁ (List.mem_cons_self ..); omega rw [if_pos (Or.inr hcatch), her_a1p1, Outcome.neg_eq_win_iff] by_cases hsum_b : s_opp + (insert a₁ (pairSet rest)).sum id < s_me + (a₁ + 1) · exact valueAux_loss_of_sum_lt (Finset.insert_ne_empty _ _) hsum_b · rw [valueAux_eq_loss_iff (Finset.insert_ne_empty _ _) (by omega)] intro y hy rcases Finset.mem_insert.1 hy with hy1 | hy_rest · rw [hy1] unfold moveOutcome have her_u : (insert a₁ (pairSet rest)).erase a₁ = pairSet rest := Finset.erase_insert ha1_not_rest rw [if_pos (Or.inr (show s_me + (a₁ + 1) ≤ s_opp + a₁ by omega)), her_u, Outcome.neg_eq_loss_iff] have hval := ih (by omega) rest hlen_rest hws_rest (s_me + (a₁ + 1)) (s_opp + a₁) (by omega) (fun b hb ↦ by have := hsep_a₁ b hb; omega) rw [hval] unfold checkerOutcome split_ifs <;> first | rfl | omega · exact hknockout a₁ s_opp (s_me + (a₁ + 1)) (Or.inl rfl) (by omega) (by omega) (by omega) y hy_rest /-- From `s_me = s_opp = 0`, `first = true` and `first = false` produce the exact same game value whenever every element is positive! -/ theorem value_eq_valueAux_false {S : Finset ℕ} : value S = valueAux S 0 0 false := by by_cases hempty : S = ∅ · subst hempty; simp [value] · unfold value rw [valueAux_eq_best_moveOutcome hempty (Nat.zero_le _), valueAux_eq_best_moveOutcome hempty (Nat.zero_le _)] exact congrArg Outcome.best (List.map_congr_left fun ⟨x, _⟩ _ ↦ by simp [moveOutcome]) /-- **Corollary 1 (Exact Value of Geometric Pair Sets for `CatchUp.value`)**: For every `WellSeparated L.length L`, `value (pairSet L) = if Even L.length then .draw else .win`. -/ theorem value_pairSet_exact {L : List ℕ} (hws : WellSeparated L.length L) : value (pairSet L) = if Even L.length then .draw else .win := by rw [value_eq_valueAux_false] have h := valueAux_pairSet_exact L.length L.length le_rfl L rfl hws 0 0 le_rfl (fun a ha ↦ by have := hws.gt_bound a ha; omega) rw [h] unfold checkerOutcome simp only [Nat.sub_zero, Nat.not_lt_zero, ↓reduceIte, Nat.even_iff] /-- **Corollary 2 (Scaled Even Geometric Pair Sets Always Draw — Arbitrary Size $4m$, Step $d \ge 1$)**: -/ theorem value_scaledPairSet_even_eq_draw {L : List ℕ} {d : ℕ} (hd : 0 < d) (hws : WellSeparated L.length L) (heven : Even L.length) : value ((pairSet L).image (d * ·)) = .draw := by rw [value_image_mul hd, value_pairSet_exact hws, if_pos heven] /-- **Corollary 3 (Scaled Odd Geometric Pair Sets Always Win — Arbitrary Size $4m + 2$, Step $d \ge 1$)**: -/ theorem value_scaledPairSet_odd_eq_win {L : List ℕ} {d : ℕ} (hd : 0 < d) (hws : WellSeparated L.length L) (hodd : Odd L.length) : value ((pairSet L).image (d * ·)) = .win := by rw [value_image_mul hd, value_pairSet_exact hws, if_neg (Nat.not_even_iff_odd.2 hodd)] /-! ### Explicit Closed-Form Infinite Family -/ /-- Explicit geometric base sequence of length `r`: `a_j = (3 * M + 5) * 3 ^ j`. -/ def geomList (M : ℕ) : ℕ → ℕ → List ℕ | 0, _ => [] | r + 1, start => start :: geomList M r (3 * start) lemma geomList_length (M r start : ℕ) : (geomList M r start).length = r := by induction r generalizing start with | zero => rfl | succ r ih => simp [geomList, ih] lemma geomList_mem_ge (M r start : ℕ) : ∀ b ∈ geomList M r start, start ≤ b := by induction r generalizing start with | zero => intro _ hb; cases hb | succ r ih => intro b hb rcases List.mem_cons.1 hb with rfl | hb' · exact le_rfl · have := ih (3 * start) b hb' omega lemma geomList_wellSeparated (M r start : ℕ) (hstart : 3 * M + 4 < start) : WellSeparated M (geomList M r start) := by induction r generalizing start with | zero => trivial | succ r ih => refine ⟨hstart, ?_, ih (3 * start) (by omega)⟩ intro b hb have := geomList_mem_ge M r (3 * start) b hb omega /-- Explicit $2r$-element geometric pair set with step $d$: `S(r, d) = ⋃_{j=0}^{r-1} {d * (3r + 5) * 3^j, d * ((3r + 5) * 3^j + 1)}`. -/ def explicitGeomSet (r d : ℕ) : Finset ℕ := (pairSet (geomList r r (3 * r + 5))).image (d * ·) /-- **Explicit Infinite Draw Family (Size $4m$ for every $m \ge 0$, every step $d \ge 1$)**: -/ theorem value_explicitGeomSet_even_draw (m d : ℕ) (hd : 0 < d) : value (explicitGeomSet (2 * m) d) = .draw := by unfold explicitGeomSet have hlen : (geomList (2 * m) (2 * m) (3 * (2 * m) + 5)).length = 2 * m := geomList_length .. have hws : WellSeparated (geomList (2 * m) (2 * m) (3 * (2 * m) + 5)).length (geomList (2 * m) (2 * m) (3 * (2 * m) + 5)) := by rw [hlen]; exact geomList_wellSeparated (2 * m) (2 * m) (3 * (2 * m) + 5) (by omega) exact value_scaledPairSet_even_eq_draw hd hws (by rw [hlen]; exact ⟨m, by omega⟩) /-- **Explicit Infinite Win Family (Size $4m + 2$ for every $m \ge 0$, every step $d \ge 1$)**: -/ theorem value_explicitGeomSet_odd_win (m d : ℕ) (hd : 0 < d) : value (explicitGeomSet (2 * m + 1) d) = .win := by unfold explicitGeomSet have hlen : (geomList (2 * m + 1) (2 * m + 1) (3 * (2 * m + 1) + 5)).length = 2 * m + 1 := geomList_length .. have hws : WellSeparated (geomList (2 * m + 1) (2 * m + 1) (3 * (2 * m + 1) + 5)).length (geomList (2 * m + 1) (2 * m + 1) (3 * (2 * m + 1) + 5)) := by rw [hlen]; exact geomList_wellSeparated (2 * m + 1) (2 * m + 1) (3 * (2 * m + 1) + 5) (by omega) exact value_scaledPairSet_odd_eq_win hd hws (by rw [hlen]; exact ⟨m, by omega⟩) /-! ## Section 6: Direct Verification of Small Catch-Up Conjecture Cases -/ theorem value_Icc_zero : value (Finset.Icc 1 0) = .draw := by simp [value] theorem value_Icc_one : value (Finset.Icc 1 1) = .win := by have h : Finset.Icc 1 1 = {1} := by decide rw [h, value, valueAux_singleton]; decide theorem value_Icc_two : value (Finset.Icc 1 2) = .win := by have h : Finset.Icc 1 2 = {1, 2} := by decide rw [h] exact value_eq_win_of_dominant_max (M := 2) (by decide) (by decide) theorem value_Icc_three : value (Finset.Icc 1 3) = .draw := by have h : Finset.Icc 1 3 = {1, 2, 3} := by decide rw [h] simpa using value_three_elements (a := 1) (b := 2) (c := 3) (by decide) (by decide) (by decide) theorem value_Icc_four : value (Finset.Icc 1 4) = .draw := by have h : Finset.Icc 1 4 = {1, 2, 3, 4} := by decide rw [h] exact value_four_balanced (a := 1) (b := 2) (c := 3) (d := 4) (by decide) (by decide) (by decide) (by decide) (by decide) end CatchUp /-! ## Section 7: Axiom Audit -/ #print axioms CatchUp.valueAux_add_right #print axioms CatchUp.value_image_mul #print axioms CatchUp.value_ne_draw_of_odd_sum #print axioms CatchUp.value_Icc_ne_draw_of_odd_triangular #print axioms CatchUp.value_eq_win_of_dominant_max #print axioms CatchUp.value_eq_draw_of_exact_sum_max #print axioms CatchUp.value_three_elements #print axioms CatchUp.value_four_balanced #print axioms CatchUp.value_four_ap #print axioms CatchUp.value_four_complete #print axioms CatchUp.valueAux_pairSet_loss_of_gap_gt_len #print axioms CatchUp.valueAux_pairSet_exact #print axioms CatchUp.value_pairSet_exact #print axioms CatchUp.value_scaledPairSet_even_eq_draw #print axioms CatchUp.value_scaledPairSet_odd_eq_win #print axioms CatchUp.value_explicitGeomSet_even_draw #print axioms CatchUp.value_explicitGeomSet_odd_win #print axioms CatchUp.value_Icc_three #print axioms CatchUp.value_Icc_four